14 const float InspectNoisePriority = 10.0f;
18 const float InspectNoisePriorityIncrease = 10.0f;
19 private const float InspectNoiseInterval = 1.0f;
20 private float inspectNoiseTimer;
27 private const float InspectNoiseExpirationDelay = 60.0f;
28 private float inspectNoiseExpirationTimer = 0.0f;
35 inspectNoiseTimer = Rand.Range(0.0f, InspectNoiseInterval);
38 public override void Update(
float deltaTime)
40 base.Update(deltaTime);
41 inspectNoiseTimer -= deltaTime;
42 if (inspectNoiseTimer <= 0.0f)
45 inspectNoiseTimer = InspectNoiseInterval;
50 inspectNoiseExpirationTimer += deltaTime;
51 if (inspectNoiseExpirationTimer > InspectNoiseExpirationDelay)
53 inspectNoiseObjective.
Abandon =
true;
61 private void CheckEnemyNoises()
66 if (inspectNoiseObjective !=
null &&
69 inspectNoiseObjective.
Abandon =
true;
72 foreach (var aiTarget
in AITarget.List)
74 if (aiTarget.ShouldBeIgnored()) {
continue; }
76 if (aiTarget.Entity is not Item item) {
continue; }
77 if (!item.HasTag(Tags.ProvocativeToHumanAI)) {
continue; }
78 if (item.GetRootInventoryOwner() is Character targetCharacter &&
79 AIObjectiveFightIntruders.IsValidTarget(targetCharacter,
character, targetCharactersInOtherSubs:
false))
84 character.
Speak(TextManager.Get(
"dialogheardenemy").Value, identifier:
"heardenemy".ToIdentifier(), minDurationBetweenSimilar: 30.0f);
85 if (inspectNoiseObjective !=
null &&
subObjectives.Contains(inspectNoiseObjective))
89 inspectNoiseObjective.
Priority = Math.Min(inspectNoiseObjective.
Priority + InspectNoisePriorityIncrease, AIObjectiveManager.LowestOrderPriority - 1);
93 inspectNoiseObjective.
Target != targetCharacter.CurrentHull)
95 CreateInspectNoiseObjective(targetCharacter.CurrentHull, priority: inspectNoiseObjective.
Priority);
100 CreateInspectNoiseObjective(targetCharacter.CurrentHull, priority: InspectNoisePriority);
105 void CreateInspectNoiseObjective(ISpatialEntity target,
float priority)
107 RemoveSubObjective(ref inspectNoiseObjective);
113 inspectNoiseObjective.
Completed += () => { inspectNoiseObjective =
null; inspectNoiseExpirationTimer = 0.0f; };
114 inspectNoiseObjective.
Abandoned += () => { inspectNoiseObjective =
null; inspectNoiseExpirationTimer = 0.0f; };
119 protected override void Act(
float deltaTime)
AIObjective CurrentSubObjective
AIObjective SourceObjective
Which objective (if any) created this objective. When this is a subobjective, the parent objective is...
float Priority
Final priority value after all calculations.
void AddSubObjective(AIObjective objective, bool addFirst=false)
readonly Character character
HumanAIController HumanAIController
readonly List< AIObjective > subObjectives
Action Completed
A single shot event. Automatically cleared after launching. Use OnCompleted method for implementing (...
Action Abandoned
A single shot event. Automatically cleared after launching. Use OnAbandoned method for implementing (...
readonly AIObjectiveManager objectiveManager
override Identifier Identifier
override bool CheckObjectiveState()
Should return whether the objective is completed or not.
override float GetPriority()
AIObjectiveInspectNoises(Character character, AIObjectiveManager objectiveManager, float priorityModifier=1)
override void Act(float deltaTime)
override void Update(float deltaTime)
AIObjective GetActiveObjective()
void Speak(string message, ChatMessageType? messageType=null, float delay=0.0f, Identifier identifier=default, float minDurationBetweenSimilar=0.0f)
override Vector2 Position
virtual Vector2 WorldPosition
float GetApproximateDistance(Vector2 startPos, Vector2 endPos, Hull targetHull, float maxDistance, float distanceMultiplierPerClosedDoor=0)
Approximate distance from this hull to the target hull, moving through open gaps without passing thro...
float Hearing
Affects how far the character can hear sounds created by AI targets with the tag ProvocativeToHumanAI...