player is now nullable; wtf is calling Ingame 5 times?

This commit is contained in:
minjaesong
2018-09-17 01:46:50 +09:00
parent 967eafe8a3
commit 03b642ddd3
35 changed files with 252 additions and 150 deletions

View File

@@ -145,7 +145,7 @@ open class ActorHumanoid(
protected var isRightDown = false
protected var isJumpDown = false
protected inline val isGamer: Boolean
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.playableActor
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying
private val nullItem = object : GameItem() {

View File

@@ -64,7 +64,7 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
if (item.originalID == Terrarum.PLAYER_REF_ID || item.originalID == 0x51621D) // do not delete this magic
throw IllegalArgumentException("Attempted to put human player into the inventory.")
if (((Terrarum.ingame as? Ingame)?.gameFullyLoaded ?: false) &&
(item.originalID == (Terrarum.ingame as? Ingame)?.playableActor?.referenceID))
(item.originalID == (Terrarum.ingame as? Ingame)?.actorNowPlaying?.referenceID))
throw IllegalArgumentException("Attempted to put active player into the inventory.")
if ((!item.stackable || item.dynamicID in ITEM_DYNAMIC) && count > 1)
throw IllegalArgumentException("Attempting to adding stack of item but the item is not stackable; item: $item, count: $count")

View File

@@ -8,9 +8,10 @@ import net.torvald.terrarum.gameactors.Controllable
* @param actor : here you 'attach' the actor you wish to control
* Created by minjaesong on 2016-10-23.
*/
@Deprecated("The ingame should discriminate 'theRealGamer' and 'actorNowPlaying'")
class PlayableActorDelegate(val actor: ActorHumanoid) {
init {
/*init {
if (actor !is Controllable)
throw IllegalArgumentException("Player must be 'Controllable'!")
}
@@ -27,5 +28,5 @@ class PlayableActorDelegate(val actor: ActorHumanoid) {
// LightmapRenderer.fireRecalculateEvent()
//}
// not going to work: think about stationery tiki torches, global lights, etc
}
}*/
}

View File

@@ -35,7 +35,10 @@ class SmarterSlimes : ActorAI {
// TEST: just target player
val playerXPos = (Terrarum.ingame!! as Ingame).playableActor.centrePosPoint.x
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
if (player == null) return
val playerXPos = player.centrePosPoint.x
val thisXPos = actor.centrePosPoint.x
val xDiff = thisXPos - playerXPos