From 012062e81c84f125de68ffc7f09a8042d45f407f Mon Sep 17 00:00:00 2001 From: Visne <39844191+Visne@users.noreply.github.com> Date: Sat, 4 Feb 2023 23:39:47 +0100 Subject: [PATCH] Fix SpraySystem (#13924) --- .../Fluids/EntitySystems/SpraySystem.cs | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Content.Server/Fluids/EntitySystems/SpraySystem.cs b/Content.Server/Fluids/EntitySystems/SpraySystem.cs index a5c08d78ab..5ba11b5dd3 100644 --- a/Content.Server/Fluids/EntitySystems/SpraySystem.cs +++ b/Content.Server/Fluids/EntitySystems/SpraySystem.cs @@ -4,15 +4,11 @@ using Content.Server.Cooldown; using Content.Server.Extinguisher; using Content.Server.Fluids.Components; using Content.Server.Popups; -using Content.Shared.Audio; using Content.Shared.Cooldown; using Content.Shared.FixedPoint; using Content.Shared.Interaction; using Content.Shared.Vapor; using Robust.Server.GameObjects; -using Robust.Shared.Audio; -using Robust.Shared.Map; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -24,15 +20,16 @@ public sealed class SpraySystem : EntitySystem [Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; - [Dependency] private readonly VaporSystem _vaporSystem = 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!; public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnAfterInteract, after: new []{ typeof(FireExtinguisherSystem) }); + SubscribeLocalEvent(OnAfterInteract, after: new[] { typeof(FireExtinguisherSystem) }); } private void OnAfterInteract(EntityUid uid, SprayComponent component, AfterInteractEvent args) @@ -42,11 +39,11 @@ public sealed class SpraySystem : EntitySystem args.Handled = true; - if (!_solutionContainerSystem.TryGetSolution(uid, SprayComponent.SolutionName, out var solution)) + if (!_solutionContainer.TryGetSolution(uid, SprayComponent.SolutionName, out var solution)) return; var ev = new SprayAttemptEvent(args.User); - RaiseLocalEvent(uid, ev, false); + RaiseLocalEvent(uid, ev); if (ev.Cancelled) return; @@ -96,7 +93,7 @@ public sealed class SpraySystem : EntitySystem if (distance > component.SprayDistance) target = userMapPos.Offset(diffNorm * component.SprayDistance); - var newSolution = _solutionContainerSystem.SplitSolution(uid, solution, component.TransferAmount); + var newSolution = _solutionContainer.SplitSolution(uid, solution, component.TransferAmount); if (newSolution.Volume <= FixedPoint2.Zero) break; @@ -106,21 +103,21 @@ public sealed class SpraySystem : EntitySystem var vapor = Spawn(component.SprayedPrototype, vaporPos); var vaporXform = xformQuery.GetComponent(vapor); - vaporXform.WorldRotation = rotation; + _transform.SetWorldRotation(vaporXform, rotation); if (TryComp(vapor, out AppearanceComponent? appearance)) { - _appearance.SetData(uid, VaporVisuals.Color, solution.GetColor(_proto).WithAlpha(1f), appearance); - _appearance.SetData(uid, VaporVisuals.State, true, appearance); + _appearance.SetData(vapor, VaporVisuals.Color, solution.GetColor(_proto).WithAlpha(1f), appearance); + _appearance.SetData(vapor, VaporVisuals.State, true, appearance); } // Add the solution to the vapor and actually send the thing var vaporComponent = Comp(vapor); - _vaporSystem.TryAddSolution(vaporComponent, newSolution); + _vapor.TryAddSolution(vaporComponent, newSolution); // impulse direction is defined in world-coordinates, not local coordinates var impulseDirection = rotation.ToVec(); - _vaporSystem.Start(vaporComponent, vaporXform, impulseDirection, component.SprayVelocity, target, component.SprayAliveTime, args.User); + _vapor.Start(vaporComponent, vaporXform, impulseDirection, component.SprayVelocity, target, component.SprayAliveTime, args.User); } _audio.PlayPvs(component.SpraySound, uid, component.SpraySound.Params.WithVariation(0.125f));