Refactor actions to be entities with components (#19900)

This commit is contained in:
DrSmugleaf
2023-09-08 18:16:05 -07:00
committed by GitHub
parent e18f731b91
commit c71f97e3a2
210 changed files with 10693 additions and 11714 deletions

View 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; }
}

View 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();
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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;
}

View 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; }
}

View 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; }
}

View 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;
}