Remove obsolete Player index cruft
This commit is contained in:
@@ -128,7 +128,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
if( player != null )
|
if( player != null )
|
||||||
return player;
|
return player;
|
||||||
return world.players.Values.First( x => x.InternalName == PlayerName );
|
return world.Players.First( x => x.InternalName == PlayerName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ namespace OpenRA.Network
|
|||||||
/* todo: this is still a hack.
|
/* todo: this is still a hack.
|
||||||
* the cases we're trying to avoid are the extra players on the host's client -- Neutral, other MapPlayers,
|
* the cases we're trying to avoid are the extra players on the host's client -- Neutral, other MapPlayers,
|
||||||
* bots,.. */
|
* bots,.. */
|
||||||
return world.players.Values.FirstOrDefault(
|
return world.Players.FirstOrDefault(
|
||||||
p => p.ClientIndex == c.Index && p.PlayerName == c.Name);
|
p => (p.ClientIndex == c.Index && p.PlayerRef.Playable && !p.IsBot));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
|
public static void ProcessOrder(OrderManager orderManager, World world, int clientId, Order order)
|
||||||
@@ -151,8 +151,8 @@ namespace OpenRA.Network
|
|||||||
if (Game.orderManager.LobbyInfo.GlobalSettings.LockTeams)
|
if (Game.orderManager.LobbyInfo.GlobalSettings.LockTeams)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var targetPlayer = order.Player.World.players[order.TargetLocation.X];
|
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
|
||||||
var newStance = (Stance)order.TargetLocation.Y;
|
var newStance = (Stance)order.TargetLocation.X;
|
||||||
|
|
||||||
SetPlayerStance(world, order.Player, targetPlayer, newStance);
|
SetPlayerStance(world, order.Player, targetPlayer, newStance);
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace OpenRA
|
|||||||
public readonly string PlayerName;
|
public readonly string PlayerName;
|
||||||
public readonly string InternalName;
|
public readonly string InternalName;
|
||||||
public readonly CountryInfo Country;
|
public readonly CountryInfo Country;
|
||||||
public readonly int Index;
|
|
||||||
public readonly bool NonCombatant = false;
|
public readonly bool NonCombatant = false;
|
||||||
public readonly int ClientIndex;
|
public readonly int ClientIndex;
|
||||||
public readonly PlayerReference PlayerRef;
|
public readonly PlayerReference PlayerRef;
|
||||||
@@ -40,10 +39,9 @@ namespace OpenRA
|
|||||||
public Shroud Shroud { get { return World.LocalShroud; }}
|
public Shroud Shroud { get { return World.LocalShroud; }}
|
||||||
public World World { get; private set; }
|
public World World { get; private set; }
|
||||||
|
|
||||||
public Player(World world, Session.Client client, PlayerReference pr, int index)
|
public Player(World world, Session.Client client, PlayerReference pr)
|
||||||
{
|
{
|
||||||
World = world;
|
World = world;
|
||||||
Index = index;
|
|
||||||
InternalName = pr.Name;
|
InternalName = pr.Name;
|
||||||
PlayerRef = pr;
|
PlayerRef = pr;
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace OpenRA
|
|||||||
public static int hash_player( Player p )
|
public static int hash_player( Player p )
|
||||||
{
|
{
|
||||||
if( p != null )
|
if( p != null )
|
||||||
return p.Index * 0x567;
|
return (int)( p.PlayerActor.ActorID << 16 ) * 0x567;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
var anim = new Animation(RenderSimple.GetImage(building, Tileset), () => 0);
|
var anim = new Animation(RenderSimple.GetImage(building, Tileset), () => 0);
|
||||||
anim.PlayRepeating("idle");
|
anim.PlayRepeating("idle");
|
||||||
yield return new Renderable(anim.Image, 0.5f * anim.Image.size * (1 - Scale), Palette ?? PlayerPalette + owner.Index, 0, Scale);
|
yield return new Renderable(anim.Image, 0.5f * anim.Image.size * (1 - Scale), Palette ?? PlayerPalette + owner.InternalName, 0, Scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ namespace OpenRA.Traits
|
|||||||
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.Index; }
|
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.InternalName; }
|
||||||
|
|
||||||
public virtual IEnumerable<Renderable> Render(Actor self)
|
public virtual IEnumerable<Renderable> Render(Actor self)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void InitPalette( WorldRenderer wr )
|
public void InitPalette( WorldRenderer wr )
|
||||||
{
|
{
|
||||||
var paletteName = "{0}{1}".F( info.BaseName, owner.Index );
|
var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
|
||||||
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
||||||
new PlayerColorRemap(owner.ColorRamp, info.PaletteFormat));
|
new PlayerColorRemap(owner.ColorRamp, info.PaletteFormat));
|
||||||
wr.AddPalette(paletteName, newpal);
|
wr.AddPalette(paletteName, newpal);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Collections;
|
using OpenRA.Collections;
|
||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
@@ -35,21 +36,16 @@ namespace OpenRA
|
|||||||
|
|
||||||
public XRandom SharedRandom;
|
public XRandom SharedRandom;
|
||||||
|
|
||||||
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
|
public readonly List<Player> Players = new List<Player>();
|
||||||
|
|
||||||
public void AddPlayer(Player p) { players[p.Index] = p; }
|
public void AddPlayer(Player p) { Players.Add(p); }
|
||||||
|
public Player LocalPlayer { get; private set; }
|
||||||
int localPlayerIndex = -999;
|
|
||||||
public Player LocalPlayer
|
|
||||||
{
|
|
||||||
get { return players.ContainsKey(localPlayerIndex) ? players[localPlayerIndex] : null; }
|
|
||||||
}
|
|
||||||
public readonly Shroud LocalShroud;
|
public readonly Shroud LocalShroud;
|
||||||
|
|
||||||
public void SetLocalPlayer(int index)
|
public void SetLocalPlayer(string pr)
|
||||||
{
|
{
|
||||||
if (!(orderManager.Connection is ReplayConnection))
|
if (!(orderManager.Connection is ReplayConnection))
|
||||||
localPlayerIndex = index;
|
LocalPlayer = Players.FirstOrDefault(p => p.InternalName == pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Actor WorldActor;
|
public readonly Actor WorldActor;
|
||||||
@@ -108,8 +104,8 @@ namespace OpenRA
|
|||||||
cmp.CreatePlayers(this);
|
cmp.CreatePlayers(this);
|
||||||
|
|
||||||
// Set defaults for any unset stances
|
// Set defaults for any unset stances
|
||||||
foreach (var p in players.Values)
|
foreach (var p in Players)
|
||||||
foreach (var q in players.Values)
|
foreach (var q in Players)
|
||||||
if (!p.Stances.ContainsKey(q))
|
if (!p.Stances.ContainsKey(q))
|
||||||
p.Stances[q] = Stance.Neutral;
|
p.Stances[q] = Stance.Neutral;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
{
|
{
|
||||||
Players = w.players.Values.ToDictionary(p => p.InternalName);
|
Players = w.Players.ToDictionary(p => p.InternalName);
|
||||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||||
var b = w.Map.Bounds;
|
var b = w.Map.Bounds;
|
||||||
Game.MoveViewport(new int2(b.Left + b.Width/2, b.Top + b.Height/2));
|
Game.MoveViewport(new int2(b.Left + b.Width/2, b.Top + b.Height/2));
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
var td = new TypeDictionary
|
var td = new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit( self.Location ),
|
new LocationInit( self.Location ),
|
||||||
new OwnerInit( self.World.players.Values.First(p => p.InternalName == Info.Owner) )
|
new OwnerInit( self.World.Players.First(p => p.InternalName == Info.Owner) )
|
||||||
};
|
};
|
||||||
|
|
||||||
if (self.HasTrait<IFacing>())
|
if (self.HasTrait<IFacing>())
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var itemTemplate = scrollpanel.GetWidget("PLAYER_TEMPLATE");
|
var itemTemplate = scrollpanel.GetWidget("PLAYER_TEMPLATE");
|
||||||
scrollpanel.RemoveChildren();
|
scrollpanel.RemoveChildren();
|
||||||
|
|
||||||
foreach (var p in world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant))
|
foreach (var p in world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant))
|
||||||
{
|
{
|
||||||
Player pp = p;
|
Player pp = p;
|
||||||
var item = itemTemplate.Clone();
|
var item = itemTemplate.Clone();
|
||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(template,
|
var item = ScrollItemWidget.Setup(template,
|
||||||
() => s == world.LocalPlayer.Stances[ pp ],
|
() => s == world.LocalPlayer.Stances[ pp ],
|
||||||
() => world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor, false)
|
() => world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor, false)
|
||||||
{ TargetLocation = new int2(pp.Index, (int)s) }));
|
{ TargetLocation = new int2((int)s, 0), TargetString = pp.InternalName }));
|
||||||
|
|
||||||
item.GetWidget<LabelWidget>("LABEL").GetText = () => s.ToString();
|
item.GetWidget<LabelWidget>("LABEL").GetText = () => s.ToString();
|
||||||
return item;
|
return item;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
|
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
|
||||||
|
|
||||||
var diplomacyButton = ingameRoot.GetWidget<ButtonWidget>("DIPLOMACY_BUTTON");
|
var diplomacyButton = ingameRoot.GetWidget<ButtonWidget>("DIPLOMACY_BUTTON");
|
||||||
var diplomacyAvailable = world.players.Values.Any(a => a != world.LocalPlayer && !a.NonCombatant);
|
var diplomacyAvailable = world.Players.Any(a => a != world.LocalPlayer && !a.NonCombatant);
|
||||||
diplomacyButton.IsDisabled = () => !diplomacyAvailable;
|
diplomacyButton.IsDisabled = () => !diplomacyAvailable;
|
||||||
diplomacyButton.OnClick = () =>
|
diplomacyButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!hasAnything && !self.Owner.NonCombatant)
|
if (!hasAnything && !self.Owner.NonCombatant)
|
||||||
Lose(self);
|
Lose(self);
|
||||||
|
|
||||||
var others = self.World.players.Where( p => !p.Value.NonCombatant
|
var others = self.World.Players.Where( p => !p.NonCombatant
|
||||||
&& p.Value != self.Owner && p.Value.Stances[self.Owner] != Stance.Ally );
|
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally );
|
||||||
|
|
||||||
if (others.Count() == 0) return;
|
if (others.Count() == 0) return;
|
||||||
|
|
||||||
if(others.All(p => p.Value.WinState == WinState.Lost))
|
if(others.All(p => p.WinState == WinState.Lost))
|
||||||
Win(self);
|
Win(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,10 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public void CreatePlayers(World w)
|
public void CreatePlayers(World w)
|
||||||
{
|
{
|
||||||
var playerIndex = 0;
|
|
||||||
var mapPlayerIndex = -1; // todo: unhack this, but people still rely on it.
|
|
||||||
|
|
||||||
// create the unplayable map players -- neutral, shellmap, scripted, etc.
|
// create the unplayable map players -- neutral, shellmap, scripted, etc.
|
||||||
foreach (var kv in w.Map.Players.Where(p => !p.Value.Playable))
|
foreach (var kv in w.Map.Players.Where(p => !p.Value.Playable))
|
||||||
{
|
{
|
||||||
var player = new Player(w, null, kv.Value, mapPlayerIndex--);
|
var player = new Player(w, null, kv.Value);
|
||||||
w.AddPlayer(player);
|
w.AddPlayer(player);
|
||||||
if (kv.Value.OwnsWorld)
|
if (kv.Value.OwnsWorld)
|
||||||
w.WorldActor.Owner = player;
|
w.WorldActor.Owner = player;
|
||||||
@@ -40,10 +37,10 @@ namespace OpenRA.Mods.RA
|
|||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
/* spawn a real player in this slot. */
|
/* spawn a real player in this slot. */
|
||||||
var player = new Player(w, client, w.Map.Players[slot.MapPlayer], playerIndex++);
|
var player = new Player(w, client, w.Map.Players[slot.MapPlayer]);
|
||||||
w.AddPlayer(player);
|
w.AddPlayer(player);
|
||||||
if (client.Index == Game.LocalClientId)
|
if (client.Index == Game.LocalClientId)
|
||||||
w.SetLocalPlayer(player.Index); // bind this one to the local player.
|
w.SetLocalPlayer(player.InternalName); // bind this one to the local player.
|
||||||
}
|
}
|
||||||
// TODO: This is shit. Merge it up into Player ctor?
|
// TODO: This is shit. Merge it up into Player ctor?
|
||||||
else if (slot.Bot != null && slot.MapPlayer != null)
|
else if (slot.Bot != null && slot.MapPlayer != null)
|
||||||
@@ -55,8 +52,7 @@ namespace OpenRA.Mods.RA
|
|||||||
w.Map.Players[slot.MapPlayer].ColorRamp = new ColorRamp(hue, 255, 180, 25);
|
w.Map.Players[slot.MapPlayer].ColorRamp = new ColorRamp(hue, 255, 180, 25);
|
||||||
|
|
||||||
/* todo: pick a random name from the pool */
|
/* todo: pick a random name from the pool */
|
||||||
|
var player = new Player(w, null, w.Map.Players[slot.MapPlayer]);
|
||||||
var player = new Player(w, null, w.Map.Players[slot.MapPlayer], playerIndex++);
|
|
||||||
w.AddPlayer(player);
|
w.AddPlayer(player);
|
||||||
|
|
||||||
/* activate the bot option that's selected! */
|
/* activate the bot option that's selected! */
|
||||||
@@ -70,8 +66,8 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var p in w.players.Values)
|
foreach (var p in w.Players)
|
||||||
foreach (var q in w.players.Values)
|
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);
|
||||||
@@ -90,17 +86,16 @@ namespace OpenRA.Mods.RA
|
|||||||
if (p.World.LobbyInfo.Slots[qc.Slot].Spectator) return Stance.Ally;
|
if (p.World.LobbyInfo.Slots[qc.Slot].Spectator) 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;
|
||||||
|
|
||||||
// Hack: All map players are neutral wrt everyone else
|
// Otherwise, default to neutral for map-players
|
||||||
if (p.Index < 0 || q.Index < 0) return Stance.Neutral;
|
if (!p.PlayerRef.Playable || !q.PlayerRef.Playable) return Stance.Neutral;
|
||||||
|
// or enemy for bot vs human
|
||||||
if (p.IsBot ^ q.IsBot)
|
if (p.IsBot ^ q.IsBot) return Stance.Enemy;
|
||||||
return Stance.Enemy; // bots and humans hate each other
|
|
||||||
|
|
||||||
|
|
||||||
return pc.Team != 0 && pc.Team == qc.Team
|
return pc.Team != 0 && pc.Team == qc.Team
|
||||||
? Stance.Ally : Stance.Enemy;
|
? Stance.Ally : Stance.Enemy;
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
bool HasHumanPlayers()
|
bool HasHumanPlayers()
|
||||||
{
|
{
|
||||||
return p.World.players.Any(a => !a.Value.IsBot && !a.Value.NonCombatant);
|
return p.World.Players.Any(a => !a.IsBot && !a.NonCombatant);
|
||||||
}
|
}
|
||||||
|
|
||||||
int2? ChooseEnemyTarget()
|
int2? ChooseEnemyTarget()
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ namespace OpenRA.Mods.RA
|
|||||||
continue; // Skip spectator slots
|
continue; // Skip spectator slots
|
||||||
var client = world.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index);
|
var client = world.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index);
|
||||||
var player = FindPlayerInSlot(world, slot);
|
var player = FindPlayerInSlot(world, slot);
|
||||||
|
|
||||||
if (player == null) continue;
|
if (player == null) continue;
|
||||||
|
|
||||||
var spid = (client == null || client.SpawnPoint == 0)
|
var spid = (client == null || client.SpawnPoint == 0)
|
||||||
@@ -62,7 +61,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
static Player FindPlayerInSlot(World world, Session.Slot slot)
|
static Player FindPlayerInSlot(World world, Session.Slot slot)
|
||||||
{
|
{
|
||||||
return world.players.Values.FirstOrDefault(p => p.PlayerRef.Name == slot.MapPlayer);
|
return world.Players.FirstOrDefault(p => p.PlayerRef.Name == slot.MapPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int2 ChooseSpawnPoint(World world, List<int2> available, List<int2> taken)
|
static int2 ChooseSpawnPoint(World world, List<int2> available, List<int2> taken)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (client.State == Session.ClientState.Disconnected)
|
if (client.State == Session.ClientState.Disconnected)
|
||||||
{
|
{
|
||||||
Disconnected = true; /* dont call this multiple times! */
|
Disconnected = true; /* dont call this multiple times! */
|
||||||
self.World.players.Do(pl => pl.Value.PlayerActor.TraitsImplementing<IResolveOrder>().Do(t => t.ResolveOrder(pl.Value.PlayerActor, new Order("Surrender", self, false))));
|
self.World.Players.Do(pl => pl.PlayerActor.TraitsImplementing<IResolveOrder>().Do(t => t.ResolveOrder(pl.PlayerActor, new Order("Surrender", self, false))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
// if there is no real player associated, dont spawn it.
|
// if there is no real player associated, dont spawn it.
|
||||||
var ownerName = actorReference.Value.InitDict.Get<OwnerInit>().PlayerName;
|
var ownerName = actorReference.Value.InitDict.Get<OwnerInit>().PlayerName;
|
||||||
if (!world.players.Values.Any(p => p.InternalName == ownerName))
|
if (!world.Players.Any(p => p.InternalName == ownerName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var initDict = actorReference.Value.InitDict;
|
var initDict = actorReference.Value.InitDict;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
foreach (var p in Self.World.players.Select(k => k.Value))
|
foreach (var p in Self.World.Players)
|
||||||
{
|
{
|
||||||
if (p == Self.Owner || (p.Stances[Self.Owner] == Stance.Ally && Self.Owner.Stances[p] == Stance.Ally))
|
if (p == Self.Owner || (p.Stances[Self.Owner] == Stance.Ally && Self.Owner.Stances[p] == Stance.Ally))
|
||||||
{
|
{
|
||||||
@@ -195,7 +195,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public void Won()
|
public void Won()
|
||||||
{
|
{
|
||||||
// Player has won
|
// Player has won
|
||||||
foreach (var p in Self.World.players.Select(k => k.Value))
|
foreach (var p in Self.World.Players)
|
||||||
{
|
{
|
||||||
var cvc = p.PlayerActor.TraitOrDefault<ConquestVictoryConditions>();
|
var cvc = p.PlayerActor.TraitOrDefault<ConquestVictoryConditions>();
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
validPlayers = world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
||||||
diplomacy.IsVisible = () => (validPlayers > 0);
|
diplomacy.IsVisible = () => (validPlayers > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,13 +79,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
y += 35;
|
y += 35;
|
||||||
|
|
||||||
foreach (var p in world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant))
|
foreach (var p in world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant))
|
||||||
{
|
{
|
||||||
var pp = p;
|
var pp = p;
|
||||||
var label = new LabelWidget
|
var label = new LabelWidget
|
||||||
{
|
{
|
||||||
Bounds = new Rectangle(margin, y, labelWidth, 25),
|
Bounds = new Rectangle(margin, y, labelWidth, 25),
|
||||||
Id = "DIPLOMACY_PLAYER_LABEL_{0}".F(p.Index),
|
|
||||||
Text = p.PlayerName,
|
Text = p.PlayerName,
|
||||||
Align = LabelWidget.TextAlign.Left,
|
Align = LabelWidget.TextAlign.Left,
|
||||||
Font = "Bold",
|
Font = "Bold",
|
||||||
@@ -97,7 +96,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var theirStance = new LabelWidget
|
var theirStance = new LabelWidget
|
||||||
{
|
{
|
||||||
Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
|
Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
|
||||||
Id = "DIPLOMACY_PLAYER_LABEL_THEIR_{0}".F(p.Index),
|
|
||||||
Text = p.PlayerName,
|
Text = p.PlayerName,
|
||||||
Align = LabelWidget.TextAlign.Left,
|
Align = LabelWidget.TextAlign.Left,
|
||||||
|
|
||||||
@@ -110,7 +108,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var myStance = new DropDownButtonWidget
|
var myStance = new DropDownButtonWidget
|
||||||
{
|
{
|
||||||
Bounds = new Rectangle( margin + 2 * labelWidth + 20, y, labelWidth, 25),
|
Bounds = new Rectangle( margin + 2 * labelWidth + 20, y, labelWidth, 25),
|
||||||
Id = "DIPLOMACY_PLAYER_LABEL_MY_{0}".F(p.Index),
|
|
||||||
GetText = () => world.LocalPlayer.Stances[ pp ].ToString(),
|
GetText = () => world.LocalPlayer.Stances[ pp ].ToString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,7 +142,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
return; // team changes are banned
|
return; // team changes are banned
|
||||||
|
|
||||||
world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor,
|
world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor,
|
||||||
false) { TargetLocation = new int2(p.Index, (int)ss) });
|
false) { TargetLocation = new int2((int)ss, 0), TargetString = p.InternalName });
|
||||||
|
|
||||||
bw.Text = ss.ToString();
|
bw.Text = ss.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
if (!IsVisible()) return;
|
if (!IsVisible()) return;
|
||||||
int2 offset = int2.Zero;
|
int2 offset = int2.Zero;
|
||||||
|
|
||||||
var svc = world.players.Select(p => p.Value.PlayerActor.TraitOrDefault<StrategicVictoryConditions>()).FirstOrDefault();
|
var svc = world.Players.Select(p => p.PlayerActor.TraitOrDefault<StrategicVictoryConditions>()).FirstOrDefault();
|
||||||
|
|
||||||
var totalWidth = (svc.Total + svc.TotalCritical) * 32;
|
var totalWidth = (svc.Total + svc.TotalCritical) * 32;
|
||||||
int curX = -(totalWidth / 2);
|
int curX = -(totalWidth / 2);
|
||||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
int shortest = int.MaxValue;
|
int shortest = int.MaxValue;
|
||||||
Player shortestPlayer = null;
|
Player shortestPlayer = null;
|
||||||
|
|
||||||
foreach (var p in world.players.Select(p => p.Value).Where(p => !p.NonCombatant))
|
foreach (var p in world.Players.Where(p => !p.NonCombatant))
|
||||||
{
|
{
|
||||||
var svc = p.PlayerActor.Trait<StrategicVictoryConditions>();
|
var svc = p.PlayerActor.Trait<StrategicVictoryConditions>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user