mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-15 19:10:18 -07:00
Redid shooting star option handling into listeners
This commit is contained in:
parent
3f204cf583
commit
71cea84609
4 changed files with 20 additions and 49 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package rs09.game.content.global.worldevents.holiday
|
||||
package rs09.game.content.global.worldevents.holiday.halloween
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.GroundItemManager
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package rs09.game.content.global.worldevents.holiday
|
||||
package rs09.game.content.global.worldevents.holiday.halloween
|
||||
|
||||
import core.game.content.dialogue.DialoguePlugin
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
import core.game.node.entity.combat.ImpactHandler
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.content.dialogue.DialoguePlugin
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
|
||||
class GrimDialogue(player: Player? = null) : DialoguePlugin(player){
|
||||
var firstSpeak = true
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package rs09.game.content.global.worldevents.holiday
|
||||
package rs09.game.content.global.worldevents.holiday.halloween
|
||||
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.world.map.Location
|
||||
|
|
@ -1,59 +1,30 @@
|
|||
package rs09.game.content.global.worldevents.shootingstar
|
||||
|
||||
import core.cache.def.impl.ObjectDefinition
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.plugin.Plugin
|
||||
import rs09.game.content.global.worldevents.WorldEvents
|
||||
import rs09.game.world.GameWorld
|
||||
import java.util.concurrent.TimeUnit
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
/**
|
||||
* Option handlers for the various shooting star objects.
|
||||
*/
|
||||
class ShootingStarOptionHandler : OptionHandler() {
|
||||
class ShootingStarOptionHandler : InteractionListener() {
|
||||
|
||||
override fun newInstance(arg: Any?): Plugin<Any>? {
|
||||
for (star in ShootingStarType.values()) {
|
||||
ObjectDefinition.forId(star.objectId).handlers["option:mine"] = this
|
||||
ObjectDefinition.forId(star.objectId).handlers["option:prospect"] = this
|
||||
val SHOOTING_STARS = ShootingStarType.values().map(ShootingStarType::objectId).toIntArray()
|
||||
|
||||
override fun defineListeners() {
|
||||
on(SHOOTING_STARS,OBJECT,"mine"){player, _ ->
|
||||
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
star.mine(player)
|
||||
return@on true
|
||||
}
|
||||
|
||||
on(SHOOTING_STARS,OBJECT,"prospect"){player, _ ->
|
||||
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
star.prospect(player)
|
||||
return@on true
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(player: Player, node: Node, option: String): Boolean {
|
||||
val star: ShootingStar? = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||
star ?: return false
|
||||
when (option) {
|
||||
"mine" -> {
|
||||
star.mine(player)
|
||||
}
|
||||
"prospect" -> {
|
||||
star.prospect(player)
|
||||
}
|
||||
"observe" -> if (star.isSpawned) {
|
||||
player.dialogueInterpreter.sendDialogue("A shooting star (Level " + (star.level.ordinal + 1).toString() + ")", "is currently crashed near the " + star.location + ".")
|
||||
} else {
|
||||
val tickDiff = (if (GameWorld.settings?.isDevMode == true) 200 else 7200) - star.ticks
|
||||
val seconds = Math.ceil((tickDiff.toFloat() / 1000.toFloat()) * 600.toDouble()).toInt()
|
||||
val hours = TimeUnit.SECONDS.toHours(seconds.toLong()).toInt()
|
||||
val minutes = TimeUnit.SECONDS.toMinutes(seconds.toLong()).toInt()
|
||||
var time = ""
|
||||
time += if (hours > 0) {
|
||||
"$hours hour"
|
||||
} else {
|
||||
if (minutes > 0) {
|
||||
"$minutes minute(s)"
|
||||
} else {
|
||||
"$seconds second(s)"
|
||||
}
|
||||
}
|
||||
player.dialogueInterpreter.sendDialogue("The next star will crash in approximately:", time)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
companion object {
|
||||
const val STAR_DUST = 13727
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue