Barotrauma Client Doc
Barotrauma.Items.Components.Powered Class Reference
Inheritance diagram for Barotrauma.Items.Components.Powered:
Barotrauma.Items.Components.ItemComponent Barotrauma.Items.Components.ItemComponent Barotrauma.ISerializableEntity Barotrauma.ISerializableEntity Barotrauma.ISerializableEntity Barotrauma.ISerializableEntity Barotrauma.Items.Components.Deconstructor Barotrauma.Items.Components.Deconstructor Barotrauma.Items.Components.ElectricalDischarger Barotrauma.Items.Components.ElectricalDischarger Barotrauma.Items.Components.Engine Barotrauma.Items.Components.Engine Barotrauma.Items.Components.Fabricator Barotrauma.Items.Components.Fabricator Barotrauma.Items.Components.LightComponent Barotrauma.Items.Components.LightComponent Barotrauma.Items.Components.MiniMap Barotrauma.Items.Components.MiniMap Barotrauma.Items.Components.OxygenGenerator Barotrauma.Items.Components.PowerContainer Barotrauma.Items.Components.PowerContainer Barotrauma.Items.Components.PowerTransfer Barotrauma.Items.Components.PowerTransfer Barotrauma.Items.Components.Pump Barotrauma.Items.Components.Pump Barotrauma.Items.Components.Reactor Barotrauma.Items.Components.Reactor Barotrauma.Items.Components.Sonar Barotrauma.Items.Components.Sonar Barotrauma.Items.Components.SonarTransducer Barotrauma.Items.Components.Steering Barotrauma.Items.Components.Steering Barotrauma.Items.Components.Turret Barotrauma.Items.Components.Turret

Public Member Functions

 Powered (Item item, ContentXElement element)
 
override void Update (float deltaTime, Camera cam)
 
override void OnItemLoaded ()
 Called when all the components of the item have been loaded. Use to initialize connections between components and such. More...
 
virtual float GetCurrentPowerConsumption (Connection connection=null)
 Current power consumption of the device (or amount of generated power if negative) More...
 
virtual PowerRange MinMaxPowerOut (Connection conn, float load=0)
 Minimum and maximum power the connection can provide More...
 
virtual float GetConnectionPowerOut (Connection conn, float power, PowerRange minMaxPower, float load)
 Finalize how much power the device will be outputting to the connection More...
 
virtual void GridResolved (Connection conn)
 Can be overridden to perform updates for the device after the connected grid has resolved its power calculations, i.e. storing voltage for later updates More...
 
- Public Member Functions inherited from Barotrauma.Items.Components.ItemComponent
readonly record struct ItemUseInfo (Item Item, Character User)
 
 ItemComponent (Item item, ContentXElement element)
 
void SetRequiredItems (ContentXElement element, bool allowEmpty=false)
 
virtual void Move (Vector2 amount, bool ignoreContacts=false)
 
virtual bool Pick (Character picker)
 a Character has picked the item More...
 
virtual bool Select (Character character)
 
virtual void Drop (Character dropper, bool setTransform=true)
 a Character has dropped the item More...
 
virtual bool CrewAIOperate (float deltaTime, Character character, AIObjectiveOperateItem objective)
 
Returns
true if the operation was completed
More...
 
virtual void UpdateBroken (float deltaTime, Camera cam)
 
virtual bool Use (float deltaTime, Character character=null)
 
virtual bool SecondaryUse (float deltaTime, Character character=null)
 
virtual void Equip (Character character)
 
virtual void Unequip (Character character)
 
virtual void ReceiveSignal (Signal signal, Connection connection)
 
virtual bool Combine (Item item, Character user)
 
void Remove ()
 
void ShallowRemove ()
 Remove the component so that it doesn't appear to exist in the game world (stop sounds, remove bodies etc) but don't reset anything that's required for cloning the item More...
 
bool HasRequiredSkills (Character character)
 
bool HasRequiredSkills (Character character, out Skill insufficientSkill)
 
virtual float GetSkillMultiplier ()
 
float DegreeOfSuccess (Character character)
 Returns 0.0f-1.0f based on how well the Character can use the itemcomponent More...
 
float DegreeOfSuccess (Character character, List< Skill > requiredSkills)
 Returns 0.0f-1.0f based on how well the Character can use the itemcomponent More...
 
virtual void FlipX (bool relativeToSub)
 
virtual void FlipY (bool relativeToSub)
 
bool IsEmpty (Character user)
 Shorthand for !HasRequiredContainedItems() More...
 
bool HasRequiredContainedItems (Character user, bool addMessage, LocalizedString msg=null)
 
virtual bool HasAccess (Character character)
 Only checks if any of the Picked requirements are matched (used for checking id card(s)). Much simpler and a bit different than HasRequiredItems. More...
 
virtual bool HasRequiredItems (Character character, bool addMessage, LocalizedString msg=null)
 
void ApplyStatusEffects (ActionType type, float deltaTime, Character character=null, Limb targetLimb=null, Entity useTarget=null, Character user=null, Vector2? worldPosition=null, float afflictionMultiplier=1.0f)
 
virtual void Load (ContentXElement componentElement, bool usePrefabValues, IdRemap idRemap)
 
virtual void OnMapLoaded ()
 Called when all items have been loaded. Use to initialize connections between items. More...
 
virtual void OnScaleChanged ()
 
virtual void OnInventoryChanged ()
 Called when the item has an ItemContainer and the contents inside of it changed. More...
 
virtual XElement Save (XElement parentElement)
 
virtual void Reset ()
 
virtual void ParseMsg ()
 
virtual bool ValidateEventData (NetEntityEvent.IData data)
 
ItemComponent GetReplacementOrThis ()
 
bool NeedsSoundUpdate ()
 
void UpdateSounds ()
 
void PlaySound (ActionType type, Character user=null)
 
void StopLoopingSound ()
 
void StopSounds (ActionType type)
 
virtual bool ShouldDrawHUD (Character character)
 
ItemComponent GetLinkUIToComponent ()
 
virtual void DrawHUD (SpriteBatch spriteBatch, Character character)
 
virtual void AddToGUIUpdateList (int order=0)
 
void UpdateHUD (Character character, float deltaTime, Camera cam)
 
virtual void UpdateHUDComponentSpecific (Character character, float deltaTime, Camera cam)
 
virtual void UpdateEditing (float deltaTime)
 
virtual void CreateEditingHUD (SerializableEntityEditor editor)
 
virtual void OnPlayerSkillsChanged ()
 
virtual void AddTooltipInfo (ref LocalizedString name, ref LocalizedString description)
 

Static Public Member Functions

static void UpdateGrids (bool useCache=true)
 Allocate electrical devices into their grids based on connections More...
 
static void UpdatePower (float deltaTime)
 Update the power calculations of all devices and grids Updates grids in the order of ConnCurrConsumption - Get load of device/ flag it as an outputting connection – If outputting power – MinMaxPower - Minimum and Maximum power output of the connection for devices to coordinate ConnPowerOut - Final power output based on the sum of the MinMaxPower – Finally – GridResolved - Indicate that a connection's grid has been finished being calculated More...
 
static bool ValidPowerConnection (Connection conn1, Connection conn2)
 
- Static Public Member Functions inherited from Barotrauma.Items.Components.ItemComponent
static ItemComponent Load (ContentXElement element, Item item, bool errorMessages=true)
 

Static Public Attributes

static readonly HashSet< ConnectionChangedConnections = new HashSet<Connection>()
 
static readonly Dictionary< int, GridInfoGrids = new Dictionary<int, GridInfo>()
 

Protected Member Functions

void UpdateOnActiveEffects (float deltaTime)
 
float GetAvailableInstantaneousBatteryPower ()
 Returns the amount of power that can be supplied by batteries directly connected to the item More...
 
IEnumerable< PowerContainerGetDirectlyConnectedBatteries ()
 
override void RemoveComponentSpecific ()
 
- Protected Member Functions inherited from Barotrauma.Items.Components.ItemComponent
virtual void ShallowRemoveComponentSpecific ()
 
string GetTextureDirectory (ContentXElement subElement)
 
ExtractEventData< T > (NetEntityEvent.IData data)
 
bool TryExtractEventData< T > (NetEntityEvent.IData data, out T componentData)
 
AIObjectiveContainItem AIContainItems< T > (ItemContainer container, Character character, AIObjective currentObjective, int itemCount, bool equip, bool removeEmpty, bool spawnItemIfNotFound=false, bool dropItemOnDeselected=false)
 
void ReleaseGuiFrame ()
 
void ReloadGuiFrame ()
 
void TryCreateDragHandle ()
 
virtual void CreateGUI ()
 Overload this method and implement. The method is automatically called when the resolution changes. More...
 
void StartDelayedCorrection (IReadMessage buffer, float sendingTime, bool waitForMidRoundSync=false)
 
void OnGUIParentChanged (RectTransform newParent)
 Launches when the parent of the GuiFrame is changed. More...
 
virtual void OnResolutionChanged ()
 

Protected Attributes

float currPowerConsumption
 The amount of power currently consumed by the item. Negative values mean that the item is providing power to connected items More...
 
float powerConsumption
 The maximum amount of power the item can draw from connected items More...
 
Connection powerIn
 
- Protected Attributes inherited from Barotrauma.Items.Components.ItemComponent
Item item
 
string name
 
bool characterUsable
 
bool canBePicked
 
bool canBeSelected
 
bool canBeCombined
 
bool removeOnCombined
 
CoroutineHandle delayedCorrectionCoroutine
 
float aiUpdateTimer
 
float correctionTimer
 

Static Protected Attributes

const float UpdateInterval = (float)Timing.Step
 
const float MaxOverVoltageFactor = 2.0f
 Maximum voltage factor when the device is being overvolted. I.e. how many times more effectively the device can function when it's being overvolted More...
 
- Static Protected Attributes inherited from Barotrauma.Items.Components.ItemComponent
const float CorrectionDelay = 1.0f
 
const float AIUpdateInterval = 0.2f
 

Properties

static IEnumerable< PoweredPoweredList [get]
 
virtual PowerPriority Priority [get]
 
float? MinVoltage [get, set]
 
float PowerConsumption [get, set]
 
override bool IsActive [get, set]
 
float CurrPowerConsumption [get, set]
 
float??? Voltage [get, set]
 
float RelativeVoltage [get]
 Essentially Voltage / MinVoltage (= how much of the minimum required voltage has been satisfied), clamped between 0 and 1. Can be used by status effects or sounds to check if the item has enough power to run More...
 
bool PoweredByTinkering [get, set]
 
bool VulnerableToEMP [get, set]
 
- Properties inherited from Barotrauma.Items.Components.ItemComponent
ItemComponent Parent [get, set]
 
bool InheritParentIsActive [get, set]
 
virtual bool DontTransferInventoryBetweenSubs [get]
 If enabled, the contents of the item are not transferred when the player transfers items between subs. Use this if this component uses item containers in a way where removing the item from the container via external means would cause problems. More...
 
virtual bool DisallowSellingItemsFromContainer [get]
 If enabled, the items inside any of the item containers on this item cannot be sold at an outpost. Use in similar cases as DontTransferInventoryBetweenSubs. More...
 
float PickingTime [get, set]
 
string PickingMsg [get, set]
 
Dictionary< Identifier, SerializablePropertySerializableProperties [get, protected set]
 
virtual bool? IsActive [get, set]
 
PropertyConditional.LogicalOperatorType IsActiveConditionalComparison [get, set]
 
bool Drawable [get, set]
 
bool CanBePicked [get, set]
 
bool DrawHudWhenEquipped [get, protected set]
 
bool LockGuiFramePosition [get, set]
 
Point GuiFrameOffset [get, set]
 
bool CanBeSelected [get, set]
 
bool CanBeCombined [get, set]
 
bool RemoveOnCombined [get, set]
 
bool CharacterUsable [get, set]
 
bool AllowInGameEditing [get, set]
 
InputType PickKey [get, protected set]
 
InputType SelectKey [get, protected set]
 
bool DeleteOnUse [get, set]
 
Item Item [get]
 
string Name [get]
 
string Msg [get, set]
 
LocalizedString DisplayMsg [get, set]
 
float CombatPriority [get]
 
int ManuallySelectedSound [get]
 Which sound should be played when manual sound selection type is selected? Not [Editable] because we don't want this visible in the editor for every component. More...
 
float Speed [get]
 Can be used by status effects or conditionals to the speed of the item More...
 
virtual bool UpdateWhenInactive [get]
 
bool HasSounds [get]
 
bool[] HasSoundsOfType [get]
 
virtual bool RecreateGUIOnResolutionChange [get]
 
GUILayoutSettings DefaultLayout [get, protected set]
 
GUILayoutSettings AlternativeLayout [get, protected set]
 
GUIFrame GuiFrame [get, set]
 
bool AllowUIOverlap [get, set]
 
string LinkUIToComponent [get, set]
 
int HudPriority [get]
 
int HudLayer [get]
 
bool?? UseAlternativeLayout [get, set]
 
- Properties inherited from Barotrauma.ISerializableEntity
string Name [get]
 
Dictionary< Identifier, SerializablePropertySerializableProperties [get]
 

Additional Inherited Members

- Public Attributes inherited from Barotrauma.Items.Components.ItemComponent
bool WasUsed
 
readonly Dictionary< ActionType, List< StatusEffect > > statusEffectLists
 
Dictionary< RelatedItem.RelationType, List< RelatedItem > > requiredItems
 
readonly List< RelatedItemDisabledRequiredItems = new List<RelatedItem>()
 
List< SkillrequiredSkills
 
readonly ContentXElement originalElement
 
Action< bool > OnActiveStateChanged
 
List< PropertyConditionalIsActiveConditionals
 
readonly NamedEvent< ItemUseInfoOnUsed = new()
 
readonly bool InheritStatusEffects
 
float IsActiveTimer
 
ItemComponent ReplacedBy
 

Detailed Description

Constructor & Destructor Documentation

◆ Powered()

Barotrauma.Items.Components.Powered.Powered ( Item  item,
ContentXElement  element 
)

Member Function Documentation

◆ GetAvailableInstantaneousBatteryPower()

float Barotrauma.Items.Components.Powered.GetAvailableInstantaneousBatteryPower ( )
protected

Returns the amount of power that can be supplied by batteries directly connected to the item

Definition at line 676 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ GetConnectionPowerOut()

virtual float Barotrauma.Items.Components.Powered.GetConnectionPowerOut ( Connection  conn,
float  power,
PowerRange  minMaxPower,
float  load 
)
virtual

Finalize how much power the device will be outputting to the connection

Parameters
connConnection being queried
powerCurrent grid power
loadCurrent load on the grid
Returns
Power pushed to the grid

Reimplemented in Barotrauma.Items.Components.RelayComponent, Barotrauma.Items.Components.PowerContainer, Barotrauma.Items.Components.PowerTransfer, and Barotrauma.Items.Components.Reactor.

Definition at line 655 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ GetCurrentPowerConsumption()

◆ GetDirectlyConnectedBatteries()

IEnumerable<PowerContainer> Barotrauma.Items.Components.Powered.GetDirectlyConnectedBatteries ( )
protected

◆ GridResolved()

virtual void Barotrauma.Items.Components.Powered.GridResolved ( Connection  conn)
virtual

Can be overridden to perform updates for the device after the connected grid has resolved its power calculations, i.e. storing voltage for later updates

Reimplemented in Barotrauma.Items.Components.Engine, Barotrauma.Items.Components.RelayComponent, and Barotrauma.Items.Components.PowerContainer.

Definition at line 663 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ MinMaxPowerOut()

virtual PowerRange Barotrauma.Items.Components.Powered.MinMaxPowerOut ( Connection  conn,
float  load = 0 
)
virtual

Minimum and maximum power the connection can provide

Parameters
connConnection being queried about its power capabilities
loadLoad of the connected grid

Reimplemented in Barotrauma.Items.Components.RelayComponent, Barotrauma.Items.Components.PowerContainer, and Barotrauma.Items.Components.Reactor.

Definition at line 643 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ OnItemLoaded()

override void Barotrauma.Items.Components.Powered.OnItemLoaded ( )
virtual

◆ RemoveComponentSpecific()

◆ Update()

◆ UpdateGrids()

static void Barotrauma.Items.Components.Powered.UpdateGrids ( bool  useCache = true)
static

Allocate electrical devices into their grids based on connections

Parameters
useCacheUse previous grids and change in connections

Definition at line 292 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ UpdateOnActiveEffects()

void Barotrauma.Items.Components.Powered.UpdateOnActiveEffects ( float  deltaTime)
protected

◆ UpdatePower()

static void Barotrauma.Items.Components.Powered.UpdatePower ( float  deltaTime)
static

Update the power calculations of all devices and grids Updates grids in the order of ConnCurrConsumption - Get load of device/ flag it as an outputting connection – If outputting power – MinMaxPower - Minimum and Maximum power output of the connection for devices to coordinate ConnPowerOut - Final power output based on the sum of the MinMaxPower – Finally – GridResolved - Indicate that a connection's grid has been finished being calculated

Power outputting devices are calculated in stages based on their priority Reactors will output first, followed by relays then batteries.

Parameters
deltaTime

Definition at line 422 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ ValidPowerConnection()

static bool Barotrauma.Items.Components.Powered.ValidPowerConnection ( Connection  conn1,
Connection  conn2 
)
static

Member Data Documentation

◆ ChangedConnections

readonly HashSet<Connection> Barotrauma.Items.Components.Powered.ChangedConnections = new HashSet<Connection>()
static

◆ currPowerConsumption

float Barotrauma.Items.Components.Powered.currPowerConsumption
protected

The amount of power currently consumed by the item. Negative values mean that the item is providing power to connected items

Definition at line 79 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ Grids

readonly Dictionary<int, GridInfo> Barotrauma.Items.Components.Powered.Grids = new Dictionary<int, GridInfo>()
static

◆ MaxOverVoltageFactor

const float Barotrauma.Items.Components.Powered.MaxOverVoltageFactor = 2.0f
staticprotected

Maximum voltage factor when the device is being overvolted. I.e. how many times more effectively the device can function when it's being overvolted

Definition at line 101 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ powerConsumption

float Barotrauma.Items.Components.Powered.powerConsumption
protected

The maximum amount of power the item can draw from connected items

Definition at line 94 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ powerIn

Connection Barotrauma.Items.Components.Powered.powerIn
protected

◆ UpdateInterval

const float Barotrauma.Items.Components.Powered.UpdateInterval = (float)Timing.Step
staticprotected

Property Documentation

◆ CurrPowerConsumption

float Barotrauma.Items.Components.Powered.CurrPowerConsumption
getset

◆ IsActive

override bool Barotrauma.Items.Components.Powered.IsActive
getset

◆ MinVoltage

float? Barotrauma.Items.Components.Powered.MinVoltage
getset

◆ PowerConsumption

float Barotrauma.Items.Components.Powered.PowerConsumption
getset

◆ PoweredByTinkering

bool Barotrauma.Items.Components.Powered.PoweredByTinkering
getset

◆ PoweredList

IEnumerable<Powered> Barotrauma.Items.Components.Powered.PoweredList
staticget

◆ Priority

virtual PowerPriority Barotrauma.Items.Components.Powered.Priority
getprotected

◆ RelativeVoltage

float Barotrauma.Items.Components.Powered.RelativeVoltage
get

Essentially Voltage / MinVoltage (= how much of the minimum required voltage has been satisfied), clamped between 0 and 1. Can be used by status effects or sounds to check if the item has enough power to run

Definition at line 171 of file BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs.

◆ Voltage

float??? Barotrauma.Items.Components.Powered.Voltage
getset

◆ VulnerableToEMP

bool Barotrauma.Items.Components.Powered.VulnerableToEMP
getset