Refactor serialization copying to use source generators (#19412)
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Content.Server.Magic.Components;
|
||||
/// Spellbooks for having an entity learn spells as long as they've read the book and it's in their hand.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class SpellbookComponent : Component
|
||||
public sealed partial class SpellbookComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// List of spells that this book has. This is a combination of the WorldSpells, EntitySpells, and InstantSpells.
|
||||
@@ -20,15 +20,15 @@ public sealed class SpellbookComponent : Component
|
||||
/// </summary>
|
||||
[DataField("worldSpells", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<int, WorldTargetActionPrototype>))]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public readonly Dictionary<string, int> WorldSpells = new();
|
||||
public Dictionary<string, int> WorldSpells = new();
|
||||
|
||||
[DataField("entitySpells", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<int, EntityTargetActionPrototype>))]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public readonly Dictionary<string, int> EntitySpells = new();
|
||||
public Dictionary<string, int> EntitySpells = new();
|
||||
|
||||
[DataField("instantSpells", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<int, InstantActionPrototype>))]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public readonly Dictionary<string, int> InstantSpells = new();
|
||||
public Dictionary<string, int> InstantSpells = new();
|
||||
|
||||
[DataField("learnTime")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Content.Server.Magic.Events;
|
||||
/// <summary>
|
||||
/// Spell that uses the magic of ECS to add & remove components. Components are first removed, then added.
|
||||
/// </summary>
|
||||
public sealed class ChangeComponentsSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
public sealed partial class ChangeComponentsSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
// TODO allow it to set component data-fields?
|
||||
// for now a Hackish way to do that is to remove & add, but that doesn't allow you to selectively set specific data fields.
|
||||
@@ -20,5 +20,5 @@ public sealed class ChangeComponentsSpellEvent : EntityTargetActionEvent, ISpeak
|
||||
public HashSet<string> ToRemove = new();
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class InstantSpawnSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
public sealed partial class InstantSpawnSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// What entity should be spawned.
|
||||
@@ -16,7 +16,7 @@ public sealed class InstantSpawnSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
public bool PreventCollideWithCaster = true;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the targeted spawn positons; may lead to multiple entities being spawned.
|
||||
@@ -25,7 +25,7 @@ public sealed class InstantSpawnSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
}
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class MagicSpawnData
|
||||
public abstract partial class MagicSpawnData
|
||||
{
|
||||
|
||||
}
|
||||
@@ -33,12 +33,12 @@ public abstract class MagicSpawnData
|
||||
/// <summary>
|
||||
/// Spawns 1 at the caster's feet.
|
||||
/// </summary>
|
||||
public sealed class TargetCasterPos : MagicSpawnData {}
|
||||
public sealed partial class TargetCasterPos : MagicSpawnData {}
|
||||
|
||||
/// <summary>
|
||||
/// Targets the 3 tiles in front of the caster.
|
||||
/// </summary>
|
||||
public sealed class TargetInFront : MagicSpawnData
|
||||
public sealed partial class TargetInFront : MagicSpawnData
|
||||
{
|
||||
[DataField("width")]
|
||||
public int Width = 3;
|
||||
|
||||
@@ -3,7 +3,7 @@ using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class KnockSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
public sealed partial class KnockSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// The range this spell opens doors in
|
||||
@@ -22,5 +22,5 @@ public sealed class KnockSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
public float KnockVolume = 5f;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class ProjectileSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
public sealed partial class ProjectileSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// What entity should be spawned.
|
||||
@@ -19,5 +19,5 @@ public sealed class ProjectileSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
[DataField("posData")] public MagicSpawnData Pos = new TargetCasterPos();
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class SmiteSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
public sealed partial class SmiteSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// Should this smite delete all parts/mechanisms gibbed except for the brain?
|
||||
@@ -11,5 +11,5 @@ public sealed class SmiteSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
public bool DeleteNonBrainParts = true;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class TeleportSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
public sealed partial class TeleportSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
[DataField("blinkSound")]
|
||||
public SoundSpecifier BlinkSound = new SoundPathSpecifier("/Audio/Magic/blink.ogg");
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Volume control for the spell.
|
||||
|
||||
@@ -4,7 +4,7 @@ using Content.Shared.Storage;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class WorldSpawnSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
public sealed partial class WorldSpawnSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
// TODO:This class needs combining with InstantSpawnSpellEvent
|
||||
|
||||
@@ -28,6 +28,6 @@ public sealed class WorldSpawnSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
[DataField("lifetime")] public float? Lifetime;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; }
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user