Barotrauma Client Doc
Barotrauma.CharacterHealth Class Reference

Classes

class  DamageOverlayPrefab
 
class  LimbHealth
 

Public Member Functions

 CharacterHealth (Character character)
 
 CharacterHealth (ContentXElement element, Character character, ContentXElement limbHealthElement=null)
 
IReadOnlyCollection< AfflictionGetAllAfflictions ()
 
IEnumerable< AfflictionGetAllAfflictions (Func< Affliction, bool > limbHealthFilter)
 
Affliction GetAffliction (string identifier, bool allowLimbAfflictions=true)
 
Affliction GetAffliction (Identifier identifier, bool allowLimbAfflictions=true)
 
Affliction GetAfflictionOfType (Identifier afflictionType, bool allowLimbAfflictions=true)
 
GetAffliction< T > (Identifier identifier, bool allowLimbAfflictions=true)
 
Affliction GetAffliction (Identifier identifier, Limb limb)
 
Limb GetAfflictionLimb (Affliction affliction)
 
float GetAfflictionStrength (Identifier afflictionType, Limb limb, bool requireLimbSpecific)
 Get the total strength of the afflictions of a specific type attached to a specific limb More...
 
float GetAfflictionStrengthByType (Identifier afflictionType, bool allowLimbAfflictions=true)
 
float GetAfflictionStrengthByIdentifier (Identifier afflictionIdentifier, bool allowLimbAfflictions=true)
 
float GetAfflictionStrength (Identifier afflictionType, Identifier afflictionidentifier, bool allowLimbAfflictions=true)
 
void ApplyAffliction (Limb targetLimb, Affliction affliction, bool allowStacking=true, bool ignoreUnkillability=false)
 
float GetResistance (AfflictionPrefab afflictionPrefab)
 
float GetStatValue (StatTypes statType)
 
bool HasFlag (AbilityFlags flagType)
 
void ReduceAllAfflictionsOnAllLimbs (float amount, ActionType? treatmentAction=null)
 
void ReduceAfflictionOnAllLimbs (Identifier afflictionIdOrType, float amount, ActionType? treatmentAction=null)
 
void ReduceAllAfflictionsOnLimb (Limb targetLimb, float amount, ActionType? treatmentAction=null)
 
void ReduceAfflictionOnLimb (Limb targetLimb, Identifier afflictionIdOrType, float amount, ActionType? treatmentAction=null)
 
void ApplyDamage (Limb hitLimb, AttackResult attackResult, bool allowStacking=true)
 
void SetAllDamage (float damageAmount, float bleedingDamageAmount, float burnDamageAmount)
 
float GetLimbDamage (Limb limb, Identifier afflictionType)
 
void RemoveAllAfflictions ()
 
void RemoveNegativeAfflictions ()
 
void Update (float deltaTime)
 
void ForceUpdateVisuals ()
 
void SetVitality (float newVitality)
 
void CalculateVitality ()
 
void ApplyAfflictionStatusEffects (ActionType type)
 
void GetSuitableTreatments (Dictionary< Identifier, float > treatmentSuitability, bool normalize, Character user, Limb limb=null, bool ignoreHiddenAfflictions=false, float predictFutureDuration=0.0f)
 Get the identifiers of the items that can be used to treat the character. Takes into account all the afflictions the character has, and negative treatment suitabilities (e.g. a medicine that causes oxygen loss may not be suitable if the character is already suffocating) More...
 
float GetTotalAdjustedAfflictionStrength (Affliction affliction, float otherAfflictionMultiplier=0.3f, bool includeSameAffliction=true)
 Returns the total strength of instances of the same affliction on all the characters limbs, with a smaller weight given to the other afflictions on other limbs More...
 
IEnumerable< IdentifierGetActiveAfflictionTags ()
 
float GetPredictedStrength (Affliction affliction, float predictFutureDuration, Limb limb=null)
 
void ServerWrite (IWriteMessage msg)
 
void Remove ()
 
void Save (XElement healthElement)
 
void Load (XElement element, Func< AfflictionPrefab, bool > afflictionPredicate=null)
 
void UpdateClientSpecific (float deltaTime)
 
void UpdateHUD (float deltaTime)
 
void AddToGUIUpdateList ()
 
void DrawHUD (SpriteBatch spriteBatch)
 
void UpdateStatusHUD (float deltaTime)
 
bool OnItemDropped (Item item, bool ignoreMousePos)
 
void SetHealthBarVisibility (bool value)
 
void ClientRead (IReadMessage inc)
 

Static Public Member Functions

static IEnumerable< AfflictionSortAfflictionsBySeverity (IEnumerable< Affliction > afflictions, bool excludeBuffs=true)
 Automatically filters out buffs. More...
 
static bool IsMouseOnHealthBar ()
 
static Color GetAfflictionIconColor (AfflictionPrefab prefab, Affliction affliction)
 
static Color GetAfflictionIconColor (AfflictionPrefab prefab, float afflictionStrength)
 
static Color GetAfflictionIconColor (Affliction affliction)
 

Public Attributes

bool Unkillable
 
readonly Character Character
 
CauseOfDeathType type
 
float DisplayedVitality
 

Static Public Attributes

const float InsufficientOxygenThreshold = 30.0f
 
const float LowOxygenThreshold = 50.0f
 
static readonly Color DefaultFaceTint = Color.TransparentBlack
 

Protected Attributes

float minVitality
 

Properties

float UnmodifiedMaxVitality [get, set]
 Maximum vitality without talent- or job-based modifiers More...
 
bool DoesBleed [get]
 
bool UseHealthWindow [get, set]
 
float CrushDepth [get]
 
Affliction BloodlossAffliction [get]
 
bool IsUnconscious [get]
 
float PressureKillDelay = 5.0f [get]
 
float Vitality [get]
 
float VitalityDisregardingDeath [get]
 How much vitality the character would have if it was alive? E.g. a character killed by disconnection or with console commands may not have any vitality-reducing afflictions despite being dead More...
 
float HealthPercentage [get]
 
float??? MaxVitality [get]
 
float??? MinVitality [get]
 
Color FaceTint [get]
 
Color BodyTint [get]
 
float OxygenAmount [get, set]
 
float BloodlossAmount [get, set]
 
float Stun [get, set]
 
bool IsParalyzed [get]
 
float StunTimer [get]
 
bool WasInFullHealth [get]
 Was the character in full health at the beginning of the frame? More...
 
Affliction PressureAffliction [get]
 
float OxygenLowResistance [get]
 0-1. More...
 
static Sprite DamageOverlay [get]
 
Alignment Alignment [get, set]
 
GUIButton SuicideButton [get]
 
float DamageOverlayTimer [get]
 
bool MouseOnElement [get]
 
static CharacterHealth?? OpenHealthWindow [get, set]
 
GUIButton CPRButton [get]
 
GUIComponent InventorySlotContainer [get]
 
float HealthBarPulsateTimer [get, set]
 

Detailed Description

Constructor & Destructor Documentation

◆ CharacterHealth() [1/2]

Barotrauma.CharacterHealth.CharacterHealth ( Character  character)

◆ CharacterHealth() [2/2]

Barotrauma.CharacterHealth.CharacterHealth ( ContentXElement  element,
Character  character,
ContentXElement  limbHealthElement = null 
)

Member Function Documentation

◆ AddToGUIUpdateList()

void Barotrauma.CharacterHealth.AddToGUIUpdateList ( )

◆ ApplyAffliction()

void Barotrauma.CharacterHealth.ApplyAffliction ( Limb  targetLimb,
Affliction  affliction,
bool  allowStacking = true,
bool  ignoreUnkillability = false 
)

◆ ApplyAfflictionStatusEffects()

void Barotrauma.CharacterHealth.ApplyAfflictionStatusEffects ( ActionType  type)

◆ ApplyDamage()

void Barotrauma.CharacterHealth.ApplyDamage ( Limb  hitLimb,
AttackResult  attackResult,
bool  allowStacking = true 
)

◆ CalculateVitality()

void Barotrauma.CharacterHealth.CalculateVitality ( )

◆ ClientRead()

void Barotrauma.CharacterHealth.ClientRead ( IReadMessage  inc)

◆ DrawHUD()

void Barotrauma.CharacterHealth.DrawHUD ( SpriteBatch  spriteBatch)

◆ ForceUpdateVisuals()

void Barotrauma.CharacterHealth.ForceUpdateVisuals ( )

◆ GetActiveAfflictionTags()

IEnumerable<Identifier> Barotrauma.CharacterHealth.GetActiveAfflictionTags ( )

◆ GetAffliction() [1/3]

Affliction Barotrauma.CharacterHealth.GetAffliction ( Identifier  identifier,
bool  allowLimbAfflictions = true 
)

◆ GetAffliction() [2/3]

Affliction Barotrauma.CharacterHealth.GetAffliction ( Identifier  identifier,
Limb  limb 
)

◆ GetAffliction() [3/3]

Affliction Barotrauma.CharacterHealth.GetAffliction ( string  identifier,
bool  allowLimbAfflictions = true 
)

◆ GetAffliction< T >()

T Barotrauma.CharacterHealth.GetAffliction< T > ( Identifier  identifier,
bool  allowLimbAfflictions = true 
)
Type Constraints
T :Affliction 

Definition at line 355 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.

◆ GetAfflictionIconColor() [1/3]

static Color Barotrauma.CharacterHealth.GetAfflictionIconColor ( Affliction  affliction)
static

◆ GetAfflictionIconColor() [2/3]

static Color Barotrauma.CharacterHealth.GetAfflictionIconColor ( AfflictionPrefab  prefab,
Affliction  affliction 
)
static

◆ GetAfflictionIconColor() [3/3]

static Color Barotrauma.CharacterHealth.GetAfflictionIconColor ( AfflictionPrefab  prefab,
float  afflictionStrength 
)
static

◆ GetAfflictionLimb()

Limb Barotrauma.CharacterHealth.GetAfflictionLimb ( Affliction  affliction)

◆ GetAfflictionOfType()

Affliction Barotrauma.CharacterHealth.GetAfflictionOfType ( Identifier  afflictionType,
bool  allowLimbAfflictions = true 
)

◆ GetAfflictionStrength() [1/2]

float Barotrauma.CharacterHealth.GetAfflictionStrength ( Identifier  afflictionType,
Identifier  afflictionidentifier,
bool  allowLimbAfflictions = true 
)

◆ GetAfflictionStrength() [2/2]

float Barotrauma.CharacterHealth.GetAfflictionStrength ( Identifier  afflictionType,
Limb  limb,
bool  requireLimbSpecific 
)

Get the total strength of the afflictions of a specific type attached to a specific limb

Parameters
afflictionTypeType of the affliction
limbThe limb the affliction is attached to
requireLimbSpecificDoes the affliction have to be attached to only the specific limb. Most monsters for example don't have separate healths for different limbs, essentially meaning that every affliction is applied to every limb.

Definition at line 396 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.

◆ GetAfflictionStrengthByIdentifier()

float Barotrauma.CharacterHealth.GetAfflictionStrengthByIdentifier ( Identifier  afflictionIdentifier,
bool  allowLimbAfflictions = true 
)

◆ GetAfflictionStrengthByType()

float Barotrauma.CharacterHealth.GetAfflictionStrengthByType ( Identifier  afflictionType,
bool  allowLimbAfflictions = true 
)

◆ GetAllAfflictions() [1/2]

IReadOnlyCollection<Affliction> Barotrauma.CharacterHealth.GetAllAfflictions ( )

◆ GetAllAfflictions() [2/2]

IEnumerable<Affliction> Barotrauma.CharacterHealth.GetAllAfflictions ( Func< Affliction, bool >  limbHealthFilter)

◆ GetLimbDamage()

float Barotrauma.CharacterHealth.GetLimbDamage ( Limb  limb,
Identifier  afflictionType 
)

◆ GetPredictedStrength()

float Barotrauma.CharacterHealth.GetPredictedStrength ( Affliction  affliction,
float  predictFutureDuration,
Limb  limb = null 
)

◆ GetResistance()

float Barotrauma.CharacterHealth.GetResistance ( AfflictionPrefab  afflictionPrefab)

◆ GetStatValue()

float Barotrauma.CharacterHealth.GetStatValue ( StatTypes  statType)

◆ GetSuitableTreatments()

void Barotrauma.CharacterHealth.GetSuitableTreatments ( Dictionary< Identifier, float >  treatmentSuitability,
bool  normalize,
Character  user,
Limb  limb = null,
bool  ignoreHiddenAfflictions = false,
float  predictFutureDuration = 0.0f 
)

Get the identifiers of the items that can be used to treat the character. Takes into account all the afflictions the character has, and negative treatment suitabilities (e.g. a medicine that causes oxygen loss may not be suitable if the character is already suffocating)

Parameters
treatmentSuitabilityA dictionary where the key is the identifier of the item and the value the suitability
normalizeIf true, the suitability values are normalized between 0 and 1. If not, they're arbitrary values defined in the medical item XML, where negative values are unsuitable, and positive ones suitable.


Parameters
predictFutureDurationIf above 0, the method will take into account how much currently active status effects while affect the afflictions in the next x seconds.


Definition at line 1138 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.

◆ GetTotalAdjustedAfflictionStrength()

float Barotrauma.CharacterHealth.GetTotalAdjustedAfflictionStrength ( Affliction  affliction,
float  otherAfflictionMultiplier = 0.3f,
bool  includeSameAffliction = true 
)

Returns the total strength of instances of the same affliction on all the characters limbs, with a smaller weight given to the other afflictions on other limbs

Parameters
otherAfflictionMultiplierMultiplier on the strengths of the afflictions on other limbs.
includeSameAfflictionShould the strength of the provided affliction be included too?

Definition at line 1217 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.

◆ HasFlag()

bool Barotrauma.CharacterHealth.HasFlag ( AbilityFlags  flagType)

◆ IsMouseOnHealthBar()

static bool Barotrauma.CharacterHealth.IsMouseOnHealthBar ( )
static

◆ Load()

void Barotrauma.CharacterHealth.Load ( XElement  element,
Func< AfflictionPrefab, bool >  afflictionPredicate = null 
)

◆ OnItemDropped()

bool Barotrauma.CharacterHealth.OnItemDropped ( Item  item,
bool  ignoreMousePos 
)

◆ ReduceAfflictionOnAllLimbs()

void Barotrauma.CharacterHealth.ReduceAfflictionOnAllLimbs ( Identifier  afflictionIdOrType,
float  amount,
ActionType treatmentAction = null 
)

◆ ReduceAfflictionOnLimb()

void Barotrauma.CharacterHealth.ReduceAfflictionOnLimb ( Limb  targetLimb,
Identifier  afflictionIdOrType,
float  amount,
ActionType treatmentAction = null 
)

◆ ReduceAllAfflictionsOnAllLimbs()

void Barotrauma.CharacterHealth.ReduceAllAfflictionsOnAllLimbs ( float  amount,
ActionType treatmentAction = null 
)

◆ ReduceAllAfflictionsOnLimb()

void Barotrauma.CharacterHealth.ReduceAllAfflictionsOnLimb ( Limb  targetLimb,
float  amount,
ActionType treatmentAction = null 
)

◆ Remove()

void Barotrauma.CharacterHealth.Remove ( )

◆ RemoveAllAfflictions()

void Barotrauma.CharacterHealth.RemoveAllAfflictions ( )

◆ RemoveNegativeAfflictions()

void Barotrauma.CharacterHealth.RemoveNegativeAfflictions ( )

◆ Save()

void Barotrauma.CharacterHealth.Save ( XElement  healthElement)

◆ ServerWrite()

void Barotrauma.CharacterHealth.ServerWrite ( IWriteMessage  msg)

◆ SetAllDamage()

void Barotrauma.CharacterHealth.SetAllDamage ( float  damageAmount,
float  bleedingDamageAmount,
float  burnDamageAmount 
)

◆ SetHealthBarVisibility()

void Barotrauma.CharacterHealth.SetHealthBarVisibility ( bool  value)

◆ SetVitality()

void Barotrauma.CharacterHealth.SetVitality ( float  newVitality)

◆ SortAfflictionsBySeverity()

static IEnumerable<Affliction> Barotrauma.CharacterHealth.SortAfflictionsBySeverity ( IEnumerable< Affliction afflictions,
bool  excludeBuffs = true 
)
static

Automatically filters out buffs.

◆ Update()

void Barotrauma.CharacterHealth.Update ( float  deltaTime)

◆ UpdateClientSpecific()

void Barotrauma.CharacterHealth.UpdateClientSpecific ( float  deltaTime)

◆ UpdateHUD()

void Barotrauma.CharacterHealth.UpdateHUD ( float  deltaTime)

◆ UpdateStatusHUD()

void Barotrauma.CharacterHealth.UpdateStatusHUD ( float  deltaTime)

Member Data Documentation

◆ Character

readonly Character Barotrauma.CharacterHealth.Character

◆ DefaultFaceTint

readonly Color Barotrauma.CharacterHealth.DefaultFaceTint = Color.TransparentBlack
static

◆ DisplayedVitality

float Barotrauma.CharacterHealth.DisplayedVitality

◆ InsufficientOxygenThreshold

const float Barotrauma.CharacterHealth.InsufficientOxygenThreshold = 30.0f
static

◆ LowOxygenThreshold

const float Barotrauma.CharacterHealth.LowOxygenThreshold = 50.0f
static

◆ minVitality

float Barotrauma.CharacterHealth.minVitality
protected

◆ type

CauseOfDeathType Barotrauma.CharacterHealth.type

◆ Unkillable

bool Barotrauma.CharacterHealth.Unkillable

Property Documentation

◆ Alignment

Alignment Barotrauma.CharacterHealth.Alignment
getset

◆ BloodlossAffliction

Affliction Barotrauma.CharacterHealth.BloodlossAffliction
get

◆ BloodlossAmount

float Barotrauma.CharacterHealth.BloodlossAmount
getset

◆ BodyTint

Color Barotrauma.CharacterHealth.BodyTint
get

◆ CPRButton

GUIButton Barotrauma.CharacterHealth.CPRButton
get

◆ CrushDepth

float Barotrauma.CharacterHealth.CrushDepth
get

◆ DamageOverlay

Sprite Barotrauma.CharacterHealth.DamageOverlay
staticget

◆ DamageOverlayTimer

float Barotrauma.CharacterHealth.DamageOverlayTimer
get

◆ DoesBleed

bool Barotrauma.CharacterHealth.DoesBleed
get

◆ FaceTint

Color Barotrauma.CharacterHealth.FaceTint
get

◆ HealthBarPulsateTimer

float Barotrauma.CharacterHealth.HealthBarPulsateTimer
getset

◆ HealthPercentage

float Barotrauma.CharacterHealth.HealthPercentage
get

◆ InventorySlotContainer

GUIComponent Barotrauma.CharacterHealth.InventorySlotContainer
get

◆ IsParalyzed

bool Barotrauma.CharacterHealth.IsParalyzed
get

◆ IsUnconscious

bool Barotrauma.CharacterHealth.IsUnconscious
get

◆ MaxVitality

float??? Barotrauma.CharacterHealth.MaxVitality
get

◆ MinVitality

float??? Barotrauma.CharacterHealth.MinVitality
get

◆ MouseOnElement

bool Barotrauma.CharacterHealth.MouseOnElement
get

◆ OpenHealthWindow

CharacterHealth?? Barotrauma.CharacterHealth.OpenHealthWindow
staticgetset

◆ OxygenAmount

float Barotrauma.CharacterHealth.OxygenAmount
getset

◆ OxygenLowResistance

float Barotrauma.CharacterHealth.OxygenLowResistance
get

◆ PressureAffliction

Affliction Barotrauma.CharacterHealth.PressureAffliction
get

◆ PressureKillDelay

float Barotrauma.CharacterHealth.PressureKillDelay = 5.0f
get

◆ Stun

float Barotrauma.CharacterHealth.Stun
getset

◆ StunTimer

float Barotrauma.CharacterHealth.StunTimer
get

◆ SuicideButton

GUIButton Barotrauma.CharacterHealth.SuicideButton
get

◆ UnmodifiedMaxVitality

float Barotrauma.CharacterHealth.UnmodifiedMaxVitality
getsetprotected

Maximum vitality without talent- or job-based modifiers

Definition at line 107 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.

◆ UseHealthWindow

bool Barotrauma.CharacterHealth.UseHealthWindow
getset

◆ Vitality

float Barotrauma.CharacterHealth.Vitality
get

◆ VitalityDisregardingDeath

float Barotrauma.CharacterHealth.VitalityDisregardingDeath
get

How much vitality the character would have if it was alive? E.g. a character killed by disconnection or with console commands may not have any vitality-reducing afflictions despite being dead

Definition at line 167 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.

◆ WasInFullHealth

bool Barotrauma.CharacterHealth.WasInFullHealth
get

Was the character in full health at the beginning of the frame?

Definition at line 249 of file BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs.