mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* PopupClient to PopupEntity/Coordinates * PopupPredictedX to PopupEntity/Cursor/Coordinates * The rest of the damn owl * nullability fixes * Buckle cleanup * cleanup, address PR comments * ExecutionSystem: one popup method * correct my filthy lies * Apply most of ajcm's suggestions * return user to SharedItemRecallSystem.cs * Fix lingering Ensnarable broadcast popups * targeted drain popups * fix lingering untargeted Guardian popups I read the comment on GuardianHostRecall. Oops. * target stethoscope popups * fix the PDA vibration popup * Fix target for encryption key removal popup * anomaly scanner: args.User, not uid * disposal unit comment, bcast pda vibration popup
78 lines
2.7 KiB
C#
78 lines
2.7 KiB
C#
using Content.Shared.Audio;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Trigger;
|
|
using Content.Shared.Weapons.Melee.Events;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.HotPotato;
|
|
|
|
public abstract partial class SharedHotPotatoSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedHandsSystem _hands = default!;
|
|
[Dependency] private SharedPopupSystem _popup = default!;
|
|
[Dependency] private SharedAmbientSoundSystem _ambientSound = default!;
|
|
[Dependency] private DamageOnHoldingSystem _damageOnHolding = default!;
|
|
[Dependency] private IGameTiming _timing = default!;
|
|
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<HotPotatoComponent, ContainerGettingRemovedAttemptEvent>(OnRemoveAttempt);
|
|
SubscribeLocalEvent<HotPotatoComponent, ActiveTimerTriggerEvent>(OnActiveTimer);
|
|
SubscribeLocalEvent<HotPotatoComponent, MeleeHitEvent>(OnMeleeHit);
|
|
}
|
|
|
|
private void OnRemoveAttempt(Entity<HotPotatoComponent> ent, ref ContainerGettingRemovedAttemptEvent args)
|
|
{
|
|
if (!_timing.ApplyingState && !ent.Comp.CanTransfer)
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnActiveTimer(Entity<HotPotatoComponent> ent, ref ActiveTimerTriggerEvent args)
|
|
{
|
|
EnsureComp<ActiveHotPotatoComponent>(ent);
|
|
ent.Comp.CanTransfer = false;
|
|
_ambientSound.SetAmbience(ent.Owner, true);
|
|
_damageOnHolding.SetEnabled(ent.Owner, true);
|
|
Dirty(ent);
|
|
}
|
|
|
|
private void OnMeleeHit(Entity<HotPotatoComponent> ent, ref MeleeHitEvent args)
|
|
{
|
|
if (!HasComp<ActiveHotPotatoComponent>(ent))
|
|
return;
|
|
|
|
ent.Comp.CanTransfer = true;
|
|
foreach (var hitEntity in args.HitEntities)
|
|
{
|
|
if (!TryComp<HandsComponent>(hitEntity, out var hands))
|
|
continue;
|
|
|
|
if (!_hands.IsHolding((hitEntity, hands), ent.Owner, out _) && _hands.TryForcePickupAnyHand(hitEntity, ent.Owner, handsComp: hands))
|
|
{
|
|
_popup.PopupEntity(
|
|
Loc.GetString("hot-potato-passed", ("from", Identity.Entity(args.User, EntityManager)), ("to", Identity.Entity(hitEntity, EntityManager))),
|
|
ent.Owner,
|
|
PopupType.Medium);
|
|
break;
|
|
}
|
|
|
|
_popup.PopupEntity(
|
|
Loc.GetString("hot-potato-failed", ("to", Identity.Entity(hitEntity, EntityManager))),
|
|
ent.Owner,
|
|
args.User,
|
|
PopupType.Medium);
|
|
|
|
break;
|
|
}
|
|
|
|
ent.Comp.CanTransfer = false;
|
|
}
|
|
}
|