]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Update vomit organ smite to not use Component.owner (#29926)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Thu, 25 Jul 2024 12:24:40 +0000 (05:24 -0700)
committerGitHub <noreply@github.com>
Thu, 25 Jul 2024 12:24:40 +0000 (05:24 -0700)
* Update vomit organ smite to not use Component.owner

* is this what you want...?

* am I winning, dad?

* update the comment

* we love entity<t>

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs
Content.Shared/Body/Systems/SharedBodySystem.Organs.cs

index eb21662719e2e4cfa5f8b61d02fba8b89c5e1251..3328563116135e83eb3a68da1fe71655a061c049 100644 (file)
@@ -285,18 +285,18 @@ public sealed partial class AdminVerbSystem
             {
                 Text = "admin-smite-remove-hands-name",
                 Category = VerbCategory.Smite,
-                Icon = new SpriteSpecifier.Rsi(new ("/Textures/Fluids/vomit_toxin.rsi"), "vomit_toxin-1"),
+                Icon = new SpriteSpecifier.Rsi(new("/Textures/Fluids/vomit_toxin.rsi"), "vomit_toxin-1"),
                 Act = () =>
                 {
                     _vomitSystem.Vomit(args.Target, -1000, -1000); // You feel hollow!
-                    var organs = _bodySystem.GetBodyOrganComponents<TransformComponent>(args.Target, body);
+                    var organs = _bodySystem.GetBodyOrganEntityComps<TransformComponent>((args.Target, body));
                     var baseXform = Transform(args.Target);
-                    foreach (var (xform, organ) in organs)
+                    foreach (var organ in organs)
                     {
-                        if (HasComp<BrainComponent>(xform.Owner) || HasComp<EyeComponent>(xform.Owner))
+                        if (HasComp<BrainComponent>(organ.Owner) || HasComp<EyeComponent>(organ.Owner))
                             continue;
 
-                        _transformSystem.AttachToGridOrMap(organ.Owner);
+                        _transformSystem.PlaceNextTo((organ.Owner, organ.Comp1), (args.Target, baseXform));
                     }
 
                     _popupSystem.PopupEntity(Loc.GetString("admin-smite-vomit-organs-self"), args.Target,
index efabebfc858bfe5896bcede8156a2d5fc98009eb..30fed573b89dddde4edde0dce63995c9515362bd 100644 (file)
@@ -183,6 +183,30 @@ public partial class SharedBodySystem
         return list;
     }
 
+    /// <summary>
+    /// Returns a list of Entity<<see cref="T"/>, <see cref="OrganComponent"/>>
+    /// for each organ of the body
+    /// </summary>
+    /// <typeparam name="T">The component that we want to return</typeparam>
+    /// <param name="entity">The body to check the organs of</param>
+    public List<Entity<T, OrganComponent>> GetBodyOrganEntityComps<T>(
+        Entity<BodyComponent?> entity)
+        where T : IComponent
+    {
+        if (!Resolve(entity, ref entity.Comp))
+            return new List<Entity<T, OrganComponent>>();
+
+        var query = GetEntityQuery<T>();
+        var list = new List<Entity<T, OrganComponent>>(3);
+        foreach (var organ in GetBodyOrgans(entity.Owner, entity.Comp))
+        {
+            if (query.TryGetComponent(organ.Id, out var comp))
+                list.Add((organ.Id, comp, organ.Component));
+        }
+
+        return list;
+    }
+
     /// <summary>
     ///     Tries to get a list of ValueTuples of <see cref="T"/> and OrganComponent on each organs
     ///     in the given body.