]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Throwing tweaks (#16266)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 12 May 2023 23:54:37 +0000 (09:54 +1000)
committerGitHub <noreply@github.com>
Fri, 12 May 2023 23:54:37 +0000 (19:54 -0400)
- Cartridge bounds decreased.
- Throwing pushback scales based on entity mass.

Content.Server/Chemistry/EntitySystems/VaporSystem.cs
Content.Shared/Throwing/ThrowingSystem.cs
Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/base_cartridge.yml

index 8fd6d315729ccf0000b704410452211e3f8ce7ad..edbaffb5a57fa6a788ba399bfa2467deb50d121d 100644 (file)
@@ -63,7 +63,7 @@ namespace Content.Server.Chemistry.EntitySystems
                 _physics.SetLinearDamping(physics, 0f);
                 _physics.SetAngularDamping(physics, 0f);
 
-                _throwing.TryThrow(vapor.Owner, dir, speed, user: user, pushbackRatio: 50f);
+                _throwing.TryThrow(vapor.Owner, dir, speed, user: user, pushbackRatio: ThrowingSystem.PushbackDefault * 10f);
 
                 var distance = (target.Position - vaporXform.WorldPosition).Length;
                 var time = (distance / physics.LinearVelocity.Length);
index 5b8f6b335a57a8fe1ebf785642852f2746f53f82..3035411148294a918c9c1ac8d71610806e0bf8df 100644 (file)
@@ -12,7 +12,9 @@ namespace Content.Shared.Throwing;
 
 public sealed class ThrowingSystem : EntitySystem
 {
-    public const float ThrowAngularImpulse = 1.5f;
+    public const float ThrowAngularImpulse = 5f;
+
+    public const float PushbackDefault = 1f;
 
     /// <summary>
     /// The minimum amount of time an entity needs to be thrown before the timer can be run.
@@ -37,7 +39,7 @@ public sealed class ThrowingSystem : EntitySystem
         Vector2 direction,
         float strength = 1.0f,
         EntityUid? user = null,
-        float pushbackRatio = 5.0f)
+        float pushbackRatio = PushbackDefault)
     {
         var physicsQuery = GetEntityQuery<PhysicsComponent>();
         if (!physicsQuery.TryGetComponent(uid, out var physics))
@@ -73,7 +75,7 @@ public sealed class ThrowingSystem : EntitySystem
         EntityQuery<TagComponent> tagQuery,
         float strength = 1.0f,
         EntityUid? user = null,
-        float pushbackRatio = 5.0f)
+        float pushbackRatio = PushbackDefault)
     {
         if (strength <= 0 || direction == Vector2.Infinity || direction == Vector2.NaN || direction == Vector2.Zero)
             return;
@@ -92,7 +94,7 @@ public sealed class ThrowingSystem : EntitySystem
 
         // Give it a l'il spin.
         if (!tagQuery.TryGetComponent(uid, out var tag) || !_tagSystem.HasTag(tag, "NoSpinOnThrow"))
-            _physics.ApplyAngularImpulse(uid, ThrowAngularImpulse, body: physics);
+            _physics.ApplyAngularImpulse(uid, ThrowAngularImpulse / physics.InvI, body: physics);
         else
             transform.LocalRotation = direction.ToWorldAngle() - Math.PI;
 
@@ -124,7 +126,8 @@ public sealed class ThrowingSystem : EntitySystem
 
         // Give thrower an impulse in the other direction
         if (user != null &&
-            pushbackRatio > 0.0f &&
+            pushbackRatio != 0.0f &&
+            physics.Mass > 0f &&
             TryComp(user.Value, out PhysicsComponent? userPhysics) &&
             _gravity.IsWeightless(user.Value, userPhysics))
         {
@@ -132,7 +135,7 @@ public sealed class ThrowingSystem : EntitySystem
             RaiseLocalEvent(uid, msg);
 
             if (!msg.Cancelled)
-                _physics.ApplyLinearImpulse(user.Value, -impulseVector * pushbackRatio, body: userPhysics);
+                _physics.ApplyLinearImpulse(user.Value, -impulseVector * pushbackRatio * physics.Mass, body: userPhysics);
         }
     }
 }
index 230be6a76b318f54c985e21d8155f15137daf842..504633fb8430a53d75330812e555c33f4bcc2222 100644 (file)
@@ -6,6 +6,17 @@
   - type: Sprite
     drawdepth: Items
     netsync: false
+  - type: Fixtures
+    fixtures:
+      fix1:
+        shape:
+          !type:PhysShapeAabb
+          bounds: "-0.10,-0.05,0.10,0.05"
+        density: 20
+        mask:
+          - ItemMask
+        restitution: 0.3  # fite me
+        friction: 0.2
   - type: Tag
     tags:
     - Cartridge