diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 7625e6ecb8..50255f8c63 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -38,6 +38,11 @@ namespace OpenRA.Traits /// public sealed class DamageType { DamageType() { } } + public interface IHealthInfo : ITraitInfo + { + int MaxHP { get; } + } + public interface IHealth { DamageState DamageState { get; } diff --git a/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs b/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs index 7be3b90ec0..f16791842f 100644 --- a/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs +++ b/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs @@ -188,10 +188,10 @@ namespace OpenRA.Mods.Common.AI var sumOfHp = 0; foreach (var a in actors) { - if (a.Info.HasTraitInfo()) + if (a.Info.HasTraitInfo()) { - sumOfMaxHp += a.Trait().MaxHP; - sumOfHp += a.Trait().HP; + sumOfMaxHp += a.Trait().MaxHP; + sumOfHp += a.Trait().HP; } } diff --git a/OpenRA.Mods.Common/AI/SupportPowerDecision.cs b/OpenRA.Mods.Common/AI/SupportPowerDecision.cs index 84c4c03f84..2ccf219512 100644 --- a/OpenRA.Mods.Common/AI/SupportPowerDecision.cs +++ b/OpenRA.Mods.Common/AI/SupportPowerDecision.cs @@ -160,7 +160,7 @@ namespace OpenRA.Mods.Common.AI return (valueInfo != null) ? valueInfo.Cost * Attractiveness : 0; case DecisionMetric.Health: - var health = a.TraitOrDefault(); + var health = a.TraitOrDefault(); if (health == null) return 0; @@ -193,8 +193,8 @@ namespace OpenRA.Mods.Common.AI return (valueInfo != null) ? valueInfo.Cost * Attractiveness : 0; case DecisionMetric.Health: - var healthInfo = fa.Info.TraitInfoOrDefault(); - return (healthInfo != null) ? fa.HP * Attractiveness / healthInfo.HP : 0; + var healthInfo = fa.Info.TraitInfoOrDefault(); + return (healthInfo != null) ? fa.HP * Attractiveness / healthInfo.MaxHP : 0; default: return Attractiveness; diff --git a/OpenRA.Mods.Common/Activities/CaptureActor.cs b/OpenRA.Mods.Common/Activities/CaptureActor.cs index daff14b57b..0d24ff9bea 100644 --- a/OpenRA.Mods.Common/Activities/CaptureActor.cs +++ b/OpenRA.Mods.Common/Activities/CaptureActor.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities readonly Building building; readonly Capturable capturable; readonly Captures[] captures; - readonly Health health; + readonly IHealth health; public CaptureActor(Actor self, Actor target) : base(self, target, EnterBehaviour.Dispose) @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Activities building = actor.TraitOrDefault(); captures = self.TraitsImplementing().ToArray(); capturable = target.Trait(); - health = actor.Trait(); + health = actor.Trait(); } protected override bool CanReserve(Actor self) diff --git a/OpenRA.Mods.Common/Activities/Repair.cs b/OpenRA.Mods.Common/Activities/Repair.cs index b765419f9b..04d1c9c8b6 100644 --- a/OpenRA.Mods.Common/Activities/Repair.cs +++ b/OpenRA.Mods.Common/Activities/Repair.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities { public class Repair : Activity { - readonly Health health; + readonly IHealth health; readonly RepairsUnits[] allRepairsUnits; readonly Target host; readonly WDist closeEnough; @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Activities this.host = Target.FromActor(host); this.closeEnough = closeEnough; allRepairsUnits = host.TraitsImplementing().ToArray(); - health = self.TraitOrDefault(); + health = self.TraitOrDefault(); repairable = self.TraitOrDefault(); } diff --git a/OpenRA.Mods.Common/Activities/RepairBuilding.cs b/OpenRA.Mods.Common/Activities/RepairBuilding.cs index c1e162eecc..36c8e51372 100644 --- a/OpenRA.Mods.Common/Activities/RepairBuilding.cs +++ b/OpenRA.Mods.Common/Activities/RepairBuilding.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Activities class RepairBuilding : Enter { readonly Actor target; - readonly Health health; + readonly IHealth health; readonly Stance validStances; public RepairBuilding(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances) @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Activities { this.target = target; this.validStances = validStances; - health = target.Trait(); + health = target.Trait(); } protected override bool CanReserve(Actor self) diff --git a/OpenRA.Mods.Common/Activities/Sell.cs b/OpenRA.Mods.Common/Activities/Sell.cs index bb63792771..724a12da83 100644 --- a/OpenRA.Mods.Common/Activities/Sell.cs +++ b/OpenRA.Mods.Common/Activities/Sell.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Activities { class Sell : Activity { - readonly Health health; + readonly IHealth health; readonly SellableInfo sellableInfo; readonly PlayerResources playerResources; bool showTicks; @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Activities public Sell(Actor self, bool showTicks) { this.showTicks = showTicks; - health = self.TraitOrDefault(); + health = self.TraitOrDefault(); sellableInfo = self.Info.TraitInfo(); playerResources = self.Owner.PlayerActor.Trait(); IsInterruptible = false; diff --git a/OpenRA.Mods.Common/Activities/Transform.cs b/OpenRA.Mods.Common/Activities/Transform.cs index 245a0fd83d..2b2f6c6b75 100644 --- a/OpenRA.Mods.Common/Activities/Transform.cs +++ b/OpenRA.Mods.Common/Activities/Transform.cs @@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Activities if (Faction != null) init.Add(new FactionInit(Faction)); - var health = self.TraitOrDefault(); + var health = self.TraitOrDefault(); if (health != null) { // Cast to long to avoid overflow when multiplying by the health diff --git a/OpenRA.Mods.Common/Lint/CheckHitShapes.cs b/OpenRA.Mods.Common/Lint/CheckHitShapes.cs index 2e8668e73c..9f0404b1cb 100644 --- a/OpenRA.Mods.Common/Lint/CheckHitShapes.cs +++ b/OpenRA.Mods.Common/Lint/CheckHitShapes.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Lint { foreach (var actorInfo in rules.Actors) { - var health = actorInfo.Value.TraitInfoOrDefault(); + var health = actorInfo.Value.TraitInfoOrDefault(); if (health == null) continue; diff --git a/OpenRA.Mods.Common/Scripting/Properties/HealthProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/HealthProperties.cs index eb6186568f..38b4a57b7c 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/HealthProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/HealthProperties.cs @@ -16,13 +16,13 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Scripting { [ScriptPropertyGroup("General")] - public class HealthProperties : ScriptActorProperties, Requires + public class HealthProperties : ScriptActorProperties, Requires { - Health health; + IHealth health; public HealthProperties(ScriptContext context, Actor self) : base(context, self) { - health = self.Trait(); + health = self.Trait(); } [Desc("Current health of the actor.")] diff --git a/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs b/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs index a42f473731..8d61f2bc4b 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/GroundLevelBridge.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Bridge actor that can't be passed underneath.")] - class GroundLevelBridgeInfo : ITraitInfo, IRulesetLoaded, Requires, Requires + class GroundLevelBridgeInfo : ITraitInfo, IRulesetLoaded, Requires, Requires { public readonly string TerrainType = "Bridge"; @@ -53,13 +53,13 @@ namespace OpenRA.Mods.Common.Traits readonly Actor self; readonly BridgeLayer bridgeLayer; readonly IEnumerable cells; - readonly Health health; + readonly IHealth health; public GroundLevelBridge(Actor self, GroundLevelBridgeInfo info) { Info = info; this.self = self; - health = self.Trait(); + health = self.Trait(); bridgeLayer = self.World.WorldActor.Trait(); var buildingInfo = self.Info.TraitInfo(); diff --git a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs index 41ee041879..a3ce6e5e51 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Building can be repaired by the repair button.")] - public class RepairableBuildingInfo : ConditionalTraitInfo, Requires + public class RepairableBuildingInfo : ConditionalTraitInfo, Requires { [Desc("Cost to fully repair the actor as a percent of its value.")] public readonly int RepairPercent = 20; @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits public class RepairableBuilding : ConditionalTrait, ITick { - readonly Health health; + readonly IHealth health; readonly Predicate isNotActiveAlly; readonly Stack repairTokens = new Stack(); ConditionManager conditionManager; @@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits public RepairableBuilding(Actor self, RepairableBuildingInfo info) : base(info) { - health = self.Trait(); + health = self.Trait(); isNotActiveAlly = player => player.WinState != WinState.Undefined || player.Stances[self.Owner] != Stance.Ally; } diff --git a/OpenRA.Mods.Common/Traits/Captures.cs b/OpenRA.Mods.Common/Traits/Captures.cs index 9b8ab7a3bf..0eb8ad7190 100644 --- a/OpenRA.Mods.Common/Traits/Captures.cs +++ b/OpenRA.Mods.Common/Traits/Captures.cs @@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits return false; } - var health = target.Trait(); + var health = target.Trait(); // Cast to long to avoid overflow when multiplying by the health var lowEnoughHealth = health.HP <= (int)(c.Info.CaptureThreshold * (long)health.MaxHP / 100); @@ -130,10 +130,10 @@ namespace OpenRA.Mods.Common.Traits return false; } - var health = target.Info.TraitInfoOrDefault(); + var health = target.Info.TraitInfoOrDefault(); // Cast to long to avoid overflow when multiplying by the health - var lowEnoughHealth = target.HP <= (int)(c.CaptureThreshold * (long)health.HP / 100); + var lowEnoughHealth = target.HP <= (int)(c.CaptureThreshold * (long)health.MaxHP / 100); cursor = !capturesInfo.Sabotage || lowEnoughHealth || target.Owner.NonCombatant ? capturesInfo.EnterCursor : capturesInfo.SabotageCursor; diff --git a/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs b/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs index 1ebf37cc50..fcc2297543 100644 --- a/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs +++ b/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits static readonly WVec TargetPosVLine = new WVec(128, 0, 0); readonly DebugVisualizations debugVis; - readonly HealthInfo healthInfo; + readonly IHealthInfo healthInfo; readonly Lazy coords; HitShape[] shapes; @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits public CombatDebugOverlay(Actor self) { - healthInfo = self.Info.TraitInfoOrDefault(); + healthInfo = self.Info.TraitInfoOrDefault(); coords = Exts.Lazy(self.Trait); debugVis = self.World.WorldActor.TraitOrDefault(); @@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits if (healthInfo == null) return; - var maxHP = healthInfo.HP > 0 ? healthInfo.HP : 1; + var maxHP = healthInfo.MaxHP > 0 ? healthInfo.MaxHP : 1; var damageText = "{0} ({1}%)".F(-e.Damage.Value, e.Damage.Value * 100 / maxHP); self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color.RGB, damageText, 30))); diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs index 0099dde750..918ad8e0fa 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDamageState.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Applies a condition to the actor at specified damage states.")] - public class GrantConditionOnDamageStateInfo : ITraitInfo, Requires + public class GrantConditionOnDamageStateInfo : ITraitInfo, Requires { [FieldLoader.Require] [GrantedConditionReference] @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits public class GrantConditionOnDamageState : INotifyDamageStateChanged, INotifyCreated { readonly GrantConditionOnDamageStateInfo info; - readonly Health health; + readonly IHealth health; ConditionManager conditionManager; int conditionToken = ConditionManager.InvalidConditionToken; @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits public GrantConditionOnDamageState(Actor self, GrantConditionOnDamageStateInfo info) { this.info = info; - health = self.Trait(); + health = self.Trait(); } void INotifyCreated.Created(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Crates/HealUnitsCrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/HealUnitsCrateAction.cs index 9c1c6a02dc..9d32bd9780 100644 --- a/OpenRA.Mods.Common/Traits/Crates/HealUnitsCrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/HealUnitsCrateAction.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits public override void Activate(Actor collector) { - foreach (var healable in collector.World.ActorsWithTrait().Where(tp => tp.Actor.Owner == collector.Owner)) + foreach (var healable in collector.World.ActorsWithTrait().Where(tp => tp.Actor.Owner == collector.Owner)) if (!healable.Trait.IsDead) healable.Trait.InflictDamage(healable.Actor, healable.Actor, new Damage(-(healable.Trait.MaxHP - healable.Trait.HP)), true); diff --git a/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs b/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs index ad6b3900b4..3fa11c7124 100644 --- a/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs +++ b/OpenRA.Mods.Common/Traits/DamagedByTerrain.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor receives damage from the given weapon when on the specified terrain type.")] - class DamagedByTerrainInfo : ConditionalTraitInfo, Requires + class DamagedByTerrainInfo : ConditionalTraitInfo, Requires { [Desc("Amount of damage received per DamageInterval ticks.")] [FieldLoader.Require] public readonly int Damage = 0; @@ -41,14 +41,14 @@ namespace OpenRA.Mods.Common.Traits class DamagedByTerrain : ConditionalTrait, ITick, ISync, INotifyAddedToWorld { - readonly Health health; + readonly IHealth health; [Sync] int damageTicks; [Sync] int damageThreshold; public DamagedByTerrain(Actor self, DamagedByTerrainInfo info) : base(info) { - health = self.Trait(); + health = self.Trait(); } void INotifyAddedToWorld.AddedToWorld(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Explodes.cs b/OpenRA.Mods.Common/Traits/Explodes.cs index 4a21de2353..09d7c311f5 100644 --- a/OpenRA.Mods.Common/Traits/Explodes.cs +++ b/OpenRA.Mods.Common/Traits/Explodes.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits public enum DamageSource { Self, Killer } [Desc("This actor explodes when killed.")] - public class ExplodesInfo : ConditionalTraitInfo, Requires + public class ExplodesInfo : ConditionalTraitInfo, Requires { [WeaponReference, FieldLoader.Require, Desc("Default weapon to use for explosion if ammo/payload is loaded.")] public readonly string Weapon = null; @@ -81,13 +81,13 @@ namespace OpenRA.Mods.Common.Traits public class Explodes : ConditionalTrait, INotifyKilled, INotifyDamage, INotifyCreated { - readonly Health health; + readonly IHealth health; BuildingInfo buildingInfo; public Explodes(ExplodesInfo info, Actor self) : base(info) { - health = self.Trait(); + health = self.Trait(); } void INotifyCreated.Created(Actor self) diff --git a/OpenRA.Mods.Common/Traits/ExplosionOnDamageTransition.cs b/OpenRA.Mods.Common/Traits/ExplosionOnDamageTransition.cs index 28103c93e6..bfff00fc9c 100644 --- a/OpenRA.Mods.Common/Traits/ExplosionOnDamageTransition.cs +++ b/OpenRA.Mods.Common/Traits/ExplosionOnDamageTransition.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor triggers an explosion on itself when transitioning to a specific damage state.")] - public class ExplosionOnDamageTransitionInfo : ITraitInfo, IRulesetLoaded, Requires + public class ExplosionOnDamageTransitionInfo : ITraitInfo, IRulesetLoaded, Requires { [WeaponReference, FieldLoader.Require, Desc("Weapon to use for explosion.")] public readonly string Weapon = null; diff --git a/OpenRA.Mods.Common/Traits/Health.cs b/OpenRA.Mods.Common/Traits/Health.cs index 6dcc4d4347..edd252be9e 100644 --- a/OpenRA.Mods.Common/Traits/Health.cs +++ b/OpenRA.Mods.Common/Traits/Health.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class HealthInfo : ITraitInfo, UsesInit, IRulesetLoaded + public class HealthInfo : IHealthInfo, UsesInit, IRulesetLoaded { [Desc("HitPoints")] public readonly int HP = 0; @@ -30,6 +30,8 @@ namespace OpenRA.Mods.Common.Traits if (!ai.HasTraitInfo()) throw new YamlException("Actors with Health need at least one HitShape trait!"); } + + int IHealthInfo.MaxHP { get { return HP; } } } public class Health : IHealth, ISync, ITick, INotifyCreated, INotifyOwnerChanged diff --git a/OpenRA.Mods.Common/Traits/KillsSelf.cs b/OpenRA.Mods.Common/Traits/KillsSelf.cs index bed46712fe..f5fbd5410b 100644 --- a/OpenRA.Mods.Common/Traits/KillsSelf.cs +++ b/OpenRA.Mods.Common/Traits/KillsSelf.cs @@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits if (conditionManager != null && !string.IsNullOrEmpty(Info.GrantsCondition)) conditionManager.GrantCondition(self, Info.GrantsCondition); - if (Info.RemoveInstead || !self.Info.HasTraitInfo()) + if (Info.RemoveInstead || !self.Info.HasTraitInfo()) self.Dispose(); else self.Kill(self, Info.DamageTypes); diff --git a/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs b/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs index d0b7b2774d..0976ed4674 100644 --- a/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs +++ b/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs @@ -14,20 +14,20 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Scale power amount with the current health.")] - public class ScalePowerWithHealthInfo : ITraitInfo, Requires, Requires + public class ScalePowerWithHealthInfo : ITraitInfo, Requires, Requires { public object Create(ActorInitializer init) { return new ScalePowerWithHealth(init.Self); } } public class ScalePowerWithHealth : IPowerModifier, INotifyDamage, INotifyOwnerChanged { - readonly Health health; + readonly IHealth health; PowerManager power; public ScalePowerWithHealth(Actor self) { power = self.Owner.PlayerActor.Trait(); - health = self.Trait(); + health = self.Trait(); } int IPowerModifier.GetPowerModifier() diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index 0fcabfca5d..30a0de52ff 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -20,7 +20,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor can be sent to a structure for repairs.")] - class RepairableInfo : ITraitInfo, Requires, Requires + class RepairableInfo : ITraitInfo, Requires, Requires { public readonly HashSet RepairBuildings = new HashSet { "fix" }; @@ -35,14 +35,14 @@ namespace OpenRA.Mods.Common.Traits class Repairable : IIssueOrder, IResolveOrder, IOrderVoice { public readonly RepairableInfo Info; - readonly Health health; + readonly IHealth health; readonly IMove movement; readonly AmmoPool[] ammoPools; public Repairable(Actor self, RepairableInfo info) { Info = info; - health = self.Trait(); + health = self.Trait(); movement = self.Trait(); ammoPools = self.TraitsImplementing().ToArray(); } diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs index f3e0a7ca39..66e90d57ae 100644 --- a/OpenRA.Mods.Common/Traits/RepairableNear.cs +++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - class RepairableNearInfo : ITraitInfo, Requires, Requires + class RepairableNearInfo : ITraitInfo, Requires, Requires { [ActorReference] public readonly HashSet Buildings = new HashSet { "spen", "syrd" }; public readonly WDist CloseEnough = WDist.FromCells(4); diff --git a/OpenRA.Mods.Common/Traits/SelfHealing.cs b/OpenRA.Mods.Common/Traits/SelfHealing.cs index 555d0dea11..53c35af2df 100644 --- a/OpenRA.Mods.Common/Traits/SelfHealing.cs +++ b/OpenRA.Mods.Common/Traits/SelfHealing.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Attach this to actors which should be able to regenerate their health points.")] - class SelfHealingInfo : ConditionalTraitInfo, Requires + class SelfHealingInfo : ConditionalTraitInfo, Requires { [Desc("Absolute amount of health points added in each step.")] public readonly int Step = 5; @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits class SelfHealing : ConditionalTrait, ITick, INotifyDamage { - readonly Health health; + readonly IHealth health; [Sync] int ticks; [Sync] int damageTicks; @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits public SelfHealing(Actor self, SelfHealingInfo info) : base(info) { - health = self.Trait(); + health = self.Trait(); } void ITick.Tick(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index 088210def0..856837a979 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public class Sellable : ConditionalTrait, IResolveOrder, IProvideTooltipInfo { readonly Actor self; - readonly Lazy health; + readonly Lazy health; readonly SellableInfo info; public Sellable(Actor self, SellableInfo info) @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits { this.self = self; this.info = info; - health = Exts.Lazy(() => self.TraitOrDefault()); + health = Exts.Lazy(() => self.TraitOrDefault()); } public void ResolveOrder(Actor self, Order order) diff --git a/OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs b/OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs index 58ecaf3f2c..cf51ffc745 100644 --- a/OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs +++ b/OpenRA.Mods.Common/Traits/SpawnActorsOnSell.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits var valued = self.Info.TraitInfoOrDefault(); var cost = csv != null ? csv.Value : (valued != null ? valued.Cost : 0); - var health = self.TraitOrDefault(); + var health = self.TraitOrDefault(); var dudesValue = Info.ValuePercent * cost / 100; if (health != null) { diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index f3cafcebf9..dec8a701c1 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Warheads if (!AffectsParent && victim == firedBy) continue; - if (!victim.Info.HasTraitInfo()) + if (!victim.Info.HasTraitInfo()) continue; // If the impact position is within any HitShape, we have a direct hit diff --git a/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs index c4bffc7e8a..2ec835df54 100644 --- a/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs @@ -43,12 +43,12 @@ namespace OpenRA.Mods.Common.Warheads if (!IsValidAgainst(victim, firedBy)) return; - var healthInfo = victim.Info.TraitInfoOrDefault(); + var healthInfo = victim.Info.TraitInfoOrDefault(); if (healthInfo == null) return; // Damage is measured as a percentage of the target health - var damage = Util.ApplyPercentageModifiers(healthInfo.HP, damageModifiers.Append(Damage, DamageVersus(victim))); + var damage = Util.ApplyPercentageModifiers(healthInfo.MaxHP, damageModifiers.Append(Damage, DamageVersus(victim))); victim.InflictDamage(firedBy, new Damage(damage, DamageTypes)); } } diff --git a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs index 4418cceb87..119e1ff597 100644 --- a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Warheads foreach (var victim in hitActors) { // Cannot be damaged without a Health trait - var healthInfo = victim.Info.TraitInfoOrDefault(); + var healthInfo = victim.Info.TraitInfoOrDefault(); if (healthInfo == null) continue;