From: fredboy Date: Tue, 21 May 2024 19:51:38 +0000 (+0700) Subject: Remove java serialization X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=91283c3181af9700e20b5600f4e9017e0c31d33a;p=cavedroid.git Remove java serialization --- diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingBlock.kt b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingBlock.kt index 77e51a1..d4494a3 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingBlock.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingBlock.kt @@ -14,7 +14,6 @@ class FallingBlock( y: Float, ) : Mob(x, y, 1.px, 1.px, Direction.RIGHT, Type.FALLING_BLOCK, Int.MAX_VALUE) { - @Transient private var _block: Block? = null init { diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java index 0f3610b..5d18755 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java @@ -10,19 +10,17 @@ import com.badlogic.gdx.utils.Timer; import ru.deadsoftware.cavedroid.game.GameItemsHolder; import ru.deadsoftware.cavedroid.game.model.dto.SaveDataDto; import ru.deadsoftware.cavedroid.game.model.item.InventoryItem; -import ru.deadsoftware.cavedroid.game.model.item.Item; import ru.deadsoftware.cavedroid.game.world.GameWorld; import ru.deadsoftware.cavedroid.misc.Saveable; import javax.annotation.CheckForNull; -import java.io.Serializable; import java.util.Collections; import java.util.List; /** * Mob class. */ -public abstract class Mob extends Rectangle implements Serializable, Saveable { +public abstract class Mob extends Rectangle implements Saveable { private static final float DAMAGE_TINT_TIMEOUT_S = 0.5f; private static final Color DAMAGE_TINT_COLOR = new Color(0xff8080ff); @@ -85,8 +83,8 @@ public abstract class Mob extends Rectangle implements Serializable, Saveable { protected int mMaxHealth; protected int mHealth; - private transient boolean mTakingDamage = false; - @CheckForNull private transient ResetTakeDamageTask mResetTakeDamageTask = null; + private boolean mTakingDamage = false; + @CheckForNull private ResetTakeDamageTask mResetTakeDamageTask = null; /** * @param x in pixels diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt b/core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt index dc01e1e..4b2c209 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/MobsController.kt @@ -6,7 +6,6 @@ import ru.deadsoftware.cavedroid.game.mobs.player.Player import ru.deadsoftware.cavedroid.game.model.dto.SaveDataDto import ru.deadsoftware.cavedroid.game.ui.TooltipManager import ru.deadsoftware.cavedroid.misc.Saveable -import java.io.Serializable import java.util.* import javax.inject.Inject @@ -14,7 +13,7 @@ import javax.inject.Inject class MobsController @Inject constructor( gameItemsHolder: GameItemsHolder, tooltipManager: TooltipManager, -) : Serializable, Saveable { +) : Saveable { private val _mobs = LinkedList() diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt b/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt index 8f0b90d..91e8be1 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/player/Inventory.kt @@ -7,7 +7,6 @@ import ru.deadsoftware.cavedroid.game.model.item.Item import ru.deadsoftware.cavedroid.game.objects.drop.Drop import ru.deadsoftware.cavedroid.game.ui.TooltipManager import ru.deadsoftware.cavedroid.misc.Saveable -import java.io.Serializable class Inventory @JvmOverloads constructor( val size: Int, @@ -15,14 +14,12 @@ class Inventory @JvmOverloads constructor( gameItemsHolder: GameItemsHolder, tooltipManager: TooltipManager, initialItems: List? = null -) : Serializable, Saveable { +) : Saveable { @Suppress("UNNECESSARY_LATEINIT") - @Transient private lateinit var tooltipManager: TooltipManager @Suppress("UNNECESSARY_LATEINIT") - @Transient private lateinit var fallbackItem: InventoryItem private val _items: Array diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/item/InventoryItem.kt b/core/src/ru/deadsoftware/cavedroid/game/model/item/InventoryItem.kt index 7190988..f420120 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/item/InventoryItem.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/item/InventoryItem.kt @@ -10,14 +10,13 @@ import ru.deadsoftware.cavedroid.misc.Saveable import ru.deadsoftware.cavedroid.misc.utils.drawSprite import ru.deadsoftware.cavedroid.misc.utils.drawString import ru.deadsoftware.cavedroid.misc.utils.px -import java.io.Serializable import kotlin.contracts.ExperimentalContracts import kotlin.contracts.contract class InventoryItem @JvmOverloads constructor( val itemKey: String, _amount: Int = 1, -) : Serializable, Saveable { +) : Saveable { var amount = _amount set(value) { @@ -28,7 +27,6 @@ class InventoryItem @JvmOverloads constructor( } } - @Transient private var _item: Item? = null var item: Item diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/container/Container.kt b/core/src/ru/deadsoftware/cavedroid/game/objects/container/Container.kt index 05ec744..624f5d0 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/container/Container.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/container/Container.kt @@ -4,14 +4,13 @@ import ru.deadsoftware.cavedroid.game.GameItemsHolder import ru.deadsoftware.cavedroid.game.model.dto.SaveDataDto import ru.deadsoftware.cavedroid.game.model.item.InventoryItem import ru.deadsoftware.cavedroid.misc.Saveable -import java.io.Serializable import javax.annotation.OverridingMethodsMustInvokeSuper abstract class Container @JvmOverloads constructor( val size: Int, gameItemsHolder: GameItemsHolder, initialItems: List? = null, -) : Serializable, Saveable { +) : Saveable { private val _items = Array(size) { index -> initialItems?.getOrNull(index) ?: gameItemsHolder.fallbackItem.toInventoryItem() diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/container/ContainerController.kt b/core/src/ru/deadsoftware/cavedroid/game/objects/container/ContainerController.kt index bffb846..d2159f1 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/container/ContainerController.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/container/ContainerController.kt @@ -9,21 +9,18 @@ import ru.deadsoftware.cavedroid.game.model.item.InventoryItem.Companion.isNoneO import ru.deadsoftware.cavedroid.game.objects.drop.DropController import ru.deadsoftware.cavedroid.misc.Saveable import ru.deadsoftware.cavedroid.misc.utils.px -import java.io.Serializable import javax.inject.Inject @GameScope class ContainerController @Inject constructor( _dropController: DropController, _gameItemsHolder: GameItemsHolder -) : Serializable, Saveable { +) : Saveable { @Suppress("UNNECESSARY_LATEINIT") - @Transient private lateinit var dropController: DropController @Suppress("UNNECESSARY_LATEINIT") - @Transient private lateinit var gameItemsHolder: GameItemsHolder private val containerMap = mutableMapOf() diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/container/Furnace.kt b/core/src/ru/deadsoftware/cavedroid/game/objects/container/Furnace.kt index 92eeab9..237006d 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/container/Furnace.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/container/Furnace.kt @@ -35,7 +35,6 @@ class Furnace @JvmOverloads constructor( val isActive: Boolean get() = currentFuel != null - @Transient var currentFuel: Item? = null set(value) { currentFuelKey = value?.params?.key diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/drop/Drop.kt b/core/src/ru/deadsoftware/cavedroid/game/objects/drop/Drop.kt index 548c44a..2b4f740 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/drop/Drop.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/drop/Drop.kt @@ -23,7 +23,6 @@ class Drop @JvmOverloads constructor( var pickedUp = false @Suppress("UNNECESSARY_LATEINIT") - @Transient lateinit var item: Item private set diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/drop/DropController.java b/core/src/ru/deadsoftware/cavedroid/game/objects/drop/DropController.java index f829913..7b99676 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/drop/DropController.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/drop/DropController.java @@ -9,12 +9,11 @@ import ru.deadsoftware.cavedroid.game.model.item.Item; import ru.deadsoftware.cavedroid.misc.Saveable; import javax.inject.Inject; -import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; @GameScope -public class DropController implements Serializable, Saveable { +public class DropController implements Saveable { private static final int SAVE_DATA_VERSION = 1;