From de1f13de9e99bac9633ba9b768a196366357b8ed Mon Sep 17 00:00:00 2001 From: Whatstone Date: Sun, 19 Jan 2025 10:45:53 -0500 Subject: [PATCH] PickedUpEvent vs. GettingPickedUp, no Has then Rem --- .../EntitySystems/AddAccentClothingSystem.cs | 5 +---- .../EntitySystems/AddAccentPickupSystem.cs | 19 ++++++------------- .../EntitySystems/SharedHandsSystem.Pickup.cs | 2 +- Content.Shared/_NF/Item/PickupEvent.cs | 6 +++--- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Content.Server/Speech/EntitySystems/AddAccentClothingSystem.cs b/Content.Server/Speech/EntitySystems/AddAccentClothingSystem.cs index 9e393798408..96cb28d9e1e 100644 --- a/Content.Server/Speech/EntitySystems/AddAccentClothingSystem.cs +++ b/Content.Server/Speech/EntitySystems/AddAccentClothingSystem.cs @@ -74,10 +74,7 @@ private void ToggleAccent(EntityUid uid, AddAccentClothingComponent component) { // try to remove the accent if it's enabled var componentType = _componentFactory.GetRegistration(component.Accent).Type; - if (EntityManager.HasComponent(component.Wearer, componentType)) - { - EntityManager.RemoveComponent(component.Wearer, componentType); - } + RemComp(component.Wearer, componentType); component.IsActive = false; // we don't wipe out wearer in this case } diff --git a/Content.Server/_NF/Speech/EntitySystems/AddAccentPickupSystem.cs b/Content.Server/_NF/Speech/EntitySystems/AddAccentPickupSystem.cs index 5f26d3ef112..6401b0bccf8 100644 --- a/Content.Server/_NF/Speech/EntitySystems/AddAccentPickupSystem.cs +++ b/Content.Server/_NF/Speech/EntitySystems/AddAccentPickupSystem.cs @@ -13,12 +13,12 @@ public sealed class AddAccentPickupSystem : EntitySystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnPickup); + SubscribeLocalEvent(OnPickup); SubscribeLocalEvent(OnDropped); SubscribeLocalEvent>(OnGetAltVerbs); } - private void OnPickup(EntityUid uid, AddAccentPickupComponent component, ref GettingPickedUpEvent args) + private void OnPickup(EntityUid uid, AddAccentPickupComponent component, ref PickedUpEvent args) { // does the user already has this accent? var componentType = _componentFactory.GetRegistration(component.Accent).Type; @@ -26,7 +26,7 @@ private void OnPickup(EntityUid uid, AddAccentPickupComponent component, ref Get return; // add accent to the user - var accentComponent = (Component) _componentFactory.GetComponent(componentType); + var accentComponent = (Component)_componentFactory.GetComponent(componentType); AddComp(args.User, accentComponent); // snowflake case for replacement accent @@ -45,10 +45,7 @@ private void OnDropped(EntityUid uid, AddAccentPickupComponent component, Droppe // try to remove accent var componentType = _componentFactory.GetRegistration(component.Accent).Type; - if (EntityManager.HasComponent(args.User, componentType)) - { - EntityManager.RemoveComponent(args.User, componentType); - } + RemComp(args.User, componentType); component.IsActive = false; } @@ -71,14 +68,11 @@ private void OnGetAltVerbs(EntityUid uid, AddAccentPickupComponent component, Ge private void ToggleAccent(EntityUid uid, AddAccentPickupComponent component) { + var componentType = _componentFactory.GetRegistration(component.Accent).Type; if (component.IsActive) { // try to remove the accent if it's enabled - var componentType = _componentFactory.GetRegistration(component.Accent).Type; - if (EntityManager.HasComponent(component.Holder, componentType)) - { - EntityManager.RemoveComponent(component.Holder, componentType); - } + RemComp(component.Holder, componentType); component.IsActive = false; // we don't wipe out Holder in this case } @@ -86,7 +80,6 @@ private void ToggleAccent(EntityUid uid, AddAccentPickupComponent component) { // try to add the accent as if we are equipping this item again // does the user already has this accent? - var componentType = _componentFactory.GetRegistration(component.Accent).Type; if (HasComp(component.Holder, componentType)) return; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs index 15cea90ff9e..845d2baff64 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs @@ -236,7 +236,7 @@ public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, HandsCo Log.Error($"Failed to insert {ToPrettyString(entity)} into users hand container when picking up. User: {ToPrettyString(uid)}. Hand: {hand.Name}."); return; } - RaiseLocalEvent(entity, new GettingPickedUpEvent(uid, entity), false); // Frontier + RaiseLocalEvent(entity, new PickedUpEvent(uid, entity), false); // Frontier if (log) { diff --git a/Content.Shared/_NF/Item/PickupEvent.cs b/Content.Shared/_NF/Item/PickupEvent.cs index 569c87cf062..4808e3e9d8a 100644 --- a/Content.Shared/_NF/Item/PickupEvent.cs +++ b/Content.Shared/_NF/Item/PickupEvent.cs @@ -1,14 +1,14 @@ namespace Content.Shared._NF.Item; /// -/// Raised directed at entity being picked up when someone picks it up sucessfully +/// Raised directed at entity being picked after someone picks it up sucessfully. /// -public sealed class GettingPickedUpEvent : CancellableEntityEventArgs +public sealed class PickedUpEvent : EntityEventArgs { public readonly EntityUid User; public readonly EntityUid Item; - public GettingPickedUpEvent(EntityUid user, EntityUid item) + public PickedUpEvent(EntityUid user, EntityUid item) { User = user; Item = item;