1 using System.Collections.Generic;
12 public Identifier
NPCTag {
get;
set; }
14 [
Serialize(
"",
IsPropertySaveable.Yes, description:
"Tag of the target. Can be any type of entity: if it's a static one like a device or a hull, the NPC will just stay at the position of that target.")]
20 [
Serialize(-1,
IsPropertySaveable.Yes, description:
"Maximum number of NPCs to target (e.g. you could choose to only make a specific number of security officers follow the player.)")]
23 [
Serialize(
true,
IsPropertySaveable.Yes, description:
"The event actions reset when a GoTo action makes the event jump to a different point. Should the NPC stop following the target when the event resets?")]
26 private bool isFinished =
false;
31 private IEnumerable<Character> affectedNpcs;
34 public override void Update(
float deltaTime)
36 if (isFinished) {
return; }
39 if (target ==
null) {
return; }
43 foreach (var npc
in affectedNpcs)
45 if (npc.Removed) {
continue; }
50 var newObjective =
new AIObjectiveGoTo(target, npc, humanAiController.ObjectiveManager, repeat:
true)
52 OverridePriority = 100.0f,
55 humanAiController.ObjectiveManager.AddObjective(newObjective);
56 humanAiController.ObjectiveManager.WaitTimer = 0.0f;
60 foreach (var objective
in humanAiController.ObjectiveManager.Objectives)
86 foreach (var npc
in affectedNpcs)
88 if (npc.Removed || npc.AIController is not
HumanAIController humanAiController) {
continue; }
89 foreach (var goToObjective
in humanAiController.ObjectiveManager.GetActiveObjectives<
AIObjectiveGoTo>())
91 if (goToObjective.Target == target)
93 goToObjective.Abandon =
true;
105 return $
"{ToolBox.GetDebugSymbol(isFinished)} {nameof(NPCFollowAction)} -> (NPCTag: {NPCTag.ColorizeObject()}, TargetTag: {TargetTag.ColorizeObject()}, Follow: {Follow.ColorizeObject()})";
readonly ScriptedEvent ParentEvent
Makes an NPC follow or stop following a specific target.
override string ToDebugString()
Rich test to display in debugdraw
override bool IsFinished(ref string goTo)
Has the action finished.
NPCFollowAction(ScriptedEvent parentEvent, ContentXElement element)
override void Update(float deltaTime)
IEnumerable< Entity > GetTargets(Identifier tag)