Steal cleanup (#24428)
- Fix datafield spelling - Fix some code oddities
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,8 +93,6 @@ 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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
id: BaseTraitorStealObjective
|
||||
components:
|
||||
- type: StealCondition
|
||||
verifyMapExistance: false
|
||||
verifyMapExistence: false
|
||||
- type: Objective
|
||||
difficulty: 2.75
|
||||
- type: ObjectiveLimit
|
||||
|
||||
Reference in New Issue
Block a user