mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-01 16:01:45 -04:00
Save associated unique in UnitAction for automation / grouping - see #12393
This commit is contained in:
parent
a0bbab1362
commit
ab15058008
@ -2,6 +2,7 @@ package com.unciv.models
|
|||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.models.ruleset.unique.Unique
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.translations.getPlaceholderParameters
|
import com.unciv.models.translations.getPlaceholderParameters
|
||||||
import com.unciv.ui.components.fonts.Fonts
|
import com.unciv.ui.components.fonts.Fonts
|
||||||
@ -23,6 +24,7 @@ open class UnitAction(
|
|||||||
val title: String = type.value,
|
val title: String = type.value,
|
||||||
val isCurrentAction: Boolean = false,
|
val isCurrentAction: Boolean = false,
|
||||||
val uncivSound: UncivSound = type.uncivSound,
|
val uncivSound: UncivSound = type.uncivSound,
|
||||||
|
val associatedUnique: Unique? = null,
|
||||||
/** Action is Null if this unit *can* execute the action but *not right now* - it's embarked, out of moves, etc */
|
/** Action is Null if this unit *can* execute the action but *not right now* - it's embarked, out of moves, etc */
|
||||||
val action: (() -> Unit)? = null
|
val action: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
@ -70,7 +72,7 @@ open class UnitAction(
|
|||||||
|
|
||||||
/** Specialized [UnitAction] for upgrades
|
/** Specialized [UnitAction] for upgrades
|
||||||
*
|
*
|
||||||
* Transports [unitToUpgradeTo] from [creation][com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsUpgrade.getUpgradeAction]
|
* Transports [unitToUpgradeTo] from [creation][com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsUpgrade.getUpgradeActions]
|
||||||
* to [UI][com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsTable.update]
|
* to [UI][com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsTable.update]
|
||||||
*/
|
*/
|
||||||
class UpgradeUnitAction(
|
class UpgradeUnitAction(
|
||||||
@ -196,6 +198,6 @@ enum class UnitActionType(
|
|||||||
|
|
||||||
val binding: KeyboardBinding =
|
val binding: KeyboardBinding =
|
||||||
binding ?:
|
binding ?:
|
||||||
KeyboardBinding.values().firstOrNull { it.name == name } ?:
|
KeyboardBinding.entries.firstOrNull { it.name == name } ?:
|
||||||
KeyboardBinding.None
|
KeyboardBinding.None
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ object UnitActionsFromUniques {
|
|||||||
useFrequency = 80f,
|
useFrequency = 80f,
|
||||||
title = title,
|
title = title,
|
||||||
uncivSound = UncivSound.Chimes,
|
uncivSound = UncivSound.Chimes,
|
||||||
|
associatedUnique = unique,
|
||||||
action = {
|
action = {
|
||||||
// check if we would be breaking a promise
|
// check if we would be breaking a promise
|
||||||
val leadersPromisedNotToSettleNear = getLeadersWePromisedNotToSettleNear(unit.civ, tile)
|
val leadersPromisedNotToSettleNear = getLeadersWePromisedNotToSettleNear(unit.civ, tile)
|
||||||
@ -242,6 +243,7 @@ object UnitActionsFromUniques {
|
|||||||
|
|
||||||
yield(
|
yield(
|
||||||
UnitAction(UnitActionType.TriggerUnique, 80f, title,
|
UnitAction(UnitActionType.TriggerUnique, 80f, title,
|
||||||
|
associatedUnique = unique,
|
||||||
action = unitAction.takeIf {
|
action = unitAction.takeIf {
|
||||||
UnitActionModifiers.canActivateSideEffects(unit, unique)
|
UnitActionModifiers.canActivateSideEffects(unit, unique)
|
||||||
})
|
})
|
||||||
@ -312,6 +314,7 @@ object UnitActionsFromUniques {
|
|||||||
unique,
|
unique,
|
||||||
unit
|
unit
|
||||||
),
|
),
|
||||||
|
associatedUnique = unique,
|
||||||
action = {
|
action = {
|
||||||
val unitTile = unit.getTile()
|
val unitTile = unit.getTile()
|
||||||
unitTile.setImprovement(improvement.name, unit.civ, unit)
|
unitTile.setImprovement(improvement.name, unit.civ, unit)
|
||||||
@ -393,6 +396,7 @@ object UnitActionsFromUniques {
|
|||||||
|
|
||||||
yield(UnitAction(UnitActionType.Transform, 70f,
|
yield(UnitAction(UnitActionType.Transform, 70f,
|
||||||
title = title,
|
title = title,
|
||||||
|
associatedUnique = unique,
|
||||||
action = {
|
action = {
|
||||||
val oldMovement = unit.currentMovement
|
val oldMovement = unit.currentMovement
|
||||||
unit.destroy()
|
unit.destroy()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user