UseDelay + ItemCooldown merge (#22502)
This commit is contained in:
@@ -1,36 +1,34 @@
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Cooldown;
|
||||
using Content.Server.Extinguisher;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Gravity;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Cooldown;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Timing;
|
||||
using Content.Shared.Vapor;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems;
|
||||
|
||||
public sealed class SpraySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly GravitySystem _gravity = default!;
|
||||
[Dependency] private readonly PhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
|
||||
[Dependency] private readonly VaporSystem _vapor = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -54,12 +52,9 @@ public sealed class SpraySystem : EntitySystem
|
||||
if (ev.Cancelled)
|
||||
return;
|
||||
|
||||
var curTime = _gameTiming.CurTime;
|
||||
if (TryComp<ItemCooldownComponent>(entity, out var cooldown)
|
||||
&& curTime < cooldown.CooldownEnd)
|
||||
{
|
||||
if (!TryComp<UseDelayComponent>(entity, out var useDelay)
|
||||
|| _useDelay.IsDelayed((entity, useDelay)))
|
||||
return;
|
||||
}
|
||||
|
||||
if (solution.Volume <= 0)
|
||||
{
|
||||
@@ -70,7 +65,7 @@ public sealed class SpraySystem : EntitySystem
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var userXform = xformQuery.GetComponent(args.User);
|
||||
|
||||
var userMapPos = userXform.MapPosition;
|
||||
var userMapPos = _transform.GetMapCoordinates(userXform);
|
||||
var clickMapPos = args.ClickLocation.ToMap(EntityManager, _transform);
|
||||
|
||||
var diffPos = clickMapPos.Position - userMapPos.Position;
|
||||
@@ -149,7 +144,8 @@ public sealed class SpraySystem : EntitySystem
|
||||
|
||||
_audio.PlayPvs(entity.Comp.SpraySound, entity, entity.Comp.SpraySound.Params.WithVariation(0.125f));
|
||||
|
||||
RaiseLocalEvent(entity, new RefreshItemCooldownEvent(curTime, curTime + TimeSpan.FromSeconds(cooldownTime)), true);
|
||||
_useDelay.SetDelay((entity, useDelay), TimeSpan.FromSeconds(cooldownTime));
|
||||
_useDelay.TryResetDelay((entity, useDelay));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user