2 using System.Collections.Generic;
3 using Microsoft.Xna.Framework;
13 public HashSet<T>
Targets {
get;
private set; } =
new HashSet<T>();
14 public Dictionary<T, AIObjective>
Objectives {
get;
private set; } =
new Dictionary<T, AIObjective>();
16 private float ignoreListClearTimer;
23 private float syncTimer;
24 private readonly
float syncTime = 1;
55 protected override void Act(
float deltaTime) { }
73 public override void Update(
float deltaTime)
75 base.Update(deltaTime);
87 ignoreListClearTimer = 0;
92 ignoreListClearTimer += deltaTime;
109 var target = objective.Key;
119 syncTimer -= deltaTime;
133 ignoreListClearTimer = 0;
148 targetPriority = 100 - targetPriority;
151 if (currentSubObjective !=
null && currentSubObjective.Priority > targetPriority)
156 targetPriority = currentSubObjective.
Priority;
159 if (targetPriority < 1)
178 Priority = MathHelper.Lerp(0, max, value);
186 CalculateTargetUpdateTimer();
194 foreach (T target
in GetList())
219 if (
ignoreList.Contains(target)) {
continue; }
228 objective.Completed += () =>
233 objective.Abandoned += () =>
AIObjective CurrentSubObjective
float Priority
Final priority value after all calculations.
readonly Character character
readonly List< AIObjective > subObjectives
readonly AIObjectiveManager objectiveManager
abstract Identifier Identifier
An objective that creates specific kinds of subobjectives for specific types of targets,...
AIObjectiveLoop(Character character, AIObjectiveManager objectiveManager, float priorityModifier, Identifier option=default)
virtual float TargetUpdateTimeMultiplier
override bool AllowSubObjectiveSorting
abstract AIObjective ObjectiveConstructor(T target)
virtual void FindTargets()
override bool CanBeCompleted
virtual float IgnoreListClearInterval
By default, doesn't clear the list automatically
override bool AbandonWhenCannotCompleteSubObjectives
override float GetPriority()
override bool AllowWhileHandcuffed
virtual bool ResetWhenClearingIgnoreList
HashSet< T > ReportedTargets
Contains targets that anyone in the same crew has reported about. Used for automatic the target has t...
override bool AbandonIfDisallowed
abstract void OnObjectiveCompleted(AIObjective objective, T target)
Dictionary< T, AIObjective > Objectives
abstract float GetTargetPriority()
Returns a priority value based on the current targets (e.g. high prio when there's lots of severe fir...
override void Update(float deltaTime)
abstract IEnumerable< T > GetList()
List of all possible items of the specified type. Used for filtering the removed objectives.
virtual bool InverseTargetPriority
Makes the priority inversely proportional to the value returned by GetTargetPriority....
override void Act(float deltaTime)
virtual void CreateObjectives()
abstract bool IsValidTarget(T target)
virtual bool ForceOrderPriority
override bool CheckObjectiveState()
Should return whether the objective is completed or not.
const float EmergencyObjectivePriority
Priority of objectives such as finding safety, rescuing someone in a critical state or defending agai...
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)