From 2375a6cd1d2edfe6692c4a0ad388d2a3f5a3ce01 Mon Sep 17 00:00:00 2001 From: keronshb <54602815+keronshb@users.noreply.github.com> Date: Fri, 12 Jan 2024 23:52:02 -0500 Subject: [PATCH] Moves ShootProjectile to shared (#24007) --- .../Weapons/Ranged/Systems/GunSystem.cs | 20 ------------------ .../Weapons/Ranged/Systems/SharedGunSystem.cs | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index 5f8ab0ecb6..96108c2e12 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -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(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(uid); - Projectiles.SetShooter(uid, projectile, user.Value); - projectile.Weapon = gunUid; - } - - TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle()); - } - /// /// Gets a linear spread of angles between start and end. /// diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index d0d2f04bcf..4e5d8b9762 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -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(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(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); /// -- 2.51.2