mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
player is now nullable; wtf is calling Ingame 5 times?
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user