mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-23 00:27:50 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> This PR ports https://github.com/Goob-Station/Goob-Station/pull/2409 https://github.com/Goob-Station/Goob-Station/pull/2591 https://github.com/Goob-Station/Goob-Station/pull/2599 This PR was initially intended to be merged into White Dream repo, so my changes are marked as WD edit. <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [ ] Port pain numbness - [ ] Port nullrods - [ ] Port tile movement --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>     </p> </details> --- <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Ported Devil antag from Goobstation --------- Signed-off-by: Kai5 <68296202+Kai518@users.noreply.github.com> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Solstice <solsticeofthewinter@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com>
110 lines
3.6 KiB
C#
110 lines
3.6 KiB
C#
// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
|
|
// SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
|
|
// SPDX-FileCopyrightText: 2025 TheBorzoiMustConsume <197824988+TheBorzoiMustConsume@users.noreply.github.com>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
using System.Linq;
|
|
using Content.Shared._Goobstation.Religion;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Shared._Goobstation.Religion;
|
|
|
|
/// <summary>
|
|
/// Handles "Spell Denial", these methods are largely targeted towards TargetActionEvents, however,
|
|
/// may also have other edge-cases.
|
|
/// </summary>
|
|
public sealed class DivineInterventionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly InventorySystem _inventory = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly INetManager _net = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<BeforeCastTouchSpellEvent>(OnTouchSpellAttempt);
|
|
|
|
SubscribeLocalEvent<DivineInterventionComponent, TouchSpellDenialRelayEvent>(OnTouchSpellDenied);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The bare minimum, no flavor -
|
|
/// used for spells that do not necessarily require players to be notified of an immunity event
|
|
/// </summary>
|
|
public bool ShouldDeny(EntityUid target, out EntityUid? denyingItem)
|
|
{
|
|
denyingItem = _inventory.GetHandOrInventoryEntities(target, SlotFlags.WITHOUT_POCKET)
|
|
.FirstOrDefault(HasComp<DivineInterventionComponent>);
|
|
return !Deleted(denyingItem); // WD edit
|
|
}
|
|
//Overload Method
|
|
public bool ShouldDeny(EntityUid target) => ShouldDeny(target, out _);
|
|
|
|
#region Flavour
|
|
/// <summary>
|
|
/// Handles denial flavour (VFX/SFX/POPUPS)
|
|
/// </summary>
|
|
private void DenialEffects(EntityUid uid, EntityUid? entNullable)
|
|
{
|
|
if (entNullable is not { } ent
|
|
|| !TryComp<DivineInterventionComponent>(uid, out var comp)
|
|
|| _net.IsClient)
|
|
return;
|
|
_popupSystem.PopupEntity(Loc.GetString(comp.DenialString), ent, PopupType.MediumCaution);
|
|
_audio.PlayPvs(comp.DenialSound, ent);
|
|
Spawn(comp.EffectProto, Transform(ent).Coordinates);
|
|
}
|
|
#endregion
|
|
|
|
#region EntityTargetActionEvent Spells
|
|
/// <summary>
|
|
/// Handles EntityTargetActionEvent spells.
|
|
/// </summary>
|
|
private void OnTouchSpellAttempt(BeforeCastTouchSpellEvent args)
|
|
{
|
|
if (args.Target is not { } target)
|
|
return;
|
|
|
|
if (ShouldDeny(target, out var denyingItem)
|
|
&& denyingItem != null
|
|
&& Exists(denyingItem.Value))
|
|
{
|
|
args.Cancel();
|
|
DenialEffects(denyingItem.Value, target);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Relays whether a spell denial took place - especially useful for working between Core & GoobMod
|
|
/// </summary>
|
|
private void OnTouchSpellDenied(EntityUid uid, DivineInterventionComponent comp, TouchSpellDenialRelayEvent args)
|
|
{
|
|
var ev = new BeforeCastTouchSpellEvent(uid);
|
|
RaiseLocalEvent(uid, ev, true);
|
|
|
|
if (ev.Cancelled)
|
|
args.Cancel();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Used where dependency is possible i.e. GoobMod Magic.
|
|
/// </summary>
|
|
public bool TouchSpellDenied(EntityUid uid)
|
|
{
|
|
var ev = new BeforeCastTouchSpellEvent(uid);
|
|
RaiseLocalEvent(uid, ev, true);
|
|
|
|
return ev.Cancelled;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|