Change DisabledSpawnPoints from List to HashSet
This commit is contained in:
@@ -35,7 +35,7 @@ namespace OpenRA
|
|||||||
/// <summary>Gets the game's duration, from the time the game started until the replay recording stopped.</summary>
|
/// <summary>Gets the game's duration, from the time the game started until the replay recording stopped.</summary>
|
||||||
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
|
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
|
||||||
public IList<Player> Players { get; private set; }
|
public IList<Player> Players { get; private set; }
|
||||||
public List<int> DisabledSpawnPoints = new List<int>();
|
public HashSet<int> DisabledSpawnPoints = new HashSet<int>();
|
||||||
public MapPreview MapPreview { get { return Game.ModData.MapCache[MapUid]; } }
|
public MapPreview MapPreview { get { return Game.ModData.MapCache[MapUid]; } }
|
||||||
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
|
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
|
||||||
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
|
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Network
|
|||||||
// Keyed by the PlayerReference id that the slot corresponds to
|
// Keyed by the PlayerReference id that the slot corresponds to
|
||||||
public Dictionary<string, Slot> Slots = new Dictionary<string, Slot>();
|
public Dictionary<string, Slot> Slots = new Dictionary<string, Slot>();
|
||||||
|
|
||||||
public List<int> DisabledSpawnPoints = new List<int>();
|
public HashSet<int> DisabledSpawnPoints = new HashSet<int>();
|
||||||
|
|
||||||
public Global GlobalSettings = new Global();
|
public Global GlobalSettings = new Global();
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ namespace OpenRA.Network
|
|||||||
session.Slots.Add(s.PlayerReference, s);
|
session.Slots.Add(s.PlayerReference, s);
|
||||||
break;
|
break;
|
||||||
case "DisabledSpawnPoints":
|
case "DisabledSpawnPoints":
|
||||||
session.DisabledSpawnPoints = FieldLoader.GetValue<List<int>>("DisabledSpawnPoints", node.Value.Value);
|
session.DisabledSpawnPoints = FieldLoader.GetValue<HashSet<int>>("DisabledSpawnPoints", node.Value.Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi))
|
LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi))
|
||||||
},
|
},
|
||||||
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants) },
|
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants) },
|
||||||
{ "getDisabledSpawnPoints", (Func<List<int>>)(() => orderManager.LobbyInfo.DisabledSpawnPoints) },
|
{ "getDisabledSpawnPoints", (Func<HashSet<int>>)(() => orderManager.LobbyInfo.DisabledSpawnPoints) },
|
||||||
{ "showUnoccupiedSpawnpoints", true },
|
{ "showUnoccupiedSpawnpoints", true },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
internal MapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, Func<MapPreview> getMap, Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown,
|
internal MapPreviewLogic(Widget widget, ModData modData, OrderManager orderManager, Func<MapPreview> getMap, Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown,
|
||||||
Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants, Func<List<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
|
Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants, Func<HashSet<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
|
||||||
{
|
{
|
||||||
var mapRepository = modData.Manifest.Get<WebServices>().MapRepository;
|
var mapRepository = modData.Manifest.Get<WebServices>().MapRepository;
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetupWidgets(Widget parent, Func<MapPreview> getMap,
|
void SetupWidgets(Widget parent, Func<MapPreview> getMap,
|
||||||
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants, Func<List<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
|
Action<MapPreviewWidget, MapPreview, MouseInput> onMouseDown, Func<Dictionary<int, SpawnOccupant>> getSpawnOccupants, Func<HashSet<int>> getDisabledSpawnPoints, bool showUnoccupiedSpawnpoints)
|
||||||
{
|
{
|
||||||
var preview = parent.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var preview = parent.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
preview.Preview = () => getMap();
|
preview.Preview = () => getMap();
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return occupants;
|
return occupants;
|
||||||
});
|
});
|
||||||
|
|
||||||
var noSpawns = new List<int>();
|
var noSpawns = new HashSet<int>();
|
||||||
var disabledSpawnPoints = new CachedTransform<ReplayMetadata, List<int>>(r => r.GameInfo.DisabledSpawnPoints ?? noSpawns);
|
var disabledSpawnPoints = new CachedTransform<ReplayMetadata, HashSet<int>>(r => r.GameInfo.DisabledSpawnPoints ?? noSpawns);
|
||||||
|
|
||||||
Ui.LoadWidget("MAP_PREVIEW", mapPreviewRoot, new WidgetArgs
|
Ui.LoadWidget("MAP_PREVIEW", mapPreviewRoot, new WidgetArgs
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "getMap", (Func<MapPreview>)(() => map) },
|
{ "getMap", (Func<MapPreview>)(() => map) },
|
||||||
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => { }) },
|
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => { }) },
|
||||||
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants.Update(selectedReplay)) },
|
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants.Update(selectedReplay)) },
|
||||||
{ "getDisabledSpawnPoints", (Func<List<int>>)(() => disabledSpawnPoints.Update(selectedReplay)) },
|
{ "getDisabledSpawnPoints", (Func<HashSet<int>>)(() => disabledSpawnPoints.Update(selectedReplay)) },
|
||||||
{ "showUnoccupiedSpawnpoints", false },
|
{ "showUnoccupiedSpawnpoints", false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user