]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fire extinguisher go brrrrrr (#20479)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Mon, 25 Sep 2023 01:33:29 +0000 (21:33 -0400)
committerGitHub <noreply@github.com>
Mon, 25 Sep 2023 01:33:29 +0000 (21:33 -0400)
Content.Server/Chemistry/EntitySystems/VaporSystem.cs
Content.Server/Fluids/Components/SprayComponent.cs
Content.Server/Fluids/EntitySystems/SpraySystem.cs
Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml

index 7288a993d3cd4c1cb4992a20f1f47b6b62e052d7..8cff8a19cb6b1b7d1d08f6f710b1061dad34d4b1 100644 (file)
@@ -67,7 +67,7 @@ namespace Content.Server.Chemistry.EntitySystems
                 _physics.SetLinearDamping(physics, 0f);
                 _physics.SetAngularDamping(physics, 0f);
 
-                _throwing.TryThrow(vapor.Owner, dir, speed, user: user, pushbackRatio: ThrowingSystem.PushbackDefault * 10f);
+                _throwing.TryThrow(vapor.Owner, dir, speed, user: user);
 
                 var distance = (target.Position - vaporXform.WorldPosition).Length();
                 var time = (distance / physics.LinearVelocity.Length());
index 98e7238889f27decf9510158ebeefb6fe30b6665..e5362eb4e9c680af2ec2f7285f871368ab63da1b 100644 (file)
@@ -2,7 +2,6 @@ using Content.Server.Fluids.EntitySystems;
 using Content.Shared.FixedPoint;
 using Robust.Shared.Audio;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
 
 namespace Content.Server.Fluids.Components;
 
@@ -12,25 +11,31 @@ public sealed partial class SprayComponent : Component
 {
     public const string SolutionName = "spray";
 
-    [DataField("transferAmount")]
+    [ViewVariables(VVAccess.ReadWrite), DataField]
     public FixedPoint2 TransferAmount = 10;
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("sprayDistance")]
+    [ViewVariables(VVAccess.ReadWrite), DataField]
     public float SprayDistance = 3.5f;
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("sprayVelocity")]
+    [ViewVariables(VVAccess.ReadWrite), DataField]
     public float SprayVelocity = 3.5f;
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("sprayedPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
-    public string SprayedPrototype = "Vapor";
+    [ViewVariables(VVAccess.ReadWrite), DataField]
+    public EntProtoId SprayedPrototype = "Vapor";
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("vaporAmount")]
+    [ViewVariables(VVAccess.ReadWrite), DataField]
     public int VaporAmount = 1;
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("vaporSpread")]
+    [ViewVariables(VVAccess.ReadWrite), DataField]
     public float VaporSpread = 90f;
 
-    [ViewVariables(VVAccess.ReadWrite), DataField("spraySound", required: true)]
+    /// <summary>
+    /// How much the player is pushed back for each spray.
+    /// </summary>
+    [ViewVariables(VVAccess.ReadWrite), DataField]
+    public float PushbackAmount = 2f;
+
+    [ViewVariables(VVAccess.ReadWrite), DataField(required: true)]
     [Access(typeof(SpraySystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends
     public SoundSpecifier SpraySound { get; private set; } = default!;
 }
index 0c137caeb46d7fff447425a65e6952bcc981b324..ad17b717e5ff1578fb42e9c07e521d3c20d48f1f 100644 (file)
@@ -4,12 +4,14 @@ 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.Vapor;
 using Robust.Server.GameObjects;
+using Robust.Shared.Physics.Components;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Timing;
 
@@ -19,6 +21,8 @@ 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 PopupSystem _popupSystem = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
@@ -104,7 +108,8 @@ public sealed class SpraySystem : EntitySystem
             if (distance > component.SprayDistance)
                 target = userMapPos.Offset(diffNorm * component.SprayDistance);
 
-            var newSolution = _solutionContainer.SplitSolution(uid, solution, component.TransferAmount);
+            var adjustedSolutionAmount = component.TransferAmount / component.VaporAmount;
+            var newSolution = _solutionContainer.SplitSolution(uid, solution, adjustedSolutionAmount);
 
             if (newSolution.Volume <= FixedPoint2.Zero)
                 break;
@@ -132,6 +137,12 @@ public sealed class SpraySystem : EntitySystem
             cooldownTime = MathF.Max(time, cooldownTime);
 
             _vapor.Start(vaporComponent, vaporXform, impulseDirection * diffLength, component.SprayVelocity, target, time, args.User);
+
+            if (TryComp<PhysicsComponent>(args.User, out var body))
+            {
+                if (_gravity.IsWeightless(args.User, body))
+                    _physics.ApplyLinearImpulse(args.User, -impulseDirection.Normalized() * component.PushbackAmount, body: body);
+            }
         }
 
         _audio.PlayPvs(component.SpraySound, uid, component.SpraySound.Params.WithVariation(0.125f));
index aea2fb7ee153e5d99c6fd95632784baed243fcaa..344d7074439781280f617eb0e9933686c8e6b959 100644 (file)
@@ -27,6 +27,7 @@
   - type: ItemCooldown
   - type: Spray
     transferAmount: 10
+    pushbackAmount: 60
     spraySound:
       path: /Audio/Effects/extinguish.ogg
     sprayedPrototype: ExtinguisherSpray