World Click events

let's hope it works w/o tests as I can't get to the Ingame now
This commit is contained in:
minjaesong
2018-10-01 23:51:04 +09:00
parent 6a1146f67b
commit f365156799
25 changed files with 341 additions and 226 deletions

View File

@@ -51,12 +51,12 @@ class EntryPoint : ModuleEntryPoint() {
print("$originalID ")
}
override fun primaryUse(delta: Float): Boolean {
override fun startPrimaryUse(delta: Float): Boolean {
return false
// TODO base punch attack
}
override fun secondaryUse(delta: Float): Boolean {
override fun startSecondaryUse(delta: Float): Boolean {
val ingame = Terrarum.ingame!! as Ingame
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())

View File

@@ -29,6 +29,7 @@ import net.torvald.terrarum.modulebasegame.console.AVTracker
import net.torvald.terrarum.modulebasegame.console.ActorsList
import net.torvald.terrarum.console.Authenticator
import net.torvald.terrarum.console.SetGlobalLightOverride
import net.torvald.terrarum.itemproperties.GameItem
import net.torvald.terrarum.modulebasegame.gameactors.*
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarum.modulebasegame.imagefont.Watch7SegMain
@@ -392,6 +393,25 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
}// END enter
override fun worldPrimaryClickStart(delta: Float) {
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
itemOnGrip?.startPrimaryUse(delta)
}
override fun worldPrimaryClickEnd(delta: Float) {
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
itemOnGrip?.endPrimaryUse(delta)
}
override fun worldSecondaryClickStart(delta: Float) {
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
itemOnGrip?.startSecondaryUse(delta)
}
override fun worldSecondaryClickEnd(delta: Float) {
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
itemOnGrip?.endSecondaryUse(delta)
}
protected var updateDeltaCounter = 0.0
protected val updateRate = 1.0 / Terrarum.TARGET_INTERNAL_FPS

View File

@@ -50,7 +50,7 @@ open class HumanoidNPC(
override val isDynamic = false
override val material = Material(0,0,0,0,0,0,0,0,0,0.0)
override fun secondaryUse(delta: Float): Boolean {
override fun startSecondaryUse(delta: Float): Boolean {
try {
// place the actor to the world
this@HumanoidNPC.setPosition(Terrarum.mouseX, Terrarum.mouseY)

View File

@@ -69,13 +69,13 @@ interface Pocketed {
fun consumePrimary(item: GameItem) {
if (item.primaryUse(Terrarum.deltaTime)) {
if (item.startPrimaryUse(Terrarum.deltaTime)) {
inventory.consumeItem(this as Actor, item) // consume on successful
}
}
fun consumeSecondary(item: GameItem) {
if (item.secondaryUse(Terrarum.deltaTime))
if (item.startSecondaryUse(Terrarum.deltaTime))
inventory.consumeItem(this as Actor, item) // consume on successful
}
}

View File

@@ -33,7 +33,7 @@ class PickaxeGeneric(override val originalID: ItemID) : GameItem() {
super.name = "Builtin Pickaxe"
}
override fun primaryUse(delta: Float): Boolean {
override fun startPrimaryUse(delta: Float): Boolean {
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
if (player == null) return false

View File

@@ -77,6 +77,9 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
return UIRemoConElement(this, dynamicStrArray)
}
// currently there's no resetter for this!
private var startNewGameCalled = false
override fun updateUI(delta: Float) {
if (mouseActionAvailable) {
remoConTray.update(delta)
@@ -105,20 +108,24 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
}
}
else if (it.labelText.contains("Start New Random Game")) {
if (!startNewGameCalled) {
startNewGameCalled = true
printdbg(this, 1)
val ingame = Ingame(Terrarum.batch)
ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
printdbg(this, 1)
printdbg(this, 2)
val ingame = Ingame(Terrarum.batch)
ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
Terrarum.ingame = ingame
LoadScreen.screenToLoad = ingame
Terrarum.setScreen(LoadScreen)
printdbg(this, 2)
printdbg(this, 3)
Terrarum.ingame = ingame
LoadScreen.screenToLoad = ingame
Terrarum.setScreen(LoadScreen)
printdbg(this, 3)
}
}
else {
// check if target exists

View File

@@ -36,6 +36,7 @@ object UITitleRemoConYaml {
- Development Tools $
- Building Maker
- Start New Random Game
- MENU_LABEL_RETURN
""".trimIndent()
operator fun invoke() = if (AppLoader.IS_DEVELOPMENT_BUILD)