Gun cleanup (#18682)

This commit is contained in:
metalgearsloth
2023-08-05 12:49:27 +10:00
committed by GitHub
parent 7b71933165
commit a5ed3af5b1
7 changed files with 16 additions and 20 deletions

View File

@@ -56,8 +56,6 @@ public abstract partial class SharedGunSystem : EntitySystem
[Dependency] protected readonly TagSystem TagSystem = default!;
[Dependency] protected readonly ThrowingSystem ThrowingSystem = default!;
protected ISawmill Sawmill = default!;
private const float InteractNextFire = 0.3f;
private const double SafetyNextFire = 0.5;
private const float EjectOffset = 0.4f;
@@ -67,8 +65,6 @@ public abstract partial class SharedGunSystem : EntitySystem
public override void Initialize()
{
Sawmill = Logger.GetSawmill("gun");
Sawmill.Level = LogLevel.Info;
SubscribeAllEvent<RequestShootEvent>(OnShootRequest);
SubscribeAllEvent<RequestStopShootEvent>(OnStopShootRequest);
SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee);
@@ -136,7 +132,7 @@ public abstract partial class SharedGunSystem : EntitySystem
return;
gun.ShootCoordinates = msg.Coordinates;
Sawmill.Debug($"Set shoot coordinates to {gun.ShootCoordinates}");
Log.Debug($"Set shoot coordinates to {gun.ShootCoordinates}");
AttemptShoot(user.Value, ent, gun);
}
@@ -193,10 +189,10 @@ public abstract partial class SharedGunSystem : EntitySystem
if (gun.ShotCounter == 0)
return;
Sawmill.Debug($"Stopped shooting {ToPrettyString(uid)}");
Log.Debug($"Stopped shooting {ToPrettyString(uid)}");
gun.ShotCounter = 0;
gun.ShootCoordinates = null;
Dirty(gun);
Dirty(uid, gun);
}
/// <summary>
@@ -253,7 +249,7 @@ public abstract partial class SharedGunSystem : EntitySystem
}
// NextFire has been touched regardless so need to dirty the gun.
Dirty(gun);
Dirty(gunUid, gun);
// Get how many shots we're actually allowed to make, due to clip size or otherwise.
// Don't do this in the loop so we still reset NextFire.