Replace ItemSlotChangedEvent with EntInsertedIntoContainerMessage (#11934)

This commit is contained in:
Leon Friedrich
2022-10-16 09:03:37 +13:00
committed by GitHub
parent 8f6b2f4e77
commit 581a805063
3 changed files with 3 additions and 14 deletions

View File

@@ -218,9 +218,6 @@ namespace Content.Shared.Containers.ItemSlots
// ContainerSlot automatically raises a directed EntInsertedIntoContainerMessage
_audioSystem.PlayPredicted(slot.InsertSound, uid, excludeUserAudio ? user : null);
var ev = new ItemSlotChangedEvent();
RaiseLocalEvent(uid, ref ev, true);
}
/// <summary>
@@ -324,8 +321,6 @@ namespace Content.Shared.Containers.ItemSlots
// ContainerSlot automatically raises a directed EntRemovedFromContainerMessage
_audioSystem.PlayPredicted(slot.EjectSound, uid, excludeUserAudio ? user : null, slot.SoundOptions);
var ev = new ItemSlotChangedEvent();
RaiseLocalEvent(uid, ref ev, true);
}
/// <summary>
@@ -606,10 +601,4 @@ namespace Content.Shared.Containers.ItemSlots
args.State = new ItemSlotsComponentState(component.Slots);
}
}
/// <summary>
/// Raised directed on an entity when one of its item slots changes.
/// </summary>
[ByRefEvent]
public readonly struct ItemSlotChangedEvent {}
}

View File

@@ -18,7 +18,7 @@ public abstract partial class SharedGunSystem
{
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, TakeAmmoEvent>(OnChamberMagazineTakeAmmo);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnMagazineVerb);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, ItemSlotChangedEvent>(OnMagazineSlotChange);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnMagazineSlotChange);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, UseInHandEvent>(OnMagazineUse);
SubscribeLocalEvent<ChamberMagazineAmmoProviderComponent, ExaminedEvent>(OnChamberMagazineExamine);
}

View File

@@ -17,7 +17,7 @@ public abstract partial class SharedGunSystem
{
SubscribeLocalEvent<MagazineAmmoProviderComponent, TakeAmmoEvent>(OnMagazineTakeAmmo);
SubscribeLocalEvent<MagazineAmmoProviderComponent, GetVerbsEvent<Verb>>(OnMagazineVerb);
SubscribeLocalEvent<MagazineAmmoProviderComponent, ItemSlotChangedEvent>(OnMagazineSlotChange);
SubscribeLocalEvent<MagazineAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnMagazineSlotChange);
SubscribeLocalEvent<MagazineAmmoProviderComponent, UseInHandEvent>(OnMagazineUse);
SubscribeLocalEvent<MagazineAmmoProviderComponent, ExaminedEvent>(OnMagazineExamine);
}
@@ -55,7 +55,7 @@ public abstract partial class SharedGunSystem
}
}
private void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, ref ItemSlotChangedEvent args)
private void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, EntInsertedIntoContainerMessage args)
{
UpdateAmmoCount(uid);
if (!TryComp<AppearanceComponent>(uid, out var appearance))