mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
implemented player 'reach' for items
This commit is contained in:
@@ -12,7 +12,6 @@ import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Humanoid actor class to provide same controlling function (such as work, jump)
|
||||
@@ -213,10 +212,10 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
// update inventory items
|
||||
inventory.forEach {
|
||||
if (!inventory.itemEquipped.contains(it.itm)) { // unequipped
|
||||
ItemCodex[it.itm]!!.effectWhileInPocket(delta)
|
||||
ItemCodex[it.itm]!!.effectWhileInPocket(this, delta)
|
||||
}
|
||||
else { // equipped
|
||||
ItemCodex[it.itm]!!.effectWhenEquipped(delta)
|
||||
ItemCodex[it.itm]!!.effectWhenEquipped(this, delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AIControlled
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
@@ -49,7 +50,7 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Boolean {
|
||||
try {
|
||||
// place the actor to the world
|
||||
this@HumanoidNPC.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-15.
|
||||
@@ -35,7 +36,7 @@ interface Pocketed {
|
||||
// Relevant Actorvalue is NOT being updated on time
|
||||
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
|
||||
|
||||
item.effectOnUnequip(App.UPDATE_RATE)
|
||||
item.effectOnUnequip(this as ActorWithBody, App.UPDATE_RATE)
|
||||
}
|
||||
|
||||
fun unequipItem(itemID: ItemID?) {
|
||||
@@ -66,7 +67,7 @@ interface Pocketed {
|
||||
|
||||
if (item.equipPosition >= 0) {
|
||||
inventory.itemEquipped[item.equipPosition] = item.dynamicID
|
||||
item.effectWhenEquipped(App.UPDATE_RATE)
|
||||
item.effectWhenEquipped(this as ActorWithBody, App.UPDATE_RATE)
|
||||
}
|
||||
// else do nothing
|
||||
}
|
||||
|
||||
@@ -1,27 +1,10 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import java.util.concurrent.Callable
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-05-25.
|
||||
*/
|
||||
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Callable<Unit> {
|
||||
override fun call() {
|
||||
for (i in startIndex..endIndex) {
|
||||
val it = INGAME.actorContainerActive[i]
|
||||
it.update(App.UPDATE_RATE)
|
||||
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Runnable {
|
||||
override fun run() {
|
||||
|
||||
if (it is Pocketed) {
|
||||
it.inventory.forEach { inventoryEntry ->
|
||||
ItemCodex[inventoryEntry.itm]?.effectWhileInPocket(App.UPDATE_RATE)
|
||||
if (it.equipped(inventoryEntry.itm)) {
|
||||
ItemCodex[inventoryEntry.itm]?.effectWhenEquipped(App.UPDATE_RATE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user