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
59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Friends.Components;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.NPC.Components;
|
|
using Content.Shared.NPC.Systems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Timing;
|
|
|
|
namespace Content.Shared.Friends.Systems;
|
|
|
|
public sealed partial class PettableFriendSystem : EntitySystem
|
|
{
|
|
[Dependency] private NpcFactionSystem _factionException = default!;
|
|
[Dependency] private SharedPopupSystem _popup = default!;
|
|
[Dependency] private UseDelaySystem _useDelay = default!;
|
|
|
|
[Dependency] private EntityQuery<FactionExceptionComponent> _exceptionQuery = default!;
|
|
[Dependency] private EntityQuery<UseDelayComponent> _useDelayQuery = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<PettableFriendComponent, UseInHandEvent>(OnUseInHand);
|
|
SubscribeLocalEvent<PettableFriendComponent, GotRehydratedEvent>(OnRehydrated);
|
|
}
|
|
|
|
private void OnUseInHand(Entity<PettableFriendComponent> ent, ref UseInHandEvent args)
|
|
{
|
|
var (uid, comp) = ent;
|
|
var user = args.User;
|
|
if (args.Handled || !_exceptionQuery.TryComp(uid, out var exceptionComp))
|
|
return;
|
|
|
|
var exception = (uid, exceptionComp);
|
|
if (!_factionException.IsIgnored(exception, user))
|
|
{
|
|
// you have made a new friend :)
|
|
_popup.PopupEntity(Loc.GetString(comp.SuccessString, ("target", uid)), user, user);
|
|
_factionException.IgnoreEntity(exception, user);
|
|
args.Handled = true;
|
|
return;
|
|
}
|
|
|
|
if (_useDelayQuery.TryComp(uid, out var useDelay) && !_useDelay.TryResetDelay((uid, useDelay), true))
|
|
return;
|
|
|
|
_popup.PopupEntity(Loc.GetString(comp.FailureString, ("target", uid)), user, user);
|
|
}
|
|
|
|
private void OnRehydrated(Entity<PettableFriendComponent> ent, ref GotRehydratedEvent args)
|
|
{
|
|
// can only pet before hydrating, after that the fish cannot be negotiated with
|
|
if (!TryComp<FactionExceptionComponent>(ent, out var comp))
|
|
return;
|
|
|
|
_factionException.IgnoreEntities(args.Target, comp.Ignored);
|
|
}
|
|
}
|