Fix gun ItemStatus (#12225)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Weapons.Ranged;
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
using Content.Shared.Weapons.Ranged.Events;
|
using Content.Shared.Weapons.Ranged.Events;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -12,16 +13,18 @@ public sealed partial class GunSystem
|
|||||||
base.InitializeChamberMagazine();
|
base.InitializeChamberMagazine();
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, AmmoCounterControlEvent>(OnChamberMagazineCounter);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, AmmoCounterControlEvent>(OnChamberMagazineCounter);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, UpdateAmmoCounterEvent>(OnChamberMagazineAmmoUpdate);
|
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.
|
// 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.
|
// 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);
|
QueueDel(args.Entity);
|
||||||
|
|
||||||
// AFAIK the only main alternative is having some client-specific handling via a bool or otherwise for the state.
|
// AFAIK the only main alternative is having some client-specific handling via a bool or otherwise for the state.
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Interaction;
|
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
@@ -19,6 +17,7 @@ public abstract partial class SharedGunSystem
|
|||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, TakeAmmoEvent>(OnChamberMagazineTakeAmmo);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, TakeAmmoEvent>(OnChamberMagazineTakeAmmo);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnMagazineVerb);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnMagazineVerb);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnMagazineSlotChange);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnMagazineSlotChange);
|
||||||
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, EntRemovedFromContainerMessage>(OnMagazineSlotChange);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, UseInHandEvent>(OnMagazineUse);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, UseInHandEvent>(OnMagazineUse);
|
||||||
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, ExaminedEvent>(OnChamberMagazineExamine);
|
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, ExaminedEvent>(OnChamberMagazineExamine);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Content.Shared.Containers.ItemSlots;
|
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Interaction;
|
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
@@ -18,6 +16,7 @@ public abstract partial class SharedGunSystem
|
|||||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, TakeAmmoEvent>(OnMagazineTakeAmmo);
|
SubscribeLocalEvent<MagazineAmmoProviderComponent, TakeAmmoEvent>(OnMagazineTakeAmmo);
|
||||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnMagazineVerb);
|
SubscribeLocalEvent<MagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnMagazineVerb);
|
||||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnMagazineSlotChange);
|
SubscribeLocalEvent<MagazineAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnMagazineSlotChange);
|
||||||
|
SubscribeLocalEvent<MagazineAmmoProviderComponent, EntRemovedFromContainerMessage>(OnMagazineSlotChange);
|
||||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, UseInHandEvent>(OnMagazineUse);
|
SubscribeLocalEvent<MagazineAmmoProviderComponent, UseInHandEvent>(OnMagazineUse);
|
||||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, ExaminedEvent>(OnMagazineExamine);
|
SubscribeLocalEvent<MagazineAmmoProviderComponent, ExaminedEvent>(OnMagazineExamine);
|
||||||
}
|
}
|
||||||
@@ -37,7 +36,7 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
if (magEnt == null) return;
|
if (magEnt == null) return;
|
||||||
|
|
||||||
RaiseLocalEvent(magEnt.Value, args, false);
|
RaiseLocalEvent(magEnt.Value, args);
|
||||||
UpdateAmmoCount(uid);
|
UpdateAmmoCount(uid);
|
||||||
UpdateMagazineAppearance(component, magEnt.Value);
|
UpdateMagazineAppearance(component, magEnt.Value);
|
||||||
}
|
}
|
||||||
@@ -50,13 +49,16 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
if (magEnt != null)
|
if (magEnt != null)
|
||||||
{
|
{
|
||||||
RaiseLocalEvent(magEnt.Value, args, false);
|
RaiseLocalEvent(magEnt.Value, args);
|
||||||
UpdateMagazineAppearance(component, magEnt.Value);
|
UpdateMagazineAppearance(component, magEnt.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, EntInsertedIntoContainerMessage args)
|
protected virtual void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, ContainerModifiedMessage args)
|
||||||
{
|
{
|
||||||
|
if (MagazineSlot != args.Container.ID)
|
||||||
|
return;
|
||||||
|
|
||||||
UpdateAmmoCount(uid);
|
UpdateAmmoCount(uid);
|
||||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user