portalPoint to the world

This commit is contained in:
minjaesong
2023-09-05 01:40:20 +09:00
parent c4deba14da
commit 8fa9ddeec1
7 changed files with 28 additions and 10 deletions

View File

@@ -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();

View File

@@ -122,4 +122,6 @@ class Point2i() {
operator fun component1() = x
operator fun component2() = y
fun toVector() = Vector2(this.x.toDouble(), this.y.toDouble())
}

View File

@@ -5,7 +5,7 @@ package net.torvald.terrarum
*/
object TerrarumGlobalState {
var HAS_KEYBOARD_INPUT_FOCUS = CountedBool()
val HAS_KEYBOARD_INPUT_FOCUS = CountedBool()
}

View File

@@ -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()

View File

@@ -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

View File

@@ -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
}

View File

@@ -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()