@@ -68,7 +68,22 @@ public sealed class GameMapManager : IGameMapManager
|
||||
|
||||
public IEnumerable<GameMapPrototype> AllVotableMaps()
|
||||
{
|
||||
return _prototypeManager.EnumeratePrototypes<GameMapPrototype>().Where(x => x.Votable);
|
||||
if (_prototypeManager.TryIndex<GameMapPoolPrototype>(_configurationManager.GetCVar(CCVars.GameMapPool), out var pool))
|
||||
{
|
||||
foreach (var map in pool.Maps)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex<GameMapPrototype>(map, out var mapProto))
|
||||
{
|
||||
Logger.Error("Couldn't index map " + map + " in pool " + pool.ID);
|
||||
continue;
|
||||
}
|
||||
|
||||
yield return mapProto;
|
||||
}
|
||||
} else
|
||||
{
|
||||
throw new Exception("Could not index map pool prototype " + _configurationManager.GetCVar(CCVars.GameMapPool) + "!");
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<GameMapPrototype> AllMaps()
|
||||
@@ -170,7 +185,6 @@ public sealed class GameMapManager : IGameMapManager
|
||||
{
|
||||
Logger.InfoS("mapsel", string.Join(", ", _previousMaps));
|
||||
var eligible = CurrentlyEligibleMaps()
|
||||
.Where(x => x.Votable)
|
||||
.Select(x => (proto: x, weight: GetMapQueuePriority(x.ID)))
|
||||
.OrderByDescending(x => x.weight).ToArray();
|
||||
Logger.InfoS("mapsel", string.Join(", ", eligible.Select(x => (x.proto.ID, x.weight))));
|
||||
|
||||
22
Content.Server/Maps/GameMapPoolPrototype.cs
Normal file
22
Content.Server/Maps/GameMapPoolPrototype.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Maps;
|
||||
|
||||
/// <summary>
|
||||
/// Prototype that holds a pool of maps that can be indexed based on the map pool CCVar.
|
||||
/// </summary>
|
||||
[Prototype("gameMapPool"), PublicAPI]
|
||||
public sealed class GameMapPoolPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Which maps are in this pool.
|
||||
/// </summary>
|
||||
[DataField("maps", customTypeSerializer:typeof(PrototypeIdHashSetSerializer<GameMapPrototype>), required: true)]
|
||||
public readonly HashSet<string> Maps = new(0);
|
||||
}
|
||||
@@ -8,12 +8,6 @@ public sealed partial class GameMapPrototype
|
||||
[DataField("fallback")]
|
||||
public bool Fallback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Controls if the map can be voted for.
|
||||
/// </summary>
|
||||
[DataField("votable")]
|
||||
public bool Votable { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum players for the given map.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user