diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 8d82da0d6d..8290fb4ee0 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -9,6 +9,7 @@ #endregion using System.Drawing; +using System.Linq; using OpenRA.Graphics; namespace OpenRA.Traits @@ -30,13 +31,20 @@ namespace OpenRA.Traits public void RenderAfterWorld (WorldRenderer wr, Actor self) { var bounds = self.GetBounds(true); + Color selectionColor = Color.White; var xy = new float2(bounds.Left, bounds.Top); var Xy = new float2(bounds.Right, bounds.Top); var xY = new float2(bounds.Left, bounds.Bottom); var XY = new float2(bounds.Right, bounds.Bottom); - DrawSelectionBox(self, xy, Xy, xY, XY, Color.White); + var colorResults = self.TraitsImplementing().Select(t => t.GetSelectionColorModifier(self, selectionColor)).Where( + c => c.ToArgb() != selectionColor.ToArgb()); + + if (colorResults.Any()) + selectionColor = colorResults.First(); + + DrawSelectionBox(self, xy, Xy, xY, XY, selectionColor); DrawHealthBar(self, xy, Xy); DrawControlGroup(wr, self, xy); DrawPips(wr, self, xY); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 803671a9a2..38592c90e9 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -109,6 +109,7 @@ namespace OpenRA.Traits public interface IDamageModifier { float GetDamageModifier(Actor attacker, WarheadInfo warhead); } public interface ISpeedModifier { decimal GetSpeedModifier(); } public interface IFirepowerModifier { float GetFirepowerModifier(); } + public interface ISelectionColorModifier { Color GetSelectionColorModifier(Actor self, Color defaultColor); } public interface IPalette { void InitPalette( WorldRenderer wr ); } public interface IPaletteModifier { void AdjustPalette(Dictionary b); } public interface IPips { IEnumerable GetPips(Actor self); }