protected virtual void DeactivateInternal() { }
- private void OnStartup(EntityUid uid, T component, ComponentStartup args)
+ private void OnStartup(Entity<T> ent, ref ComponentStartup args)
{
- RefreshOverlay(uid);
+ RefreshOverlay();
}
- private void OnRemove(EntityUid uid, T component, ComponentRemove args)
+ private void OnRemove(Entity<T> ent, ref ComponentRemove args)
{
- RefreshOverlay(uid);
+ RefreshOverlay();
}
private void OnPlayerAttached(LocalPlayerAttachedEvent args)
{
- RefreshOverlay(args.Entity);
+ RefreshOverlay();
}
private void OnPlayerDetached(LocalPlayerDetachedEvent args)
{
- if (_player.LocalSession?.AttachedEntity == null)
+ if (_player.LocalSession?.AttachedEntity is null)
Deactivate();
}
- private void OnCompEquip(EntityUid uid, T component, GotEquippedEvent args)
+ private void OnCompEquip(Entity<T> ent, ref GotEquippedEvent args)
{
- RefreshOverlay(args.Equipee);
+ RefreshOverlay();
}
- private void OnCompUnequip(EntityUid uid, T component, GotUnequippedEvent args)
+ private void OnCompUnequip(Entity<T> ent, ref GotUnequippedEvent args)
{
- RefreshOverlay(args.Equipee);
+ RefreshOverlay();
}
private void OnRoundRestart(RoundRestartCleanupEvent args)
Deactivate();
}
- protected virtual void OnRefreshEquipmentHud(EntityUid uid, T component, InventoryRelayedEvent<RefreshEquipmentHudEvent<T>> args)
+ protected virtual void OnRefreshEquipmentHud(Entity<T> ent, ref InventoryRelayedEvent<RefreshEquipmentHudEvent<T>> args)
{
- OnRefreshComponentHud(uid, component, args.Args);
+ OnRefreshComponentHud(ent, ref args.Args);
}
- protected virtual void OnRefreshComponentHud(EntityUid uid, T component, RefreshEquipmentHudEvent<T> args)
+ protected virtual void OnRefreshComponentHud(Entity<T> ent, ref RefreshEquipmentHudEvent<T> args)
{
args.Active = true;
- args.Components.Add(component);
+ args.Components.Add(ent.Comp);
}
- protected void RefreshOverlay(EntityUid uid)
+ protected void RefreshOverlay()
{
- if (uid != _player.LocalSession?.AttachedEntity)
+ if (_player.LocalSession?.AttachedEntity is not { } entity)
return;
var ev = new RefreshEquipmentHudEvent<T>(TargetSlots);
- RaiseLocalEvent(uid, ev);
+ RaiseLocalEvent(entity, ref ev);
if (ev.Active)
Update(ev);
namespace Content.Shared.Inventory.Events;
-public sealed class RefreshEquipmentHudEvent<T> : EntityEventArgs, IInventoryRelayEvent where T : IComponent
+[ByRefEvent]
+public record struct RefreshEquipmentHudEvent<T>(SlotFlags TargetSlots) : IInventoryRelayEvent
+ where T : IComponent
{
- public SlotFlags TargetSlots { get; init; }
+ public SlotFlags TargetSlots { get; } = TargetSlots;
public bool Active = false;
public List<T> Components = new();
-
- public RefreshEquipmentHudEvent(SlotFlags targetSlots)
- {
- TargetSlots = targetSlots;
- }
}
SubscribeLocalEvent<InventoryComponent, SolutionScanEvent>(RelayInventoryEvent);
// ComponentActivatedClientSystems
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowJobIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHealthBarsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHealthIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHungerIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowThirstIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowMindShieldIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowSyndicateIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowCriminalRecordIconsComponent>>(RelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowJobIconsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHealthBarsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHealthIconsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHungerIconsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowThirstIconsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowMindShieldIconsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowSyndicateIconsComponent>>(RefRelayInventoryEvent);
+ SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowCriminalRecordIconsComponent>>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetEquipmentVerbs);
}