mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-20 19:56:51 +01:00
Separate unit automation from other actions (#10248)
* Separate unit automation from other actions * Change field name
This commit is contained in:
parent
a81d5f0837
commit
d714b00dd7
|
|
@ -118,6 +118,7 @@ object BattleUnitCapture {
|
|||
val capturedUnit = defender.unit
|
||||
// Stop current action
|
||||
capturedUnit.action = null
|
||||
capturedUnit.automated = false
|
||||
|
||||
val capturedUnitTile = capturedUnit.getTile()
|
||||
val originalOwner = if (capturedUnit.originalOwner != null)
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||
var health: Int = 100
|
||||
|
||||
var action: String? = null // work, automation, fortifying, I dunno what.
|
||||
var automated: Boolean = false
|
||||
|
||||
@Transient
|
||||
var showAdditionalActions: Boolean = false
|
||||
|
||||
|
|
@ -175,6 +177,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||
toReturn.currentMovement = currentMovement
|
||||
toReturn.health = health
|
||||
toReturn.action = action
|
||||
toReturn.automated = automated
|
||||
toReturn.attacksThisTurn = attacksThisTurn
|
||||
toReturn.turnsFortified = turnsFortified
|
||||
toReturn.promotions = promotions.clone()
|
||||
|
|
@ -335,7 +338,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||
|
||||
fun isMoving() = action?.startsWith("moveTo") == true
|
||||
|
||||
fun isAutomated() = action == UnitActionType.Automate.value
|
||||
fun isAutomated() = automated
|
||||
fun isExploring() = action == UnitActionType.Explore.value
|
||||
fun isPreparingParadrop() = action == UnitActionType.Paradrop.value
|
||||
fun isPreparingAirSweep() = action == UnitActionType.AirSweep.value
|
||||
|
|
@ -460,6 +463,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||
?: throw java.lang.Exception("Unit $name is not found!")
|
||||
|
||||
updateUniques()
|
||||
if (action == UnitActionType.Automate.value) automated = true
|
||||
}
|
||||
|
||||
fun getTriggeredUniques(trigger: UniqueType,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import com.unciv.logic.map.mapunit.MapUnit
|
|||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.UnitAction
|
||||
import com.unciv.models.UnitActionType
|
||||
import com.unciv.models.ruleset.unique.Unique
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.popups.ConfirmPopup
|
||||
|
|
@ -62,7 +61,10 @@ object UnitActions {
|
|||
if (unit.isExploring())
|
||||
actionList += UnitAction(UnitActionType.StopExploration) { unit.action = null }
|
||||
if (unit.isAutomated())
|
||||
actionList += UnitAction(UnitActionType.StopAutomation) { unit.action = null }
|
||||
actionList += UnitAction(UnitActionType.StopAutomation) {
|
||||
unit.action = null
|
||||
unit.automated = false
|
||||
}
|
||||
|
||||
addPromoteAction(unit, actionList)
|
||||
UnitActionsUpgrade.addUnitUpgradeAction(unit, actionList)
|
||||
|
|
@ -293,7 +295,9 @@ object UnitActions {
|
|||
actionList += UnitAction(UnitActionType.Automate,
|
||||
isCurrentAction = unit.isAutomated(),
|
||||
action = {
|
||||
// Temporary, for compatibility - we want games serialized *moving through old versions* to come out the other end with units still automated
|
||||
unit.action = UnitActionType.Automate.value
|
||||
unit.automated = true
|
||||
UnitAutomation.automateUnitMoves(unit)
|
||||
}.takeIf { unit.currentMovement > 0 }
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user