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

@@ -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
{

View File

@@ -59,7 +59,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (!ProtoManager.TryIndex<EntityPrototype>(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;
}

View File

@@ -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)

View File

@@ -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);

View File

@@ -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)

View File

@@ -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);

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.