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

@@ -124,8 +124,10 @@ class UIItemInventoryElemSimple(
if (item != null && Terrarum.ingame != null && keycode in Input.Keys.NUM_1..Input.Keys.NUM_0) {
println("keydown elemgrid")
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
if (player == null) return false
val inventory = (Terrarum.ingame!! as Ingame).playableActor.inventory
val inventory = player.inventory
val slot = if (keycode == Input.Keys.NUM_0) 9 else keycode - Input.Keys.NUM_1
val currentSlotItem = inventory.getQuickBar(slot)
@@ -157,7 +159,8 @@ class UIItemInventoryElemSimple(
// equip da shit
val itemEquipSlot = item!!.equipPosition
val player = (Terrarum.ingame!! as Ingame).playableActor
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
if (player == null) return false
if (item != player.inventory.itemEquipped.get(itemEquipSlot)) { // if this item is unequipped, equip it
player.equipItem(item!!)