mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-20 15:08:46 +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>
120 lines
4.4 KiB
C#
120 lines
4.4 KiB
C#
// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
|
|
// SPDX-FileCopyrightText: 2025 Solstice <solsticeofthewinter@gmail.com>
|
|
// SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
using Content.Shared._Goobstation.Devil;
|
|
using Content.Shared._Goobstation.Devil.Condemned;
|
|
using Content.Shared._Goobstation.Devil.UI;
|
|
using Content.Server.Administration.Systems;
|
|
using Content.Server.Mind;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Popups;
|
|
using Robust.Server.GameObjects;
|
|
|
|
namespace Content.Server._Goobstation.Devil.Contract.Revival;
|
|
public sealed partial class PendingRevivalContractSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
|
|
[Dependency] private readonly RejuvenateSystem _rejuvenate = default!;
|
|
[Dependency] private readonly DevilContractSystem _contract = default!;
|
|
[Dependency] private readonly MindSystem _mind = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<RevivalContractComponent, AfterInteractEvent>(AfterInteract);
|
|
SubscribeLocalEvent<PendingRevivalContractComponent, RevivalContractMessage>(OnMessage);
|
|
}
|
|
|
|
private void AfterInteract(Entity<RevivalContractComponent> ent, ref AfterInteractEvent args)
|
|
{
|
|
if (args.Target is not { } target
|
|
|| !TryComp<MobStateComponent>(target, out var mobState)
|
|
|| mobState.CurrentState != MobState.Dead)
|
|
return;
|
|
|
|
// Non-devils can't offer deals silly.
|
|
if (!HasComp<DevilComponent>(args.User))
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("devil-sign-invalid-user"), args.User, PopupType.MediumCaution);
|
|
return;
|
|
}
|
|
|
|
// Make sure the mind actually exists
|
|
if (!_mind.TryGetMind(target, out var mindId, out var mindComp) || mindComp.CurrentEntity is not { } ghost)
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("revival-contract-no-mind"), args.User, args.User);
|
|
return;
|
|
}
|
|
|
|
// You can't offer two deals at once.
|
|
if (HasComp<PendingRevivalContractComponent>(ghost) || HasComp<CondemnedComponent>(target))
|
|
{
|
|
var failedPopup = Loc.GetString("revival-contract-use-failed");
|
|
_popupSystem.PopupEntity(failedPopup, args.User, args.User);
|
|
return;
|
|
}
|
|
|
|
// Create pending contract
|
|
var pending = EnsureComp<PendingRevivalContractComponent>(ghost);
|
|
pending.Contractee = target;
|
|
pending.Offerer = args.User;
|
|
pending.Contract = ent;
|
|
pending.MindId = mindId;
|
|
|
|
// Show confirmation
|
|
var successPopup = Loc.GetString("revival-contract-use-success", ("target", target));
|
|
_popupSystem.PopupEntity(successPopup, args.User, args.User);
|
|
|
|
ent.Comp.Signer = target;
|
|
ent.Comp.ContractOwner = args.User;
|
|
|
|
TryOpenUi(ghost);
|
|
}
|
|
|
|
private bool TryOpenUi(EntityUid target)
|
|
{
|
|
if (!_userInterface.HasUi(target, RevivalContractUiKey.Key))
|
|
return false;
|
|
|
|
if (_mind.TryGetMind(target, out _, out var mindComp) && mindComp.Session is { } session)
|
|
_userInterface.OpenUi(target, RevivalContractUiKey.Key, session);
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnMessage(Entity<PendingRevivalContractComponent> ent, ref RevivalContractMessage args)
|
|
{
|
|
if (args.Accepted && ent.Comp.Contractee is { } contractee)
|
|
{
|
|
TryReviveAndTransferSoul(contractee, ent.Comp);
|
|
_mind.UnVisit(ent.Comp.MindId);
|
|
}
|
|
|
|
RemComp<PendingRevivalContractComponent>(args.Actor);
|
|
}
|
|
|
|
private bool TryReviveAndTransferSoul(EntityUid target, PendingRevivalContractComponent pending)
|
|
{
|
|
if (TerminatingOrDeleted(target))
|
|
return false;
|
|
|
|
if (TryComp<RevivalContractComponent>(pending.Contract, out var contract) && contract is { ContractOwner: { Valid: true } contractOwner, Signer: { } signer })
|
|
{
|
|
_rejuvenate.PerformRejuvenate(target);
|
|
_popupSystem.PopupEntity(Loc.GetString("revival-contract-accepted"), target, target);
|
|
_contract.TryTransferSouls(contractOwner, signer, 1);
|
|
}
|
|
|
|
RemComp(target, pending);
|
|
return true;
|
|
}
|
|
|
|
}
|