Replace usage of the Stances dict by a method call
This commit is contained in:
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (e.Attacker == null || e.Attacker.Disposed)
|
||||
return;
|
||||
|
||||
if (e.Attacker.Owner.Stances[self.Owner] != PlayerRelationship.Enemy)
|
||||
if (e.Attacker.Owner.RelationshipWith(self.Owner) != PlayerRelationship.Enemy)
|
||||
return;
|
||||
|
||||
if (!e.Attacker.Info.HasTraitInfo<ITargetableInfo>())
|
||||
|
||||
@@ -409,7 +409,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
case BuildingType.Defense:
|
||||
|
||||
// Build near the closest enemy structure
|
||||
var closestEnemy = world.ActorsHavingTrait<Building>().Where(a => !a.Disposed && player.Stances[a.Owner] == PlayerRelationship.Enemy)
|
||||
var closestEnemy = world.ActorsHavingTrait<Building>().Where(a => !a.Disposed && player.RelationshipWith(a.Owner) == PlayerRelationship.Enemy)
|
||||
.ClosestTo(world.Map.CenterOfCell(baseBuilder.DefenseCenter));
|
||||
|
||||
var targetCell = closestEnemy != null ? closestEnemy.Location : baseCenter;
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var checkActors = world.FindActorsInCircle(pos, radiusToUse);
|
||||
foreach (var scrutinized in checkActors)
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.Stances[scrutinized.Owner], firedBy);
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy);
|
||||
|
||||
var delta = new WVec(radiusToUse, radiusToUse, WDist.Zero);
|
||||
var tl = world.Map.CellContaining(pos - delta);
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// IsValid check filters out Frozen Actors that have not initizialized their Owner
|
||||
foreach (var scrutinized in checkFrozen)
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.Stances[scrutinized.Owner], firedBy);
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy);
|
||||
}
|
||||
|
||||
return answer;
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var consideration in Considerations)
|
||||
foreach (var scrutinized in actors)
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.Stances[scrutinized.Owner], firedBy);
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy);
|
||||
|
||||
return answer;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var consideration in Considerations)
|
||||
foreach (var scrutinized in frozenActors)
|
||||
if (scrutinized.IsValid && scrutinized.Visible)
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.Stances[scrutinized.Owner], firedBy);
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy);
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// HACK: We don't want D2k bots to repair all their buildings on placement
|
||||
// where half their HP is removed via neutral terrain damage.
|
||||
// TODO: Implement concrete placement for D2k bots and remove this hack.
|
||||
if (e.Attacker.Owner.Stances[self.Owner] == PlayerRelationship.Neutral)
|
||||
if (self.Owner.RelationshipWith(e.Attacker.Owner) == PlayerRelationship.Neutral)
|
||||
return;
|
||||
|
||||
var rb = self.TraitOrDefault<RepairableBuilding>();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
isEnemyUnit = unit =>
|
||||
player.Stances[unit.Owner] == PlayerRelationship.Enemy
|
||||
player.RelationshipWith(unit.Owner) == PlayerRelationship.Enemy
|
||||
&& !unit.Info.HasTraitInfo<HuskInfo>()
|
||||
&& unit.Info.HasTraitInfo<ITargetableInfo>();
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var randPlayer = world.Players.Where(p => !p.Spectating
|
||||
&& Info.CapturableStances.HasStance(player.Stances[p])).Random(world.LocalRandom);
|
||||
&& Info.CapturableStances.HasStance(player.RelationshipWith(p))).Random(world.LocalRandom);
|
||||
|
||||
var targetOptions = Info.CheckCaptureTargetsForVisibility
|
||||
? GetVisibleActorsBelongingToPlayer(randPlayer)
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var path = pathfinder.FindPath(
|
||||
PathSearch.Search(world, harv.Locomotor, actor, BlockedByActor.Stationary, isValidResource)
|
||||
.WithCustomCost(loc => world.FindActorsInCircle(world.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
|
||||
.Where(u => !u.IsDead && actor.Owner.Stances[u.Owner] == PlayerRelationship.Enemy)
|
||||
.Where(u => !u.IsDead && actor.Owner.RelationshipWith(u.Owner) == PlayerRelationship.Enemy)
|
||||
.Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (world.Map.CenterOfCell(loc) - u.CenterPosition).Length)))
|
||||
.FromPoint(actor.Location));
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Use for proactive targeting.
|
||||
public bool IsPreferredEnemyUnit(Actor a)
|
||||
{
|
||||
if (a == null || a.IsDead || Player.Stances[a.Owner] != PlayerRelationship.Enemy || a.Info.HasTraitInfo<HuskInfo>())
|
||||
if (a == null || a.IsDead || Player.RelationshipWith(a.Owner) != PlayerRelationship.Enemy || a.Info.HasTraitInfo<HuskInfo>())
|
||||
return false;
|
||||
|
||||
var targetTypes = a.GetEnabledTargetTypes();
|
||||
|
||||
Reference in New Issue
Block a user