Gun cleanup (#18682)
This commit is contained in:
@@ -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.
|
// 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);
|
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
|
EntityManager.RaisePredictiveEvent(new RequestShootEvent
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
|
|
||||||
if (!ProtoManager.TryIndex<EntityPrototype>(component.FillProto, out var proto))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public abstract partial class SharedGunSystem
|
|||||||
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
|
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
UpdateBallisticAppearance(uid, component);
|
UpdateBallisticAppearance(uid, component);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBallisticAfterInteract(EntityUid uid, BallisticAmmoProviderComponent component, AfterInteractEvent args)
|
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);
|
gunComp.NextFire = Timing.CurTime + TimeSpan.FromSeconds(1 / gunComp.FireRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
Audio.PlayPredicted(component.SoundRack, uid, user);
|
Audio.PlayPredicted(component.SoundRack, uid, user);
|
||||||
|
|
||||||
var shots = GetBallisticShots(component);
|
var shots = GetBallisticShots(component);
|
||||||
@@ -190,7 +190,7 @@ public abstract partial class SharedGunSystem
|
|||||||
if (component.FillProto != null)
|
if (component.FillProto != null)
|
||||||
{
|
{
|
||||||
component.UnspawnedCount = Math.Max(0, component.Capacity - component.Container.ContainedEntities.Count);
|
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);
|
UpdateBallisticAppearance(uid, component);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBallisticAmmoCount(EntityUid uid, BallisticAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
private void OnBallisticAmmoCount(EntityUid uid, BallisticAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public abstract partial class SharedGunSystem
|
|||||||
if (component.Count is null)
|
if (component.Count is null)
|
||||||
{
|
{
|
||||||
component.Count = component.Capacity;
|
component.Count = component.Capacity;
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateBasicEntityAppearance(uid, component);
|
UpdateBasicEntityAppearance(uid, component);
|
||||||
@@ -42,7 +42,7 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
_recharge.Reset(uid);
|
_recharge.Reset(uid);
|
||||||
UpdateBasicEntityAppearance(uid, component);
|
UpdateBasicEntityAppearance(uid, component);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBasicEntityAmmoCount(EntityUid uid, BasicEntityAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
private void OnBasicEntityAmmoCount(EntityUid uid, BasicEntityAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
||||||
@@ -72,7 +72,7 @@ public abstract partial class SharedGunSystem
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
component.Count = count;
|
component.Count = count;
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
UpdateBasicEntityAppearance(uid, component);
|
UpdateBasicEntityAppearance(uid, component);
|
||||||
UpdateAmmoCount(uid);
|
UpdateAmmoCount(uid);
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
TakeCharge(uid, component);
|
TakeCharge(uid, component);
|
||||||
UpdateBatteryAppearance(uid, component);
|
UpdateBatteryAppearance(uid, component);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBatteryAmmoCount(EntityUid uid, BatteryAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
private void OnBatteryAmmoCount(EntityUid uid, BatteryAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public partial class SharedGunSystem
|
|||||||
|
|
||||||
if (ent == null)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public partial class SharedGunSystem
|
|||||||
DebugTools.Assert(ammo.Count == 0);
|
DebugTools.Assert(ammo.Count == 0);
|
||||||
UpdateRevolverAppearance(revolverUid, component);
|
UpdateRevolverAppearance(revolverUid, component);
|
||||||
UpdateAmmoCount(uid);
|
UpdateAmmoCount(uid);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
|
|
||||||
Audio.PlayPredicted(component.SoundInsert, revolverUid, user);
|
Audio.PlayPredicted(component.SoundInsert, revolverUid, user);
|
||||||
Popup(Loc.GetString("gun-revolver-insert"), revolverUid, user);
|
Popup(Loc.GetString("gun-revolver-insert"), revolverUid, user);
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
[Dependency] protected readonly TagSystem TagSystem = default!;
|
[Dependency] protected readonly TagSystem TagSystem = default!;
|
||||||
[Dependency] protected readonly ThrowingSystem ThrowingSystem = default!;
|
[Dependency] protected readonly ThrowingSystem ThrowingSystem = default!;
|
||||||
|
|
||||||
protected ISawmill Sawmill = default!;
|
|
||||||
|
|
||||||
private const float InteractNextFire = 0.3f;
|
private const float InteractNextFire = 0.3f;
|
||||||
private const double SafetyNextFire = 0.5;
|
private const double SafetyNextFire = 0.5;
|
||||||
private const float EjectOffset = 0.4f;
|
private const float EjectOffset = 0.4f;
|
||||||
@@ -67,8 +65,6 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
Sawmill = Logger.GetSawmill("gun");
|
|
||||||
Sawmill.Level = LogLevel.Info;
|
|
||||||
SubscribeAllEvent<RequestShootEvent>(OnShootRequest);
|
SubscribeAllEvent<RequestShootEvent>(OnShootRequest);
|
||||||
SubscribeAllEvent<RequestStopShootEvent>(OnStopShootRequest);
|
SubscribeAllEvent<RequestStopShootEvent>(OnStopShootRequest);
|
||||||
SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee);
|
SubscribeLocalEvent<GunComponent, MeleeHitEvent>(OnGunMelee);
|
||||||
@@ -136,7 +132,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
gun.ShootCoordinates = msg.Coordinates;
|
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);
|
AttemptShoot(user.Value, ent, gun);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,10 +189,10 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
if (gun.ShotCounter == 0)
|
if (gun.ShotCounter == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Sawmill.Debug($"Stopped shooting {ToPrettyString(uid)}");
|
Log.Debug($"Stopped shooting {ToPrettyString(uid)}");
|
||||||
gun.ShotCounter = 0;
|
gun.ShotCounter = 0;
|
||||||
gun.ShootCoordinates = null;
|
gun.ShootCoordinates = null;
|
||||||
Dirty(gun);
|
Dirty(uid, gun);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -253,7 +249,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NextFire has been touched regardless so need to dirty the gun.
|
// 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.
|
// 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.
|
// Don't do this in the loop so we still reset NextFire.
|
||||||
|
|||||||
Reference in New Issue
Block a user