UseDelay + ItemCooldown merge (#22502)

This commit is contained in:
AJCM-git
2024-01-03 21:33:09 -04:00
committed by GitHub
parent 42ec9b2967
commit 9c522c8b19
80 changed files with 324 additions and 589 deletions

View File

@@ -5,9 +5,7 @@ using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Timing;
using Content.Shared.Tools;
using Content.Shared.Tools.Systems;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using SignalReceivedEvent = Content.Server.DeviceLinking.Events.SignalReceivedEvent;
@@ -74,7 +72,8 @@ public sealed class LogicGateSystem : EntitySystem
return;
// no sound spamming
if (TryComp<UseDelayComponent>(uid, out var useDelay) && _useDelay.ActiveDelay(uid, useDelay))
if (TryComp<UseDelayComponent>(uid, out var useDelay)
&& !_useDelay.TryResetDelay((uid, useDelay), true))
return;
// cycle through possible gates
@@ -90,8 +89,6 @@ public sealed class LogicGateSystem : EntitySystem
var msg = Loc.GetString("logic-gate-cycle", ("gate", comp.Gate.ToString().ToUpper()));
_popup.PopupEntity(msg, uid, args.User);
_appearance.SetData(uid, LogicGateVisuals.Gate, comp.Gate);
_useDelay.BeginDelay(uid, useDelay);
}
private void OnSignalReceived(EntityUid uid, LogicGateComponent comp, ref SignalReceivedEvent args)

View File

@@ -1,5 +1,4 @@
using Content.Server.DeviceLinking.Components;
using Content.Server.DeviceNetwork;
using Content.Server.NodeContainer;
using Content.Server.Power.EntitySystems;
using Content.Server.Power.Nodes;
@@ -9,10 +8,9 @@ using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Power.Generator;
using Content.Shared.Timing;
using Content.Shared.Tools;
using Content.Shared.Tools.Systems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Timing;
namespace Content.Server.DeviceLinking.Systems;
@@ -21,7 +19,6 @@ public sealed class PowerSensorSystem : EntitySystem
{
[Dependency] private readonly DeviceLinkSystem _deviceLink = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly PowerNetSystem _powerNet = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
@@ -76,7 +73,8 @@ public sealed class PowerSensorSystem : EntitySystem
return;
// no sound spamming
if (TryComp<UseDelayComponent>(uid, out var useDelay) && _useDelay.ActiveDelay(uid, useDelay))
if (TryComp<UseDelayComponent>(uid, out var useDelay)
&& !_useDelay.TryResetDelay((uid, useDelay), true))
return;
// switch between input and output mode.
@@ -89,8 +87,6 @@ public sealed class PowerSensorSystem : EntitySystem
_audio.PlayPvs(comp.SwitchSound, uid);
var msg = Loc.GetString("power-sensor-switch", ("output", comp.Output));
_popup.PopupEntity(msg, uid, args.User);
_useDelay.BeginDelay(uid, useDelay);
}
private void UpdateOutputs(EntityUid uid, PowerSensorComponent comp)
@@ -107,7 +103,9 @@ public sealed class PowerSensorSystem : EntitySystem
// update state based on the power stats retrieved from the selected power network
var xform = _xformQuery.GetComponent(uid);
_mapManager.TryGetGrid(xform.GridUid, out var grid);
if (!TryComp(xform.GridUid, out MapGridComponent? grid))
return;
var cables = deviceNode.GetReachableNodes(xform, _nodeQuery, _xformQuery, grid, EntityManager);
foreach (var node in cables)
{

View File

@@ -39,15 +39,12 @@ public sealed class SignallerSystem : EntitySystem
private void OnTrigger(EntityUid uid, SignallerComponent component, TriggerEvent args)
{
// if on cooldown, do nothing
var hasUseDelay = TryComp<UseDelayComponent>(uid, out var useDelay);
if (hasUseDelay && _useDelay.ActiveDelay(uid, useDelay))
if (!TryComp(uid, out UseDelayComponent? useDelay)
// if on cooldown, do nothing
// and set cooldown to prevent clocks
|| !_useDelay.TryResetDelay((uid, useDelay), true))
return;
// set cooldown to prevent clocks
if (hasUseDelay)
_useDelay.BeginDelay(uid, useDelay);
_link.InvokePort(uid, component.Port);
args.Handled = true;
}