mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
Renamed AppLoader into App
This commit is contained in:
@@ -5,11 +5,10 @@ import com.jme3.math.FastMath
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.spriteanimation.HasAssembledSprite
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -224,22 +223,22 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
|
||||
private fun updateGamerControlBox() {
|
||||
if (isGamer) {
|
||||
isUpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyup"))
|
||||
isLeftDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyleft"))
|
||||
isDownDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keydown"))
|
||||
isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyright"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump"))
|
||||
isUpDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyup"))
|
||||
isLeftDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyleft"))
|
||||
isDownDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keydown"))
|
||||
isRightDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyright"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyjump"))
|
||||
|
||||
val gamepad = AppLoader.gamepad
|
||||
val gamepad = App.gamepad
|
||||
|
||||
if (gamepad != null) {
|
||||
axisX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx"))
|
||||
axisY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly"))
|
||||
axisRX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisrx"))
|
||||
axisRY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisry"))
|
||||
axisX = gamepad.getAxis(App.getConfigInt("config_gamepadaxislx"))
|
||||
axisY = gamepad.getAxis(App.getConfigInt("config_gamepadaxisly"))
|
||||
axisRX = gamepad.getAxis(App.getConfigInt("config_gamepadaxisrx"))
|
||||
axisRY = gamepad.getAxis(App.getConfigInt("config_gamepadaxisry"))
|
||||
|
||||
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump")) ||
|
||||
gamepad.getButton(AppLoader.getConfigInt("config_gamepadltrigger"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyjump")) ||
|
||||
gamepad.getButton(App.getConfigInt("config_gamepadltrigger"))
|
||||
}
|
||||
|
||||
if (isJumpJustDown && jumpJustPressedLatched) {
|
||||
@@ -263,7 +262,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
}
|
||||
|
||||
private inline val hasController: Boolean
|
||||
get() = if (isGamer) AppLoader.gamepad != null
|
||||
get() = if (isGamer) App.gamepad != null
|
||||
else true
|
||||
|
||||
private var playerJumpKeyHeldDown = false
|
||||
@@ -308,11 +307,11 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
// ↑F, ↓S
|
||||
if (isRightDown && !isLeftDown) {
|
||||
walkHorizontal(false, AXIS_KEYBOARD)
|
||||
prevHMoveKey = AppLoader.getConfigInt("config_keyright")
|
||||
prevHMoveKey = App.getConfigInt("config_keyright")
|
||||
} // ↓F, ↑S
|
||||
else if (isLeftDown && !isRightDown) {
|
||||
walkHorizontal(true, AXIS_KEYBOARD)
|
||||
prevHMoveKey = AppLoader.getConfigInt("config_keyleft")
|
||||
prevHMoveKey = App.getConfigInt("config_keyleft")
|
||||
} // ↓F, ↓S
|
||||
/*else if (isLeftDown && isRightDown) {
|
||||
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
||||
@@ -336,11 +335,11 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
// ↑E, ↓D
|
||||
if (isDownDown && !isUpDown) {
|
||||
walkVertical(false, AXIS_KEYBOARD)
|
||||
prevVMoveKey = AppLoader.getConfigInt("config_keydown")
|
||||
prevVMoveKey = App.getConfigInt("config_keydown")
|
||||
} // ↓E, ↑D
|
||||
else if (isUpDown && !isDownDown) {
|
||||
walkVertical(true, AXIS_KEYBOARD)
|
||||
prevVMoveKey = AppLoader.getConfigInt("config_keyup")
|
||||
prevVMoveKey = App.getConfigInt("config_keyup")
|
||||
} // ↓E, ↓D
|
||||
/*else if (isUpDown && isDownDown) {
|
||||
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
@@ -96,7 +96,7 @@ class ActorInventory() : FixtureInventory() {
|
||||
actor.avStrength / 1000.0
|
||||
else
|
||||
1.0 // TODO variable: scale, strength
|
||||
val swingDmgToFrameDmg = AppLoader.UPDATE_RATE.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = App.UPDATE_RATE.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
// damage the item
|
||||
newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.IngameInstance
|
||||
import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorID
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import net.torvald.terrarum.*
|
||||
@@ -57,7 +55,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
this.inventory = inventory
|
||||
|
||||
if (mainUI != null)
|
||||
AppLoader.disposableSingletonsPool.add(mainUI)
|
||||
App.disposableSingletonsPool.add(mainUI)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,15 +57,15 @@ internal class FixtureStorageChest : FixtureBase {
|
||||
|
||||
|
||||
internal class UIStorageChest : UICanvas(
|
||||
toggleKeyLiteral = AppLoader.getConfigInt("config_keyinventory"),
|
||||
toggleButtonLiteral = AppLoader.getConfigInt("config_gamepadstart"),
|
||||
toggleKeyLiteral = App.getConfigInt("config_keyinventory"),
|
||||
toggleButtonLiteral = App.getConfigInt("config_gamepadstart"),
|
||||
), HasInventory {
|
||||
|
||||
lateinit var chestInventory: FixtureInventory
|
||||
lateinit var chestNameFun: () -> String
|
||||
|
||||
override var width = AppLoader.screenSize.screenW
|
||||
override var height = AppLoader.screenSize.screenH
|
||||
override var width = App.scr.width
|
||||
override var height = App.scr.height
|
||||
override var openCloseTime: Second = 0.0f
|
||||
|
||||
private val shapeRenderer = ShapeRenderer()
|
||||
@@ -127,8 +127,8 @@ internal class UIStorageChest : UICanvas(
|
||||
|
||||
catBar = UIItemInventoryCatBar(
|
||||
this,
|
||||
(AppLoader.screenSize.screenW - catBarWidth) / 2,
|
||||
42 + (AppLoader.screenSize.screenH - internalHeight) / 2,
|
||||
(App.scr.width - catBarWidth) / 2,
|
||||
42 + (App.scr.height - internalHeight) / 2,
|
||||
internalWidth,
|
||||
catBarWidth,
|
||||
false
|
||||
@@ -195,17 +195,17 @@ internal class UIStorageChest : UICanvas(
|
||||
gdxSetBlendNormal()
|
||||
|
||||
|
||||
val gradTopStart = (AppLoader.screenSize.screenH - internalHeight).div(2).toFloat()
|
||||
val gradBottomEnd = AppLoader.screenSize.screenH - gradTopStart
|
||||
val gradTopStart = (App.scr.height - internalHeight).div(2).toFloat()
|
||||
val gradBottomEnd = App.scr.height - gradTopStart
|
||||
|
||||
shapeRenderer.inUse {
|
||||
shapeRenderer.rect(0f, gradTopStart, AppLoader.screenSize.screenWf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||
shapeRenderer.rect(0f, gradBottomEnd, AppLoader.screenSize.screenWf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||
shapeRenderer.rect(0f, gradTopStart, App.scr.wf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||
shapeRenderer.rect(0f, gradBottomEnd, App.scr.wf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
|
||||
|
||||
shapeRenderer.rect(0f, gradTopStart + gradHeight, AppLoader.screenSize.screenWf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
|
||||
shapeRenderer.rect(0f, gradTopStart + gradHeight, App.scr.wf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
|
||||
|
||||
shapeRenderer.rect(0f, 0f, AppLoader.screenSize.screenWf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||
shapeRenderer.rect(0f, AppLoader.screenSize.screenHf, AppLoader.screenSize.screenWf, -(AppLoader.screenSize.screenHf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||
shapeRenderer.rect(0f, 0f, App.scr.wf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||
shapeRenderer.rect(0f, App.scr.hf, App.scr.wf, -(App.scr.hf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ internal class UIStorageChest : UICanvas(
|
||||
// encumbrance meter
|
||||
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
||||
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - weightBarWidth
|
||||
val encumbBarTextXPos = encumbBarXPos - 6 - AppLoader.fontGame.getWidth(encumbranceText)
|
||||
val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
|
||||
val encumbBarYPos = UIInventoryCells.encumbBarYPos
|
||||
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
|
||||
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
||||
@@ -250,10 +250,10 @@ internal class UIStorageChest : UICanvas(
|
||||
|
||||
// chest name text
|
||||
batch.color = Color.WHITE
|
||||
AppLoader.fontGame.draw(batch, chestName, itemListChest.posX + 6f, encumbBarYPos - 3f)
|
||||
App.fontGame.draw(batch, chestName, itemListChest.posX + 6f, encumbBarYPos - 3f)
|
||||
// encumb text
|
||||
batch.color = Color.WHITE
|
||||
AppLoader.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f)
|
||||
App.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f)
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.random.Fudge3
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.WireCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
@@ -79,7 +76,7 @@ object PlayerBuilderSigrid {
|
||||
|
||||
fun fillTestInventory(inventory: ActorInventory) {
|
||||
|
||||
AppLoader.tileMaker.tags.forEach { t, _ ->
|
||||
App.tileMaker.tags.forEach { t, _ ->
|
||||
inventory.add(t, 9995)
|
||||
try {
|
||||
inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
@@ -36,7 +35,7 @@ interface Pocketed {
|
||||
// Relevant Actorvalue is NOT being updated on time
|
||||
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
|
||||
|
||||
item.effectOnUnequip(AppLoader.UPDATE_RATE)
|
||||
item.effectOnUnequip(App.UPDATE_RATE)
|
||||
}
|
||||
|
||||
fun unequipItem(itemID: ItemID?) {
|
||||
@@ -67,7 +66,7 @@ interface Pocketed {
|
||||
|
||||
if (item.equipPosition >= 0) {
|
||||
inventory.itemEquipped[item.equipPosition] = item.dynamicID
|
||||
item.effectWhenEquipped(AppLoader.UPDATE_RATE)
|
||||
item.effectWhenEquipped(App.UPDATE_RATE)
|
||||
}
|
||||
// else do nothing
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import java.util.concurrent.Callable
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
@@ -13,13 +12,13 @@ class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Callable<Unit>
|
||||
override fun call() {
|
||||
for (i in startIndex..endIndex) {
|
||||
val it = Terrarum.ingame!!.actorContainerActive[i]
|
||||
it.update(AppLoader.UPDATE_RATE)
|
||||
it.update(App.UPDATE_RATE)
|
||||
|
||||
if (it is Pocketed) {
|
||||
it.inventory.forEach { inventoryEntry ->
|
||||
ItemCodex[inventoryEntry.itm]?.effectWhileInPocket(AppLoader.UPDATE_RATE)
|
||||
ItemCodex[inventoryEntry.itm]?.effectWhileInPocket(App.UPDATE_RATE)
|
||||
if (it.equipped(inventoryEntry.itm)) {
|
||||
ItemCodex[inventoryEntry.itm]?.effectWhenEquipped(AppLoader.UPDATE_RATE)
|
||||
ItemCodex[inventoryEntry.itm]?.effectWhenEquipped(App.UPDATE_RATE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user