mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 22:44:04 +09:00
still WIP inventory impl, held item impl
Former-commit-id: 9468cfae21ff09c3dd30352a849910364e01d780 Former-commit-id: 50247ccebf3284f739877a1d6c6d8574449a9824
This commit is contained in:
@@ -6,6 +6,7 @@ import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.gamecontroller.EnumKeyFunc
|
||||
import net.torvald.terrarum.gamecontroller.KeyMap
|
||||
import net.torvald.terrarum.gameitem.InventoryItem
|
||||
import net.torvald.terrarum.realestate.RealEstateUtility
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.lwjgl.input.Controller
|
||||
@@ -25,6 +26,12 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
/** Must be set by PlayerFactory */
|
||||
override var inventory: ActorInventory = ActorInventory()
|
||||
|
||||
override var itemHolding: InventoryItem
|
||||
get() = throw TODO("itemHolding")
|
||||
set(value) {
|
||||
throw TODO("itemHolding")
|
||||
}
|
||||
|
||||
/** Must be set by PlayerFactory */
|
||||
override var faction: HashSet<Faction> = HashSet()
|
||||
/**
|
||||
@@ -126,7 +133,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
protected var isRightDown = false
|
||||
protected var isJumpDown = false
|
||||
protected val isGamer: Boolean
|
||||
get() = this is Player
|
||||
get() = this is Player // FIXME true iff composed by PlayableActorDelegate
|
||||
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
@@ -174,7 +181,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun processInput(input: Input) {
|
||||
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
if (isGamer && Terrarum.hasController) {
|
||||
gamepad = Controllers.getController(0)
|
||||
axisX = gamepad!!.getAxisValue(0)
|
||||
@@ -189,6 +196,24 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
if (Math.abs(axisRY) < Terrarum.CONTROLLER_DEADZONE) axisRY = 0f
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// MOUSE CONTROL //
|
||||
///////////////////
|
||||
// PRIMARY/SECONDARY IS FIXED TO LEFT/RIGHT BUTTON //
|
||||
|
||||
/**
|
||||
* Primary Use
|
||||
*/
|
||||
// Left mouse
|
||||
if (isGamer && input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
|
||||
itemHolding.primaryUse(gc, delta)
|
||||
}
|
||||
|
||||
// Right mouse
|
||||
if (isGamer && input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
|
||||
itemHolding.secondaryUse(gc, delta)
|
||||
}
|
||||
|
||||
/**
|
||||
* L-R stop
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
/**
|
||||
@@ -10,7 +11,7 @@ import org.newdawn.slick.Input
|
||||
*/
|
||||
interface Controllable {
|
||||
|
||||
fun processInput(input: Input)
|
||||
fun processInput(gc: GameContainer, delta: Int, input: Input)
|
||||
|
||||
fun keyPressed(key: Int, c: Char)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class DroppedItem(private val item: InventoryItem) : ActorWithBody() {
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
item.worldActorEffect(gc, delta)
|
||||
item.effectWhenTakenOut(gc, delta)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
/**
|
||||
@@ -16,8 +17,8 @@ class PlayableActorDelegate(val actor: ActorHumanoid) {
|
||||
throw IllegalArgumentException("Player must be 'Controllable'!")
|
||||
}
|
||||
|
||||
fun processInput(input: Input) {
|
||||
(actor as Controllable).processInput(input)
|
||||
fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
(actor as Controllable).processInput(gc, delta, input)
|
||||
}
|
||||
|
||||
fun keyPressed(key: Int, c: Char) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameitem.InventoryItem
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-15.
|
||||
*/
|
||||
@@ -7,4 +9,7 @@ interface Pocketed {
|
||||
|
||||
var inventory: ActorInventory
|
||||
|
||||
/** Item currentry holding, like tools/weapons/scrolls/magic/etc. */
|
||||
var itemHolding: InventoryItem
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user