Added: ISelectionColorModifier

This commit is contained in:
geckosoft
2010-11-11 04:18:54 +01:00
committed by Bob
parent 75e7124af0
commit 5b71bee4c8
2 changed files with 10 additions and 1 deletions

View File

@@ -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<ISelectionColorModifier>().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);

View File

@@ -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<string,Palette> b); }
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }