Remove Player.CanViewActor and .CanTargetActor.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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(); } }
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user