Adds grappling gun (#16662)
This commit is contained in:
@@ -313,15 +313,16 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
}
|
||||
|
||||
// Shoot confirmed - sounds also played here in case it's invalid (e.g. cartridge already spent).
|
||||
Shoot(gunUid, gun, ev.Ammo, fromCoordinates, toCoordinates.Value, user, throwItems: attemptEv.ThrowItems);
|
||||
var shotEv = new GunShotEvent(user);
|
||||
Shoot(gunUid, gun, ev.Ammo, fromCoordinates, toCoordinates.Value, out var userImpulse, user, throwItems: attemptEv.ThrowItems);
|
||||
var shotEv = new GunShotEvent(user, ev.Ammo);
|
||||
RaiseLocalEvent(gunUid, ref shotEv);
|
||||
// Projectiles cause impulses especially important in non gravity environments
|
||||
if (TryComp<PhysicsComponent>(user, out var userPhysics))
|
||||
|
||||
if (userImpulse && TryComp<PhysicsComponent>(user, out var userPhysics))
|
||||
{
|
||||
if (_gravity.IsWeightless(user, userPhysics))
|
||||
CauseImpulse(fromCoordinates, toCoordinates.Value, user, userPhysics);
|
||||
}
|
||||
|
||||
Dirty(gun);
|
||||
}
|
||||
|
||||
@@ -331,11 +332,12 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
EntityUid ammo,
|
||||
EntityCoordinates fromCoordinates,
|
||||
EntityCoordinates toCoordinates,
|
||||
out bool userImpulse,
|
||||
EntityUid? user = null,
|
||||
bool throwItems = false)
|
||||
{
|
||||
var shootable = EnsureComp<AmmoComponent>(ammo);
|
||||
Shoot(gunUid, gun, new List<(EntityUid? Entity, IShootable Shootable)>(1) { (ammo, shootable) }, fromCoordinates, toCoordinates, user, throwItems);
|
||||
Shoot(gunUid, gun, new List<(EntityUid? Entity, IShootable Shootable)>(1) { (ammo, shootable) }, fromCoordinates, toCoordinates, out userImpulse, user, throwItems);
|
||||
}
|
||||
|
||||
public abstract void Shoot(
|
||||
@@ -344,6 +346,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
List<(EntityUid? Entity, IShootable Shootable)> ammo,
|
||||
EntityCoordinates fromCoordinates,
|
||||
EntityCoordinates toCoordinates,
|
||||
out bool userImpulse,
|
||||
EntityUid? user = null,
|
||||
bool throwItems = false);
|
||||
|
||||
@@ -436,7 +439,7 @@ public record struct AttemptShootEvent(EntityUid User, string? Message, bool Can
|
||||
/// </summary>
|
||||
/// <param name="User">The user that fired this gun.</param>
|
||||
[ByRefEvent]
|
||||
public record struct GunShotEvent(EntityUid User);
|
||||
public record struct GunShotEvent(EntityUid User, List<(EntityUid? Uid, IShootable Shootable)> Ammo);
|
||||
|
||||
public enum EffectLayers : byte
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user