dump (another useless message)

This commit is contained in:
minjaesong
2018-08-05 21:57:18 +09:00
parent 0d05a40f8f
commit 6ed012f0c1
130 changed files with 1350 additions and 563 deletions

View File

@@ -1,115 +0,0 @@
package net.torvald.terrarum.modulebasegame.gameactors
/**
* See [res/raw/Creature_raw_doc.md] for information about raw.
*
* Created by minjaesong on 2016-04-02.
*/
object AVKey {
const val BUFF = "buff"
/** pixels per frame
* walking/running speed
*/
const val SPEED = "speed"
const val SPEEDBUFF = "$SPEED$BUFF"
/** pixels per frame squared
* acceleration of the movement (e.g. running, flying, driving, etc.)
*/
const val ACCEL = "accel"
const val ACCELBUFF = "$ACCEL$BUFF"
/** internal value used by ActorHumanoid to implement friction in walkfunction */
const val SCALE = "scale"
const val SCALEBUFF = "$SCALE$BUFF" // aka PHYSIQUE
/** pixels */
const val BASEHEIGHT = "baseheight"
/** kilogrammes */
const val BASEMASS = "basemass"
/** pixels per frame */
const val JUMPPOWER = "jumppower"
const val JUMPPOWERBUFF = "$JUMPPOWER$BUFF"
/** Int
* "Default" value of 1 000
*/
const val STRENGTH = "strength"
const val STRENGTHBUFF = "$STRENGTH$BUFF"
const val ENCUMBRANCE = "encumbrance"
/** 30-bit RGB (Int)
* 0000 0010000000 0010000000 0010000000
* ^ Red ^ Green ^ Blue
*/
const val LUMR = "luminosityred"
const val LUMG = "luminositygreen"
const val LUMB = "luminosityblue"
const val LUMA = "luminosityuv"
const val DRAGCOEFF = "dragcoeff"
const val FALLDAMPENMULT = "falldampenmult"
/** String
* e.g. Jarppi
*/
const val NAME = "name"
/** String
* e.g. Duudsoni
*/
const val RACENAME = "racename"
/** String
* e.g. Duudsonit
*/
const val RACENAMEPLURAL = "racenameplural"
/** killogrammes
* will affect attack strength, speed and inventory label
* (see "Attack momentum calculator.numbers")
* e.g. Hatchet (tiny)
*/
const val TOOLSIZE = "toolsize"
/** Boolean
* whether the player can talk with it
*/
const val INTELLIGENT = "intelligent"
/** (unit TBA)
* base defence point of the species
*/
const val BASEDEFENCE = "basedefence"
/** (unit TBA)
* current defence point of worn armour(s)
*/
const val ARMOURDEFENCE = "armourdefence"
const val ARMOURDEFENCEBUFF = "$ARMOURDEFENCE$BUFF"
const val MAGICREGENRATE = "magicregenrate"
const val MAGICREGENRATEBUFF = "$MAGICREGENRATE$BUFF"
/** Double
*
*/
const val ACTION_INTERVAL = "actioninterval"
/** String
* UUID for certain fixtures
*/
const val UUID = "uuid"
const val __PLAYER_QUICKSLOTSEL = "__quickslotselection"
/** Double
* When using tool/arm/etc. how long action button is held, in milliseconds (Int)
* Or for NPCs, how long it has been waiting for next move
*/
const val __ACTION_TIMER = "__actiontimer"
const val HEALTH = "health"
const val MAGIC = "magic"
const val __HISTORICAL_BORNTIME = "__borntime" // time_t
const val __HISTORICAL_DEADTIME = "__deadtime" // time_t
}

View File

@@ -5,10 +5,7 @@ import com.badlogic.gdx.graphics.Color
import com.jme3.math.FastMath
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.bipolarClamp
import net.torvald.terrarum.gameactors.Controllable
import net.torvald.terrarum.gameactors.Factionable
import net.torvald.terrarum.gameactors.Hitbox
import net.torvald.terrarum.gameactors.Luminous
import net.torvald.terrarum.gameactors.*
import net.torvald.terrarum.gameactors.faction.Faction
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.itemproperties.GameItem
@@ -32,7 +29,7 @@ open class ActorHumanoid(
birth: time_t,
death: time_t? = null,
usePhysics: Boolean = true
) : ActorWithPhysics(world, RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
) : ActorWBMovable(world, RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
@@ -139,8 +136,6 @@ open class ActorHumanoid(
@Transient private var prevHMoveKey = KEY_NULL
@Transient private var prevVMoveKey = KEY_NULL
internal var noClip = false
@Transient private val AXIS_KEYBOARD = -13372f // leetz
@Transient private val GAMEPAD_JUMP = 7
@@ -150,7 +145,7 @@ open class ActorHumanoid(
protected var isRightDown = false
protected var isJumpDown = false
protected inline val isGamer: Boolean
get() = if (Terrarum.ingame == null) false else this == (Terrarum.ingame!! as Ingame).player
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.playableActor
private val nullItem = object : GameItem() {
@@ -174,7 +169,7 @@ open class ActorHumanoid(
override fun update(delta: Float) {
super.update(delta)
if (vehicleRiding is Player)
if (vehicleRiding is IngamePlayer)
throw Error("Attempted to 'ride' player object. ($vehicleRiding)")
if (vehicleRiding != null && vehicleRiding == this)
throw Error("Attempted to 'ride' itself. ($vehicleRiding)")
@@ -188,7 +183,7 @@ open class ActorHumanoid(
updateSprite(delta)
if (noClip) {
if (isNoClip) {
//grounded = true
}
@@ -277,7 +272,7 @@ open class ActorHumanoid(
}
// ↑E
// ↑D
if (isNoClip() && !isUpDown && !isDownDown) {
if (isNoClip && !isUpDown && !isDownDown) {
walkVStop()
prevVMoveKey = KEY_NULL
}
@@ -313,7 +308,7 @@ open class ActorHumanoid(
/**
* Up/Down movement
*/
if (noClip || COLLISION_TEST_MODE) {
if (isNoClip || COLLISION_TEST_MODE) {
if (hasController) {
if (axisY != 0f) {
walkVertical(axisY < 0, axisY.abs())
@@ -343,7 +338,7 @@ open class ActorHumanoid(
* Jump control
*/
if (isJumpDown) {
if (!noClip) {
if (!isNoClip) {
if (airJumpingAllowed ||
(!airJumpingAllowed && walledBottom)) {
jumping = true
@@ -385,7 +380,7 @@ open class ActorHumanoid(
* this code base, ACCELERATION must be changed (in other words, we must deal with JERK) accordingly
* to the FRICTION.
*
* So I'm adding walkX/Y and getting the ActorWithPhysics.setNewNextHitbox to use the velocity value of
* So I'm adding walkX/Y and getting the ActorWBMovable.setNewNextHitbox to use the velocity value of
* walkX/Y + velocity, which is stored in variable moveDelta.
*
* Be warned.
@@ -608,18 +603,6 @@ open class ActorHumanoid(
}
}
fun isNoClip(): Boolean {
return noClip
}
fun setNoClip(b: Boolean) {
noClip = b
if (b) {
externalForce.zero()
controllerMoveDelta?.zero()
}
}
fun Float.abs() = FastMath.abs(this)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.itemproperties.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
@@ -60,10 +61,10 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
if (count < 0)
throw IllegalArgumentException("Item count is negative number. If you intended removing items, use remove()\n" +
"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
if (item.originalID == Terrarum.PLAYER_REF_ID || item.originalID == 0x51621D) // do not delete this magic
throw IllegalArgumentException("Attempted to put human player into the inventory.")
if (((Terrarum.ingame as? Ingame)?.gameFullyLoaded ?: false) &&
(item.originalID == (Terrarum.ingame as? Ingame)?.player?.referenceID))
(item.originalID == (Terrarum.ingame as? Ingame)?.playableActor?.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")

View File

@@ -1,6 +1,8 @@
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.gameworld.GameWorld
@@ -13,8 +15,8 @@ object CreatureBuilder {
/**
* @Param jsonFileName with extension
*/
operator fun invoke(world: GameWorld, module: String, jsonFileName: String): ActorWithPhysics {
val actor = ActorWithPhysics(world, Actor.RenderOrder.MIDDLE)
operator fun invoke(world: GameWorld, module: String, jsonFileName: String): ActorWBMovable {
val actor = ActorWBMovable(world, Actor.RenderOrder.MIDDLE)
InjectCreatureRaw(actor.actorValue, module, jsonFileName)

View File

@@ -173,6 +173,6 @@ object DecodeTapestry {
readCounter++
}
return TapestryObject((Terrarum.ingame!! as Ingame).world, outImageData, artName, authorName)
return TapestryObject((Terrarum.ingame!!.world), outImageData, artName, authorName)
}
}

View File

@@ -4,12 +4,13 @@ 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 net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.gameworld.GameWorld
/**
* Created by minjaesong on 2016-03-15.
*/
open class DroppedItem(world: GameWorld, private val item: GameItem) : ActorWithPhysics(world, RenderOrder.MIDTOP) {
open class DroppedItem(world: GameWorld, private val item: GameItem) : ActorWBMovable(world, RenderOrder.MIDTOP) {
init {
if (item.dynamicID >= ItemCodex.ACTORID_MIN)

View File

@@ -1,12 +1,13 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.gameworld.GameWorld
/**
* Created by minjaesong on 2016-06-17.
*/
open class FixtureBase(world: GameWorld, physics: Boolean = true) :
ActorWithPhysics(world, RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
ActorWBMovable(world, RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
/**
* 0: Open
* 1: Blocked

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Hitbox
import net.torvald.terrarum.gameactors.Luminous
import net.torvald.terrarum.gameworld.GameWorld

View File

@@ -2,11 +2,11 @@ package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AIControlled
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.ai.ActorAI
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.itemproperties.GameItem
import net.torvald.terrarum.itemproperties.Material
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics.Companion.COLLISION_DYNAMIC
import net.torvald.terrarum.modulebasegame.gameworld.time_t
/**

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarum.modulebasegame.gameworld.time_t
@@ -10,27 +11,17 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
* Created by minjaesong on 2015-12-31.
*/
class Player(world: GameWorld, born: time_t) : ActorHumanoid(world, born) {
companion object {
@Transient const val PLAYER_REF_ID: Int = 0x91A7E2
}
class IngamePlayer(world: GameWorldExtension, born: time_t) : ActorHumanoid(world, born) {
/**
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
* **Use PlayerFactory to build player!**
* @throws SlickException
*/
init {
referenceID = PLAYER_REF_ID // forcibly set ID
referenceID = Terrarum.PLAYER_REF_ID // forcibly set ID
density = BASE_DENSITY
collisionType = COLLISION_KINEMATIC
}
override fun update(delta: Float) {
super.update(delta)
}
}

View File

@@ -5,6 +5,7 @@ import net.torvald.random.Fudge3
import net.torvald.terrarum.langpack.Lang
import com.google.gson.JsonObject
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.ActorValue
import java.security.SecureRandom

View File

@@ -4,14 +4,13 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics.Companion.SI_TO_GAME_ACC
import net.torvald.terrarum.gameactors.ActorWBMovable.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 net.torvald.terrarum.floorInt
import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.Hitbox
import net.torvald.terrarum.modulebasegame.Ingame
import org.dyn4j.geometry.Vector2
/**
@@ -48,7 +47,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
if (despawnUponCollision) {
if (velocity.isZero ||
// simple stuck check
BlockCodex[(Terrarum.ingame!! as Ingame).world.getTileFromTerrain(
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
hitbox.canonicalY.div(TILE_SIZE).floorInt()
) ?: Block.STONE].isSolid) {
@@ -62,7 +61,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
// gravity, winds, etc. (external forces)
if (!isNoSubjectToGrav) {
velocity += (Terrarum.ingame!! as Ingame).world.gravitation / dragCoefficient * SI_TO_GAME_ACC
velocity += (Terrarum.ingame!!.world).gravitation / dragCoefficient * SI_TO_GAME_ACC
}

View File

@@ -7,6 +7,7 @@ import net.torvald.random.HQRNG
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Second
import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.ActorWBMovable
/**
* Created by minjaesong on 2017-12-18.
@@ -23,7 +24,7 @@ class ParticleMegaRain(posX: Double, posY: Double) : ParticleBase(Actor.RenderOr
w, h
)
velocity.y = 11.5 * ActorWithPhysics.SI_TO_GAME_VEL
velocity.y = 11.5 * ActorWBMovable.SI_TO_GAME_VEL
}
}

View File

@@ -3,14 +3,14 @@ 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.gameworld.GameWorld
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
/**
* Created by minjaesong on 2016-03-05.
*/
class PhysTestBall(world: GameWorld) : ActorWithPhysics(world, RenderOrder.MIDDLE, immobileBody = true) {
class PhysTestBall(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDDLE, immobileBody = true) {
private var color = Color.GOLD
@@ -32,13 +32,13 @@ class PhysTestBall(world: GameWorld) : ActorWithPhysics(world, RenderOrder.MIDDL
)
it.circle(
hitbox.startX.toFloat() + (Terrarum.ingame!! as Ingame).world.width * TILE_SIZE - 1f,
hitbox.startX.toFloat() + (Terrarum.ingame!!.world).width * TILE_SIZE - 1f,
hitbox.startY.toFloat() - 1f,
hitbox.width.toFloat()
)
it.circle(
hitbox.startX.toFloat() - (Terrarum.ingame!! as Ingame).world.width * TILE_SIZE - 1f,
hitbox.startX.toFloat() - (Terrarum.ingame!!.world).width * TILE_SIZE - 1f,
hitbox.startY.toFloat() - 1f,
hitbox.width.toFloat()
)

View File

@@ -6,6 +6,8 @@ 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.gameworld.GameWorld
@@ -13,7 +15,7 @@ import net.torvald.terrarum.gameworld.GameWorld
/**
* Created by minjaesong on 2018-01-17.
*/
class PhysTestLuarLander(world: GameWorld) : ActorWithPhysics(world, RenderOrder.MIDTOP), Controllable {
class PhysTestLuarLander(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDTOP), Controllable {
private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.modulebasegame.Ingame
@@ -10,7 +11,9 @@ import net.torvald.terrarum.modulebasegame.Ingame
object PlayerBuilder {
operator fun invoke(): Actor {
val p: Actor = Player((Terrarum.ingame!! as Ingame).world, (Terrarum.ingame!! as Ingame).world.time.TIME_T)
val world = (Terrarum.ingame!! as Ingame).gameworld
val p: Actor = IngamePlayer(world, world.time.TIME_T)
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
// attach sprite

View File

@@ -2,8 +2,9 @@ package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.gameactors.ai.NullAI
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -12,10 +13,10 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
*/
object PlayerBuilderCynthia {
operator fun invoke(): ActorWithPhysics {
//val p: Player = Player(GameDate(100, 143)) // random value thrown
operator fun invoke(): ActorWBMovable {
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
val p: HumanoidNPC = HumanoidNPC(
(Terrarum.ingame!! as Ingame).world,
(Terrarum.ingame!!.world),
NullAI(),
-589141658L) // random value thrown
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")

View File

@@ -5,7 +5,9 @@ import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.faction.FactionFactory
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
@@ -14,8 +16,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
object PlayerBuilderSigrid {
operator fun invoke(): Player {
val p = Player((Terrarum.ingame!! as Ingame).world, -9223372036854775807L) // XD
operator fun invoke(): IngamePlayer {
val p = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -9223372036854775807L) // XD
p.referenceID = 0x51621D // the only constant of this procedural universe

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -10,8 +11,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
* Created by minjaesong on 2017-02-10.
*/
object PlayerBuilderTestSubject1 {
operator fun invoke(): Player {
val p: Player = Player((Terrarum.ingame!! as Ingame).world, -589141658L) // random value thrown
operator fun invoke(): IngamePlayer {
val p: IngamePlayer = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -589141658L) // random value thrown
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")

View File

@@ -2,14 +2,14 @@ package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.point.Point2d
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.Hitbox
import net.torvald.terrarum.gameactors.Luminous
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.modulebasegame.Ingame
import org.dyn4j.geometry.Vector2
import java.util.*
@@ -25,7 +25,7 @@ open class ProjectileSimple(
private val type: Int,
fromPoint: Vector2, // projected coord
toPoint: Vector2 // arriving coord
) : ActorWithPhysics(world, RenderOrder.MIDTOP), Luminous, Projectile {
) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous, Projectile {
val damage: Int
val displayColour: Color
@@ -77,7 +77,7 @@ open class ProjectileSimple(
lifetimeCounter += delta
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
// stuck check
BlockCodex[(Terrarum.ingame!! as Ingame).world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
) {
flagDespawn()
}

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.graphics.Color
import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.gameactors.Hitbox
import net.torvald.terrarum.gameactors.Luminous
import net.torvald.terrarum.gameworld.GameWorld
@@ -8,7 +9,7 @@ import net.torvald.terrarum.gameworld.GameWorld
/**
* Created by minjaesong on 2016-04-26.
*/
class WeaponSwung(world: GameWorld, val itemID: Int) : ActorWithPhysics(world, RenderOrder.MIDTOP), Luminous {
class WeaponSwung(world: GameWorld, val itemID: Int) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous {
// just let the solver use AABB; it's cheap but works just enough
/**

View File

@@ -35,7 +35,7 @@ class SmarterSlimes : ActorAI {
// TEST: just target player
val playerXPos = (Terrarum.ingame!! as Ingame).player.centrePosPoint.x
val playerXPos = (Terrarum.ingame!! as Ingame).playableActor.centrePosPoint.x
val thisXPos = actor.centrePosPoint.x
val xDiff = thisXPos - playerXPos

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
import net.torvald.terrarum.gameactors.ActorWBMovable
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<ActorWithPhysics, ActorWithPhysics>>(COLL_CANDIDATES_SIZE)
private val collCandidateY = ArrayList<Pair<ActorWithPhysics, ActorWithPhysics>>(COLL_CANDIDATES_SIZE)
private var collCandidates = ArrayList<Pair<ActorWithPhysics, ActorWithPhysics>>(COLL_FINAL_CANDIDATES_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 collCandidateStack = Stack<CollisionMarkings>()
@@ -40,7 +40,7 @@ object CollisionSolver {
// mark list x
(Terrarum.ingame!! as Ingame).actorContainer.forEach { it ->
if (it is ActorWithPhysics) {
if (it is ActorWBMovable) {
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 Ingame).actorContainer.forEach { it ->
if (it is ActorWithPhysics) {
if (it is ActorWBMovable) {
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<ActorWithPhysics, ActorWithPhysics>
val collCandidate: Pair<ActorWBMovable, ActorWBMovable>
// 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: ActorWithPhysics, b: ActorWithPhysics) {
private fun solveCollision(a: ActorWBMovable, b: ActorWBMovable) {
// 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 ActorWithPhysics.makesCollisionWith(other: ActorWithPhysics) =
this.collisionType != ActorWithPhysics.COLLISION_NOCOLLIDE &&
other.collisionType != ActorWithPhysics.COLLISION_NOCOLLIDE
private infix fun ActorWBMovable.makesCollisionWith(other: ActorWBMovable) =
this.collisionType != ActorWBMovable.COLLISION_NOCOLLIDE &&
other.collisionType != ActorWBMovable.COLLISION_NOCOLLIDE
private infix fun ActorWithPhysics.isCollidingWith(other: ActorWithPhysics): Boolean {
private infix fun ActorWBMovable.isCollidingWith(other: ActorWBMovable): 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: ActorWithPhysics
val actor: ActorWBMovable
)
/**

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
import net.torvald.terrarum.gameactors.ActorWBMovable
/**
* Created by minjaesong on 2016-05-01.
@@ -11,7 +11,7 @@ object VelocitySolver {
}
private fun applyGravity(actor: ActorWithPhysics) {
private fun applyGravity(actor: ActorWBMovable) {
}