mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
portalPoint to the world
This commit is contained in:
@@ -909,6 +909,7 @@ public class App implements ApplicationListener {
|
||||
currentScreen.show();
|
||||
currentScreen.resize(scr.getWidth(), scr.getHeight());
|
||||
|
||||
TerrarumGlobalState.INSTANCE.getHAS_KEYBOARD_INPUT_FOCUS().unset();
|
||||
|
||||
System.gc();
|
||||
|
||||
|
||||
@@ -122,4 +122,6 @@ class Point2i() {
|
||||
|
||||
operator fun component1() = x
|
||||
operator fun component2() = y
|
||||
|
||||
fun toVector() = Vector2(this.x.toDouble(), this.y.toDouble())
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package net.torvald.terrarum
|
||||
*/
|
||||
object TerrarumGlobalState {
|
||||
|
||||
var HAS_KEYBOARD_INPUT_FOCUS = CountedBool()
|
||||
val HAS_KEYBOARD_INPUT_FOCUS = CountedBool()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,14 @@ open class GameWorld(
|
||||
/** Tilewise spawn point */
|
||||
var spawnY: Int = 0
|
||||
|
||||
var spawnPoint: Point2i
|
||||
get() = Point2i(spawnX, spawnY)
|
||||
set(value) {
|
||||
spawnX = value.x
|
||||
spawnY = value.y
|
||||
}
|
||||
var portalPoint: Point2i? = null
|
||||
|
||||
val wallDamages = HashArray<Float>()
|
||||
val terrainDamages = HashArray<Float>()
|
||||
val fluidTypes = HashedFluidType()
|
||||
|
||||
@@ -390,7 +390,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
printdbg(this, "No mapping found")
|
||||
printdbg(this, "Changing XY Position ${codices.player.hitbox.canonVec} -> (${world.spawnX * TILE_SIZED}, ${world.spawnY * TILE_SIZED})")
|
||||
|
||||
codices.player.setPosition(world.spawnX * TILE_SIZED, world.spawnY * TILE_SIZED)
|
||||
codices.player.setPosition((world.portalPoint ?: world.spawnPoint).toVector() * TILE_SIZED)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,10 +424,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
// go to spawn position
|
||||
printdbg(this, "World Spawn position: (${world.spawnX}, ${world.spawnY})")
|
||||
actorGamer.setPosition(
|
||||
world.spawnX * TILE_SIZED,
|
||||
world.spawnY * TILE_SIZED
|
||||
)
|
||||
actorGamer.setPosition(world.spawnPoint.toVector() * TILE_SIZED)
|
||||
actorGamer.backupPlayerProps(isMultiplayer)
|
||||
|
||||
// make initial savefile
|
||||
|
||||
@@ -150,6 +150,13 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE, null)
|
||||
protected constructor(renderOrder: RenderOrder, physProp: PhysProperties, id: ActorID?) : super(renderOrder, physProp, id)
|
||||
|
||||
/**
|
||||
* Callend whenever the fixture was spawned successfully.
|
||||
*
|
||||
* @param tx bottom-centre tilewise point of the spawned fixture
|
||||
* @param ty bottom-centre tilewise point of the spawned fixture
|
||||
*/
|
||||
open fun onSpawn(tx: Int, ty: Int) {}
|
||||
|
||||
/**
|
||||
* Making the sprite: do not address the CommonResourcePool directly; just do it like this snippet:
|
||||
@@ -278,6 +285,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
actorThatInstalledThisFixture = installersUUID
|
||||
|
||||
onSpawn(posX0, posY0)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.random.XXHash64
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.WireCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
@@ -111,6 +108,10 @@ class FixtureWorldPortal : Electric {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSpawn(tx: Int, ty: Int) {
|
||||
INGAME.world.portalPoint = Point2i(tx, ty)
|
||||
}
|
||||
|
||||
override fun reload() {
|
||||
super.reload()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user