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

@@ -12,7 +12,7 @@ namespace Content.Shared.Research.Prototypes
{
[ViewVariables]
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
[DataField("name")]
private string _name = string.Empty;

View File

@@ -12,37 +12,37 @@ public sealed class TechDisciplinePrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// Player-facing name.
/// Supports locale strings.
/// </summary>
[DataField("name", required: true)]
public readonly string Name = string.Empty;
public string Name = string.Empty;
/// <summary>
/// A color used for UI
/// </summary>
[DataField("color", required: true)]
public readonly Color Color;
public Color Color;
/// <summary>
/// An icon used to visually represent the discipline in UI.
/// </summary>
[DataField("icon")]
public readonly SpriteSpecifier Icon = default!;
public SpriteSpecifier Icon = default!;
/// <summary>
/// For each tier a discipline supports, what percentage
/// of the previous tier must be unlocked for it to become available
/// </summary>
[DataField("tierPrerequisites", required: true)]
public readonly Dictionary<int, float> TierPrerequisites = new();
public Dictionary<int, float> TierPrerequisites = new();
/// <summary>
/// Purchasing this tier of technology causes a server to become "locked" to this discipline.
/// </summary>
[DataField("lockoutTier")]
public readonly int LockoutTier = 3;
public int LockoutTier = 3;
}

View File

@@ -13,26 +13,26 @@ public sealed class TechnologyPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// The name of the technology.
/// Supports locale strings
/// </summary>
[DataField("name", required: true)]
public readonly string Name = string.Empty;
public string Name = string.Empty;
/// <summary>
/// An icon used to visually represent the technology in UI.
/// </summary>
[DataField("icon", required: true)]
public readonly SpriteSpecifier Icon = default!;
public SpriteSpecifier Icon = default!;
/// <summary>
/// What research discipline this technology belongs to.
/// </summary>
[DataField("discipline", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<TechDisciplinePrototype>))]
public readonly string Discipline = default!;
public string Discipline = default!;
/// <summary>
/// What tier research is this?
@@ -40,53 +40,53 @@ public sealed class TechnologyPrototype : IPrototype
/// needs to be unlocked before this one.
/// </summary>
[DataField("tier", required: true)]
public readonly int Tier;
public int Tier;
/// <summary>
/// Hidden tech is not ever available at the research console.
/// </summary>
[DataField("hidden")]
public readonly bool Hidden;
public bool Hidden;
/// <summary>
/// How much research is needed to unlock.
/// </summary>
[DataField("cost")]
public readonly int Cost = 10000;
public int Cost = 10000;
/// <summary>
/// A list of <see cref="TechnologyPrototype"/>s that need to be unlocked in order to unlock this technology.
/// </summary>
[DataField("technologyPrerequisites", customTypeSerializer: typeof(PrototypeIdListSerializer<TechnologyPrototype>))]
public readonly IReadOnlyList<string> TechnologyPrerequisites = new List<string>();
public IReadOnlyList<string> TechnologyPrerequisites = new List<string>();
/// <summary>
/// A list of <see cref="LatheRecipePrototype"/>s that are unlocked by this technology
/// </summary>
[DataField("recipeUnlocks", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
public readonly IReadOnlyList<string> RecipeUnlocks = new List<string>();
public IReadOnlyList<string> RecipeUnlocks = new List<string>();
/// <summary>
/// A list of non-standard effects that are done when this technology is unlocked.
/// </summary>
[DataField("genericUnlocks")]
public readonly IReadOnlyList<GenericUnlock> GenericUnlocks = new List<GenericUnlock>();
public IReadOnlyList<GenericUnlock> GenericUnlocks = new List<GenericUnlock>();
}
[DataDefinition]
public record struct GenericUnlock()
public partial record struct GenericUnlock()
{
/// <summary>
/// What event is raised when this is unlocked?
/// Used for doing non-standard logic.
/// </summary>
[DataField("purchaseEvent")]
public readonly object? PurchaseEvent = null;
public object? PurchaseEvent = null;
/// <summary>
/// A player facing tooltip for what the unlock does.
/// Supports locale strings.
/// </summary>
[DataField("unlockDescription")]
public readonly string UnlockDescription = string.Empty;
public string UnlockDescription = string.Empty;
}