Barotrauma Client Doc
Barotrauma.HumanAIController Class Reference
Inheritance diagram for Barotrauma.HumanAIController:
Barotrauma.AIController Barotrauma.AIController Barotrauma.ISteerable Barotrauma.ISteerable Barotrauma.ISteerable Barotrauma.ISteerable

Public Member Functions

void InitMentalStateManager ()
 
void InitShipCommandManager ()
 
 HumanAIController (Character c)
 
override void Update (float deltaTime)
 
bool FindSuitableContainer (Item containableItem, out Item suitableContainer)
 
override void OnHealed (Character healer, float healAmount)
 
override void OnAttacked (Character attacker, AttackResult attackResult)
 
void AddCombatObjective (AIObjectiveCombat.CombatMode mode, Character target, float delay=0, Func< AIObjective, bool > abortCondition=null, Action onAbort=null, Action onCompleted=null, bool allowHoldFire=false)
 
void SetOrder (Order order, bool speak=true)
 
void SetForcedOrder (Order order)
 
void ClearForcedOrder ()
 
override void SelectTarget (AITarget target)
 
override void Reset ()
 
override bool Escape (float deltaTime)
 
bool AllowCampaignInteraction ()
 
bool NeedsDivingGear (Hull hull, out bool needsSuit)
 
void AskToRecalculateHullSafety (Hull hull)
 
float GetHullSafety (Hull hull, Character character, IEnumerable< Hull > visibleHulls=null)
 
bool IsInHostileFaction ()
 
bool IsTrueForAnyCrewMember (Func< Character, bool > predicate, bool onlyActive=true, bool onlyConnectedSubs=false)
 Including the player characters in the same team. More...
 
bool IsItemOperatedByAnother (ItemComponent target, out Character other)
 
bool IsItemRepairedByAnother (Item target, out Character other)
 
bool IsFriendly (Character other, bool onlySameTeam=false)
 
bool IsTrueForAnyBotInTheCrew (Func< HumanAIController, bool > predicate)
 
bool IsTrueForAllBotsInTheCrew (Func< HumanAIController, bool > predicate)
 
int CountBotsInTheCrew (Func< HumanAIController, bool > predicate=null)
 
override void DebugDraw (Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
 
- Public Member Functions inherited from Barotrauma.AIController
bool HasValidPath (bool requireNonDirty=true, bool requireUnfinished=true, Func< WayPoint, bool > nodePredicate=null)
 Is the current path valid, using the provided parameters. More...
 
 AIController (Character c)
 
void FaceTarget (ISpatialEntity target)
 
virtual bool SteerThroughGap (Structure wall, WallSection section, Vector2 targetWorldPos, float deltaTime)
 
virtual bool SteerThroughGap (Gap gap, Vector2 targetWorldPos, float deltaTime, float maxDistance=-1)
 
bool CanPassThroughHole (Structure wall, int sectionIndex, int requiredHoleCount)
 
bool TakeItem (Item item, CharacterInventory targetInventory, bool equip, bool wear=false, bool dropOtherIfCannotMove=true, bool allowSwapping=false, bool storeUnequipped=false, IEnumerable< Identifier > targetTags=null)
 
void UnequipEmptyItems (Item parentItem, bool avoidDroppingInSea=true)
 
void UnequipContainedItems (Item parentItem, Func< Item, bool > predicate=null, bool avoidDroppingInSea=true, int? unequipMax=null)
 
void ReequipUnequipped ()
 
void ResetEscape ()
 
virtual void DebugDraw (SpriteBatch spriteBatch)
 

Static Public Member Functions

static bool FindSuitableContainer (Character character, Item containableItem, List< Item > ignoredItems, ref int itemIndex, out Item suitableContainer)
 
static bool IsBallastFloraNoticeable (Character character, Hull hull)
 
static void ReportProblem (Character reporter, Order order, Hull targetHull=null)
 
static bool HasDivingGear (Character character, float conditionPercentage=0, bool requireOxygenTank=true)
 
static bool HasDivingSuit (Character character, float conditionPercentage=0, bool requireOxygenTank=true)
 Check whether the character has a diving suit in usable condition plus some oxygen. More...
 
static bool HasDivingMask (Character character, float conditionPercentage=0, bool requireOxygenTank=true)
 Check whether the character has a diving mask in usable condition plus some oxygen. More...
 
static bool HasItem (Character character, Identifier tagOrIdentifier, out IEnumerable< Item > items, Identifier containedTag=default, float conditionPercentage=0, bool requireEquipped=false, bool recursive=true, Func< Item, bool > predicate=null)
 Note: uses a single list for matching items. The item is reused each time when the method is called. So if you use the method twice, and then refer to the first items, you'll actually get the second. To solve this, create a copy of the collection or change the code so that you first handle the first items and only after that query for the next items. More...
 
static void StructureDamaged (Structure structure, float damageAmount, Character character)
 
static void ItemTaken (Item item, Character thief)
 
static void ApplyStealingReputationLoss (Item item)
 
static void PropagateHullSafety (Character character, Hull hull)
 Updates the hull safety for all ai characters in the team. The idea is that the crew communicates (magically) via radio about the threats. The safety levels need to be calculated for each bot individually, because the formula takes into account things like current orders. There's now a cached value per each hull, which should prevent too frequent calculations. More...
 
static void RefreshTargets (Character character, Order order, Hull hull)
 
static void RemoveTargets< T1, T2 > (Character caller, T2 target)
 
static float GetHullSafety (Hull hull, IEnumerable< Hull > visibleHulls, Character character, bool ignoreWater=false, bool ignoreOxygen=false, bool ignoreFire=false, bool ignoreEnemies=false)
 
static bool IsFriendly (Character me, Character other, bool onlySameTeam=false)
 
static bool IsActive (Character c)
 
static bool IsTrueForAllBotsInTheCrew (Character character, Func< HumanAIController, bool > predicate)
 
static bool IsTrueForAnyBotInTheCrew (Character character, Func< HumanAIController, bool > predicate)
 
static int CountBotsInTheCrew (Character character, Func< HumanAIController, bool > predicate=null)
 
static bool IsItemTargetedBySomeone (ItemComponent target, CharacterTeamType team, out Character operatingCharacter)
 
- Static Public Member Functions inherited from Barotrauma.AIController
static void UnequipEmptyItems (Character character, Item parentItem, bool avoidDroppingInSea=true)
 
static void UnequipContainedItems (Character character, Item parentItem, Func< Item, bool > predicate, bool avoidDroppingInSea=true, int? unequipMax=null)
 

Public Attributes

bool AutoFaceMovement = true
 Resets each frame More...
 
readonly HashSet< HullUnreachableHulls = new HashSet<Hull>()
 
readonly HashSet< HullUnsafeHulls = new HashSet<Hull>()
 
readonly List< ItemIgnoredItems = new List<Item>()
 
- Public Attributes inherited from Barotrauma.AIController
bool Enabled
 
readonly Character Character
 

Static Public Attributes

static bool DebugAI
 
static bool DisableCrewAI
 
const float HULL_SAFETY_THRESHOLD = 40
 
const float HULL_LOW_OXYGEN_PERCENTAGE = 30
 

Protected Member Functions

void ReportProblems ()
 
- Protected Member Functions inherited from Barotrauma.AIController
void ResetAITarget ()
 
bool IsWallDisabled (Structure wall)
 
bool UpdateEscape (float deltaTime, bool canAttackDoors)
 
virtual void OnStateChanged (AIState from, AIState to)
 
virtual void OnTargetChanged (AITarget previousTarget, AITarget newTarget)
 

Properties

float SortTimer [get, set]
 
float ReportRange = float.PositiveInfinity [get, set]
 How far other characters can hear reports done by this character (e.g. reports for fires, intruders). Defaults to infinity. More...
 
float AimSpeed [get, set]
 
float AimAccuracy [get, set]
 
bool UseOutsideWaypoints [get]
 Waypoints that are not linked to a sub (e.g. main path). More...
 
IndoorsSteeringManager PathSteering [get]
 
HumanoidAnimController AnimController [get]
 
AIObjectiveManager ObjectiveManager [get]
 
float CurrentHullSafety = 100 [get]
 
MentalStateManager MentalStateManager [get]
 
override bool IsMentallyUnstable [get]
 
ShipCommandManager ShipCommandManager [get]
 
- Properties inherited from Barotrauma.AIController
AITarget SelectedAiTarget [get, protected set]
 
SteeringManager SteeringManager [get]
 
Vector2 Steering [get, set]
 
Vector2 SimPosition [get]
 
Vector2 WorldPosition [get]
 
Vector2 Velocity [get]
 
virtual bool CanEnterSubmarine [get]
 
virtual bool CanFlip [get]
 
virtual bool IsMentallyUnstable [get]
 
IEnumerable< HullVisibleHulls [get]
 Returns hulls that are visible to the character, including the current hull. Note that this is not an accurate visibility check, it only checks for open gaps between the adjacent and linked hulls. More...
 
bool IsCurrentPathNullOrUnreachable [get]
 
bool IsCurrentPathUnreachable [get]
 
bool IsCurrentPathFinished [get]
 
bool IsSteeringThroughGap [get, protected set]
 
bool IsTryingToSteerThroughGap [get, protected set]
 
Gap EscapeTarget [get]
 
- Properties inherited from Barotrauma.ISteerable
Vector2 Steering [get, set]
 
Vector2 Velocity [get]
 
Vector2 SimPosition [get]
 
Vector2 WorldPosition [get]
 

Additional Inherited Members

- Protected Attributes inherited from Barotrauma.AIController
AITarget _lastAiTarget
 
AITarget _previousAiTarget
 
AITarget _selectedAiTarget
 
SteeringManager steeringManager
 
readonly float colliderWidth
 
readonly float minGapSize
 
readonly float colliderLength
 
readonly float avoidLookAheadDistance
 
bool allGapsSearched
 
readonly HashSet< GapunreachableGaps = new HashSet<Gap>()
 

Detailed Description

Constructor & Destructor Documentation

◆ HumanAIController()

Barotrauma.HumanAIController.HumanAIController ( Character  c)

Member Function Documentation

◆ AddCombatObjective()

void Barotrauma.HumanAIController.AddCombatObjective ( AIObjectiveCombat.CombatMode  mode,
Character  target,
float  delay = 0,
Func< AIObjective, bool >  abortCondition = null,
Action  onAbort = null,
Action  onCompleted = null,
bool  allowHoldFire = false 
)

◆ AllowCampaignInteraction()

bool Barotrauma.HumanAIController.AllowCampaignInteraction ( )

◆ ApplyStealingReputationLoss()

static void Barotrauma.HumanAIController.ApplyStealingReputationLoss ( Item  item)
static

◆ AskToRecalculateHullSafety()

void Barotrauma.HumanAIController.AskToRecalculateHullSafety ( Hull  hull)

◆ ClearForcedOrder()

void Barotrauma.HumanAIController.ClearForcedOrder ( )

◆ CountBotsInTheCrew() [1/2]

static int Barotrauma.HumanAIController.CountBotsInTheCrew ( Character  character,
Func< HumanAIController, bool >  predicate = null 
)
static

◆ CountBotsInTheCrew() [2/2]

int Barotrauma.HumanAIController.CountBotsInTheCrew ( Func< HumanAIController, bool >  predicate = null)

◆ DebugDraw()

override void Barotrauma.HumanAIController.DebugDraw ( Microsoft.Xna.Framework.Graphics.SpriteBatch  spriteBatch)

◆ Escape()

override bool Barotrauma.HumanAIController.Escape ( float  deltaTime)
virtual

◆ FindSuitableContainer() [1/2]

static bool Barotrauma.HumanAIController.FindSuitableContainer ( Character  character,
Item  containableItem,
List< Item ignoredItems,
ref int  itemIndex,
out Item  suitableContainer 
)
static

◆ FindSuitableContainer() [2/2]

bool Barotrauma.HumanAIController.FindSuitableContainer ( Item  containableItem,
out Item  suitableContainer 
)

◆ GetHullSafety() [1/2]

float Barotrauma.HumanAIController.GetHullSafety ( Hull  hull,
Character  character,
IEnumerable< Hull visibleHulls = null 
)

◆ GetHullSafety() [2/2]

static float Barotrauma.HumanAIController.GetHullSafety ( Hull  hull,
IEnumerable< Hull visibleHulls,
Character  character,
bool  ignoreWater = false,
bool  ignoreOxygen = false,
bool  ignoreFire = false,
bool  ignoreEnemies = false 
)
static

◆ HasDivingGear()

static bool Barotrauma.HumanAIController.HasDivingGear ( Character  character,
float  conditionPercentage = 0,
bool  requireOxygenTank = true 
)
static

◆ HasDivingMask()

static bool Barotrauma.HumanAIController.HasDivingMask ( Character  character,
float  conditionPercentage = 0,
bool  requireOxygenTank = true 
)
static

Check whether the character has a diving mask in usable condition plus some oxygen.

◆ HasDivingSuit()

static bool Barotrauma.HumanAIController.HasDivingSuit ( Character  character,
float  conditionPercentage = 0,
bool  requireOxygenTank = true 
)
static

Check whether the character has a diving suit in usable condition plus some oxygen.

◆ HasItem()

static bool Barotrauma.HumanAIController.HasItem ( Character  character,
Identifier  tagOrIdentifier,
out IEnumerable< Item items,
Identifier  containedTag = default,
float  conditionPercentage = 0,
bool  requireEquipped = false,
bool  recursive = true,
Func< Item, bool >  predicate = null 
)
static

Note: uses a single list for matching items. The item is reused each time when the method is called. So if you use the method twice, and then refer to the first items, you'll actually get the second. To solve this, create a copy of the collection or change the code so that you first handle the first items and only after that query for the next items.

Definition at line 1701 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.

◆ InitMentalStateManager()

void Barotrauma.HumanAIController.InitMentalStateManager ( )

◆ InitShipCommandManager()

void Barotrauma.HumanAIController.InitShipCommandManager ( )

◆ IsActive()

static bool Barotrauma.HumanAIController.IsActive ( Character  c)
static

◆ IsBallastFloraNoticeable()

static bool Barotrauma.HumanAIController.IsBallastFloraNoticeable ( Character  character,
Hull  hull 
)
static

◆ IsFriendly() [1/2]

static bool Barotrauma.HumanAIController.IsFriendly ( Character  me,
Character  other,
bool  onlySameTeam = false 
)
static

◆ IsFriendly() [2/2]

bool Barotrauma.HumanAIController.IsFriendly ( Character  other,
bool  onlySameTeam = false 
)

◆ IsInHostileFaction()

bool Barotrauma.HumanAIController.IsInHostileFaction ( )

◆ IsItemOperatedByAnother()

bool Barotrauma.HumanAIController.IsItemOperatedByAnother ( ItemComponent  target,
out Character  other 
)

◆ IsItemRepairedByAnother()

bool Barotrauma.HumanAIController.IsItemRepairedByAnother ( Item  target,
out Character  other 
)

◆ IsItemTargetedBySomeone()

static bool Barotrauma.HumanAIController.IsItemTargetedBySomeone ( ItemComponent  target,
CharacterTeamType  team,
out Character  operatingCharacter 
)
static

◆ IsTrueForAllBotsInTheCrew() [1/2]

static bool Barotrauma.HumanAIController.IsTrueForAllBotsInTheCrew ( Character  character,
Func< HumanAIController, bool >  predicate 
)
static

◆ IsTrueForAllBotsInTheCrew() [2/2]

bool Barotrauma.HumanAIController.IsTrueForAllBotsInTheCrew ( Func< HumanAIController, bool >  predicate)

◆ IsTrueForAnyBotInTheCrew() [1/2]

static bool Barotrauma.HumanAIController.IsTrueForAnyBotInTheCrew ( Character  character,
Func< HumanAIController, bool >  predicate 
)
static

◆ IsTrueForAnyBotInTheCrew() [2/2]

bool Barotrauma.HumanAIController.IsTrueForAnyBotInTheCrew ( Func< HumanAIController, bool >  predicate)

◆ IsTrueForAnyCrewMember()

bool Barotrauma.HumanAIController.IsTrueForAnyCrewMember ( Func< Character, bool >  predicate,
bool  onlyActive = true,
bool  onlyConnectedSubs = false 
)

Including the player characters in the same team.

Definition at line 2305 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.

◆ ItemTaken()

static void Barotrauma.HumanAIController.ItemTaken ( Item  item,
Character  thief 
)
static

◆ NeedsDivingGear()

bool Barotrauma.HumanAIController.NeedsDivingGear ( Hull  hull,
out bool  needsSuit 
)

◆ OnAttacked()

override void Barotrauma.HumanAIController.OnAttacked ( Character  attacker,
AttackResult  attackResult 
)
virtual

◆ OnHealed()

override void Barotrauma.HumanAIController.OnHealed ( Character  healer,
float  healAmount 
)
virtual

◆ PropagateHullSafety()

static void Barotrauma.HumanAIController.PropagateHullSafety ( Character  character,
Hull  hull 
)
static

Updates the hull safety for all ai characters in the team. The idea is that the crew communicates (magically) via radio about the threats. The safety levels need to be calculated for each bot individually, because the formula takes into account things like current orders. There's now a cached value per each hull, which should prevent too frequent calculations.

Definition at line 1935 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.

◆ RefreshTargets()

static void Barotrauma.HumanAIController.RefreshTargets ( Character  character,
Order  order,
Hull  hull 
)
static

◆ RemoveTargets< T1, T2 >()

static void Barotrauma.HumanAIController.RemoveTargets< T1, T2 > ( Character  caller,
T2  target 
)
static
Type Constraints
T1 :AIObjectiveLoop<T2> 

Definition at line 2029 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.

◆ ReportProblem()

static void Barotrauma.HumanAIController.ReportProblem ( Character  reporter,
Order  order,
Hull  targetHull = null 
)
static

◆ ReportProblems()

void Barotrauma.HumanAIController.ReportProblems ( )
protected

◆ Reset()

override void Barotrauma.HumanAIController.Reset ( )
virtual

◆ SelectTarget()

override void Barotrauma.HumanAIController.SelectTarget ( AITarget  target)
virtual

◆ SetForcedOrder()

void Barotrauma.HumanAIController.SetForcedOrder ( Order  order)

◆ SetOrder()

void Barotrauma.HumanAIController.SetOrder ( Order  order,
bool  speak = true 
)

◆ StructureDamaged()

static void Barotrauma.HumanAIController.StructureDamaged ( Structure  structure,
float  damageAmount,
Character  character 
)
static

◆ Update()

override void Barotrauma.HumanAIController.Update ( float  deltaTime)
virtual

Member Data Documentation

◆ AutoFaceMovement

bool Barotrauma.HumanAIController.AutoFaceMovement = true

Resets each frame

Definition at line 26 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.

◆ DebugAI

bool Barotrauma.HumanAIController.DebugAI
static

◆ DisableCrewAI

bool Barotrauma.HumanAIController.DisableCrewAI
static

◆ HULL_LOW_OXYGEN_PERCENTAGE

const float Barotrauma.HumanAIController.HULL_LOW_OXYGEN_PERCENTAGE = 30
static

◆ HULL_SAFETY_THRESHOLD

const float Barotrauma.HumanAIController.HULL_SAFETY_THRESHOLD = 40
static

◆ IgnoredItems

readonly List<Item> Barotrauma.HumanAIController.IgnoredItems = new List<Item>()

◆ UnreachableHulls

readonly HashSet<Hull> Barotrauma.HumanAIController.UnreachableHulls = new HashSet<Hull>()

◆ UnsafeHulls

readonly HashSet<Hull> Barotrauma.HumanAIController.UnsafeHulls = new HashSet<Hull>()

Property Documentation

◆ AimAccuracy

float Barotrauma.HumanAIController.AimAccuracy
getset

◆ AimSpeed

float Barotrauma.HumanAIController.AimSpeed
getset

◆ AnimController

HumanoidAnimController Barotrauma.HumanAIController.AnimController
get

◆ CurrentHullSafety

float Barotrauma.HumanAIController.CurrentHullSafety = 100
get

◆ IsMentallyUnstable

override bool Barotrauma.HumanAIController.IsMentallyUnstable
get

◆ MentalStateManager

MentalStateManager Barotrauma.HumanAIController.MentalStateManager
get

◆ ObjectiveManager

AIObjectiveManager Barotrauma.HumanAIController.ObjectiveManager
get

◆ PathSteering

IndoorsSteeringManager Barotrauma.HumanAIController.PathSteering
get

◆ ReportRange

float Barotrauma.HumanAIController.ReportRange = float.PositiveInfinity
getset

How far other characters can hear reports done by this character (e.g. reports for fires, intruders). Defaults to infinity.

Definition at line 74 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.

◆ ShipCommandManager

ShipCommandManager Barotrauma.HumanAIController.ShipCommandManager
get

◆ SortTimer

float Barotrauma.HumanAIController.SortTimer
getset

◆ UseOutsideWaypoints

bool Barotrauma.HumanAIController.UseOutsideWaypoints
get

Waypoints that are not linked to a sub (e.g. main path).

Definition at line 101 of file BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs.