basegame: added an Interface that marks the actor as 'not to be serialised when saving the world'

This commit is contained in:
minjaesong
2022-09-02 23:26:59 +09:00
parent 760188ebe9
commit d6144d52d2
5 changed files with 13 additions and 19 deletions

View File

@@ -13,7 +13,7 @@ import kotlin.math.floor
/**
* Used as construction markers and fixture ghost images
*/
class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT) {
class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT), NoSerialise {
private val defaultSize = 16.0

View File

@@ -0,0 +1,6 @@
package net.torvald.terrarum.gameactors
/**
* Created by minjaesong on 2022-09-02.
*/
interface NoSerialise

View File

@@ -11,7 +11,7 @@ import net.torvald.terrarum.gameitems.ItemID
*
* Created by minjaesong on 2021-07-30.
*/
class WireActor : ActorWithBody {
class WireActor : ActorWithBody, NoSerialise {
companion object {
val WIRE_NEARBY = arrayOf(

View File

@@ -1,23 +1,16 @@
package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.spriteanimation.HasAssembledSprite
import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.terrarum.spriteassembler.ADProperties
import net.torvald.terrarum.spriteassembler.AssembleSheetPixmap
import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.gameactors.NoSerialise
import net.torvald.terrarum.itemproperties.ItemRemapTable
import net.torvald.terrarum.itemproperties.ItemTable
import net.torvald.terrarum.savegame.DiskSkimmer
import net.torvald.terrarum.savegame.SimpleFileSystem
import net.torvald.terrarum.spriteassembler.ADProperties
import net.torvald.terrarum.utils.PlayerLastStatus
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.util.*
@@ -27,7 +20,7 @@ import java.util.*
* Created by minjaesong on 2015-12-31.
*/
class IngamePlayer : ActorHumanoid, HasAssembledSprite {
class IngamePlayer : ActorHumanoid, HasAssembledSprite, NoSerialise {
val creationTime = App.getTIME_T()
var lastPlayTime = App.getTIME_T() // cumulative value for the savegame

View File

@@ -1,10 +1,8 @@
package net.torvald.terrarum.serialise
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.ItemCodex
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.BlockMarkerActor
import net.torvald.terrarum.gameactors.NoSerialise
import net.torvald.terrarum.gameworld.BlockLayer
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.GameWorldTitleScreen
@@ -25,10 +23,7 @@ import java.io.Reader
object WriteWorld {
fun actorAcceptable(actor: Actor): Boolean {
return actor.referenceID !in ReferencingRanges.ACTORS_WIRES &&
actor.referenceID !in ReferencingRanges.ACTORS_WIRES_HELPER &&
actor != (CommonResourcePool.get("blockmarking_actor") as BlockMarkerActor) &&
actor !is IngamePlayer // IngamePlayers must not be saved with the world
return actor !is NoSerialise // IngamePlayers is also NoSerialised because they must not be saved with the world
}
private fun preWrite(ingame: TerrarumIngame, time_t: Long, actorsList: List<Actor>, playersList: List<IngamePlayer>): GameWorld {