Makes projectile speed configurable in gun system (#10535)
This commit is contained in:
@@ -58,14 +58,14 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
for (var i = 0; i < cartridge.Count; i++)
|
||||
{
|
||||
var uid = Spawn(cartridge.Prototype, fromCoordinates);
|
||||
ShootProjectile(uid, angles[i].ToVec(), user);
|
||||
ShootProjectile(uid, angles[i].ToVec(), user, gun.ProjectileSpeed);
|
||||
shotProjectiles.Add(uid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var uid = Spawn(cartridge.Prototype, fromCoordinates);
|
||||
ShootProjectile(uid, mapDirection, user);
|
||||
ShootProjectile(uid, mapDirection, user, gun.ProjectileSpeed);
|
||||
shotProjectiles.Add(uid);
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
{
|
||||
RemComp<AmmoComponent>(newAmmo.Owner);
|
||||
// TODO: Someone can probably yeet this a billion miles so need to pre-validate input somewhere up the call stack.
|
||||
ThrowingSystem.TryThrow(newAmmo.Owner, mapDirection, 20f, user);
|
||||
ThrowingSystem.TryThrow(newAmmo.Owner, mapDirection, gun.ProjectileSpeed, user);
|
||||
break;
|
||||
}
|
||||
|
||||
ShootProjectile(newAmmo.Owner, mapDirection, user);
|
||||
ShootProjectile(newAmmo.Owner, mapDirection, user, gun.ProjectileSpeed);
|
||||
break;
|
||||
case HitscanPrototype hitscan:
|
||||
var ray = new CollisionRay(fromMap.Position, mapDirection.Normalized, hitscan.CollisionMask);
|
||||
@@ -155,11 +155,11 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
}, false);
|
||||
}
|
||||
|
||||
public void ShootProjectile(EntityUid uid, Vector2 direction, EntityUid? user = null)
|
||||
public void ShootProjectile(EntityUid uid, Vector2 direction, EntityUid? user = null, float speed = 20f)
|
||||
{
|
||||
var physics = EnsureComp<PhysicsComponent>(uid);
|
||||
physics.BodyStatus = BodyStatus.InAir;
|
||||
physics.LinearVelocity = direction.Normalized * 20f;
|
||||
physics.LinearVelocity = direction.Normalized * speed;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user