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

@@ -7,31 +7,31 @@ namespace Content.Server.Tabletop.Components
/// A component that makes an object playable as a tabletop game.
/// </summary>
[RegisterComponent, Access(typeof(TabletopSystem))]
public sealed class TabletopGameComponent : Component
public sealed partial class TabletopGameComponent : Component
{
/// <summary>
/// The localized name of the board. Shown in the UI.
/// </summary>
[DataField("boardName")]
public string BoardName { get; } = "tabletop-default-board-name";
public string BoardName { get; private set; } = "tabletop-default-board-name";
/// <summary>
/// The type of method used to set up a tabletop.
/// </summary>
[DataField("setup", required: true)]
public TabletopSetup Setup { get; } = new TabletopChessSetup();
public TabletopSetup Setup { get; private set; } = new TabletopChessSetup();
/// <summary>
/// The size of the viewport being opened. Must match the board dimensions otherwise you'll get the space parallax (unless that's what you want).
/// </summary>
[DataField("size")]
public Vector2i Size { get; } = (300, 300);
public Vector2i Size { get; private set; } = (300, 300);
/// <summary>
/// The zoom of the viewport camera.
/// </summary>
[DataField("cameraZoom")]
public Vector2 CameraZoom { get; } = Vector2.One;
public Vector2 CameraZoom { get; private set; } = Vector2.One;
/// <summary>
/// The specific session of this tabletop.

View File

@@ -4,7 +4,7 @@ namespace Content.Server.Tabletop.Components
/// Component for marking an entity as currently playing a tabletop.
/// </summary>
[RegisterComponent, Access(typeof(TabletopSystem))]
public sealed class TabletopGamerComponent : Component
public sealed partial class TabletopGamerComponent : Component
{
[DataField("tabletop")]
public EntityUid Tabletop { get; set; } = EntityUid.Invalid;

View File

@@ -3,14 +3,14 @@ using JetBrains.Annotations;
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public sealed class TabletopBackgammonSetup : TabletopSetup
public sealed partial class TabletopBackgammonSetup : TabletopSetup
{
[DataField("whitePiecePrototype")]
public string WhitePiecePrototype { get; } = "WhiteTabletopPiece";
public string WhitePiecePrototype { get; private set; } = "WhiteTabletopPiece";
[DataField("blackPiecePrototype")]
public string BlackPiecePrototype { get; } = "BlackTabletopPiece";
public string BlackPiecePrototype { get; private set; } = "BlackTabletopPiece";
public override void SetupTabletop(TabletopSession session, IEntityManager entityManager)
{
var board = entityManager.SpawnEntity(BoardPrototype, session.Position);

View File

@@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public sealed class TabletopCheckerSetup : TabletopSetup
public sealed partial class TabletopCheckerSetup : TabletopSetup
{
// TODO: Un-hardcode the rest of entity prototype IDs, probably.

View File

@@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public sealed class TabletopChessSetup : TabletopSetup
public sealed partial class TabletopChessSetup : TabletopSetup
{
// TODO: Un-hardcode the rest of entity prototype IDs, probably.

View File

@@ -3,7 +3,7 @@ using JetBrains.Annotations;
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public sealed class TabletopEmptySetup : TabletopSetup
public sealed partial class TabletopEmptySetup : TabletopSetup
{
public override void SetupTabletop(TabletopSession session, IEntityManager entityManager)
{

View File

@@ -4,7 +4,7 @@ namespace Content.Server.Tabletop;
/// This is used for tracking pieces that are simply "holograms" shown on the tabletop
/// </summary>
[RegisterComponent]
public sealed class TabletopHologramComponent : Component
public sealed partial class TabletopHologramComponent : Component
{
}

View File

@@ -5,20 +5,20 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public sealed class TabletopParchisSetup : TabletopSetup
public sealed partial class TabletopParchisSetup : TabletopSetup
{
[DataField("redPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string RedPiecePrototype { get; } = "RedTabletopPiece";
public string RedPiecePrototype { get; private set; } = "RedTabletopPiece";
[DataField("greenPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string GreenPiecePrototype { get; } = "GreenTabletopPiece";
public string GreenPiecePrototype { get; private set; } = "GreenTabletopPiece";
[DataField("yellowPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string YellowPiecePrototype { get; } = "YellowTabletopPiece";
public string YellowPiecePrototype { get; private set; } = "YellowTabletopPiece";
[DataField("bluePiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string BluePiecePrototype { get; } = "BlueTabletopPiece";
public string BluePiecePrototype { get; private set; } = "BlueTabletopPiece";
public override void SetupTabletop(TabletopSession session, IEntityManager entityManager)
{

View File

@@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Tabletop
{
[ImplicitDataDefinitionForInheritors]
public abstract class TabletopSetup
public abstract partial class TabletopSetup
{
/// <summary>
/// Method for setting up a tabletop. Use this to spawn the board and pieces, etc.