mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 08:39:27 +00:00
Add packages to plugins
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import org.apollo.game.model.*
|
||||
package org.apollo.game.plugin.entity.spawn
|
||||
|
||||
import org.apollo.game.model.Animation
|
||||
import org.apollo.game.model.Direction
|
||||
import org.apollo.game.model.Graphic
|
||||
import org.apollo.game.model.Position
|
||||
|
||||
data class Spawn(val id: Int?, val name: String, val position: Position, val facing: Direction,
|
||||
val spawnAnimation: Animation? = null,
|
||||
val spawnGraphic: Graphic? = null)
|
||||
val spawnAnimation: Animation? = null, val spawnGraphic: Graphic? = null)
|
||||
|
||||
object Spawns {
|
||||
val list = mutableListOf<Spawn>()
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.game.model.entity.Npc
|
||||
import org.apollo.game.plugin.entity.spawn.Spawns
|
||||
import org.apollo.game.plugin.util.lookup.lookup_npc
|
||||
|
||||
start { world ->
|
||||
Spawns.list.forEach {
|
||||
val definition = if (it.id != null) NpcDefinition.lookup(it.id!!) else lookup_npc(it.name)
|
||||
if (definition == null) {
|
||||
val definition = it.id?.let { NpcDefinition.lookup(it) } ?: lookup_npc(it.name) ?:
|
||||
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)
|
||||
}
|
||||
it.spawnAnimation?.let(npc::playAnimation)
|
||||
it.spawnGraphic?.let(npc::playGraphic)
|
||||
|
||||
world.register(npc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user