Barotrauma Client Doc
Barotrauma.PropertyConditional Class Reference

Conditionals are used by some in-game mechanics to require one or more conditions to be met for those mechanics to be active. For example, some StatusEffects use Conditionals to only trigger if the affected character is alive. More...

Public Types

enum class  ConditionType {
  PropertyValueOrAffliction , SkillRequirement , Name , SpeciesName ,
  SpeciesGroup , HasTag , HasStatusTag , HasSpecifierTag ,
  EntityType , LimbType
}
 Category of properties to check against More...
 
enum class  LogicalOperatorType { And , Or }
 
enum class  ComparisonOperatorType {
  None , Equals , NotEquals , LessThan ,
  LessThanEquals , GreaterThan , GreaterThanEquals
}
 There are several ways to compare properties to values. The comparison operator to use can be specified by placing one of the following before the value to compare against. More...
 

Public Member Functions

bool Matches (ISerializableEntity? target)
 
bool TargetTagMatchesTagCondition (Identifier targetTag)
 

Static Public Member Functions

static IEnumerable< PropertyConditionalFromXElement (ContentXElement element, Predicate< XAttribute >? predicate=null)
 
static ComparisonOperatorType GetComparisonOperatorType (string op)
 
static bool CompareFloat (float val1, float val2, ComparisonOperatorType op)
 

Public Attributes

readonly ConditionType Type
 
readonly ComparisonOperatorType ComparisonOperator
 
readonly Identifier AttributeName
 
readonly string AttributeValue
 
readonly ImmutableArray< IdentifierAttributeValueAsTags
 
readonly? float FloatValue
 
readonly string TargetItemComponent
 If set to the name of one of the target's ItemComponents, the conditionals defined by this element check against the properties of that component. Only works on items. More...
 
readonly bool TargetSelf
 If set to true, the conditionals defined by this element check against the attacking character instead of the attacked character. Only applies to a character's attacks. More...
 
readonly bool TargetContainer
 If set to true, the conditionals defined by this element check against the entity containing the target. More...
 
readonly bool TargetGrandParent
 If this and TargetContainer are set to true, the conditionals defined by this element check against the entity containing the target's container. For example, diving suits have a status effect that targets contained oxygen tanks, with a conditional that only passes if the locker containing the suit is powered. More...
 
readonly bool TargetContainedItem
 If set to true, the conditionals defined by this element check against the items contained by the target. Only works with items. More...
 

Static Public Attributes

static ComparisonOperatorType ComparisonOperator
 

Detailed Description

Conditionals are used by some in-game mechanics to require one or more conditions to be met for those mechanics to be active. For example, some StatusEffects use Conditionals to only trigger if the affected character is alive.

Definition at line 18 of file PropertyConditional.cs.

Member Enumeration Documentation

◆ ComparisonOperatorType

There are several ways to compare properties to values. The comparison operator to use can be specified by placing one of the following before the value to compare against.

Enumerator
None 
Equals 

Require that the property being checked equals the given value.

This is the default operator used if none is specified.

NotEquals 

Require that the property being checked doesn't equal the given value.

LessThan 

Require that the property being checked is less than the given value.

This can only be used to compare with numeric object properties, affliction strengths and skill levels.

LessThanEquals 

Require that the property being checked is less than or equal to the given value.

This can only be used to compare with numeric object properties, affliction strengths and skill levels.

GreaterThan 

Require that the property being checked is greater than the given value.

This can only be used to compare with numeric object properties, affliction strengths and skill levels.

GreaterThanEquals 

Require that the property being checked is greater than or equal to the given value.

This can only be used to compare with numeric object properties, affliction strengths and skill levels.

Definition at line 115 of file PropertyConditional.cs.

◆ ConditionType

Category of properties to check against

Enumerator
PropertyValueOrAffliction 

If there exists an affliction with an identifier that matches the given key, check against the strength of that affliction. Otherwise, check against the value of one of the target's properties.

The target object's available properties depend on how that object is defined in the source code.

This is not applicable if the element contains the attribute SkillRequirement="true".

<AutoDocEntryName value="Property or affliction identifier" >

<Conditional WatchersGaze="gt 0" > <Conditional IsDead="true" >

SkillRequirement 

Check against the target character's skill with the same name as the attribute.

This is only applicable if the element contains the attribute SkillRequirement="true".

<AutoDocEntryName value="Skill identifier" >

<Conditional SkillRequirement="true" weapons="lt 50" >

Name 

Check against the name of the target.

SpeciesName 

Check against the species identifier of the target. Only works on characters.

SpeciesGroup 

Check against the species group of the target. Only works on characters.

HasTag 

Check against the target's tags. Only works on items.

Several tags can be checked against by using a comma-separated list.

HasStatusTag 

Check against the tags of the target's active status effects.

Several tags can be checked against by using a comma-separated list.

HasSpecifierTag 

Check against the target's specifier tags. In the vanilla game, these are the head index and gender. See human.xml for more details.

Several tags can be checked against by using a comma-separated list.

EntityType 

Check against the target's entity type.

The currently supported values are "character", "limb", "item", "structure" and "null".

LimbType 

Check against the target's limb type. See Barotrauma.LimbType.

Definition at line 25 of file PropertyConditional.cs.

◆ LogicalOperatorType

Enumerator
And 
Or 

Definition at line 105 of file PropertyConditional.cs.

Member Function Documentation

◆ CompareFloat()

static bool Barotrauma.PropertyConditional.CompareFloat ( float  val1,
float  val2,
ComparisonOperatorType  op 
)
static

Definition at line 606 of file PropertyConditional.cs.

◆ FromXElement()

static IEnumerable<PropertyConditional> Barotrauma.PropertyConditional.FromXElement ( ContentXElement  element,
Predicate< XAttribute >?  predicate = null 
)
static

Definition at line 199 of file PropertyConditional.cs.

◆ GetComparisonOperatorType()

static ComparisonOperatorType Barotrauma.PropertyConditional.GetComparisonOperatorType ( string  op)
static

Definition at line 307 of file PropertyConditional.cs.

◆ Matches()

bool Barotrauma.PropertyConditional.Matches ( ISerializableEntity target)

Definition at line 345 of file PropertyConditional.cs.

◆ TargetTagMatchesTagCondition()

bool Barotrauma.PropertyConditional.TargetTagMatchesTagCondition ( Identifier  targetTag)

Definition at line 529 of file PropertyConditional.cs.

Member Data Documentation

◆ AttributeName

readonly Identifier Barotrauma.PropertyConditional.AttributeName

Definition at line 166 of file PropertyConditional.cs.

◆ AttributeValue

readonly string Barotrauma.PropertyConditional.AttributeValue

Definition at line 167 of file PropertyConditional.cs.

◆ AttributeValueAsTags

readonly ImmutableArray<Identifier> Barotrauma.PropertyConditional.AttributeValueAsTags

Definition at line 168 of file PropertyConditional.cs.

◆ ComparisonOperator [1/2]

readonly ComparisonOperatorType Barotrauma.PropertyConditional.ComparisonOperator

Definition at line 165 of file PropertyConditional.cs.

◆ ComparisonOperator [2/2]

ComparisonOperatorType Barotrauma.PropertyConditional.ComparisonOperator
static

Definition at line 292 of file PropertyConditional.cs.

◆ FloatValue

readonly? float Barotrauma.PropertyConditional.FloatValue

Definition at line 169 of file PropertyConditional.cs.

◆ TargetContainedItem

readonly bool Barotrauma.PropertyConditional.TargetContainedItem

If set to true, the conditionals defined by this element check against the items contained by the target. Only works with items.

Definition at line 197 of file PropertyConditional.cs.

◆ TargetContainer

readonly bool Barotrauma.PropertyConditional.TargetContainer

If set to true, the conditionals defined by this element check against the entity containing the target.

Definition at line 186 of file PropertyConditional.cs.

◆ TargetGrandParent

readonly bool Barotrauma.PropertyConditional.TargetGrandParent

If this and TargetContainer are set to true, the conditionals defined by this element check against the entity containing the target's container. For example, diving suits have a status effect that targets contained oxygen tanks, with a conditional that only passes if the locker containing the suit is powered.

Definition at line 192 of file PropertyConditional.cs.

◆ TargetItemComponent

readonly string Barotrauma.PropertyConditional.TargetItemComponent

If set to the name of one of the target's ItemComponents, the conditionals defined by this element check against the properties of that component. Only works on items.

Definition at line 175 of file PropertyConditional.cs.

◆ TargetSelf

readonly bool Barotrauma.PropertyConditional.TargetSelf

If set to true, the conditionals defined by this element check against the attacking character instead of the attacked character. Only applies to a character's attacks.

Definition at line 181 of file PropertyConditional.cs.

◆ Type

readonly ConditionType Barotrauma.PropertyConditional.Type

Definition at line 164 of file PropertyConditional.cs.