parent
88d43a428a
commit
45ea7451ca
|
|
@ -41,18 +41,18 @@ public sealed class KillPersonConditionSystem : EntitySystem
|
|||
|
||||
private void OnPersonAssigned(Entity<PickRandomPersonComponent> ent, ref ObjectiveAssignedEvent args)
|
||||
{
|
||||
AssignRandomTarget(ent, args, _ => true);
|
||||
AssignRandomTarget(ent, ref args, _ => true);
|
||||
}
|
||||
|
||||
private void OnHeadAssigned(Entity<PickRandomHeadComponent> ent, ref ObjectiveAssignedEvent args)
|
||||
{
|
||||
AssignRandomTarget(ent, args, mindId =>
|
||||
AssignRandomTarget(ent, ref args, mindId =>
|
||||
TryComp<MindComponent>(mindId, out var mind) &&
|
||||
mind.OwnedEntity is { } ownedEnt &&
|
||||
HasComp<CommandStaffComponent>(ownedEnt));
|
||||
}
|
||||
|
||||
private void AssignRandomTarget(EntityUid uid, ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool fallbackToAny = true)
|
||||
private void AssignRandomTarget(EntityUid uid, ref ObjectiveAssignedEvent args, Predicate<EntityUid> filter, bool fallbackToAny = true)
|
||||
{
|
||||
// invalid prototype
|
||||
if (!TryComp<TargetObjectiveComponent>(uid, out var target))
|
||||
|
|
@ -97,6 +97,13 @@ public sealed class KillPersonConditionSystem : EntitySystem
|
|||
// Pick between humans matching our filter or fall back to all humans alive
|
||||
var selectedHumans = filteredHumans.Count > 0 ? filteredHumans : allHumans;
|
||||
|
||||
// Still no valid targets even after the fallback
|
||||
if (selectedHumans.Count == 0)
|
||||
{
|
||||
args.Cancelled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_target.SetTarget(uid, _random.Pick(selectedHumans), target);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue