mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description Ports MODsuits from Goobstation PR https://github.com/Goob-Station/Goob-Station/pull/1242. The PR author has confirmed that he is okay with me doing this. --- # TODO - [X] Port in sprites - [x] Port in YMLs - [X] Port code - [x] Port code PATCHES - [x] Update EE with required fixes --- <details><summary><h1>Media</h1></summary> <p> ## Modsuit crafting https://github.com/user-attachments/assets/8ff03d3a-0fc1-4818-b710-bfc43f0e2a68 ## Modsuit sealing https://github.com/user-attachments/assets/6671459a-7767-499b-8678-062fc1db7134 </p> </details> --- # Changelog 🆑 - add: Modsuits have been ported from Goobstation! --------- Signed-off-by: Eris <erisfiregamer1@gmail.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit cb06c41fc07275e1f15af916babb44368c0c26c2)
90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
using Content.Shared.Actions.Events;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.Actions;
|
|
|
|
/// <summary>
|
|
/// Handles action priming, confirmation and automatic unpriming.
|
|
/// </summary>
|
|
public sealed class ConfirmableActionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly SharedActionsSystem _actions = default!; // Goobstation
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ConfirmableActionComponent, ActionAttemptEvent>(OnAttempt);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
// handle automatic unpriming
|
|
var now = _timing.CurTime;
|
|
var query = EntityQueryEnumerator<ConfirmableActionComponent>();
|
|
while (query.MoveNext(out var uid, out var comp))
|
|
{
|
|
if (comp.NextUnprime is not {} time)
|
|
continue;
|
|
|
|
if (now >= time)
|
|
Unprime((uid, comp));
|
|
}
|
|
}
|
|
|
|
private void OnAttempt(Entity<ConfirmableActionComponent> ent, ref ActionAttemptEvent args)
|
|
{
|
|
if (args.Cancelled)
|
|
return;
|
|
|
|
// if not primed, prime it and cancel the action
|
|
if (ent.Comp.NextConfirm is not {} confirm)
|
|
{
|
|
Prime(ent, args.User);
|
|
args.Cancelled = true;
|
|
return;
|
|
}
|
|
|
|
// primed but the delay isnt over, cancel the action
|
|
if (_timing.CurTime < confirm)
|
|
{
|
|
args.Cancelled = true;
|
|
return;
|
|
}
|
|
|
|
// primed and delay has passed, let the action go through
|
|
Unprime(ent);
|
|
}
|
|
|
|
private void Prime(Entity<ConfirmableActionComponent> ent, EntityUid user)
|
|
{
|
|
var (uid, comp) = ent;
|
|
comp.NextConfirm = _timing.CurTime + comp.ConfirmDelay;
|
|
comp.NextUnprime = comp.NextConfirm + comp.PrimeTime;
|
|
Dirty(uid, comp);
|
|
|
|
// Goobstation - Confirmable action with changed icon - Start
|
|
if (!string.IsNullOrEmpty(comp.Popup))
|
|
_popup.PopupClient(Loc.GetString(comp.Popup), user, user, comp.PopupFontType);
|
|
|
|
_actions.SetToggled(ent, true);
|
|
// Goobstation - Confirmable action with changed icon - End
|
|
}
|
|
|
|
private void Unprime(Entity<ConfirmableActionComponent> ent)
|
|
{
|
|
var (uid, comp) = ent;
|
|
comp.NextConfirm = null;
|
|
comp.NextUnprime = null;
|
|
|
|
_actions.SetToggled(ent, false); // Goobstation - Confirmable action with changed icon
|
|
|
|
Dirty(uid, comp);
|
|
}
|
|
}
|