3 using Microsoft.Xna.Framework;
5 using System.Collections.Generic;
26 private const float InspectTime = 5.0f;
27 private const float NormalWarnDelay = 5.0f;
28 private const float CriminalWarnDelay = 3.0f;
29 private float inspectTimer;
30 private float warnTimer;
31 private float currentWarnDelay;
33 private State currentState;
39 private readonly List<Item> stolenItems =
new List<Item>();
73 protected override void Act(
float deltaTime)
80 case State.GotoTarget:
81 TryAddSubObjective(ref goToObjective,
88 RemoveSubObjective(ref goToObjective);
98 currentState = State.Inspect;
118 private void Inspect(
float deltaTime)
120 if (inspectTimer > 0.0f)
123 float dist = diff.Length();
130 currentState = State.GotoTarget;
133 else if (Math.Abs(diff.X) > Math.Abs(diff.Y) * 2.0f)
149 inspectTimer -= deltaTime;
150 if (inspectTimer < InspectTime - 1)
155 character.
Speak(TextManager.Get(
"dialogcheckstolenitems.holdstill").Value, identifier:
"holdstill".ToIdentifier(), minDurationBetweenSimilar: 3f);
168 if (stolenItems.Any() &&
171 character.
Speak(TextManager.Get(
"dialogcheckstolenitems.warn").Value);
172 currentState = State.Warn;
176 character.
Speak(TextManager.Get(
Target.
IsCriminal ?
"dialogcheckstolenitems.nostolenitems.criminal" :
"dialogcheckstolenitems.nostolenitems").Value);
177 currentState = State.Done;
183 private void Warn(
float deltaTime)
185 if (warnTimer > 0.0f)
187 warnTimer -= deltaTime;
190 var stolenItemsOnCharacter = stolenItems.Where(it => it.GetRootInventoryOwner() ==
Target);
191 if (stolenItemsOnCharacter.Any())
194 Arrest(abortWhenItemsDropped:
true, allowHoldFire:
true);
195 foreach (var stolenItem
in stolenItemsOnCharacter)
202 character.
Speak(TextManager.Get(
"dialogcheckstolenitems.comply").Value);
204 foreach (var item
in stolenItems)
211 currentState = State.Done;
215 private void Arrest(
bool abortWhenItemsDropped,
bool allowHoldFire)
218 Func<AIObjective, bool>? abortCondition =
null;
219 if (abortWhenItemsDropped && !isCriminal)
235 currentState = State.GotoTarget;
239 private void InitTimers()
241 inspectTimer = InspectTime;
243 warnTimer = currentWarnDelay;
SteeringManager SteeringManager
override void OnDeselected()
float FindStolenItemsProbability
override void Act(float deltaTime)
override bool AllowOutsideSubmarine
readonly Character Target
override bool CheckObjectiveState()
Should return whether the objective is completed or not.
override float GetPriority()
AIObjectiveCheckStolenItems(Character character, Character target, AIObjectiveManager objectiveManager, float priorityModifier=1)
override Identifier Identifier
override bool AllowInAnySub
float Priority
Final priority value after all calculations.
readonly Character character
HumanAIController HumanAIController
readonly AIObjectiveManager objectiveManager
void AddObjective(AIObjective objective)
const float LowestOrderPriority
Maximum priority of an order given to the character (rightmost order in the crew list)
float GetOrderPriority(AIObjective objective)
bool IsOrder(AIObjective objective)
void SelectCharacter(Character character)
void Speak(string message, ChatMessageType? messageType=null, float delay=0.0f, Identifier identifier=default, float minDurationBetweenSimilar=0.0f)
virtual AIController AIController
bool IsCriminal
Do the outpost security officers treat the character as a criminal? Triggers when the character has e...
Character SelectedCharacter
CharacterInventory Inventory
readonly AnimController AnimController
bool CanSeeTarget(ISpatialEntity target, ISpatialEntity seeingEntity=null, bool seeThroughWindows=false, bool checkFacing=false)
virtual Vector2 WorldPosition
static void ApplyStealingReputationLoss(Item item)
AIObjectiveManager ObjectiveManager
void AddCombatObjective(AIObjectiveCombat.CombatMode mode, Character target, float delay=0, Func< AIObjective, bool > abortCondition=null, Action onAbort=null, Action onCompleted=null, bool allowHoldFire=false, bool speakWarnings=false)
const float BreakFromGrabDistance
Item FindItem(Func< Item, bool > predicate, bool recursive)
List< Item > FindAllItems(Func< Item, bool > predicate=null, bool recursive=false, List< Item > list=null)
void SteeringManual(float deltaTime, Vector2 velocity)