Fix SpraySystem (#13924)
This commit is contained in:
@@ -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<SprayComponent, AfterInteractEvent>(OnAfterInteract, after: new []{ typeof(FireExtinguisherSystem) });
|
||||
SubscribeLocalEvent<SprayComponent, AfterInteractEvent>(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<VaporComponent>(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));
|
||||
|
||||
Reference in New Issue
Block a user