Rewrite ChooseInitialStance to support bot teams and remove obsolete crap.
This commit is contained in:
@@ -46,37 +46,29 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
foreach (var p in w.Players)
|
foreach (var p in w.Players)
|
||||||
foreach (var q in w.Players)
|
foreach (var q in w.Players)
|
||||||
{
|
|
||||||
if (!p.Stances.ContainsKey(q))
|
if (!p.Stances.ContainsKey(q))
|
||||||
p.Stances[q] = ChooseInitialStance(p, q);
|
p.Stances[q] = ChooseInitialStance(p, q);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Stance ChooseInitialStance(Player p, Player q)
|
static Stance ChooseInitialStance(Player p, Player q)
|
||||||
{
|
{
|
||||||
if (p == q) return Stance.Ally;
|
if (p == q) return Stance.Ally;
|
||||||
var pc = GetClientForPlayer(p);
|
|
||||||
var qc = GetClientForPlayer(q);
|
|
||||||
|
|
||||||
if (p.World.LobbyInfo.Slots.Count > 0)
|
// Stances set via PlayerReference
|
||||||
{
|
|
||||||
if (p.PlayerRef == null) return Stance.Ally;
|
|
||||||
if (q.PlayerRef == null) return Stance.Ally;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stances set via the player reference
|
|
||||||
if (p.PlayerRef.Allies.Contains(q.InternalName))
|
if (p.PlayerRef.Allies.Contains(q.InternalName))
|
||||||
return Stance.Ally;
|
return Stance.Ally;
|
||||||
if (p.PlayerRef.Enemies.Contains(q.InternalName))
|
if (p.PlayerRef.Enemies.Contains(q.InternalName))
|
||||||
return Stance.Enemy;
|
return Stance.Enemy;
|
||||||
|
|
||||||
// Otherwise, default to neutral for map-players
|
|
||||||
if (!p.PlayerRef.Playable || !q.PlayerRef.Playable) return Stance.Neutral;
|
|
||||||
// or enemy for bot vs human
|
|
||||||
if (p.IsBot ^ q.IsBot) return Stance.Enemy;
|
|
||||||
|
|
||||||
return pc.Team != 0 && pc.Team == qc.Team
|
// Stances set via lobby teams
|
||||||
? Stance.Ally : Stance.Enemy;
|
var pc = GetClientForPlayer(p);
|
||||||
|
var qc = GetClientForPlayer(q);
|
||||||
|
if (pc != null && qc != null)
|
||||||
|
return pc.Team != 0 && pc.Team == qc.Team
|
||||||
|
? Stance.Ally : Stance.Enemy;
|
||||||
|
|
||||||
|
// Otherwise, default to neutral
|
||||||
|
return Stance.Neutral;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Session.Client GetClientForPlayer(Player p)
|
static Session.Client GetClientForPlayer(Player p)
|
||||||
|
|||||||
Reference in New Issue
Block a user