2024-07-28 17:26:47 +03:00
|
|
|
using Content.Server.Chat.Systems;
|
2024-08-01 11:52:27 +03:00
|
|
|
using Content.Shared._CP14.MagicSpell;
|
|
|
|
|
using Content.Shared._CP14.MagicSpell.Components;
|
|
|
|
|
using Content.Shared._CP14.MagicSpell.Events;
|
|
|
|
|
using Robust.Server.GameObjects;
|
2024-07-28 17:26:47 +03:00
|
|
|
|
2024-08-01 11:52:27 +03:00
|
|
|
namespace Content.Server._CP14.MagicSpell;
|
2024-07-28 17:26:47 +03:00
|
|
|
|
|
|
|
|
public sealed partial class CP14MagicSystem : CP14SharedMagicSystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly ChatSystem _chat = default!;
|
2024-08-01 11:52:27 +03:00
|
|
|
[Dependency] private readonly TransformSystem _transform = default!;
|
2024-07-28 17:26:47 +03:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
base.Initialize();
|
|
|
|
|
|
2024-07-28 17:26:47 +03:00
|
|
|
SubscribeLocalEvent<CP14MagicEffectVerbalAspectComponent, CP14VerbalAspectSpeechEvent>(OnSpellSpoken);
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<CP14MagicEffectCastingVisualComponent, CP14StartCastMagicEffectEvent>(OnSpawnMagicVisualEffect);
|
2024-08-02 13:51:54 +03:00
|
|
|
SubscribeLocalEvent<CP14MagicEffectCastingVisualComponent, CP14EndCastMagicEffectEvent>(OnDespawnMagicVisualEffect);
|
2024-07-28 17:26:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSpellSpoken(Entity<CP14MagicEffectVerbalAspectComponent> ent, ref CP14VerbalAspectSpeechEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Performer is not null && args.Speech is not null)
|
2024-08-02 00:48:36 +03:00
|
|
|
_chat.TrySendInGameICMessage(args.Performer.Value, args.Speech, InGameICChatType.Speak, true);
|
2024-07-28 17:26:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSpawnMagicVisualEffect(Entity<CP14MagicEffectCastingVisualComponent> ent, ref CP14StartCastMagicEffectEvent args)
|
|
|
|
|
{
|
2024-11-07 16:04:49 +03:00
|
|
|
var vfx = SpawnAttachedTo(ent.Comp.Proto, Transform(args.Performer).Coordinates);
|
|
|
|
|
_transform.SetParent(vfx, args.Performer);
|
2024-07-28 17:26:47 +03:00
|
|
|
ent.Comp.SpawnedEntity = vfx;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 13:51:54 +03:00
|
|
|
private void OnDespawnMagicVisualEffect(Entity<CP14MagicEffectCastingVisualComponent> ent, ref CP14EndCastMagicEffectEvent args)
|
2024-07-28 17:26:47 +03:00
|
|
|
{
|
|
|
|
|
QueueDel(ent.Comp.SpawnedEntity);
|
|
|
|
|
ent.Comp.SpawnedEntity = null;
|
|
|
|
|
}
|
|
|
|
|
}
|