12
Content.Server/Magic/Events/SmiteSpellEvent.cs
Normal file
12
Content.Server/Magic/Events/SmiteSpellEvent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Content.Shared.Actions;
|
||||
|
||||
namespace Content.Server.Magic.Events;
|
||||
|
||||
public sealed class SmiteSpellEvent : EntityTargetActionEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Should this smite delete all parts/mechanisms gibbed except for the brain?
|
||||
/// </summary>
|
||||
[DataField("deleteNonBrainParts")]
|
||||
public bool DeleteNonBrainParts = true;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Decals;
|
||||
using Content.Server.DoAfter;
|
||||
@@ -9,6 +10,7 @@ using Content.Server.Spawners.Components;
|
||||
using Content.Server.Weapon.Ranged.Systems;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.Interaction.Events;
|
||||
@@ -49,6 +51,7 @@ public sealed class MagicSystem : EntitySystem
|
||||
SubscribeLocalEvent<InstantSpawnSpellEvent>(OnInstantSpawn);
|
||||
SubscribeLocalEvent<TeleportSpellEvent>(OnTeleportSpell);
|
||||
SubscribeLocalEvent<KnockSpellEvent>(OnKnockSpell);
|
||||
SubscribeLocalEvent<SmiteSpellEvent>(OnSmiteSpell);
|
||||
SubscribeLocalEvent<WorldSpawnSpellEvent>(OnWorldSpawn);
|
||||
SubscribeLocalEvent<ProjectileSpellEvent>(OnProjectileSpell);
|
||||
}
|
||||
@@ -264,6 +267,30 @@ public sealed class MagicSystem : EntitySystem
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnSmiteSpell(SmiteSpellEvent ev)
|
||||
{
|
||||
if (ev.Handled)
|
||||
return;
|
||||
|
||||
if (!TryComp<BodyComponent>(ev.Target, out var body))
|
||||
return;
|
||||
|
||||
var ents = body.Gib(true);
|
||||
|
||||
if (!ev.DeleteNonBrainParts)
|
||||
return;
|
||||
|
||||
foreach (var part in ents)
|
||||
{
|
||||
// just leaves a brain and clothes
|
||||
if ((HasComp<BodyPartComponent>(part) || HasComp<MechanismComponent>(part))
|
||||
&& !HasComp<BrainComponent>(part))
|
||||
{
|
||||
QueueDel(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns entity prototypes from a list within range of click.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user