Fix gun ItemStatus (#12225)

This commit is contained in:
metalgearsloth
2022-10-27 01:46:13 +11:00
committed by GitHub
parent 7ef4d117e6
commit f38bef562c
3 changed files with 15 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Examine;
using Content.Shared.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Containers;
@@ -12,16 +13,18 @@ public sealed partial class GunSystem
base.InitializeChamberMagazine();
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, AmmoCounterControlEvent>(OnChamberMagazineCounter);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, UpdateAmmoCounterEvent>(OnChamberMagazineAmmoUpdate);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, EntRemovedFromContainerMessage>(OnChamberEntRemove);
}
private void OnChamberEntRemove(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntRemovedFromContainerMessage args)
protected override void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, ContainerModifiedMessage args)
{
if (args.Container.ID != ChamberSlot) return;
base.OnMagazineSlotChange(uid, component, args);
if (ChamberSlot != args.Container.ID || args is not EntRemovedFromContainerMessage removedArgs)
return;
// This is dirty af. Prediction moment.
// We may be predicting spawning entities and the engine just removes them from the container so we'll just delete them.
if (args.Entity.IsClientSide())
if (removedArgs.Entity.IsClientSide())
QueueDel(args.Entity);
// AFAIK the only main alternative is having some client-specific handling via a bool or otherwise for the state.