StationSystem/jobs/partial spawning refactor (#7580)
* Partial work on StationSystem refactor. * WIP station jobs API. * forgor to fire off grid events. * Partial implementation of StationSpawningSystem * whoops infinite loop. * Spawners should work now. * it compiles. * tfw * Vestigial code cleanup. * fix station deletion. * attempt to make tests go brr * add latejoin spawnpoints to test maps. * make sure the station still exists while destructing spawners. * forgot an exists check. * destruction order check. * hopefully fix final test. * fail-safe radstorm. * Deep-clean job code further. This is bugged!!!!! * Fix job bug. (init order moment) * whooo cleanup * New job selection algorithm that tries to distribute fairly across stations. * small nitpicks * Give the heads their weights to replace the head field. * make overflow assign take a station list. * moment * Fixes and test #1 of many. * please fix nullspace * AssignJobs should no longer even consider showing up on a trace. * add comment. * Introduce station configs, praying i didn't miss something. * in one small change stations are now fully serializable. * Further doc comments. * whoops. * Solve bug where assignjobs didn't account for roundstart. * Fix spawning, improve the API. Caught an oversight in stationsystem that should've broke everything but didn't, whoops. * Goodbye JobController. * minor fix.. * fix test fail, remove debug logs. * quick serialization fixes. * fixes.. * sus * partialing * Update Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * Use dirtying to avoid rebuilding the list 2,100 times. * add a bajillion more lines of docs (mostly in AssignJobs so i don't ever forget how it works) * Update Content.IntegrationTests/Tests/Station/StationJobsTest.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * Add the Mysteriously Missing Captain Check. * Put maprender back the way it belongs. * I love addressing reviews. * Update Content.Server/Station/Systems/StationJobsSystem.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * doc cleanup. * Fix bureaucratic error, add job slot tests. * zero cost abstractions when * cri * saner error. * Fix spawning failing certain tests due to gameticker not handling falliability correctly. Can't fix this until I refactor the rest of spawning code. * submodule gaming * Packedenger. * Documentation consistency. Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Server.Player;
|
||||
@@ -23,7 +24,7 @@ public sealed class GameMapManager : IGameMapManager
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private readonly Queue<string> _previousMaps = new Queue<string>();
|
||||
private readonly Queue<string> _previousMaps = new();
|
||||
[ViewVariables]
|
||||
private GameMapPrototype _currentMap = default!;
|
||||
[ViewVariables]
|
||||
@@ -137,7 +138,7 @@ public sealed class GameMapManager : IGameMapManager
|
||||
var map = GetSelectedMap();
|
||||
|
||||
if (markAsPlayed)
|
||||
_previousMaps.Enqueue(map.ID);
|
||||
EnqueueMap(map.ID);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -158,14 +159,6 @@ public sealed class GameMapManager : IGameMapManager
|
||||
return _prototypeManager.TryIndex(gameMap, out map);
|
||||
}
|
||||
|
||||
public string GenerateMapName(GameMapPrototype gameMap)
|
||||
{
|
||||
if (gameMap.NameGenerator is not null && gameMap.MapNameTemplate is not null)
|
||||
return gameMap.NameGenerator.FormatName(gameMap.MapNameTemplate);
|
||||
else
|
||||
return gameMap.MapName;
|
||||
}
|
||||
|
||||
public int GetMapQueuePriority(string gameMapProtoName)
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
35
Content.Server/Maps/GameMapPrototype.MapSelection.cs
Normal file
35
Content.Server/Maps/GameMapPrototype.MapSelection.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace Content.Server.Maps;
|
||||
|
||||
public sealed partial class GameMapPrototype
|
||||
{
|
||||
/// <summary>
|
||||
/// Controls if the map can be used as a fallback if no maps are eligible.
|
||||
/// </summary>
|
||||
[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>
|
||||
[DataField("minPlayers", required: true)]
|
||||
public uint MinPlayers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum players for the given map.
|
||||
/// </summary>
|
||||
[DataField("maxPlayers")]
|
||||
public uint MaxPlayers { get; } = uint.MaxValue;
|
||||
|
||||
[DataField("conditions")] private readonly List<GameMapCondition> _conditions = new();
|
||||
|
||||
/// <summary>
|
||||
/// The game map conditions that must be fulfilled for this map to be selectable.
|
||||
/// </summary>
|
||||
public IReadOnlyList<GameMapCondition> Conditions => _conditions;
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Maps.NameGenerators;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Server.Station;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Maps;
|
||||
@@ -12,25 +8,17 @@ namespace Content.Server.Maps;
|
||||
/// <summary>
|
||||
/// Prototype data for a game map.
|
||||
/// </summary>
|
||||
[Prototype("gameMap")]
|
||||
public sealed class GameMapPrototype : IPrototype
|
||||
/// <remarks>
|
||||
/// Forks should not directly edit existing parts of this class.
|
||||
/// Make a new partial for your fancy new feature, it'll save you time later.
|
||||
/// </remarks>
|
||||
[Prototype("gameMap"), PublicAPI]
|
||||
public sealed partial class GameMapPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataFieldAttribute]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum players for the given map.
|
||||
/// </summary>
|
||||
[DataField("minPlayers", required: true)]
|
||||
public uint MinPlayers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum players for the given map.
|
||||
/// </summary>
|
||||
[DataField("maxPlayers")]
|
||||
public uint MaxPlayers { get; } = uint.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the map to use in generic messages, like the map vote.
|
||||
/// </summary>
|
||||
@@ -38,49 +26,16 @@ public sealed class GameMapPrototype : IPrototype
|
||||
public string MapName { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the given map.
|
||||
/// </summary>
|
||||
[DataField("mapNameTemplate")]
|
||||
public string? MapNameTemplate { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Name generator to use for the map, if any.
|
||||
/// </summary>
|
||||
[DataField("nameGenerator")]
|
||||
public GameMapNameGenerator? NameGenerator { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Relative directory path to the given map, i.e. `Maps/saltern.yml`
|
||||
/// Relative directory path to the given map, i.e. `/Maps/saltern.yml`
|
||||
/// </summary>
|
||||
[DataField("mapPath", required: true)]
|
||||
public ResourcePath MapPath { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Controls if the map can be used as a fallback if no maps are eligible.
|
||||
/// </summary>
|
||||
[DataField("fallback")]
|
||||
public bool Fallback { get; }
|
||||
[DataField("stations")]
|
||||
private Dictionary<string, StationConfig> _stations = new();
|
||||
|
||||
/// <summary>
|
||||
/// Controls if the map can be voted for.
|
||||
/// The stations this map contains. The names should match with the BecomesStation components.
|
||||
/// </summary>
|
||||
[DataField("votable")]
|
||||
public bool Votable { get; } = true;
|
||||
|
||||
[DataField("conditions")]
|
||||
public List<GameMapCondition> Conditions { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Jobs used at round start should the station run out of job slots.
|
||||
/// Doesn't necessarily mean the station has infinite slots for the given jobs midround!
|
||||
/// </summary>
|
||||
[DataField("overflowJobs", required: true, customTypeSerializer:typeof(PrototypeIdListSerializer<JobPrototype>))]
|
||||
public List<string> OverflowJobs { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Index of all jobs available on the station, of form
|
||||
/// jobname: [roundstart, midround]
|
||||
/// </summary>
|
||||
[DataField("availableJobs", required: true, customTypeSerializer:typeof(PrototypeIdDictionarySerializer<List<int>, JobPrototype>))]
|
||||
public Dictionary<string, List<int>> AvailableJobs { get; } = default!;
|
||||
public IReadOnlyDictionary<string, StationConfig> Stations => _stations;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,4 @@ public interface IGameMapManager
|
||||
/// <param name="gameMap">name of the map</param>
|
||||
/// <returns>existence</returns>
|
||||
bool CheckMapExists(string gameMap);
|
||||
|
||||
public string GenerateMapName(GameMapPrototype gameMap);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
||||
namespace Content.Server.Maps.NameGenerators;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class NanotrasenNameGenerator : GameMapNameGenerator
|
||||
public sealed class NanotrasenNameGenerator : StationNameGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Where the map comes from. Should be a two or three letter code, for example "VG" for Packedstation.
|
||||
|
||||
@@ -3,7 +3,7 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
||||
namespace Content.Server.Maps.NameGenerators;
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class GameMapNameGenerator
|
||||
public abstract class StationNameGenerator
|
||||
{
|
||||
public abstract string FormatName(string input);
|
||||
}
|
||||
Reference in New Issue
Block a user