Space cleaner buffs (#15779)
This commit is contained in:
@@ -4,6 +4,7 @@ using Content.Server.Cooldown;
|
||||
using Content.Server.Extinguisher;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Cooldown;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -50,7 +51,9 @@ public sealed class SpraySystem : EntitySystem
|
||||
var curTime = _gameTiming.CurTime;
|
||||
if (TryComp<ItemCooldownComponent>(uid, out var cooldown)
|
||||
&& curTime < cooldown.CooldownEnd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (solution.Volume <= 0)
|
||||
{
|
||||
@@ -59,26 +62,37 @@ public sealed class SpraySystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryComp<SolutionTransferComponent>(uid, out var transfer))
|
||||
return;
|
||||
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var userXform = xformQuery.GetComponent(args.User);
|
||||
|
||||
var userMapPos = userXform.MapPosition;
|
||||
var clickMapPos = args.ClickLocation.ToMap(EntityManager);
|
||||
var clickMapPos = args.ClickLocation.ToMap(EntityManager, _transform);
|
||||
|
||||
var diffPos = clickMapPos.Position - userMapPos.Position;
|
||||
if (diffPos == Vector2.Zero || diffPos == Vector2.NaN)
|
||||
return;
|
||||
|
||||
var diffLength = diffPos.Length;
|
||||
var diffNorm = diffPos.Normalized;
|
||||
var diffLength = diffPos.Length;
|
||||
|
||||
if (diffLength > component.SprayDistance)
|
||||
{
|
||||
diffLength = component.SprayDistance;
|
||||
}
|
||||
|
||||
var diffAngle = diffNorm.ToAngle();
|
||||
|
||||
// Vectors to determine the spawn offset of the vapor clouds.
|
||||
var threeQuarters = diffNorm * 0.75f;
|
||||
var quarter = diffNorm * 0.25f;
|
||||
|
||||
var amount = Math.Max(Math.Min((solution.Volume / component.TransferAmount).Int(), component.VaporAmount), 1);
|
||||
var amount = Math.Max(Math.Min((solution.Volume / transfer.TransferAmount).Int(), component.VaporAmount), 1);
|
||||
var spread = component.VaporSpread / amount;
|
||||
// TODO: Just use usedelay homie.
|
||||
var cooldownTime = 0f;
|
||||
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
@@ -89,11 +103,11 @@ public sealed class SpraySystem : EntitySystem
|
||||
var target = userMapPos
|
||||
.Offset((diffNorm + rotation.ToVec()).Normalized * diffLength + quarter);
|
||||
|
||||
var distance = target.Position.Length;
|
||||
var distance = (target.Position - userMapPos.Position).Length;
|
||||
if (distance > component.SprayDistance)
|
||||
target = userMapPos.Offset(diffNorm * component.SprayDistance);
|
||||
|
||||
var newSolution = _solutionContainer.SplitSolution(uid, solution, component.TransferAmount);
|
||||
var newSolution = _solutionContainer.SplitSolution(uid, solution, transfer.TransferAmount);
|
||||
|
||||
if (newSolution.Volume <= FixedPoint2.Zero)
|
||||
break;
|
||||
@@ -117,13 +131,16 @@ public sealed class SpraySystem : EntitySystem
|
||||
|
||||
// impulse direction is defined in world-coordinates, not local coordinates
|
||||
var impulseDirection = rotation.ToVec();
|
||||
_vapor.Start(vaporComponent, vaporXform, impulseDirection, component.SprayVelocity, target, component.SprayAliveTime, args.User);
|
||||
var time = diffLength / component.SprayVelocity;
|
||||
cooldownTime = MathF.Max(time, cooldownTime);
|
||||
|
||||
_vapor.Start(vaporComponent, vaporXform, impulseDirection * diffLength, component.SprayVelocity, target, time, args.User);
|
||||
}
|
||||
|
||||
_audio.PlayPvs(component.SpraySound, uid, component.SpraySound.Params.WithVariation(0.125f));
|
||||
|
||||
RaiseLocalEvent(uid,
|
||||
new RefreshItemCooldownEvent(curTime, curTime + TimeSpan.FromSeconds(component.CooldownTime)), true);
|
||||
new RefreshItemCooldownEvent(curTime, curTime + TimeSpan.FromSeconds(cooldownTime)), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user