mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 13:34:06 +09:00
LibGDX, here I am.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN
|
||||
import org.newdawn.slick.GameContainer
|
||||
|
||||
typealias ActorID = Int
|
||||
|
||||
@@ -30,7 +28,7 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
||||
val RANGE_FRONT = 0x7000_0000..0x7FFF_FFFF
|
||||
}
|
||||
|
||||
abstract fun update(gc: GameContainer, delta: Int)
|
||||
abstract fun update(delta: Float)
|
||||
|
||||
/**
|
||||
* Valid RefID is equal to or greater than 16777216.
|
||||
@@ -59,7 +57,7 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
||||
fun generateUniqueReferenceID(): ActorID {
|
||||
fun hasCollision(value: ActorID) =
|
||||
try {
|
||||
Terrarum.ingame!!.theGameHasActor(value) ||
|
||||
TerrarumGDX.ingame!!.theGameHasActor(value) ||
|
||||
value < ItemCodex.ACTORID_MIN ||
|
||||
value !in when (renderOrder) {
|
||||
RenderOrder.BEHIND -> RANGE_BEHIND
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.gamecontroller.Key
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.ui.UIInventory
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Input
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -81,8 +79,8 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
@Transient internal const val WALK_ACCEL_BASE: Double = 0.67
|
||||
|
||||
@Transient const val BASE_HEIGHT = 40
|
||||
// 333.33 miliseconds
|
||||
@Transient const val BASE_ACTION_INTERVAL = 1000.0 / 3.0
|
||||
// 0.33333 miliseconds
|
||||
@Transient const val BASE_ACTION_INTERVAL = 1.0 / 3.0
|
||||
|
||||
@Transient const val SPRITE_ROW_IDLE = 0
|
||||
@Transient const val SPRITE_ROW_WALK = 1
|
||||
@@ -136,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 == Terrarum.ingame!!.player
|
||||
get() = this == TerrarumGDX.ingame!!.player
|
||||
|
||||
|
||||
private val nullItem = object : GameItem() {
|
||||
@@ -152,8 +150,8 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
override val material = Material(0,0,0,0,0,0,0,0,0,0.0)
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
super.update(gc, delta)
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
if (vehicleRiding is Player)
|
||||
throw Error("Attempted to 'ride' player object. ($vehicleRiding)")
|
||||
@@ -163,7 +161,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
|
||||
// don't put this into keyPressed; execution order is important!
|
||||
updateGamerControlBox(gc.input)
|
||||
updateGamerControlBox()
|
||||
|
||||
updateSprite(delta)
|
||||
|
||||
@@ -187,45 +185,45 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// update inventory items
|
||||
inventory.forEach {
|
||||
if (!inventory.itemEquipped.contains(it.item)) { // unequipped
|
||||
it.item.effectWhileInPocket(gc, delta)
|
||||
it.item.effectWhileInPocket(delta)
|
||||
}
|
||||
else { // equipped
|
||||
it.item.effectWhenEquipped(gc, delta)
|
||||
it.item.effectWhenEquipped(delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateGamerControlBox(input: Input) {
|
||||
private fun updateGamerControlBox() {
|
||||
if (isGamer) {
|
||||
isUpDown = input.isKeyDown(Terrarum.getConfigInt("keyup"))
|
||||
isLeftDown = input.isKeyDown(Terrarum.getConfigInt("keyleft"))
|
||||
isDownDown = input.isKeyDown(Terrarum.getConfigInt("keydown"))
|
||||
isRightDown = input.isKeyDown(Terrarum.getConfigInt("keyright"))
|
||||
isJumpDown = input.isKeyDown(Terrarum.getConfigInt("keyjump"))
|
||||
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"))
|
||||
|
||||
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"))
|
||||
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"))
|
||||
|
||||
// deadzonning
|
||||
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
|
||||
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
|
||||
|
||||
isJumpDown = input.isKeyDown(Terrarum.getConfigInt("keyjump")) ||
|
||||
Terrarum.controller!!.isButtonPressed(GAMEPAD_JUMP)
|
||||
isJumpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyjump")) ||
|
||||
TerrarumGDX.controller!!.isButtonPressed(GAMEPAD_JUMP)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline val hasController: Boolean
|
||||
get() = if (isGamer) Terrarum.controller != null
|
||||
get() = if (isGamer) TerrarumGDX.controller != null
|
||||
else true
|
||||
|
||||
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
override fun processInput(delta: Float) {
|
||||
|
||||
/**
|
||||
* L-R stop
|
||||
@@ -267,11 +265,11 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// ↑F, ↓S
|
||||
if (isRightDown && !isLeftDown) {
|
||||
walkHorizontal(false, AXIS_KEYBOARD)
|
||||
prevHMoveKey = Terrarum.getConfigInt("keyright")
|
||||
prevHMoveKey = TerrarumGDX.getConfigInt("keyright")
|
||||
} // ↓F, ↑S
|
||||
else if (isLeftDown && !isRightDown) {
|
||||
walkHorizontal(true, AXIS_KEYBOARD)
|
||||
prevHMoveKey = Terrarum.getConfigInt("keyleft")
|
||||
prevHMoveKey = TerrarumGDX.getConfigInt("keyleft")
|
||||
} // ↓F, ↓S
|
||||
/*else if (isLeftDown && isRightDown) {
|
||||
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
||||
@@ -295,11 +293,11 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// ↑E, ↓D
|
||||
if (isDownDown && !isUpDown) {
|
||||
walkVertical(false, AXIS_KEYBOARD)
|
||||
prevVMoveKey = Terrarum.getConfigInt("keydown")
|
||||
prevVMoveKey = TerrarumGDX.getConfigInt("keydown")
|
||||
} // ↓E, ↑D
|
||||
else if (isUpDown && !isDownDown) {
|
||||
walkVertical(true, AXIS_KEYBOARD)
|
||||
prevVMoveKey = Terrarum.getConfigInt("keyup")
|
||||
prevVMoveKey = TerrarumGDX.getConfigInt("keyup")
|
||||
} // ↓E, ↓D
|
||||
/*else if (isUpDown && isDownDown) {
|
||||
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
||||
@@ -337,7 +335,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
override fun keyPressed(key: Int, c: Char) {
|
||||
// quickslot (quickbar)
|
||||
val quickbarKeys = Terrarum.getConfigIntArray("keyquickbars")
|
||||
val quickbarKeys = TerrarumGDX.getConfigIntArray("keyquickbars")
|
||||
if (key in quickbarKeys) {
|
||||
actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = quickbarKeys.indexOf(key)
|
||||
}
|
||||
@@ -498,7 +496,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
// force update inventory UI
|
||||
try {
|
||||
(Terrarum.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
|
||||
(TerrarumGDX.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
|
||||
}
|
||||
catch (LateInitMyArse: kotlin.UninitializedPropertyAccessException) { }
|
||||
}
|
||||
@@ -519,7 +517,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
fun Float.abs() = FastMath.abs(this)
|
||||
|
||||
private fun updateSprite(delta: Int) {
|
||||
private fun updateSprite(delta: Float) {
|
||||
sprite?.update(delta)
|
||||
spriteGlow?.update(delta)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -58,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 (Terrarum.ingame != null &&
|
||||
(item.originalID == Terrarum.ingame?.player?.referenceID))
|
||||
if (TerrarumGDX.ingame != null &&
|
||||
(item.originalID == TerrarumGDX.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")
|
||||
@@ -201,7 +202,7 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
actor.avStrength / 1000.0
|
||||
else
|
||||
1.0 // TODO variable: scale, strength
|
||||
val swingDmgToFrameDmg = Terrarum.delta.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
val swingDmgToFrameDmg = Gdx.graphics.deltaTime.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
// damage the item
|
||||
newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
|
||||
/**
|
||||
* Actor with visible body
|
||||
@@ -10,6 +10,7 @@ import org.newdawn.slick.Graphics
|
||||
*/
|
||||
abstract class ActorWithBody(renderOrder: RenderOrder) : Actor(renderOrder) {
|
||||
open val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
|
||||
abstract fun drawBody(g: Graphics)
|
||||
abstract fun drawGlow(g: Graphics)
|
||||
abstract fun drawBody(batch: SpriteBatch)
|
||||
abstract fun drawGlow(batch: SpriteBatch)
|
||||
open var tooltipText = ""
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.*
|
||||
@@ -12,12 +14,13 @@ import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockProp
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import java.util.*
|
||||
|
||||
|
||||
typealias Second = Float
|
||||
|
||||
/**
|
||||
* Base class for every actor that has animated sprites. This includes furnishings, paintings, gadgets, etc.
|
||||
* Also has all the physics
|
||||
@@ -41,7 +44,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
|
||||
var drawMode = BlendMode.NORMAL
|
||||
|
||||
@Transient private val world: GameWorld = Terrarum.ingame!!.world
|
||||
@Transient private val world: GameWorld = TerrarumGDX.ingame!!.world
|
||||
|
||||
var hitboxTranslateX: Double = 0.0// relative to spritePosX
|
||||
protected set
|
||||
@@ -194,7 +197,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
/**
|
||||
* Post-hit invincibility, in milliseconds
|
||||
*/
|
||||
@Transient val INVINCIBILITY_TIME: Millisec = 500
|
||||
@Transient val INVINCIBILITY_TIME: Second = 0.5f
|
||||
|
||||
@Transient internal val BASE_FRICTION = 0.3
|
||||
|
||||
@@ -233,11 +236,9 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
internal var walledTop = false // UNUSED; only for BasicDebugInfoWindow
|
||||
internal var walledBottom = false // UNUSED; only for BasicDebugInfoWindow
|
||||
internal var colliding = false
|
||||
|
||||
protected inline val gameContainer: GameContainer
|
||||
get() = Terrarum.appgc
|
||||
protected inline val updateDelta: Int
|
||||
get() = Terrarum.delta
|
||||
|
||||
protected inline val updateDelta: Float
|
||||
get() = Gdx.graphics.deltaTime
|
||||
|
||||
|
||||
var isWalkingH = false
|
||||
@@ -247,24 +248,14 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
// some initialiser goes here...
|
||||
}
|
||||
|
||||
fun makeNewSprite(w: Int, h: Int, image: Image) {
|
||||
sprite = SpriteAnimation(this, w, h)
|
||||
sprite!!.setSpriteImage(image)
|
||||
fun makeNewSprite(textureRegionPack: TextureRegionPack) {
|
||||
sprite = SpriteAnimation(this)
|
||||
sprite!!.setSpriteImage(textureRegionPack)
|
||||
}
|
||||
|
||||
fun makeNewSprite(w: Int, h: Int, imageref: String) {
|
||||
sprite = SpriteAnimation(this, w, h)
|
||||
sprite!!.setSpriteImage(imageref)
|
||||
}
|
||||
|
||||
fun makeNewSpriteGlow(w: Int, h: Int, image: Image) {
|
||||
spriteGlow = SpriteAnimation(this, w, h)
|
||||
spriteGlow!!.setSpriteImage(image)
|
||||
}
|
||||
|
||||
fun makeNewSpriteGlow(w: Int, h: Int, imageref: String) {
|
||||
spriteGlow = SpriteAnimation(this, w, h)
|
||||
spriteGlow!!.setSpriteImage(imageref)
|
||||
fun makeNewSpriteGlow(textureRegionPack: TextureRegionPack) {
|
||||
spriteGlow = SpriteAnimation(this)
|
||||
spriteGlow!!.setSpriteImage(textureRegionPack)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,7 +305,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
inline val feetPosTile: IntArray
|
||||
get() = intArrayOf(tilewiseHitbox.centeredX.floorInt(), tilewiseHitbox.endY.floorInt())
|
||||
|
||||
override fun run() = update(gameContainer, updateDelta)
|
||||
override fun run() = update(updateDelta)
|
||||
|
||||
/**
|
||||
* Add vector value to the velocity, in the time unit of single frame.
|
||||
@@ -329,7 +320,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
|
||||
private val bounceDampenVelThreshold = 0.5
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
override fun update(delta: Float) {
|
||||
if (isUpdate && !flagDespawn) {
|
||||
|
||||
if (!assertPrinted) assertInit()
|
||||
@@ -499,7 +490,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 * Terrarum.TARGET_FPS.toDouble()
|
||||
val W: Vector2 = gravitation * TerrarumGDX.TARGET_FPS.toDouble()
|
||||
/**
|
||||
* Area
|
||||
*/
|
||||
@@ -510,7 +501,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) / Terrarum.TARGET_FPS.toDouble() * SI_TO_GAME_ACC
|
||||
val V: Vector2 = (W - D) / TerrarumGDX.TARGET_FPS.toDouble() * SI_TO_GAME_ACC
|
||||
|
||||
applyForce(V)
|
||||
//}
|
||||
@@ -707,7 +698,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 / Terrarum.TARGET_FPS).sqr()) / fallDamageDampening.sqr() * GAME_TO_SI_ACC
|
||||
val collisionDamage = mass * (vectorSum.magnitude / (10.0 / TerrarumGDX.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) println("Collision damage: $collisionDamage N")
|
||||
|
||||
@@ -1193,20 +1184,16 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
)
|
||||
}
|
||||
|
||||
override fun drawGlow(g: Graphics) {
|
||||
override fun drawGlow(batch: SpriteBatch) {
|
||||
if (isVisible && spriteGlow != null) {
|
||||
blendLightenOnly()
|
||||
|
||||
val offsetX = if (!spriteGlow!!.flippedHorizontal())
|
||||
hitboxTranslateX * scale
|
||||
else
|
||||
spriteGlow!!.cellWidth * scale - (hitbox.width + hitboxTranslateX * scale)
|
||||
|
||||
val offsetX = hitboxTranslateX * scale
|
||||
val offsetY = spriteGlow!!.cellHeight * scale - hitbox.height - hitboxTranslateY * scale - 1
|
||||
|
||||
if (WorldCamera.xCentre > leftsidePadding && centrePosPoint.x <= rightsidePadding) {
|
||||
// camera center neg, actor center pos
|
||||
spriteGlow!!.render(g,
|
||||
spriteGlow!!.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat() + world.width * TILE_SIZE,
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
@@ -1214,14 +1201,14 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
}
|
||||
else if (WorldCamera.xCentre < rightsidePadding && centrePosPoint.x >= leftsidePadding) {
|
||||
// camera center pos, actor center neg
|
||||
spriteGlow!!.render(g,
|
||||
spriteGlow!!.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat() - world.width * TILE_SIZE,
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
)
|
||||
}
|
||||
else {
|
||||
spriteGlow!!.render(g,
|
||||
spriteGlow!!.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat(),
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
@@ -1233,21 +1220,17 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
val leftsidePadding = world.width.times(TILE_SIZE) - WorldCamera.width.ushr(1)
|
||||
val rightsidePadding = WorldCamera.width.ushr(1)
|
||||
|
||||
override fun drawBody(g: Graphics) {
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
if (isVisible && sprite != null) {
|
||||
|
||||
BlendMode.resolve(drawMode)
|
||||
|
||||
val offsetX = if (!sprite!!.flippedHorizontal())
|
||||
hitboxTranslateX * scale
|
||||
else
|
||||
sprite!!.cellWidth * scale - (hitbox.width + hitboxTranslateX * scale)
|
||||
|
||||
val offsetX = hitboxTranslateX * scale
|
||||
val offsetY = sprite!!.cellHeight * scale - hitbox.height - hitboxTranslateY * scale - 1
|
||||
|
||||
if (WorldCamera.xCentre > leftsidePadding && centrePosPoint.x <= rightsidePadding) {
|
||||
// camera center neg, actor center pos
|
||||
sprite!!.render(g,
|
||||
sprite!!.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat() + world.width * TILE_SIZE,
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
@@ -1255,14 +1238,14 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
}
|
||||
else if (WorldCamera.xCentre < rightsidePadding && centrePosPoint.x >= leftsidePadding) {
|
||||
// camera center pos, actor center neg
|
||||
sprite!!.render(g,
|
||||
sprite!!.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat() - world.width * TILE_SIZE,
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
)
|
||||
}
|
||||
else {
|
||||
sprite!!.render(g,
|
||||
sprite!!.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat(),
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
@@ -1412,16 +1395,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 / (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS)
|
||||
@Transient val SI_TO_GAME_ACC = METER / (TerrarumGDX.TARGET_FPS * TerrarumGDX.TARGET_FPS)
|
||||
/**
|
||||
* [m / s] * SI_TO_GAME_VEL -> [px / InternalFrame]
|
||||
*/
|
||||
@Transient val SI_TO_GAME_VEL = METER / Terrarum.TARGET_FPS
|
||||
@Transient val SI_TO_GAME_VEL = METER / TerrarumGDX.TARGET_FPS
|
||||
|
||||
/**
|
||||
* [px / InternalFrame^2] * GAME_TO_SI_ACC -> [m / s^2]
|
||||
*/
|
||||
@Transient val GAME_TO_SI_ACC = (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS) / METER
|
||||
@Transient val GAME_TO_SI_ACC = (TerrarumGDX.TARGET_FPS * TerrarumGDX.TARGET_FPS) / METER
|
||||
|
||||
|
||||
/**
|
||||
@@ -1442,8 +1425,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
||||
if (x < 0)
|
||||
return 0
|
||||
else if (x >= Terrarum.ingame!!.world.width shl 4)
|
||||
return Terrarum.ingame!!.world.width - 1
|
||||
else if (x >= TerrarumGDX.ingame!!.world.width shl 4)
|
||||
return TerrarumGDX.ingame!!.world.width - 1
|
||||
else
|
||||
return x and 0x7FFFFFFF shr 4
|
||||
}
|
||||
@@ -1451,8 +1434,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
private fun div16TruncateToMapHeight(y: Int): Int {
|
||||
if (y < 0)
|
||||
return 0
|
||||
else if (y >= Terrarum.ingame!!.world.height shl 4)
|
||||
return Terrarum.ingame!!.world.height - 1
|
||||
else if (y >= TerrarumGDX.ingame!!.world.height shl 4)
|
||||
return TerrarumGDX.ingame!!.world.height - 1
|
||||
else
|
||||
return y and 0x7FFFFFFF shr 4
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
/**
|
||||
* Actors that has movement controlled by Keyboard or AI
|
||||
@@ -11,7 +8,7 @@ import org.newdawn.slick.Input
|
||||
*/
|
||||
interface Controllable {
|
||||
|
||||
fun processInput(gc: GameContainer, delta: Int, input: Input)
|
||||
fun processInput(delta: Float)
|
||||
|
||||
fun keyPressed(key: Int, c: Char)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import org.newdawn.slick.SlickException
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-05.
|
||||
@@ -12,7 +10,6 @@ object CreatureBuilder {
|
||||
/**
|
||||
* @Param jsonFileName with extension
|
||||
*/
|
||||
@Throws(IOException::class, SlickException::class)
|
||||
operator fun invoke(module: String, jsonFileName: String): ActorWithPhysics {
|
||||
val actor = ActorWithPhysics(Actor.RenderOrder.MIDDLE)
|
||||
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import net.torvald.terrarum.gameworld.toUint
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.Image
|
||||
import org.newdawn.slick.ImageBuffer
|
||||
import org.newdawn.slick.opengl.ImageData
|
||||
import org.newdawn.slick.opengl.TextureImpl
|
||||
import java.io.File
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.charset.Charset
|
||||
import java.util.*
|
||||
|
||||
@@ -101,9 +96,10 @@ object DecodeTapestry {
|
||||
)
|
||||
|
||||
private fun Int.fourBitCol() = Color(
|
||||
this.and(0xF00).shl(12) + this.and(0xF00).shl(8) +
|
||||
this.and(0x0F0).shl(8) + this.and(0x0F0).shl(4) +
|
||||
this.and(0x00F).shl(4) + this.and(0x00F)
|
||||
this.and(0xF00).shl(20) or this.and(0xF00).shl(16) or
|
||||
this.and(0x0F0).shl(16) or this.and(0x0F0).shl(12) or
|
||||
this.and(0x00F).shl(12) or this.and(0x00F).shl(8) or
|
||||
0xFF
|
||||
)
|
||||
|
||||
val MAGIC = "TEAF".toByteArray(charset = Charset.forName("US-ASCII"))
|
||||
@@ -157,36 +153,24 @@ object DecodeTapestry {
|
||||
|
||||
val imageDataSize = file.size - readCounter
|
||||
val height = imageDataSize / width
|
||||
val outImageData = ImageBuffer(width, height)
|
||||
val outImageData = Pixmap(width, height, Pixmap.Format.RGBA8888)
|
||||
val counterOffset = readCounter
|
||||
while (readCounter < file.size) {
|
||||
val ofs = readCounter - counterOffset
|
||||
val palIndex = file[readCounter].toUint()
|
||||
|
||||
if (colourModel == FORMAT_16) {
|
||||
outImageData.setRGBA(
|
||||
ofs % width,
|
||||
ofs / width,
|
||||
colourIndices16[palIndex].redByte,
|
||||
colourIndices16[palIndex].greenByte,
|
||||
colourIndices16[palIndex].blueByte,
|
||||
255
|
||||
)
|
||||
outImageData.setColor(colourIndices16[palIndex])
|
||||
outImageData.drawPixel(ofs % width, ofs / width)
|
||||
}
|
||||
else {
|
||||
outImageData.setRGBA(
|
||||
ofs % width,
|
||||
ofs / width,
|
||||
colourIndices64[palIndex].redByte,
|
||||
colourIndices64[palIndex].greenByte,
|
||||
colourIndices64[palIndex].blueByte,
|
||||
255
|
||||
)
|
||||
outImageData.setColor(colourIndices64[palIndex])
|
||||
outImageData.drawPixel(ofs % width, ofs / width)
|
||||
}
|
||||
|
||||
readCounter++
|
||||
}
|
||||
|
||||
return TapestryObject(outImageData.image.getScaledCopy(2f), artName, authorName)
|
||||
return TapestryObject(outImageData, artName, authorName)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-15.
|
||||
@@ -25,14 +24,15 @@ open class DroppedItem(private val item: GameItem) : ActorWithPhysics(Actor.Rend
|
||||
scale = ItemCodex[item.dynamicID].scale
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
override fun drawBody(g: Graphics) {
|
||||
super.drawBody(g)
|
||||
override fun drawGlow(batch: SpriteBatch) {
|
||||
super.drawGlow(batch)
|
||||
}
|
||||
|
||||
override fun drawGlow(g: Graphics) {
|
||||
super.drawGlow(g)
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
super.drawBody(batch)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -24,8 +26,8 @@ internal class FixtureTikiTorch : FixtureBase(), Luminous {
|
||||
lightBoxList = ArrayList(1)
|
||||
lightBoxList.add(Hitbox(3.0, 0.0, 4.0, 3.0))
|
||||
|
||||
makeNewSprite(10, 27, "assets/graphics/sprites/fixtures/tiki_torch.tga")
|
||||
sprite!!.delay = 200
|
||||
makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 10, 27))
|
||||
sprite!!.delay = 0.2f
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 1.0
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
typealias AnyPlayer = HistoricalFigure
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
import net.torvald.terrarum.gameactors.ai.LuaAIWrapper
|
||||
import net.torvald.terrarum.gamecontroller.mouseX
|
||||
import net.torvald.terrarum.gamecontroller.mouseY
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import org.newdawn.slick.GameContainer
|
||||
|
||||
/**
|
||||
* @param ai AI class. Use LuaAIWrapper for Lua script
|
||||
@@ -51,11 +48,11 @@ 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(gc: GameContainer, delta: Int): Boolean {
|
||||
override fun secondaryUse(delta: Float): Boolean {
|
||||
try {
|
||||
// place the actor to the world
|
||||
this@HumanoidNPC.setPosition(gc.mouseX, gc.mouseY)
|
||||
Terrarum.ingame!!.addNewActor(this@HumanoidNPC)
|
||||
this@HumanoidNPC.setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
TerrarumGDX.ingame!!.addNewActor(this@HumanoidNPC)
|
||||
// successful
|
||||
return true
|
||||
}
|
||||
@@ -80,8 +77,8 @@ open class HumanoidNPC(
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
super.update(gc, delta)
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
ai.update(delta)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +1,50 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
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.gameactors.ActorWithPhysics.Companion.SI_TO_GAME_ACC
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
|
||||
/**
|
||||
* Actors with static sprites and very simple physics
|
||||
*
|
||||
* Created by minjaesong on 2017-01-20.
|
||||
*/
|
||||
open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Int? = null) : Runnable {
|
||||
open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = null) : Runnable {
|
||||
|
||||
/** Will NOT actually delete from the CircularArray */
|
||||
@Volatile var flagDespawn = false
|
||||
|
||||
override fun run() = update(Terrarum.appgc, Terrarum.delta)
|
||||
override fun run() = update(Gdx.graphics.deltaTime)
|
||||
|
||||
var isNoSubjectToGrav = false
|
||||
var dragCoefficient = 3.0
|
||||
|
||||
private val lifetimeMax = maxLifeTime ?: 5000
|
||||
private var lifetimeCounter = 0
|
||||
private val lifetimeMax = maxLifeTime ?: 5f
|
||||
private var lifetimeCounter = 0f
|
||||
|
||||
open val velocity = Vector2(0.0, 0.0)
|
||||
open val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
|
||||
|
||||
open lateinit var body: Image // you might want to use SpriteAnimation
|
||||
open var glow: Image? = null
|
||||
open lateinit var body: TextureRegion // you might want to use SpriteAnimation
|
||||
open var glow: TextureRegion? = null
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
fun update(gc: GameContainer, delta: Int) {
|
||||
fun update(delta: Float) {
|
||||
if (!flagDespawn) {
|
||||
lifetimeCounter += delta
|
||||
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
|
||||
// simple stuck check
|
||||
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(
|
||||
BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(
|
||||
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
|
||||
hitbox.canonicalY.div(TILE_SIZE).floorInt()
|
||||
) ?: Block.STONE].isSolid) {
|
||||
@@ -52,7 +53,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Int? = null
|
||||
|
||||
// gravity, winds, etc. (external forces)
|
||||
if (!isNoSubjectToGrav) {
|
||||
velocity += Terrarum.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
velocity += TerrarumGDX.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
}
|
||||
|
||||
|
||||
@@ -61,15 +62,15 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Int? = null
|
||||
}
|
||||
}
|
||||
|
||||
fun drawBody(g: Graphics) {
|
||||
fun drawBody(batch: SpriteBatch) {
|
||||
if (!flagDespawn) {
|
||||
g.drawImage(body, hitbox.centeredX.toFloat(), hitbox.centeredY.toFloat())
|
||||
batch.draw(body, hitbox.startX.toFloat(), hitbox.startY.toFloat(), hitbox.width.toFloat(), hitbox.height.toFloat())
|
||||
}
|
||||
}
|
||||
|
||||
fun drawGlow(g: Graphics) {
|
||||
fun drawGlow(batch: SpriteBatch) {
|
||||
if (!flagDespawn && glow != null) {
|
||||
g.drawImage(glow, hitbox.centeredX.toFloat(), hitbox.centeredY.toFloat())
|
||||
batch.draw(glow, hitbox.startX.toFloat(), hitbox.startY.toFloat(), hitbox.width.toFloat(), hitbox.height.toFloat())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.Image
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.ModMgr
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-01-20.
|
||||
*/
|
||||
class ParticleTestRain(posX: Double, posY: Double) : ParticleBase(Actor.RenderOrder.BEHIND, 6000) {
|
||||
class ParticleTestRain(posX: Double, posY: Double) : ParticleBase(Actor.RenderOrder.BEHIND, 6f) {
|
||||
|
||||
init {
|
||||
body = Image("./assets/modules/basegame/weathers/raindrop.tga")
|
||||
val w = body.width.toDouble()
|
||||
val h = body.height.toDouble()
|
||||
body = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "weathers/raindrop.tga")))
|
||||
val w = body.regionWidth.toDouble()
|
||||
val h = body.regionHeight.toDouble()
|
||||
hitbox.setFromWidthHeight(
|
||||
posX - w.times(0.5),
|
||||
posY - h.times(0.5),
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.Graphics
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = true) {
|
||||
|
||||
private var color = Color.orange
|
||||
private var color = Color.GOLD
|
||||
|
||||
init {
|
||||
setHitboxDimension(16, 16, 0, 0)
|
||||
@@ -21,26 +20,27 @@ class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = t
|
||||
color = RoguelikeRandomiser.composeColourFrom(RoguelikeRandomiser.POTION_PRIMARY_COLSET)
|
||||
}
|
||||
|
||||
override fun drawBody(g: Graphics) {
|
||||
g.color = color
|
||||
g.fillOval(
|
||||
hitbox.startX.toFloat() - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat(),
|
||||
hitbox.height.toFloat())
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
it.color = color
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
|
||||
g.fillOval(
|
||||
hitbox.startX.toFloat() + Terrarum.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat(),
|
||||
hitbox.height.toFloat())
|
||||
|
||||
g.fillOval(
|
||||
hitbox.startX.toFloat() - Terrarum.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat(),
|
||||
hitbox.height.toFloat())
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() + TerrarumGDX.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.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
}
|
||||
|
||||
//println(moveDelta)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.AmmoMeterProxy
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
/**
|
||||
* A wrapper to support instant player changing (or possessing other NPCs maybe)
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import org.newdawn.slick.GameContainer
|
||||
|
||||
/**
|
||||
* Game player (YOU!)
|
||||
@@ -27,8 +26,8 @@ class Player(born: GameDate) : ActorHumanoid(born) {
|
||||
collisionType = COLLISION_KINEMATIC
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
super.update(gc, delta)
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import org.newdawn.slick.SlickException
|
||||
import java.io.IOException
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-03.
|
||||
*/
|
||||
object PlayerBuilder {
|
||||
private val JSONPATH = "./assets/raw/"
|
||||
private val jsonString = String()
|
||||
|
||||
operator fun invoke(): Actor {
|
||||
val p: Actor = Player(Terrarum.ingame!!.world.time.currentTimeAsGameDate)
|
||||
val p: Actor = Player(TerrarumGDX.ingame!!.world.time.currentTimeAsGameDate)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.ai.LuaAIWrapper
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-25.
|
||||
@@ -23,8 +24,8 @@ object PlayerBuilderCynthia {
|
||||
p.actorValue[AVKey.NAME] = "Cynthia"
|
||||
|
||||
|
||||
p.makeNewSprite(26, 42, ModMgr.getPath("basegame", "sprites/test_player_2.tga"))
|
||||
p.sprite!!.delay = 200
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player_2.tga"), 26, 42))
|
||||
p.sprite!!.delay = 0.2f
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 9, 0)
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.to10bit
|
||||
import org.newdawn.slick.Color
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-03.
|
||||
@@ -20,12 +18,13 @@ object PlayerBuilderSigrid {
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
p.makeNewSprite(28, 51, ModMgr.getPath("basegame", "sprites/test_player.tga"))
|
||||
p.sprite!!.delay = 200
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player.tga"), 28, 51))
|
||||
p.sprite!!.delay = 0.2f
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.makeNewSpriteGlow(28, 51, ModMgr.getPath("basegame", "sprites/test_player_glow.tga"))
|
||||
p.spriteGlow!!.delay = 200
|
||||
p.makeNewSpriteGlow(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player_glow.tga"), 28, 51))
|
||||
p.spriteGlow!!.delay = 0.2f
|
||||
p.spriteGlow!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.actorValue[AVKey.SCALE] = 1.0
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-02-10.
|
||||
@@ -18,8 +19,8 @@ object PlayerBuilderTestSubject1 {
|
||||
p.actorValue[AVKey.NAME] = "Test Subject 1"
|
||||
|
||||
|
||||
p.makeNewSprite(48, 52, ModMgr.getPath("basegame", "sprites/npc_template_anim_prototype.tga"))
|
||||
p.sprite!!.delay = 200
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/npc_template_anim_prototype.tga"), 48, 52))
|
||||
p.sprite!!.delay = 0.2f
|
||||
p.sprite!!.setRowsAndFrames(2, 4)
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
|
||||
@@ -27,7 +27,7 @@ interface Pocketed {
|
||||
}
|
||||
|
||||
inventory.itemEquipped[item.equipPosition] = null
|
||||
item.effectOnUnequip(Terrarum.appgc, Terrarum.delta)
|
||||
item.effectOnUnequip(Gdx.graphics.deltaTime)
|
||||
}
|
||||
|
||||
// no need for equipSlot(Int)
|
||||
@@ -49,7 +49,7 @@ interface Pocketed {
|
||||
|
||||
if (item.equipPosition >= 0) {
|
||||
inventory.itemEquipped[item.equipPosition] = item
|
||||
item.effectWhenEquipped(Terrarum.appgc, Terrarum.delta)
|
||||
item.effectWhenEquipped(Gdx.graphics.deltaTime)
|
||||
}
|
||||
// else do nothing
|
||||
}
|
||||
@@ -68,13 +68,13 @@ interface Pocketed {
|
||||
|
||||
|
||||
fun consumePrimary(item: GameItem) {
|
||||
if (item.primaryUse(Terrarum.appgc, Terrarum.delta)) {
|
||||
if (item.primaryUse(Gdx.graphics.deltaTime)) {
|
||||
inventory.consumeItem(this as Actor, item) // consume on successful
|
||||
}
|
||||
}
|
||||
|
||||
fun consumeSecondary(item: GameItem) {
|
||||
if (item.secondaryUse(Terrarum.appgc, Terrarum.delta))
|
||||
if (item.secondaryUse(Gdx.graphics.deltaTime))
|
||||
inventory.consumeItem(this as Actor, item) // consume on successful
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
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.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,7 @@ open class ProjectileSimple(
|
||||
override val lightBoxList = ArrayList<Hitbox>()
|
||||
|
||||
private val lifetimeMax = 2500
|
||||
private var lifetimeCounter = 0
|
||||
private var lifetimeCounter = 0f
|
||||
|
||||
private val posPre: Point2d
|
||||
|
||||
@@ -68,38 +67,45 @@ open class ProjectileSimple(
|
||||
collisionType = COLLISION_KINEMATIC
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
override fun update(delta: Float) {
|
||||
// hit something and despawn
|
||||
lifetimeCounter += delta
|
||||
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
|
||||
// stuck check
|
||||
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
) {
|
||||
flagDespawn()
|
||||
}
|
||||
|
||||
posPre.set(centrePosPoint)
|
||||
|
||||
super.update(gc, delta)
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
override fun drawBody(g: Graphics) {
|
||||
val colourTail = displayColour.darker(0f) // clone a colour
|
||||
/**
|
||||
* WARNING! ends and begins Batch
|
||||
*/
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
val colourTail = displayColour.cpy() // clone a colour
|
||||
colourTail.a = 0.16f
|
||||
|
||||
// draw trail of solid colour (Terraria style maybe?)
|
||||
g.lineWidth = 2f * Terrarum.ingame!!.screenZoom
|
||||
g.drawGradientLine(
|
||||
hitbox.centeredX.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
hitbox.centeredY.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
displayColour,
|
||||
posPre.x.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
posPre.y.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
colourTail
|
||||
)
|
||||
/*batch.end()
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
// draw trail of solid colour (Terraria style maybe?)
|
||||
it.lineWidth = 2f * TerrarumGDX.ingame!!.screenZoom
|
||||
g.drawGradientLine(
|
||||
hitbox.centeredX.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
hitbox.centeredY.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
displayColour,
|
||||
posPre.x.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
posPre.y.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
colourTail
|
||||
)
|
||||
}
|
||||
batch.begin()*/
|
||||
}
|
||||
|
||||
override fun drawGlow(g: Graphics) = drawBody(g)
|
||||
override fun drawGlow(batch: SpriteBatch) = drawBody(batch)
|
||||
|
||||
companion object {
|
||||
val OFFSET_DAMAGE = 0
|
||||
|
||||
@@ -1,32 +1,37 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gamecontroller.mouseX
|
||||
import net.torvald.terrarum.gamecontroller.mouseY
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
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.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-01-07.
|
||||
*/
|
||||
class TapestryObject(image: Image, val artName: String, val artAuthor: String) : FixtureBase(physics = false) {
|
||||
class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String) : FixtureBase(physics = false) {
|
||||
|
||||
// physics = false only speeds up for ~2 frames with 50 tapestries
|
||||
|
||||
init {
|
||||
image.filter = Image.FILTER_NEAREST
|
||||
makeNewSprite(image.width, image.height, image)
|
||||
setHitboxDimension(image.width, image.height, 0, 0)
|
||||
setPosition(Terrarum.appgc.mouseX, Terrarum.appgc.mouseY)
|
||||
val texture = Texture(pixmap)
|
||||
pixmap.dispose()
|
||||
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest)
|
||||
val texturePack = TextureRegionPack(texture, texture.width, texture.height)
|
||||
|
||||
makeNewSprite(texturePack)
|
||||
setHitboxDimension(texture.width, texture.height, 0, 0)
|
||||
setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
// you CAN'T destroy the image
|
||||
}
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
super.update(gc, delta)
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
override fun drawBody(g: Graphics) {
|
||||
super.drawBody(g)
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
super.drawBody(batch)
|
||||
}
|
||||
|
||||
override var tooltipText: String = "$artName\n$artAuthor"
|
||||
}
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import org.newdawn.slick.GameContainer
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-05-25.
|
||||
*/
|
||||
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int,
|
||||
val gc: GameContainer, val delta: Int) : Runnable {
|
||||
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Runnable {
|
||||
override fun run() {
|
||||
for (i in startIndex..endIndex) {
|
||||
val it = Terrarum.ingame!!.actorContainer[i]
|
||||
it.update(gc, delta)
|
||||
val it = TerrarumGDX.ingame!!.actorContainer[i]
|
||||
it.update(Gdx.graphics.deltaTime)
|
||||
|
||||
if (it is Pocketed) {
|
||||
it.inventory.forEach { inventoryEntry ->
|
||||
inventoryEntry.item.effectWhileInPocket(gc, delta)
|
||||
inventoryEntry.item.effectWhileInPocket(Gdx.graphics.deltaTime)
|
||||
if (it.equipped(inventoryEntry.item)) {
|
||||
inventoryEntry.item.effectWhenEquipped(gc, delta)
|
||||
inventoryEntry.item.effectWhenEquipped(Gdx.graphics.deltaTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.ai
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
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[Terrarum.ingame!!.world.getTileFromTerrain(x, y) ?: Block.NULL]
|
||||
val tile = BlockCodex[TerrarumGDX.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 = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Block.STONE
|
||||
val tile = TerrarumGDX.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 = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
val tile = TerrarumGDX.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 = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
val tile = TerrarumGDX.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 Terrarum.VERSION_STRING.toLua()
|
||||
return TerrarumGDX.VERSION_STRING.toLua()
|
||||
}
|
||||
}
|
||||
|
||||
class GameVersionRaw : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return Terrarum.VERSION_RAW.toLua()
|
||||
return TerrarumGDX.VERSION_RAW.toLua()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ package net.torvald.terrarum.gameactors.ai
|
||||
* Created by minjaesong on 16-03-02.
|
||||
*/
|
||||
interface ActorAI {
|
||||
fun update(delta: Int)
|
||||
fun update(delta: Float)
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class LuaAIWrapper(private val scriptPath: String) : ActorAI {
|
||||
luaInstance.call()
|
||||
}
|
||||
|
||||
override fun update(delta: Int) {
|
||||
override fun update(delta: Float) {
|
||||
// run "update()" function in the script
|
||||
luag.get("update").call(delta.toLua())
|
||||
}
|
||||
@@ -109,5 +109,5 @@ class LuaAIWrapper(private val scriptPath: String) : ActorAI {
|
||||
}
|
||||
}
|
||||
|
||||
fun Int.toLua(): LuaValue = LuaInteger.valueOf(this)
|
||||
fun Float.toLua(): LuaValue = LuaInteger.valueOf(this.toDouble())
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors.faction
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import java.util.HashSet
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.faction
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ object FactionFactory {
|
||||
*/
|
||||
@Throws(IOException::class)
|
||||
fun create(module: String, path: String): Faction {
|
||||
val jsonObj = JsonFetcher(ModMgr.getPath(module, path))
|
||||
val jsonObj = JsonFetcher(ModMgr.getFile(module, path))
|
||||
val factionObj = Faction(jsonObj.get("factionname").asString)
|
||||
|
||||
jsonObj.get("factionamicable").asJsonArray.forEach { factionObj.addFactionAmicable(it.asString) }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors.physicssolver
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
import java.util.*
|
||||
|
||||
@@ -39,7 +39,7 @@ object CollisionSolver {
|
||||
collCandidateY.clear()
|
||||
|
||||
// mark list x
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
TerrarumGDX.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 +72,7 @@ object CollisionSolver {
|
||||
collCandidateStack.clear()
|
||||
|
||||
// mark list y
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
TerrarumGDX.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