Refactor serialization copying to use source generators (#19412)
This commit is contained in:
@@ -12,11 +12,11 @@ namespace Content.Shared.Store;
|
||||
/// </summary>
|
||||
[Prototype("currency")]
|
||||
[DataDefinition, Serializable, NetSerializable]
|
||||
public sealed class CurrencyPrototype : IPrototype
|
||||
public sealed partial class CurrencyPrototype : IPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The Loc string used for displaying the currency in the store ui.
|
||||
@@ -24,17 +24,17 @@ public sealed class CurrencyPrototype : IPrototype
|
||||
/// that which is displayed to the user.
|
||||
/// </summary>
|
||||
[DataField("displayName")]
|
||||
public string DisplayName { get; } = string.Empty;
|
||||
public string DisplayName { get; private set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The physical entity of the currency
|
||||
/// </summary>
|
||||
[DataField("cash", customTypeSerializer: typeof(PrototypeIdValueDictionarySerializer<FixedPoint2, EntityPrototype>))]
|
||||
public Dictionary<FixedPoint2, string>? Cash { get; }
|
||||
public Dictionary<FixedPoint2, string>? Cash { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not this currency can be withdrawn from a shop by a player. Requires a valid entityId.
|
||||
/// </summary>
|
||||
[DataField("canWithdraw")]
|
||||
public bool CanWithdraw { get; } = true;
|
||||
public bool CanWithdraw { get; private set; } = true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Content.Shared.Store;
|
||||
/// </summary>
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
[MeansImplicitUse]
|
||||
public abstract class ListingCondition
|
||||
public abstract partial class ListingCondition
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether or not a certain entity can purchase a listing.
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Shared.Store;
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
[Virtual, DataDefinition]
|
||||
public class ListingData : IEquatable<ListingData>, ICloneable
|
||||
public partial class ListingData : IEquatable<ListingData>, ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the listing. If empty, uses the entity's name (if present)
|
||||
@@ -148,9 +148,9 @@ public class ListingData : IEquatable<ListingData>, ICloneable
|
||||
[Prototype("listing")]
|
||||
[Serializable, NetSerializable]
|
||||
[DataDefinition]
|
||||
public sealed class ListingPrototype : ListingData, IPrototype
|
||||
public sealed partial class ListingPrototype : ListingData, IPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
public string ID { get; private set; } = default!;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ namespace Content.Shared.Store;
|
||||
/// </summary>
|
||||
[Prototype("storeCategory")]
|
||||
[Serializable, NetSerializable, DataDefinition]
|
||||
public sealed class StoreCategoryPrototype : IPrototype
|
||||
public sealed partial class StoreCategoryPrototype : IPrototype
|
||||
{
|
||||
private string _name = string.Empty;
|
||||
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
[DataField("name")]
|
||||
public string Name { get; private set; } = "";
|
||||
|
||||
[DataField("priority")]
|
||||
public int Priority { get; } = 0;
|
||||
public int Priority { get; private set; } = 0;
|
||||
}
|
||||
|
||||
@@ -10,32 +10,32 @@ namespace Content.Shared.Store;
|
||||
/// </summary>
|
||||
[Prototype("storePreset")]
|
||||
[DataDefinition]
|
||||
public sealed class StorePresetPrototype : IPrototype
|
||||
public sealed partial class StorePresetPrototype : IPrototype
|
||||
{
|
||||
[ViewVariables] [IdDataField] public string ID { get; } = default!;
|
||||
[ViewVariables] [IdDataField] public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The name displayed at the top of the store window
|
||||
/// </summary>
|
||||
[DataField("storeName", required: true)]
|
||||
public string StoreName { get; } = string.Empty;
|
||||
public string StoreName { get; private set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The categories that this store can access
|
||||
/// </summary>
|
||||
[DataField("categories", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<StoreCategoryPrototype>))]
|
||||
public HashSet<string> Categories { get; } = new();
|
||||
public HashSet<string> Categories { get; private set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The inital balance that the store initializes with.
|
||||
/// </summary>
|
||||
[DataField("initialBalance",
|
||||
customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, CurrencyPrototype>))]
|
||||
public Dictionary<string, FixedPoint2>? InitialBalance { get; }
|
||||
public Dictionary<string, FixedPoint2>? InitialBalance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The currencies that are accepted in the store
|
||||
/// </summary>
|
||||
[DataField("currencyWhitelist", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<CurrencyPrototype>))]
|
||||
public HashSet<string> CurrencyWhitelist { get; } = new();
|
||||
public HashSet<string> CurrencyWhitelist { get; private set; } = new();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user