diff --git a/OpenRA.Mods.Common/Activities/Repair.cs b/OpenRA.Mods.Common/Activities/Repair.cs index b6809c3043..295befa282 100644 --- a/OpenRA.Mods.Common/Activities/Repair.cs +++ b/OpenRA.Mods.Common/Activities/Repair.cs @@ -10,6 +10,7 @@ #endregion using System; +using System.Linq; using OpenRA.Activities; using OpenRA.Mods.Common.Traits; using OpenRA.Traits; @@ -18,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities { public class Repair : Activity { - readonly RepairsUnitsInfo repairsUnits; + readonly RepairsUnits[] allRepairsUnits; readonly Target host; readonly WDist closeEnough; @@ -33,7 +34,7 @@ namespace OpenRA.Mods.Common.Activities { this.host = Target.FromActor(host); this.closeEnough = closeEnough; - repairsUnits = host.Info.TraitInfo(); + allRepairsUnits = host.TraitsImplementing().ToArray(); health = self.TraitOrDefault(); } @@ -47,6 +48,26 @@ namespace OpenRA.Mods.Common.Activities return this; } + // First active. + RepairsUnits repairsUnits = null; + var paused = false; + foreach (var r in allRepairsUnits) + { + if (!r.IsTraitDisabled) + { + if (r.IsTraitPaused) + paused = true; + else + { + repairsUnits = r; + break; + } + } + } + + if (repairsUnits == null) + return paused ? this : NextActivity; + if (host.Type == TargetType.Invalid || health == null) return NextActivity; @@ -59,23 +80,23 @@ namespace OpenRA.Mods.Common.Activities { var exp = host.Actor.Owner.PlayerActor.TraitOrDefault(); if (exp != null) - exp.GiveExperience(repairsUnits.PlayerExperience); + exp.GiveExperience(repairsUnits.Info.PlayerExperience); } - Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Faction.InternalName); + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.FinishRepairingNotification, self.Owner.Faction.InternalName); return NextActivity; } if (remainingTicks == 0) { var unitCost = self.Info.TraitInfo().Cost; - var hpToRepair = repairsUnits.HpPerStep; - var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100)); + var hpToRepair = repairsUnits.Info.HpPerStep; + var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.Info.ValuePercentage) / (health.MaxHP * 100)); if (!played) { played = true; - Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.StartRepairingNotification, self.Owner.Faction.InternalName); + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.StartRepairingNotification, self.Owner.Faction.InternalName); } if (!self.Owner.PlayerActor.Trait().TakeCash(cost, true)) @@ -89,7 +110,7 @@ namespace OpenRA.Mods.Common.Activities foreach (var depot in host.Actor.TraitsImplementing()) depot.Repairing(host.Actor, self); - remainingTicks = repairsUnits.Interval; + remainingTicks = repairsUnits.Info.Interval; } else --remainingTicks; diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index ce4c980fff..fddf393d21 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -349,7 +349,6 @@ - @@ -496,6 +495,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Buildings/RepairsUnits.cs b/OpenRA.Mods.Common/Traits/Buildings/RepairsUnits.cs index 22e11c83b3..e95588a24e 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RepairsUnits.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RepairsUnits.cs @@ -9,11 +9,9 @@ */ #endregion -using OpenRA.Traits; - namespace OpenRA.Mods.Common.Traits { - public class RepairsUnitsInfo : TraitInfo + public class RepairsUnitsInfo : PausableConditionalTraitInfo { [Desc("Cost in % of the unit value to fully repair the unit.")] public readonly int ValuePercentage = 20; @@ -30,7 +28,12 @@ namespace OpenRA.Mods.Common.Traits [Desc("Experience gained by the player owning this actor for repairing an allied unit.")] public readonly int PlayerExperience = 0; + + public override object Create(ActorInitializer init) { return new RepairsUnits(this); } } - public class RepairsUnits { } + public class RepairsUnits : PausableConditionalTrait + { + public RepairsUnits(RepairsUnitsInfo info) : base(info) { } + } } diff --git a/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs b/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs index dc942ba0a6..46d4cf30dc 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs @@ -15,10 +15,10 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - /// Use as base class for *Info to subclass of UpgradableTrait. (See UpgradableTrait.) + /// Use as base class for *Info to subclass of ConditionalTrait. (See ConditionalTrait.) public abstract class ConditionalTraitInfo : IObservesVariablesInfo, IRulesetLoaded { - static readonly IReadOnlyDictionary NoConditions = new ReadOnlyDictionary(new Dictionary()); + protected static readonly IReadOnlyDictionary NoConditions = new ReadOnlyDictionary(new Dictionary()); [ConsumedConditionReference] [Desc("Boolean expression defining the condition to enable this trait.")] @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits /// /// Abstract base for enabling and disabling trait using conditions. - /// Requires basing *Info on UpgradableTraitInfo and using base(info) constructor. + /// Requires basing *Info on ConditionalTraitInfo and using base(info) constructor. /// TraitEnabled will be called at creation if the trait starts enabled or does not use conditions. /// public abstract class ConditionalTrait : IObservesVariables, IDisabledTrait, INotifyCreated, ISync where InfoType : ConditionalTraitInfo diff --git a/OpenRA.Mods.Common/Traits/Conditions/PausableConditionalTrait.cs b/OpenRA.Mods.Common/Traits/Conditions/PausableConditionalTrait.cs new file mode 100644 index 0000000000..d6203e3a30 --- /dev/null +++ b/OpenRA.Mods.Common/Traits/Conditions/PausableConditionalTrait.cs @@ -0,0 +1,81 @@ +#region Copyright & License Information +/* + * Copyright 2007-2017 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Collections.Generic; +using OpenRA.Primitives; +using OpenRA.Support; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Traits +{ + /// Use as base class for *Info to subclass of PausableConditionalTrait. (See PausableConditionalTrait.) + public abstract class PausableConditionalTraitInfo : ConditionalTraitInfo + { + [ConsumedConditionReference] + [Desc("Boolean expression defining the condition to pause this trait.")] + public readonly BooleanExpression PauseOnCondition = null; + + public bool PausedByDefault { get; private set; } + + public override void RulesetLoaded(Ruleset rules, ActorInfo ai) + { + base.RulesetLoaded(rules, ai); + PausedByDefault = PauseOnCondition != null && PauseOnCondition.Evaluate(NoConditions); + } + } + + /// + /// Abstract base for enabling and disabling trait using conditions. + /// Requires basing *Info on PausableConditionalTraitInfo and using base(info) constructor. + /// TraitResumed will be called at creation if the trait starts not paused or does not have a pause condition. + /// + public abstract class PausableConditionalTrait : ConditionalTrait where InfoType : PausableConditionalTraitInfo + { + [Sync] public bool IsTraitPaused { get; private set; } + + protected PausableConditionalTrait(InfoType info) : base(info) { IsTraitPaused = info.PausedByDefault; } + + protected override void Created(Actor self) + { + base.Created(self); + if (Info.PauseOnCondition == null) + TraitResumed(self); + } + + // Overrides must call `base.GetVariableObservers()` to avoid breaking RequiresCondition or PauseOnCondition. + public override IEnumerable GetVariableObservers() + { + foreach (var observer in base.GetVariableObservers()) + yield return observer; + + if (Info.PauseOnCondition != null) + yield return new VariableObserver(PauseConditionsChanged, Info.PauseOnCondition.Variables); + } + + void PauseConditionsChanged(Actor self, IReadOnlyDictionary conditions) + { + var wasPaused = IsTraitPaused; + IsTraitPaused = Info.PauseOnCondition.Evaluate(conditions); + + if (IsTraitPaused != wasPaused) + { + if (wasPaused) + TraitResumed(self); + else + TraitPaused(self); + } + } + + // Subclasses can add pause support by querying IsTraitPaused and/or overriding these methods. + protected virtual void TraitResumed(Actor self) { } + protected virtual void TraitPaused(Actor self) { } + } +} diff --git a/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs b/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs index 2a46ed1465..f38322ca78 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Applies a condition to actors within a specified range.")] - public class ProximityExternalConditionInfo : ITraitInfo + public class ProximityExternalConditionInfo : ConditionalTraitInfo { [FieldLoader.Require] [Desc("The condition to apply. Must be included in the target actor's ExternalConditions list.")] @@ -38,12 +38,11 @@ namespace OpenRA.Mods.Common.Traits public readonly string EnableSound = null; public readonly string DisableSound = null; - public object Create(ActorInitializer init) { return new ProximityExternalCondition(init.Self, this); } + public override object Create(ActorInitializer init) { return new ProximityExternalCondition(init.Self, this); } } - public class ProximityExternalCondition : ITick, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOtherProduction + public class ProximityExternalCondition : ConditionalTrait, ITick, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOtherProduction { - readonly ProximityExternalConditionInfo info; readonly Actor self; readonly Dictionary tokens = new Dictionary(); @@ -55,14 +54,12 @@ namespace OpenRA.Mods.Common.Traits WDist cachedVRange; WDist desiredVRange; - bool cachedDisabled = true; - public ProximityExternalCondition(Actor self, ProximityExternalConditionInfo info) + : base(info) { - this.info = info; this.self = self; - cachedRange = info.Range; - cachedVRange = info.MaximumVerticalOffset; + cachedRange = WDist.Zero; + cachedVRange = WDist.Zero; } public void AddedToWorld(Actor self) @@ -76,18 +73,22 @@ namespace OpenRA.Mods.Common.Traits self.World.ActorMap.RemoveProximityTrigger(proximityTrigger); } + protected override void TraitEnabled(Actor self) + { + Game.Sound.Play(SoundType.World, Info.EnableSound, self.CenterPosition); + desiredRange = Info.Range; + desiredVRange = Info.MaximumVerticalOffset; + } + + protected override void TraitDisabled(Actor self) + { + Game.Sound.Play(SoundType.World, Info.DisableSound, self.CenterPosition); + desiredRange = WDist.Zero; + desiredVRange = WDist.Zero; + } + public void Tick(Actor self) { - var disabled = self.IsDisabled(); - - if (cachedDisabled != disabled) - { - Game.Sound.Play(SoundType.World, disabled ? info.DisableSound : info.EnableSound, self.CenterPosition); - desiredRange = disabled ? WDist.Zero : info.Range; - desiredVRange = disabled ? WDist.Zero : info.MaximumVerticalOffset; - cachedDisabled = disabled; - } - if (self.CenterPosition != cachedPosition || desiredRange != cachedRange || desiredVRange != cachedVRange) { cachedPosition = self.CenterPosition; @@ -102,18 +103,18 @@ namespace OpenRA.Mods.Common.Traits if (a.Disposed || self.Disposed) return; - if (a == self && !info.AffectsParent) + if (a == self && !Info.AffectsParent) return; if (tokens.ContainsKey(a)) return; var stance = self.Owner.Stances[a.Owner]; - if (!info.ValidStances.HasStance(stance)) + if (!Info.ValidStances.HasStance(stance)) return; var external = a.TraitsImplementing() - .FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(a, self)); + .FirstOrDefault(t => t.Info.Condition == Info.Condition && t.CanGrantCondition(a, self)); if (external != null) tokens[a] = external.GrantCondition(a, self); @@ -126,18 +127,18 @@ namespace OpenRA.Mods.Common.Traits return; // We don't grant conditions when disabled - if (self.IsDisabled()) + if (IsTraitDisabled) return; // Work around for actors produced within the region not triggering until the second tick - if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= info.Range.LengthSquared) + if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= Info.Range.LengthSquared) { var stance = self.Owner.Stances[produced.Owner]; - if (!info.ValidStances.HasStance(stance)) + if (!Info.ValidStances.HasStance(stance)) return; var external = produced.TraitsImplementing() - .FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(produced, self)); + .FirstOrDefault(t => t.Info.Condition == Info.Condition && t.CanGrantCondition(produced, self)); if (external != null) tokens[produced] = external.GrantCondition(produced, self); diff --git a/OpenRA.Mods.Common/Traits/Husk.cs b/OpenRA.Mods.Common/Traits/Husk.cs index 6c6d2276ba..e0ac3912e3 100644 --- a/OpenRA.Mods.Common/Traits/Husk.cs +++ b/OpenRA.Mods.Common/Traits/Husk.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits bool IOccupySpaceInfo.SharesCell { get { return false; } } } - public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisable, IDeathActorInitModifier + public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDeathActorInitModifier { readonly HuskInfo info; readonly Actor self; @@ -120,11 +120,6 @@ namespace OpenRA.Mods.Common.Traits self.World.RemoveFromMaps(self, this); } - public bool Disabled - { - get { return true; } - } - public void ModifyDeathActorInit(Actor self, TypeDictionary init) { init.Add(new FacingInit(Facing)); diff --git a/OpenRA.Mods.Common/Traits/Modifiers/DisabledOverlay.cs b/OpenRA.Mods.Common/Traits/Modifiers/DisabledOverlay.cs deleted file mode 100644 index 5ea9101131..0000000000 --- a/OpenRA.Mods.Common/Traits/Modifiers/DisabledOverlay.cs +++ /dev/null @@ -1,44 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2017 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using System.Collections.Generic; -using OpenRA.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Use together with CanPowerDown/RequiresPower on buildings or Husk for vehicles.")] - public class DisabledOverlayInfo : TraitInfo { } - - public class DisabledOverlay : IRenderModifier - { - public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) - { - if (!self.IsDisabled()) - return r; - - return ModifiedRender(self, wr, r); - } - - IEnumerable ModifiedRender(Actor self, WorldRenderer wr, IEnumerable r) - { - foreach (var a in r) - { - yield return a; - - if (!a.IsDecoration) - yield return a.WithPalette(wr.Palette("disabled")) - .WithZOffset(a.ZOffset + 1) - .AsDecoration(); - } - } - } -} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index dfc21e040d..7ada78a98c 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits void AfterReachActivities(Actor self, Order order, IMove movement) { - if (!order.TargetActor.IsInWorld || order.TargetActor.IsDead || order.TargetActor.IsDisabled()) + if (!order.TargetActor.IsInWorld || order.TargetActor.IsDead || order.TargetActor.TraitsImplementing().All(r => r.IsTraitDisabled)) return; // TODO: This is hacky, but almost every single component affected diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 1c53911fae..a83c24fdd1 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -830,7 +830,8 @@ ForceHealthPercentage: 25 Tooltip: GenericName: Destroyed Vehicle - DisabledOverlay: + WithColoredOverlay@IDISABLE: + Palette: disabled ScriptTriggers: Explodes: Weapon: UnitExplodeSmall @@ -892,3 +893,10 @@ -GivesBuildableArea: MustBeDestroyed: RequiredForShortGame: false + +^DisabledOverlay: + WithColoredOverlay@IDISABLE: + RequiresCondition: disabled + Palette: disabled + GrantConditionOnDisabled@IDISABLE: + Condition: disabled diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index a49673b64e..fd536ac1bf 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -441,6 +441,7 @@ HPAD: HQ: Inherits: ^BaseBuilding + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1000 Tooltip: @@ -463,7 +464,6 @@ HQ: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: WithSpriteBody: PauseAnimationWhenDisabled: true Health: @@ -500,8 +500,6 @@ HQ: SupportPowerChargeBar: Power: Amount: -50 - GrantConditionOnDisabled@IDISABLE: - Condition: disabled FIX: Inherits: ^BaseBuilding @@ -539,6 +537,7 @@ FIX: EYE: Inherits: ^BaseBuilding + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1800 Tooltip: @@ -561,7 +560,6 @@ EYE: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: WithSpriteBody: PauseAnimationWhenDisabled: true Health: @@ -592,11 +590,10 @@ EYE: Power: Amount: -200 ProvidesPrerequisite@buildingname: - GrantConditionOnDisabled@IDISABLE: - Condition: disabled TMPL: Inherits: ^BaseBuilding + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 2000 Tooltip: @@ -619,7 +616,6 @@ TMPL: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Health: HP: 2100 RevealsShroud: @@ -697,6 +693,7 @@ GUN: SAM: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 650 Tooltip: @@ -712,7 +709,6 @@ SAM: Footprint: xx Dimensions: 2,1 RequiresPower: - DisabledOverlay: Health: HP: 400 Armor: @@ -739,6 +735,7 @@ SAM: OBLI: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1500 Tooltip: @@ -755,7 +752,6 @@ OBLI: SelectionDecorations: VisualBounds: 22,44,0,-10 RequiresPower: - DisabledOverlay: Health: HP: 600 Armor: @@ -818,6 +814,7 @@ GTWR: ATWR: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1000 Tooltip: @@ -834,7 +831,6 @@ ATWR: SelectionDecorations: VisualBounds: 22,48,0,-12 RequiresPower: - DisabledOverlay: Health: HP: 550 Armor: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 045f6d0740..15bbb25084 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -199,7 +199,8 @@ Targetable: TargetTypes: Ground, Vehicle RequiresForceFire: true - DisabledOverlay: + WithColoredOverlay@IDISABLE: + Palette: disabled Explodes: Weapon: UnitExplodeMed EmptyWeapon: UnitExplodeMed @@ -394,3 +395,10 @@ MustBeDestroyed: RequiredForShortGame: false RevealOnFire: + +^DisabledOverlay: + WithColoredOverlay@IDISABLE: + RequiresCondition: disabled + Palette: disabled + GrantConditionOnDisabled@IDISABLE: + Condition: disabled diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index b44fea62c7..163a28219b 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -486,11 +486,11 @@ heavy_factory: outpost: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay RequiresPower: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Buildable: Prerequisites: barracks, ~techlevel.medium Queue: Building @@ -533,11 +533,10 @@ outpost: Power: Amount: -125 ProvidesPrerequisite@buildingname: - GrantConditionOnDisabled@IDISABLE: - Condition: disabled starport: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Tooltip: Name: Starport Buildable: @@ -583,7 +582,6 @@ starport: ProductionBar: PrimaryBuilding: PrimaryCondition: primary - DisabledOverlay: ProvidesPrerequisite@atreides: Prerequisite: starport.atreides Factions: atreides @@ -702,6 +700,7 @@ medium_gun_turret: large_gun_turret: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building Prerequisites: outpost, upgrade.conyard, ~techlevel.medium @@ -739,7 +738,6 @@ large_gun_turret: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Power: Amount: -60 SelectionDecorations: @@ -905,6 +903,7 @@ research_centre: palace: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Prerequisites: research_centre, ~techlevel.high Queue: Building @@ -1002,7 +1001,6 @@ palace: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: RequiresPower: SupportPowerChargeBar: ProvidesPrerequisite@buildingname: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index d10e940a71..bede68cdd8 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -786,7 +786,8 @@ CaptureThreshold: 100 TransformOnCapture: ForceHealthPercentage: 25 - DisabledOverlay: + WithColoredOverlay@IDISABLE: + Palette: disabled Targetable: TargetTypes: Ground, Husk RequiresForceFire: true @@ -925,3 +926,10 @@ TargetTypes: Ground Immobile: OccupiesSpace: true + +^DisabledOverlay: + WithColoredOverlay@IDISABLE: + RequiresCondition: disabled + Palette: disabled + GrantConditionOnDisabled@IDISABLE: + Condition: disabled diff --git a/mods/ra/rules/fakes.yaml b/mods/ra/rules/fakes.yaml index 825a21de0d..1d5b0a3fbe 100644 --- a/mods/ra/rules/fakes.yaml +++ b/mods/ra/rules/fakes.yaml @@ -120,6 +120,7 @@ WEAF: DOMF: Inherits: ^FakeBuilding + Inherits@IDISABLE: ^DisabledOverlay Inherits@infiltrate: ^InfiltratableFake Tooltip: Name: Fake Radar Dome @@ -145,7 +146,6 @@ DOMF: Armor: Type: Wood RequiresPower: - DisabledOverlay: FIXF: Inherits: ^FakeBuilding @@ -207,6 +207,7 @@ FAPW: ATEF: Inherits: ^FakeBuilding + Inherits@IDISABLE: ^DisabledOverlay Tooltip: Name: Fake Allied Tech Center GenericName: Allied Tech Center @@ -231,10 +232,10 @@ ATEF: Armor: Type: Wood RequiresPower: - DisabledOverlay: PDOF: Inherits: ^FakeBuilding + Inherits@IDISABLE: ^DisabledOverlay Tooltip: Name: Fake Chronosphere GenericName: Chronosphere @@ -263,10 +264,10 @@ PDOF: Explodes: DamageThreshold: 50 RequiresPower: - DisabledOverlay: MSLF: Inherits: ^FakeBuilding + Inherits@IDISABLE: ^DisabledOverlay Tooltip: Name: Fake Missile Silo GenericName: Missile Silo @@ -293,7 +294,6 @@ MSLF: Explodes: DamageThreshold: 50 RequiresPower: - DisabledOverlay: FACF: Inherits: ^FakeBuilding diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 8fc688e0ca..4908d2cb41 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -1,5 +1,6 @@ MSLO: Inherits: ^ScienceBuilding + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 2500 Tooltip: @@ -45,7 +46,6 @@ MSLO: PowerupSound: EnablePower PowerdownSound: DisablePower RequiresPower: - DisabledOverlay: SupportPowerChargeBar: Power: Amount: -150 @@ -54,6 +54,7 @@ MSLO: GAP: Inherits: ^ScienceBuilding + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 800 Tooltip: @@ -71,7 +72,6 @@ GAP: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: WithSpriteBody: PauseAnimationWhenDisabled: true Health: @@ -284,6 +284,7 @@ SYRD: IRON: Inherits: ^ScienceBuilding + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Defense BuildPaletteOrder: 130 @@ -301,7 +302,6 @@ IRON: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Selectable: Bounds: 48,28,0,2 SelectionDecorations: @@ -338,6 +338,7 @@ IRON: PDOX: Inherits: ^ScienceBuilding + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Defense BuildPaletteOrder: 120 @@ -355,7 +356,6 @@ PDOX: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Health: HP: 1000 Armor: @@ -412,6 +412,7 @@ PDOX: TSLA: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Defense BuildPaletteOrder: 80 @@ -429,7 +430,6 @@ TSLA: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Health: HP: 400 Armor: @@ -457,6 +457,7 @@ TSLA: AGUN: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Defense BuildPaletteOrder: 90 @@ -474,7 +475,6 @@ AGUN: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Health: HP: 400 Armor: @@ -508,6 +508,7 @@ AGUN: DOME: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 90 @@ -526,7 +527,6 @@ DOME: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Health: HP: 1000 Armor: @@ -739,6 +739,7 @@ FTUR: SAM: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Defense BuildPaletteOrder: 100 @@ -755,7 +756,6 @@ SAM: CanPowerDown: PowerupSound: EnablePower PowerdownSound: DisablePower - DisabledOverlay: Health: HP: 400 Armor: @@ -785,6 +785,7 @@ SAM: ATEK: Inherits: ^ScienceBuilding + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 140 @@ -820,7 +821,6 @@ ATEK: DisplayTimerStances: Ally, Neutral, Enemy SupportPowerChargeBar: RequiresPower: - DisabledOverlay: Power: Amount: -200 ProvidesPrerequisite@buildingname: @@ -1303,6 +1303,7 @@ AFLD: POWR: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 10 @@ -1331,13 +1332,13 @@ POWR: Targetable: TargetTypes: Ground, Structure, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: - DisabledOverlay: WithDeathAnimation: DeathSequence: dead UseDeathTypeSuffix: false APWR: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 110 @@ -1370,7 +1371,6 @@ APWR: Targetable: TargetTypes: Ground, Structure, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: - DisabledOverlay: WithDeathAnimation: DeathSequence: dead UseDeathTypeSuffix: false diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 635212b4bb..02422a42fb 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -947,3 +947,10 @@ StartDelay: -1 SpawnAtLastPosition: false RequiresCondition: !inside-tunnel + +^DisabledOverlay: + WithColoredOverlay@IDISABLE: + RequiresCondition: disabled + Palette: disabled + GrantConditionOnDisabled@IDISABLE: + Condition: disabled diff --git a/mods/ts/rules/gdi-structures.yaml b/mods/ts/rules/gdi-structures.yaml index c7e5ba8bf4..082b8fc440 100644 --- a/mods/ts/rules/gdi-structures.yaml +++ b/mods/ts/rules/gdi-structures.yaml @@ -1,5 +1,6 @@ GAPOWR: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 10 @@ -35,7 +36,6 @@ GAPOWR: Targetable: TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: - DisabledOverlay: Pluggable@pluga: Offset: 0,1 Conditions: @@ -211,6 +211,7 @@ GAHPAD: PrimaryCondition: primary Reservable: RepairsUnits: + PauseOnCondition: empdisable PlayerExperience: 15 ProductionBar: WithIdleOverlay@PLATFORM: @@ -258,6 +259,7 @@ GADEPT: MaxHeightDelta: 3 Reservable: RepairsUnits: + PauseOnCondition: empdisable PlayerExperience: 15 RallyPoint: Palette: mouse @@ -370,6 +372,7 @@ GATECH: GAPLUG: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1000 Tooltip: @@ -389,7 +392,6 @@ GAPLUG: IndicatorPalette: mouse PowerupSpeech: EnablePower PowerdownSpeech: DisablePower - DisabledOverlay: WithIdleOverlay@DISH: Sequence: idle-dish WithIdleOverlay@LIGHTS: diff --git a/mods/ts/rules/gdi-support.yaml b/mods/ts/rules/gdi-support.yaml index 8f186dfcb1..ba48c4a6ec 100644 --- a/mods/ts/rules/gdi-support.yaml +++ b/mods/ts/rules/gdi-support.yaml @@ -43,6 +43,7 @@ GAGATE_B: GACTWR: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay -WithSpriteBody: WithWallSpriteBody: Type: wall @@ -58,7 +59,6 @@ GACTWR: Building: Selectable: Bounds: 48, 36, 0, -6 - DisabledOverlay: Health: HP: 500 Armor: diff --git a/mods/ts/rules/nod-structures.yaml b/mods/ts/rules/nod-structures.yaml index 3062ce436a..afd1cb6ab6 100644 --- a/mods/ts/rules/nod-structures.yaml +++ b/mods/ts/rules/nod-structures.yaml @@ -1,5 +1,6 @@ NAPOWR: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 20 @@ -33,12 +34,12 @@ NAPOWR: TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: PowerTooltip: - DisabledOverlay: SelectionDecorations: VisualBounds: 88, 80, 2, -12 NAAPWR: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Building BuildPaletteOrder: 120 @@ -71,7 +72,6 @@ NAAPWR: Targetable: TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate ScalePowerWithHealth: - DisabledOverlay: PowerTooltip: SelectionDecorations: VisualBounds: 100, 74, 0, -12 @@ -222,6 +222,7 @@ NAHPAD: PrimaryCondition: primary Reservable: RepairsUnits: + PauseOnCondition: empdisable PlayerExperience: 15 ProductionBar: WithIdleOverlay@PLATFORM: diff --git a/mods/ts/rules/nod-support.yaml b/mods/ts/rules/nod-support.yaml index 1911230584..6227aef6b8 100644 --- a/mods/ts/rules/nod-support.yaml +++ b/mods/ts/rules/nod-support.yaml @@ -148,6 +148,7 @@ NAFNCE: NALASR: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 300 Tooltip: @@ -160,7 +161,6 @@ NALASR: Building: Selectable: Bounds: 40, 30, -8, -6 - DisabledOverlay: Health: HP: 500 Armor: @@ -188,6 +188,7 @@ NALASR: NAOBEL: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1500 Tooltip: @@ -203,7 +204,6 @@ NAOBEL: Selectable: Bounds: 88, 42, 0, -6 RequiresPower: - DisabledOverlay: Health: HP: 725 Armor: @@ -232,6 +232,7 @@ NAOBEL: NASAM: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 500 Tooltip: @@ -244,7 +245,6 @@ NASAM: Selectable: Bounds: 40, 30, -3, -8 RequiresPower: - DisabledOverlay: Health: HP: 600 Armor: @@ -301,7 +301,10 @@ NASTLH: PowerupSpeech: EnablePower PowerdownSpeech: DisablePower IndicatorPalette: mouse + GrantConditionOnDisabled: + Condition: disabled ProximityExternalCondition: + RequiresCondition: !disabled Condition: cloakgenerator Range: 12c0 EnableSound: cloak5.aud @@ -314,6 +317,7 @@ NASTLH: NAMISL: Inherits: ^Building + Inherits@IDISABLE: ^DisabledOverlay Buildable: Queue: Defense BuildPaletteOrder: 180 @@ -346,7 +350,6 @@ NAMISL: PowerupSpeech: EnablePower PowerdownSpeech: DisablePower RequiresPower: - DisabledOverlay: ProvidesPrerequisite@buildingname: SupportPowerChargeBar: NukePower: diff --git a/mods/ts/rules/shared-support.yaml b/mods/ts/rules/shared-support.yaml index c652af6df8..5b6eb687ea 100644 --- a/mods/ts/rules/shared-support.yaml +++ b/mods/ts/rules/shared-support.yaml @@ -1,5 +1,6 @@ NAPULS: Inherits: ^Defense + Inherits@IDISABLE: ^DisabledOverlay Valued: Cost: 1000 Tooltip: @@ -15,7 +16,6 @@ NAPULS: Selectable: Bounds: 78, 54, 0, -12 RequiresPower: - DisabledOverlay: Health: HP: 500 Armor: