DayZ 1.24
Loading...
Searching...
No Matches
ComponentEnergyManager Class Reference
Inheritance diagram for ComponentEnergyManager:
[legend]
Collaboration diagram for ComponentEnergyManager:
[legend]

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"
 

Additional Inherited Members

- Private Member Functions inherited from Component
void Event_OnFrame (IEntity other, float timeSlice)
 
Shape DebugBBoxDraw ()
 
void DebugBBoxSetColor (int color)
 
void DebugBBoxDelete ()
 
Shape DebugDirectionDraw (float distance=1)
 
void DebugDirectionSetColor (int color)
 
void DebugDirectionDelete ()
 
void SetParentEntityAI (EntityAI e)
 
void Event_OnAwake ()
 
void Event_OnInit ()
 
void LogThis (string msg, string fnc_name="n/a")
 
void LogThisWarning (string msg, string fnc_name="n/a")
 
void LogThisError (string msg, string fnc_name="n/a")
 
string GetCompName ()
 
int GetCompType ()
 
void Event_OnItemAttached (EntityAI item, string slot_name)
 
void Event_OnItemDetached (EntityAI item, string slot_name)
 
override Shape DebugBBoxDraw ()
 
override void DebugBBoxSetColor (int color)
 
override void DebugBBoxDelete ()
 
override Shape DebugDirectionDraw (float distance=1)
 
override void DebugDirectionDelete ()
 
void OnDrawing ()
 
- Static Private Member Functions inherited from Component
static void Init ()
 
static string GetNameByType (int comp_type)
 
static bool IsTypeExist (int comp_type)
 
static void LogErrorBadCompType (int comp_type, string fnc_name)
 
static void LogWarningAlredyExist (int comp_type, string fnc_name)
 
- Private Attributes inherited from Component
EntityAI m_ThisEntityAI
 
Shape m_DebugShapeBBox
 
Shape m_DebugShapeDirection
 
float m_DebugShapeDirectionDist
 

Detailed Description

Definition at line 18 of file ComponentEnergyManager.c.

Constructor & Destructor Documentation

◆ ComponentEnergyManager()

void ComponentEnergyManager::ComponentEnergyManager ( )
inlineprotected

Definition at line 82 of file ComponentEnergyManager.c.

83 {
84 // Disable debug arrows on public release, so that they don't use their timers.
85#ifndef DEVELOPER
86 m_DebugPlugs = false;
87#endif
88 }

References m_DebugPlugs.

◆ ~ComponentEnergyManager()

void ComponentEnergyManager::~ComponentEnergyManager ( )
inlineprotected

Definition at line 90 of file ComponentEnergyManager.c.

91 {
93 {
94 m_DebugPlugArrow.Destroy();
96 }
97 }

References m_DebugPlugArrow.

Member Function Documentation

◆ AddEnergy()

float ComponentEnergyManager::AddEnergy ( float added_energy)
inlineprotected

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 1150 of file ComponentEnergyManager.c.

1151 {
1152 if (added_energy != 0)
1153 {
1154 //Print("AddEnergy ---------> " + added_energy + " " + this + " " +m_ThisEntityAI.ClassName());
1155#ifdef DIAG_DEVELOPER
1156 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_CONSUMPTION) && added_energy < 0)
1157 {
1158 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
1160 }
1161#endif
1162
1163 bool energy_was_added = (added_energy > 0);
1164
1168 StartUpdates();
1169
1170 if (energy_was_added)
1171 OnEnergyAdded();
1172 else
1174
1176 }
1177
1178 return 0;
1179 }
float GetEnergyMax()
Energy manager: Returns the maximum amount of energy this device can curently store....
void OnEnergyAdded()
Energy manager: Called when energy was added on this device.
float GetEnergy()
Energy manager: Returns the amount of stored energy this device has.
void SetEnergy(float new_energy)
Energy manager: Sets stored energy for this device. It ignores the min/max limit!
void OnEnergyConsumed()
Energy manager: Called when energy was consumed on this device.
Definition EnMath.c:7
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

References Math::Clamp(), GetEnergy(), GetEnergyMax(), OnEnergyAdded(), OnEnergyConsumed(), SetEnergy(), and StartUpdates().

Referenced by FindAndConsumeEnergy().

◆ CanBePluggedInto()

bool ComponentEnergyManager::CanBePluggedInto ( EntityAI potential_energy_provider)
inlineprotected

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

Definition at line 944 of file ComponentEnergyManager.c.

945 {
946 return potential_energy_provider.GetCompEM().CanReceivePlugFrom(m_ThisEntityAI);
947 }
EntityAI m_ThisEntityAI
Definition Component.c:24

References Component::m_ThisEntityAI.

◆ CanReceivePlugFrom()

bool ComponentEnergyManager::CanReceivePlugFrom ( EntityAI device_to_plug)
inlineprotected

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

Definition at line 924 of file ComponentEnergyManager.c.

925 {
926 // The following conditions are broken down for the sake of easier reading/debugging.
927
929 {
930 if (device_to_plug.GetCompEM().GetEnergySource() != m_ThisEntityAI)
931 {
932 if (IsPlugCompatible(device_to_plug.GetCompEM().GetPlugType()))
933 {
934 if (device_to_plug.GetCompEM().IsEnergySourceAtReach(device_to_plug.GetPosition(), 0, m_ThisEntityAI.GetPosition()))
935 return true;
936 }
937 }
938 }
939
940 return false;
941 }
bool HasFreeSocket(int socket_id=-1)
Energy manager: Returns true if this device has any free socket to receive a plug....
bool IsPlugCompatible(int plug_ID)
Energy manager: Checks if the given plug is compatible with this device's socket. Used by CanReceiveP...

References HasFreeSocket(), IsPlugCompatible(), and Component::m_ThisEntityAI.

Referenced by PlugInDevice().

◆ CanSwitchOff()

bool ComponentEnergyManager::CanSwitchOff ( )
inlineprotected

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

Definition at line 809 of file ComponentEnergyManager.c.

810 {
811 if (IsPassive())
812 return false;
813
814 return IsSwitchedOn();
815 }
bool IsPassive()
Energy manager: Returns true if this device is set to be passive. False if otherwise.
bool IsSwitchedOn()
Energy manager: Returns state of the switch. Whenever the device is working or not does not matter....

References IsPassive(), and IsSwitchedOn().

Referenced by SwitchOff().

◆ CanSwitchOn()

bool ComponentEnergyManager::CanSwitchOn ( )
inlineprotected

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

Definition at line 715 of file ComponentEnergyManager.c.

716 {
717 if (!IsSwitchedOn())
718 return true;
719
720 return false;
721 }

References IsSwitchedOn().

Referenced by SwitchOn().

◆ CanWork()

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

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 729 of file ComponentEnergyManager.c.

730 {
731 if (GetGame().IsMultiplayer() && GetGame().IsClient())
732 return m_CanWork;
733
734 if (m_ThisEntityAI && m_ThisEntityAI.IsRuined())
735 return false;
736
737 // Check if the power source(s) (which can be serially connected) can provide needed energy.
739 float gathered_energy = GetEnergy();
741
742 if (energy_usage == -1)
744
745 if (!CheckWetness())
746 return false;
747
748 if (gathered_energy <= 0 && energy_usage <= 0) //empty power source
749 return false;
750
751 int cycle_limit = 500; // Sanity check to definitely avoid infinite cycles
752
753 while (gathered_energy < energy_usage) // Look for energy source if we don't have enough stored energy
754 {
755 // Safetycheck!
756 if (cycle_limit > 0)
757 cycle_limit--;
758 else
759 {
760 DPrint("Energy Manager ERROR: The 'cycle_limit' safety break had to be activated to prevent possible game freeze. Dumping debug information...");
761 //Print(m_ThisEntityAI);
762 //Print(this);
763 //Print(energy_source);
764
765 if (energy_source.GetCompEM())
766 {
767 //Print(energy_source.GetCompEM());
768 }
769
770 //Print(gathered_energy);
771 //Print(energy_usage);
772
773 //Print(m_ThisEntityAI.GetPosition());
774
775 if (energy_source)
776 {
777 //Print(energy_source.GetPosition());
778 }
779
780 //Print("End of the 'cycle_limit' safety break ^ ");
781
782 return false;
783 }
784 // ^ Safetycheck!
785
786 if (energy_source && energy_source != m_ThisEntityAI && !energy_source.IsRuined() && energy_source.GetCompEM() && energy_source.GetCompEM().IsSwitchedOn() && energy_source.GetCompEM().CheckWetness())
787 {
788 gathered_energy = gathered_energy + energy_source.GetCompEM().GetEnergy();
789 energy_source = energy_source.GetCompEM().GetEnergySource();
790 }
791 else
792 {
793 // No power source, no energy.
794 return false;
795 }
796 }
797
798 // Enough energy was found
799 return true;
800 }
float GetEnergyUsage()
Energy manager: Returns the number of energy this device needs to run itself (See its config >> energ...
bool CheckWetness()
Energy manager: Checks if this device is being stopped from working by its wetness level....
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
proto native CGame GetGame()
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...

References CheckWetness(), DPrint(), GetEnergy(), GetEnergySource(), GetEnergyUsage(), GetGame(), m_CanWork, and Component::m_ThisEntityAI.

Referenced by UpdateCanWork().

◆ CheckWetness()

bool ComponentEnergyManager::CheckWetness ( )
inlineprotected

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 803 of file ComponentEnergyManager.c.

804 {
805 return (m_ThisEntityAI.GetWet() <= 1 - m_WetnessExposure);
806 }

References Component::m_ThisEntityAI, and m_WetnessExposure.

Referenced by CanWork(), and DeviceUpdate().

◆ ClearLastUpdateTime()

void ComponentEnergyManager::ClearLastUpdateTime ( )
inlineprotected

Definition at line 1635 of file ComponentEnergyManager.c.

1636 {
1637 m_LastUpdateTime = 0;
1638 }

References m_LastUpdateTime.

Referenced by DeviceUpdate().

◆ ConsumeEnergy()

bool ComponentEnergyManager::ConsumeEnergy ( float amount)
inlineprotected

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 852 of file ComponentEnergyManager.c.

853 {
854 return FindAndConsumeEnergy(m_ThisEntityAI, amount, true);
855 }
bool FindAndConsumeEnergy(EntityAI original_caller, float amount, bool ignore_switch_state=false)

References FindAndConsumeEnergy(), and Component::m_ThisEntityAI.

Referenced by DeviceUpdate().

◆ DebugUpdate()

void ComponentEnergyManager::DebugUpdate ( )
inlineprotected

Definition at line 107 of file ComponentEnergyManager.c.

108 {
109 if (GetDebugPlugs())
110 {
111 if (GetGame().IsMultiplayer() && GetGame().IsServer())
112 {
113 if (m_DebugUpdate)
114 m_DebugUpdate.Stop();
115
116 return;
117 }
118
120 {
121 m_DebugPlugArrow.Destroy();
123 }
124
125 if (GetEnergySource())
126 {
127 vector from = GetEnergySource().GetPosition() + "0 0.1 0";
128 vector to = m_ThisEntityAI.GetPosition() + "0 0.1 0";
129
130 //No need to draw an arrow in this situation as it would not be visible
131 if (vector.DistanceSq(from, to) == 0)
132 return;
133
134 if (m_ThisEntityAI.GetType() == "BarbedWire") // Special case for debugging of electric fences. Temporal code until offsets in fences are fixed.
135 {
136 EntityAI BBB = m_ThisEntityAI.GetHierarchyParent();
137
138 if (BBB && BBB.GetType() == "Fence")
139 to = to + "0 -1.3 0";
140 }
141
143 }
144 }
145 }
Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, float flags=0)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.

References vector::DistanceSq(), DrawArrow(), GetDebugPlugs(), GetEnergySource(), GetGame(), m_DebugPlugArrow, m_DebugUpdate, and Component::m_ThisEntityAI.

◆ DeviceUpdate()

void ComponentEnergyManager::DeviceUpdate ( )
inlineprotected

Definition at line 1651 of file ComponentEnergyManager.c.

1652 {
1653 /*
1654 vector pos = m_ThisEntityAI.GetPosition();
1655 string debug_message = "Object " + m_ThisEntityAI.GetType() + " | Energy: " + GetEnergy() + " | IsAtReach: " + (IsEnergySourceAtReach(pos)).ToString();
1656 Print(debug_message);
1657 */
1658
1659 if (!m_IsPassiveDevice)
1660 {
1661 // 'm_ThisEntityAI' and 'this' must be checked because this method is caled from a timer
1662 if (m_ThisEntityAI && this && IsSwitchedOn() && !m_ThisEntityAI.IsRuined() && CheckWetness() && m_CanWork && !GetGame().IsMissionMainMenu())
1663 {
1664 bool was_powered = IsWorking();
1666 // Make sure to use only as much % of energy as needed since this function can be called at random.
1667
1668 if (m_LastUpdateTime == 0)
1669 {
1672 }
1673 else
1674 {
1677 consumed_energy_coef = time / 1000;
1678 }
1679
1680 if (consumed_energy_coef > 0) // Prevents calling of OnWork events when no energy is consumed
1681 {
1684 bool has_consumed_enough = true;
1685
1686 if (GetGame().IsServer() || !GetGame().IsMultiplayer()) // single player or server side multiplayer
1688
1690
1692 {
1693 if (!was_powered)
1694 {
1695 m_CanStopWork = true;
1697 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnWorkStart", NULL, 0);
1698 UpdateCanWork();
1699 }
1700
1702 }
1703 else
1704 {
1705 if (was_powered)
1706 {
1707 if (m_CanStopWork)
1708 {
1709 m_CanStopWork = false;
1711 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnWorkStop", NULL, 0); // This event is called only once when the device STOPS being powered
1712 UpdateCanWork();
1713
1714 if (m_AutoSwitchOff)
1715 SwitchOff();
1716 }
1717 }
1718
1719 StopUpdates();
1720 }
1721 }
1722 else
1724 }
1725 else if (this && m_ThisEntityAI)
1726 {
1727 SetPowered(false);
1728 StopUpdates();
1729
1730 if (m_CanStopWork)
1731 {
1732 m_CanStopWork = false;
1734 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnWorkStop", NULL, 0); // This event is called only once when the device STOPS being powered
1735 UpdateCanWork();
1736
1737 if (m_AutoSwitchOff)
1738 SwitchOff();
1739 }
1740 }
1741 }
1742 }
bool IsWorking()
Energy manager: Returns true if this device is working right now.
void WakeUpWholeBranch(EntityAI original_caller)
void OnWork(float consumed_energy)
void SwitchOff()
Energy manager: Switches OFF the device.
bool ConsumeEnergy(float amount)
Energy manager: Consumes the given amount of energy. If there is not enough of stored energy in this ...

References CheckWetness(), ClearLastUpdateTime(), ConsumeEnergy(), GetCurrentUpdateTime(), GetEnergyUsage(), GetGame(), IsSwitchedOn(), IsWorking(), m_AutoSwitchOff, m_CanStopWork, m_CanWork, m_IsPassiveDevice, m_LastUpdateTime, Component::m_ThisEntityAI, OnWork(), RememberLastUpdateTime(), SetPowered(), StopUpdates(), SwitchOff(), UpdateCanWork(), and WakeUpWholeBranch().

Referenced by Entity::OnVariablesSynchronized(), SetPassiveState(), SwitchOff(), and SwitchOn().

◆ DrawArrow()

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

Definition at line 147 of file ComponentEnergyManager.c.

148 {
149 vector dir = to - from;
150 dir.Normalize();
151 vector dir1 = dir * size;
152 size = size * 0.5;
153
154 vector dir2 = dir.Perpend() * size;
155
156 vector pts[5];
157 pts[0] = from;
158 pts[1] = to;
159 pts[2] = to - dir1 - dir2;
160 pts[3] = to - dir1 + dir2;
161 pts[4] = to;
162
163 return Shape.CreateLines(color, flags, pts, 5);
164 }
proto float Normalize()
Normalizes vector. Returns length.
vector Perpend()
Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector ...
Definition EnConvert.c:209
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead

References vector::Normalize(), vector::Perpend(), and Shape.

Referenced by DebugUpdate().

◆ Event_OnAwake()

override void ComponentEnergyManager::Event_OnAwake ( )
inlineprotected

Definition at line 172 of file ComponentEnergyManager.c.

173 {
174 string cfg_item = "CfgVehicles " + m_ThisEntityAI.GetType();
175 string cfg_energy_manager = cfg_item + " EnergyManager ";
176
177 // Read all config parameters
178 m_EnergyUsage = GetGame().ConfigGetFloat(cfg_energy_manager + "energyUsagePerSecond");
179 bool switch_on = GetGame().ConfigGetFloat(cfg_energy_manager + "switchOnAtSpawn");
180 m_AutoSwitchOff = GetGame().ConfigGetFloat(cfg_energy_manager + "autoSwitchOff");
181 m_HasElectricityIcon = GetGame().ConfigGetFloat(cfg_energy_manager + "hasIcon");
182 m_AutoSwitchOffWhenInCargo = GetGame().ConfigGetFloat(cfg_energy_manager + "autoSwitchOffWhenInCargo");
183
184 m_EnergyAtSpawn = GetGame().ConfigGetFloat(cfg_energy_manager + "energyAtSpawn");
186 m_EnergyStorageMax = GetGame().ConfigGetFloat(cfg_energy_manager + "energyStorageMax");
187 m_ReduceMaxEnergyByDamageCoef = GetGame().ConfigGetFloat(cfg_energy_manager + "reduceMaxEnergyByDamageCoef");
188 m_SocketsCount = GetGame().ConfigGetFloat(cfg_energy_manager + "powerSocketsCount");
189
190 m_IsPassiveDevice = GetGame().ConfigGetFloat(cfg_energy_manager + "isPassiveDevice");
191 m_CordLength = GetGame().ConfigGetFloat(cfg_energy_manager + "cordLength");
192 m_PlugType = GetGame().ConfigGetFloat(cfg_energy_manager + "plugType");
193
194 m_AttachmentActionType = GetGame().ConfigGetFloat(cfg_energy_manager + "attachmentAction");
195 m_WetnessExposure = GetGame().ConfigGetFloat(cfg_energy_manager + "wetnessExposure");
196
197 float update_interval = GetGame().ConfigGetFloat(cfg_energy_manager + "updateInterval");
198
199 m_ConvertEnergyToQuantity = GetGame().ConfigGetFloat(cfg_energy_manager + "convertEnergyToQuantity");
200
201
202 // Check if energy->quantity converion is configured properly
203 float cfg_max_quantity = GetGame().ConfigGetFloat(cfg_item + " varQuantityMax");
204
206 {
207 string error = "Error! Item " + m_ThisEntityAI.GetType() + " has invalid configuration of the energy->quantity conversion feature. To fix this, add 'varQuantityMax' parameter with value higher than 0 to the item's config. Then make sure to re-build the PBO containing this item!";
208 Error(error);
210 }
211 else
212 {
214 {
217
218 m_UpdateQuantityTimer.Run(0.3, this, "OnEnergyAdded", NULL, false);
219 }
220 }
221
222 // Set update interval
223 if (update_interval <= 0)
225
227
228 // If energyAtSpawn is present, then use its value for energyStorageMax if that cfg param is not present (for convenience's sake)
229 string cfg_check_energy_limit = cfg_energy_manager + "energyStorageMax";
230
231 if (!GetGame().ConfigIsExisting(cfg_check_energy_limit) && m_Energy > 0)
233
234 // Fill m_CompatiblePlugTypes
235 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
236
237 if (GetGame().ConfigIsExisting(cfg_check_plug_types))
238 {
241 }
242
243 if (GetSocketsCount() > 0)
245
246 if (m_CordLength < 0)
247 {
248 m_CordLength = 0;
249 string error_message_cord = "Warning! " + m_ThisEntityAI.GetType() + ": config parameter 'cordLength' is less than 0! Cord length should not be negative!";
251 }
252
253 if (GetSocketsCount() > 0)
254 {
256 // Prepare the m_DeviceByPlugSelection
257 string cfg_animation_sources = "cfgVehicles " + m_ThisEntityAI.GetType() + " " + "AnimationSources ";
258 int animation_sources_count = GetGame().ConfigGetChildrenCount(cfg_animation_sources);
259
261 {
262 // TO DO: This could be optimized so not all selections on item are considered as plug/socket selections.
263 string selection;
264 GetGame().ConfigGetChildName(cfg_animation_sources, i_selection, selection);
265 m_DeviceByPlugSelection.Set(selection, NULL);
266 }
267 }
268
269
270 // Prepare sockets
272 {
274 string error_message_sockets = "Error! " + m_ThisEntityAI.GetType() + ": config parameter 'powerSocketsCount' is higher than the current limit (" + MAX_SOCKETS_COUNT.ToString() + ")! Raise the limit (constant MAX_SOCKETS_COUNT) or decrease the powerSocketsCount parameter for this device!";
276 }
277
278 m_Sockets[MAX_SOCKETS_COUNT]; // Handles selections for plugs in the sockets. Feel free to change the limit if needed.
279
280 GetGame().ConfigGetText(cfg_energy_manager + "cordTextureFile", m_CordTextureFile);
281
282 if (switch_on)
283 SwitchOn();
284
285 for (int i = 0; i <= GetSocketsCount(); ++i)
286 m_ThisEntityAI.HideSelection(SOCKET_ + i.ToString() + _PLUGGED);
287
288 // Show/hide inventory sockets
290 if (GetSocketsCount() > 0 && IsPlugCompatible(PLUG_COMMON_APPLIANCE) && m_ThisEntityAI.GetType() != "MetalWire") // metal wire filter is hopefully temporal.
292
294
295 m_ThisEntityAI.HideSelection(SEL_CORD_PLUGGED);
296
297
298#ifdef DIAG_DEVELOPER
299 GetGame().m_EnergyManagerArray.Insert(this);
300#endif
301 }
const int PLUG_COMMON_APPLIANCE
Definition _constants.c:25
void SwitchOn()
Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
void SetUpdateInterval(float value)
Energy manager: Sets the interval of the OnWork(...) calls. Changing this value does not change the r...
ref map< string, EntityAI > m_DeviceByPlugSelection
ref array< EntityAI > m_PluggedDevices
EntityAI m_Sockets[MAX_SOCKETS_COUNT]
static const string SEL_CORD_PLUGGED
int GetSocketsCount()
Energy manager: Returns the count of power sockets (whenever used or not)
bool HasEnoughStoredEnergy()
Energy manager: Returns true if this device has enough of stored energy for its own use.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
array< int > TIntArray
Definition EnScript.c:668
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References _PLUGGED, CALL_CATEGORY_SYSTEM, DEFAULT_UPDATE_INTERVAL, DPrint(), Error(), GetGame(), GetSocketsCount(), HasEnoughStoredEnergy(), IsPlugCompatible(), m_AttachmentActionType, m_AutoSwitchOff, m_AutoSwitchOffWhenInCargo, m_CanWork, m_CompatiblePlugTypes, m_ConvertEnergyToQuantity, m_CordLength, m_CordTextureFile, m_DeviceByPlugSelection, m_Energy, m_EnergyAtSpawn, m_EnergyStorageMax, m_EnergyUsage, m_HasElectricityIcon, m_IsPassiveDevice, m_PluggedDevices, m_PlugType, m_ReduceMaxEnergyByDamageCoef, m_ShowSocketsInInventory, m_Sockets, m_SocketsCount, Component::m_ThisEntityAI, m_UpdateQuantityTimer, m_WetnessExposure, MAX_SOCKETS_COUNT, PLUG_COMMON_APPLIANCE, SEL_CORD_PLUGGED, SetUpdateInterval(), SOCKET_, and SwitchOn().

◆ Event_OnInit()

override void ComponentEnergyManager::Event_OnInit ( )
inlineprotected

Definition at line 100 of file ComponentEnergyManager.c.

101 {
102 m_ThisEntityAI.m_EM = this;
103 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnInitEnergy", NULL, 0);
104 }

References GetGame(), and Component::m_ThisEntityAI.

◆ FindAndConsumeEnergy()

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

Definition at line 1594 of file ComponentEnergyManager.c.

1595 {
1596 if ((ignore_switch_state || IsSwitchedOn()) && !m_ThisEntityAI.IsRuined())
1597 {
1598 float available_energy = AddEnergy(-amount);
1599
1600 if (available_energy < 0 && IsPlugged())
1601 {
1602 // This devices does not has enough of stored energy, therefore it will take it from its power source (which can be a chain of cable reels)
1604
1605 if (next_power_source && next_power_source != original_caller) // Prevents infinite loop if the power source is the original caller itself
1606 return next_power_source.GetCompEM().FindAndConsumeEnergy(original_caller, -available_energy);
1607 }
1608
1609 if (available_energy >= 0)
1610 return true;
1611
1612 return false;
1613 }
1614 else
1615 return false;
1616 }
float AddEnergy(float added_energy)
Energy manager: Adds energy to this device and clamps it within its min/max storage limits....
bool IsPlugged()
Energy manager: Returns true if this device is plugged into some other device (even if they are OFF o...

References AddEnergy(), GetEnergySource(), IsPlugged(), IsSwitchedOn(), and Component::m_ThisEntityAI.

Referenced by ConsumeEnergy().

◆ GetAttachmentAction()

int ComponentEnergyManager::GetAttachmentAction ( )
inlineprotected

Definition at line 1048 of file ComponentEnergyManager.c.

1049 {
1051 }

References m_AttachmentActionType.

Referenced by OnAttachmentAdded(), and OnAttachmentRemoved().

◆ GetCompatiblePlugTypes()

void ComponentEnergyManager::GetCompatiblePlugTypes ( out TIntArray IDs)
inlineprotected

Definition at line 593 of file ComponentEnergyManager.c.

594 {
596 }

References m_CompatiblePlugTypes.

◆ GetCompType()

override int ComponentEnergyManager::GetCompType ( )
inlineprotected

Definition at line 304 of file ComponentEnergyManager.c.

305 {
307 }
const int COMP_TYPE_ENERGY_MANAGER
Definition Component.c:9

References COMP_TYPE_ENERGY_MANAGER.

◆ GetCordLength()

float ComponentEnergyManager::GetCordLength ( )
inlineprotected

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

Definition at line 1216 of file ComponentEnergyManager.c.

1217 {
1218 return m_CordLength;
1219 }

References m_CordLength.

Referenced by IsEnergySourceAtReach().

◆ GetCordTextureFile()

string ComponentEnergyManager::GetCordTextureFile ( )
inlineprotected

Energy manager: Returns path to the cord texture file.

Definition at line 1252 of file ComponentEnergyManager.c.

1253 {
1254 return m_CordTextureFile;
1255 }

References m_CordTextureFile.

◆ GetCurrentUpdateTime()

float ComponentEnergyManager::GetCurrentUpdateTime ( )
inlineprotected

Definition at line 1645 of file ComponentEnergyManager.c.

1646 {
1647 return GetGame().GetTime();
1648 }

References GetGame().

Referenced by DeviceUpdate(), and RememberLastUpdateTime().

◆ GetDebugPlugs()

bool ComponentEnergyManager::GetDebugPlugs ( )
inlineprotected

Definition at line 345 of file ComponentEnergyManager.c.

346 {
347 return m_DebugPlugs;
348 }

References m_DebugPlugs.

Referenced by DebugUpdate().

◆ GetDeviceBySocketID()

EntityAI ComponentEnergyManager::GetDeviceBySocketID ( int id)
inlineprotected

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

Definition at line 1228 of file ComponentEnergyManager.c.

1229 {
1230 return m_Sockets[id];
1231 }

References m_Sockets.

Referenced by HasFreeSocket(), PlugCordIntoSocket(), UnplugCordFromSocket(), and UpdateSelections().

◆ GetEnergy()

float ComponentEnergyManager::GetEnergy ( )
inlineprotected

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

Definition at line 1144 of file ComponentEnergyManager.c.

1145 {
1146 return m_Energy;
1147 }

References m_Energy.

Referenced by AddEnergy(), CanWork(), HasEnoughStoredEnergy(), and Entity::OnStoreSave().

◆ GetEnergy0To1()

float ComponentEnergyManager::GetEnergy0To1 ( )
inlineprotected

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

Definition at line 1111 of file ComponentEnergyManager.c.

1112 {
1113 if (m_EnergyStorageMax > 0)
1115
1116 return 0;
1117 }

References m_Energy, and m_EnergyStorageMax.

◆ GetEnergy0To100()

int ComponentEnergyManager::GetEnergy0To100 ( )
inlineprotected

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

Definition at line 1099 of file ComponentEnergyManager.c.

1100 {
1101 if (m_EnergyStorageMax > 0)
1102 {
1103 int coef = Math.Round(m_Energy / m_EnergyStorageMax * 100);
1104 return coef;
1105 }
1106
1107 return 0;
1108 }
static proto float Round(float f)
Returns mathematical round of value.

References m_Energy, m_EnergyStorageMax, and Math::Round().

◆ GetEnergyAtSpawn()

float ComponentEnergyManager::GetEnergyAtSpawn ( )
inlineprotected

Definition at line 1210 of file ComponentEnergyManager.c.

1211 {
1212 return m_EnergyAtSpawn;
1213 }

References m_EnergyAtSpawn.

◆ GetEnergyMax()

float ComponentEnergyManager::GetEnergyMax ( )
inlineprotected

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 1182 of file ComponentEnergyManager.c.

1183 {
1184 float max_health = 0;
1185
1186 if (m_ThisEntityAI.HasDamageSystem())
1187 max_health = m_ThisEntityAI.GetMaxHealth("", "");
1188 //else if ( m_ReduceMaxEnergyByDamageCoef != 0 )
1189 // Error("[ERROR] ReduceMaxEnergyByDamageCoef is setup but " + m_ThisEntityAI.GetType() + " does not have a Damage System");
1190
1192 return GetEnergyMaxPristine();
1193
1194 float health = 100;
1195
1196 if (GetGame().IsServer() || !GetGame().IsMultiplayer()) // TO DO: Remove this IF when method GetHealth can be called on client!
1197 health = m_ThisEntityAI.GetHealth("", "");
1198
1199 float damage_coef = 1 - (health / max_health);
1200
1202 }
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...

References GetEnergyMaxPristine(), GetGame(), m_ReduceMaxEnergyByDamageCoef, and Component::m_ThisEntityAI.

Referenced by AddEnergy(), and SetEnergy0To1().

◆ GetEnergyMaxPristine()

float ComponentEnergyManager::GetEnergyMaxPristine ( )
inlineprotected

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

Definition at line 1205 of file ComponentEnergyManager.c.

1206 {
1207 return m_EnergyStorageMax;
1208 }

References m_EnergyStorageMax.

Referenced by GetEnergyMax().

◆ GetEnergySource()

EntityAI ComponentEnergyManager::GetEnergySource ( )
inlineprotected

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

Definition at line 1222 of file ComponentEnergyManager.c.

1223 {
1224 return m_EnergySource;
1225 }

References m_EnergySource.

Referenced by CanWork(), DebugUpdate(), FindAndConsumeEnergy(), IsEnergySourceAtReach(), OnAttachmentRemoved(), Entity::OnStoreSave(), UnplugThis(), and UpdateSelections().

◆ GetEnergySourceNetworkIDHigh()

int ComponentEnergyManager::GetEnergySourceNetworkIDHigh ( )
inlineprotected

Definition at line 1084 of file ComponentEnergyManager.c.

1085 {
1087 }

References m_EnergySourceNetworkIDHigh.

Referenced by Entity::OnVariablesSynchronized().

◆ GetEnergySourceNetworkIDLow()

int ComponentEnergyManager::GetEnergySourceNetworkIDLow ( )
inlineprotected

Definition at line 1078 of file ComponentEnergyManager.c.

1079 {
1081 }

References m_EnergySourceNetworkIDLow.

Referenced by Entity::OnVariablesSynchronized().

◆ GetEnergySourceStorageIDb1()

int ComponentEnergyManager::GetEnergySourceStorageIDb1 ( )
inlineprotected

Definition at line 1054 of file ComponentEnergyManager.c.

1055 {
1057 }

References m_EnergySourceStorageIDb1.

Referenced by Entity::EEOnAfterLoad().

◆ GetEnergySourceStorageIDb2()

int ComponentEnergyManager::GetEnergySourceStorageIDb2 ( )
inlineprotected

Definition at line 1060 of file ComponentEnergyManager.c.

1061 {
1063 }

References m_EnergySourceStorageIDb2.

Referenced by Entity::EEOnAfterLoad().

◆ GetEnergySourceStorageIDb3()

int ComponentEnergyManager::GetEnergySourceStorageIDb3 ( )
inlineprotected

Definition at line 1066 of file ComponentEnergyManager.c.

1067 {
1069 }

References m_EnergySourceStorageIDb3.

Referenced by Entity::EEOnAfterLoad().

◆ GetEnergySourceStorageIDb4()

int ComponentEnergyManager::GetEnergySourceStorageIDb4 ( )
inlineprotected

Definition at line 1072 of file ComponentEnergyManager.c.

1073 {
1075 }

References m_EnergySourceStorageIDb4.

Referenced by Entity::EEOnAfterLoad().

◆ GetEnergyUsage()

float ComponentEnergyManager::GetEnergyUsage ( )
inlineprotected

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

Definition at line 1138 of file ComponentEnergyManager.c.

1139 {
1140 return m_EnergyUsage;
1141 }

References m_EnergyUsage.

Referenced by CanWork(), DeviceUpdate(), HasEnoughStoredEnergy(), and SetEnergy().

◆ GetMySocketID()

int ComponentEnergyManager::GetMySocketID ( )
inlineprotected

Definition at line 1619 of file ComponentEnergyManager.c.

1620 {
1621 return m_MySocketID;
1622 }

References m_MySocketID.

◆ GetPluggedDevice()

EntityAI ComponentEnergyManager::GetPluggedDevice ( )
inlineprotected

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 1243 of file ComponentEnergyManager.c.

1244 {
1245 if (GetPluggedDevicesCount() > 0)
1246 return GetPluggedDevices().Get(0);
1247
1248 return NULL;
1249 }
int GetPluggedDevicesCount()
Energy manager: Returns the number of devices plugged into this one.
array< EntityAI > GetPluggedDevices()
Energy manager: Returns an array of devices which are plugged into this one.

References GetPluggedDevices(), and GetPluggedDevicesCount().

◆ GetPluggedDevices()

array< EntityAI > ComponentEnergyManager::GetPluggedDevices ( )
inlineprotected

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

Definition at line 1258 of file ComponentEnergyManager.c.

1259 {
1260 return m_PluggedDevices;
1261 }

References m_PluggedDevices.

Referenced by GetPluggedDevice(), GetPluggedDevicesCount(), GetPoweredDevices(), InteractBranch(), IsSelectionAPlug(), PlugInDevice(), UnplugAllDevices(), UnplugDevice(), and WakeUpWholeBranch().

◆ GetPluggedDevicesCount()

int ComponentEnergyManager::GetPluggedDevicesCount ( )
inlineprotected

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

Definition at line 1090 of file ComponentEnergyManager.c.

1091 {
1092 if (GetPluggedDevices())
1093 return GetPluggedDevices().Count();
1094
1095 return 0;
1096 }

References GetPluggedDevices().

Referenced by GetPluggedDevice(), GetPoweredDevices(), HasFreeSocket(), UnplugAllDevices(), and UnplugDevice().

◆ GetPlugOwner()

EntityAI ComponentEnergyManager::GetPlugOwner ( string plug_selection_name)
inlineprotected

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

Definition at line 1234 of file ComponentEnergyManager.c.

1235 {
1238
1239 return NULL;
1240 }

References m_DeviceByPlugSelection.

◆ GetPlugType()

int ComponentEnergyManager::GetPlugType ( )
inlineprotected

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

Definition at line 1042 of file ComponentEnergyManager.c.

1043 {
1044 return m_PlugType;
1045 }

References m_PlugType.

◆ GetPoweredDevices()

array< EntityAI > ComponentEnergyManager::GetPoweredDevices ( )
inlineprotected

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

Definition at line 1264 of file ComponentEnergyManager.c.

1265 {
1268 for (int i = 0; i < plugged_devices_c; ++i)
1269 {
1271 if (IsSwitchedOn())
1272 return_array.Insert(device);
1273 }
1274
1275 return return_array;
1276 }

References GetPluggedDevices(), GetPluggedDevicesCount(), and IsSwitchedOn().

◆ GetPreviousSwitchState()

bool ComponentEnergyManager::GetPreviousSwitchState ( )
inlineprotected

Definition at line 818 of file ComponentEnergyManager.c.

819 {
821 }

References m_IsSwichedOnPreviousState.

Referenced by Entity::OnVariablesSynchronized().

◆ GetRestorePlugState()

bool ComponentEnergyManager::GetRestorePlugState ( )
inlineprotected

Definition at line 703 of file ComponentEnergyManager.c.

704 {
705 return m_RestorePlugState;
706 }

References m_RestorePlugState.

Referenced by Entity::EEOnAfterLoad().

◆ GetSocketsCount()

int ComponentEnergyManager::GetSocketsCount ( )
inlineprotected

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

Definition at line 1036 of file ComponentEnergyManager.c.

1037 {
1038 return m_SocketsCount;
1039 }

References m_SocketsCount.

Referenced by Event_OnAwake(), HasFreeSocket(), InteractBranch(), IsSelectionAPlug(), PlugCordIntoSocket(), UpdateSelections(), and WakeUpWholeBranch().

◆ GetThisEntityAI()

EntityAI ComponentEnergyManager::GetThisEntityAI ( )
inlineprotected

Definition at line 166 of file ComponentEnergyManager.c.

167 {
168 return m_ThisEntityAI;
169 }

References Component::m_ThisEntityAI.

◆ GetUpdateInterval()

float ComponentEnergyManager::GetUpdateInterval ( )
inlineprotected

Energy manager: Returns the update interval of this device.

Definition at line 1120 of file ComponentEnergyManager.c.

1121 {
1122#ifdef DIAG_DEVELOPER
1123 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_CONSUMPTION) || (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_RECHARGE)))
1124 {
1125 return 1;//when modifying time accel, we might want to see things happen when they should, instead of waiting for the next tick
1126 }
1127#endif
1128 return m_UpdateInterval;
1129 }

References m_UpdateInterval.

Referenced by StartUpdates().

◆ GetWetnessExposure()

float ComponentEnergyManager::GetWetnessExposure ( )
inlineprotected

Returns wetness exposure value defined in config.

Definition at line 1132 of file ComponentEnergyManager.c.

1133 {
1134 return m_WetnessExposure;
1135 }

References m_WetnessExposure.

◆ HandleMoveInsideCargo()

void ComponentEnergyManager::HandleMoveInsideCargo ( EntityAI container)
inlineprotected

Definition at line 687 of file ComponentEnergyManager.c.

688 {
690 {
691 if (IsSwitchedOn())
692 SwitchOff();
693 }
694 }

References IsSwitchedOn(), m_AutoSwitchOffWhenInCargo, and SwitchOff().

Referenced by Entity::OnMovedInsideCargo().

◆ HasConversionOfEnergyToQuantity()

bool ComponentEnergyManager::HasConversionOfEnergyToQuantity ( )
inlineprotected

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

Definition at line 956 of file ComponentEnergyManager.c.

957 {
959 }

References m_ConvertEnergyToQuantity.

◆ HasElectricityIcon()

bool ComponentEnergyManager::HasElectricityIcon ( )
inlineprotected

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

Definition at line 950 of file ComponentEnergyManager.c.

951 {
953 }

References m_HasElectricityIcon.

◆ HasEnoughStoredEnergy()

bool ComponentEnergyManager::HasEnoughStoredEnergy ( )
inlineprotected

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

Definition at line 864 of file ComponentEnergyManager.c.

865 {
866 if (GetEnergy() > GetEnergyUsage())
867 return true;
868
869 return false;
870 }

References GetEnergy(), and GetEnergyUsage().

Referenced by Event_OnAwake().

◆ HasFreeSocket()

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

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 873 of file ComponentEnergyManager.c.

874 {
875 if (socket_id == -1)
876 {
879
881 return true;
882
883 return false;
884 }
885 else
886 {
888
889 if (device)
890 return false;
891 else
892 return true;
893 }
894 }
EntityAI GetDeviceBySocketID(int id)
Energy manager: Returns the device which is plugged into the given socket ID.

References GetDeviceBySocketID(), GetPluggedDevicesCount(), and GetSocketsCount().

Referenced by CanReceivePlugFrom().

◆ HasVisibleSocketsInInventory()

bool ComponentEnergyManager::HasVisibleSocketsInInventory ( )
inlineprotected

Definition at line 1010 of file ComponentEnergyManager.c.

1011 {
1013 }

References m_ShowSocketsInInventory.

◆ InteractBranch()

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

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 1416 of file ComponentEnergyManager.c.

1417 {
1419 if (GetSocketsCount() > 0)
1420 {
1422
1423 foreach (EntityAI device : devices)
1424 {
1425 if (device != originalCaller) // originalCaller check here prevents infinite loops
1426 device.GetCompEM().InteractBranch(originalCaller, player, system);
1427 }
1428 }
1429 }
void OnInteractBranch(EntityAI originalCaller, Man player, int system)
Called when the player is interacting with an item containing this energy component,...

References GetPluggedDevices(), GetSocketsCount(), and OnInteractBranch().

Referenced by PlugInDevice().

◆ IsCordFolded()

bool ComponentEnergyManager::IsCordFolded ( )
inlineprotected

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

Definition at line 830 of file ComponentEnergyManager.c.

831 {
832 if (IsPlugged())
833 return false;
834
835 return true;
836 }

References IsPlugged().

◆ IsEnergySourceAtReach()

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

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 void Print(void var)
Prints content of variable to console/log.

Definition at line 977 of file ComponentEnergyManager.c.

978 {
979 if (!IsPlugged() && override_source_position == "-1 -1 -1")
980 return false;
981
982 if (GetCordLength() == 0) // 0 is an exception, which means infinitely long cable.
983 return true;
984
986 float distance;
987
988 if (override_source_position == "-1 -1 -1")
989 {
991
992 if (!energy_source)
993 return false;
994
995 source_pos = energy_source.GetPosition();
997 }
998 else
999 {
1002 }
1003
1005 return false;
1006 else
1007 return true;
1008 }
float GetCordLength()
Energy manager: Returns the length of the virtual power cord.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

References vector::Distance(), GetCordLength(), GetEnergySource(), and IsPlugged().

Referenced by UpdatePlugState().

◆ IsPassive()

bool ComponentEnergyManager::IsPassive ( )
inlineprotected

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

Definition at line 839 of file ComponentEnergyManager.c.

840 {
841 return m_IsPassiveDevice;
842 }

References m_IsPassiveDevice.

Referenced by CanSwitchOff(), and Entity::OnStoreSave().

◆ IsPlugCompatible()

bool ComponentEnergyManager::IsPlugCompatible ( int plug_ID)
inlineprotected

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

Definition at line 897 of file ComponentEnergyManager.c.

898 {
899 if (plug_ID == PLUG_UNDEFINED)
900 {
901 return true; // When plugType is undefined in config then make it compatible.
902 }
903
905 {
906 for (int i = 0; i < m_CompatiblePlugTypes.Count(); i++)
907 {
909
911 return true;
912 }
913 }
914 else
915 {
916 // Since the config parameter compatiblePlugTypes is not present, then accept all plugs for simplicity's sake
917 return true;
918 }
919
920 return false;
921 }
const int PLUG_UNDEFINED
Definition _constants.c:23

References m_CompatiblePlugTypes, and PLUG_UNDEFINED.

Referenced by CanReceivePlugFrom(), and Event_OnAwake().

◆ IsPlugged()

bool ComponentEnergyManager::IsPlugged ( )
inlineprotected

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 845 of file ComponentEnergyManager.c.

846 {
847 return m_IsPlugged;
848 }

References m_IsPlugged.

Referenced by FindAndConsumeEnergy(), IsCordFolded(), IsEnergySourceAtReach(), and Entity::OnStoreSave().

◆ IsSelectionAPlug()

bool ComponentEnergyManager::IsSelectionAPlug ( string selection_to_test)
inlineprotected

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

Definition at line 1016 of file ComponentEnergyManager.c.

1017 {
1018 if (GetPluggedDevices())
1019 {
1021
1022 for (int i = socket_count; i >= 0; --i)
1023 {
1024 string real_selection = SOCKET_ + i.ToString() + _PLUGGED;
1025
1027 return true;
1028 }
1029 }
1030
1031 return false;
1032 }

References _PLUGGED, GetPluggedDevices(), GetSocketsCount(), and SOCKET_.

◆ IsSwitchedOn()

bool ComponentEnergyManager::IsSwitchedOn ( )
inlineprotected

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 824 of file ComponentEnergyManager.c.

825 {
826 return m_IsSwichedOn;
827 }

References m_IsSwichedOn.

Referenced by CanSwitchOff(), CanSwitchOn(), DeviceUpdate(), FindAndConsumeEnergy(), GetPoweredDevices(), HandleMoveInsideCargo(), Entity::OnStoreSave(), and Entity::OnVariablesSynchronized().

◆ IsWorking()

bool ComponentEnergyManager::IsWorking ( )
inlineprotected

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

Definition at line 858 of file ComponentEnergyManager.c.

859 {
860 return m_IsWorking;
861 }

References m_IsWorking.

Referenced by DeviceUpdate(), Entity::IsIgnited(), and SwitchOff().

◆ OnAttachmentAdded()

void ComponentEnergyManager::OnAttachmentAdded ( EntityAI elec_device)
inlineprotected

Definition at line 1340 of file ComponentEnergyManager.c.

1341 {
1343
1345 {
1346 if (elec_device.GetCompEM().CanReceivePlugFrom(m_ThisEntityAI))
1348 }
1350 elec_device.GetCompEM().PlugThisInto(m_ThisEntityAI);
1351 }
const int PLUG_ATTACHMENTS_INTO_THIS
Definition _constants.c:36
const int PLUG_THIS_INTO_ATTACHMENT
Definition _constants.c:35
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 s...

References GetAttachmentAction(), Component::m_ThisEntityAI, PLUG_ATTACHMENTS_INTO_THIS, PLUG_THIS_INTO_ATTACHMENT, and PlugThisInto().

Referenced by Entity::EEItemAttached().

◆ OnAttachmentRemoved()

void ComponentEnergyManager::OnAttachmentRemoved ( EntityAI elec_device)
inlineprotected

Definition at line 1354 of file ComponentEnergyManager.c.

1355 {
1357
1359 {
1361 UnplugThis();
1362 }
1364 elec_device.GetCompEM().UnplugThis();
1365 }
void UnplugThis()
Energy manager: Unplugs this device from its power source.

References GetAttachmentAction(), GetEnergySource(), PLUG_ATTACHMENTS_INTO_THIS, PLUG_THIS_INTO_ATTACHMENT, and UnplugThis().

Referenced by Entity::EEItemDetached().

◆ OnDeviceDestroyed()

void ComponentEnergyManager::OnDeviceDestroyed ( )
inlineprotected

Definition at line 310 of file ComponentEnergyManager.c.

311 {
312 bool was_working = m_ThisEntityAI.GetCompEM().IsWorking();
313
314 SwitchOff();
316 UnplugThis();
317 SetPowered(false);
318
319 if (was_working)
320 m_ThisEntityAI.OnWorkStop();
321 ;
322 }
void UnplugAllDevices()
Energy manager: Unplugs everything directly connected to this device.

References Component::m_ThisEntityAI, SetPowered(), SwitchOff(), UnplugAllDevices(), and UnplugThis().

Referenced by Entity::EEDelete().

◆ OnEnergyAdded()

void ComponentEnergyManager::OnEnergyAdded ( )
inlineprotected

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

Definition at line 1387 of file ComponentEnergyManager.c.

1388 {
1390 {
1391 m_UpdateQuantityTimer.Stop();
1393 }
1394
1395 m_ThisEntityAI.OnEnergyAdded();
1396 }

References Component::m_ThisEntityAI, and m_UpdateQuantityTimer.

Referenced by AddEnergy().

◆ OnEnergyConsumed()

void ComponentEnergyManager::OnEnergyConsumed ( )
inlineprotected

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

Definition at line 1381 of file ComponentEnergyManager.c.

1382 {
1383 m_ThisEntityAI.OnEnergyConsumed();
1384 }

References Component::m_ThisEntityAI.

Referenced by AddEnergy().

◆ OnInteractBranch()

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

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 1432 of file ComponentEnergyManager.c.

1433 {
1434 m_ThisEntityAI.IncreaseLifetime();
1435
1436 }

References Component::m_ThisEntityAI.

Referenced by InteractBranch().

◆ OnIsPlugged()

void ComponentEnergyManager::OnIsPlugged ( EntityAI source_device)
inlineprotected

Definition at line 1290 of file ComponentEnergyManager.c.

1291 {
1292 if (m_DebugPlugs)
1293 {
1294 if (!m_DebugUpdate)
1296
1297 if (!m_DebugUpdate.IsRunning())
1298 m_DebugUpdate.Run(0.01, this, "DebugUpdate", NULL, true);
1299 }
1300
1301 UpdateCanWork();
1302 m_ThisEntityAI.OnIsPlugged(source_device);
1303 }

References CALL_CATEGORY_SYSTEM, m_DebugPlugs, m_DebugUpdate, Component::m_ThisEntityAI, and UpdateCanWork().

◆ OnIsUnplugged()

void ComponentEnergyManager::OnIsUnplugged ( EntityAI last_energy_source)
inlineprotected

Definition at line 1306 of file ComponentEnergyManager.c.

1307 {
1308 UpdateCanWork();
1309 m_ThisEntityAI.OnIsUnplugged(last_energy_source);
1310 }

References Component::m_ThisEntityAI, and UpdateCanWork().

◆ OnOwnSocketReleased()

void ComponentEnergyManager::OnOwnSocketReleased ( EntityAI device)
inlineprotected

Definition at line 1326 of file ComponentEnergyManager.c.

1327 {
1328 //play sound
1329 if (device.GetCompEM().GetPlugType() == PLUG_COMMON_APPLIANCE && m_ThisEntityAI.IsInitialized())
1330 {
1332 m_ThisEntityAI.PlaySoundSet(sound_unplug, "cablereel_unplug_SoundSet", 0, 0);
1333 }
1334
1335 m_ThisEntityAI.OnOwnSocketReleased(device);
1336 }
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5

References Component::m_ThisEntityAI, and PLUG_COMMON_APPLIANCE.

Referenced by UnplugDevice().

◆ OnOwnSocketTaken()

void ComponentEnergyManager::OnOwnSocketTaken ( EntityAI device)
inlineprotected

Definition at line 1313 of file ComponentEnergyManager.c.

1314 {
1315 //play sound
1316 if (device.GetCompEM().GetPlugType() == PLUG_COMMON_APPLIANCE && m_ThisEntityAI.IsInitialized())
1317 {
1319 m_ThisEntityAI.PlaySoundSet(sound_plug, "cablereel_plugin_SoundSet", 0, 0);
1320 }
1321
1322 m_ThisEntityAI.OnOwnSocketTaken(device);
1323 }

References Component::m_ThisEntityAI, and PLUG_COMMON_APPLIANCE.

Referenced by PlugInDevice().

◆ OnWork()

void ComponentEnergyManager::OnWork ( float consumed_energy)
inlineprotected

Definition at line 1284 of file ComponentEnergyManager.c.

1285 {
1287 }

References Component::m_ThisEntityAI.

Referenced by DeviceUpdate().

◆ PlugCordIntoSocket()

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

Definition at line 1462 of file ComponentEnergyManager.c.

1463 {
1464 if (socket_id >= 0)
1465 {
1467
1469 {
1471 return;
1472 }
1473 }
1474
1475 int slots_c = GetSocketsCount();
1476
1477 for (int i = 0; i < slots_c; ++i)
1478 {
1480
1481 if (!plug_owner) // Check if this socket is available
1482 {
1484 break;
1485 }
1486 }
1487 }
void UpdateSocketSelections(int socket_id, EntityAI device_to_plug)

References GetDeviceBySocketID(), GetSocketsCount(), and UpdateSocketSelections().

Referenced by PlugInDevice().

◆ PlugInDevice()

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

Definition at line 1531 of file ComponentEnergyManager.c.

1532 {
1534 {
1535 device_to_plug.IncreaseLifetime();
1537 if (device_to_plug.GetCompEM().IsPlugged())
1538 device_to_plug.GetCompEM().UnplugThis();
1539
1541 device_to_plug.GetCompEM().SetEnergySource(m_ThisEntityAI);
1542
1543 PlugCordIntoSocket(device_to_plug, socket_id); // Visualisation
1545
1546 device_to_plug.GetCompEM().OnIsPlugged(m_ThisEntityAI);
1548
1549 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
1550 {
1551 device_to_plug.HideSelection(SEL_CORD_FOLDED);
1552 device_to_plug.ShowSelection(SEL_CORD_PLUGGED);
1553 }
1554
1555 return true;
1556 }
1557
1558 return false;
1559 }
static const string SEL_CORD_FOLDED
void InteractBranch(EntityAI originalCaller, Man player=null, int system=0)
void PlugCordIntoSocket(EntityAI device_to_plug, int socket_id=-1)
void OnOwnSocketTaken(EntityAI device)
bool CanReceivePlugFrom(EntityAI device_to_plug)
Energy manager: Returns true if this device can receive power plug of the other device.

References CanReceivePlugFrom(), GetGame(), GetPluggedDevices(), InteractBranch(), Component::m_ThisEntityAI, OnOwnSocketTaken(), PlugCordIntoSocket(), SEL_CORD_FOLDED, SEL_CORD_PLUGGED, and WakeUpWholeBranch().

◆ PlugThisInto()

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

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 709 of file ComponentEnergyManager.c.

710 {
711 return energy_source.GetCompEM().PlugInDevice(m_ThisEntityAI, socket_id);
712 }

References Component::m_ThisEntityAI.

Referenced by Entity::EEOnAfterLoad(), OnAttachmentAdded(), and Entity::OnVariablesSynchronized().

◆ RefreshDebug()

void ComponentEnergyManager::RefreshDebug ( )
inlineprotected

Definition at line 325 of file ComponentEnergyManager.c.

326 {
327 if (m_DebugPlugs)
328 {
329 if (!m_DebugUpdate)
331
332 if (!m_DebugUpdate.IsRunning())
333 m_DebugUpdate.Run(0.01, this, "DebugUpdate", NULL, true);
334 }
335 else
336 {
338 {
339 m_DebugPlugArrow.Destroy();
341 }
342 }
343 }

References CALL_CATEGORY_SYSTEM, m_DebugPlugArrow, m_DebugPlugs, and m_DebugUpdate.

Referenced by SetDebugPlugs().

◆ RememberLastUpdateTime()

void ComponentEnergyManager::RememberLastUpdateTime ( )
inlineprotected

Definition at line 1640 of file ComponentEnergyManager.c.

1641 {
1643 }

References GetCurrentUpdateTime(), and m_LastUpdateTime.

Referenced by DeviceUpdate().

◆ ResetEnergyUsage()

void ComponentEnergyManager::ResetEnergyUsage ( )
inlineprotected

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

Definition at line 638 of file ComponentEnergyManager.c.

639 {
640 string cfg_energy_usage = "CfgVehicles " + m_ThisEntityAI.GetType() + " EnergyManager ";
641 m_EnergyUsage = GetGame().ConfigGetFloat(cfg_energy_usage + "energyUsagePerSecond");
642 }

References GetGame(), m_EnergyUsage, and Component::m_ThisEntityAI.

◆ RestorePlugState()

void ComponentEnergyManager::RestorePlugState ( bool state)
inlineprotected

Definition at line 499 of file ComponentEnergyManager.c.

500 {
502 }

References m_RestorePlugState.

Referenced by Entity::OnStoreLoad().

◆ SetAttachmentAction()

void ComponentEnergyManager::SetAttachmentAction ( int new_action_type)
inlineprotected

Definition at line 626 of file ComponentEnergyManager.c.

References m_AttachmentActionType.

◆ SetCordLength()

void ComponentEnergyManager::SetCordLength ( float new_length)
inlineprotected

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

Definition at line 614 of file ComponentEnergyManager.c.

615 {
617 }

References m_CordLength.

◆ SetCordTextureFile()

void ComponentEnergyManager::SetCordTextureFile ( string new_path)
inlineprotected

Definition at line 645 of file ComponentEnergyManager.c.

646 {
648 }

References m_CordTextureFile.

◆ SetDebugPlugs()

void ComponentEnergyManager::SetDebugPlugs ( bool newVal)
inlineprotected

Definition at line 350 of file ComponentEnergyManager.c.

References m_DebugPlugs, and RefreshDebug().

◆ SetDeviceBySocketID()

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

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

Definition at line 657 of file ComponentEnergyManager.c.

658 {
660 }

References m_Sockets.

Referenced by UnplugCordFromSocket(), and UpdateSocketSelections().

◆ SetElectricityIconVisibility()

void ComponentEnergyManager::SetElectricityIconVisibility ( bool make_visible)
inlineprotected

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

Definition at line 664 of file ComponentEnergyManager.c.

665 {
667 }

References m_HasElectricityIcon.

◆ SetEnergy()

void ComponentEnergyManager::SetEnergy ( float new_energy)
inlineprotected

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

Definition at line 505 of file ComponentEnergyManager.c.

506 {
507 if (GetGame().IsServer() || !GetGame().IsMultiplayer()) // Client can't change energy value.
508 {
509 m_ThisEntityAI.SetWeightDirty();
510 float old_energy = m_Energy;
512
515 }
516 }
static proto float Min(float x, float y)
Returns smaller of two given values.

References GetEnergyUsage(), GetGame(), m_Energy, Component::m_ThisEntityAI, Math::Min(), and UpdateCanWork().

Referenced by AddEnergy(), Entity::OnStoreLoad(), and SetEnergy0To1().

◆ SetEnergy0To1()

void ComponentEnergyManager::SetEnergy0To1 ( float energy01)
inlineprotected

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

Definition at line 519 of file ComponentEnergyManager.c.

520 {
522 }
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.

References GetEnergyMax(), Math::Lerp(), and SetEnergy().

◆ SetEnergyMaxPristine()

void ComponentEnergyManager::SetEnergyMaxPristine ( float new_limit)
inlineprotected

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

Definition at line 608 of file ComponentEnergyManager.c.

609 {
611 }

References m_EnergyStorageMax.

◆ SetEnergySource()

void ComponentEnergyManager::SetEnergySource ( EntityAI source)
inlineprotected

Definition at line 1508 of file ComponentEnergyManager.c.

1509 {
1511
1512 if (source)
1513 {
1514 m_IsPlugged = true;
1515 StartUpdates();
1516 }
1517 else
1518 {
1519 m_IsPlugged = false;
1522 }
1523
1524 if (m_EnergySource)
1526
1527 Synch();
1528 }

References m_EnergySource, m_EnergySourceNetworkIDHigh, m_EnergySourceNetworkIDLow, m_IsPlugged, StartUpdates(), and Synch().

Referenced by SetEnergySourceClient().

◆ SetEnergySourceClient()

void ComponentEnergyManager::SetEnergySourceClient ( EntityAI source)
inlineprotected

Definition at line 651 of file ComponentEnergyManager.c.

652 {
654 }
void SetEnergySource(EntityAI source)

References SetEnergySource().

◆ SetEnergyUsage()

void ComponentEnergyManager::SetEnergyUsage ( float new_usage)
inlineprotected

Energy manager: Changes the energy usage per second.

Definition at line 632 of file ComponentEnergyManager.c.

633 {
635 }

References m_EnergyUsage.

◆ SetMySocketID()

void ComponentEnergyManager::SetMySocketID ( int slot_ID)
inlineprotected

Definition at line 1625 of file ComponentEnergyManager.c.

1626 {
1628 }

References m_MySocketID.

◆ SetPassiveState()

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

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 427 of file ComponentEnergyManager.c.

References DeviceUpdate(), and m_IsPassiveDevice.

Referenced by Entity::OnStoreLoad().

◆ SetPlugOwner()

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

◆ SetPlugType()

void ComponentEnergyManager::SetPlugType ( int new_type)
inlineprotected

Definition at line 620 of file ComponentEnergyManager.c.

621 {
623 }

References m_PlugType.

◆ SetPowered()

void ComponentEnergyManager::SetPowered ( bool state)
inlineprotected

Definition at line 1588 of file ComponentEnergyManager.c.

1589 {
1591 }

References m_IsWorking.

Referenced by DeviceUpdate(), and OnDeviceDestroyed().

◆ SetUpdateInterval()

void ComponentEnergyManager::SetUpdateInterval ( float value)
inlineprotected

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

Definition at line 697 of file ComponentEnergyManager.c.

698 {
700 }

References m_UpdateInterval.

Referenced by Event_OnAwake().

◆ StartUpdates()

void ComponentEnergyManager::StartUpdates ( )
inlineprotected

Definition at line 1368 of file ComponentEnergyManager.c.

1369 {
1370 if (!m_IsPassiveDevice)
1371 {
1372 if (!m_UpdateTimer)
1374
1375 if (!m_UpdateTimer.IsRunning()) // Makes sure the timer is NOT running already
1376 m_UpdateTimer.Run(GetUpdateInterval(), this, "DeviceUpdate", null, true);
1377 }
1378 }
float GetUpdateInterval()
Energy manager: Returns the update interval of this device.

References CALL_CATEGORY_SYSTEM, GetUpdateInterval(), m_IsPassiveDevice, and m_UpdateTimer.

Referenced by AddEnergy(), Entity::OnVariablesSynchronized(), SetEnergySource(), and SwitchOn().

◆ StopUpdates()

void ComponentEnergyManager::StopUpdates ( )
inlineprotected

Definition at line 1404 of file ComponentEnergyManager.c.

1405 {
1406 if (m_UpdateTimer)
1407 {
1408 m_UpdateTimer.Stop();
1409 m_UpdateTimer = NULL; // Delete timer from memory
1410 }
1411 }

References m_UpdateTimer.

Referenced by DeviceUpdate(), and SwitchOff().

◆ StoreEnergySourceIDs()

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

◆ SwitchOff()

void ComponentEnergyManager::SwitchOff ( )
inlineprotected

Energy manager: Switches OFF the device.

Definition at line 392 of file ComponentEnergyManager.c.

393 {
395
396 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
397 {
398 if (CanSwitchOff())
399 {
400 m_IsSwichedOn = false;
401 Synch();
402
403 if (IsWorking())
404 {
405 StopUpdates();
406 DeviceUpdate();
407 }
408
409 // 'Wakes up' all connected devices
411
413
414 // Call event
415 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOff", NULL, 0);
416 }
417 }
418
419 if (!GetGame().IsServer() && GetGame().IsMultiplayer())
420 {
421 m_IsSwichedOn = false;
422 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOff", NULL, 0);
423 }
424 }
bool CanSwitchOff()
Energy manager: Checks if the device can be switched OFF.

References CanSwitchOff(), DeviceUpdate(), GetGame(), IsWorking(), m_IsSwichedOn, m_IsSwichedOnPreviousState, Component::m_ThisEntityAI, StopUpdates(), Synch(), UpdateCanWork(), and WakeUpWholeBranch().

Referenced by DeviceUpdate(), HandleMoveInsideCargo(), OnDeviceDestroyed(), and Entity::OnVariablesSynchronized().

◆ SwitchOn()

void ComponentEnergyManager::SwitchOn ( )
inlineprotected

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

Definition at line 363 of file ComponentEnergyManager.c.

364 {
366
367 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
368 {
369 if (CanSwitchOn())
370 {
371 m_IsSwichedOn = true;
372 Synch();
373
374 DeviceUpdate(); // 'Wake up' this device now
375 StartUpdates();
376
377 // 'Wakes up' all connected devices
379
381
382 // Call event
383 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOn", NULL, 0);
384 }
385 }
386
387 if (!GetGame().IsServer() && GetGame().IsMultiplayer()/* && CanSwitchOn() */) // I want the CanSwitchOn() check, but when it's here, the OnSwitchOn() event is never called on client-side due to engine's synchronization system changing the m_IsSwichedOn to true without any specific event beign called. (Yes there is OnVariablesSynchronized() but that is called also when m_CanWork is synchronized, so I need to write a method of knowing when was this specific value changed.)
388 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOn", NULL, 0);
389 }
bool CanSwitchOn()
Energy manager: Checks if the device can be switched ON.

References CanSwitchOn(), DeviceUpdate(), GetGame(), m_IsSwichedOn, m_IsSwichedOnPreviousState, Component::m_ThisEntityAI, StartUpdates(), Synch(), UpdateCanWork(), and WakeUpWholeBranch().

Referenced by Event_OnAwake(), Entity::OnStoreLoad(), and Entity::OnVariablesSynchronized().

◆ Synch()

void ComponentEnergyManager::Synch ( )
inlineprotected

Definition at line 1630 of file ComponentEnergyManager.c.

1631 {
1632 m_ThisEntityAI.SetSynchDirty();
1633 }

References Component::m_ThisEntityAI.

Referenced by SetEnergySource(), SwitchOff(), SwitchOn(), and UpdateCanWork().

◆ UnplugAllDevices()

void ComponentEnergyManager::UnplugAllDevices ( )
inlineprotected

Energy manager: Unplugs everything directly connected to this device.

Definition at line 488 of file ComponentEnergyManager.c.

489 {
490 if (GetPluggedDevices()) // This check is necesarry in case this function is called before initialization
491 {
493 for (int i = indexStart; i >= 0; --i)
495 }
496 }
array< ref PlayerStatBase > Get()
void UnplugDevice(EntityAI device_to_unplug)
Energy manager: Unplugs the given device from this one.

References Get(), GetPluggedDevices(), GetPluggedDevicesCount(), and UnplugDevice().

Referenced by OnDeviceDestroyed().

◆ UnplugCordFromSocket()

void ComponentEnergyManager::UnplugCordFromSocket ( int socket_to_unplug_ID)
inlineprotected

Definition at line 1570 of file ComponentEnergyManager.c.

1571 {
1573
1574 if (plug_owner)
1575 {
1578 m_ThisEntityAI.ShowSelection(unplugged_selection);
1579
1581 m_ThisEntityAI.HideSelection(plugged_selection);
1583 plug_owner.GetCompEM().SetMySocketID(-1);
1584 }
1585 }
proto string ToString()
static const string _AVAILABLE
void SetPlugOwner(string selection_name, EntityAI device)
void SetDeviceBySocketID(int id, EntityAI plugged_device)
Energy manager: Stores the device which is plugged into the given socket ID.

References _AVAILABLE, _PLUGGED, GetDeviceBySocketID(), Component::m_ThisEntityAI, SetDeviceBySocketID(), SetPlugOwner(), SOCKET_, and ToString().

Referenced by UnplugDevice().

◆ UnplugDevice()

void ComponentEnergyManager::UnplugDevice ( EntityAI device_to_unplug)
inlineprotected

Energy manager: Unplugs the given device from this one.

Definition at line 435 of file ComponentEnergyManager.c.

436 {
437 if (GetGame())
438 {
440 bool deviceFound = false;
441
442 for (int i = indexStart; i >= 0; --i)
443 {
445
447 {
448 GetPluggedDevices().Remove(i);
449 deviceFound = true;
450 break;
451 }
452 }
453
454 if (deviceFound)
455 {
456 int socket_ID = device_to_unplug.GetCompEM().GetMySocketID();
458 device_to_unplug.GetCompEM().SetEnergySource(null);
459 device_to_unplug.GetCompEM().DeviceUpdate();
460 device_to_unplug.GetCompEM().StartUpdates();
461 device_to_unplug.GetCompEM().WakeUpWholeBranch(m_ThisEntityAI);
462
464 {
465 m_DebugPlugArrow.Destroy();
467 }
468
470 device_to_unplug.GetCompEM().OnIsUnplugged(m_ThisEntityAI);
471 device_to_unplug.ShowSelection(SEL_CORD_FOLDED);
472 device_to_unplug.HideSelection(SEL_CORD_PLUGGED);
473 }
474 }
475 }
void UnplugCordFromSocket(int socket_to_unplug_ID)
void OnOwnSocketReleased(EntityAI device)

References GetGame(), GetPluggedDevices(), GetPluggedDevicesCount(), m_DebugPlugArrow, m_DebugPlugs, Component::m_ThisEntityAI, OnOwnSocketReleased(), SEL_CORD_FOLDED, SEL_CORD_PLUGGED, and UnplugCordFromSocket().

Referenced by UnplugAllDevices().

◆ UnplugThis()

void ComponentEnergyManager::UnplugThis ( )
inlineprotected

Energy manager: Unplugs this device from its power source.

Definition at line 478 of file ComponentEnergyManager.c.

479 {
480 if (GetGame())
481 {
482 if (GetEnergySource())
483 GetEnergySource().GetCompEM().UnplugDevice(m_ThisEntityAI);
484 }
485 }

References GetEnergySource(), GetGame(), and Component::m_ThisEntityAI.

Referenced by OnAttachmentRemoved(), OnDeviceDestroyed(), Entity::OnVariablesSynchronized(), and UpdatePlugState().

◆ UpdateCanWork()

void ComponentEnergyManager::UpdateCanWork ( )
inlineprotected

Definition at line 670 of file ComponentEnergyManager.c.

671 {
672 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
673 {
674 bool current_state = CanWork();
675
677 {
679 Synch();
680
681 if (m_ThisEntityAI && m_ThisEntityAI.GetHierarchyParent() && m_ThisEntityAI.GetHierarchyParent().GetCompEM())
682 m_ThisEntityAI.GetHierarchyParent().GetCompEM().UpdateCanWork();
683 }
684 }
685 }
bool CanWork(float test_energy=-1)
Energy manager: Checks whenever this device can do work or not.

References CanWork(), GetGame(), m_CanWork, Component::m_ThisEntityAI, and Synch().

Referenced by DeviceUpdate(), OnIsPlugged(), OnIsUnplugged(), SetEnergy(), SwitchOff(), and SwitchOn().

◆ UpdatePlugState()

void ComponentEnergyManager::UpdatePlugState ( )
inlineprotected

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

Definition at line 565 of file ComponentEnergyManager.c.

566 {
567 if (m_ThisEntityAI.GetCompEM().GetEnergySource())
568 {
569 EntityAI player = m_ThisEntityAI.GetHierarchyRootPlayer();
570 // Check if the item is held in hands during advanced placement
571 if (player)
572 {
573 // Measure distance from the player
574 vector playerPosition = player.GetPosition();
576 UnplugThis();
577 }
578 else
579 {
580 // Measure distance from the device
581 vector itemPosition = m_ThisEntityAI.GetPosition();
582
583 if (m_ThisEntityAI.GetHierarchyParent())
584 itemPosition = m_ThisEntityAI.GetHierarchyParent().GetPosition();
585
587 UnplugThis();
588 }
589 }
590 }
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 g...

References IsEnergySourceAtReach(), Component::m_ThisEntityAI, and UnplugThis().

◆ UpdateSelections()

void ComponentEnergyManager::UpdateSelections ( )
inlineprotected

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 525 of file ComponentEnergyManager.c.

526 {
527 // Lets update sockets, if there are any
528 int slots_c = GetSocketsCount();
529
530 for (int i = 0; i < slots_c; ++i)
531 {
533
534 if (plug_owner)
535 {
536 string plugged_selection = SOCKET_ + (i + 1).ToString() + _PLUGGED;
537 string available_selection = SOCKET_ + (i + 1).ToString() + _AVAILABLE;
538 m_ThisEntityAI.ShowSelection(plugged_selection);
539 m_ThisEntityAI.HideSelection(available_selection);
540 string texture_path = plug_owner.GetCompEM().GetCordTextureFile();
541 int selection_index = m_ThisEntityAI.GetHiddenSelectionIndex(plugged_selection);
543 }
544 else
545 {
546 m_ThisEntityAI.ShowSelection(SOCKET_ + (i + 1).ToString() + _AVAILABLE);
547 m_ThisEntityAI.HideSelection(SOCKET_ + (i + 1).ToString() + _PLUGGED);
548 }
549 }
550
551 // Now lets update the cord/plug state
552 if (GetEnergySource())
553 {
554 m_ThisEntityAI.ShowSelection(SEL_CORD_PLUGGED);
555 m_ThisEntityAI.HideSelection(SEL_CORD_FOLDED);
556 }
557 else
558 {
559 m_ThisEntityAI.ShowSelection(SEL_CORD_FOLDED);
560 m_ThisEntityAI.HideSelection(SEL_CORD_PLUGGED);
561 }
562 }

References _AVAILABLE, _PLUGGED, GetDeviceBySocketID(), GetEnergySource(), GetSocketsCount(), Component::m_ThisEntityAI, SEL_CORD_FOLDED, SEL_CORD_PLUGGED, SOCKET_, and ToString().

◆ UpdateSocketSelections()

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

Definition at line 1490 of file ComponentEnergyManager.c.

1491 {
1493
1496 m_ThisEntityAI.ShowSelection(plugged_selection);
1497
1499 m_ThisEntityAI.HideSelection(unplugged_selection);
1500 string texture_path = device_to_plug.GetCompEM().GetCordTextureFile();
1501 int selection_index = m_ThisEntityAI.GetHiddenSelectionIndex(plugged_selection);
1502 m_ThisEntityAI.SetObjectTexture(selection_index, texture_path);
1503 device_to_plug.GetCompEM().SetMySocketID(socket_id);
1504 }

References _AVAILABLE, _PLUGGED, Component::m_ThisEntityAI, SetDeviceBySocketID(), SetPlugOwner(), SOCKET_, and ToString().

Referenced by PlugCordIntoSocket().

◆ WakeUpWholeBranch()

void ComponentEnergyManager::WakeUpWholeBranch ( EntityAI original_caller)
inlineprotected

Definition at line 1439 of file ComponentEnergyManager.c.

1440 {
1441 if (GetSocketsCount() > 0)
1442 {
1444 int plugged_devices_c = plugged_devices.Count();
1445
1446 for (int i = 0; i < plugged_devices_c; ++i)
1447 {
1449 if (device != original_caller) // original_caller check here prevents infinite loops
1450 {
1451 device.GetCompEM().UpdateCanWork();
1452 device.GetCompEM().DeviceUpdate();
1453 device.GetCompEM().StartUpdates();
1454 device.GetCompEM().WakeUpWholeBranch(original_caller);
1455 }
1456 }
1457 }
1458 }

References GetPluggedDevices(), and GetSocketsCount().

Referenced by DeviceUpdate(), PlugInDevice(), SwitchOff(), and SwitchOn().

Member Data Documentation

◆ _AVAILABLE

const string ComponentEnergyManager::_AVAILABLE = "_available"
staticprotected

◆ _PLUGGED

const string ComponentEnergyManager::_PLUGGED = "_plugged"
staticprotected

◆ DEFAULT_UPDATE_INTERVAL

const float ComponentEnergyManager::DEFAULT_UPDATE_INTERVAL = 15
protected

Definition at line 20 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake().

◆ m_AttachmentActionType

int ComponentEnergyManager::m_AttachmentActionType
protected

◆ m_AutoSwitchOff

bool ComponentEnergyManager::m_AutoSwitchOff
protected

Definition at line 31 of file ComponentEnergyManager.c.

Referenced by DeviceUpdate(), and Event_OnAwake().

◆ m_AutoSwitchOffWhenInCargo

bool ComponentEnergyManager::m_AutoSwitchOffWhenInCargo
protected

Definition at line 34 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and HandleMoveInsideCargo().

◆ m_CanStopWork

bool ComponentEnergyManager::m_CanStopWork
protected

Definition at line 29 of file ComponentEnergyManager.c.

Referenced by DeviceUpdate().

◆ m_CanWork

bool ComponentEnergyManager::m_CanWork
protected

Definition at line 28 of file ComponentEnergyManager.c.

Referenced by CanWork(), DeviceUpdate(), Event_OnAwake(), and UpdateCanWork().

◆ m_CompatiblePlugTypes

ref TIntArray ComponentEnergyManager::m_CompatiblePlugTypes
protected

◆ m_ConvertEnergyToQuantity

bool ComponentEnergyManager::m_ConvertEnergyToQuantity
protected

Definition at line 36 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and HasConversionOfEnergyToQuantity().

◆ m_CordLength

float ComponentEnergyManager::m_CordLength
protected

Definition at line 54 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), GetCordLength(), and SetCordLength().

◆ m_CordTextureFile

string ComponentEnergyManager::m_CordTextureFile
protected

Definition at line 59 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), GetCordTextureFile(), and SetCordTextureFile().

◆ m_DebugPlugArrow

Shape ComponentEnergyManager::m_DebugPlugArrow
protected

◆ m_DebugPlugs

bool ComponentEnergyManager::m_DebugPlugs = false
staticprotected

◆ m_DebugUpdate

ref Timer ComponentEnergyManager::m_DebugUpdate
protected

Definition at line 75 of file ComponentEnergyManager.c.

Referenced by DebugUpdate(), OnIsPlugged(), and RefreshDebug().

◆ m_DeviceByPlugSelection

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

Definition at line 71 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), GetPlugOwner(), and SetPlugOwner().

◆ m_Energy

float ComponentEnergyManager::m_Energy
protected

◆ m_EnergyAtSpawn

float ComponentEnergyManager::m_EnergyAtSpawn
protected

Definition at line 50 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and GetEnergyAtSpawn().

◆ m_EnergySource

EntityAI ComponentEnergyManager::m_EnergySource
protected

Definition at line 69 of file ComponentEnergyManager.c.

Referenced by GetEnergySource(), and SetEnergySource().

◆ m_EnergySourceNetworkIDHigh

int ComponentEnergyManager::m_EnergySourceNetworkIDHigh = -1
protected

Definition at line 46 of file ComponentEnergyManager.c.

Referenced by GetEnergySourceNetworkIDHigh(), and SetEnergySource().

◆ m_EnergySourceNetworkIDLow

int ComponentEnergyManager::m_EnergySourceNetworkIDLow = -1
protected

Definition at line 45 of file ComponentEnergyManager.c.

Referenced by GetEnergySourceNetworkIDLow(), and SetEnergySource().

◆ m_EnergySourceStorageIDb1

int ComponentEnergyManager::m_EnergySourceStorageIDb1
protected

Definition at line 40 of file ComponentEnergyManager.c.

Referenced by GetEnergySourceStorageIDb1(), and StoreEnergySourceIDs().

◆ m_EnergySourceStorageIDb2

int ComponentEnergyManager::m_EnergySourceStorageIDb2
protected

Definition at line 41 of file ComponentEnergyManager.c.

Referenced by GetEnergySourceStorageIDb2(), and StoreEnergySourceIDs().

◆ m_EnergySourceStorageIDb3

int ComponentEnergyManager::m_EnergySourceStorageIDb3
protected

Definition at line 42 of file ComponentEnergyManager.c.

Referenced by GetEnergySourceStorageIDb3(), and StoreEnergySourceIDs().

◆ m_EnergySourceStorageIDb4

int ComponentEnergyManager::m_EnergySourceStorageIDb4
protected

Definition at line 43 of file ComponentEnergyManager.c.

Referenced by GetEnergySourceStorageIDb4(), and StoreEnergySourceIDs().

◆ m_EnergyStorageMax

float ComponentEnergyManager::m_EnergyStorageMax
protected

◆ m_EnergyUsage

float ComponentEnergyManager::m_EnergyUsage
protected

◆ m_HasElectricityIcon

bool ComponentEnergyManager::m_HasElectricityIcon
protected

◆ m_IsPassiveDevice

bool ComponentEnergyManager::m_IsPassiveDevice
protected

◆ m_IsPlugged

bool ComponentEnergyManager::m_IsPlugged
protected

Definition at line 35 of file ComponentEnergyManager.c.

Referenced by IsPlugged(), and SetEnergySource().

◆ m_IsSwichedOn

bool ComponentEnergyManager::m_IsSwichedOn
protected

Definition at line 24 of file ComponentEnergyManager.c.

Referenced by IsSwitchedOn(), SwitchOff(), and SwitchOn().

◆ m_IsSwichedOnPreviousState

bool ComponentEnergyManager::m_IsSwichedOnPreviousState
protected

Definition at line 25 of file ComponentEnergyManager.c.

Referenced by GetPreviousSwitchState(), SwitchOff(), and SwitchOn().

◆ m_IsWorking

bool ComponentEnergyManager::m_IsWorking
protected

Definition at line 27 of file ComponentEnergyManager.c.

Referenced by IsWorking(), and SetPowered().

◆ m_LastUpdateTime

float ComponentEnergyManager::m_LastUpdateTime
protected

◆ m_MySocketID

int ComponentEnergyManager::m_MySocketID = -1
protected

Definition at line 38 of file ComponentEnergyManager.c.

Referenced by GetMySocketID(), and SetMySocketID().

◆ m_PluggedDevices

ref array<EntityAI> ComponentEnergyManager::m_PluggedDevices
protected

Definition at line 70 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and GetPluggedDevices().

◆ m_PlugType

int ComponentEnergyManager::m_PlugType
protected

Definition at line 39 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), GetPlugType(), and SetPlugType().

◆ m_ReduceMaxEnergyByDamageCoef

float ComponentEnergyManager::m_ReduceMaxEnergyByDamageCoef
protected

Definition at line 52 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and GetEnergyMax().

◆ m_RestorePlugState

bool ComponentEnergyManager::m_RestorePlugState
protected

Definition at line 30 of file ComponentEnergyManager.c.

Referenced by GetRestorePlugState(), and RestorePlugState().

◆ m_ShowSocketsInInventory

bool ComponentEnergyManager::m_ShowSocketsInInventory
protected

Definition at line 32 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and HasVisibleSocketsInInventory().

◆ m_Sockets

EntityAI ComponentEnergyManager::m_Sockets[MAX_SOCKETS_COUNT]
protected

◆ m_SocketsCount

float ComponentEnergyManager::m_SocketsCount
protected

Definition at line 53 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and GetSocketsCount().

◆ m_UpdateInterval

float ComponentEnergyManager::m_UpdateInterval
protected

Definition at line 57 of file ComponentEnergyManager.c.

Referenced by GetUpdateInterval(), and SetUpdateInterval().

◆ m_UpdateQuantityTimer

ref Timer ComponentEnergyManager::m_UpdateQuantityTimer
protected

Definition at line 74 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake(), and OnEnergyAdded().

◆ m_UpdateTimer

ref Timer ComponentEnergyManager::m_UpdateTimer
protected

Definition at line 73 of file ComponentEnergyManager.c.

Referenced by StartUpdates(), and StopUpdates().

◆ m_WetnessExposure

float ComponentEnergyManager::m_WetnessExposure
protected

Definition at line 56 of file ComponentEnergyManager.c.

Referenced by CheckWetness(), Event_OnAwake(), and GetWetnessExposure().

◆ MAX_SOCKETS_COUNT

const int ComponentEnergyManager::MAX_SOCKETS_COUNT = 4
protected

Definition at line 77 of file ComponentEnergyManager.c.

Referenced by Event_OnAwake().

◆ SEL_CORD_FOLDED

const string ComponentEnergyManager::SEL_CORD_FOLDED = "cord_folded"
staticprotected

Definition at line 66 of file ComponentEnergyManager.c.

Referenced by PlugInDevice(), UnplugDevice(), and UpdateSelections().

◆ SEL_CORD_PLUGGED

const string ComponentEnergyManager::SEL_CORD_PLUGGED = "cord_plugged"
staticprotected

◆ SOCKET_

const string ComponentEnergyManager::SOCKET_ = "socket_"
staticprotected

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