mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
Reducing hierarchy by merging ActorWithBody with ActorWBMovable
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package net.torvald.aa
|
||||
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.sqr
|
||||
|
||||
/**
|
||||
@@ -17,34 +17,34 @@ import net.torvald.terrarum.sqr
|
||||
* Remarks:
|
||||
* - NOT using the fullCodePage with 2x2 mode makes it slower... skewed tree generation?
|
||||
*/
|
||||
class KDHeapifiedTree(actors: List<ActorWBMovable>) {
|
||||
class KDHeapifiedTree(actors: List<ActorWithBody>) {
|
||||
|
||||
private val dimension = 2
|
||||
private val initialSize = 128
|
||||
private val nodes = Array<ActorWBMovable?>(initialSize, { null })
|
||||
private val nodes = Array<ActorWithBody?>(initialSize, { null })
|
||||
|
||||
private val root: Int = 0
|
||||
|
||||
fun findNearestActor(query: Point2d): ActorWBMovable =
|
||||
fun findNearestActor(query: Point2d): ActorWithBody =
|
||||
getNearest(root, query, 0).getActor()!!
|
||||
|
||||
private fun Int.get() = nodes[this]?.feetPosPoint
|
||||
private fun Int.getActor() = nodes[this]
|
||||
private fun Int.getLeft() = this * 2 + 1
|
||||
private fun Int.getRight() = this * 2 + 2
|
||||
private fun Int.set(value: ActorWBMovable?) {
|
||||
private fun Int.set(value: ActorWithBody?) {
|
||||
try {
|
||||
nodes[this] = value
|
||||
}
|
||||
catch (_: ArrayIndexOutOfBoundsException) {
|
||||
// modification of the private fun expandArray()
|
||||
val prevNodes = nodes.copyOf() + value
|
||||
Array<ActorWBMovable?>(prevNodes.size * 2, { null })
|
||||
Array<ActorWithBody?>(prevNodes.size * 2, { null })
|
||||
create(prevNodes.toList(), 0, 0)
|
||||
}
|
||||
}
|
||||
private fun Int.setLeftChild(value: ActorWBMovable?) { nodes[this.getLeft()] = value }
|
||||
private fun Int.setRightChild(value: ActorWBMovable?) { nodes[this.getRight()] = value }
|
||||
private fun Int.setLeftChild(value: ActorWithBody?) { nodes[this.getLeft()] = value }
|
||||
private fun Int.setRightChild(value: ActorWithBody?) { nodes[this.getRight()] = value }
|
||||
|
||||
private val zeroPoint = Point2d(0.0, 0.0)
|
||||
|
||||
@@ -52,7 +52,7 @@ class KDHeapifiedTree(actors: List<ActorWBMovable>) {
|
||||
create(actors, 0, 0)
|
||||
}
|
||||
|
||||
private fun create(points: List<ActorWBMovable?>, depth: Int, index: Int): ActorWBMovable? {
|
||||
private fun create(points: List<ActorWithBody?>, depth: Int, index: Int): ActorWithBody? {
|
||||
if (points.isEmpty()) {
|
||||
index.set(null)
|
||||
|
||||
@@ -103,7 +103,7 @@ class KDHeapifiedTree(actors: List<ActorWBMovable>) {
|
||||
|
||||
private fun expandArray() {
|
||||
val prevNodes = nodes.copyOf()
|
||||
Array<ActorWBMovable?>(prevNodes.size * 2, { null })
|
||||
Array<ActorWithBody?>(prevNodes.size * 2, { null })
|
||||
create(prevNodes.toList(), 0, 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* This class should not be serialised; save its Animation Description Language instead.
|
||||
*/
|
||||
class SpriteAnimation(@Transient val parentActor: ActorWBMovable) {
|
||||
class SpriteAnimation(@Transient val parentActor: ActorWithBody) {
|
||||
|
||||
lateinit var textureRegion: TextureRegionPack; private set
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
}
|
||||
|
||||
private class CameraPlayer(val demoWorld: GameWorld, override val ai: ActorAI) : ActorWithBody(RenderOrder.FRONT), AIControlled {
|
||||
private class CameraPlayer(val demoWorld: GameWorld, override val ai: ActorAI) : ActorWithBody(RenderOrder.FRONT, usePhysics = false), AIControlled {
|
||||
|
||||
override val hitbox = Hitbox(0.0, 0.0, 2.0, 2.0)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -134,7 +134,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
val blockMarkings = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common")
|
||||
internal var showSelection = true
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY, usePhysics = false) {
|
||||
|
||||
override var referenceID: ActorID = 1048575 // custom refID
|
||||
override val hitbox = Hitbox(0.0, 0.0, 16.0, 16.0)
|
||||
@@ -175,7 +175,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private var _testMarkerDrawCalls = 0L
|
||||
|
||||
private fun generateNewBlockMarkerVisible(x: Int, y: Int) = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
||||
private fun generateNewBlockMarkerVisible(x: Int, y: Int) = object : ActorWithBody(Actor.RenderOrder.OVERLAY, usePhysics = false) {
|
||||
override var referenceID: ActorID = blockPosToRefID(x, y) // custom refID
|
||||
override val hitbox = Hitbox(x * 16.0, y * 16.0, 16.0, 16.0)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-01-20.
|
||||
@@ -24,7 +24,7 @@ internal object SetScale : ConsoleCommand {
|
||||
|
||||
val target = Terrarum.ingame!!.getActorByID(targetID!!)
|
||||
|
||||
if (target !is ActorWBMovable) {
|
||||
if (target !is ActorWithBody) {
|
||||
EchoError("Target is not ActorWBMovable")
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
|
||||
@@ -34,8 +34,8 @@ internal object Teleport : ConsoleCommand {
|
||||
EchoError("missing 'to' on teleport command")
|
||||
return
|
||||
}
|
||||
val fromActor: ActorWBMovable
|
||||
val targetActor: ActorWBMovable
|
||||
val fromActor: ActorWithBody
|
||||
val targetActor: ActorWithBody
|
||||
try {
|
||||
val fromActorID = args[1].toInt()
|
||||
val targetActorID = if (args[3].toLowerCase() == "player") {
|
||||
@@ -53,13 +53,13 @@ internal object Teleport : ConsoleCommand {
|
||||
// if from == target, ignore the action
|
||||
if (fromActorID == targetActorID) return
|
||||
|
||||
if (Terrarum.ingame!!.getActorByID(fromActorID) !is ActorWBMovable ||
|
||||
Terrarum.ingame!!.getActorByID(targetActorID) !is ActorWBMovable) {
|
||||
if (Terrarum.ingame!!.getActorByID(fromActorID) !is ActorWithBody ||
|
||||
Terrarum.ingame!!.getActorByID(targetActorID) !is ActorWithBody) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
fromActor = Terrarum.ingame!!.getActorByID(fromActorID) as ActorWBMovable
|
||||
targetActor = Terrarum.ingame!!.getActorByID(targetActorID) as ActorWBMovable
|
||||
fromActor = Terrarum.ingame!!.getActorByID(fromActorID) as ActorWithBody
|
||||
targetActor = Terrarum.ingame!!.getActorByID(targetActorID) as ActorWithBody
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
@@ -82,7 +82,7 @@ internal object Teleport : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
val actor: ActorWBMovable
|
||||
val actor: ActorWithBody
|
||||
val x: Int
|
||||
val y: Int
|
||||
try {
|
||||
@@ -90,11 +90,11 @@ internal object Teleport : ConsoleCommand {
|
||||
y = args[4].toInt() * CreateTileAtlas.TILE_SIZE + CreateTileAtlas.TILE_SIZE / 2
|
||||
val actorID = args[1].toInt()
|
||||
|
||||
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWBMovable) {
|
||||
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWithBody) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
actor = Terrarum.ingame!!.getActorByID(actorID) as ActorWBMovable
|
||||
actor = Terrarum.ingame!!.getActorByID(actorID) as ActorWithBody
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.ccY
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.console.SetAV
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
@@ -32,7 +32,7 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
private val avPosArea = JTextArea()
|
||||
private val avPosScroller = JScrollPane(avPosArea)
|
||||
|
||||
private var actor: ActorWBMovable? = null
|
||||
private var actor: ActorWithBody? = null
|
||||
private var actorValue: ActorValue? = null
|
||||
|
||||
private val modavInputKey = JTextField()
|
||||
@@ -91,7 +91,7 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
else if (actorIDField.text.isNotBlank()) {
|
||||
actor = Terrarum.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWBMovable
|
||||
actor = Terrarum.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWithBody
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
|
||||
this.title = "AVTracker $EMDASH $actor"
|
||||
|
||||
if (actor is ActorWBMovable) {
|
||||
if (actor is ActorWithBody) {
|
||||
this.actor = actor
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ open class ActorHumanoid(
|
||||
birth: Long,
|
||||
death: Long? = null,
|
||||
usePhysics: Boolean = true
|
||||
) : ActorWBMovable(RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||
) : ActorWithBody(RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||
|
||||
private val world: GameWorld?
|
||||
get() = Terrarum.ingame?.world
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ object CreatureBuilder {
|
||||
/**
|
||||
* @Param jsonFileName with extension
|
||||
*/
|
||||
operator fun invoke(module: String, jsonFileName: String): ActorWBMovable {
|
||||
val actor = ActorWBMovable(Actor.RenderOrder.MIDDLE)
|
||||
operator fun invoke(module: String, jsonFileName: String): ActorWithBody {
|
||||
val actor = ActorWithBody(Actor.RenderOrder.MIDDLE)
|
||||
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
||||
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-15.
|
||||
*/
|
||||
open class DroppedItem(private val item: GameItem) : ActorWBMovable(RenderOrder.MIDTOP) {
|
||||
open class DroppedItem(private val item: GameItem) : ActorWithBody(RenderOrder.MIDTOP) {
|
||||
|
||||
init {
|
||||
if (item.dynamicID >= ItemCodex.ACTORID_MIN)
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
|
||||
@@ -19,7 +19,7 @@ open class FixtureBase(
|
||||
val mainUI: UICanvas? = null
|
||||
|
||||
// disabling physics (not allowing the fixture to move) WILL make things easier in many ways
|
||||
) : ActorWBMovable(renderOrder, immobileBody = true, usePhysics = false), CuedByTerrainChange {
|
||||
) : ActorWithBody(renderOrder, immobileBody = true, usePhysics = false), CuedByTerrainChange {
|
||||
|
||||
var blockBox: BlockBox = blockBox0
|
||||
protected set // something like TapestryObject will want to redefine this
|
||||
|
||||
@@ -3,13 +3,13 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-05.
|
||||
*/
|
||||
class PhysTestBall : ActorWBMovable(RenderOrder.MIDDLE, immobileBody = true) {
|
||||
class PhysTestBall : ActorWithBody(RenderOrder.MIDDLE, immobileBody = true) {
|
||||
|
||||
private var color = Color.GOLD
|
||||
|
||||
|
||||
@@ -6,15 +6,12 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.Controllable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-01-17.
|
||||
*/
|
||||
class PhysTestLuarLander : ActorWBMovable(RenderOrder.MIDTOP), Controllable {
|
||||
class PhysTestLuarLander : ActorWithBody(RenderOrder.MIDTOP), Controllable {
|
||||
|
||||
private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ai.NullAI
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -12,7 +12,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
object PlayerBuilderCynthia {
|
||||
|
||||
operator fun invoke(): ActorWBMovable {
|
||||
operator fun invoke(): ActorWithBody {
|
||||
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
|
||||
val p: HumanoidNPC = HumanoidNPC(
|
||||
NullAI(),
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -24,7 +24,7 @@ open class ProjectileSimple(
|
||||
private val type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ActorWBMovable(RenderOrder.MIDTOP), Luminous, Projectile {
|
||||
) : ActorWithBody(RenderOrder.MIDTOP), Luminous, Projectile {
|
||||
|
||||
val damage: Int
|
||||
val displayColour: Color
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-04-26.
|
||||
*/
|
||||
class WeaponSwung(val itemID: Int) : ActorWBMovable(RenderOrder.MIDTOP), Luminous {
|
||||
class WeaponSwung(val itemID: Int) : ActorWithBody(RenderOrder.MIDTOP), Luminous {
|
||||
// just let the solver use AABB; it's cheap but works just enough
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -20,9 +20,9 @@ object CollisionSolver {
|
||||
private val collListX = ArrayList<CollisionMarkings>(COLL_LIST_SIZE)
|
||||
private val collListY = ArrayList<CollisionMarkings>(COLL_LIST_SIZE)
|
||||
|
||||
private val collCandidateX = ArrayList<Pair<ActorWBMovable, ActorWBMovable>>(COLL_CANDIDATES_SIZE)
|
||||
private val collCandidateY = ArrayList<Pair<ActorWBMovable, ActorWBMovable>>(COLL_CANDIDATES_SIZE)
|
||||
private var collCandidates = ArrayList<Pair<ActorWBMovable, ActorWBMovable>>(COLL_FINAL_CANDIDATES_SIZE)
|
||||
private val collCandidateX = ArrayList<Pair<ActorWithBody, ActorWithBody>>(COLL_CANDIDATES_SIZE)
|
||||
private val collCandidateY = ArrayList<Pair<ActorWithBody, ActorWithBody>>(COLL_CANDIDATES_SIZE)
|
||||
private var collCandidates = ArrayList<Pair<ActorWithBody, ActorWithBody>>(COLL_FINAL_CANDIDATES_SIZE)
|
||||
|
||||
private val collCandidateStack = Stack<CollisionMarkings>()
|
||||
|
||||
@@ -40,7 +40,7 @@ object CollisionSolver {
|
||||
|
||||
// mark list x
|
||||
(Terrarum.ingame!! as TerrarumIngame).actorContainerActive.forEach { it ->
|
||||
if (it is ActorWBMovable) {
|
||||
if (it is ActorWithBody && it.usePhysics) {
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
||||
}
|
||||
@@ -73,7 +73,7 @@ object CollisionSolver {
|
||||
|
||||
// mark list y
|
||||
(Terrarum.ingame!! as TerrarumIngame).actorContainerActive.forEach { it ->
|
||||
if (it is ActorWBMovable) {
|
||||
if (it is ActorWithBody && it.usePhysics) {
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
||||
}
|
||||
@@ -89,7 +89,7 @@ object CollisionSolver {
|
||||
else if (it.kind == ENDPOINT) {
|
||||
val mark_this = it
|
||||
val mark_other = collCandidateStack.pop()
|
||||
val collCandidate: Pair<ActorWBMovable, ActorWBMovable>
|
||||
val collCandidate: Pair<ActorWithBody, ActorWithBody>
|
||||
// make sure actor with lower ID comes first
|
||||
if (mark_this.actor < mark_other.actor)
|
||||
collCandidate = Pair(mark_this.actor, mark_other.actor)
|
||||
@@ -137,7 +137,7 @@ object CollisionSolver {
|
||||
return indexOfEqFn(this, other) >= 0
|
||||
}
|
||||
|
||||
private fun solveCollision(a: ActorWBMovable, b: ActorWBMovable) {
|
||||
private fun solveCollision(a: ActorWithBody, b: ActorWithBody) {
|
||||
// some of the Pair(a, b) are either duplicates or erroneously reported.
|
||||
// e.g. (A, B), (B, C) and then (A, C);
|
||||
// in some situation (A, C) will not making any contact with each other
|
||||
@@ -173,11 +173,11 @@ object CollisionSolver {
|
||||
}
|
||||
}
|
||||
|
||||
private infix fun ActorWBMovable.makesCollisionWith(other: ActorWBMovable) =
|
||||
this.collisionType != ActorWBMovable.COLLISION_NOCOLLIDE &&
|
||||
other.collisionType != ActorWBMovable.COLLISION_NOCOLLIDE
|
||||
private infix fun ActorWithBody.makesCollisionWith(other: ActorWithBody) =
|
||||
this.collisionType != ActorWithBody.COLLISION_NOCOLLIDE &&
|
||||
other.collisionType != ActorWithBody.COLLISION_NOCOLLIDE
|
||||
|
||||
private infix fun ActorWBMovable.isCollidingWith(other: ActorWBMovable): Boolean {
|
||||
private infix fun ActorWithBody.isCollidingWith(other: ActorWithBody): Boolean {
|
||||
val ax = this.hitbox.centeredX
|
||||
val ay = this.hitbox.centeredY
|
||||
val bx = other.hitbox.centeredX
|
||||
@@ -208,7 +208,7 @@ object CollisionSolver {
|
||||
data class CollisionMarkings(
|
||||
val pos: Double,
|
||||
val kind: Int,
|
||||
val actor: ActorWBMovable
|
||||
val actor: ActorWithBody
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-05-01.
|
||||
@@ -11,7 +11,7 @@ object VelocitySolver {
|
||||
|
||||
}
|
||||
|
||||
private fun applyGravity(actor: ActorWBMovable) {
|
||||
private fun applyGravity(actor: ActorWithBody) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameitems
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -35,7 +35,7 @@ object BlockBase {
|
||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK) {
|
||||
var ret1 = true
|
||||
ingame.actorContainerActive.forEach {
|
||||
if (it is ActorWBMovable && it.intTilewiseHitbox.intersects(mousePoint))
|
||||
if (it is ActorWithBody && it.usePhysics && it.intTilewiseHitbox.intersects(mousePoint))
|
||||
ret1 = false // return is not allowed here
|
||||
}
|
||||
if (!ret1) return ret1
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.torvald.ENDASH
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.*
|
||||
import net.torvald.terrarum.blockstats.MinimapComposer
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
@@ -136,7 +136,7 @@ class UIInventoryFull(
|
||||
UIItemInventoryEquippedView(
|
||||
this,
|
||||
actor.inventory,
|
||||
actor as ActorWBMovable,
|
||||
actor as ActorWithBody,
|
||||
internalWidth - UIItemInventoryEquippedView.WIDTH + (AppLoader.screenW - internalWidth) / 2,
|
||||
107 + (AppLoader.screenH - internalHeight) / 2
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
@@ -21,7 +21,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
class UIItemInventoryEquippedView(
|
||||
parentUI: UIInventoryFull,
|
||||
val inventory: ActorInventory,
|
||||
val theActor: ActorWBMovable,
|
||||
val theActor: ActorWithBody,
|
||||
override var posX: Int,
|
||||
override var posY: Int
|
||||
) : UIItem(parentUI) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
import net.torvald.terrarum.concurrent.sliceEvenly
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
@@ -334,7 +333,7 @@ object LightmapRenderer {
|
||||
lanternMap.clear()
|
||||
actorContainers.forEach { actorContainer ->
|
||||
actorContainer?.forEach {
|
||||
if (it is Luminous && it is ActorWBMovable) {
|
||||
if (it is Luminous && it is ActorWithBody) {
|
||||
// put lanterns to the area the luminantBox is occupying
|
||||
for (lightBox in it.lightBoxList) {
|
||||
val lightBoxX = it.hitbox.startX + lightBox.startX
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.ceilInt
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -73,7 +72,7 @@ object WorldCamera {
|
||||
|
||||
// some hacky equation to position player at the dead centre
|
||||
// implementing the "lag behind" camera the right way
|
||||
val pVecSum = if (player is ActorWBMovable)
|
||||
val pVecSum = if (player is ActorWithBody)
|
||||
player.externalV + (player.controllerV ?: nullVec)
|
||||
else
|
||||
nullVec
|
||||
|
||||
Reference in New Issue
Block a user