mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 05:24:06 +09:00
asynch update and render (aka frameskip)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN
|
||||
|
||||
@@ -57,7 +57,7 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
||||
fun generateUniqueReferenceID(): ActorID {
|
||||
fun hasCollision(value: ActorID) =
|
||||
try {
|
||||
TerrarumGDX.ingame!!.theGameHasActor(value) ||
|
||||
Terrarum.ingame!!.theGameHasActor(value) ||
|
||||
value < ItemCodex.ACTORID_MIN ||
|
||||
value !in when (renderOrder) {
|
||||
RenderOrder.BEHIND -> RANGE_BEHIND
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
@@ -134,7 +134,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
protected var isRightDown = false
|
||||
protected var isJumpDown = false
|
||||
protected inline val isGamer: Boolean
|
||||
get() = this == TerrarumGDX.ingame!!.player
|
||||
get() = this == Terrarum.ingame!!.player
|
||||
|
||||
|
||||
private val nullItem = object : GameItem() {
|
||||
@@ -195,32 +195,32 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
private fun updateGamerControlBox() {
|
||||
if (isGamer) {
|
||||
isUpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyup"))
|
||||
isLeftDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyleft"))
|
||||
isDownDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keydown"))
|
||||
isRightDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyright"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyjump"))
|
||||
isUpDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyup"))
|
||||
isLeftDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyleft"))
|
||||
isDownDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keydown"))
|
||||
isRightDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyright"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyjump"))
|
||||
|
||||
if (TerrarumGDX.controller != null) {
|
||||
axisX = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadlstickx"))
|
||||
axisY = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadlsticky"))
|
||||
axisRX = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadrstickx"))
|
||||
axisRY = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadrsticky"))
|
||||
if (Terrarum.controller != null) {
|
||||
axisX = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadlstickx"))
|
||||
axisY = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadlsticky"))
|
||||
axisRX = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadrstickx"))
|
||||
axisRY = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadrsticky"))
|
||||
|
||||
// deadzonning
|
||||
if (Math.abs(axisX) < TerrarumGDX.CONTROLLER_DEADZONE) axisX = 0f
|
||||
if (Math.abs(axisY) < TerrarumGDX.CONTROLLER_DEADZONE) axisY = 0f
|
||||
if (Math.abs(axisRX) < TerrarumGDX.CONTROLLER_DEADZONE) axisRX = 0f
|
||||
if (Math.abs(axisRY) < TerrarumGDX.CONTROLLER_DEADZONE) axisRY = 0f
|
||||
if (Math.abs(axisX) < Terrarum.CONTROLLER_DEADZONE) axisX = 0f
|
||||
if (Math.abs(axisY) < Terrarum.CONTROLLER_DEADZONE) axisY = 0f
|
||||
if (Math.abs(axisRX) < Terrarum.CONTROLLER_DEADZONE) axisRX = 0f
|
||||
if (Math.abs(axisRY) < Terrarum.CONTROLLER_DEADZONE) axisRY = 0f
|
||||
|
||||
isJumpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyjump")) ||
|
||||
TerrarumGDX.controller!!.isButtonPressed(GAMEPAD_JUMP)
|
||||
isJumpDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyjump")) ||
|
||||
Terrarum.controller!!.isButtonPressed(GAMEPAD_JUMP)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline val hasController: Boolean
|
||||
get() = if (isGamer) TerrarumGDX.controller != null
|
||||
get() = if (isGamer) Terrarum.controller != null
|
||||
else true
|
||||
|
||||
override fun processInput(delta: Float) {
|
||||
@@ -265,11 +265,11 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// ↑F, ↓S
|
||||
if (isRightDown && !isLeftDown) {
|
||||
walkHorizontal(false, AXIS_KEYBOARD)
|
||||
prevHMoveKey = TerrarumGDX.getConfigInt("keyright")
|
||||
prevHMoveKey = Terrarum.getConfigInt("keyright")
|
||||
} // ↓F, ↑S
|
||||
else if (isLeftDown && !isRightDown) {
|
||||
walkHorizontal(true, AXIS_KEYBOARD)
|
||||
prevHMoveKey = TerrarumGDX.getConfigInt("keyleft")
|
||||
prevHMoveKey = Terrarum.getConfigInt("keyleft")
|
||||
} // ↓F, ↓S
|
||||
/*else if (isLeftDown && isRightDown) {
|
||||
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
||||
@@ -293,11 +293,11 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// ↑E, ↓D
|
||||
if (isDownDown && !isUpDown) {
|
||||
walkVertical(false, AXIS_KEYBOARD)
|
||||
prevVMoveKey = TerrarumGDX.getConfigInt("keydown")
|
||||
prevVMoveKey = Terrarum.getConfigInt("keydown")
|
||||
} // ↓E, ↑D
|
||||
else if (isUpDown && !isDownDown) {
|
||||
walkVertical(true, AXIS_KEYBOARD)
|
||||
prevVMoveKey = TerrarumGDX.getConfigInt("keyup")
|
||||
prevVMoveKey = Terrarum.getConfigInt("keyup")
|
||||
} // ↓E, ↓D
|
||||
/*else if (isUpDown && isDownDown) {
|
||||
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
||||
@@ -335,7 +335,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
// quickslot (quickbar)
|
||||
val quickbarKeys = TerrarumGDX.getConfigIntArray("keyquickbars")
|
||||
val quickbarKeys = Terrarum.getConfigIntArray("keyquickbars")
|
||||
if (keycode in quickbarKeys) {
|
||||
actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = quickbarKeys.indexOf(keycode)
|
||||
}
|
||||
@@ -501,7 +501,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
// force update inventory UI
|
||||
try {
|
||||
(TerrarumGDX.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
|
||||
(Terrarum.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
|
||||
}
|
||||
catch (LateInitMyArse: kotlin.UninitializedPropertyAccessException) { }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -59,8 +59,8 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
"These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.")
|
||||
if (item.originalID == Player.PLAYER_REF_ID || item.originalID == 0x51621D) // do not delete this magic
|
||||
throw IllegalArgumentException("Attempted to put human player into the inventory.")
|
||||
if (TerrarumGDX.ingame != null &&
|
||||
(item.originalID == TerrarumGDX.ingame?.player?.referenceID))
|
||||
if (Terrarum.ingame != null &&
|
||||
(item.originalID == Terrarum.ingame?.player?.referenceID))
|
||||
throw IllegalArgumentException("Attempted to put active player into the inventory.")
|
||||
if ((!item.stackable || item.dynamicID in ITEM_DYNAMIC) && count > 1)
|
||||
throw IllegalArgumentException("Attempting to adding stack of item but the item is not stackable; item: $item, count: $count")
|
||||
|
||||
@@ -44,7 +44,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
|
||||
var drawMode = BlendMode.NORMAL
|
||||
|
||||
@Transient private val world: GameWorld = TerrarumGDX.ingame!!.world
|
||||
@Transient private val world: GameWorld = Terrarum.ingame!!.world
|
||||
|
||||
var hitboxTranslateX: Int = 0// relative to spritePosX
|
||||
protected set
|
||||
@@ -492,7 +492,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
* weight; gravitational force in action
|
||||
* W = mass * G (9.8 [m/s^2])
|
||||
*/
|
||||
val W: Vector2 = gravitation * TerrarumGDX.TARGET_FPS.toDouble()
|
||||
val W: Vector2 = gravitation * Terrarum.TARGET_FPS.toDouble()
|
||||
/**
|
||||
* Area
|
||||
*/
|
||||
@@ -503,7 +503,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
*/
|
||||
val D: Vector2 = Vector2(externalForce.x.magnSqr(), externalForce.y.magnSqr()) * dragCoefficient * 0.5 * A// * tileDensityFluid.toDouble()
|
||||
|
||||
val V: Vector2 = (W - D) / TerrarumGDX.TARGET_FPS.toDouble() * SI_TO_GAME_ACC
|
||||
val V: Vector2 = (W - D) / Terrarum.TARGET_FPS.toDouble() * SI_TO_GAME_ACC
|
||||
|
||||
applyForce(V)
|
||||
//}
|
||||
@@ -767,7 +767,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
|
||||
// slam-into-whatever damage (such dirty; much hack; wow)
|
||||
// vvvv hack (supposed to be 1.0) vvv 50% hack
|
||||
val collisionDamage = mass * (vectorSum.magnitude / (10.0 / TerrarumGDX.TARGET_FPS).sqr()) / fallDamageDampening.sqr() * GAME_TO_SI_ACC
|
||||
val collisionDamage = mass * (vectorSum.magnitude / (10.0 / Terrarum.TARGET_FPS).sqr()) / fallDamageDampening.sqr() * GAME_TO_SI_ACC
|
||||
// kg * m / s^2 (mass * acceleration), acceleration -> (vectorMagn / (0.01)^2).gameToSI()
|
||||
if (collisionDamage != 0.0) debug1("Collision damage: $collisionDamage N")
|
||||
// FIXME instead of 0.5mv^2, we can model after "change of velocity (aka accel)", just as in real-life; big change of accel on given unit time is what kills
|
||||
@@ -1358,16 +1358,16 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
/**
|
||||
* [m / s^2] * SI_TO_GAME_ACC -> [px / InternalFrame^2]
|
||||
*/
|
||||
@Transient val SI_TO_GAME_ACC = METER / (TerrarumGDX.TARGET_FPS * TerrarumGDX.TARGET_FPS)
|
||||
@Transient val SI_TO_GAME_ACC = METER / (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS)
|
||||
/**
|
||||
* [m / s] * SI_TO_GAME_VEL -> [px / InternalFrame]
|
||||
*/
|
||||
@Transient val SI_TO_GAME_VEL = METER / TerrarumGDX.TARGET_FPS
|
||||
@Transient val SI_TO_GAME_VEL = METER / Terrarum.TARGET_FPS
|
||||
|
||||
/**
|
||||
* [px / InternalFrame^2] * GAME_TO_SI_ACC -> [m / s^2]
|
||||
*/
|
||||
@Transient val GAME_TO_SI_ACC = (TerrarumGDX.TARGET_FPS * TerrarumGDX.TARGET_FPS) / METER
|
||||
@Transient val GAME_TO_SI_ACC = (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS) / METER
|
||||
|
||||
|
||||
/**
|
||||
@@ -1388,8 +1388,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
||||
if (x < 0)
|
||||
return 0
|
||||
else if (x >= TerrarumGDX.ingame!!.world.width shl 4)
|
||||
return TerrarumGDX.ingame!!.world.width - 1
|
||||
else if (x >= Terrarum.ingame!!.world.width shl 4)
|
||||
return Terrarum.ingame!!.world.width - 1
|
||||
else
|
||||
return x and 0x7FFFFFFF shr 4
|
||||
}
|
||||
@@ -1397,8 +1397,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
private fun div16TruncateToMapHeight(y: Int): Int {
|
||||
if (y < 0)
|
||||
return 0
|
||||
else if (y >= TerrarumGDX.ingame!!.world.height shl 4)
|
||||
return TerrarumGDX.ingame!!.world.height - 1
|
||||
else if (y >= Terrarum.ingame!!.world.height shl 4)
|
||||
return Terrarum.ingame!!.world.height - 1
|
||||
else
|
||||
return y and 0x7FFFFFFF shr 4
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
|
||||
typealias AnyPlayer = HistoricalFigure
|
||||
@@ -20,12 +20,13 @@ open class HistoricalFigure(
|
||||
realAirFriction: Boolean = false
|
||||
) : ActorWithPhysics(Actor.RenderOrder.MIDDLE, realAirFriction) {
|
||||
|
||||
val historicalFigureIdentifier: Int = generateHistoricalFigureIdentifier()
|
||||
var historicalFigureIdentifier: Int = generateHistoricalFigureIdentifier()
|
||||
internal set
|
||||
|
||||
private fun generateHistoricalFigureIdentifier(): Int {
|
||||
fun hasCollision(value: Int) =
|
||||
try {
|
||||
TerrarumGDX.ingame!!.historicalFigureIDBucket.contains(value)
|
||||
Terrarum.ingame!!.historicalFigureIDBucket.contains(value)
|
||||
}
|
||||
catch (gameNotInitialisedException: KotlinNullPointerException) {
|
||||
false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
import net.torvald.terrarum.gameactors.ai.LuaAIWrapper
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
@@ -51,8 +51,8 @@ open class HumanoidNPC(
|
||||
override fun secondaryUse(delta: Float): Boolean {
|
||||
try {
|
||||
// place the actor to the world
|
||||
this@HumanoidNPC.setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
TerrarumGDX.ingame!!.addNewActor(this@HumanoidNPC)
|
||||
this@HumanoidNPC.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
Terrarum.ingame!!.addNewActor(this@HumanoidNPC)
|
||||
// successful
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics.Companion.SI_TO_GAME_ACC
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
@@ -44,7 +43,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = n
|
||||
lifetimeCounter += delta
|
||||
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
|
||||
// simple stuck check
|
||||
BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(
|
||||
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(
|
||||
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
|
||||
hitbox.canonicalY.div(TILE_SIZE).floorInt()
|
||||
) ?: Block.STONE].isSolid) {
|
||||
@@ -53,7 +52,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = n
|
||||
|
||||
// gravity, winds, etc. (external forces)
|
||||
if (!isNoSubjectToGrav) {
|
||||
velocity += TerrarumGDX.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
velocity += Terrarum.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = t
|
||||
}
|
||||
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
it.color = color
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() - 1f,
|
||||
@@ -30,13 +30,13 @@ class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = t
|
||||
)
|
||||
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() + TerrarumGDX.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startX.toFloat() + Terrarum.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() - TerrarumGDX.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startX.toFloat() - Terrarum.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-03.
|
||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
object PlayerBuilder {
|
||||
|
||||
operator fun invoke(): Actor {
|
||||
val p: Actor = Player(TerrarumGDX.ingame!!.world.time.currentTimeAsGameDate)
|
||||
val p: Actor = Player(Terrarum.ingame!!.world.time.currentTimeAsGameDate)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -17,6 +17,7 @@ object PlayerBuilderSigrid {
|
||||
val p = Player(GameDate(-2147483648, 0)) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
p.historicalFigureIdentifier = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player.tga"), 28, 51))
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -72,7 +72,7 @@ open class ProjectileSimple(
|
||||
lifetimeCounter += delta
|
||||
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
|
||||
// stuck check
|
||||
BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
) {
|
||||
flagDespawn()
|
||||
}
|
||||
@@ -90,15 +90,15 @@ open class ProjectileSimple(
|
||||
colourTail.a = 0.16f
|
||||
|
||||
/*batch.end()
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
// draw trail of solid colour (Terraria style maybe?)
|
||||
it.lineWidth = 2f * TerrarumGDX.ingame!!.screenZoom
|
||||
it.lineWidth = 2f * Terrarum.ingame!!.screenZoom
|
||||
g.drawGradientLine(
|
||||
hitbox.centeredX.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
hitbox.centeredY.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
hitbox.centeredX.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
hitbox.centeredY.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
displayColour,
|
||||
posPre.x.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
posPre.y.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
posPre.x.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
posPre.y.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
colourTail
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String)
|
||||
|
||||
makeNewSprite(texturePack)
|
||||
setHitboxDimension(texture.width, texture.height, 0, 0)
|
||||
setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
// you CAN'T destroy the image
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-05-25.
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Runnable {
|
||||
override fun run() {
|
||||
for (i in startIndex..endIndex) {
|
||||
val it = TerrarumGDX.ingame!!.actorContainer[i]
|
||||
val it = Terrarum.ingame!!.actorContainer[i]
|
||||
it.update(Gdx.graphics.deltaTime)
|
||||
|
||||
if (it is Pocketed) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.ai
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AIControlled
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
@@ -240,7 +240,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
luatable[y - feetTilePos[1]] = LuaTable()
|
||||
|
||||
for (x in feetTilePos[0] - radius..feetTilePos[0] + radius) {
|
||||
val tile = BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(x, y) ?: Block.NULL]
|
||||
val tile = BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(x, y) ?: Block.NULL]
|
||||
val solidity = tile.isSolid.toInt()
|
||||
val liquidity = tile.isFluid.toInt()
|
||||
val gravity = tile.isFallable.toInt()
|
||||
@@ -284,7 +284,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
// search down
|
||||
var searchDownCounter = 0
|
||||
while (true) {
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Block.STONE
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Block.STONE
|
||||
if (BlockCodex[tile].isSolid || searchDownCounter >= searchDownLimit) {
|
||||
luatable[x - feetTilePos[0]] = searchDownCounter
|
||||
break
|
||||
@@ -327,7 +327,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
// search up
|
||||
var searchUpCounter = 0
|
||||
while (true) {
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
if (BlockCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
|
||||
luatable[x - feetTilePos[0]] = searchUpCounter
|
||||
break
|
||||
@@ -369,7 +369,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
// search up
|
||||
var searchUpCounter = 0
|
||||
while (true) {
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
if (!BlockCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
|
||||
luatable[x - feetTilePos[0]] = searchUpCounter
|
||||
break
|
||||
@@ -388,13 +388,13 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
|
||||
class GameVersion : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return TerrarumGDX.VERSION_STRING.toLua()
|
||||
return Terrarum.VERSION_STRING.toLua()
|
||||
}
|
||||
}
|
||||
|
||||
class GameVersionRaw : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return TerrarumGDX.VERSION_RAW.toLua()
|
||||
return Terrarum.VERSION_RAW.toLua()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.faction
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import java.util.HashSet
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.gameactors.faction
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.physicssolver
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
import java.util.*
|
||||
|
||||
@@ -39,7 +38,7 @@ object CollisionSolver {
|
||||
collCandidateY.clear()
|
||||
|
||||
// mark list x
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach { it ->
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
if (it is ActorWithPhysics) {
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
||||
@@ -72,7 +71,7 @@ object CollisionSolver {
|
||||
collCandidateStack.clear()
|
||||
|
||||
// mark list y
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach { it ->
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
if (it is ActorWithPhysics) {
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
||||
|
||||
Reference in New Issue
Block a user