mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Reorganize project sources from src/main to src/main/java
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.game.model.*
|
||||
import org.apollo.game.model.entity.Npc
|
||||
|
||||
data class Spawn(val id: Int?, val name: String, val position: Position, val facing: Direction,
|
||||
val spawnAnimation: Animation? = null,
|
||||
val spawnGraphic: Graphic? = null)
|
||||
|
||||
object Spawns {
|
||||
val list = mutableListOf<Spawn>()
|
||||
}
|
||||
|
||||
fun npc_spawn(name: String, x: Int, y: Int, id: Int? = null) {
|
||||
Spawns.list.add(Spawn(id, name, Position(x, y), Direction.NORTH))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.game.model.entity.Npc
|
||||
|
||||
start {
|
||||
Spawns.list.forEach {
|
||||
val definition = if (it.id != null) NpcDefinition.lookup(it.id) else lookup_npc(it.name)
|
||||
if (definition == null) {
|
||||
throw IllegalArgumentException("Invalid NPC name or ID ${it.name}, ${it.id}")
|
||||
}
|
||||
|
||||
val npc = Npc(world, definition.id, it.position)
|
||||
npc.turnTo(it.position.step(1, it.facing))
|
||||
|
||||
if (it.spawnAnimation != null) {
|
||||
npc.playAnimation(it.spawnAnimation)
|
||||
}
|
||||
|
||||
if (it.spawnGraphic != null) {
|
||||
npc.playGraphic(it.spawnGraphic)
|
||||
}
|
||||
|
||||
world.register(npc)
|
||||
}
|
||||
}
|
||||
|
||||
stop {
|
||||
}
|
||||
Reference in New Issue
Block a user