diff --git a/OpenRA.Game/Traits/Cloak.cs b/OpenRA.Game/Traits/Cloak.cs index f6b12a4f88..7ec5aa7e40 100644 --- a/OpenRA.Game/Traits/Cloak.cs +++ b/OpenRA.Game/Traits/Cloak.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Drawing; namespace OpenRA.Traits { @@ -24,7 +25,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new Cloak(init.self); } } - public class Cloak : IRenderModifier, INotifyAttack, ITick, INotifyDamage, IRadarVisibilityModifier + public class Cloak : IRenderModifier, INotifyAttack, ITick, INotifyDamage, IRadarVisibilityModifier, IRadarColorModifier { [Sync] int remainingTime; @@ -76,7 +77,7 @@ namespace OpenRA.Traits Sound.Play(self.Info.Traits.Get().CloakSound, self.CenterLocation); } - public bool Cloaked { get { return remainingTime > 0; } } + public bool Cloaked { get { return remainingTime == 0; } } public bool VisibleOnRadar(Actor self) @@ -84,6 +85,14 @@ namespace OpenRA.Traits return !Cloaked || self.Owner == self.World.LocalPlayer; } + public Color RadarColorOverride(Actor self) + { + var c = self.Owner.Color; + if (self.Owner == self.World.LocalPlayer && Cloaked) + c = Color.FromArgb(128, c); + return c; + } + public void Decloak(int time) { DoSurface(); diff --git a/OpenRA.Mods.RA/LimitedAmmo.cs b/OpenRA.Mods.RA/LimitedAmmo.cs index c910cf0e18..96588a6ed3 100644 --- a/OpenRA.Mods.RA/LimitedAmmo.cs +++ b/OpenRA.Mods.RA/LimitedAmmo.cs @@ -18,20 +18,18 @@ namespace OpenRA.Mods.RA public readonly int Ammo = 0; public readonly int PipCount = 0; - public object Create(ActorInitializer init) { return new LimitedAmmo(init.self, this); } + public object Create(ActorInitializer init) { return new LimitedAmmo(this); } } public class LimitedAmmo : INotifyAttack, IPips { [Sync] int ammo; - Actor self; LimitedAmmoInfo Info; - public LimitedAmmo(Actor self, LimitedAmmoInfo info) + public LimitedAmmo(LimitedAmmoInfo info) { ammo = info.Ammo; - this.self = self; Info = info; } diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index 607450f20e..fe3c58983b 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using OpenRA.Traits; using OpenRA.Traits.Activities; +using System.Drawing; namespace OpenRA.Mods.RA { @@ -24,7 +25,7 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new Mine(init, this); } } - class Mine : ICrushable, IOccupySpace + class Mine : ICrushable, IOccupySpace, IRadarVisibilityModifier, IRadarColorModifier { readonly Actor self; readonly MineInfo info; @@ -55,6 +56,16 @@ namespace OpenRA.Mods.RA public int2 TopLeft { get { return location; } } public IEnumerable OccupiedCells() { yield return TopLeft; } + + public bool VisibleOnRadar(Actor self) + { + return self.Owner == self.World.LocalPlayer; + } + + public Color RadarColorOverride(Actor self) + { + return Color.FromArgb(128, self.Owner.Color); + } } /* tag trait for stuff that shouldnt trigger mines */