Refactor serialization copying to use source generators (#19412)
This commit is contained in:
@@ -3,10 +3,10 @@ using Content.Server.Holiday;
|
||||
|
||||
namespace Content.Server.Maps.Conditions;
|
||||
|
||||
public sealed class HolidayMapCondition : GameMapCondition
|
||||
public sealed partial class HolidayMapCondition : GameMapCondition
|
||||
{
|
||||
[DataField("holidays")]
|
||||
public string[] Holidays { get; } = default!;
|
||||
public string[] Holidays { get; private set; } = default!;
|
||||
|
||||
public override bool Check(GameMapPrototype map)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace Content.Server.Maps;
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class GameMapCondition
|
||||
public abstract partial class GameMapCondition
|
||||
{
|
||||
[DataField("inverted")]
|
||||
public bool Inverted { get; }
|
||||
public bool Inverted { get; private set; }
|
||||
public abstract bool Check(GameMapPrototype map);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ public sealed class GameMapPoolPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Which maps are in this pool.
|
||||
/// </summary>
|
||||
[DataField("maps", customTypeSerializer:typeof(PrototypeIdHashSetSerializer<GameMapPrototype>), required: true)]
|
||||
public readonly HashSet<string> Maps = new(0);
|
||||
public HashSet<string> Maps = new(0);
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ public sealed partial class GameMapPrototype
|
||||
/// Controls if the map can be used as a fallback if no maps are eligible.
|
||||
/// </summary>
|
||||
[DataField("fallback")]
|
||||
public bool Fallback { get; }
|
||||
public bool Fallback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Minimum players for the given map.
|
||||
/// </summary>
|
||||
[DataField("minPlayers", required: true)]
|
||||
public uint MinPlayers { get; }
|
||||
public uint MinPlayers { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum players for the given map.
|
||||
/// </summary>
|
||||
[DataField("maxPlayers")]
|
||||
public uint MaxPlayers { get; } = uint.MaxValue;
|
||||
public uint MaxPlayers { get; private set; } = uint.MaxValue;
|
||||
|
||||
[DataField("conditions")] private readonly List<GameMapCondition> _conditions = new();
|
||||
[DataField("conditions")] private List<GameMapCondition> _conditions = new();
|
||||
|
||||
/// <summary>
|
||||
/// The game map conditions that must be fulfilled for this map to be selectable.
|
||||
|
||||
@@ -19,19 +19,19 @@ public sealed partial class GameMapPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the map to use in generic messages, like the map vote.
|
||||
/// </summary>
|
||||
[DataField("mapName", required: true)]
|
||||
public string MapName { get; } = default!;
|
||||
public string MapName { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Relative directory path to the given map, i.e. `/Maps/saltern.yml`
|
||||
/// </summary>
|
||||
[DataField("mapPath", required: true)]
|
||||
public ResPath MapPath { get; } = default!;
|
||||
public ResPath MapPath { get; private set; } = default!;
|
||||
|
||||
[DataField("stations", required: true)]
|
||||
private Dictionary<string, StationConfig> _stations = new();
|
||||
|
||||
@@ -4,7 +4,7 @@ using Robust.Shared.Random;
|
||||
namespace Content.Server.Maps.NameGenerators;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class NanotrasenNameGenerator : StationNameGenerator
|
||||
public sealed partial class NanotrasenNameGenerator : StationNameGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Where the map comes from. Should be a two or three letter code, for example "VG" for Packedstation.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Content.Server.Maps.NameGenerators;
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class StationNameGenerator
|
||||
public abstract partial class StationNameGenerator
|
||||
{
|
||||
public abstract string FormatName(string input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user