mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 13:04:05 +09:00
Reducing hierarchy by merging ActorWithBody with ActorWBMovable
This commit is contained in:
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user