Refactor serialization copying to use source generators (#19412)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user