Add chasm integration tests (#40286)

* add chasm integration test

* fix assert

* fix

* more fixes

* review
This commit is contained in:
slarticodefast
2025-09-17 06:19:46 +02:00
committed by GitHub
parent fc89f231a5
commit a4368264f0
5 changed files with 336 additions and 28 deletions

View File

@@ -204,38 +204,40 @@ public abstract partial class SharedGunSystem : EntitySystem
/// <summary>
/// Attempts to shoot at the target coordinates. Resets the shot counter after every shot.
/// </summary>
public void AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun, EntityCoordinates toCoordinates, EntityUid? target = null)
public bool AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun, EntityCoordinates toCoordinates, EntityUid? target = null)
{
gun.ShootCoordinates = toCoordinates;
AttemptShoot(user, gunUid, gun);
gun.ShotCounter = 0;
gun.Target = target;
var result = AttemptShoot(user, gunUid, gun);
gun.ShotCounter = 0;
DirtyField(gunUid, gun, nameof(GunComponent.ShotCounter));
return result;
}
/// <summary>
/// Shoots by assuming the gun is the user at default coordinates.
/// </summary>
public void AttemptShoot(EntityUid gunUid, GunComponent gun)
public bool AttemptShoot(EntityUid gunUid, GunComponent gun)
{
var coordinates = new EntityCoordinates(gunUid, gun.DefaultDirection);
gun.ShootCoordinates = coordinates;
AttemptShoot(gunUid, gunUid, gun);
var result = AttemptShoot(gunUid, gunUid, gun);
gun.ShotCounter = 0;
return result;
}
private void AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun)
private bool AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun)
{
if (gun.FireRateModified <= 0f ||
!_actionBlockerSystem.CanAttack(user))
{
return;
return false;
}
var toCoordinates = gun.ShootCoordinates;
if (toCoordinates == null)
return;
return false;
var curTime = Timing.CurTime;
@@ -247,16 +249,16 @@ public abstract partial class SharedGunSystem : EntitySystem
};
RaiseLocalEvent(gunUid, ref prevention);
if (prevention.Cancelled)
return;
return false;
RaiseLocalEvent(user, ref prevention);
if (prevention.Cancelled)
return;
return false;
// Need to do this to play the clicking sound for empty automatic weapons
// but not play anything for burst fire.
if (gun.NextFire > curTime)
return;
return false;
var fireRate = TimeSpan.FromSeconds(1f / gun.FireRateModified);
@@ -315,7 +317,7 @@ public abstract partial class SharedGunSystem : EntitySystem
gun.BurstActivated = false;
gun.BurstShotsCount = 0;
gun.NextFire = TimeSpan.FromSeconds(Math.Max(lastFire.TotalSeconds + SafetyNextFire, gun.NextFire.TotalSeconds));
return;
return false;
}
var fromCoordinates = Transform(user).Coordinates;
@@ -355,10 +357,10 @@ public abstract partial class SharedGunSystem : EntitySystem
// May cause prediction issues? Needs more tweaking
gun.NextFire = TimeSpan.FromSeconds(Math.Max(lastFire.TotalSeconds + SafetyNextFire, gun.NextFire.TotalSeconds));
Audio.PlayPredicted(gun.SoundEmpty, gunUid, user);
return;
return false;
}
return;
return false;
}
// Handle burstfire
@@ -383,13 +385,14 @@ public abstract partial class SharedGunSystem : EntitySystem
RaiseLocalEvent(gunUid, ref shotEv);
if (!userImpulse || !TryComp<PhysicsComponent>(user, out var userPhysics))
return;
return true;
var shooterEv = new ShooterImpulseEvent();
RaiseLocalEvent(user, ref shooterEv);
if (shooterEv.Push)
CauseImpulse(fromCoordinates, toCoordinates.Value, user, userPhysics);
return true;
}
public void Shoot(