Magic spells backend (#358)

* add EntityEffect aability support

* delayed actions

* renaming

* delayed projectile spells

* spawn on self + entityEffect on self spells

* spawn on point spell

* rename

* clean up base species components

* magic alert

* move magic energy to Shared, add manacost to spells

* magic recoil

* improve magic recoil

* verbal aspect

* somatic aspect

* add simple vfx proto and sprites

* add casting VFX

* add TODO
This commit is contained in:
Ed
2024-07-28 17:26:47 +03:00
committed by GitHub
parent 6f2e1d6d9f
commit 655b32b720
51 changed files with 1213 additions and 81 deletions

View File

@@ -0,0 +1,37 @@
using Content.Server.Chat.Systems;
using Content.Shared._CP14.Magic;
using Content.Shared._CP14.Magic.Components;
using Content.Shared._CP14.Magic.Events;
namespace Content.Server._CP14.Magic;
public sealed partial class CP14MagicSystem : CP14SharedMagicSystem
{
[Dependency] private readonly ChatSystem _chat = default!;
public override void Initialize()
{
SubscribeLocalEvent<CP14MagicEffectVerbalAspectComponent, CP14VerbalAspectSpeechEvent>(OnSpellSpoken);
SubscribeLocalEvent<CP14MagicEffectCastingVisualComponent, CP14StartCastMagicEffectEvent>(OnSpawnMagicVisualEffect);
SubscribeLocalEvent<CP14MagicEffectCastingVisualComponent, CP14StopCastMagicEffectEvent>(OnDespawnMagicVisualEffect);
}
private void OnSpellSpoken(Entity<CP14MagicEffectVerbalAspectComponent> ent, ref CP14VerbalAspectSpeechEvent args)
{
if (args.Performer is not null && args.Speech is not null)
_chat.TrySendInGameICMessage(args.Performer.Value, args.Speech, InGameICChatType.Speak, false);
}
private void OnSpawnMagicVisualEffect(Entity<CP14MagicEffectCastingVisualComponent> ent, ref CP14StartCastMagicEffectEvent args)
{
var vfx = SpawnAttachedTo(ent.Comp.Proto, Transform(args.Performer).Coordinates);
ent.Comp.SpawnedEntity = vfx;
}
private void OnDespawnMagicVisualEffect(Entity<CP14MagicEffectCastingVisualComponent> ent, ref CP14StopCastMagicEffectEvent args)
{
QueueDel(ent.Comp.SpawnedEntity);
ent.Comp.SpawnedEntity = null;
}
}