Barotrauma Client Doc
Barotrauma.RelatedItem Class Reference

Used by various features to define different kinds of relations between items: for example, which item a character must have equipped to interact with some item in some way, which items can go inside a container, or which kind of item the target of a status effect must have for the effect to execute. More...

Public Types

enum class  RelationType {
  None , Contained , Equipped , Picked ,
  Container , Invalid
}
 

Public Member Functions

bool MatchesItem (Item item)
 
bool MatchesItem (ItemPrefab itemPrefab)
 
 RelatedItem (Identifier[] identifiers, Identifier[] excludedIdentifiers)
 
 RelatedItem (ContentXElement element, string parentDebugName)
 
bool CheckRequirements (Character character, Item parentItem)
 
void Save (XElement element)
 

Static Public Member Functions

static RelatedItem Load (ContentXElement element, bool returnEmpty, string parentDebugName)
 

Public Attributes

List< StatusEffectStatusEffects = new List<StatusEffect>()
 
LocalizedString Msg
 Only valid for the RequiredItems of an ItemComponent. A message displayed if the required item isn't found (e.g. a notification about lack of ammo or fuel). More...
 
Identifier MsgTag
 Only valid for the RequiredItems of an ItemComponent. The localization tag of a message displayed if the required item isn't found (e.g. a notification about lack of ammo or fuel). More...
 
int TargetSlot = -1
 Index of the slot the target must be in when targeting a Contained item More...
 
InvSlotType CharacterInventorySlotType
 The slot type the target must be in when targeting an item contained inside a character's inventory More...
 
Vector2? ItemPos
 Overrides the position defined in ItemContainer. Only valid when used in the Containable definitions of an ItemContainer. More...
 
bool Hide
 Only valid when used in the Containable definitions of an ItemContainer. Only affects when ItemContainer.hideItems is false. Doesn't override the value. More...
 
float Rotation
 Only valid when used in the Containable definitions of an ItemContainer. Can be used to override the rotation of specific items in the container. More...
 
bool SetActive
 Only valid when used in the Containable definitions of an ItemContainer. Can be used to force specific items to stay active inside the container (such as flashlights attached to a gun). More...
 

Properties

bool MatchOnEmpty [get, set]
 Should an empty inventory (or an empty inventory slot if TargetSlot is set) be considered valid? Can be used to, for example, make an item do something if there's a specific item, or nothing, inside it. More...
 
bool RequireEmpty [get, set]
 Should only an empty inventory (or an empty inventory slot if TargetSlot is set) be considered valid? Can be used to, for example, make an item do something when there's nothing inside it. More...
 
bool IgnoreInEditor [get, set]
 Only valid for the RequiredItems of an ItemComponent. Can be used to ignore the requirement in the submarine editor, making it easier to for example make rewire things that require some special tool to rewire. More...
 
ImmutableHashSet< IdentifierExcludedIdentifiers [get]
 Identifier(s) or tag(s) of the items that are NOT considered valid. Can be used to, for example, exclude some specific items when using tags that apply to multiple items. More...
 
bool ExcludeBroken [get]
 Should broken (0 condition) items be excluded? More...
 
bool ExcludeFullCondition [get]
 Should full condition (100%) items be excluded? More...
 
bool AllowVariants = true [get]
 Are item variants considered valid? More...
 
RelationType Type [get]
 
bool IsOptional [get, set]
 Only valid for the RequiredItems of an ItemComponent. Can be used to make the requirement optional, meaning that you don't need to have the item to interact with something, but having it may still affect what the interaction does (such as using a crowbar on a door). More...
 
string JoinedIdentifiers [get, set]
 
ImmutableHashSet< IdentifierIdentifiers [get]
 Identifier(s) or tag(s) of the items that are considered valid. More...
 
string JoinedExcludedIdentifiers [get, set]
 

Detailed Description

Used by various features to define different kinds of relations between items: for example, which item a character must have equipped to interact with some item in some way, which items can go inside a container, or which kind of item the target of a status effect must have for the effect to execute.

Definition at line 16 of file RelatedItem.cs.

Member Enumeration Documentation

◆ RelationType

Enumerator
None 
Contained 

The item must be contained inside the item this relation is defined in. Can for example by used to make an item usable only when there's a specific kind of item inside it.

Equipped 

The user must have equipped the item (i.e. held or worn).

Picked 

The user must have picked up the item (i.e. the item needs to be in the user's inventory).

Container 

The item this relation is defined in must be inside a specific kind of container. Can for example by used to make an item do something when it's inside some other type of item.

Invalid 

Signifies an error (type could not be parsed)

Definition at line 18 of file RelatedItem.cs.

Constructor & Destructor Documentation

◆ RelatedItem() [1/2]

Barotrauma.RelatedItem.RelatedItem ( Identifier[]  identifiers,
Identifier[]  excludedIdentifiers 
)

Definition at line 213 of file RelatedItem.cs.

◆ RelatedItem() [2/2]

Barotrauma.RelatedItem.RelatedItem ( ContentXElement  element,
string  parentDebugName 
)

Definition at line 219 of file RelatedItem.cs.

Member Function Documentation

◆ CheckRequirements()

bool Barotrauma.RelatedItem.CheckRequirements ( Character  character,
Item  parentItem 
)

Definition at line 336 of file RelatedItem.cs.

◆ Load()

static RelatedItem Barotrauma.RelatedItem.Load ( ContentXElement  element,
bool  returnEmpty,
string  parentDebugName 
)
static

Definition at line 445 of file RelatedItem.cs.

◆ MatchesItem() [1/2]

bool Barotrauma.RelatedItem.MatchesItem ( Item  item)

Definition at line 170 of file RelatedItem.cs.

◆ MatchesItem() [2/2]

bool Barotrauma.RelatedItem.MatchesItem ( ItemPrefab  itemPrefab)

Definition at line 193 of file RelatedItem.cs.

◆ Save()

void Barotrauma.RelatedItem.Save ( XElement  element)

Definition at line 412 of file RelatedItem.cs.

Member Data Documentation

◆ CharacterInventorySlotType

InvSlotType Barotrauma.RelatedItem.CharacterInventorySlotType

The slot type the target must be in when targeting an item contained inside a character's inventory

Definition at line 112 of file RelatedItem.cs.

◆ Hide

bool Barotrauma.RelatedItem.Hide

Only valid when used in the Containable definitions of an ItemContainer. Only affects when ItemContainer.hideItems is false. Doesn't override the value.

Definition at line 123 of file RelatedItem.cs.

◆ ItemPos

Vector2? Barotrauma.RelatedItem.ItemPos

Overrides the position defined in ItemContainer. Only valid when used in the Containable definitions of an ItemContainer.

Definition at line 117 of file RelatedItem.cs.

◆ Msg

LocalizedString Barotrauma.RelatedItem.Msg

Only valid for the RequiredItems of an ItemComponent. A message displayed if the required item isn't found (e.g. a notification about lack of ammo or fuel).

Definition at line 77 of file RelatedItem.cs.

◆ MsgTag

Identifier Barotrauma.RelatedItem.MsgTag

Only valid for the RequiredItems of an ItemComponent. The localization tag of a message displayed if the required item isn't found (e.g. a notification about lack of ammo or fuel).

Definition at line 82 of file RelatedItem.cs.

◆ Rotation

float Barotrauma.RelatedItem.Rotation

Only valid when used in the Containable definitions of an ItemContainer. Can be used to override the rotation of specific items in the container.

Definition at line 129 of file RelatedItem.cs.

◆ SetActive

bool Barotrauma.RelatedItem.SetActive

Only valid when used in the Containable definitions of an ItemContainer. Can be used to force specific items to stay active inside the container (such as flashlights attached to a gun).

Definition at line 135 of file RelatedItem.cs.

◆ StatusEffects

List<StatusEffect> Barotrauma.RelatedItem.StatusEffects = new List<StatusEffect>()

Definition at line 72 of file RelatedItem.cs.

◆ TargetSlot

int Barotrauma.RelatedItem.TargetSlot = -1

Index of the slot the target must be in when targeting a Contained item

Definition at line 107 of file RelatedItem.cs.

Property Documentation

◆ AllowVariants

bool Barotrauma.RelatedItem.AllowVariants = true
get

Are item variants considered valid?

Definition at line 97 of file RelatedItem.cs.

◆ ExcludeBroken

bool Barotrauma.RelatedItem.ExcludeBroken
get

Should broken (0 condition) items be excluded?

Definition at line 87 of file RelatedItem.cs.

◆ ExcludedIdentifiers

ImmutableHashSet<Identifier> Barotrauma.RelatedItem.ExcludedIdentifiers
get

Identifier(s) or tag(s) of the items that are NOT considered valid. Can be used to, for example, exclude some specific items when using tags that apply to multiple items.

Definition at line 68 of file RelatedItem.cs.

◆ ExcludeFullCondition

bool Barotrauma.RelatedItem.ExcludeFullCondition
get

Should full condition (100%) items be excluded?

Definition at line 92 of file RelatedItem.cs.

◆ Identifiers

ImmutableHashSet<Identifier> Barotrauma.RelatedItem.Identifiers
get

Identifier(s) or tag(s) of the items that are considered valid.

Definition at line 157 of file RelatedItem.cs.

◆ IgnoreInEditor

bool Barotrauma.RelatedItem.IgnoreInEditor
getset

Only valid for the RequiredItems of an ItemComponent. Can be used to ignore the requirement in the submarine editor, making it easier to for example make rewire things that require some special tool to rewire.

Definition at line 61 of file RelatedItem.cs.

◆ IsOptional

bool Barotrauma.RelatedItem.IsOptional
getset

Only valid for the RequiredItems of an ItemComponent. Can be used to make the requirement optional, meaning that you don't need to have the item to interact with something, but having it may still affect what the interaction does (such as using a crowbar on a door).

Definition at line 141 of file RelatedItem.cs.

◆ JoinedExcludedIdentifiers

string Barotrauma.RelatedItem.JoinedExcludedIdentifiers
getset

Definition at line 159 of file RelatedItem.cs.

◆ JoinedIdentifiers

string Barotrauma.RelatedItem.JoinedIdentifiers
getset

Definition at line 143 of file RelatedItem.cs.

◆ MatchOnEmpty

bool Barotrauma.RelatedItem.MatchOnEmpty
getset

Should an empty inventory (or an empty inventory slot if TargetSlot is set) be considered valid? Can be used to, for example, make an item do something if there's a specific item, or nothing, inside it.

Definition at line 48 of file RelatedItem.cs.

◆ RequireEmpty

bool Barotrauma.RelatedItem.RequireEmpty
getset

Should only an empty inventory (or an empty inventory slot if TargetSlot is set) be considered valid? Can be used to, for example, make an item do something when there's nothing inside it.

Definition at line 53 of file RelatedItem.cs.

◆ Type

RelationType Barotrauma.RelatedItem.Type
get

Definition at line 99 of file RelatedItem.cs.