add a spectator player that shares shroud with everyone

closes #4607
This commit is contained in:
Matthias Mailänder
2014-03-08 06:57:56 +01:00
parent 1f18374733
commit fbf408b886
6 changed files with 31 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ NEW:
Removed the ability of commandos to plant C4 on walls.
Order lines are now shown on unit selection.
Fixed chat synchronization in replays.
Added a combined shroud view of every player to the replay viewer and spectator mode.
Fixed the game sometimes crashing when deploying and activating the guard cursor at the same time.
Build time is now set when an item reaches the front of a queue, instead of immediately when queued.
The attack cursor now changes if the target is out of range.

View File

@@ -17,6 +17,7 @@ namespace OpenRA.FileFormats
public bool OwnsWorld = false;
public bool NonCombatant = false;
public bool Playable = false;
public bool Spectating = false;
public string Bot = null;
public string StartingUnitsClass = null;
public bool AllowBots = true;

View File

@@ -30,6 +30,8 @@ namespace OpenRA
public readonly string InternalName;
public readonly CountryInfo Country;
public readonly bool NonCombatant = false;
public readonly bool Spectating = false;
public readonly bool Playable = true;
public readonly int ClientIndex;
public readonly PlayerReference PlayerReference;
public bool IsBot;
@@ -70,6 +72,8 @@ namespace OpenRA
Color = pr.Color;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
Playable = pr.Playable;
Spectating = pr.Spectating;
botType = pr.Bot;
Country = ChooseCountry(world, pr.Race);
}

View File

@@ -36,13 +36,13 @@ namespace OpenRA.Mods.RA
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
.Any( a => a.Actor.Owner == self.Owner );
.Any(a => a.Actor.Owner == self.Owner);
if (!hasAnything && !self.Owner.NonCombatant)
Lose(self);
var others = self.World.Players.Where( p => !p.NonCombatant
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally );
var others = self.World.Players.Where(p => !p.NonCombatant
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally);
if (!others.Any()) return;

View File

@@ -9,6 +9,7 @@
#endregion
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Network;
using OpenRA.Traits;
@@ -43,6 +44,15 @@ namespace OpenRA.Mods.RA
w.SetLocalPlayer(player.InternalName);
}
// create a player that is allied with everyone for shared observer shroud
w.AddPlayer(new Player(w, null, null, new PlayerReference
{
Name = "Everyone",
NonCombatant = true,
Spectating = true,
Allies = w.Players.Where(p => !p.NonCombatant && p.Playable).Select(p => p.InternalName).ToArray()
}));
foreach (var p in w.Players)
foreach (var q in w.Players)
if (!p.Stances.ContainsKey(q))
@@ -51,7 +61,11 @@ namespace OpenRA.Mods.RA
static Stance ChooseInitialStance(Player p, Player q)
{
if (p == q) return Stance.Ally;
if (p == q)
return Stance.Ally;
if (q.Spectating && !p.NonCombatant && p.Playable)
return Stance.Ally;
// Stances set via PlayerReference
if (p.PlayerReference.Allies.Contains(q.InternalName))

View File

@@ -32,17 +32,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic
static string LabelForPlayer(Player p)
{
return p != null ? "{0}'s view".F(p.PlayerName) : "World view";
return p != null ? p.PlayerName == "Everyone" ? "Combined view" : "{0}'s view".F(p.PlayerName) : "World view";
}
[ObjectCreator.UseCtor]
public ObserverShroudSelectorLogic(Widget widget, World world)
{
var views = world.Players.Where(p => !p.NonCombatant).Concat(new[] { (Player)null }).Select(
p => new CameraOption(LabelForPlayer(p),
() => world.RenderPlayer == p,
() => world.RenderPlayer = p
)).ToArray();
var views = world.Players.Where(p => (p.NonCombatant && p.Spectating)
|| !p.NonCombatant).Concat(new[] { (Player)null }).Select(
p => new CameraOption(LabelForPlayer(p),
() => world.RenderPlayer == p,
() => world.RenderPlayer = p
)).ToArray();
var shroudSelector = widget.Get<DropDownButtonWidget>("SHROUD_SELECTOR");
shroudSelector.GetText = () => LabelForPlayer(world.RenderPlayer);