From a5ed3af5b14c4ed8e21eda7ccb47768330d9de0e Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 5 Aug 2023 12:49:27 +1000 Subject: [PATCH] Gun cleanup (#18682) --- Content.Client/Weapons/Ranged/Systems/GunSystem.cs | 2 +- Content.Server/Weapons/Ranged/Systems/GunSystem.cs | 2 +- .../Ranged/Systems/SharedGunSystem.Ballistic.cs | 8 ++++---- .../Ranged/Systems/SharedGunSystem.BasicEntity.cs | 6 +++--- .../Ranged/Systems/SharedGunSystem.Battery.cs | 2 +- .../Ranged/Systems/SharedGunSystem.Revolver.cs | 4 ++-- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 12 ++++-------- 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 74ee7bdbbf..1cfcd2a69a 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -164,7 +164,7 @@ public sealed partial class GunSystem : SharedGunSystem // Define target coordinates relative to gun entity, so that network latency on moving grids doesn't fuck up the target location. var coordinates = EntityCoordinates.FromMap(entity, mousePos, TransformSystem, EntityManager); - Sawmill.Debug($"Sending shoot request tick {Timing.CurTick} / {Timing.CurTime}"); + Log.Debug($"Sending shoot request tick {Timing.CurTick} / {Timing.CurTime}"); EntityManager.RaisePredictiveEvent(new RequestShootEvent { diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index be24ef4eee..00bbcc92a1 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -59,7 +59,7 @@ public sealed partial class GunSystem : SharedGunSystem if (!ProtoManager.TryIndex(component.FillProto, out var proto)) { - Sawmill.Error($"Unable to find fill prototype for price on {component.FillProto} on {ToPrettyString(uid)}"); + Log.Error($"Unable to find fill prototype for price on {component.FillProto} on {ToPrettyString(uid)}"); return; } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index 296c260a28..c232264b5c 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -50,7 +50,7 @@ public abstract partial class SharedGunSystem Audio.PlayPredicted(component.SoundInsert, uid, args.User); args.Handled = true; UpdateBallisticAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } private void OnBallisticAfterInteract(EntityUid uid, BallisticAmmoProviderComponent component, AfterInteractEvent args) @@ -161,7 +161,7 @@ public abstract partial class SharedGunSystem gunComp.NextFire = Timing.CurTime + TimeSpan.FromSeconds(1 / gunComp.FireRate); } - Dirty(component); + Dirty(uid, component); Audio.PlayPredicted(component.SoundRack, uid, user); var shots = GetBallisticShots(component); @@ -190,7 +190,7 @@ public abstract partial class SharedGunSystem if (component.FillProto != null) { component.UnspawnedCount = Math.Max(0, component.Capacity - component.Container.ContainedEntities.Count); - Dirty(component); + Dirty(uid, component); } } @@ -252,7 +252,7 @@ public abstract partial class SharedGunSystem } UpdateBallisticAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } private void OnBallisticAmmoCount(EntityUid uid, BallisticAmmoProviderComponent component, ref GetAmmoCountEvent args) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs index 7e459169d8..14aeefb916 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs @@ -18,7 +18,7 @@ public abstract partial class SharedGunSystem if (component.Count is null) { component.Count = component.Capacity; - Dirty(component); + Dirty(uid, component); } UpdateBasicEntityAppearance(uid, component); @@ -42,7 +42,7 @@ public abstract partial class SharedGunSystem _recharge.Reset(uid); UpdateBasicEntityAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } private void OnBasicEntityAmmoCount(EntityUid uid, BasicEntityAmmoProviderComponent component, ref GetAmmoCountEvent args) @@ -72,7 +72,7 @@ public abstract partial class SharedGunSystem return false; component.Count = count; - Dirty(component); + Dirty(uid, component); UpdateBasicEntityAppearance(uid, component); UpdateAmmoCount(uid); diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs index 1d6c85f6f1..5ce43e246b 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs @@ -68,7 +68,7 @@ public abstract partial class SharedGunSystem TakeCharge(uid, component); UpdateBatteryAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } private void OnBatteryAmmoCount(EntityUid uid, BatteryAmmoProviderComponent component, ref GetAmmoCountEvent args) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs index 50a89cb93e..45c133a4a5 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs @@ -127,7 +127,7 @@ public partial class SharedGunSystem if (ent == null) { - Sawmill.Error($"Tried to load hitscan into a revolver which is unsupported"); + Log.Error($"Tried to load hitscan into a revolver which is unsupported"); continue; } @@ -141,7 +141,7 @@ public partial class SharedGunSystem DebugTools.Assert(ammo.Count == 0); UpdateRevolverAppearance(revolverUid, component); UpdateAmmoCount(uid); - Dirty(component); + Dirty(uid, component); Audio.PlayPredicted(component.SoundInsert, revolverUid, user); Popup(Loc.GetString("gun-revolver-insert"), revolverUid, user); diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index a24d2bf358..c72deb5956 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -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(OnShootRequest); SubscribeAllEvent(OnStopShootRequest); SubscribeLocalEvent(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); } /// @@ -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.