Refactor serialization copying to use source generators (#19412)

This commit is contained in:
DrSmugleaf
2023-08-22 18:14:33 -07:00
committed by GitHub
parent 08b43990ab
commit a88e747a0b
1737 changed files with 2532 additions and 2521 deletions

View File

@@ -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)
{

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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.

View File

@@ -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();

View File

@@ -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.

View File

@@ -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);
}