Refactor actions to be entities with components (#19900)
This commit is contained in:
24
Content.Shared/Magic/Events/ChangeComponentSpellEvent.cs
Normal file
24
Content.Shared/Magic/Events/ChangeComponentSpellEvent.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Spell that uses the magic of ECS to add & remove components. Components are first removed, then added.
|
||||
/// </summary>
|
||||
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.
|
||||
|
||||
[DataField("toAdd")]
|
||||
[AlwaysPushInheritance]
|
||||
public ComponentRegistry ToAdd = new();
|
||||
|
||||
[DataField("toRemove")]
|
||||
[AlwaysPushInheritance]
|
||||
public HashSet<string> ToRemove = new();
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
25
Content.Shared/Magic/Events/InstantSpawnSpellEvent.cs
Normal file
25
Content.Shared/Magic/Events/InstantSpawnSpellEvent.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
public sealed partial class InstantSpawnSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// What entity should be spawned.
|
||||
/// </summary>
|
||||
[DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Prototype = default!;
|
||||
|
||||
[DataField("preventCollide")]
|
||||
public bool PreventCollideWithCaster = true;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the targeted spawn positons; may lead to multiple entities being spawned.
|
||||
/// </summary>
|
||||
[DataField("posData")] public MagicSpawnData Pos = new TargetCasterPos();
|
||||
}
|
||||
26
Content.Shared/Magic/Events/KnockSpellEvent.cs
Normal file
26
Content.Shared/Magic/Events/KnockSpellEvent.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
public sealed partial class KnockSpellEvent : InstantActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// The range this spell opens doors in
|
||||
/// 4f is the default
|
||||
/// </summary>
|
||||
[DataField("range")]
|
||||
public float Range = 4f;
|
||||
|
||||
[DataField("knockSound")]
|
||||
public SoundSpecifier KnockSound = new SoundPathSpecifier("/Audio/Magic/knock.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// Volume control for the spell.
|
||||
/// </summary>
|
||||
[DataField("knockVolume")]
|
||||
public float KnockVolume = 5f;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
22
Content.Shared/Magic/Events/ProjectileSpellEvent.cs
Normal file
22
Content.Shared/Magic/Events/ProjectileSpellEvent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
public sealed partial class ProjectileSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// What entity should be spawned.
|
||||
/// </summary>
|
||||
[DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Prototype = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the targeted spawn positions; may lead to multiple entities being spawned.
|
||||
/// </summary>
|
||||
[DataField("posData")] public MagicSpawnData Pos = new TargetCasterPos();
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
15
Content.Shared/Magic/Events/SmiteSpellEvent.cs
Normal file
15
Content.Shared/Magic/Events/SmiteSpellEvent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Shared.Actions;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
public sealed partial class SmiteSpellEvent : EntityTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
/// <summary>
|
||||
/// Should this smite delete all parts/mechanisms gibbed except for the brain?
|
||||
/// </summary>
|
||||
[DataField("deleteNonBrainParts")]
|
||||
public bool DeleteNonBrainParts = true;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
19
Content.Shared/Magic/Events/TeleportSpellEvent.cs
Normal file
19
Content.Shared/Magic/Events/TeleportSpellEvent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
public sealed partial class TeleportSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
[DataField("blinkSound")]
|
||||
public SoundSpecifier BlinkSound = new SoundPathSpecifier("/Audio/Magic/blink.ogg");
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Volume control for the spell.
|
||||
/// </summary>
|
||||
[DataField("blinkVolume")]
|
||||
public float BlinkVolume = 5f;
|
||||
}
|
||||
32
Content.Shared/Magic/Events/WorldSpawnSpellEvent.cs
Normal file
32
Content.Shared/Magic/Events/WorldSpawnSpellEvent.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Storage;
|
||||
|
||||
namespace Content.Shared.Magic.Events;
|
||||
|
||||
public sealed partial class WorldSpawnSpellEvent : WorldTargetActionEvent, ISpeakSpell
|
||||
{
|
||||
// TODO:This class needs combining with InstantSpawnSpellEvent
|
||||
|
||||
/// <summary>
|
||||
/// The list of prototypes this spell will spawn
|
||||
/// </summary>
|
||||
[DataField("prototypes")]
|
||||
public List<EntitySpawnEntry> Contents = new();
|
||||
|
||||
// TODO: This offset is liable for deprecation.
|
||||
/// <summary>
|
||||
/// The offset the prototypes will spawn in on relative to the one prior.
|
||||
/// Set to 0,0 to have them spawn on the same tile.
|
||||
/// </summary>
|
||||
[DataField("offset")]
|
||||
public Vector2 Offset;
|
||||
|
||||
/// <summary>
|
||||
/// Lifetime to set for the entities to self delete
|
||||
/// </summary>
|
||||
[DataField("lifetime")] public float? Lifetime;
|
||||
|
||||
[DataField("speech")]
|
||||
public string? Speech { get; private set; }
|
||||
}
|
||||
9
Content.Shared/Magic/ISpeakSpell.cs
Normal file
9
Content.Shared/Magic/ISpeakSpell.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared.Magic;
|
||||
|
||||
public interface ISpeakSpell // The speak n spell interface
|
||||
{
|
||||
/// <summary>
|
||||
/// Localized string spoken by the caster when casting this spell.
|
||||
/// </summary>
|
||||
public string? Speech { get; }
|
||||
}
|
||||
20
Content.Shared/Magic/MagicSpawnData.cs
Normal file
20
Content.Shared/Magic/MagicSpawnData.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Content.Shared.Magic;
|
||||
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract partial class MagicSpawnData
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns 1 at the caster's feet.
|
||||
/// </summary>
|
||||
public sealed partial class TargetCasterPos : MagicSpawnData {}
|
||||
|
||||
/// <summary>
|
||||
/// Targets the 3 tiles in front of the caster.
|
||||
/// </summary>
|
||||
public sealed partial class TargetInFront : MagicSpawnData
|
||||
{
|
||||
[DataField("width")] public int Width = 3;
|
||||
}
|
||||
Reference in New Issue
Block a user