Barotrauma Client
Loading...
Searching...
No Matches
Barotrauma.AIObjectiveLoop< T > Class Template Referenceabstract

An objective that creates specific kinds of subobjectives for specific types of targets, and loops through those targets. For example, a cleanup objective that loops through items that need to be cleaned up, or a "fix leaks" objective that loops through leaks that need welding. More...

Inheritance diagram for Barotrauma.AIObjectiveLoop< T >:
Barotrauma.AIObjective

Public Member Functions

bool AddTarget (T target)
 
 AIObjectiveLoop (Character character, AIObjectiveManager objectiveManager, float priorityModifier, Identifier option=default)
 
override void Update (float deltaTime)
 
override void Reset ()
 
- Public Member Functions inherited from Barotrauma.AIObjective
IEnumerable< AIObjectiveGetSubObjectivesRecursive (bool includingSelf=false)
 
AIObjective GetActiveObjective ()
 
 AIObjective (Character character, AIObjectiveManager objectiveManager, float priorityModifier, Identifier option=default)
 
void TryComplete (float deltaTime)
 Makes the character act according to the objective, or according to any subobjectives that need to be completed before this one.
 
void AddSubObjective (AIObjective objective, bool addFirst=false)
 
void RemoveSubObjective< T > (ref T objective)
 
void SortSubObjectives ()
 
bool IsIgnoredAtOutpost ()
 Returns true only when at a friendly outpost and when the order is set to be ignored there. Note that even if this returns false, the objective can be disallowed, because AllowInFriendlySubs is false.
 
float CalculatePriority ()
 Call this only when the priority needs to be recalculated. Use the cached Priority property when you don't need to recalculate.
 
virtual bool IsDuplicate< T > (T otherObjective)
 
virtual void OnSelected ()
 
virtual void OnDeselected ()
 
virtual void SpeakAfterOrderReceived ()
 

Protected Member Functions

override void Act (float deltaTime)
 
override bool CheckObjectiveSpecific ()
 
override float GetPriority ()
 
void UpdateTargets ()
 
virtual void FindTargets ()
 
virtual void CreateObjectives ()
 
void OnObjectiveCompleted (AIObjective objective, T target)
 
IEnumerable< T > GetList ()
 List of all possible items of the specified type. Used for filtering the removed objectives.
 
float GetTargetPriority ()
 Returns a priority value based on the current targets (e.g. high prio when there's lots of severe fires or leaks). The priority of this objective is based on the target priority.
 
AIObjective ObjectiveConstructor (T target)
 
bool IsValidTarget (T target)
 
- Protected Member Functions inherited from Barotrauma.AIObjective
void HandleDisallowed ()
 
float GetDistanceFactor (Vector2 targetWorldPos, float factorAtMaxDistance, float verticalDistanceMultiplier=3, float maxDistance=10000.0f, float factorAtMinDistance=1.0f)
 Get a normalized value representing how close the target position is. The value is a rough estimation, where vertical movement is assumed to be more costly than horizontal.
 
virtual void SyncRemovedObjectives< T1, T2 > (Dictionary< T1, T2 > dictionary, IEnumerable< T1 > collection)
 Checks if the subobjectives in the given collection are removed from the subobjectives. And if so, removes it also from the dictionary.
 
bool TryAddSubObjective< T > (ref T objective, Func< T > constructor, Action onCompleted=null, Action onAbandon=null)
 Checks if the objective already is created and added in subobjectives. If not, creates it. Handles objectives that cannot be completed. If the objective has been removed form the subobjectives, a null value is assigned to the reference. Returns true if the objective was created and successfully added.
 
virtual void OnCompleted ()
 
virtual void OnAbandon ()
 
void Act (float deltaTime)
 
bool CheckObjectiveSpecific ()
 Should return whether the objective is completed or not.
 
bool CanEquip (Item item, bool allowWearing)
 

Protected Attributes

HashSet< T > ignoreList = new HashSet<T>()
 
float targetUpdateTimer
 
- Protected Attributes inherited from Barotrauma.AIObjective
readonly List< AIObjectivesubObjectives = new List<AIObjective>()
 

Properties

HashSet< T > Targets = new HashSet<T>() [get]
 
Dictionary< T, AIObjectiveObjectives = new Dictionary<T, AIObjective>() [get]
 
virtual float TargetUpdateTimeMultiplier = 1 [get]
 
virtual float IgnoreListClearInterval [get]
 By default, doesn't clear the list automatically.
 
HashSet< T > ReportedTargets = new HashSet<T>() [get]
 Contains targets that anyone in the same crew has reported about. Used for automatic the target has to be reported before it can be can be targeted, so characters don't magically know where e.g. enemies are. Ignored on orders: a bot explicitly ordered to repair leaks or fight intruders can find targets that haven't been reported.
 
override bool CanBeCompleted [get]
 
override bool AbandonWhenCannotCompleteSubObjectives [get]
 
override bool AllowSubObjectiveSorting [get]
 
override bool AllowWhileHandcuffed [get]
 
override bool AbandonIfDisallowed [get]
 
virtual bool InverseTargetPriority [get]
 Makes the priority inversely proportional to the value returned by GetTargetPriority. In other words, gives this objective a high priority when priority of the targets is low.
 
virtual bool ResetWhenClearingIgnoreList [get]
 
virtual bool ForceOrderPriority [get]
 
virtual int MaxTargets [get]
 
- Properties inherited from Barotrauma.AIObjective
virtual float Devotion [get]
 
Identifier Identifier [get, set]
 
virtual string DebugTag [get]
 
virtual bool ForceRun [get]
 
virtual bool IgnoreUnsafeHulls [get]
 
virtual bool AbandonWhenCannotCompleteSubObjectives [get]
 
virtual bool AllowSubObjectiveSorting [get]
 Should subobjectives be sorted according to their priority?
 
virtual bool PrioritizeIfSubObjectivesActive [get]
 
virtual bool AllowMultipleInstances [get]
 Can there be multiple objective instaces of the same type?
 
virtual bool ConcurrentObjectives [get]
 Run the main objective with all subobjectives concurrently? If false, the main objective will continue only when all the subobjectives have been removed (done).
 
virtual bool KeepDivingGearOn [get]
 
virtual bool KeepDivingGearOnAlsoWhenInactive [get]
 
virtual bool AllowAutomaticItemUnequipping [get]
 There's a separate property for diving suit and mask: KeepDivingGearOn.
 
virtual bool AllowOutsideSubmarine [get]
 
virtual bool AllowInFriendlySubs [get]
 When true, the objective is allowed in the player subs (when in the same team) and on friendly outposts (regardless of the alignment). Note: ignored when AllowInAnySub is true.
 
virtual bool AllowInAnySub [get]
 
virtual bool AllowWhileHandcuffed [get]
 
virtual bool AbandonIfDisallowed [get]
 Should the objective abandon when it's not allowed in the current context or should it just stay inactive with 0 priority? Abandoned automatic objectives are removed and recreated automatically (when new orders are assigned or after a cooldown period). Abandoned orders are removed, but the most recent order can be reissued by clicking the small order icon with the arrow in the crew manager panel.
 
virtual bool CanBeCompleted [get]
 
virtual float MaxDevotion [get]
 
float CumulatedDevotion [get, set]
 
float Priority [get, set]
 Final priority value after all calculations.
 
float BasePriority [get, set]
 
float PriorityModifier = 1 [get]
 
bool ForceHighestPriority [get, set]
 
bool ForceWalk [get, set]
 
bool IgnoreAtOutpost [get, set]
 
bool Abandon [get, set]
 
IEnumerable< AIObjectiveSubObjectives [get]
 
AIObjective CurrentSubObjective [get]
 
HumanAIController HumanAIController [get]
 
IndoorsSteeringManager PathSteering [get]
 
SteeringManager SteeringManager [get]
 
bool IsAllowed [get]
 
bool IsCompleted [get, protected set]
 

Additional Inherited Members

- Static Public Member Functions inherited from Barotrauma.AIObjective
static float GetDistanceFactor (Vector2 selfPos, Vector2 targetWorldPos, float factorAtMaxDistance, float verticalDistanceMultiplier=3, float maxDistance=10000.0f, float factorAtMinDistance=1.0f)
 Get a normalized value representing how close the target position is. The value is a rough estimation, where vertical movement is assumed to be more costly than horizontal.
 
- Public Attributes inherited from Barotrauma.AIObjective
EventAction SourceEventAction
 Which event action (if any) created this objective.
 
AIObjective SourceObjective
 Which objective (if any) created this objective. When this is a subobjective, the parent objective is used by default.
 
readonly Character character
 
readonly AIObjectiveManager objectiveManager
 
readonly Identifier Option
 
Func< AIObjective, bool > AbortCondition
 Aborts the objective when this condition is true.
 
- Static Protected Member Functions inherited from Barotrauma.AIObjective
static bool CanPutInInventory (Character character, Item item, bool allowWearing)
 
- Events inherited from Barotrauma.AIObjective
Action Completed
 A single shot event. Automatically cleared after launching. Use OnCompleted method for implementing (internal) persistent behavior.
 
Action Abandoned
 A single shot event. Automatically cleared after launching. Use OnAbandoned method for implementing (internal) persistent behavior.
 
Action Selected
 A single shot event. Automatically cleared after launching. Use OnSelected method for implementing (internal) persistent behavior.
 
Action Deselected
 A single shot event. Automatically cleared after launching. Use OnDeselected method for implementing (internal) persistent behavior.
 

Detailed Description

An objective that creates specific kinds of subobjectives for specific types of targets, and loops through those targets. For example, a cleanup objective that loops through items that need to be cleaned up, or a "fix leaks" objective that loops through leaks that need welding.

Constructor & Destructor Documentation

◆ AIObjectiveLoop()

Barotrauma.AIObjectiveLoop< T >.AIObjectiveLoop ( Character character,
AIObjectiveManager objectiveManager,
float priorityModifier,
Identifier option = default )

Member Function Documentation

◆ Act()

override void Barotrauma.AIObjectiveLoop< T >.Act ( float deltaTime)
protected

◆ AddTarget()

bool Barotrauma.AIObjectiveLoop< T >.AddTarget ( T target)

◆ CheckObjectiveSpecific()

override bool Barotrauma.AIObjectiveLoop< T >.CheckObjectiveSpecific ( )
protected

◆ CreateObjectives()

virtual void Barotrauma.AIObjectiveLoop< T >.CreateObjectives ( )
protectedvirtual

◆ FindTargets()

virtual void Barotrauma.AIObjectiveLoop< T >.FindTargets ( )
protectedvirtual

◆ GetList()

IEnumerable< T > Barotrauma.AIObjectiveLoop< T >.GetList ( )
abstractprotected

List of all possible items of the specified type. Used for filtering the removed objectives.

◆ GetPriority()

override float Barotrauma.AIObjectiveLoop< T >.GetPriority ( )
protectedvirtual

Reimplemented from Barotrauma.AIObjective.

◆ GetTargetPriority()

float Barotrauma.AIObjectiveLoop< T >.GetTargetPriority ( )
abstractprotected

Returns a priority value based on the current targets (e.g. high prio when there's lots of severe fires or leaks). The priority of this objective is based on the target priority.

◆ IsValidTarget()

bool Barotrauma.AIObjectiveLoop< T >.IsValidTarget ( T target)
abstractprotected

◆ ObjectiveConstructor()

AIObjective Barotrauma.AIObjectiveLoop< T >.ObjectiveConstructor ( T target)
abstractprotected

◆ OnObjectiveCompleted()

void Barotrauma.AIObjectiveLoop< T >.OnObjectiveCompleted ( AIObjective objective,
T target )
abstractprotected

◆ Reset()

override void Barotrauma.AIObjectiveLoop< T >.Reset ( )
virtual

Reimplemented from Barotrauma.AIObjective.

◆ Update()

override void Barotrauma.AIObjectiveLoop< T >.Update ( float deltaTime)
virtual

Reimplemented from Barotrauma.AIObjective.

◆ UpdateTargets()

void Barotrauma.AIObjectiveLoop< T >.UpdateTargets ( )
protected

Member Data Documentation

◆ ignoreList

HashSet<T> Barotrauma.AIObjectiveLoop< T >.ignoreList = new HashSet<T>()
protected

◆ targetUpdateTimer

float Barotrauma.AIObjectiveLoop< T >.targetUpdateTimer
protected

Property Documentation

◆ AbandonIfDisallowed

override bool Barotrauma.AIObjectiveLoop< T >.AbandonIfDisallowed
getprotected

◆ AbandonWhenCannotCompleteSubObjectives

override bool Barotrauma.AIObjectiveLoop< T >.AbandonWhenCannotCompleteSubObjectives
get

◆ AllowSubObjectiveSorting

override bool Barotrauma.AIObjectiveLoop< T >.AllowSubObjectiveSorting
get

◆ AllowWhileHandcuffed

override bool Barotrauma.AIObjectiveLoop< T >.AllowWhileHandcuffed
getprotected

◆ CanBeCompleted

override bool Barotrauma.AIObjectiveLoop< T >.CanBeCompleted
get

◆ ForceOrderPriority

virtual bool Barotrauma.AIObjectiveLoop< T >.ForceOrderPriority
getprotected

◆ IgnoreListClearInterval

virtual float Barotrauma.AIObjectiveLoop< T >.IgnoreListClearInterval
getprotected

By default, doesn't clear the list automatically.

◆ InverseTargetPriority

virtual bool Barotrauma.AIObjectiveLoop< T >.InverseTargetPriority
get

Makes the priority inversely proportional to the value returned by GetTargetPriority. In other words, gives this objective a high priority when priority of the targets is low.

◆ MaxTargets

virtual int Barotrauma.AIObjectiveLoop< T >.MaxTargets
getprotected

◆ Objectives

Dictionary<T, AIObjective> Barotrauma.AIObjectiveLoop< T >.Objectives = new Dictionary<T, AIObjective>()
get

◆ ReportedTargets

HashSet<T> Barotrauma.AIObjectiveLoop< T >.ReportedTargets = new HashSet<T>()
get

Contains targets that anyone in the same crew has reported about. Used for automatic the target has to be reported before it can be can be targeted, so characters don't magically know where e.g. enemies are. Ignored on orders: a bot explicitly ordered to repair leaks or fight intruders can find targets that haven't been reported.

◆ ResetWhenClearingIgnoreList

virtual bool Barotrauma.AIObjectiveLoop< T >.ResetWhenClearingIgnoreList
getprotected

◆ Targets

HashSet<T> Barotrauma.AIObjectiveLoop< T >.Targets = new HashSet<T>()
get

◆ TargetUpdateTimeMultiplier

virtual float Barotrauma.AIObjectiveLoop< T >.TargetUpdateTimeMultiplier = 1
getprotected

The documentation for this class was generated from the following file: