Remove the Stances dictionary

This commit is contained in:
abcdefg30
2020-09-26 16:49:10 +02:00
committed by Paul Chote
parent 718cf37146
commit ea3c7a3c34
3 changed files with 26 additions and 55 deletions

View File

@@ -132,23 +132,25 @@ namespace OpenRA.Mods.Common.Traits
foreach (var p in w.Players)
foreach (var q in w.Players)
if (!p.Stances.ContainsKey(q))
p.Stances[q] = ChooseInitialStance(p, q);
SetupPlayerMasks(p, q);
}
static PlayerRelationship ChooseInitialStance(Player p, Player q)
static void SetupPlayerMasks(Player p, Player q)
{
if (p == q)
return PlayerRelationship.Ally;
if (!p.Spectating)
p.World.AllPlayersMask = p.World.AllPlayersMask.Union(p.PlayerMask);
if (q.Spectating && !p.NonCombatant && p.Playable)
return PlayerRelationship.Ally;
if (p == q || p.PlayerReference.Allies.Contains(q.InternalName))
{
p.AlliedPlayersMask = p.AlliedPlayersMask.Union(q.PlayerMask);
return;
}
// Stances set via PlayerReference
if (p.PlayerReference.Allies.Contains(q.InternalName))
return PlayerRelationship.Ally;
if (p.PlayerReference.Enemies.Contains(q.InternalName))
return PlayerRelationship.Enemy;
{
p.EnemyPlayersMask = p.EnemyPlayersMask.Union(q.PlayerMask);
return;
}
// HACK: Map players share a ClientID with the host, so would
// otherwise take the host's team stance instead of being neutral
@@ -158,12 +160,13 @@ namespace OpenRA.Mods.Common.Traits
var pc = GetClientForPlayer(p);
var qc = GetClientForPlayer(q);
if (pc != null && qc != null)
return pc.Team != 0 && pc.Team == qc.Team
? PlayerRelationship.Ally : PlayerRelationship.Enemy;
{
if (pc.Team != 0 && pc.Team == qc.Team)
p.AlliedPlayersMask = p.AlliedPlayersMask.Union(q.PlayerMask);
else
p.EnemyPlayersMask = p.EnemyPlayersMask.Union(q.PlayerMask);
}
}
// Otherwise, default to neutral
return PlayerRelationship.Neutral;
}
static Session.Client GetClientForPlayer(Player p)