Move Shape from Health to new HitShape trait

Renamed Shape to Type
This commit is contained in:
reaperrr
2017-05-21 12:44:47 +02:00
parent c7c6cf864c
commit 43b55ae333
9 changed files with 87 additions and 51 deletions

View File

@@ -34,6 +34,7 @@ namespace OpenRA.Mods.Common.Traits
readonly HealthInfo healthInfo;
readonly Lazy<BodyOrientation> coords;
HitShape[] shapes;
IBlocksProjectiles[] allBlockers;
ITargetablePositions[] targetablePositions;
@@ -48,6 +49,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self)
{
shapes = self.TraitsImplementing<HitShape>().ToArray();
allBlockers = self.TraitsImplementing<IBlocksProjectiles>().ToArray();
targetablePositions = self.TraitsImplementing<ITargetablePositions>().ToArray();
}
@@ -60,9 +62,6 @@ namespace OpenRA.Mods.Common.Traits
var wcr = Game.Renderer.WorldRgbaColorRenderer;
var iz = 1 / wr.Viewport.Zoom;
if (healthInfo != null)
healthInfo.Shape.DrawCombatOverlay(wr, wcr, self);
var blockers = allBlockers.Where(Exts.IsTraitEnabled).ToList();
if (blockers.Count > 0)
{
@@ -75,6 +74,10 @@ namespace OpenRA.Mods.Common.Traits
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
}
var activeShapes = shapes.Where(Exts.IsTraitEnabled);
foreach (var s in activeShapes)
s.Info.Type.DrawCombatOverlay(wr, wcr, self);
var tc = Color.Lime;
var enabledPositions = targetablePositions.Where(Exts.IsTraitEnabled);
var positions = enabledPositions.SelectMany(tp => tp.TargetablePositions(self));