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

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