]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make UtensilSystem and SharpSystem not run AfterInteract if it has already been handl...
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Sun, 14 Apr 2024 03:39:22 +0000 (20:39 -0700)
committerGitHub <noreply@github.com>
Sun, 14 Apr 2024 03:39:22 +0000 (13:39 +1000)
* Make UtensilSystem and SharpSystem not run AfterInteract if it has already been handled

* merge conflicts

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Server/Kitchen/EntitySystems/SharpSystem.cs
Content.Server/Nutrition/EntitySystems/UtensilSystem.cs

index 2caab4063cf2354691b982df946f6eddb230edbc..3c1e89b1f2d9ccd012991bb10e4ce7bbdb741655 100644 (file)
@@ -1,5 +1,7 @@
 using Content.Server.Body.Systems;
 using Content.Server.Kitchen.Components;
+using Content.Server.Nutrition.EntitySystems;
+using Content.Shared.Body.Components;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Body.Components;
 using Content.Shared.Database;
@@ -11,9 +13,14 @@ using Content.Shared.Storage;
 using Content.Shared.Verbs;
 using Content.Shared.Destructible;
 using Content.Shared.DoAfter;
+using Content.Shared.Interaction;
 using Content.Shared.Kitchen;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
+using Content.Shared.Nutrition.Components;
+using Content.Shared.Popups;
+using Content.Shared.Storage;
+using Content.Shared.Verbs;
 using Robust.Server.Containers;
 using Robust.Shared.Random;
 using Robust.Shared.Utility;
@@ -35,7 +42,7 @@ public sealed class SharpSystem : EntitySystem
     {
         base.Initialize();
 
-        SubscribeLocalEvent<SharpComponent, AfterInteractEvent>(OnAfterInteract, before: new[] { typeof(UtensilSystem) });
+        SubscribeLocalEvent<SharpComponent, AfterInteractEvent>(OnAfterInteract, before: [typeof(UtensilSystem)]);
         SubscribeLocalEvent<SharpComponent, SharpDoAfterEvent>(OnDoAfter);
 
         SubscribeLocalEvent<ButcherableComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
@@ -43,16 +50,14 @@ public sealed class SharpSystem : EntitySystem
 
     private void OnAfterInteract(EntityUid uid, SharpComponent component, AfterInteractEvent args)
     {
-        if (args.Handled)
-            return;
-
-        if (args.Target is null || !args.CanReach)
+        if (args.Handled || args.Target is null || !args.CanReach)
             return;
 
-        args.Handled = TryStartButcherDoAfter(uid, args.Target.Value, args.User);
+        if (TryStartButcherDoafter(uid, args.Target.Value, args.User))
+            args.Handled = true;
     }
 
-    private bool TryStartButcherDoAfter(EntityUid knife, EntityUid target, EntityUid user)
+    private bool TryStartButcherDoafter(EntityUid knife, EntityUid target, EntityUid user)
     {
         if (!TryComp<ButcherableComponent>(target, out var butcher))
             return false;
@@ -66,11 +71,11 @@ public sealed class SharpSystem : EntitySystem
         if (butcher.Type != ButcheringType.Knife && target != user)
         {
             _popupSystem.PopupEntity(Loc.GetString("butcherable-different-tool", ("target", target)), knife, user);
-            return true;
+            return false;
         }
 
         if (!sharp.Butchering.Add(target))
-            return true;
+            return false;
 
         var doAfter =
             new DoAfterArgs(EntityManager, user, sharp.ButcherDelayModifier * butcher.ButcherDelay, new SharpDoAfterEvent(), knife, target: target, used: knife)
@@ -165,7 +170,7 @@ public sealed class SharpSystem : EntitySystem
             Act = () =>
             {
                 if (!disabled)
-                    TryStartButcherDoAfter(args.Using!.Value, args.Target, args.User);
+                    TryStartButcherDoafter(args.Using!.Value, args.Target, args.User);
             },
             Message = message,
             Disabled = disabled,
index 0edd0711b670d6e0ceb76cc21c66a139cdb607ba..43087214a453d5650c01f605993bc65a74afa1e1 100644 (file)
@@ -1,12 +1,11 @@
 using Content.Shared.Containers.ItemSlots;
 using Content.Server.Nutrition.Components;
-using Content.Shared.Nutrition.Components;
-using Content.Shared.Nutrition.EntitySystems;
 using Content.Server.Popups;
 using Content.Shared.Interaction;
+using Content.Shared.Nutrition.Components;
+using Content.Shared.Nutrition.EntitySystems;
 using Robust.Shared.Audio;
 using Robust.Shared.Audio.Systems;
-using Robust.Shared.Player;
 using Robust.Shared.Random;
 
 namespace Content.Server.Nutrition.EntitySystems
@@ -34,10 +33,7 @@ namespace Content.Server.Nutrition.EntitySystems
         /// </summary>
         private void OnAfterInteract(EntityUid uid, UtensilComponent component, AfterInteractEvent ev)
         {
-            if (ev.Handled)
-                return;
-
-            if (ev.Target == null || !ev.CanReach)
+            if (ev.Handled || ev.Target == null || !ev.CanReach)
                 return;
 
             var result = TryUseUtensil(ev.User, ev.Target.Value, component);