Make WithRangeCircle conditional
This commit is contained in:
committed by
reaperrr
parent
2ee6243e67
commit
b8a85091d4
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
public enum RangeCircleVisibility { Always, WhenSelected }
|
||||
|
||||
[Desc("Renders an arbitrary circle when selected or placing a structure")]
|
||||
class WithRangeCircleInfo : ITraitInfo, IPlaceBuildingDecorationInfo
|
||||
class WithRangeCircleInfo : ConditionalTraitInfo, IPlaceBuildingDecorationInfo
|
||||
{
|
||||
[Desc("Type of range circle. used to decide which circles to draw on other structures during building placement.")]
|
||||
public readonly string Type = null;
|
||||
@@ -43,37 +43,42 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||
{
|
||||
yield return new RangeCircleRenderable(
|
||||
centerPosition,
|
||||
Range,
|
||||
0,
|
||||
Color,
|
||||
Color.FromArgb(96, Color.Black));
|
||||
if (EnabledByDefault)
|
||||
{
|
||||
yield return new RangeCircleRenderable(
|
||||
centerPosition,
|
||||
Range,
|
||||
0,
|
||||
Color,
|
||||
Color.FromArgb(96, Color.Black));
|
||||
|
||||
foreach (var a in w.ActorsWithTrait<WithRangeCircle>())
|
||||
if (a.Trait.Info.Type == Type)
|
||||
foreach (var r in a.Trait.RenderRangeCircle(a.Actor, wr))
|
||||
yield return r;
|
||||
foreach (var a in w.ActorsWithTrait<WithRangeCircle>())
|
||||
if (a.Trait.Info.Type == Type)
|
||||
foreach (var r in a.Trait.RenderRangeCircle(a.Actor, wr))
|
||||
yield return r;
|
||||
}
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithRangeCircle(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new WithRangeCircle(init.Self, this); }
|
||||
}
|
||||
|
||||
class WithRangeCircle : IRenderAboveShroudWhenSelected, IRenderAboveWorld
|
||||
class WithRangeCircle : ConditionalTrait<WithRangeCircleInfo>, IRenderAboveShroudWhenSelected, IRenderAboveWorld
|
||||
{
|
||||
public readonly WithRangeCircleInfo Info;
|
||||
readonly Actor self;
|
||||
|
||||
public WithRangeCircle(Actor self, WithRangeCircleInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.self = self;
|
||||
Info = info;
|
||||
}
|
||||
|
||||
bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return false;
|
||||
|
||||
var p = self.World.RenderPlayer;
|
||||
return p == null || Info.ValidStances.HasStance(self.Owner.Stances[p]) || (p.Spectating && !p.NonCombatant);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user