healing bard spell (#938)

This commit is contained in:
Ed
2025-02-25 15:44:22 +03:00
committed by GitHub
parent 3a0a4c17ea
commit 3e26334c53
16 changed files with 136 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
using Content.Server._CP14.MagicEnergy;
using Content.Server.Atmos.Components;
using Content.Server.Chat.Systems;
using Content.Server.Instruments;
using Content.Shared._CP14.MagicEnergy.Components;
using Content.Shared._CP14.MagicSpell;
using Content.Shared._CP14.MagicSpell.Components;
@@ -39,6 +40,8 @@ public sealed partial class CP14MagicSystem : CP14SharedMagicSystem
SubscribeLocalEvent<CP14MagicEffectCastingVisualComponent, CP14EndCastMagicEffectEvent>(OnDespawnMagicVisualEffect);
SubscribeLocalEvent<CP14MagicEffectManaCostComponent, CP14MagicEffectConsumeResourceEvent>(OnManaConsume);
SubscribeLocalEvent<CP14MagicEffectRequiredMusicToolComponent, CP14CastMagicEffectAttemptEvent>(OnMusicCheck);
}
private void OnProjectileHit(Entity<CP14SpellEffectOnHitComponent> ent, ref ThrowDoHitEvent args)
@@ -140,4 +143,29 @@ public sealed partial class CP14MagicSystem : CP14SharedMagicSystem
_magicEnergy.TryConsumeEnergy(args.Performer.Value, requiredMana, safe: false);
}
}
private void OnMusicCheck(Entity<CP14MagicEffectRequiredMusicToolComponent> ent, ref CP14CastMagicEffectAttemptEvent args)
{
var passed = false;
var query = EntityQueryEnumerator<ActiveInstrumentComponent, InstrumentComponent>();
while (query.MoveNext(out var uid, out var active, out var instrument))
{
if (!instrument.Playing)
continue;
if (Transform(uid).ParentUid != args.Performer)
continue;
passed = true;
break;
}
if (!passed)
{
args.PushReason(Loc.GetString("cp14-magic-music-aspect"));
args.Cancel();
}
}
}