From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 28 Jan 2024 01:10:39 +0000 (+1100) Subject: Steal cleanup (#24428) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b1f9e25c1364064b03bc37357d3453f01e28b8a4;p=space-station-14.git Steal cleanup (#24428) - Fix datafield spelling - Fix some code oddities --- diff --git a/Content.Server/Objectives/Components/StealConditionComponent.cs b/Content.Server/Objectives/Components/StealConditionComponent.cs index 4da028de25..f8d68063f8 100644 --- a/Content.Server/Objectives/Components/StealConditionComponent.cs +++ b/Content.Server/Objectives/Components/StealConditionComponent.cs @@ -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). /// [DataField] - public bool VerifyMapExistance = true; + public bool VerifyMapExistence = true; /// /// If the target may be alive but has died, it will not be counted diff --git a/Content.Server/Objectives/Systems/StealConditionSystem.cs b/Content.Server/Objectives/Systems/StealConditionSystem.cs index 2b552285ad..02d4ee010b 100644 --- a/Content.Server/Objectives/Systems/StealConditionSystem.cs +++ b/Content.Server/Objectives/Systems/StealConditionSystem.cs @@ -42,17 +42,8 @@ public sealed class StealConditionSystem : EntitySystem { List targetList = new(); - // cancel if invalid TargetStealName - var group = _proto.Index(condition.Comp.StealGroup); - if (group == null) - { - args.Cancelled = true; - Log.Error("StealTargetGroup invalid prototype!"); - return; - } - - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var target)) + var query = AllEntityQuery(); + 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(); var count = 0; - //check pulling object + //check pulling object if (TryComp(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(entity, out var state)) { - if (!_mobState.IsAlive(entity)) + if (!_mobState.IsAlive(entity, state)) return false; } } diff --git a/Resources/Prototypes/Objectives/thief.yml b/Resources/Prototypes/Objectives/thief.yml index 4fc44119e3..29432e1736 100644 --- a/Resources/Prototypes/Objectives/thief.yml +++ b/Resources/Prototypes/Objectives/thief.yml @@ -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 @@ -125,7 +125,7 @@ stealGroup: TechnologyDisk minCollectionSize: 5 maxCollectionSize: 15 - verifyMapExistance: false + verifyMapExistence: false - type: Objective difficulty: 0.8 @@ -138,7 +138,7 @@ stealGroup: IDCard minCollectionSize: 5 maxCollectionSize: 15 - verifyMapExistance: false + verifyMapExistence: false - type: Objective difficulty: 0.7 @@ -153,7 +153,7 @@ stealGroup: Cannabis minCollectionSize: 20 maxCollectionSize: 30 - verifyMapExistance: false + verifyMapExistence: false - type: Objective difficulty: 0.5 @@ -169,7 +169,7 @@ stealGroup: LAMP minCollectionSize: 1 maxCollectionSize: 10 - verifyMapExistance: true + verifyMapExistence: true - type: Objective difficulty: 0.5 # just for fun, collectings LAMP on Moth diff --git a/Resources/Prototypes/Objectives/traitor.yml b/Resources/Prototypes/Objectives/traitor.yml index f4530e0168..5a2d6880b8 100644 --- a/Resources/Prototypes/Objectives/traitor.yml +++ b/Resources/Prototypes/Objectives/traitor.yml @@ -27,7 +27,7 @@ id: BaseTraitorStealObjective components: - type: StealCondition - verifyMapExistance: false + verifyMapExistence: false - type: Objective difficulty: 2.75 - type: ObjectiveLimit