Objectives that do not fit requirements are now deleted (#38365)

* Fix

* Update Content.Server/Objectives/ObjectivesSystem.cs

Thanks Tayrathn!

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
beck-thompson
2025-06-16 15:54:11 -07:00
committed by GitHub
parent 00858aaa5a
commit a48c390854

View File

@@ -244,8 +244,10 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
var objectives = group.Weights.ShallowClone();
while (_random.TryPickAndTake(objectives, out var objectiveProto))
{
if (TryCreateObjective((mindId, mind), objectiveProto, out var objective)
&& Comp<ObjectiveComponent>(objective.Value).Difficulty <= maxDifficulty)
if (!_prototypeManager.Index(objectiveProto).TryGetComponent<ObjectiveComponent>(out var objectiveComp, EntityManager.ComponentFactory))
continue;
if (objectiveComp.Difficulty <= maxDifficulty && TryCreateObjective((mindId, mind), objectiveProto, out var objective))
return objective;
}
}