Moves ShootProjectile to shared (#24007)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user