]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Steal cleanup (#24428)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 28 Jan 2024 01:10:39 +0000 (12:10 +1100)
committerGitHub <noreply@github.com>
Sun, 28 Jan 2024 01:10:39 +0000 (12:10 +1100)
- Fix datafield spelling
- Fix some code oddities

Content.Server/Objectives/Components/StealConditionComponent.cs
Content.Server/Objectives/Systems/StealConditionSystem.cs
Resources/Prototypes/Objectives/thief.yml
Resources/Prototypes/Objectives/traitor.yml

index 4da028de259e1ad8373818a289224f35b6085af6..f8d68063f8701940f4ae595baa54cd488d777a39 100644 (file)
@@ -20,7 +20,7 @@ public sealed partial class StealConditionComponent : Component
     /// When enabled, disables generation of this target if there is no entity on the map (disable for objects that can be created mid-round).
     /// </summary>
     [DataField]
-    public bool VerifyMapExistance = true;
+    public bool VerifyMapExistence = true;
 
     /// <summary>
     /// If the target may be alive but has died, it will not be counted
index 2b552285aded197bdd79f15288114f5255d0c67c..02d4ee010b5883aef9bb85205f5028a2a2259661 100644 (file)
@@ -42,17 +42,8 @@ public sealed class StealConditionSystem : EntitySystem
     {
         List<StealTargetComponent?> targetList = new();
 
-        // cancel if invalid TargetStealName
-        var group = _proto.Index<StealTargetGroupPrototype>(condition.Comp.StealGroup);
-        if (group == null)
-        {
-            args.Cancelled = true;
-            Log.Error("StealTargetGroup invalid prototype!");
-            return;
-        }
-
-        var query = EntityQueryEnumerator<StealTargetComponent>();
-        while (query.MoveNext(out var uid, out var target))
+        var query = AllEntityQuery<StealTargetComponent>();
+        while (query.MoveNext(out var target))
         {
             if (condition.Comp.StealGroup != target.StealGroup)
                 continue;
@@ -61,17 +52,17 @@ public sealed class StealConditionSystem : EntitySystem
         }
 
         // cancel if the required items do not exist
-        if (targetList.Count == 0 && condition.Comp.VerifyMapExistance)
+        if (targetList.Count == 0 && condition.Comp.VerifyMapExistence)
         {
             args.Cancelled = true;
             return;
         }
 
         //setup condition settings
-        var maxSize = condition.Comp.VerifyMapExistance
+        var maxSize = condition.Comp.VerifyMapExistence
             ? Math.Min(targetList.Count, condition.Comp.MaxCollectionSize)
             : condition.Comp.MaxCollectionSize;
-        var minSize = condition.Comp.VerifyMapExistance
+        var minSize = condition.Comp.VerifyMapExistence
             ? Math.Min(targetList.Count, condition.Comp.MinCollectionSize)
             : condition.Comp.MinCollectionSize;
 
@@ -102,15 +93,13 @@ public sealed class StealConditionSystem : EntitySystem
 
     private float GetProgress(MindComponent mind, StealConditionComponent condition)
     {
-        if (!_metaQuery.TryGetComponent(mind.OwnedEntity, out var meta))
-            return 0;
         if (!_containerQuery.TryGetComponent(mind.OwnedEntity, out var currentManager))
             return 0;
 
         var stack = new Stack<ContainerManagerComponent>();
         var count = 0;
 
-        //check pulling object 
+        //check pulling object
         if (TryComp<SharedPullerComponent>(mind.OwnedEntity, out var pull)) //TO DO: to make the code prettier? don't like the repetition
         {
             var pullid = pull.Pulling;
@@ -147,7 +136,7 @@ public sealed class StealConditionSystem : EntitySystem
             }
         } while (stack.TryPop(out currentManager));
 
-        var result = (float) count / (float) condition.CollectionSize;
+        var result = count / (float) condition.CollectionSize;
         result = Math.Clamp(result, 0, 1);
         return result;
     }
@@ -166,7 +155,7 @@ public sealed class StealConditionSystem : EntitySystem
         {
             if (TryComp<MobStateComponent>(entity, out var state))
             {
-                if (!_mobState.IsAlive(entity))
+                if (!_mobState.IsAlive(entity, state))
                     return false;
             }
         }
index 4fc44119e3d4b6ac0b960ce839ac0cd4abf2225c..29432e1736c04e12ecdb65f60acf35c775f71438 100644 (file)
@@ -16,7 +16,7 @@
   id: BaseThiefStealObjective
   components:
   - type: StealCondition
-    verifyMapExistance: false
+    verifyMapExistence: false
     descriptionText: objective-condition-thief-description
 
 - type: entity
@@ -25,7 +25,7 @@
   id: BaseThiefStealCollectionObjective
   components:
   - type: StealCondition
-    verifyMapExistance: true
+    verifyMapExistence: true
     descriptionText: objective-condition-thief-description
 
 - type: entity
@@ -34,7 +34,7 @@
   id: BaseThiefStealStructureObjective
   components:
   - type: StealCondition
-    verifyMapExistance: true
+    verifyMapExistence: true
     descriptionText: objective-condition-thief-description
   - type: Objective
     difficulty: 2 # it's hard to hide
@@ -45,7 +45,7 @@
   id: BaseThiefStealAnimalObjective
   components:
   - type: StealCondition
-    verifyMapExistance: false
+    verifyMapExistence: false
     checkAlive: true
     objectiveNoOwnerText: objective-condition-steal-title-alive-no-owner
     descriptionText: objective-condition-thief-animal-description
     stealGroup: TechnologyDisk
     minCollectionSize: 5
     maxCollectionSize: 15
-    verifyMapExistance: false
+    verifyMapExistence: false
   - type: Objective
     difficulty: 0.8
 
     stealGroup: IDCard
     minCollectionSize: 5
     maxCollectionSize: 15
-    verifyMapExistance: false
+    verifyMapExistence: false
   - type: Objective
     difficulty: 0.7
 
     stealGroup: Cannabis
     minCollectionSize: 20
     maxCollectionSize: 30
-    verifyMapExistance: false
+    verifyMapExistence: false
   - type: Objective
     difficulty: 0.5
 
     stealGroup: LAMP
     minCollectionSize: 1
     maxCollectionSize: 10
-    verifyMapExistance: true
+    verifyMapExistence: true
   - type: Objective
     difficulty: 0.5 # just for fun, collectings LAMP on Moth
 
index f4530e01687bda1e57d7698fbd49fbd919d908d5..5a2d6880b898a99044a06d2d9a781dcb9b0195ac 100644 (file)
@@ -27,7 +27,7 @@
   id: BaseTraitorStealObjective
   components:
   - type: StealCondition
-    verifyMapExistance: false
+    verifyMapExistence: false
   - type: Objective
     difficulty: 2.75
   - type: ObjectiveLimit