]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Moves ShootProjectile to shared (#24007)
authorkeronshb <54602815+keronshb@users.noreply.github.com>
Sat, 13 Jan 2024 04:52:02 +0000 (23:52 -0500)
committerGitHub <noreply@github.com>
Sat, 13 Jan 2024 04:52:02 +0000 (15:52 +1100)
Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs

index 5f8ab0ecb6e2c2ba1b040cae08d0767faf15d49e..96108c2e122301433549e54b9774e5339c165895 100644 (file)
@@ -313,26 +313,6 @@ public sealed partial class GunSystem : SharedGunSystem
         ShootProjectile(uid, mapDirection, gunVelocity, gunUid, user, gun.ProjectileSpeed);
     }
 
-    public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid gunUid, EntityUid? user = null, float speed = 20f)
-    {
-        var physics = EnsureComp<PhysicsComponent>(uid);
-        Physics.SetBodyStatus(physics, BodyStatus.InAir);
-
-        var targetMapVelocity = gunVelocity + direction.Normalized() * speed;
-        var currentMapVelocity = Physics.GetMapLinearVelocity(uid, physics);
-        var finalLinear = physics.LinearVelocity + targetMapVelocity - currentMapVelocity;
-        Physics.SetLinearVelocity(uid, finalLinear, body: physics);
-
-        if (user != null)
-        {
-            var projectile = EnsureComp<ProjectileComponent>(uid);
-            Projectiles.SetShooter(uid, projectile, user.Value);
-            projectile.Weapon = gunUid;
-        }
-
-        TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle());
-    }
-
     /// <summary>
     /// Gets a linear spread of angles between start and end.
     /// </summary>
index d0d2f04bcfa3a977bf94782f9215df95ac24460a..4e5d8b9762aed1c8c335d7ed4e41b5b25a729e1d 100644 (file)
@@ -1,4 +1,5 @@
 using System.Diagnostics.CodeAnalysis;
+using System.Numerics;
 using Content.Shared.ActionBlocker;
 using Content.Shared.Actions;
 using Content.Shared.Administration.Logs;
@@ -374,6 +375,26 @@ public abstract partial class SharedGunSystem : EntitySystem
         EntityUid? user = null,
         bool throwItems = false);
 
+    public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid gunUid, EntityUid? user = null, float speed = 20f)
+    {
+        var physics = EnsureComp<PhysicsComponent>(uid);
+        Physics.SetBodyStatus(physics, BodyStatus.InAir);
+
+        var targetMapVelocity = gunVelocity + direction.Normalized() * speed;
+        var currentMapVelocity = Physics.GetMapLinearVelocity(uid, physics);
+        var finalLinear = physics.LinearVelocity + targetMapVelocity - currentMapVelocity;
+        Physics.SetLinearVelocity(uid, finalLinear, body: physics);
+
+        if (user != null)
+        {
+            var projectile = EnsureComp<ProjectileComponent>(uid);
+            Projectiles.SetShooter(uid, projectile, user.Value);
+            projectile.Weapon = gunUid;
+        }
+
+        TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle());
+    }
+
     protected abstract void Popup(string message, EntityUid? uid, EntityUid? user);
 
     /// <summary>