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

@@ -9,26 +9,26 @@ namespace Content.Shared.Cargo;
/// A data structure for storing currently available bounties.
/// </summary>
[DataDefinition, NetSerializable, Serializable]
public readonly record struct CargoBountyData(int Id, string Bounty, TimeSpan EndTime)
public readonly partial record struct CargoBountyData(int Id, string Bounty, TimeSpan EndTime)
{
/// <summary>
/// A numeric id used to identify the bounty
/// </summary>
[DataField("id"), ViewVariables(VVAccess.ReadWrite)]
public readonly int Id = Id;
public int Id { get; init; } = Id;
/// <summary>
/// The prototype containing information about the bounty.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("bounty", customTypeSerializer: typeof(PrototypeIdSerializer<CargoBountyPrototype>), required:true)]
public readonly string Bounty = Bounty;
public string Bounty { get; init; } = Bounty;
/// <summary>
/// The time at which the bounty is closed and no longer is available.
/// </summary>
[DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public readonly TimeSpan EndTime = EndTime;
public TimeSpan EndTime { get; init; } = EndTime;
public CargoBountyData() : this(default, string.Empty, default)
{

View File

@@ -7,7 +7,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Shared.Cargo.Components;
[RegisterComponent]
public sealed class CargoBountyConsoleComponent : Component
public sealed partial class CargoBountyConsoleComponent : Component
{
/// <summary>
/// The id of the label entity spawned by the print label button.

View File

@@ -8,7 +8,7 @@ namespace Content.Shared.Cargo.Components;
/// Present on cargo shuttles to provide metadata such as preventing spam calling.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedCargoSystem))]
public sealed class CargoShuttleComponent : Component
public sealed partial class CargoShuttleComponent : Component
{
/// <summary>
/// The paper-type prototype to spawn with the order information.

View File

@@ -11,7 +11,7 @@ namespace Content.Shared.Cargo.Components;
/// Handles teleporting in requested cargo after the specified delay.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedCargoSystem))]
public sealed class CargoTelepadComponent : Component
public sealed partial class CargoTelepadComponent : Component
{
/// <summary>
/// The base amount of time it takes to teleport from the telepad

View File

@@ -14,35 +14,35 @@ public sealed class CargoBountyPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// The monetary reward for completing the bounty
/// </summary>
[DataField("reward", required: true)]
public readonly int Reward;
public int Reward;
/// <summary>
/// A description for flava purposes.
/// </summary>
[DataField("description")]
public readonly string Description = string.Empty;
public string Description = string.Empty;
/// <summary>
/// The entries that must be satisfied for the cargo bounty to be complete.
/// </summary>
[DataField("entries", required: true)]
public readonly List<CargoBountyItemEntry> Entries = new();
public List<CargoBountyItemEntry> Entries = new();
}
[DataDefinition, Serializable, NetSerializable]
public readonly record struct CargoBountyItemEntry()
public readonly partial record struct CargoBountyItemEntry()
{
/// <summary>
/// A whitelist for determining what items satisfy the entry.
/// </summary>
[DataField("whitelist", required: true)]
public readonly EntityWhitelist Whitelist = default!;
public EntityWhitelist Whitelist { get; init; } = default!;
// todo: implement some kind of simple generic condition system
@@ -50,11 +50,11 @@ public readonly record struct CargoBountyItemEntry()
/// How much of the item must be present to satisfy the entry
/// </summary>
[DataField("amount")]
public readonly int Amount = 1;
public int Amount { get; init; } = 1;
/// <summary>
/// A player-facing name for the item.
/// </summary>
[DataField("name")]
public readonly string Name = string.Empty;
public string Name { get; init; } = string.Empty;
}

View File

@@ -14,7 +14,7 @@ namespace Content.Shared.Cargo.Prototypes
[ViewVariables]
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// Product name.
@@ -60,30 +60,30 @@ namespace Content.Shared.Cargo.Prototypes
/// Texture path used in the CargoConsole GUI.
/// </summary>
[DataField("icon")]
public SpriteSpecifier Icon { get; } = SpriteSpecifier.Invalid;
public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
/// <summary>
/// The prototype name of the product.
/// </summary>
[DataField("product", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Product { get; } = string.Empty;
public string Product { get; private set; } = string.Empty;
/// <summary>
/// The point cost of the product.
/// </summary>
[DataField("cost")]
public int PointCost { get; }
public int PointCost { get; private set; }
/// <summary>
/// The prototype category of the product. (e.g. Engineering, Medical)
/// </summary>
[DataField("category")]
public string Category { get; } = string.Empty;
public string Category { get; private set; } = string.Empty;
/// <summary>
/// The prototype group of the product. (e.g. Contraband)
/// </summary>
[DataField("group")]
public string Group { get; } = string.Empty;
public string Group { get; private set; } = string.Empty;
}
}