// Assets/_Project/Scripts/Gameplay/EnemyUpgrades/DoubleUpEnemyUpgradeOption.cs using UnityEngine; using TD.Gameplay.Waves; namespace TD.Gameplay.EnemyUpgrades { /// /// Vote-meta card: the next time this wave is cleared, it takes several buffs automatically /// and the players get no say in which. /// /// /// Not an enemy ability. Nothing about the enemies changes when this is voted in — it /// changes how the next vote on this slot resolves. That's why it derives from /// directly instead of wrapping an /// EnemyAbilityDefinition: the spawn path builds ability sets only from ability cards, /// so this one is recorded on the slot and otherwise invisible to enemies. /// /// The trade is agency for information. Voting this in is choosing to make one /// future wave worse in exchange for it not being the worst option — the auto-draw is weighted /// and slot-filtered exactly like a real vote, so it's a gamble on the pool, not a punishment. /// It also disarms itself after firing (ServerConsumeAutoApply), so a slot can only be /// doubled once per card. /// /// Repeats are prevented by the normal offer filter: the slot records this card like any /// other, so it can't be offered to the same slot twice in a phase. /// [CreateAssetMenu(fileName = "EnemyUpgrade_DoubleUp", menuName = "TD/Enemy Upgrades/Double Up Card", order = 22)] public class DoubleUpEnemyUpgradeOption : EnemyUpgradeOption { [Header("Payload")] [Tooltip("How many buffs the wave takes automatically in place of its next vote.")] [Min(2)] public int BuffsToAutoApply = 2; public override bool IsValidForSlot(RunState run, int slot) { // Pointless to offer while the slot is already armed — the player would be trading a // vote away for nothing. return run != null && run.GetAutoApplyCount(slot) <= 0; } public override void ServerOnApplied(RunState run, int slot) { run?.ServerSetAutoApply(slot, BuffsToAutoApply); } } }