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

@@ -6,10 +6,10 @@ using Robust.Shared.Utility;
namespace Content.Shared.Tools.Components
{
[RegisterComponent, NetworkedComponent]
public sealed class MultipleToolComponent : Component
public sealed partial class MultipleToolComponent : Component
{
[DataDefinition]
public sealed class ToolEntry
public sealed partial class ToolEntry
{
[DataField("behavior", required: true)]
public PrototypeFlags<ToolQualityPrototype> Behavior = new();
@@ -25,7 +25,7 @@ namespace Content.Shared.Tools.Components
}
[DataField("entries", required: true)]
public ToolEntry[] Entries { get; } = Array.Empty<ToolEntry>();
public ToolEntry[] Entries { get; private set; } = Array.Empty<ToolEntry>();
[ViewVariables]
public uint CurrentEntry = 0;

View File

@@ -1,7 +1,7 @@
namespace Content.Shared.GPS
{
public abstract class SharedHandheldGPSComponent : Component
public abstract partial class SharedHandheldGPSComponent : Component
{
[DataField("updateRate")]
public float UpdateRate = 1.5f;

View File

@@ -2,7 +2,7 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Tools.Components;
public abstract class SharedWeldableComponent : Component
public abstract partial class SharedWeldableComponent : Component
{
}

View File

@@ -4,7 +4,7 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Tools.Components
{
[NetworkedComponent]
public abstract class SharedWelderComponent : Component
public abstract partial class SharedWelderComponent : Component
{
public bool Lit { get; set; }
}

View File

@@ -5,7 +5,7 @@ using Robust.Shared.Utility;
namespace Content.Shared.Tools.Components
{
[RegisterComponent, NetworkedComponent] // TODO move tool system to shared, and make it a friend.
public sealed class ToolComponent : Component
public sealed partial class ToolComponent : Component
{
[DataField("qualities")]
public PrototypeFlags<ToolQualityPrototype> Qualities { get; set; } = new();

View File

@@ -5,6 +5,6 @@ namespace Content.Shared.Tools.Components
/// or not to work.
/// </summary>
[RegisterComponent]
public sealed class ToolForcePoweredComponent : Component
public sealed partial class ToolForcePoweredComponent : Component
{}
}

View File

@@ -197,16 +197,16 @@ public abstract partial class SharedToolSystem : EntitySystem
#region DoAfterEvents
[Serializable, NetSerializable]
protected sealed class ToolDoAfterEvent : DoAfterEvent
protected sealed partial class ToolDoAfterEvent : DoAfterEvent
{
/// <summary>
/// Entity that the wrapped do after event will get directed at. If null, event will be broadcast.
/// </summary>
[DataField("target")]
public readonly EntityUid? OriginalTarget;
public EntityUid? OriginalTarget;
[DataField("wrappedEvent")]
public readonly DoAfterEvent WrappedEvent = default!;
public DoAfterEvent WrappedEvent = default!;
private ToolDoAfterEvent()
{
@@ -233,10 +233,10 @@ public abstract partial class SharedToolSystem : EntitySystem
}
[Serializable, NetSerializable]
protected sealed class LatticeCuttingCompleteEvent : DoAfterEvent
protected sealed partial class LatticeCuttingCompleteEvent : DoAfterEvent
{
[DataField("coordinates", required:true)]
public readonly EntityCoordinates Coordinates;
public EntityCoordinates Coordinates;
private LatticeCuttingCompleteEvent()
{
@@ -251,10 +251,10 @@ public abstract partial class SharedToolSystem : EntitySystem
}
[Serializable, NetSerializable]
protected sealed class TilePryingDoAfterEvent : DoAfterEvent
protected sealed partial class TilePryingDoAfterEvent : DoAfterEvent
{
[DataField("coordinates", required:true)]
public readonly EntityCoordinates Coordinates;
public EntityCoordinates Coordinates;
private TilePryingDoAfterEvent()
{
@@ -270,7 +270,7 @@ public abstract partial class SharedToolSystem : EntitySystem
}
[Serializable, NetSerializable]
public sealed class CableCuttingFinishedEvent : SimpleDoAfterEvent
public sealed partial class CableCuttingFinishedEvent : SimpleDoAfterEvent
{
}

View File

@@ -8,6 +8,6 @@ namespace Content.Shared.Tools.Systems;
/// use <see cref="WeldableChangedEvent"/> to get updated status.
/// </summary>
[Serializable, NetSerializable]
public sealed class WeldFinishedEvent : SimpleDoAfterEvent
public sealed partial class WeldFinishedEvent : SimpleDoAfterEvent
{
}
}

View File

@@ -8,32 +8,32 @@ namespace Content.Shared.Tools
public sealed class ToolQualityPrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
/// <summary>
/// Human-readable name for this tool quality e.g. "Anchoring"
/// </summary>
/// <remarks>This is a localization string ID.</remarks>
[DataField("name")]
public string Name { get; } = string.Empty;
public string Name { get; private set; } = string.Empty;
/// <summary>
/// Human-readable name for a tool of this type e.g. "Wrench"
/// </summary>
/// <remarks>This is a localization string ID.</remarks>
[DataField("toolName")]
public string ToolName { get; } = string.Empty;
public string ToolName { get; private set; } = string.Empty;
/// <summary>
/// An icon that will be used to represent this tool type.
/// </summary>
[DataField("icon")]
public SpriteSpecifier? Icon { get; } = null;
public SpriteSpecifier? Icon { get; private set; } = null;
/// <summary>
/// The default entity prototype for this tool type.
/// </summary>
[DataField("spawn", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Spawn { get; } = string.Empty;
public string Spawn { get; private set; } = string.Empty;
}
}