Barotrauma Server 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 ()
 

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]
 

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

Definition at line 10 of file AIObjective.cs.

Constructor & Destructor Documentation

◆ AIObjective()

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

Definition at line 162 of file AIObjective.cs.

Member Function Documentation

◆ Act()

◆ AddSubObjective()

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

Definition at line 186 of file AIObjective.cs.

◆ 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 AIObjective.cs.

◆ CanEquip() [1/2]

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

Definition at line 512 of file AIObjective.cs.

◆ CanEquip() [2/2]

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

◆ CheckObjectiveSpecific()

◆ GetActiveObjective()

AIObjective Barotrauma.AIObjective.GetActiveObjective ( )

Definition at line 156 of file AIObjective.cs.

◆ GetPriority()

◆ GetSubObjectivesRecursive()

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

Definition at line 114 of file AIObjective.cs.

◆ HandleNonAllowed()

void Barotrauma.AIObjective.HandleNonAllowed ( )
protected

Definition at line 262 of file AIObjective.cs.

◆ 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 AIObjective.cs.

◆ OnAbandon()

◆ OnCompleted()

virtual void Barotrauma.AIObjective.OnCompleted ( )
protectedvirtual

◆ OnDeselected()

virtual void Barotrauma.AIObjective.OnDeselected ( )
virtual

Reimplemented in Barotrauma.AIObjectiveRescue, and Barotrauma.AIObjectiveIdle.

Definition at line 396 of file AIObjective.cs.

◆ OnSelected()

virtual void Barotrauma.AIObjective.OnSelected ( )
virtual

Definition at line 389 of file AIObjective.cs.

◆ RemoveSubObjective< T >()

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

Definition at line 200 of file AIObjective.cs.

◆ Reset()

◆ SortSubObjectives()

void Barotrauma.AIObjective.SortSubObjectives ( )

Definition at line 212 of file AIObjective.cs.

◆ SpeakAfterOrderReceived()

virtual void Barotrauma.AIObjective.SpeakAfterOrderReceived ( )
virtual

Definition at line 510 of file AIObjective.cs.

◆ 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 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 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 AIObjective.cs.

◆ Update()

virtual void Barotrauma.AIObjective.Update ( float  deltaTime)
virtual

Member Data Documentation

◆ AbortCondition

Func<AIObjective, bool> Barotrauma.AIObjective.AbortCondition

Aborts the objective when this condition is true.

Definition at line 132 of file AIObjective.cs.

◆ character

readonly Character Barotrauma.AIObjective.character

Definition at line 86 of file AIObjective.cs.

◆ objectiveManager

readonly AIObjectiveManager Barotrauma.AIObjective.objectiveManager

Definition at line 87 of file AIObjective.cs.

◆ Option

readonly Identifier Barotrauma.AIObjective.Option

Definition at line 88 of file AIObjective.cs.

◆ subObjectives

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

Definition at line 45 of file AIObjective.cs.

Property Documentation

◆ Abandon

bool Barotrauma.AIObjective.Abandon
getset

Definition at line 91 of file AIObjective.cs.

◆ AbandonWhenCannotCompleteSubjectives

virtual bool Barotrauma.AIObjective.AbandonWhenCannotCompleteSubjectives
get

Definition at line 18 of file AIObjective.cs.

◆ AllowAutomaticItemUnequipping

virtual bool Barotrauma.AIObjective.AllowAutomaticItemUnequipping
get

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

Definition at line 39 of file AIObjective.cs.

◆ AllowInAnySub

virtual bool Barotrauma.AIObjective.AllowInAnySub
get

Definition at line 42 of file AIObjective.cs.

◆ AllowInFriendlySubs

virtual bool Barotrauma.AIObjective.AllowInFriendlySubs
get

Definition at line 41 of file AIObjective.cs.

◆ AllowMultipleInstances

virtual bool Barotrauma.AIObjective.AllowMultipleInstances
get

Can there be multiple objective instaces of the same type?

Definition at line 25 of file AIObjective.cs.

◆ AllowOutsideSubmarine

virtual bool Barotrauma.AIObjective.AllowOutsideSubmarine
get

Definition at line 40 of file AIObjective.cs.

◆ AllowSubObjectiveSorting

virtual bool Barotrauma.AIObjective.AllowSubObjectiveSorting
get

Definition at line 19 of file AIObjective.cs.

◆ AllowWhileHandcuffed

virtual bool Barotrauma.AIObjective.AllowWhileHandcuffed
get

Definition at line 43 of file AIObjective.cs.

◆ BasePriority

float Barotrauma.AIObjective.BasePriority
getset

Definition at line 59 of file AIObjective.cs.

◆ CanBeCompleted

virtual bool Barotrauma.AIObjective.CanBeCompleted
get

Definition at line 104 of file AIObjective.cs.

◆ 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 AIObjective.cs.

◆ CumulatedDevotion

float Barotrauma.AIObjective.CumulatedDevotion
getsetprotected

Definition at line 47 of file AIObjective.cs.

◆ CurrentSubObjective

AIObjective Barotrauma.AIObjective.CurrentSubObjective
get

Definition at line 111 of file AIObjective.cs.

◆ DebugTag

virtual string Barotrauma.AIObjective.DebugTag
get

Definition at line 15 of file AIObjective.cs.

◆ Devotion

virtual float Barotrauma.AIObjective.Devotion
get

Definition at line 12 of file AIObjective.cs.

◆ ForceHighestPriority

bool Barotrauma.AIObjective.ForceHighestPriority
getset

Definition at line 66 of file AIObjective.cs.

◆ ForceRun

virtual bool Barotrauma.AIObjective.ForceRun
get

Definition at line 16 of file AIObjective.cs.

◆ ForceWalk

bool Barotrauma.AIObjective.ForceWalk
getset

Definition at line 82 of file AIObjective.cs.

◆ HumanAIController

HumanAIController Barotrauma.AIObjective.HumanAIController
getprotected

Definition at line 152 of file AIObjective.cs.

◆ Identifier

abstract Identifier Barotrauma.AIObjective.Identifier
getset

Definition at line 14 of file AIObjective.cs.

◆ IgnoreAtOutpost

bool Barotrauma.AIObjective.IgnoreAtOutpost
getset

Definition at line 84 of file AIObjective.cs.

◆ IgnoreUnsafeHulls

virtual bool Barotrauma.AIObjective.IgnoreUnsafeHulls
get

Definition at line 17 of file AIObjective.cs.

◆ IsAllowed

bool Barotrauma.AIObjective.IsAllowed
get

Definition at line 235 of file AIObjective.cs.

◆ IsCompleted

bool Barotrauma.AIObjective.IsCompleted
getprotected set

Definition at line 429 of file AIObjective.cs.

◆ IsLoop

virtual bool Barotrauma.AIObjective.IsLoop
getset

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

Definition at line 109 of file AIObjective.cs.

◆ KeepDivingGearOn

virtual bool Barotrauma.AIObjective.KeepDivingGearOn
get

Definition at line 33 of file AIObjective.cs.

◆ KeepDivingGearOnAlsoWhenInactive

virtual bool Barotrauma.AIObjective.KeepDivingGearOnAlsoWhenInactive
get

Definition at line 34 of file AIObjective.cs.

◆ MaxDevotion

virtual float Barotrauma.AIObjective.MaxDevotion
getprotected

Definition at line 53 of file AIObjective.cs.

◆ PathSteering

IndoorsSteeringManager Barotrauma.AIObjective.PathSteering
getprotected

Definition at line 153 of file AIObjective.cs.

◆ PrioritizeIfSubObjectivesActive

virtual bool Barotrauma.AIObjective.PrioritizeIfSubObjectivesActive
get

Definition at line 20 of file AIObjective.cs.

◆ Priority

float Barotrauma.AIObjective.Priority
getset

Final priority value after all calculations.

Definition at line 58 of file AIObjective.cs.

◆ PriorityModifier

float Barotrauma.AIObjective.PriorityModifier = 1
get

Definition at line 60 of file AIObjective.cs.

◆ SteeringManager

SteeringManager Barotrauma.AIObjective.SteeringManager
getprotected

Definition at line 154 of file AIObjective.cs.

◆ SubObjectives

IEnumerable<AIObjective> Barotrauma.AIObjective.SubObjectives
get

Definition at line 110 of file AIObjective.cs.

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 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 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 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 AIObjective.cs.