Remove Player.CanViewActor and .CanTargetActor.

This commit is contained in:
Paul Chote
2017-10-05 16:59:42 +00:00
committed by reaperrr
parent 47634b25f9
commit 1376ad674e
10 changed files with 14 additions and 22 deletions

View File

@@ -162,16 +162,6 @@ namespace OpenRA
return p == null || Stances[p] == Stance.Ally || (p.Spectating && !NonCombatant);
}
public bool CanViewActor(Actor a)
{
return a.CanBeViewedByPlayer(this);
}
public bool CanTargetActor(Actor a)
{
return CanViewActor(a);
}
public Color PlayerStanceColor(Actor a)
{
var player = a.World.RenderPlayer ?? a.World.LocalPlayer;

View File

@@ -77,7 +77,7 @@ namespace OpenRA
set { renderPlayer = value; }
}
public bool FogObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.CanViewActor(a); }
public bool FogObscures(Actor a) { return RenderPlayer != null && !a.CanBeViewedByPlayer(RenderPlayer); }
public bool FogObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(p); }
public bool FogObscures(WPos pos) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(pos); }
public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); }

View File

@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Traits
var targetUnits = power.UnitsInRange(xy).Where(a => !world.FogObscures(a));
foreach (var unit in targetUnits)
if (manager.Self.Owner.CanTargetActor(unit))
if (unit.CanBeViewedByPlayer(manager.Self.Owner))
yield return new SelectionBoxRenderable(unit, Color.Red);
}
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.Cnc.Traits
// Unit previews
foreach (var unit in power.UnitsInRange(sourceLocation))
{
if (manager.Self.Owner.CanTargetActor(unit))
if (unit.CanBeViewedByPlayer(manager.Self.Owner))
{
var targetCell = unit.Location + (xy - sourceLocation);
var canEnter = manager.Self.Owner.Shroud.IsExplored(targetCell) &&
@@ -260,13 +260,13 @@ namespace OpenRA.Mods.Cnc.Traits
}
var offset = world.Map.CenterOfCell(xy) - world.Map.CenterOfCell(sourceLocation);
if (manager.Self.Owner.CanTargetActor(unit))
if (unit.CanBeViewedByPlayer(manager.Self.Owner))
foreach (var r in unit.Render(wr))
yield return r.OffsetBy(offset);
}
foreach (var unit in power.UnitsInRange(sourceLocation))
if (manager.Self.Owner.CanTargetActor(unit))
if (unit.CanBeViewedByPlayer(manager.Self.Owner))
yield return new SelectionBoxRenderable(unit, Color.Red);
}

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.AI
public bool IsTargetVisible
{
get { return Bot.Player.PlayerActor.Owner.CanTargetActor(TargetActor); }
get { return TargetActor.CanBeViewedByPlayer(Bot.Player); }
}
public WPos CenterPosition { get { return Units.Select(u => u.CenterPosition).Average(); } }

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Activities
var pos = self.CenterPosition;
var targetPos = attackHeli.GetTargetPosition(pos, target);
if (attackOnlyVisibleTargets && target.Type == TargetType.Actor && canHideUnderFog
&& !self.Owner.CanTargetActor(target.Actor))
&& !target.Actor.CanBeViewedByPlayer(self.Owner))
{
var newTarget = Target.FromCell(self.World, self.World.Map.CellContaining(targetPos));

View File

@@ -90,7 +90,9 @@ namespace OpenRA.Mods.Common.Activities
// HACK: This would otherwise break targeting frozen actors
// The problem is that Shroud.IsTargetable returns false (as it should) for
// frozen actors, but we do want to explicitly target the underlying actor here.
if (!attack.Info.IgnoresVisibility && type == TargetType.Actor && !Target.Actor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !self.Owner.CanTargetActor(Target.Actor))
if (!attack.Info.IgnoresVisibility && type == TargetType.Actor
&& !Target.Actor.Info.HasTraitInfo<FrozenUnderFogInfo>()
&& !Target.Actor.CanBeViewedByPlayer(self.Owner))
return NextActivity;
// Drop the target once none of the weapons are effective against it

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Activities
// Target moved under the fog. Move to its last known position.
if (Target.Type == TargetType.Actor && canHideUnderFog
&& !self.Owner.CanTargetActor(Target.Actor))
&& !Target.Actor.CanBeViewedByPlayer(self.Owner))
{
if (inner != null)
inner.Cancel(self);

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Scripting
if (!target.IsValidFor(Self))
Log.Write("lua", "{1} is an invalid target for {0}!", Self, targetActor);
if (!targetActor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !Self.Owner.CanTargetActor(targetActor))
if (!targetActor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !targetActor.CanBeViewedByPlayer(Self.Owner))
Log.Write("lua", "{1} is not revealed for player {0}!", Self.Owner, targetActor);
attackBase.AttackTarget(target, true, allowMove, forceAttack);

View File

@@ -300,7 +300,7 @@ namespace OpenRA.Mods.Common.Traits
return true;
}).ToList();
if (!validPriorities.Any() || PreventsAutoTarget(self, actor) || !self.Owner.CanTargetActor(actor))
if (!validPriorities.Any() || PreventsAutoTarget(self, actor) || !actor.CanBeViewedByPlayer(self.Owner))
continue;
// Make sure that we can actually fire on the actor

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
continue;
// The actor is not currently visible
if (!self.Owner.CanViewActor(actor.Actor))
if (!actor.Actor.CanBeViewedByPlayer(self.Owner))
continue;
visibleActorIds.Add(actor.Actor.ActorID);