Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
ComponentEnergyManager Class Reference
Inheritance diagram for ComponentEnergyManager:
Component

Protected Member Functions

void ComponentEnergyManager ()
 
void ~ComponentEnergyManager ()
 
override void Event_OnInit ()
 
void DebugUpdate ()
 
Shape DrawArrow (vector from, vector to, float size=0.5, int color=0xFFFFFFFF, float flags=0)
 
EntityAI GetThisEntityAI ()
 
override void Event_OnAwake ()
 
override int GetCompType ()
 
void OnDeviceDestroyed ()
 
void RefreshDebug ()
 
bool GetDebugPlugs ()
 
void SetDebugPlugs (bool newVal)
 
void SwitchOn ()
 Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
 
void SwitchOff ()
 Energy manager: Switches OFF the device.
 
void SetPassiveState (bool state=true)
 Energy manager: Changes the status of this device. When it's passive (true), the main timer and OnWork events are not used.
 
void UnplugDevice (EntityAI device_to_unplug)
 Energy manager: Unplugs the given device from this one.
 
void UnplugThis ()
 Energy manager: Unplugs this device from its power source.
 
void UnplugAllDevices ()
 Energy manager: Unplugs everything directly connected to this device.
 
void RestorePlugState (bool state)
 
void SetEnergy (float new_energy)
 Energy manager: Sets stored energy for this device. It ignores the min/max limit!
 
void SetEnergy0To1 (float energy01)
 Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value between 0 and 1.
 
void UpdateSelections ()
 Energy manager: Shows/Hides all selections this system works with. Call this if something is wrong with selections (like during Init and Restore event in config)
 
void UpdatePlugState ()
 Energy manager: Unplugs this device when it's necesarry.
 
void GetCompatiblePlugTypes (out TIntArray IDs)
 
void StoreEnergySourceIDs (int b1, int b2, int b3, int b4)
 
void SetEnergyMaxPristine (float new_limit)
 Energy manager: Changes the maximum amount of energy this device can store (when pristine).
 
void SetCordLength (float new_length)
 Energy manager: Changes the length of the virtual power cord.
 
void SetPlugType (int new_type)
 
void SetAttachmentAction (int new_action_type)
 
void SetEnergyUsage (float new_usage)
 Energy manager: Changes the energy usage per second.
 
void ResetEnergyUsage ()
 Energy manager: Resets energy usage to default (config) value.
 
void SetCordTextureFile (string new_path)
 
void SetEnergySourceClient (EntityAI source)
 
void SetDeviceBySocketID (int id, EntityAI plugged_device)
 Energy manager: Stores the device which is plugged into the given socket ID.
 
void SetElectricityIconVisibility (bool make_visible)
 Energy manager: Sets visibility of the electricity icon (bolt).
 
void UpdateCanWork ()
 
void HandleMoveInsideCargo (EntityAI container)
 
void SetUpdateInterval (float value)
 Energy manager: Sets the interval of the OnWork(...) calls. Changing this value does not change the rate of energy consumption.
 
bool GetRestorePlugState ()
 
bool PlugThisInto (EntityAI energy_source, int socket_id=-1)
 Energy manager: Attempts to plug this device into the energy_source. Returns true if the action was successfull, or false if not (due to plug incompatibility or no free socket on the receiver). The ID of the power socket is chosen automatically unless optional parameter socket_id is used (starting from 0). If the given ID is not free then a free socket is found.
 
bool CanSwitchOn ()
 Energy manager: Checks if the device can be switched ON.
 
bool CanWork (float test_energy=-1)
 Energy manager: Checks whenever this device can do work or not.
 
bool CheckWetness ()
 Energy manager: Checks if this device is being stopped from working by its wetness level. Returns true when its wetness is not blocking it, false when its to owet to work.
 
bool CanSwitchOff ()
 Energy manager: Checks if the device can be switched OFF.
 
bool GetPreviousSwitchState ()
 
bool IsSwitchedOn ()
 Energy manager: Returns state of the switch. Whenever the device is working or not does not matter. Use IsWorking() to account for that as well.
 
bool IsCordFolded ()
 Energy manager: Returns true if the cord of this device is folded. Returns false if it's plugged.
 
bool IsPassive ()
 Energy manager: Returns true if this device is set to be passive. False if otherwise.
 
bool IsPlugged ()
 Energy manager: Returns true if this device is plugged into some other device (even if they are OFF or ruined). Otherwise it returns false.
 
bool ConsumeEnergy (float amount)
 Energy manager: Consumes the given amount of energy. If there is not enough of stored energy in this device, then it tries to take it from its power source, if any exists. Returns true if the requested amount of energy was consumed. Otherwise it returns false.
 
bool IsWorking ()
 Energy manager: Returns true if this device is working right now.
 
bool HasEnoughStoredEnergy ()
 Energy manager: Returns true if this device has enough of stored energy for its own use.
 
bool HasFreeSocket (int socket_id=-1)
 Energy manager: Returns true if this device has any free socket to receive a plug. If optional parameter socket_id is provided then only that socket ID is checked.
 
bool IsPlugCompatible (int plug_ID)
 Energy manager: Checks if the given plug is compatible with this device's socket. Used by CanReceivePlugFrom() method.
 
bool CanReceivePlugFrom (EntityAI device_to_plug)
 Energy manager: Returns true if this device can receive power plug of the other device.
 
bool CanBePluggedInto (EntityAI potential_energy_provider)
 Energy manager: Returns true if this device can be plugged into the given energy source. Otherwise returns false.
 
bool HasElectricityIcon ()
 Energy manager: Returns true if the electricity icon (bolt) is supposed to be visible for this device. False if not.
 
bool HasConversionOfEnergyToQuantity ()
 Energy manager: Returns true if this item automatically converts its energy to quantity.
 
bool IsEnergySourceAtReach (vector from_position, float add_tolerance=0, vector override_source_position="-1 -1 -1")
 Energy manager: Returns true if this device's virtual power cord can reach its energy source at the given position, depending on its cordLength config parameter. Otherwise returns false.
 
bool HasVisibleSocketsInInventory ()
 
bool IsSelectionAPlug (string selection_to_test)
 Energy manager: Returns true if this selection is a plug that's plugged into this device. Otherwise returns false.
 
int GetSocketsCount ()
 Energy manager: Returns the count of power sockets (whenever used or not)
 
int GetPlugType ()
 Energy manager: Returns plug type. Check \DZ\data\basicDefines.hpp OR \Scripts\Classes\Component_constants.h files for types of plugs.
 
int GetAttachmentAction ()
 
int GetEnergySourceStorageIDb1 ()
 
int GetEnergySourceStorageIDb2 ()
 
int GetEnergySourceStorageIDb3 ()
 
int GetEnergySourceStorageIDb4 ()
 
int GetEnergySourceNetworkIDLow ()
 
int GetEnergySourceNetworkIDHigh ()
 
int GetPluggedDevicesCount ()
 Energy manager: Returns the number of devices plugged into this one.
 
int GetEnergy0To100 ()
 Energy manager: Returns % of stored energy this device has as integer (from 0 to 100)
 
float GetEnergy0To1 ()
 Energy manager: Returns % of stored energy this device has as float (from 0.0 to 1.0)
 
float GetUpdateInterval ()
 Energy manager: Returns the update interval of this device.
 
float GetWetnessExposure ()
 Returns wetness exposure value defined in config.
 
float GetEnergyUsage ()
 Energy manager: Returns the number of energy this device needs to run itself (See its config >> energyUsagePerSecond)
 
float GetEnergy ()
 Energy manager: Returns the amount of stored energy this device has.
 
float AddEnergy (float added_energy)
 Energy manager: Adds energy to this device and clamps it within its min/max storage limits. Returns the amount of energy that was clamped. Negative value is supported, but you should still use ConsumeEnergy(...) for propper substraction of energy.
 
float GetEnergyMax ()
 Energy manager: Returns the maximum amount of energy this device can curently store. If parameter 'reduceMaxEnergyByDamageCoef' is used in the config of this device then the returned value will be reduced by damage.
 
float GetEnergyMaxPristine ()
 Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken into account.
 
float GetEnergyAtSpawn ()
 
float GetCordLength ()
 Energy manager: Returns the length of the virtual power cord.
 
EntityAI GetEnergySource ()
 Energy manager: Returns the energy source this device is plugged into.
 
EntityAI GetDeviceBySocketID (int id)
 Energy manager: Returns the device which is plugged into the given socket ID.
 
EntityAI GetPlugOwner (string plug_selection_name)
 Energy manager: Returns the device to which the given plug selection belongs to.
 
EntityAI GetPluggedDevice ()
 Energy manager: Returns a device which is plugged into this one. If there are more devices to choose from then it returns the first one that is found.
 
string GetCordTextureFile ()
 Energy manager: Returns path to the cord texture file.
 
array< EntityAIGetPluggedDevices ()
 Energy manager: Returns an array of devices which are plugged into this one.
 
array< EntityAIGetPoweredDevices ()
 Energy manager: Returns an array of devices which are plugged into this one and are turned on.
 
void OnWork (float consumed_energy)
 
void OnIsPlugged (EntityAI source_device)
 
void OnIsUnplugged (EntityAI last_energy_source)
 
void OnOwnSocketTaken (EntityAI device)
 
void OnOwnSocketReleased (EntityAI device)
 
void OnAttachmentAdded (EntityAI elec_device)
 
void OnAttachmentRemoved (EntityAI elec_device)
 
void StartUpdates ()
 
void OnEnergyConsumed ()
 Energy manager: Called when energy was consumed on this device.
 
void OnEnergyAdded ()
 Energy manager: Called when energy was added on this device.
 
void StopUpdates ()
 
void InteractBranch (EntityAI originalCaller, Man player=null, int system=0)
 
void OnInteractBranch (EntityAI originalCaller, Man player, int system)
 Called when the player is interacting with an item containing this energy component, or when interacting with an item this device is connected to.
 
void WakeUpWholeBranch (EntityAI original_caller)
 
void PlugCordIntoSocket (EntityAI device_to_plug, int socket_id=-1)
 
void UpdateSocketSelections (int socket_id, EntityAI device_to_plug)
 
void SetEnergySource (EntityAI source)
 
bool PlugInDevice (EntityAI device_to_plug, int socket_id=-1)
 
void SetPlugOwner (string selection_name, EntityAI device)
 
void UnplugCordFromSocket (int socket_to_unplug_ID)
 
void SetPowered (bool state)
 
bool FindAndConsumeEnergy (EntityAI original_caller, float amount, bool ignore_switch_state=false)
 
int GetMySocketID ()
 
void SetMySocketID (int slot_ID)
 
void Synch ()
 
void ClearLastUpdateTime ()
 
void RememberLastUpdateTime ()
 
float GetCurrentUpdateTime ()
 
void DeviceUpdate ()
 

Protected Attributes

const float DEFAULT_UPDATE_INTERVAL = 15
 
Shape m_DebugPlugArrow
 
bool m_IsSwichedOn
 
bool m_IsSwichedOnPreviousState
 
bool m_IsPassiveDevice
 
bool m_IsWorking
 
bool m_CanWork
 
bool m_CanStopWork
 
bool m_RestorePlugState
 
bool m_AutoSwitchOff
 
bool m_ShowSocketsInInventory
 
bool m_HasElectricityIcon
 
bool m_AutoSwitchOffWhenInCargo
 
bool m_IsPlugged
 
bool m_ConvertEnergyToQuantity
 
int m_MySocketID = -1
 
int m_PlugType
 
int m_EnergySourceStorageIDb1
 
int m_EnergySourceStorageIDb2
 
int m_EnergySourceStorageIDb3
 
int m_EnergySourceStorageIDb4
 
int m_AttachmentActionType
 
int m_EnergySourceNetworkIDLow = -1
 
int m_EnergySourceNetworkIDHigh = -1
 
float m_EnergyUsage
 
float m_Energy
 
float m_EnergyAtSpawn
 
float m_EnergyStorageMax
 
float m_ReduceMaxEnergyByDamageCoef
 
float m_SocketsCount
 
float m_CordLength
 
float m_LastUpdateTime
 
float m_WetnessExposure
 
float m_UpdateInterval
 
string m_CordTextureFile
 
ref TIntArray m_CompatiblePlugTypes
 
EntityAI m_EnergySource
 
ref array< EntityAIm_PluggedDevices
 
ref map< string, EntityAIm_DeviceByPlugSelection
 
ref Timer m_UpdateTimer
 
ref Timer m_UpdateQuantityTimer
 
ref Timer m_DebugUpdate
 
const int MAX_SOCKETS_COUNT = 4
 
EntityAI m_Sockets [MAX_SOCKETS_COUNT]
 

Static Protected Attributes

static bool m_DebugPlugs = false
 
static const string SOCKET_ = "socket_"
 
static const string _PLUGGED = "_plugged"
 
static const string _AVAILABLE = "_available"
 
static const string SEL_CORD_PLUGGED = "cord_plugged"
 
static const string SEL_CORD_FOLDED = "cord_folded"
 

Detailed Description

Definition at line 18 of file componentenergymanager.c.

Constructor & Destructor Documentation

◆ ComponentEnergyManager()

void ComponentEnergyManager::ComponentEnergyManager ( )
protected

Definition at line 83 of file componentenergymanager.c.

◆ ~ComponentEnergyManager()

void ComponentEnergyManager::~ComponentEnergyManager ( )
protected

Definition at line 91 of file componentenergymanager.c.

Member Function Documentation

◆ AddEnergy()

float ComponentEnergyManager::AddEnergy ( float added_energy)
protected

Energy manager: Adds energy to this device and clamps it within its min/max storage limits. Returns the amount of energy that was clamped. Negative value is supported, but you should still use ConsumeEnergy(...) for propper substraction of energy.

Definition at line 1220 of file componentenergymanager.c.

◆ CanBePluggedInto()

bool ComponentEnergyManager::CanBePluggedInto ( EntityAI potential_energy_provider)
protected

Energy manager: Returns true if this device can be plugged into the given energy source. Otherwise returns false.

Definition at line 998 of file componentenergymanager.c.

◆ CanReceivePlugFrom()

bool ComponentEnergyManager::CanReceivePlugFrom ( EntityAI device_to_plug)
protected

Energy manager: Returns true if this device can receive power plug of the other device.

Definition at line 976 of file componentenergymanager.c.

◆ CanSwitchOff()

bool ComponentEnergyManager::CanSwitchOff ( )
protected

Energy manager: Checks if the device can be switched OFF.

Definition at line 849 of file componentenergymanager.c.

◆ CanSwitchOn()

bool ComponentEnergyManager::CanSwitchOn ( )
protected

Energy manager: Checks if the device can be switched ON.

Definition at line 741 of file componentenergymanager.c.

◆ CanWork()

bool ComponentEnergyManager::CanWork ( float test_energy = -1)
protected

Energy manager: Checks whenever this device can do work or not.

Parameters
test_energyfloat optional parameter will overwite the default energy consumption value of this device.
Returns
bool Returns true if this device will work when it's switched on. Otherwise it returns false.

Definition at line 757 of file componentenergymanager.c.

◆ CheckWetness()

bool ComponentEnergyManager::CheckWetness ( )
protected

Energy manager: Checks if this device is being stopped from working by its wetness level. Returns true when its wetness is not blocking it, false when its to owet to work.

Definition at line 843 of file componentenergymanager.c.

◆ ClearLastUpdateTime()

void ComponentEnergyManager::ClearLastUpdateTime ( )
protected

Definition at line 1731 of file componentenergymanager.c.

◆ ConsumeEnergy()

bool ComponentEnergyManager::ConsumeEnergy ( float amount)
protected

Energy manager: Consumes the given amount of energy. If there is not enough of stored energy in this device, then it tries to take it from its power source, if any exists. Returns true if the requested amount of energy was consumed. Otherwise it returns false.

Definition at line 894 of file componentenergymanager.c.

◆ DebugUpdate()

void ComponentEnergyManager::DebugUpdate ( )
protected

Definition at line 108 of file componentenergymanager.c.

◆ DeviceUpdate()

void ComponentEnergyManager::DeviceUpdate ( )
protected

Definition at line 1747 of file componentenergymanager.c.

◆ DrawArrow()

Shape ComponentEnergyManager::DrawArrow ( vector from,
vector to,
float size = 0.5,
int color = 0xFFFFFFFF,
float flags = 0 )
protected

Definition at line 150 of file componentenergymanager.c.

◆ Event_OnAwake()

override void ComponentEnergyManager::Event_OnAwake ( )
protected

Definition at line 175 of file componentenergymanager.c.

◆ Event_OnInit()

override void ComponentEnergyManager::Event_OnInit ( )
protected

Definition at line 101 of file componentenergymanager.c.

◆ FindAndConsumeEnergy()

bool ComponentEnergyManager::FindAndConsumeEnergy ( EntityAI original_caller,
float amount,
bool ignore_switch_state = false )
protected

Definition at line 1684 of file componentenergymanager.c.

◆ GetAttachmentAction()

int ComponentEnergyManager::GetAttachmentAction ( )
protected

Definition at line 1114 of file componentenergymanager.c.

◆ GetCompatiblePlugTypes()

void ComponentEnergyManager::GetCompatiblePlugTypes ( out TIntArray IDs)
protected

Definition at line 615 of file componentenergymanager.c.

◆ GetCompType()

override int ComponentEnergyManager::GetCompType ( )
protected

Definition at line 316 of file componentenergymanager.c.

◆ GetCordLength()

float ComponentEnergyManager::GetCordLength ( )
protected

Energy manager: Returns the length of the virtual power cord.

Definition at line 1286 of file componentenergymanager.c.

◆ GetCordTextureFile()

string ComponentEnergyManager::GetCordTextureFile ( )
protected

Energy manager: Returns path to the cord texture file.

Definition at line 1326 of file componentenergymanager.c.

◆ GetCurrentUpdateTime()

float ComponentEnergyManager::GetCurrentUpdateTime ( )
protected

Definition at line 1741 of file componentenergymanager.c.

◆ GetDebugPlugs()

bool ComponentEnergyManager::GetDebugPlugs ( )
protected

Definition at line 357 of file componentenergymanager.c.

◆ GetDeviceBySocketID()

EntityAI ComponentEnergyManager::GetDeviceBySocketID ( int id)
protected

Energy manager: Returns the device which is plugged into the given socket ID.

Definition at line 1298 of file componentenergymanager.c.

◆ GetEnergy()

float ComponentEnergyManager::GetEnergy ( )
protected

Energy manager: Returns the amount of stored energy this device has.

Definition at line 1214 of file componentenergymanager.c.

◆ GetEnergy0To1()

float ComponentEnergyManager::GetEnergy0To1 ( )
protected

Energy manager: Returns % of stored energy this device has as float (from 0.0 to 1.0)

Definition at line 1179 of file componentenergymanager.c.

◆ GetEnergy0To100()

int ComponentEnergyManager::GetEnergy0To100 ( )
protected

Energy manager: Returns % of stored energy this device has as integer (from 0 to 100)

Definition at line 1167 of file componentenergymanager.c.

◆ GetEnergyAtSpawn()

float ComponentEnergyManager::GetEnergyAtSpawn ( )
protected

Definition at line 1280 of file componentenergymanager.c.

◆ GetEnergyMax()

float ComponentEnergyManager::GetEnergyMax ( )
protected

Energy manager: Returns the maximum amount of energy this device can curently store. If parameter 'reduceMaxEnergyByDamageCoef' is used in the config of this device then the returned value will be reduced by damage.

Definition at line 1252 of file componentenergymanager.c.

◆ GetEnergyMaxPristine()

float ComponentEnergyManager::GetEnergyMaxPristine ( )
protected

Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken into account.

Definition at line 1275 of file componentenergymanager.c.

◆ GetEnergySource()

EntityAI ComponentEnergyManager::GetEnergySource ( )
protected

Energy manager: Returns the energy source this device is plugged into.

Definition at line 1292 of file componentenergymanager.c.

◆ GetEnergySourceNetworkIDHigh()

int ComponentEnergyManager::GetEnergySourceNetworkIDHigh ( )
protected

Definition at line 1150 of file componentenergymanager.c.

◆ GetEnergySourceNetworkIDLow()

int ComponentEnergyManager::GetEnergySourceNetworkIDLow ( )
protected

Definition at line 1144 of file componentenergymanager.c.

◆ GetEnergySourceStorageIDb1()

int ComponentEnergyManager::GetEnergySourceStorageIDb1 ( )
protected

Definition at line 1120 of file componentenergymanager.c.

◆ GetEnergySourceStorageIDb2()

int ComponentEnergyManager::GetEnergySourceStorageIDb2 ( )
protected

Definition at line 1126 of file componentenergymanager.c.

◆ GetEnergySourceStorageIDb3()

int ComponentEnergyManager::GetEnergySourceStorageIDb3 ( )
protected

Definition at line 1132 of file componentenergymanager.c.

◆ GetEnergySourceStorageIDb4()

int ComponentEnergyManager::GetEnergySourceStorageIDb4 ( )
protected

Definition at line 1138 of file componentenergymanager.c.

◆ GetEnergyUsage()

float ComponentEnergyManager::GetEnergyUsage ( )
protected

Energy manager: Returns the number of energy this device needs to run itself (See its config >> energyUsagePerSecond)

Definition at line 1208 of file componentenergymanager.c.

◆ GetMySocketID()

int ComponentEnergyManager::GetMySocketID ( )
protected

Definition at line 1715 of file componentenergymanager.c.

◆ GetPluggedDevice()

EntityAI ComponentEnergyManager::GetPluggedDevice ( )
protected

Energy manager: Returns a device which is plugged into this one. If there are more devices to choose from then it returns the first one that is found.

Definition at line 1315 of file componentenergymanager.c.

◆ GetPluggedDevices()

array< EntityAI > ComponentEnergyManager::GetPluggedDevices ( )
protected

Energy manager: Returns an array of devices which are plugged into this one.

Definition at line 1332 of file componentenergymanager.c.

◆ GetPluggedDevicesCount()

int ComponentEnergyManager::GetPluggedDevicesCount ( )
protected

Energy manager: Returns the number of devices plugged into this one.

Definition at line 1156 of file componentenergymanager.c.

◆ GetPlugOwner()

EntityAI ComponentEnergyManager::GetPlugOwner ( string plug_selection_name)
protected

Energy manager: Returns the device to which the given plug selection belongs to.

Definition at line 1304 of file componentenergymanager.c.

◆ GetPlugType()

int ComponentEnergyManager::GetPlugType ( )
protected

Energy manager: Returns plug type. Check \DZ\data\basicDefines.hpp OR \Scripts\Classes\Component_constants.h files for types of plugs.

Definition at line 1108 of file componentenergymanager.c.

◆ GetPoweredDevices()

array< EntityAI > ComponentEnergyManager::GetPoweredDevices ( )
protected

Energy manager: Returns an array of devices which are plugged into this one and are turned on.

Definition at line 1338 of file componentenergymanager.c.

◆ GetPreviousSwitchState()

bool ComponentEnergyManager::GetPreviousSwitchState ( )
protected

Definition at line 860 of file componentenergymanager.c.

◆ GetRestorePlugState()

bool ComponentEnergyManager::GetRestorePlugState ( )
protected

Definition at line 729 of file componentenergymanager.c.

◆ GetSocketsCount()

int ComponentEnergyManager::GetSocketsCount ( )
protected

Energy manager: Returns the count of power sockets (whenever used or not)

Definition at line 1102 of file componentenergymanager.c.

◆ GetThisEntityAI()

EntityAI ComponentEnergyManager::GetThisEntityAI ( )
protected

Definition at line 169 of file componentenergymanager.c.

◆ GetUpdateInterval()

float ComponentEnergyManager::GetUpdateInterval ( )
protected

Energy manager: Returns the update interval of this device.

Definition at line 1190 of file componentenergymanager.c.

◆ GetWetnessExposure()

float ComponentEnergyManager::GetWetnessExposure ( )
protected

Returns wetness exposure value defined in config.

Definition at line 1202 of file componentenergymanager.c.

◆ HandleMoveInsideCargo()

void ComponentEnergyManager::HandleMoveInsideCargo ( EntityAI container)
protected

Definition at line 711 of file componentenergymanager.c.

◆ HasConversionOfEnergyToQuantity()

bool ComponentEnergyManager::HasConversionOfEnergyToQuantity ( )
protected

Energy manager: Returns true if this item automatically converts its energy to quantity.

Definition at line 1010 of file componentenergymanager.c.

◆ HasElectricityIcon()

bool ComponentEnergyManager::HasElectricityIcon ( )
protected

Energy manager: Returns true if the electricity icon (bolt) is supposed to be visible for this device. False if not.

Definition at line 1004 of file componentenergymanager.c.

◆ HasEnoughStoredEnergy()

bool ComponentEnergyManager::HasEnoughStoredEnergy ( )
protected

Energy manager: Returns true if this device has enough of stored energy for its own use.

Definition at line 906 of file componentenergymanager.c.

◆ HasFreeSocket()

bool ComponentEnergyManager::HasFreeSocket ( int socket_id = -1)
protected

Energy manager: Returns true if this device has any free socket to receive a plug. If optional parameter socket_id is provided then only that socket ID is checked.

Definition at line 917 of file componentenergymanager.c.

◆ HasVisibleSocketsInInventory()

bool ComponentEnergyManager::HasVisibleSocketsInInventory ( )
protected

Definition at line 1072 of file componentenergymanager.c.

◆ InteractBranch()

void ComponentEnergyManager::InteractBranch ( EntityAI originalCaller,
Man player = null,
int system = 0 )
protected

Gets called originally when the player is interacting with an item containing this energy component, then recursively following the branches of connection from the original item to the peripheries External calling of this function is not automatic for all item interactions and may need to be implemented on case by case bases Avoid using for gameplay logic, use 'OnInteractBranch' instead

Definition at line 1502 of file componentenergymanager.c.

◆ IsCordFolded()

bool ComponentEnergyManager::IsCordFolded ( )
protected

Energy manager: Returns true if the cord of this device is folded. Returns false if it's plugged.

Definition at line 872 of file componentenergymanager.c.

◆ IsEnergySourceAtReach()

bool ComponentEnergyManager::IsEnergySourceAtReach ( vector from_position,
float add_tolerance = 0,
vector override_source_position = "-1 -1 -1" )
protected

Energy manager: Returns true if this device's virtual power cord can reach its energy source at the given position, depending on its cordLength config parameter. Otherwise returns false.

Parameters
from_positionvector position from where the measurement will be taken
add_tolerancefloat parameter will add to the cord's length in meters (optional)
Returns
bool True if the power source will be at reach for the plug, or if config param cordLength is absent or 0. False if not, or is not plugged, or this device lacks Energy Manager component.
vector position_player = GetGame().GetPlayer().GetPosition();
if ( my_device.GetCompEM().IsEnergySourceAtReach( position_player ) )
{
Print("Power source is at reach!");
}else{
Print("Power source is NOT at reach!");
}
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.

Definition at line 1031 of file componentenergymanager.c.

◆ IsPassive()

bool ComponentEnergyManager::IsPassive ( )
protected

Energy manager: Returns true if this device is set to be passive. False if otherwise.

Definition at line 881 of file componentenergymanager.c.

◆ IsPlugCompatible()

bool ComponentEnergyManager::IsPlugCompatible ( int plug_ID)
protected

Energy manager: Checks if the given plug is compatible with this device's socket. Used by CanReceivePlugFrom() method.

Definition at line 947 of file componentenergymanager.c.

◆ IsPlugged()

bool ComponentEnergyManager::IsPlugged ( )
protected

Energy manager: Returns true if this device is plugged into some other device (even if they are OFF or ruined). Otherwise it returns false.

Definition at line 887 of file componentenergymanager.c.

◆ IsSelectionAPlug()

bool ComponentEnergyManager::IsSelectionAPlug ( string selection_to_test)
protected

Energy manager: Returns true if this selection is a plug that's plugged into this device. Otherwise returns false.

Definition at line 1078 of file componentenergymanager.c.

◆ IsSwitchedOn()

bool ComponentEnergyManager::IsSwitchedOn ( )
protected

Energy manager: Returns state of the switch. Whenever the device is working or not does not matter. Use IsWorking() to account for that as well.

Definition at line 866 of file componentenergymanager.c.

◆ IsWorking()

bool ComponentEnergyManager::IsWorking ( )
protected

Energy manager: Returns true if this device is working right now.

Definition at line 900 of file componentenergymanager.c.

◆ OnAttachmentAdded()

void ComponentEnergyManager::OnAttachmentAdded ( EntityAI elec_device)
protected

Definition at line 1416 of file componentenergymanager.c.

◆ OnAttachmentRemoved()

void ComponentEnergyManager::OnAttachmentRemoved ( EntityAI elec_device)
protected

Definition at line 1434 of file componentenergymanager.c.

◆ OnDeviceDestroyed()

void ComponentEnergyManager::OnDeviceDestroyed ( )
protected

Definition at line 322 of file componentenergymanager.c.

◆ OnEnergyAdded()

void ComponentEnergyManager::OnEnergyAdded ( )
protected

Energy manager: Called when energy was added on this device.

Definition at line 1473 of file componentenergymanager.c.

◆ OnEnergyConsumed()

void ComponentEnergyManager::OnEnergyConsumed ( )
protected

Energy manager: Called when energy was consumed on this device.

Definition at line 1467 of file componentenergymanager.c.

◆ OnInteractBranch()

void ComponentEnergyManager::OnInteractBranch ( EntityAI originalCaller,
Man player,
int system )
protected

Called when the player is interacting with an item containing this energy component, or when interacting with an item this device is connected to.

Definition at line 1520 of file componentenergymanager.c.

◆ OnIsPlugged()

void ComponentEnergyManager::OnIsPlugged ( EntityAI source_device)
protected

Definition at line 1366 of file componentenergymanager.c.

◆ OnIsUnplugged()

void ComponentEnergyManager::OnIsUnplugged ( EntityAI last_energy_source)
protected

Definition at line 1382 of file componentenergymanager.c.

◆ OnOwnSocketReleased()

void ComponentEnergyManager::OnOwnSocketReleased ( EntityAI device)
protected

Definition at line 1402 of file componentenergymanager.c.

◆ OnOwnSocketTaken()

void ComponentEnergyManager::OnOwnSocketTaken ( EntityAI device)
protected

Definition at line 1389 of file componentenergymanager.c.

◆ OnWork()

void ComponentEnergyManager::OnWork ( float consumed_energy)
protected

Definition at line 1360 of file componentenergymanager.c.

◆ PlugCordIntoSocket()

void ComponentEnergyManager::PlugCordIntoSocket ( EntityAI device_to_plug,
int socket_id = -1 )
protected

Definition at line 1550 of file componentenergymanager.c.

◆ PlugInDevice()

bool ComponentEnergyManager::PlugInDevice ( EntityAI device_to_plug,
int socket_id = -1 )
protected

Definition at line 1619 of file componentenergymanager.c.

◆ PlugThisInto()

bool ComponentEnergyManager::PlugThisInto ( EntityAI energy_source,
int socket_id = -1 )
protected

Energy manager: Attempts to plug this device into the energy_source. Returns true if the action was successfull, or false if not (due to plug incompatibility or no free socket on the receiver). The ID of the power socket is chosen automatically unless optional parameter socket_id is used (starting from 0). If the given ID is not free then a free socket is found.

Definition at line 735 of file componentenergymanager.c.

◆ RefreshDebug()

void ComponentEnergyManager::RefreshDebug ( )
protected

Definition at line 337 of file componentenergymanager.c.

◆ RememberLastUpdateTime()

void ComponentEnergyManager::RememberLastUpdateTime ( )
protected

Definition at line 1736 of file componentenergymanager.c.

◆ ResetEnergyUsage()

void ComponentEnergyManager::ResetEnergyUsage ( )
protected

Energy manager: Resets energy usage to default (config) value.

Definition at line 660 of file componentenergymanager.c.

◆ RestorePlugState()

void ComponentEnergyManager::RestorePlugState ( bool state)
protected

Definition at line 519 of file componentenergymanager.c.

◆ SetAttachmentAction()

void ComponentEnergyManager::SetAttachmentAction ( int new_action_type)
protected

Definition at line 648 of file componentenergymanager.c.

◆ SetCordLength()

void ComponentEnergyManager::SetCordLength ( float new_length)
protected

Energy manager: Changes the length of the virtual power cord.

Definition at line 636 of file componentenergymanager.c.

◆ SetCordTextureFile()

void ComponentEnergyManager::SetCordTextureFile ( string new_path)
protected

Definition at line 667 of file componentenergymanager.c.

◆ SetDebugPlugs()

void ComponentEnergyManager::SetDebugPlugs ( bool newVal)
protected

Definition at line 362 of file componentenergymanager.c.

◆ SetDeviceBySocketID()

void ComponentEnergyManager::SetDeviceBySocketID ( int id,
EntityAI plugged_device )
protected

Energy manager: Stores the device which is plugged into the given socket ID.

Definition at line 679 of file componentenergymanager.c.

◆ SetElectricityIconVisibility()

void ComponentEnergyManager::SetElectricityIconVisibility ( bool make_visible)
protected

Energy manager: Sets visibility of the electricity icon (bolt).

Definition at line 686 of file componentenergymanager.c.

◆ SetEnergy()

void ComponentEnergyManager::SetEnergy ( float new_energy)
protected

Energy manager: Sets stored energy for this device. It ignores the min/max limit!

Definition at line 525 of file componentenergymanager.c.

◆ SetEnergy0To1()

void ComponentEnergyManager::SetEnergy0To1 ( float energy01)
protected

Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value between 0 and 1.

Definition at line 541 of file componentenergymanager.c.

◆ SetEnergyMaxPristine()

void ComponentEnergyManager::SetEnergyMaxPristine ( float new_limit)
protected

Energy manager: Changes the maximum amount of energy this device can store (when pristine).

Definition at line 630 of file componentenergymanager.c.

◆ SetEnergySource()

void ComponentEnergyManager::SetEnergySource ( EntityAI source)
protected

Definition at line 1596 of file componentenergymanager.c.

◆ SetEnergySourceClient()

void ComponentEnergyManager::SetEnergySourceClient ( EntityAI source)
protected

Definition at line 673 of file componentenergymanager.c.

◆ SetEnergyUsage()

void ComponentEnergyManager::SetEnergyUsage ( float new_usage)
protected

Energy manager: Changes the energy usage per second.

Definition at line 654 of file componentenergymanager.c.

◆ SetMySocketID()

void ComponentEnergyManager::SetMySocketID ( int slot_ID)
protected

Definition at line 1721 of file componentenergymanager.c.

◆ SetPassiveState()

void ComponentEnergyManager::SetPassiveState ( bool state = true)
protected

Energy manager: Changes the status of this device. When it's passive (true), the main timer and OnWork events are not used.

Definition at line 441 of file componentenergymanager.c.

◆ SetPlugOwner()

void ComponentEnergyManager::SetPlugOwner ( string selection_name,
EntityAI device )
protected

Definition at line 1650 of file componentenergymanager.c.

◆ SetPlugType()

void ComponentEnergyManager::SetPlugType ( int new_type)
protected

Definition at line 642 of file componentenergymanager.c.

◆ SetPowered()

void ComponentEnergyManager::SetPowered ( bool state)
protected

Definition at line 1678 of file componentenergymanager.c.

◆ SetUpdateInterval()

void ComponentEnergyManager::SetUpdateInterval ( float value)
protected

Energy manager: Sets the interval of the OnWork(...) calls. Changing this value does not change the rate of energy consumption.

Definition at line 723 of file componentenergymanager.c.

◆ StartUpdates()

void ComponentEnergyManager::StartUpdates ( )
protected

Definition at line 1452 of file componentenergymanager.c.

◆ StopUpdates()

void ComponentEnergyManager::StopUpdates ( )
protected

Definition at line 1490 of file componentenergymanager.c.

◆ StoreEnergySourceIDs()

void ComponentEnergyManager::StoreEnergySourceIDs ( int b1,
int b2,
int b3,
int b4 )
protected

Definition at line 621 of file componentenergymanager.c.

◆ SwitchOff()

void ComponentEnergyManager::SwitchOff ( )
protected

Energy manager: Switches OFF the device.

Definition at line 406 of file componentenergymanager.c.

◆ SwitchOn()

void ComponentEnergyManager::SwitchOn ( )
protected

Energy manager: Switches ON the device so it starts doing its work if it has enough energy.

Definition at line 375 of file componentenergymanager.c.

◆ Synch()

void ComponentEnergyManager::Synch ( )
protected

Definition at line 1726 of file componentenergymanager.c.

◆ UnplugAllDevices()

void ComponentEnergyManager::UnplugAllDevices ( )
protected

Energy manager: Unplugs everything directly connected to this device.

Definition at line 506 of file componentenergymanager.c.

◆ UnplugCordFromSocket()

void ComponentEnergyManager::UnplugCordFromSocket ( int socket_to_unplug_ID)
protected

Definition at line 1660 of file componentenergymanager.c.

◆ UnplugDevice()

void ComponentEnergyManager::UnplugDevice ( EntityAI device_to_unplug)
protected

Energy manager: Unplugs the given device from this one.

Definition at line 451 of file componentenergymanager.c.

◆ UnplugThis()

void ComponentEnergyManager::UnplugThis ( )
protected

Energy manager: Unplugs this device from its power source.

Definition at line 494 of file componentenergymanager.c.

◆ UpdateCanWork()

void ComponentEnergyManager::UpdateCanWork ( )
protected

Definition at line 692 of file componentenergymanager.c.

◆ UpdatePlugState()

void ComponentEnergyManager::UpdatePlugState ( )
protected

Energy manager: Unplugs this device when it's necesarry.

Definition at line 587 of file componentenergymanager.c.

◆ UpdateSelections()

void ComponentEnergyManager::UpdateSelections ( )
protected

Energy manager: Shows/Hides all selections this system works with. Call this if something is wrong with selections (like during Init and Restore event in config)

Definition at line 547 of file componentenergymanager.c.

◆ UpdateSocketSelections()

void ComponentEnergyManager::UpdateSocketSelections ( int socket_id,
EntityAI device_to_plug )
protected

Definition at line 1578 of file componentenergymanager.c.

◆ WakeUpWholeBranch()

void ComponentEnergyManager::WakeUpWholeBranch ( EntityAI original_caller)
protected

Definition at line 1527 of file componentenergymanager.c.

Member Data Documentation

◆ _AVAILABLE

const string ComponentEnergyManager::_AVAILABLE = "_available"
staticprotected

Definition at line 64 of file componentenergymanager.c.

◆ _PLUGGED

const string ComponentEnergyManager::_PLUGGED = "_plugged"
staticprotected

Definition at line 63 of file componentenergymanager.c.

◆ DEFAULT_UPDATE_INTERVAL

const float ComponentEnergyManager::DEFAULT_UPDATE_INTERVAL = 15
protected

Definition at line 20 of file componentenergymanager.c.

◆ m_AttachmentActionType

int ComponentEnergyManager::m_AttachmentActionType
protected

Definition at line 44 of file componentenergymanager.c.

◆ m_AutoSwitchOff

bool ComponentEnergyManager::m_AutoSwitchOff
protected

Definition at line 31 of file componentenergymanager.c.

◆ m_AutoSwitchOffWhenInCargo

bool ComponentEnergyManager::m_AutoSwitchOffWhenInCargo
protected

Definition at line 34 of file componentenergymanager.c.

◆ m_CanStopWork

bool ComponentEnergyManager::m_CanStopWork
protected

Definition at line 29 of file componentenergymanager.c.

◆ m_CanWork

bool ComponentEnergyManager::m_CanWork
protected

Definition at line 28 of file componentenergymanager.c.

◆ m_CompatiblePlugTypes

ref TIntArray ComponentEnergyManager::m_CompatiblePlugTypes
protected

Definition at line 68 of file componentenergymanager.c.

◆ m_ConvertEnergyToQuantity

bool ComponentEnergyManager::m_ConvertEnergyToQuantity
protected

Definition at line 36 of file componentenergymanager.c.

◆ m_CordLength

float ComponentEnergyManager::m_CordLength
protected

Definition at line 54 of file componentenergymanager.c.

◆ m_CordTextureFile

string ComponentEnergyManager::m_CordTextureFile
protected

Definition at line 59 of file componentenergymanager.c.

◆ m_DebugPlugArrow

Shape ComponentEnergyManager::m_DebugPlugArrow
protected

Definition at line 22 of file componentenergymanager.c.

◆ m_DebugPlugs

bool ComponentEnergyManager::m_DebugPlugs = false
staticprotected

Definition at line 21 of file componentenergymanager.c.

◆ m_DebugUpdate

ref Timer ComponentEnergyManager::m_DebugUpdate
protected

Definition at line 75 of file componentenergymanager.c.

◆ m_DeviceByPlugSelection

ref map<string,EntityAI> ComponentEnergyManager::m_DeviceByPlugSelection
protected

Definition at line 71 of file componentenergymanager.c.

◆ m_Energy

float ComponentEnergyManager::m_Energy
protected

Definition at line 49 of file componentenergymanager.c.

◆ m_EnergyAtSpawn

float ComponentEnergyManager::m_EnergyAtSpawn
protected

Definition at line 50 of file componentenergymanager.c.

◆ m_EnergySource

EntityAI ComponentEnergyManager::m_EnergySource
protected

Definition at line 69 of file componentenergymanager.c.

◆ m_EnergySourceNetworkIDHigh

int ComponentEnergyManager::m_EnergySourceNetworkIDHigh = -1
protected

Definition at line 46 of file componentenergymanager.c.

◆ m_EnergySourceNetworkIDLow

int ComponentEnergyManager::m_EnergySourceNetworkIDLow = -1
protected

Definition at line 45 of file componentenergymanager.c.

◆ m_EnergySourceStorageIDb1

int ComponentEnergyManager::m_EnergySourceStorageIDb1
protected

Definition at line 40 of file componentenergymanager.c.

◆ m_EnergySourceStorageIDb2

int ComponentEnergyManager::m_EnergySourceStorageIDb2
protected

Definition at line 41 of file componentenergymanager.c.

◆ m_EnergySourceStorageIDb3

int ComponentEnergyManager::m_EnergySourceStorageIDb3
protected

Definition at line 42 of file componentenergymanager.c.

◆ m_EnergySourceStorageIDb4

int ComponentEnergyManager::m_EnergySourceStorageIDb4
protected

Definition at line 43 of file componentenergymanager.c.

◆ m_EnergyStorageMax

float ComponentEnergyManager::m_EnergyStorageMax
protected

Definition at line 51 of file componentenergymanager.c.

◆ m_EnergyUsage

float ComponentEnergyManager::m_EnergyUsage
protected

Definition at line 48 of file componentenergymanager.c.

◆ m_HasElectricityIcon

bool ComponentEnergyManager::m_HasElectricityIcon
protected

Definition at line 33 of file componentenergymanager.c.

◆ m_IsPassiveDevice

bool ComponentEnergyManager::m_IsPassiveDevice
protected

Definition at line 26 of file componentenergymanager.c.

◆ m_IsPlugged

bool ComponentEnergyManager::m_IsPlugged
protected

Definition at line 35 of file componentenergymanager.c.

◆ m_IsSwichedOn

bool ComponentEnergyManager::m_IsSwichedOn
protected

Definition at line 24 of file componentenergymanager.c.

◆ m_IsSwichedOnPreviousState

bool ComponentEnergyManager::m_IsSwichedOnPreviousState
protected

Definition at line 25 of file componentenergymanager.c.

◆ m_IsWorking

bool ComponentEnergyManager::m_IsWorking
protected

Definition at line 27 of file componentenergymanager.c.

◆ m_LastUpdateTime

float ComponentEnergyManager::m_LastUpdateTime
protected

Definition at line 55 of file componentenergymanager.c.

◆ m_MySocketID

int ComponentEnergyManager::m_MySocketID = -1
protected

Definition at line 38 of file componentenergymanager.c.

◆ m_PluggedDevices

ref array<EntityAI> ComponentEnergyManager::m_PluggedDevices
protected

Definition at line 70 of file componentenergymanager.c.

◆ m_PlugType

int ComponentEnergyManager::m_PlugType
protected

Definition at line 39 of file componentenergymanager.c.

◆ m_ReduceMaxEnergyByDamageCoef

float ComponentEnergyManager::m_ReduceMaxEnergyByDamageCoef
protected

Definition at line 52 of file componentenergymanager.c.

◆ m_RestorePlugState

bool ComponentEnergyManager::m_RestorePlugState
protected

Definition at line 30 of file componentenergymanager.c.

◆ m_ShowSocketsInInventory

bool ComponentEnergyManager::m_ShowSocketsInInventory
protected

Definition at line 32 of file componentenergymanager.c.

◆ m_Sockets

EntityAI ComponentEnergyManager::m_Sockets[MAX_SOCKETS_COUNT]
protected

Definition at line 78 of file componentenergymanager.c.

◆ m_SocketsCount

float ComponentEnergyManager::m_SocketsCount
protected

Definition at line 53 of file componentenergymanager.c.

◆ m_UpdateInterval

float ComponentEnergyManager::m_UpdateInterval
protected

Definition at line 57 of file componentenergymanager.c.

◆ m_UpdateQuantityTimer

ref Timer ComponentEnergyManager::m_UpdateQuantityTimer
protected

Definition at line 74 of file componentenergymanager.c.

◆ m_UpdateTimer

ref Timer ComponentEnergyManager::m_UpdateTimer
protected

Definition at line 73 of file componentenergymanager.c.

◆ m_WetnessExposure

float ComponentEnergyManager::m_WetnessExposure
protected

Definition at line 56 of file componentenergymanager.c.

◆ MAX_SOCKETS_COUNT

const int ComponentEnergyManager::MAX_SOCKETS_COUNT = 4
protected

Definition at line 77 of file componentenergymanager.c.

◆ SEL_CORD_FOLDED

const string ComponentEnergyManager::SEL_CORD_FOLDED = "cord_folded"
staticprotected

Definition at line 66 of file componentenergymanager.c.

◆ SEL_CORD_PLUGGED

const string ComponentEnergyManager::SEL_CORD_PLUGGED = "cord_plugged"
staticprotected

Definition at line 65 of file componentenergymanager.c.

◆ SOCKET_

const string ComponentEnergyManager::SOCKET_ = "socket_"
staticprotected

Definition at line 62 of file componentenergymanager.c.


The documentation for this class was generated from the following file: