Rename Stance to PlayerRelationship

This commit is contained in:
abcdefg30
2020-09-25 16:22:37 +02:00
committed by Paul Chote
parent 672172d1f1
commit eda9966d27
63 changed files with 111 additions and 111 deletions

View File

@@ -229,11 +229,11 @@ namespace OpenRA
return "{0} ({1})".F(PlayerName, ClientIndex); return "{0} ({1})".F(PlayerName, ClientIndex);
} }
public Dictionary<Player, Stance> Stances = new Dictionary<Player, Stance>(); public Dictionary<Player, PlayerRelationship> Stances = new Dictionary<Player, PlayerRelationship>();
public bool IsAlliedWith(Player p) public bool IsAlliedWith(Player p)
{ {
// Observers are considered allies to active combatants // Observers are considered allies to active combatants
return p == null || Stances[p] == Stance.Ally || (p.Spectating && !NonCombatant); return p == null || Stances[p] == PlayerRelationship.Ally || (p.Spectating && !NonCombatant);
} }
public Color PlayerStanceColor(Actor a) public Color PlayerStanceColor(Actor a)

View File

@@ -38,9 +38,9 @@ namespace OpenRA.Traits
switch (viewer.Stances[a.Owner]) switch (viewer.Stances[a.Owner])
{ {
case Stance.Ally: return basePriority - PriorityRange; case PlayerRelationship.Ally: return basePriority - PriorityRange;
case Stance.Neutral: return basePriority - 2 * PriorityRange; case PlayerRelationship.Neutral: return basePriority - 2 * PriorityRange;
case Stance.Enemy: return basePriority - 3 * PriorityRange; case PlayerRelationship.Enemy: return basePriority - 3 * PriorityRange;
default: default:
throw new InvalidOperationException(); throw new InvalidOperationException();

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Traits
} }
[Flags] [Flags]
public enum Stance public enum PlayerRelationship
{ {
None = 0, None = 0,
Enemy = 1, Enemy = 1,
@@ -78,7 +78,7 @@ namespace OpenRA.Traits
public static class StanceExts public static class StanceExts
{ {
public static bool HasStance(this Stance s, Stance stance) public static bool HasStance(this PlayerRelationship s, PlayerRelationship stance)
{ {
// PERF: Enum.HasFlag is slower and requires allocations. // PERF: Enum.HasFlag is slower and requires allocations.
return (s & stance) == stance; return (s & stance) == stance;
@@ -196,7 +196,7 @@ namespace OpenRA.Traits
public interface ITooltipInfo : ITraitInfoInterface public interface ITooltipInfo : ITraitInfoInterface
{ {
string TooltipForPlayerStance(Stance stance); string TooltipForPlayerStance(PlayerRelationship stance);
bool IsOwnerRowVisible { get; } bool IsOwnerRowVisible { get; }
} }

View File

@@ -227,7 +227,7 @@ namespace OpenRA
SetUpPlayerMask(p, q); SetUpPlayerMask(p, q);
if (!p.Stances.ContainsKey(q)) if (!p.Stances.ContainsKey(q))
p.Stances[q] = Stance.Neutral; p.Stances[q] = PlayerRelationship.Neutral;
} }
} }
@@ -254,11 +254,11 @@ namespace OpenRA
switch (p.Stances[q]) switch (p.Stances[q])
{ {
case Stance.Enemy: case PlayerRelationship.Enemy:
case Stance.Neutral: case PlayerRelationship.Neutral:
p.EnemyPlayersMask = p.EnemyPlayersMask.Union(bitSet); p.EnemyPlayersMask = p.EnemyPlayersMask.Union(bitSet);
break; break;
case Stance.Ally: case PlayerRelationship.Ally:
p.AlliedPlayersMask = p.AlliedPlayersMask.Union(bitSet); p.AlliedPlayersMask = p.AlliedPlayersMask.Union(bitSet);
break; break;
} }

View File

@@ -90,8 +90,8 @@ namespace OpenRA
public static bool AreMutualAllies(Player a, Player b) public static bool AreMutualAllies(Player a, Player b)
{ {
return a.Stances[b] == Stance.Ally && return a.Stances[b] == PlayerRelationship.Ally &&
b.Stances[a] == Stance.Ally; b.Stances[a] == PlayerRelationship.Ally;
} }
} }
} }

View File

@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Activities
if (rearmableInfo != null && ammoPools.Any(p => p.Info.Name == minelayer.Info.AmmoPoolName && !p.HasAmmo)) if (rearmableInfo != null && ammoPools.Any(p => p.Info.Name == minelayer.Info.AmmoPoolName && !p.HasAmmo))
{ {
// Rearm (and possibly repair) at rearm building, then back out here to refill the minefield some more // Rearm (and possibly repair) at rearm building, then back out here to refill the minefield some more
rearmTarget = self.World.Actors.Where(a => self.Owner.Stances[a.Owner] == Stance.Ally && rearmableInfo.RearmActors.Contains(a.Info.Name)) rearmTarget = self.World.Actors.Where(a => self.Owner.Stances[a.Owner] == PlayerRelationship.Ally && rearmableInfo.RearmActors.Contains(a.Info.Name))
.ClosestTo(self); .ClosestTo(self);
if (rearmTarget == null) if (rearmTarget == null)

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly string DisguisedCondition = null; public readonly string DisguisedCondition = null;
[Desc("What diplomatic stances can this actor disguise as.")] [Desc("What diplomatic stances can this actor disguise as.")]
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Target types of actors that this actor disguise as.")] [Desc("Target types of actors that this actor disguise as.")]
public readonly BitSet<TargetableType> TargetTypes = new BitSet<TargetableType>("Disguise"); public readonly BitSet<TargetableType> TargetTypes = new BitSet<TargetableType>("Disguise");

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly string Voice = "Action"; public readonly string Voice = "Action";
[Desc("What diplomatic stances can be infiltrated by this actor.")] [Desc("What diplomatic stances can be infiltrated by this actor.")]
public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Behaviour when entering the target.", [Desc("Behaviour when entering the target.",
"Possible values are Exit, Suicide, Dispose.")] "Possible values are Exit, Suicide, Dispose.")]

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Traits
if (!info.CrushClasses.Overlaps(crushClasses)) if (!info.CrushClasses.Overlaps(crushClasses))
return; return;
if (crusher.Info.HasTraitInfo<MineImmuneInfo>() || (self.Owner.Stances[crusher.Owner] == Stance.Ally && info.AvoidFriendly)) if (crusher.Info.HasTraitInfo<MineImmuneInfo>() || (self.Owner.Stances[crusher.Owner] == PlayerRelationship.Ally && info.AvoidFriendly))
return; return;
var mobile = crusher.TraitOrDefault<Mobile>(); var mobile = crusher.TraitOrDefault<Mobile>();
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.Traits
bool ICrushable.CrushableBy(Actor self, Actor crusher, BitSet<CrushClass> crushClasses) bool ICrushable.CrushableBy(Actor self, Actor crusher, BitSet<CrushClass> crushClasses)
{ {
if (info.BlockFriendly && !crusher.Info.HasTraitInfo<MineImmuneInfo>() && self.Owner.Stances[crusher.Owner] == Stance.Ally) if (info.BlockFriendly && !crusher.Info.HasTraitInfo<MineImmuneInfo>() && self.Owner.Stances[crusher.Owner] == PlayerRelationship.Ally)
return false; return false;
return info.CrushClasses.Overlaps(crushClasses); return info.CrushClasses.Overlaps(crushClasses);

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common
public static List<Actor> FindEnemiesByCommonName(HashSet<string> commonNames, Player player) public static List<Actor> FindEnemiesByCommonName(HashSet<string> commonNames, Player player)
{ {
return player.World.Actors.Where(a => !a.IsDead && player.Stances[a.Owner] == Stance.Enemy && return player.World.Actors.Where(a => !a.IsDead && player.Stances[a.Owner] == PlayerRelationship.Enemy &&
commonNames.Contains(a.Info.Name)).ToList(); commonNames.Contains(a.Info.Name)).ToList();
} }

View File

@@ -37,11 +37,11 @@ namespace OpenRA.Mods.Common
public static bool AppearsFriendlyTo(this Actor self, Actor toActor) public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
{ {
var stance = toActor.Owner.Stances[self.Owner]; var stance = toActor.Owner.Stances[self.Owner];
if (stance == Stance.Ally) if (stance == PlayerRelationship.Ally)
return true; return true;
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.Info.HasTraitInfo<IgnoresDisguiseInfo>()) if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.Info.HasTraitInfo<IgnoresDisguiseInfo>())
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == Stance.Ally; return toActor.Owner.Stances[self.EffectiveOwner.Owner] == PlayerRelationship.Ally;
return false; return false;
} }
@@ -49,13 +49,13 @@ namespace OpenRA.Mods.Common
public static bool AppearsHostileTo(this Actor self, Actor toActor) public static bool AppearsHostileTo(this Actor self, Actor toActor)
{ {
var stance = toActor.Owner.Stances[self.Owner]; var stance = toActor.Owner.Stances[self.Owner];
if (stance == Stance.Ally) if (stance == PlayerRelationship.Ally)
return false; /* otherwise, we'll hate friendly disguised spies */ return false; /* otherwise, we'll hate friendly disguised spies */
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.Info.HasTraitInfo<IgnoresDisguiseInfo>()) if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.Info.HasTraitInfo<IgnoresDisguiseInfo>())
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == Stance.Enemy; return toActor.Owner.Stances[self.EffectiveOwner.Owner] == PlayerRelationship.Enemy;
return stance == Stance.Enemy; return stance == PlayerRelationship.Enemy;
} }
public static void NotifyBlocker(this Actor self, IEnumerable<Actor> blockers) public static void NotifyBlocker(this Actor self, IEnumerable<Actor> blockers)

View File

@@ -25,12 +25,12 @@ namespace OpenRA.Mods.Common.Effects
readonly Player player; readonly Player player;
readonly Shroud.SourceType sourceType; readonly Shroud.SourceType sourceType;
readonly WDist revealRadius; readonly WDist revealRadius;
readonly Stance validStances; readonly PlayerRelationship validStances;
readonly int duration; readonly int duration;
int ticks; int ticks;
public RevealShroudEffect(WPos pos, WDist radius, Shroud.SourceType type, Player forPlayer, Stance stances, int delay = 0, int duration = 50) public RevealShroudEffect(WPos pos, WDist radius, Shroud.SourceType type, Player forPlayer, PlayerRelationship stances, int delay = 0, int duration = 50)
{ {
this.pos = pos; this.pos = pos;
player = forPlayer; player = forPlayer;

View File

@@ -52,10 +52,10 @@ namespace OpenRA.Mods.Common.Orders
var owner = type == TargetType.FrozenActor ? target.FrozenActor.Owner : target.Actor.Owner; var owner = type == TargetType.FrozenActor ? target.FrozenActor.Owner : target.Actor.Owner;
var playerRelationship = self.Owner.Stances[owner]; var playerRelationship = self.Owner.Stances[owner];
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Ally && !targetAllyUnits) if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == PlayerRelationship.Ally && !targetAllyUnits)
return false; return false;
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Enemy && !targetEnemyUnits) if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == PlayerRelationship.Enemy && !targetEnemyUnits)
return false; return false;
return type == TargetType.FrozenActor ? return type == TargetType.FrozenActor ?

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Projectiles
public readonly HashSet<string> InvalidBounceTerrain = new HashSet<string>(); public readonly HashSet<string> InvalidBounceTerrain = new HashSet<string>();
[Desc("If projectile touches an actor with one of these stances during or after the first bounce, trigger explosion.")] [Desc("If projectile touches an actor with one of these stances during or after the first bounce, trigger explosion.")]
public readonly Stance ValidBounceBlockerStances = Stance.Enemy | Stance.Neutral; public readonly PlayerRelationship ValidBounceBlockerStances = PlayerRelationship.Enemy | PlayerRelationship.Neutral;
[Desc("Altitude above terrain below which to explode. Zero effectively deactivates airburst.")] [Desc("Altitude above terrain below which to explode. Zero effectively deactivates airburst.")]
public readonly WDist AirburstAltitude = WDist.Zero; public readonly WDist AirburstAltitude = WDist.Zero;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly HashSet<string> ValidTypes = new HashSet<string>(); public readonly HashSet<string> ValidTypes = new HashSet<string>();
[Desc("Stance the delivering actor needs to enter.")] [Desc("Stance the delivering actor needs to enter.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("Play a randomly selected sound from this list when accepting cash.")] [Desc("Play a randomly selected sound from this list when accepting cash.")]
public readonly string[] Sounds = { }; public readonly string[] Sounds = { };

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly HashSet<string> ValidTypes = new HashSet<string>(); public readonly HashSet<string> ValidTypes = new HashSet<string>();
[Desc("Stance the delivering actor needs to enter.")] [Desc("Stance the delivering actor needs to enter.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
public override object Create(ActorInitializer init) { return new AcceptsDeliveredExperience(init.Self, this); } public override object Create(ActorInitializer init) { return new AcceptsDeliveredExperience(init.Self, this); }
} }

View File

@@ -670,7 +670,7 @@ namespace OpenRA.Mods.Common.Traits
// We are not blocked by actors we can nudge out of the way // We are not blocked by actors we can nudge out of the way
// TODO: Generalize blocker checks and handling here and in Locomotor // TODO: Generalize blocker checks and handling here and in Locomotor
if (!blockedByMobile && self.Owner.Stances[otherActor.Owner] == Stance.Ally && if (!blockedByMobile && self.Owner.Stances[otherActor.Owner] == PlayerRelationship.Ally &&
otherActor.TraitOrDefault<Mobile>() != null && otherActor.CurrentActivity == null) otherActor.TraitOrDefault<Mobile>() != null && otherActor.CurrentActivity == null)
return false; return false;

View File

@@ -68,8 +68,8 @@ namespace OpenRA.Mods.Common.Traits
public WeaponInfo WeaponInfo { get; private set; } public WeaponInfo WeaponInfo { get; private set; }
public WDist ModifiedRange { get; private set; } public WDist ModifiedRange { get; private set; }
public readonly Stance TargetStances = Stance.Enemy; public readonly PlayerRelationship TargetStances = PlayerRelationship.Enemy;
public readonly Stance ForceTargetStances = Stance.Enemy | Stance.Neutral | Stance.Ally; public readonly PlayerRelationship ForceTargetStances = PlayerRelationship.Enemy | PlayerRelationship.Neutral | PlayerRelationship.Ally;
// TODO: instead of having multiple Armaments and unique AttackBase, // TODO: instead of having multiple Armaments and unique AttackBase,
// an actor should be able to have multiple AttackBases with // an actor should be able to have multiple AttackBases with

View File

@@ -403,10 +403,10 @@ namespace OpenRA.Mods.Common.Traits
&& (target.IsInRange(self.CenterPosition, GetMaximumRangeVersusTarget(target)) || (allowMove && self.Info.HasTraitInfo<IMoveInfo>())); && (target.IsInRange(self.CenterPosition, GetMaximumRangeVersusTarget(target)) || (allowMove && self.Info.HasTraitInfo<IMoveInfo>()));
} }
public Stance UnforcedAttackTargetStances() public PlayerRelationship UnforcedAttackTargetStances()
{ {
// PERF: Avoid LINQ. // PERF: Avoid LINQ.
var stances = Stance.None; var stances = PlayerRelationship.None;
foreach (var armament in Armaments) foreach (var armament in Armaments)
if (!armament.IsTraitDisabled) if (!armament.IsTraitDisabled)
stances |= armament.Info.TargetStances; stances |= armament.Info.TargetStances;
@@ -444,7 +444,7 @@ namespace OpenRA.Mods.Common.Traits
// targeting and attacking logic (which should be logically separate) // targeting and attacking logic (which should be logically separate)
// to use the same code // to use the same code
if (target.Type == TargetType.Actor && target.Actor.EffectiveOwner != null && if (target.Type == TargetType.Actor && target.Actor.EffectiveOwner != null &&
target.Actor.EffectiveOwner.Disguised && self.Owner.Stances[target.Actor.Owner] == Stance.Enemy) target.Actor.EffectiveOwner.Disguised && self.Owner.Stances[target.Actor.Owner] == PlayerRelationship.Enemy)
modifiers |= TargetModifiers.ForceAttack; modifiers |= TargetModifiers.ForceAttack;
var forceAttack = modifiers.HasModifier(TargetModifiers.ForceAttack); var forceAttack = modifiers.HasModifier(TargetModifiers.ForceAttack);

View File

@@ -294,7 +294,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
// If we can't attack right now, there's no need to try and find a target. // If we can't attack right now, there's no need to try and find a target.
var attackStances = ab.UnforcedAttackTargetStances(); var attackStances = ab.UnforcedAttackTargetStances();
if (attackStances != OpenRA.Traits.Stance.None) if (attackStances != OpenRA.Traits.PlayerRelationship.None)
{ {
var range = Info.ScanRadius > 0 ? WDist.FromCells(Info.ScanRadius) : ab.GetMaximumRange(); var range = Info.ScanRadius > 0 ? WDist.FromCells(Info.ScanRadius) : ab.GetMaximumRange();
return ChooseTarget(self, ab, attackStances, range, allowMove, allowTurn); return ChooseTarget(self, ab, attackStances, range, allowMove, allowTurn);
@@ -337,7 +337,7 @@ namespace OpenRA.Mods.Common.Traits
}); });
} }
Target ChooseTarget(Actor self, AttackBase ab, Stance attackStances, WDist scanRange, bool allowMove, bool allowTurn) Target ChooseTarget(Actor self, AttackBase ab, PlayerRelationship attackStances, WDist scanRange, bool allowMove, bool allowTurn)
{ {
var chosenTarget = Target.Invalid; var chosenTarget = Target.Invalid;
var chosenTargetPriority = int.MinValue; var chosenTargetPriority = int.MinValue;
@@ -362,7 +362,7 @@ namespace OpenRA.Mods.Common.Traits
// can bail early and avoid the more expensive targeting checks and armament selection. For groups of // can bail early and avoid the more expensive targeting checks and armament selection. For groups of
// allied units, this helps significantly reduce the cost of auto target scans. This is important as // allied units, this helps significantly reduce the cost of auto target scans. This is important as
// these groups will continuously rescan their allies until an enemy finally comes into range. // these groups will continuously rescan their allies until an enemy finally comes into range.
if (attackStances == OpenRA.Traits.Stance.Enemy && !target.Actor.AppearsHostileTo(self)) if (attackStances == OpenRA.Traits.PlayerRelationship.Enemy && !target.Actor.AppearsHostileTo(self))
continue; continue;
// Check whether we can auto-target this actor // Check whether we can auto-target this actor
@@ -375,7 +375,7 @@ namespace OpenRA.Mods.Common.Traits
} }
else if (target.Type == TargetType.FrozenActor) else if (target.Type == TargetType.FrozenActor)
{ {
if (attackStances == OpenRA.Traits.Stance.Enemy && self.Owner.Stances[target.FrozenActor.Owner] == OpenRA.Traits.Stance.Ally) if (attackStances == OpenRA.Traits.PlayerRelationship.Enemy && self.Owner.Stances[target.FrozenActor.Owner] == OpenRA.Traits.PlayerRelationship.Ally)
continue; continue;
targetTypes = target.FrozenActor.TargetTypes; targetTypes = target.FrozenActor.TargetTypes;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly BitSet<TargetableType> InvalidTargets; public readonly BitSet<TargetableType> InvalidTargets;
[Desc("Stances between actor's and target's owner which can be AutoTargeted.")] [Desc("Stances between actor's and target's owner which can be AutoTargeted.")]
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("ValidTargets with larger priorities will be AutoTargeted before lower priorities.")] [Desc("ValidTargets with larger priorities will be AutoTargeted before lower priorities.")]
public readonly int Priority = 1; public readonly int Priority = 1;

View File

@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
if (e.Attacker == null || e.Attacker.Disposed) if (e.Attacker == null || e.Attacker.Disposed)
return; return;
if (e.Attacker.Owner.Stances[self.Owner] != Stance.Enemy) if (e.Attacker.Owner.Stances[self.Owner] != PlayerRelationship.Enemy)
return; return;
if (!e.Attacker.Info.HasTraitInfo<ITargetableInfo>()) if (!e.Attacker.Info.HasTraitInfo<ITargetableInfo>())

View File

@@ -409,7 +409,7 @@ namespace OpenRA.Mods.Common.Traits
case BuildingType.Defense: case BuildingType.Defense:
// Build near the closest enemy structure // Build near the closest enemy structure
var closestEnemy = world.ActorsHavingTrait<Building>().Where(a => !a.Disposed && player.Stances[a.Owner] == Stance.Enemy) var closestEnemy = world.ActorsHavingTrait<Building>().Where(a => !a.Disposed && player.Stances[a.Owner] == PlayerRelationship.Enemy)
.ClosestTo(world.Map.CenterOfCell(baseBuilder.DefenseCenter)); .ClosestTo(world.Map.CenterOfCell(baseBuilder.DefenseCenter));
var targetCell = closestEnemy != null ? closestEnemy.Location : baseCenter; var targetCell = closestEnemy != null ? closestEnemy.Location : baseCenter;

View File

@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
public enum DecisionMetric { Health, Value, None } public enum DecisionMetric { Health, Value, None }
[Desc("Against whom should this power be used?", "Allowed keywords: Ally, Neutral, Enemy")] [Desc("Against whom should this power be used?", "Allowed keywords: Ally, Neutral, Enemy")]
public readonly Stance Against = Stance.Enemy; public readonly PlayerRelationship Against = PlayerRelationship.Enemy;
[Desc("What types should the desired targets of this power be?")] [Desc("What types should the desired targets of this power be?")]
public readonly BitSet<TargetableType> Types = new BitSet<TargetableType>("Air", "Ground", "Water"); public readonly BitSet<TargetableType> Types = new BitSet<TargetableType>("Air", "Ground", "Water");
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Common.Traits
} }
/// <summary>Evaluates a single actor according to the rules defined in this consideration</summary> /// <summary>Evaluates a single actor according to the rules defined in this consideration</summary>
public int GetAttractiveness(Actor a, Stance stance, Player firedBy) public int GetAttractiveness(Actor a, PlayerRelationship stance, Player firedBy)
{ {
if (stance != Against) if (stance != Against)
return 0; return 0;
@@ -174,7 +174,7 @@ namespace OpenRA.Mods.Common.Traits
return 0; return 0;
} }
public int GetAttractiveness(FrozenActor fa, Stance stance, Player firedBy) public int GetAttractiveness(FrozenActor fa, PlayerRelationship stance, Player firedBy)
{ {
if (stance != Against) if (stance != Against)
return 0; return 0;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
// HACK: We don't want D2k bots to repair all their buildings on placement // HACK: We don't want D2k bots to repair all their buildings on placement
// where half their HP is removed via neutral terrain damage. // where half their HP is removed via neutral terrain damage.
// TODO: Implement concrete placement for D2k bots and remove this hack. // TODO: Implement concrete placement for D2k bots and remove this hack.
if (e.Attacker.Owner.Stances[self.Owner] == Stance.Neutral) if (e.Attacker.Owner.Stances[self.Owner] == PlayerRelationship.Neutral)
return; return;
var rb = self.TraitOrDefault<RepairableBuilding>(); var rb = self.TraitOrDefault<RepairableBuilding>();

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool CheckCaptureTargetsForVisibility = true; public readonly bool CheckCaptureTargetsForVisibility = true;
[Desc("Player stances that capturers should attempt to target.")] [Desc("Player stances that capturers should attempt to target.")]
public readonly Stance CapturableStances = Stance.Enemy | Stance.Neutral; public readonly PlayerRelationship CapturableStances = PlayerRelationship.Enemy | PlayerRelationship.Neutral;
public override object Create(ActorInitializer init) { return new CaptureManagerBotModule(init.Self, this); } public override object Create(ActorInitializer init) { return new CaptureManagerBotModule(init.Self, this); }
} }
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
isEnemyUnit = unit => isEnemyUnit = unit =>
player.Stances[unit.Owner] == Stance.Enemy player.Stances[unit.Owner] == PlayerRelationship.Enemy
&& !unit.Info.HasTraitInfo<HuskInfo>() && !unit.Info.HasTraitInfo<HuskInfo>()
&& unit.Info.HasTraitInfo<ITargetableInfo>(); && unit.Info.HasTraitInfo<ITargetableInfo>();

View File

@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
var path = pathfinder.FindPath( var path = pathfinder.FindPath(
PathSearch.Search(world, harv.Locomotor, actor, BlockedByActor.Stationary, isValidResource) PathSearch.Search(world, harv.Locomotor, actor, BlockedByActor.Stationary, isValidResource)
.WithCustomCost(loc => world.FindActorsInCircle(world.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius) .WithCustomCost(loc => world.FindActorsInCircle(world.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
.Where(u => !u.IsDead && actor.Owner.Stances[u.Owner] == Stance.Enemy) .Where(u => !u.IsDead && actor.Owner.Stances[u.Owner] == PlayerRelationship.Enemy)
.Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (world.Map.CenterOfCell(loc) - u.CenterPosition).Length))) .Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (world.Map.CenterOfCell(loc) - u.CenterPosition).Length)))
.FromPoint(actor.Location)); .FromPoint(actor.Location));

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
// Use for proactive targeting. // Use for proactive targeting.
public bool IsPreferredEnemyUnit(Actor a) public bool IsPreferredEnemyUnit(Actor a)
{ {
if (a == null || a.IsDead || Player.Stances[a.Owner] != Stance.Enemy || a.Info.HasTraitInfo<HuskInfo>()) if (a == null || a.IsDead || Player.Stances[a.Owner] != PlayerRelationship.Enemy || a.Info.HasTraitInfo<HuskInfo>())
return false; return false;
var targetTypes = a.GetEnabledTargetTypes(); var targetTypes = a.GetEnabledTargetTypes();

View File

@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var bp in world.ActorsWithTrait<BaseProvider>()) foreach (var bp in world.ActorsWithTrait<BaseProvider>())
{ {
var validOwner = bp.Actor.Owner == p || (allyBuildEnabled && bp.Actor.Owner.Stances[p] == Stance.Ally); var validOwner = bp.Actor.Owner == p || (allyBuildEnabled && bp.Actor.Owner.Stances[p] == PlayerRelationship.Ally);
if (!validOwner || !bp.Trait.Ready()) if (!validOwner || !bp.Trait.Ready())
continue; continue;
@@ -217,7 +217,7 @@ namespace OpenRA.Mods.Common.Traits
if (!a.IsInWorld) if (!a.IsInWorld)
continue; continue;
if (a.Owner != p && (!allyBuildEnabled || a.Owner.Stances[p] != Stance.Ally)) if (a.Owner != p && (!allyBuildEnabled || a.Owner.Stances[p] != PlayerRelationship.Ally))
continue; continue;
if (ActorGrantsValidArea(a, requiresBuildableArea)) if (ActorGrantsValidArea(a, requiresBuildableArea))

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
: base(info) : base(info)
{ {
health = self.Trait<IHealth>(); health = self.Trait<IHealth>();
isNotActiveAlly = player => player.WinState != WinState.Undefined || player.Stances[self.Owner] != Stance.Ally; isNotActiveAlly = player => player.WinState != WinState.Undefined || player.Stances[self.Owner] != PlayerRelationship.Ally;
} }
[Sync] [Sync]

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly BitSet<CaptureType> Types = default(BitSet<CaptureType>); public readonly BitSet<CaptureType> Types = default(BitSet<CaptureType>);
[Desc("What diplomatic stances can be captured by this actor.")] [Desc("What diplomatic stances can be captured by this actor.")]
public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Cancel the actor's current activity when getting captured.")] [Desc("Cancel the actor's current activity when getting captured.")]
public readonly bool CancelActivity = false; public readonly bool CancelActivity = false;

View File

@@ -109,13 +109,13 @@ namespace OpenRA.Mods.Common.Traits
allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>); allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>);
foreach (var c in enabledCapturable) foreach (var c in enabledCapturable)
{ {
if (c.Info.ValidStances.HasStance(Stance.Ally)) if (c.Info.ValidStances.HasStance(PlayerRelationship.Ally))
allyCapturableTypes = allyCapturableTypes.Union(c.Info.Types); allyCapturableTypes = allyCapturableTypes.Union(c.Info.Types);
if (c.Info.ValidStances.HasStance(Stance.Neutral)) if (c.Info.ValidStances.HasStance(PlayerRelationship.Neutral))
neutralCapturableTypes = neutralCapturableTypes.Union(c.Info.Types); neutralCapturableTypes = neutralCapturableTypes.Union(c.Info.Types);
if (c.Info.ValidStances.HasStance(Stance.Enemy)) if (c.Info.ValidStances.HasStance(PlayerRelationship.Enemy))
enemyCapturableTypes = enemyCapturableTypes.Union(c.Info.Types); enemyCapturableTypes = enemyCapturableTypes.Union(c.Info.Types);
} }
} }
@@ -130,13 +130,13 @@ namespace OpenRA.Mods.Common.Traits
public bool CanBeTargetedBy(Actor self, Actor captor, CaptureManager captorManager) public bool CanBeTargetedBy(Actor self, Actor captor, CaptureManager captorManager)
{ {
var stance = self.Owner.Stances[captor.Owner]; var stance = self.Owner.Stances[captor.Owner];
if (stance.HasStance(Stance.Enemy)) if (stance.HasStance(PlayerRelationship.Enemy))
return captorManager.capturesTypes.Overlaps(enemyCapturableTypes); return captorManager.capturesTypes.Overlaps(enemyCapturableTypes);
if (stance.HasStance(Stance.Neutral)) if (stance.HasStance(PlayerRelationship.Neutral))
return captorManager.capturesTypes.Overlaps(neutralCapturableTypes); return captorManager.capturesTypes.Overlaps(neutralCapturableTypes);
if (stance.HasStance(Stance.Ally)) if (stance.HasStance(PlayerRelationship.Ally))
return captorManager.capturesTypes.Overlaps(allyCapturableTypes); return captorManager.capturesTypes.Overlaps(allyCapturableTypes);
return false; return false;
@@ -148,13 +148,13 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
var stance = self.Owner.Stances[captor.Owner]; var stance = self.Owner.Stances[captor.Owner];
if (stance.HasStance(Stance.Enemy)) if (stance.HasStance(PlayerRelationship.Enemy))
return captures.Info.CaptureTypes.Overlaps(enemyCapturableTypes); return captures.Info.CaptureTypes.Overlaps(enemyCapturableTypes);
if (stance.HasStance(Stance.Neutral)) if (stance.HasStance(PlayerRelationship.Neutral))
return captures.Info.CaptureTypes.Overlaps(neutralCapturableTypes); return captures.Info.CaptureTypes.Overlaps(neutralCapturableTypes);
if (stance.HasStance(Stance.Ally)) if (stance.HasStance(PlayerRelationship.Ally))
return captures.Info.CaptureTypes.Overlaps(allyCapturableTypes); return captures.Info.CaptureTypes.Overlaps(allyCapturableTypes);
return false; return false;

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int PlayerExperience = 0; public readonly int PlayerExperience = 0;
[Desc("Stance that the structure's previous owner needs to have for the capturing player to receive Experience.")] [Desc("Stance that the structure's previous owner needs to have for the capturing player to receive Experience.")]
public readonly Stance PlayerExperienceStances = Stance.Enemy; public readonly PlayerRelationship PlayerExperienceStances = PlayerRelationship.Enemy;
[Desc("Cursor to display when the health of the target actor is above the sabotage threshold.")] [Desc("Cursor to display when the health of the target actor is above the sabotage threshold.")]
public readonly string SabotageCursor = "capture"; public readonly string SabotageCursor = "capture";

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly WDist MaximumVerticalOffset = WDist.Zero; public readonly WDist MaximumVerticalOffset = WDist.Zero;
[Desc("What diplomatic stances are affected.")] [Desc("What diplomatic stances are affected.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("Condition is applied permanently to this actor.")] [Desc("Condition is applied permanently to this actor.")]
public readonly bool AffectsParent = false; public readonly bool AffectsParent = false;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
public class CreatesShroudInfo : AffectsShroudInfo public class CreatesShroudInfo : AffectsShroudInfo
{ {
[Desc("Stance the watching player needs to see the generated shroud.")] [Desc("Stance the watching player needs to see the generated shroud.")]
public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
public override object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); } public override object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); }
} }

View File

@@ -44,8 +44,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Voice string when planting explosive charges.")] [Desc("Voice string when planting explosive charges.")]
public readonly string Voice = "Action"; public readonly string Voice = "Action";
public readonly Stance TargetStances = Stance.Enemy | Stance.Neutral; public readonly PlayerRelationship TargetStances = PlayerRelationship.Enemy | PlayerRelationship.Neutral;
public readonly Stance ForceTargetStances = Stance.Enemy | Stance.Neutral | Stance.Ally; public readonly PlayerRelationship ForceTargetStances = PlayerRelationship.Enemy | PlayerRelationship.Neutral | PlayerRelationship.Ally;
[Desc("Cursor to display when hovering over a demolishable target.")] [Desc("Cursor to display when hovering over a demolishable target.")]
public readonly string Cursor = "c4"; public readonly string Cursor = "c4";

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Dispose; public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Dispose;
[Desc("What diplomatic stances allow target to be repaired by this actor.")] [Desc("What diplomatic stances allow target to be repaired by this actor.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("Sound to play when repairing is done.")] [Desc("Sound to play when repairing is done.")]
public readonly string RepairSound = null; public readonly string RepairSound = null;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Percentage = 10; public readonly int Percentage = 10;
[Desc("Stance the attacking player needs to receive the bounty.")] [Desc("Stance the attacking player needs to receive the bounty.")]
public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Whether to show a floating text announcing the won bounty.")] [Desc("Whether to show a floating text announcing the won bounty.")]
public readonly bool ShowBounty = true; public readonly bool ShowBounty = true;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Experience = -1; public readonly int Experience = -1;
[Desc("Stance the attacking player needs to receive the experience.")] [Desc("Stance the attacking player needs to receive the experience.")]
public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Percentage of the `Experience` value that is being granted to the killing actor.")] [Desc("Percentage of the `Experience` value that is being granted to the killing actor.")]
public readonly int ActorExperienceModifier = 10000; public readonly int ActorExperienceModifier = 10000;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly WDist Range = WDist.Zero; public readonly WDist Range = WDist.Zero;
[Desc("What diplomatic stances are affected.")] [Desc("What diplomatic stances are affected.")]
public readonly Stance DeflectionStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship DeflectionStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Chance of deflecting missiles.")] [Desc("Chance of deflecting missiles.")]
public readonly int Chance = 100; public readonly int Chance = 100;
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public class JamsMissiles : ConditionalTrait<JamsMissilesInfo> public class JamsMissiles : ConditionalTrait<JamsMissilesInfo>
{ {
public WDist Range { get { return IsTraitDisabled ? WDist.Zero : Info.Range; } } public WDist Range { get { return IsTraitDisabled ? WDist.Zero : Info.Range; } }
public Stance DeflectionStances { get { return Info.DeflectionStances; } } public PlayerRelationship DeflectionStances { get { return Info.DeflectionStances; } }
public int Chance { get { return Info.Chance; } } public int Chance { get { return Info.Chance; } }
public JamsMissiles(JamsMissilesInfo info) public JamsMissiles(JamsMissilesInfo info)

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public class FrozenUnderFogInfo : TraitInfo, Requires<BuildingInfo>, IDefaultVisibilityInfo public class FrozenUnderFogInfo : TraitInfo, Requires<BuildingInfo>, IDefaultVisibilityInfo
{ {
[Desc("Players with these stances can always see the actor.")] [Desc("Players with these stances can always see the actor.")]
public readonly Stance AlwaysVisibleStances = Stance.Ally; public readonly PlayerRelationship AlwaysVisibleStances = PlayerRelationship.Ally;
public override object Create(ActorInitializer init) { return new FrozenUnderFog(init, this); } public override object Create(ActorInitializer init) { return new FrozenUnderFog(init, this); }
} }

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
public class HiddenUnderShroudInfo : TraitInfo, IDefaultVisibilityInfo public class HiddenUnderShroudInfo : TraitInfo, IDefaultVisibilityInfo
{ {
[Desc("Players with these stances can always see the actor.")] [Desc("Players with these stances can always see the actor.")]
public readonly Stance AlwaysVisibleStances = Stance.Ally; public readonly PlayerRelationship AlwaysVisibleStances = PlayerRelationship.Ally;
[Desc("Possible values are CenterPosition (reveal when the center is visible) and ", [Desc("Possible values are CenterPosition (reveal when the center is visible) and ",
"Footprint (reveal when any footprint cell is visible).")] "Footprint (reveal when any footprint cell is visible).")]

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits.Radar
public readonly bool UseLocation = false; public readonly bool UseLocation = false;
[Desc("Player stances who can view this actor on radar.")] [Desc("Player stances who can view this actor on radar.")]
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
public override object Create(ActorInitializer init) { return new AppearsOnRadar(this); } public override object Create(ActorInitializer init) { return new AppearsOnRadar(this); }
} }

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits.Render
class CashTricklerBarInfo : TraitInfo, Requires<CashTricklerInfo> class CashTricklerBarInfo : TraitInfo, Requires<CashTricklerInfo>
{ {
[Desc("Defines to which players the bar is to be shown.")] [Desc("Defines to which players the bar is to be shown.")]
public readonly Stance DisplayStances = Stance.Ally; public readonly PlayerRelationship DisplayStances = PlayerRelationship.Ally;
public readonly Color Color = Color.Magenta; public readonly Color Color = Color.Magenta;

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits.Render
class SupportPowerChargeBarInfo : ConditionalTraitInfo class SupportPowerChargeBarInfo : ConditionalTraitInfo
{ {
[Desc("Defines to which players the bar is to be shown.")] [Desc("Defines to which players the bar is to be shown.")]
public readonly Stance DisplayStances = Stance.Ally; public readonly PlayerRelationship DisplayStances = PlayerRelationship.Ally;
public readonly Color Color = Color.Magenta; public readonly Color Color = Color.Magenta;

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly string Position = "TopLeft"; public readonly string Position = "TopLeft";
[Desc("Player stances who can view the decoration.")] [Desc("Player stances who can view the decoration.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("Should this be visible only when selected?")] [Desc("Should this be visible only when selected?")]
public readonly bool RequiresSelection = false; public readonly bool RequiresSelection = false;

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Stances of players which will be able to see the circle.", [Desc("Stances of players which will be able to see the circle.",
"Valid values are combinations of `None`, `Ally`, `Enemy` and `Neutral`.")] "Valid values are combinations of `None`, `Ally`, `Enemy` and `Neutral`.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("When to show the range circle. Valid values are `Always`, and `WhenSelected`")] [Desc("When to show the range circle. Valid values are `Always`, and `WhenSelected`")]
public readonly RangeCircleVisibility Visible = RangeCircleVisibility.WhenSelected; public readonly RangeCircleVisibility Visible = RangeCircleVisibility.WhenSelected;

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
public class RevealOnDeathInfo : ConditionalTraitInfo public class RevealOnDeathInfo : ConditionalTraitInfo
{ {
[Desc("Stances relative to the actors' owner that shroud will be revealed for.")] [Desc("Stances relative to the actors' owner that shroud will be revealed for.")]
public readonly Stance RevealForStances = Stance.Ally; public readonly PlayerRelationship RevealForStances = PlayerRelationship.Ally;
[Desc("Duration of the reveal.")] [Desc("Duration of the reveal.")]
public readonly int Duration = 25; public readonly int Duration = 25;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string[] ArmamentNames = { "primary", "secondary" }; public readonly string[] ArmamentNames = { "primary", "secondary" };
[Desc("Stances relative to the target player this actor will be revealed to during firing.")] [Desc("Stances relative to the target player this actor will be revealed to during firing.")]
public readonly Stance RevealForStancesRelativeToTarget = Stance.Ally; public readonly PlayerRelationship RevealForStancesRelativeToTarget = PlayerRelationship.Ally;
[Desc("Duration of the reveal.")] [Desc("Duration of the reveal.")]
public readonly int Duration = 25; public readonly int Duration = 25;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
public class RevealsMapInfo : ConditionalTraitInfo public class RevealsMapInfo : ConditionalTraitInfo
{ {
[Desc("Stance the watching player needs to see the shroud removed.")] [Desc("Stance the watching player needs to see the shroud removed.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("Can this actor reveal shroud generated by the `GeneratesShroud` trait?")] [Desc("Can this actor reveal shroud generated by the `GeneratesShroud` trait?")]
public readonly bool RevealGeneratedShroud = true; public readonly bool RevealGeneratedShroud = true;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
public class RevealsShroudInfo : AffectsShroudInfo public class RevealsShroudInfo : AffectsShroudInfo
{ {
[Desc("Stance the watching player needs to see the shroud removed.")] [Desc("Stance the watching player needs to see the shroud removed.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[Desc("Can this actor reveal shroud generated by the GeneratesShroud trait?")] [Desc("Can this actor reveal shroud generated by the GeneratesShroud trait?")]
public readonly bool RevealGeneratedShroud = true; public readonly bool RevealGeneratedShroud = true;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
public readonly string Voice = null; public readonly string Voice = null;
[Desc("Player stances who can hear this voice.")] [Desc("Player stances who can hear this voice.")]
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Play the voice to the owning player even if Stance.Ally is not included in ValidStances.")] [Desc("Play the voice to the owning player even if Stance.Ally is not included in ValidStances.")]
public readonly bool PlayToOwner = true; public readonly bool PlayToOwner = true;

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string OnFireSound = null; public readonly string OnFireSound = null;
[Desc("Player stances which condition can be applied to.")] [Desc("Player stances which condition can be applied to.")]
public readonly Stance ValidStances = Stance.Ally; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally;
[SequenceReference] [SequenceReference]
[Desc("Sequence to play for granting actor when activated.", [Desc("Sequence to play for granting actor when activated.",

View File

@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool RevealGeneratedShroud = true; public readonly bool RevealGeneratedShroud = true;
[Desc("Reveal cells to players with these stances only.")] [Desc("Reveal cells to players with these stances only.")]
public readonly Stance CameraStances = Stance.Ally; public readonly PlayerRelationship CameraStances = PlayerRelationship.Ally;
[Desc("Amount of time before detonation to spawn the camera.")] [Desc("Amount of time before detonation to spawn the camera.")]
public readonly int CameraSpawnAdvance = 25; public readonly int CameraSpawnAdvance = 25;

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string IncomingSpeechNotification = null; public readonly string IncomingSpeechNotification = null;
[Desc("Defines to which players the timer is shown.")] [Desc("Defines to which players the timer is shown.")]
public readonly Stance DisplayTimerStances = Stance.None; public readonly PlayerRelationship DisplayTimerStances = PlayerRelationship.None;
[Desc("Beacons are only supported on the Airstrike, Paratroopers, and Nuke powers")] [Desc("Beacons are only supported on the Airstrike, Paratroopers, and Nuke powers")]
public readonly bool DisplayBeacon = false; public readonly bool DisplayBeacon = false;

View File

@@ -49,25 +49,25 @@ namespace OpenRA.Mods.Common.Traits
public readonly string EnemyPrefix = "Enemy"; public readonly string EnemyPrefix = "Enemy";
[Desc("Player stances that the generic name should be shown to.")] [Desc("Player stances that the generic name should be shown to.")]
public readonly Stance GenericVisibility = Stance.None; public readonly PlayerRelationship GenericVisibility = PlayerRelationship.None;
[Desc("Show the actor's owner and their faction flag")] [Desc("Show the actor's owner and their faction flag")]
public readonly bool ShowOwnerRow = true; public readonly bool ShowOwnerRow = true;
public override object Create(ActorInitializer init) { return new Tooltip(init.Self, this); } public override object Create(ActorInitializer init) { return new Tooltip(init.Self, this); }
public string TooltipForPlayerStance(Stance stance) public string TooltipForPlayerStance(PlayerRelationship stance)
{ {
if (stance == Stance.None || !GenericVisibility.HasStance(stance)) if (stance == PlayerRelationship.None || !GenericVisibility.HasStance(stance))
return Name; return Name;
if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && stance == Stance.Ally) if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && stance == PlayerRelationship.Ally)
return AllyPrefix + " " + GenericName; return AllyPrefix + " " + GenericName;
if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && stance == Stance.Neutral) if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && stance == PlayerRelationship.Neutral)
return NeutralPrefix + " " + GenericName; return NeutralPrefix + " " + GenericName;
if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && stance == Stance.Enemy) if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && stance == PlayerRelationship.Enemy)
return EnemyPrefix + " " + GenericName; return EnemyPrefix + " " + GenericName;
return GenericName; return GenericName;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Description = ""; public readonly string Description = "";
[Desc("Player stances who can view the description.")] [Desc("Player stances who can view the description.")]
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
public override object Create(ActorInitializer init) { return new TooltipDescription(init.Self, this); } public override object Create(ActorInitializer init) { return new TooltipDescription(init.Self, this); }
} }

View File

@@ -136,19 +136,19 @@ namespace OpenRA.Mods.Common.Traits
p.Stances[q] = ChooseInitialStance(p, q); p.Stances[q] = ChooseInitialStance(p, q);
} }
static Stance ChooseInitialStance(Player p, Player q) static PlayerRelationship ChooseInitialStance(Player p, Player q)
{ {
if (p == q) if (p == q)
return Stance.Ally; return PlayerRelationship.Ally;
if (q.Spectating && !p.NonCombatant && p.Playable) if (q.Spectating && !p.NonCombatant && p.Playable)
return Stance.Ally; return PlayerRelationship.Ally;
// Stances set via PlayerReference // Stances set via PlayerReference
if (p.PlayerReference.Allies.Contains(q.InternalName)) if (p.PlayerReference.Allies.Contains(q.InternalName))
return Stance.Ally; return PlayerRelationship.Ally;
if (p.PlayerReference.Enemies.Contains(q.InternalName)) if (p.PlayerReference.Enemies.Contains(q.InternalName))
return Stance.Enemy; return PlayerRelationship.Enemy;
// HACK: Map players share a ClientID with the host, so would // HACK: Map players share a ClientID with the host, so would
// otherwise take the host's team stance instead of being neutral // otherwise take the host's team stance instead of being neutral
@@ -159,11 +159,11 @@ namespace OpenRA.Mods.Common.Traits
var qc = GetClientForPlayer(q); var qc = GetClientForPlayer(q);
if (pc != null && qc != null) if (pc != null && qc != null)
return pc.Team != 0 && pc.Team == qc.Team return pc.Team != 0 && pc.Team == qc.Team
? Stance.Ally : Stance.Enemy; ? PlayerRelationship.Ally : PlayerRelationship.Enemy;
} }
// Otherwise, default to neutral // Otherwise, default to neutral
return Stance.Neutral; return PlayerRelationship.Neutral;
} }
static Session.Client GetClientForPlayer(Player p) static Session.Client GetClientForPlayer(Player p)

View File

@@ -301,7 +301,7 @@ namespace OpenRA.Mods.Common.Traits
// If the check allows: We are not blocked by units that we can force to move out of the way. // If the check allows: We are not blocked by units that we can force to move out of the way.
if (check <= BlockedByActor.Immovable && cellFlag.HasCellFlag(CellFlag.HasMovableActor) && if (check <= BlockedByActor.Immovable && cellFlag.HasCellFlag(CellFlag.HasMovableActor) &&
actor.Owner.Stances[otherActor.Owner] == Stance.Ally) actor.Owner.Stances[otherActor.Owner] == PlayerRelationship.Ally)
{ {
var mobile = otherActor.OccupiesSpace as Mobile; var mobile = otherActor.OccupiesSpace as Mobile;
if (mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable) if (mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable)

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Warheads
public readonly BitSet<TargetableType> InvalidTargets; public readonly BitSet<TargetableType> InvalidTargets;
[Desc("What diplomatic stances are affected.")] [Desc("What diplomatic stances are affected.")]
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy; public readonly PlayerRelationship ValidStances = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Can this warhead affect the actor that fired it.")] [Desc("Can this warhead affect the actor that fired it.")]
public readonly bool AffectsParent = false; public readonly bool AffectsParent = false;

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var flag = item.Get<ImageWidget>("FACTIONFLAG"); var flag = item.Get<ImageWidget>("FACTIONFLAG");
flag.GetImageCollection = () => "flags"; flag.GetImageCollection = () => "flags";
if (player == null || player.Stances[pp] == Stance.Ally || player.WinState != WinState.Undefined) if (player == null || player.Stances[pp] == PlayerRelationship.Ally || player.WinState != WinState.Undefined)
{ {
flag.GetImageName = () => pp.Faction.InternalName; flag.GetImageName = () => pp.Faction.InternalName;
item.Get<LabelWidget>("FACTION").GetText = () => pp.Faction.Name; item.Get<LabelWidget>("FACTION").GetText = () => pp.Faction.Name;

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
o = viewport.ActorTooltip.Owner; o = viewport.ActorTooltip.Owner;
showOwner = o != null && !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible; showOwner = o != null && !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible;
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer]; var stance = o == null || world.RenderPlayer == null ? PlayerRelationship.None : o.Stances[world.RenderPlayer];
labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance); labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break; break;
} }
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
o = viewport.FrozenActorTooltip.TooltipOwner; o = viewport.FrozenActorTooltip.TooltipOwner;
showOwner = o != null && !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible; showOwner = o != null && !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible;
var stance = o == null || world.RenderPlayer == null ? Stance.None : o.Stances[world.RenderPlayer]; var stance = o == null || world.RenderPlayer == null ? PlayerRelationship.None : o.Stances[world.RenderPlayer];
labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance); labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
break; break;
} }

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Widgets
powers = world.ActorsWithTrait<SupportPowerManager>() powers = world.ActorsWithTrait<SupportPowerManager>()
.Where(p => !p.Actor.IsDead && !p.Actor.Owner.NonCombatant) .Where(p => !p.Actor.IsDead && !p.Actor.Owner.NonCombatant)
.SelectMany(s => s.Trait.Powers.Values) .SelectMany(s => s.Trait.Powers.Values)
.Where(p => p.Instances.Any() && p.Info.DisplayTimerStances != Stance.None && !p.Disabled); .Where(p => p.Instances.Any() && p.Info.DisplayTimerStances != PlayerRelationship.None && !p.Disabled);
// Timers in replays should be synced to the effective game time, not the playback time. // Timers in replays should be synced to the effective game time, not the playback time.
timestep = world.Timestep; timestep = world.Timestep;