Barotrauma Client Doc
Barotrauma.AIObjective Class Referenceabstract
Inheritance diagram for Barotrauma.AIObjective:
Barotrauma.AIObjectiveCheckStolenItems Barotrauma.AIObjectiveCleanupItem Barotrauma.AIObjectiveCombat Barotrauma.AIObjectiveContainItem Barotrauma.AIObjectiveDecontainItem Barotrauma.AIObjectiveEscapeHandcuffs Barotrauma.AIObjectiveExtinguishFire Barotrauma.AIObjectiveFindDivingGear Barotrauma.AIObjectiveFindSafety Barotrauma.AIObjectiveFixLeak Barotrauma.AIObjectiveGetItem Barotrauma.AIObjectiveGetItems Barotrauma.AIObjectiveGoTo Barotrauma.AIObjectiveIdle Barotrauma.AIObjectiveLoadItem Barotrauma.AIObjectiveLoop< T > Barotrauma.AIObjectiveOperateItem Barotrauma.AIObjectivePrepare Barotrauma.AIObjectiveRepairItem Barotrauma.AIObjectiveRescue Barotrauma.AIObjectiveReturn

Public Member Functions

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 More...
 
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. More...
 
float CalculatePriority ()
 Call this only when the priority needs to be recalculated. Use the cached Priority property when you don't need to recalculate. More...
 
virtual bool IsDuplicate< T > (T otherObjective)
 
virtual void Update (float deltaTime)
 
virtual void OnSelected ()
 
virtual void OnDeselected ()
 
virtual void Reset ()
 
virtual void SpeakAfterOrderReceived ()
 
Sprite GetSprite ()
 

Static Public Member Functions

static Sprite GetSprite (Identifier identifier, Identifier option, Entity targetEntity)
 

Public Attributes

readonly Character character
 
readonly AIObjectiveManager objectiveManager
 
readonly Identifier Option
 
Func< AIObjective, bool > AbortCondition
 Aborts the objective when this condition is true. More...
 

Protected Member Functions

void HandleNonAllowed ()
 
virtual float GetPriority ()
 
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. More...
 
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. More...
 
virtual void OnCompleted ()
 
virtual void OnAbandon ()
 
abstract void Act (float deltaTime)
 
abstract bool CheckObjectiveSpecific ()
 
bool CanEquip (Item item, bool allowWearing)
 

Static Protected Member Functions

static bool CanEquip (Character character, Item item, bool allowWearing)
 

Protected Attributes

readonly List< AIObjectivesubObjectives = new List<AIObjective>()
 

Properties

virtual float Devotion [get]
 
abstract Identifier Identifier [get, set]
 
virtual string DebugTag [get]
 
virtual bool ForceRun [get]
 
virtual bool IgnoreUnsafeHulls [get]
 
virtual bool AbandonWhenCannotCompleteSubjectives [get]
 
virtual bool AllowSubObjectiveSorting [get]
 
virtual bool PrioritizeIfSubObjectivesActive [get]
 
virtual bool AllowMultipleInstances [get]
 Can there be multiple objective instaces of the same type? More...
 
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). More...
 
virtual bool KeepDivingGearOn [get]
 
virtual bool KeepDivingGearOnAlsoWhenInactive [get]
 
virtual bool AllowAutomaticItemUnequipping [get]
 There's a separate property for diving suit and mask: KeepDivingGearOn. More...
 
virtual bool AllowOutsideSubmarine [get]
 
virtual bool AllowInFriendlySubs [get]
 
virtual bool AllowInAnySub [get]
 
virtual bool AllowWhileHandcuffed [get]
 
float CumulatedDevotion [get, set]
 
virtual float MaxDevotion [get]
 
float Priority [get, set]
 Final priority value after all calculations. More...
 
float BasePriority [get, set]
 
float PriorityModifier = 1 [get]
 
bool ForceHighestPriority [get, set]
 
bool ForceWalk [get, set]
 
bool IgnoreAtOutpost [get, set]
 
bool Abandon [get, set]
 
virtual bool CanBeCompleted [get]
 
virtual bool IsLoop [get, set]
 When true, the objective is never completed, unless CanBeCompleted returns false. More...
 
IEnumerable< AIObjectiveSubObjectives [get]
 
AIObjective CurrentSubObjective [get]
 
HumanAIController HumanAIController [get]
 
IndoorsSteeringManager PathSteering [get]
 
SteeringManager SteeringManager [get]
 
bool IsAllowed [get]
 
bool IsCompleted [get, protected set]
 
static Color ObjectiveIconColor [get]
 

Events

Action Completed
 A single shot event. Automatically cleared after launching. Use OnCompleted method for implementing (internal) persistent behavior. More...
 
Action Abandoned
 A single shot event. Automatically cleared after launching. Use OnAbandoned method for implementing (internal) persistent behavior. More...
 
Action Selected
 A single shot event. Automatically cleared after launching. Use OnSelected method for implementing (internal) persistent behavior. More...
 
Action Deselected
 A single shot event. Automatically cleared after launching. Use OnDeselected method for implementing (internal) persistent behavior. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ AIObjective()

Barotrauma.AIObjective.AIObjective ( Character  character,
AIObjectiveManager  objectiveManager,
float  priorityModifier,
Identifier  option = default 
)

Member Function Documentation

◆ Act()

◆ AddSubObjective()

void Barotrauma.AIObjective.AddSubObjective ( AIObjective  objective,
bool  addFirst = false 
)

◆ CalculatePriority()

float Barotrauma.AIObjective.CalculatePriority ( )

Call this only when the priority needs to be recalculated. Use the cached Priority property when you don't need to recalculate.

Definition at line 289 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ CanEquip() [1/2]

static bool Barotrauma.AIObjective.CanEquip ( Character  character,
Item  item,
bool  allowWearing 
)
staticprotected

◆ CanEquip() [2/2]

bool Barotrauma.AIObjective.CanEquip ( Item  item,
bool  allowWearing 
)
protected

◆ CheckObjectiveSpecific()

◆ GetActiveObjective()

AIObjective Barotrauma.AIObjective.GetActiveObjective ( )

◆ GetPriority()

◆ GetSprite() [1/2]

Sprite Barotrauma.AIObjective.GetSprite ( )

◆ GetSprite() [2/2]

static Sprite Barotrauma.AIObjective.GetSprite ( Identifier  identifier,
Identifier  option,
Entity  targetEntity 
)
static

◆ GetSubObjectivesRecursive()

IEnumerable<AIObjective> Barotrauma.AIObjective.GetSubObjectivesRecursive ( bool  includingSelf = false)

◆ HandleNonAllowed()

void Barotrauma.AIObjective.HandleNonAllowed ( )
protected

◆ IsDuplicate< T >()

virtual bool Barotrauma.AIObjective.IsDuplicate< T > ( otherObjective)
virtual

Reimplemented in Barotrauma.AIObjectiveOperateItem.

Type Constraints
T :AIObjective 
T :otherObjective.Option 
T :Option 

◆ IsIgnoredAtOutpost()

bool Barotrauma.AIObjective.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.

Definition at line 253 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ OnAbandon()

◆ OnCompleted()

virtual void Barotrauma.AIObjective.OnCompleted ( )
protectedvirtual

◆ OnDeselected()

virtual void Barotrauma.AIObjective.OnDeselected ( )
virtual

◆ OnSelected()

virtual void Barotrauma.AIObjective.OnSelected ( )
virtual

◆ RemoveSubObjective< T >()

void Barotrauma.AIObjective.RemoveSubObjective< T > ( ref T  objective)
Type Constraints
T :AIObjective 

Definition at line 200 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ Reset()

◆ SortSubObjectives()

void Barotrauma.AIObjective.SortSubObjectives ( )

◆ SpeakAfterOrderReceived()

virtual void Barotrauma.AIObjective.SpeakAfterOrderReceived ( )
virtual

◆ SyncRemovedObjectives< T1, T2 >()

void Barotrauma.AIObjective.SyncRemovedObjectives< T1, T2 > ( Dictionary< T1, T2 >  dictionary,
IEnumerable< T1 >  collection 
)
protected

Checks if the subobjectives in the given collection are removed from the subobjectives. And if so, removes it also from the dictionary.

Type Constraints
T2 :AIObjective 

Definition at line 328 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ TryAddSubObjective< T >()

bool Barotrauma.AIObjective.TryAddSubObjective< T > ( ref T  objective,
Func< T >  constructor,
Action  onCompleted = null,
Action  onAbandon = null 
)
protected

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.

Type Constraints
T :AIObjective 

Definition at line 347 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ TryComplete()

void Barotrauma.AIObjective.TryComplete ( float  deltaTime)

Makes the character act according to the objective, or according to any subobjectives that need to be completed before this one

Definition at line 173 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ Update()

Member Data Documentation

◆ AbortCondition

Func<AIObjective, bool> Barotrauma.AIObjective.AbortCondition

Aborts the objective when this condition is true.

Definition at line 132 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ character

readonly Character Barotrauma.AIObjective.character

◆ objectiveManager

readonly AIObjectiveManager Barotrauma.AIObjective.objectiveManager

◆ Option

readonly Identifier Barotrauma.AIObjective.Option

◆ subObjectives

readonly List<AIObjective> Barotrauma.AIObjective.subObjectives = new List<AIObjective>()
protected

Property Documentation

◆ Abandon

bool Barotrauma.AIObjective.Abandon
getset

◆ AbandonWhenCannotCompleteSubjectives

virtual bool Barotrauma.AIObjective.AbandonWhenCannotCompleteSubjectives
get

◆ AllowAutomaticItemUnequipping

virtual bool Barotrauma.AIObjective.AllowAutomaticItemUnequipping
get

There's a separate property for diving suit and mask: KeepDivingGearOn.

Definition at line 39 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ AllowInAnySub

virtual bool Barotrauma.AIObjective.AllowInAnySub
get

◆ AllowInFriendlySubs

virtual bool Barotrauma.AIObjective.AllowInFriendlySubs
get

◆ AllowMultipleInstances

virtual bool Barotrauma.AIObjective.AllowMultipleInstances
get

Can there be multiple objective instaces of the same type?

Definition at line 25 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ AllowOutsideSubmarine

virtual bool Barotrauma.AIObjective.AllowOutsideSubmarine
get

◆ AllowSubObjectiveSorting

virtual bool Barotrauma.AIObjective.AllowSubObjectiveSorting
get

◆ AllowWhileHandcuffed

virtual bool Barotrauma.AIObjective.AllowWhileHandcuffed
get

◆ BasePriority

float Barotrauma.AIObjective.BasePriority
getset

◆ CanBeCompleted

virtual bool Barotrauma.AIObjective.CanBeCompleted
get

◆ ConcurrentObjectives

virtual bool Barotrauma.AIObjective.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).

Definition at line 31 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ CumulatedDevotion

float Barotrauma.AIObjective.CumulatedDevotion
getsetprotected

◆ CurrentSubObjective

AIObjective Barotrauma.AIObjective.CurrentSubObjective
get

◆ DebugTag

virtual string Barotrauma.AIObjective.DebugTag
get

◆ Devotion

virtual float Barotrauma.AIObjective.Devotion
get

◆ ForceHighestPriority

bool Barotrauma.AIObjective.ForceHighestPriority
getset

◆ ForceRun

virtual bool Barotrauma.AIObjective.ForceRun
get

◆ ForceWalk

bool Barotrauma.AIObjective.ForceWalk
getset

◆ HumanAIController

HumanAIController Barotrauma.AIObjective.HumanAIController
getprotected

◆ Identifier

abstract Identifier Barotrauma.AIObjective.Identifier
getset

◆ IgnoreAtOutpost

bool Barotrauma.AIObjective.IgnoreAtOutpost
getset

◆ IgnoreUnsafeHulls

virtual bool Barotrauma.AIObjective.IgnoreUnsafeHulls
get

◆ IsAllowed

bool Barotrauma.AIObjective.IsAllowed
get

◆ IsCompleted

bool Barotrauma.AIObjective.IsCompleted
getprotected set

◆ IsLoop

virtual bool Barotrauma.AIObjective.IsLoop
getset

When true, the objective is never completed, unless CanBeCompleted returns false.

Definition at line 109 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ KeepDivingGearOn

virtual bool Barotrauma.AIObjective.KeepDivingGearOn
get

◆ KeepDivingGearOnAlsoWhenInactive

virtual bool Barotrauma.AIObjective.KeepDivingGearOnAlsoWhenInactive
get

◆ MaxDevotion

virtual float Barotrauma.AIObjective.MaxDevotion
getprotected

◆ ObjectiveIconColor

Color Barotrauma.AIObjective.ObjectiveIconColor
staticget

◆ PathSteering

IndoorsSteeringManager Barotrauma.AIObjective.PathSteering
getprotected

◆ PrioritizeIfSubObjectivesActive

virtual bool Barotrauma.AIObjective.PrioritizeIfSubObjectivesActive
get

◆ Priority

float Barotrauma.AIObjective.Priority
getset

Final priority value after all calculations.

Definition at line 58 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ PriorityModifier

float Barotrauma.AIObjective.PriorityModifier = 1
get

◆ SteeringManager

SteeringManager Barotrauma.AIObjective.SteeringManager
getprotected

◆ SubObjectives

IEnumerable<AIObjective> Barotrauma.AIObjective.SubObjectives
get

Event Documentation

◆ Abandoned

Action Barotrauma.AIObjective.Abandoned

A single shot event. Automatically cleared after launching. Use OnAbandoned method for implementing (internal) persistent behavior.

Definition at line 142 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ Completed

Action Barotrauma.AIObjective.Completed

A single shot event. Automatically cleared after launching. Use OnCompleted method for implementing (internal) persistent behavior.

Definition at line 138 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ Deselected

Action Barotrauma.AIObjective.Deselected

A single shot event. Automatically cleared after launching. Use OnDeselected method for implementing (internal) persistent behavior.

Definition at line 150 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.

◆ Selected

Action Barotrauma.AIObjective.Selected

A single shot event. Automatically cleared after launching. Use OnSelected method for implementing (internal) persistent behavior.

Definition at line 146 of file BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjective.cs.