]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Steal Objective Condition now support stacks (#29843)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Wed, 10 Jul 2024 05:24:25 +0000 (08:24 +0300)
committerGitHub <noreply@github.com>
Wed, 10 Jul 2024 05:24:25 +0000 (15:24 +1000)
* Update StealConditionSystem.cs

* Update StealConditionSystem.cs

Content.Server/Objectives/Systems/StealConditionSystem.cs

index 0fe6f0947c876bf2973f80526f23005d002f8448..42a296ab925c37b64b9ca89b2d7a2d3c2588106e 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Mind.Components;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Movement.Pulling.Components;
+using Content.Shared.Stacks;
 
 namespace Content.Server.Objectives.Systems;
 
@@ -105,7 +106,7 @@ public sealed class StealConditionSystem : EntitySystem
             if (pulledEntity != null)
             {
                 // check if this is the item
-                if (CheckStealTarget(pulledEntity.Value, condition)) count++;
+                count += CheckStealTarget(pulledEntity.Value, condition);
 
                 //we don't check the inventories of sentient entity
                 if (!HasComp<MindContainerComponent>(pulledEntity))
@@ -126,7 +127,7 @@ public sealed class StealConditionSystem : EntitySystem
                 foreach (var entity in container.ContainedEntities)
                 {
                     // check if this is the item
-                    if (CheckStealTarget(entity, condition)) count++; //To Do: add support for stackable items
+                    count += CheckStealTarget(entity, condition);
 
                     // if it is a container check its contents
                     if (_containerQuery.TryGetComponent(entity, out var containerManager))
@@ -140,14 +141,14 @@ public sealed class StealConditionSystem : EntitySystem
         return result;
     }
 
-    private bool CheckStealTarget(EntityUid entity, StealConditionComponent condition)
+    private int CheckStealTarget(EntityUid entity, StealConditionComponent condition)
     {
         // check if this is the target
         if (!TryComp<StealTargetComponent>(entity, out var target))
-            return false;
+            return 0;
 
         if (target.StealGroup != condition.StealGroup)
-            return false;
+            return 0;
 
         // check if needed target alive
         if (condition.CheckAlive)
@@ -155,9 +156,10 @@ public sealed class StealConditionSystem : EntitySystem
             if (TryComp<MobStateComponent>(entity, out var state))
             {
                 if (!_mobState.IsAlive(entity, state))
-                    return false;
+                    return 0;
             }
         }
-        return true;
+
+        return TryComp<StackComponent>(entity, out var stack) ? stack.Count : 1;
     }
 }