Eject casings some distance from the gun (#18081)
Makes bullet casings launch a bit away from you when shooting a gun. Cycling still drops it at your feet. --------- Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
@@ -377,6 +377,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
/// </summary>
|
||||
protected void EjectCartridge(
|
||||
EntityUid entity,
|
||||
Angle? angle = null,
|
||||
bool playSound = true)
|
||||
{
|
||||
// TODO: Sound limit version.
|
||||
@@ -389,6 +390,13 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
TransformSystem.SetLocalRotation(xform, Random.NextAngle());
|
||||
TransformSystem.SetCoordinates(entity, xform, coordinates);
|
||||
|
||||
// decides direction the casing ejects and only when not cycling
|
||||
if (angle != null)
|
||||
{
|
||||
Angle ejectAngle = angle.Value;
|
||||
ejectAngle += 3.7f; // 212 degrees; casings should eject slightly to the right and behind of a gun
|
||||
ThrowingSystem.TryThrow(entity, ejectAngle.ToVec().Normalized() / 100, 5f);
|
||||
}
|
||||
if (playSound && TryComp<CartridgeAmmoComponent>(entity, out var cartridge))
|
||||
{
|
||||
Audio.PlayPvs(cartridge.EjectSound, entity, AudioParams.Default.WithVariation(0.05f).WithVolume(-1f));
|
||||
|
||||
Reference in New Issue
Block a user