Explosives with timers now properly alert admins when detonating (#40471)

* Explosives with timers now properly alert admins when detonating

* add TODO comment

* Check if user is deleted before triggering
This commit is contained in:
beck-thompson
2025-10-04 10:51:36 -07:00
committed by GitHub
parent cad61d62e1
commit 7e3ee1d7c6
3 changed files with 4 additions and 1 deletions

View File

@@ -75,6 +75,7 @@ public sealed partial class TimerTriggerComponent : Component
/// <summary> /// <summary>
/// The entity that activated this trigger. /// The entity that activated this trigger.
/// TODO: use WeakEntityReference once the engine PR is merged!
/// </summary> /// </summary>
[DataField, AutoNetworkedField] [DataField, AutoNetworkedField]
public EntityUid? User; public EntityUid? User;

View File

@@ -168,7 +168,8 @@ public sealed partial class TriggerSystem
if (timer.NextTrigger <= curTime) if (timer.NextTrigger <= curTime)
{ {
Trigger(uid, timer.User, timer.KeyOut); var user = TerminatingOrDeleted(timer.User) ? null : timer.User;
Trigger(uid, user, timer.KeyOut);
// Remove after triggering to prevent it from starting the timer again // Remove after triggering to prevent it from starting the timer again
RemComp<ActiveTimerTriggerComponent>(uid); RemComp<ActiveTimerTriggerComponent>(uid);
if (TryComp<AppearanceComponent>(uid, out var appearance)) if (TryComp<AppearanceComponent>(uid, out var appearance))

View File

@@ -107,6 +107,7 @@ public sealed partial class TriggerSystem : EntitySystem
ent.Comp.NextTrigger = curTime + ent.Comp.Delay; ent.Comp.NextTrigger = curTime + ent.Comp.Delay;
var delay = ent.Comp.InitialBeepDelay ?? ent.Comp.BeepInterval; var delay = ent.Comp.InitialBeepDelay ?? ent.Comp.BeepInterval;
ent.Comp.NextBeep = curTime + delay; ent.Comp.NextBeep = curTime + delay;
ent.Comp.User = user;
Dirty(ent); Dirty(ent);
var ev = new ActiveTimerTriggerEvent(user); var ev = new ActiveTimerTriggerEvent(user);