mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
abolished a need to pass world as parametre
+ simply changing the single variable (ingame.world) will update all the renderer's behaviour + somehow my git changelogs are exploding
This commit is contained in:
@@ -25,12 +25,13 @@ import java.util.*
|
||||
* Created by minjaesong on 2016-10-24.
|
||||
*/
|
||||
open class ActorHumanoid(
|
||||
world: GameWorld,
|
||||
birth: time_t,
|
||||
death: time_t? = null,
|
||||
usePhysics: Boolean = true
|
||||
) : ActorWBMovable(world, RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||
) : ActorWBMovable(RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||
|
||||
private val world: GameWorld?
|
||||
get() = Terrarum.ingame?.world
|
||||
|
||||
|
||||
var vehicleRiding: Controllable? = null // usually player only
|
||||
@@ -50,11 +51,11 @@ open class ActorHumanoid(
|
||||
override var houseDesignation: ArrayList<Long>? = ArrayList()
|
||||
|
||||
override fun addHouseTile(x: Int, y: Int) {
|
||||
if (houseDesignation != null) houseDesignation!!.add(LandUtil.getBlockAddr(world, x, y))
|
||||
if (houseDesignation != null) houseDesignation!!.add(LandUtil.getBlockAddr(world!!, x, y))
|
||||
}
|
||||
|
||||
override fun removeHouseTile(x: Int, y: Int) {
|
||||
if (houseDesignation != null) houseDesignation!!.remove(LandUtil.getBlockAddr(world, x, y))
|
||||
if (houseDesignation != null) houseDesignation!!.remove(LandUtil.getBlockAddr(world!!, x, y))
|
||||
}
|
||||
|
||||
override fun clearHouseDesignation() {
|
||||
|
||||
@@ -15,8 +15,8 @@ object CreatureBuilder {
|
||||
/**
|
||||
* @Param jsonFileName with extension
|
||||
*/
|
||||
operator fun invoke(world: GameWorld, module: String, jsonFileName: String): ActorWBMovable {
|
||||
val actor = ActorWBMovable(world, Actor.RenderOrder.MIDDLE)
|
||||
operator fun invoke(module: String, jsonFileName: String): ActorWBMovable {
|
||||
val actor = ActorWBMovable(Actor.RenderOrder.MIDDLE)
|
||||
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
||||
|
||||
|
||||
|
||||
@@ -173,6 +173,6 @@ object DecodeTapestry {
|
||||
readCounter++
|
||||
}
|
||||
|
||||
return TapestryObject((Terrarum.ingame!!.world), outImageData, artName, authorName)
|
||||
return TapestryObject(outImageData, artName, authorName)
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-15.
|
||||
*/
|
||||
open class DroppedItem(world: GameWorld, private val item: GameItem) : ActorWBMovable(world, RenderOrder.MIDTOP) {
|
||||
open class DroppedItem(private val item: GameItem) : ActorWBMovable(RenderOrder.MIDTOP) {
|
||||
|
||||
init {
|
||||
if (item.dynamicID >= ItemCodex.ACTORID_MIN)
|
||||
|
||||
@@ -6,8 +6,8 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
/**
|
||||
* Created by minjaesong on 2016-06-17.
|
||||
*/
|
||||
open class FixtureBase(world: GameWorld, physics: Boolean = true) :
|
||||
ActorWBMovable(world, RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
|
||||
open class FixtureBase(physics: Boolean = true) :
|
||||
ActorWBMovable(RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
|
||||
/**
|
||||
* 0: Open
|
||||
* 1: Blocked
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.*
|
||||
/**
|
||||
* Created by minjaesong on 2016-06-17.
|
||||
*/
|
||||
internal class FixtureTikiTorch(world: GameWorld) : FixtureBase(world), Luminous {
|
||||
internal class FixtureTikiTorch : FixtureBase(), Luminous {
|
||||
|
||||
override var color: Color
|
||||
get() = BlockCodex[Block.TORCH].luminosity
|
||||
|
||||
@@ -15,12 +15,11 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
* Created by minjaesong on 2016-01-31.
|
||||
*/
|
||||
open class HumanoidNPC(
|
||||
world: GameWorld,
|
||||
override val ai: ActorAI, // it's there for written-in-Kotlin, "hard-wired" AIs
|
||||
born: time_t,
|
||||
usePhysics: Boolean = true,
|
||||
forceAssignRefID: Int? = null
|
||||
) : ActorHumanoid(world, born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
||||
) : ActorHumanoid(born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
||||
|
||||
companion object {
|
||||
val DEFAULT_COLLISION_TYPE = COLLISION_DYNAMIC
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
|
||||
class IngamePlayer(world: GameWorldExtension, born: time_t) : ActorHumanoid(world, born) {
|
||||
class IngamePlayer(born: time_t) : ActorHumanoid(born) {
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-05.
|
||||
*/
|
||||
class PhysTestBall(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDDLE, immobileBody = true) {
|
||||
class PhysTestBall : ActorWBMovable(RenderOrder.MIDDLE, immobileBody = true) {
|
||||
|
||||
private var color = Color.GOLD
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
/**
|
||||
* Created by minjaesong on 2018-01-17.
|
||||
*/
|
||||
class PhysTestLuarLander(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDTOP), Controllable {
|
||||
class PhysTestLuarLander : ActorWBMovable(RenderOrder.MIDTOP), Controllable {
|
||||
|
||||
private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ object PlayerBuilder {
|
||||
operator fun invoke(): Actor {
|
||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||
|
||||
val p: Actor = IngamePlayer(world, world.time.TIME_T)
|
||||
val p: Actor = IngamePlayer(world.time.TIME_T)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -16,7 +16,6 @@ object PlayerBuilderCynthia {
|
||||
operator fun invoke(): ActorWBMovable {
|
||||
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
|
||||
val p: HumanoidNPC = HumanoidNPC(
|
||||
(Terrarum.ingame!!.world),
|
||||
NullAI(),
|
||||
-589141658L) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
object PlayerBuilderSigrid {
|
||||
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -9223372036854775807L) // XD
|
||||
val p = IngamePlayer(-9223372036854775807L) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
object PlayerBuilderTestSubject1 {
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p: IngamePlayer = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -589141658L) // random value thrown
|
||||
val p: IngamePlayer = IngamePlayer(-589141658L) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ import org.dyn4j.geometry.Vector2
|
||||
* Created by minjaesong on 2016-08-29.
|
||||
*/
|
||||
class ProjectileHoming(
|
||||
world: GameWorld,
|
||||
type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ProjectileSimple(world, type, fromPoint, toPoint) {
|
||||
) : ProjectileSimple(type, fromPoint, toPoint) {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,11 +21,10 @@ import java.util.*
|
||||
|
||||
// TODO simplified, lightweight physics (does not call PhysicsSolver)
|
||||
open class ProjectileSimple(
|
||||
world: GameWorld,
|
||||
private val type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous, Projectile {
|
||||
) : ActorWBMovable(RenderOrder.MIDTOP), Luminous, Projectile {
|
||||
|
||||
val damage: Int
|
||||
val displayColour: Color
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
/**
|
||||
* Created by minjaesong on 2017-01-07.
|
||||
*/
|
||||
class TapestryObject(world: GameWorld, pixmap: Pixmap, val artName: String, val artAuthor: String) : FixtureBase(world, 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
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
/**
|
||||
* Created by minjaesong on 2016-04-26.
|
||||
*/
|
||||
class WeaponSwung(world: GameWorld, val itemID: Int) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous {
|
||||
class WeaponSwung(val itemID: Int) : ActorWBMovable(RenderOrder.MIDTOP), Luminous {
|
||||
// just let the solver use AABB; it's cheap but works just enough
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user