Dayz 1.25
Dayz Code Explorer by KGB
Загрузка...
Поиск...
Не найдено
Класс ComponentEnergyManager
+ Граф наследования:ComponentEnergyManager:

Защищенные члены

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 ()
 

Защищенные данные

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 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"
 

Дополнительные унаследованные члены

- Закрытые члены унаследованные от 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 ()
 
- Закрытые статические члены унаследованные от 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)
 
- Закрытые данные унаследованные от Component
EntityAI m_ThisEntityAI
 
Shape m_DebugShapeBBox
 
Shape m_DebugShapeDirection
 
float m_DebugShapeDirectionDist
 

Подробное описание

Конструктор(ы)

◆ ComponentEnergyManager()

void ComponentEnergyManager ( )
inlineprotected
84 {
85 // Disable debug arrows on public release, so that they don't use their timers.
86 #ifndef DEVELOPER
87 m_DebugPlugs = false;
88 #endif
89 }
static bool m_DebugPlugs
Definition ComponentEnergyManager.c:21

Перекрестные ссылки m_DebugPlugs.

◆ ~ComponentEnergyManager()

void ~ComponentEnergyManager ( )
inlineprotected
92 {
94 {
95 m_DebugPlugArrow.Destroy();
97 }
98 }
Shape m_DebugPlugArrow
Definition ComponentEnergyManager.c:22
Definition EntityAI.c:95

Перекрестные ссылки m_DebugPlugArrow.

Методы

◆ AddEnergy()

float 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.

1221 {
1222 if (added_energy != 0)
1223 {
1224 //Print("AddEnergy ---------> " + added_energy + " " + this + " " +m_ThisEntityAI.ClassName());
1225 #ifdef DIAG_DEVELOPER
1226 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_CONSUMPTION) && added_energy < 0)
1227 {
1228 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
1230 }
1231 #endif
1232
1233 bool energy_was_added = (added_energy > 0);
1234
1238 StartUpdates();
1239
1240 if (energy_was_added)
1241 OnEnergyAdded();
1242 else
1244
1246 }
1247
1248 return 0;
1249 }
float GetEnergy()
Energy manager: Returns the amount of stored energy this device has.
Definition ComponentEnergyManager.c:1214
void SetEnergy(float new_energy)
Energy manager: Sets stored energy for this device. It ignores the min/max limit!
Definition ComponentEnergyManager.c:525
void OnEnergyConsumed()
Energy manager: Called when energy was consumed on this device.
Definition ComponentEnergyManager.c:1467
void StartUpdates()
Definition ComponentEnergyManager.c:1452
float GetEnergyMax()
Energy manager: Returns the maximum amount of energy this device can curently store....
Definition ComponentEnergyManager.c:1252
void OnEnergyAdded()
Energy manager: Called when energy was added on this device.
Definition ComponentEnergyManager.c:1473
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'.

Перекрестные ссылки Math::Clamp(), GetEnergy(), GetEnergyMax(), OnEnergyAdded(), OnEnergyConsumed(), SetEnergy() и StartUpdates().

Используется в FindAndConsumeEnergy().

◆ CanBePluggedInto()

bool CanBePluggedInto ( EntityAI potential_energy_provider)
inlineprotected

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

999 {
1000 return potential_energy_provider.GetCompEM().CanReceivePlugFrom( m_ThisEntityAI );
1001 }
EntityAI m_ThisEntityAI
Definition Component.c:24

Перекрестные ссылки Component::m_ThisEntityAI.

◆ CanReceivePlugFrom()

bool CanReceivePlugFrom ( EntityAI device_to_plug)
inlineprotected

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

977 {
978 // The following conditions are broken down for the sake of easier reading/debugging.
979
981 {
982 if ( device_to_plug.GetCompEM().GetEnergySource() != m_ThisEntityAI)
983 {
984 if ( IsPlugCompatible(device_to_plug.GetCompEM().GetPlugType()) )
985 {
986 if ( device_to_plug.GetCompEM().IsEnergySourceAtReach( device_to_plug.GetPosition(), 0, m_ThisEntityAI.GetPosition() ) )
987 {
988 return true;
989 }
990 }
991 }
992 }
993
994 return false;
995 }
bool HasFreeSocket(int socket_id=-1)
Energy manager: Returns true if this device has any free socket to receive a plug....
Definition ComponentEnergyManager.c:917
bool IsPlugCompatible(int plug_ID)
Energy manager: Checks if the given plug is compatible with this device's socket. Used by CanReceiveP...
Definition ComponentEnergyManager.c:947

Перекрестные ссылки HasFreeSocket(), IsPlugCompatible() и Component::m_ThisEntityAI.

Используется в PlugInDevice().

◆ CanSwitchOff()

bool CanSwitchOff ( )
inlineprotected

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

850 {
851 if ( IsPassive() )
852 {
853 return false;
854 }
855
856 return IsSwitchedOn();
857 }
bool IsPassive()
Energy manager: Returns true if this device is set to be passive. False if otherwise.
Definition ComponentEnergyManager.c:881
bool IsSwitchedOn()
Energy manager: Returns state of the switch. Whenever the device is working or not does not matter....
Definition ComponentEnergyManager.c:866

Перекрестные ссылки IsPassive() и IsSwitchedOn().

Используется в SwitchOff().

◆ CanSwitchOn()

bool CanSwitchOn ( )
inlineprotected

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

742 {
743 if ( !IsSwitchedOn() )
744 {
745 return true;
746 }
747
748 return false;
749 }

Перекрестные ссылки IsSwitchedOn().

Используется в SwitchOn().

◆ CanWork()

bool CanWork ( float test_energy = -1)
inlineprotected

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

Аргументы
test_energyfloat optional parameter will overwite the default energy consumption value of this device.
Возвращает
bool Returns true if this device will work when it's switched on. Otherwise it returns false.
758 {
759 if ( GetGame().IsMultiplayer() && GetGame().IsClient() )
760 {
761 return m_CanWork;
762 }
763
764 if (m_ThisEntityAI && m_ThisEntityAI.IsRuined())
765 {
766 return false;
767 }
768
769 // Check if the power source(s) (which can be serially connected) can provide needed energy.
771 float gathered_energy = GetEnergy();
773
774 if (energy_usage == -1)
775 {
777 }
778
779 if ( !CheckWetness() )
780 {
781 return false;
782 }
783
784 if (gathered_energy <= 0 && energy_usage <= 0) //empty power source
785 {
786 return false;
787 }
788
789 int cycle_limit = 500; // Sanity check to definitely avoid infinite cycles
790
791 while ( gathered_energy < energy_usage ) // Look for energy source if we don't have enough stored energy
792 {
793 // Safetycheck!
794 if (cycle_limit > 0)
795 {
796 cycle_limit--;
797 }
798 else
799 {
800 DPrint("Energy Manager ERROR: The 'cycle_limit' safety break had to be activated to prevent possible game freeze. Dumping debug information...");
801 //Print(m_ThisEntityAI);
802 //Print(this);
803 //Print(energy_source);
804
805 if (energy_source.GetCompEM())
806 {
807 //Print(energy_source.GetCompEM());
808 }
809
810 //Print(gathered_energy);
811 //Print(energy_usage);
812
813 //Print(m_ThisEntityAI.GetPosition());
814
815 if (energy_source)
816 {
817 //Print(energy_source.GetPosition());
818 }
819
820 //Print("End of the 'cycle_limit' safety break ^ ");
821
822 return false;
823 }
824 // ^ Safetycheck!
825
826 if ( energy_source && energy_source != m_ThisEntityAI && !energy_source.IsRuined() && energy_source.GetCompEM() && energy_source.GetCompEM().IsSwitchedOn() && energy_source.GetCompEM().CheckWetness() )
827 {
828 gathered_energy = gathered_energy + energy_source.GetCompEM().GetEnergy();
829 energy_source = energy_source.GetCompEM().GetEnergySource();
830 }
831 else
832 {
833 // No power source, no energy.
834 return false;
835 }
836 }
837
838 // Enough energy was found
839 return true;
840 }
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
Definition ComponentEnergyManager.c:1292
bool CheckWetness()
Energy manager: Checks if this device is being stopped from working by its wetness level....
Definition ComponentEnergyManager.c:843
bool m_CanWork
Definition ComponentEnergyManager.c:28
float GetEnergyUsage()
Energy manager: Returns the number of energy this device needs to run itself (See its config >> energ...
Definition ComponentEnergyManager.c:1208
Definition Building.c:6
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 ...

Перекрестные ссылки CheckWetness(), DPrint(), GetEnergy(), GetEnergySource(), GetEnergyUsage(), GetGame(), m_CanWork и Component::m_ThisEntityAI.

Используется в UpdateCanWork().

◆ CheckWetness()

bool 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.

844 {
845 return (m_ThisEntityAI.GetWet() <= 1-m_WetnessExposure);
846 }
float m_WetnessExposure
Definition ComponentEnergyManager.c:56

Перекрестные ссылки Component::m_ThisEntityAI и m_WetnessExposure.

Используется в CanWork() и DeviceUpdate().

◆ ClearLastUpdateTime()

void ClearLastUpdateTime ( )
inlineprotected
1732 {
1733 m_LastUpdateTime = 0;
1734 }
float m_LastUpdateTime
Definition ComponentEnergyManager.c:55

Перекрестные ссылки m_LastUpdateTime.

Используется в DeviceUpdate().

◆ ConsumeEnergy()

bool 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.

895 {
896 return FindAndConsumeEnergy(m_ThisEntityAI, amount, true);
897 }
bool FindAndConsumeEnergy(EntityAI original_caller, float amount, bool ignore_switch_state=false)
Definition ComponentEnergyManager.c:1684

Перекрестные ссылки FindAndConsumeEnergy() и Component::m_ThisEntityAI.

Используется в DeviceUpdate().

◆ DebugUpdate()

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

Перекрестные ссылки vector::DistanceSq(), DrawArrow(), GetDebugPlugs(), GetEnergySource(), GetGame(), m_DebugPlugArrow, m_DebugUpdate и Component::m_ThisEntityAI.

◆ DeviceUpdate()

void DeviceUpdate ( )
inlineprotected
1748 {
1749 /*
1750 vector pos = m_ThisEntityAI.GetPosition();
1751 string debug_message = "Object " + m_ThisEntityAI.GetType() + " | Energy: " + GetEnergy() + " | IsAtReach: " + (IsEnergySourceAtReach(pos)).ToString();
1752 Print(debug_message);
1753 */
1754
1755 if ( !m_IsPassiveDevice )
1756 {
1757 // 'm_ThisEntityAI' and 'this' must be checked because this method is caled from a timer
1758 if ( m_ThisEntityAI && this && IsSwitchedOn() && !m_ThisEntityAI.IsRuined() && CheckWetness() && m_CanWork && !GetGame().IsMissionMainMenu() )
1759 {
1760 bool was_powered = IsWorking();
1762 // Make sure to use only as much % of energy as needed since this function can be called at random.
1763
1764 if ( m_LastUpdateTime == 0 )
1765 {
1768 }
1769 else
1770 {
1773 consumed_energy_coef = time / 1000;
1774 }
1775
1776 if (consumed_energy_coef > 0) // Prevents calling of OnWork events when no energy is consumed
1777 {
1780 bool has_consumed_enough = true;
1781
1782 if (GetGame().IsServer() || !GetGame().IsMultiplayer()) // single player or server side multiplayer
1784
1786
1787 if ( has_consumed_enough )
1788 {
1789 if ( !was_powered )
1790 {
1791 m_CanStopWork = true;
1793 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnWorkStart", NULL, 0);
1794 UpdateCanWork();
1795 }
1796
1798 }
1799 else
1800 {
1801 if ( was_powered )
1802 {
1803 if (m_CanStopWork)
1804 {
1805 m_CanStopWork = false;
1807 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnWorkStop", NULL, 0); // This event is called only once when the device STOPS being powered
1808 UpdateCanWork();
1809
1810 if (m_AutoSwitchOff)
1811 {
1812 SwitchOff();
1813 }
1814 }
1815 }
1816
1817 StopUpdates();
1818 }
1819 }
1820 else
1821 {
1823 }
1824 }
1825 else if (this && m_ThisEntityAI)
1826 {
1827 SetPowered( false );
1828 StopUpdates();
1829
1830 if (m_CanStopWork)
1831 {
1832 m_CanStopWork = false;
1834 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnWorkStop", NULL, 0); // This event is called only once when the device STOPS being powered
1835 UpdateCanWork();
1836
1837 if (m_AutoSwitchOff)
1838 {
1839 SwitchOff();
1840 }
1841 }
1842 }
1843 }
1844 }
void StopUpdates()
Definition ComponentEnergyManager.c:1490
bool m_AutoSwitchOff
Definition ComponentEnergyManager.c:31
void SwitchOff()
Energy manager: Switches OFF the device.
Definition ComponentEnergyManager.c:406
void UpdateCanWork()
Definition ComponentEnergyManager.c:692
void WakeUpWholeBranch(EntityAI original_caller)
Definition ComponentEnergyManager.c:1527
float GetCurrentUpdateTime()
Definition ComponentEnergyManager.c:1741
bool IsWorking()
Energy manager: Returns true if this device is working right now.
Definition ComponentEnergyManager.c:900
void OnWork(float consumed_energy)
Definition ComponentEnergyManager.c:1360
bool m_CanStopWork
Definition ComponentEnergyManager.c:29
bool m_IsPassiveDevice
Definition ComponentEnergyManager.c:26
void RememberLastUpdateTime()
Definition ComponentEnergyManager.c:1736
bool ConsumeEnergy(float amount)
Energy manager: Consumes the given amount of energy. If there is not enough of stored energy in this ...
Definition ComponentEnergyManager.c:894
void SetPowered(bool state)
Definition ComponentEnergyManager.c:1678
void ClearLastUpdateTime()
Definition ComponentEnergyManager.c:1731

Перекрестные ссылки 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() и WakeUpWholeBranch().

Используется в Entity::OnVariablesSynchronized(), SetPassiveState(), SwitchOff() и SwitchOn().

◆ DrawArrow()

Shape DrawArrow ( vector from,
vector to,
float size = 0.5,
int color = 0xFFFFFFFF,
float flags = 0 )
inlineprotected
151 {
152 vector dir = to - from;
153 dir.Normalize();
154 vector dir1 = dir * size;
155 size = size * 0.5;
156
157 vector dir2 = dir.Perpend() * size;
158
159 vector pts[5];
160 pts[0] = from;
161 pts[1] = to;
162 pts[2] = to - dir1 - dir2;
163 pts[3] = to - dir1 + dir2;
164 pts[4] = to;
165
166 return Shape.CreateLines(color, flags, pts, 5);
167 }
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

Перекрестные ссылки vector::Normalize(), vector::Perpend() и Shape.

Используется в DebugUpdate().

◆ Event_OnAwake()

override void Event_OnAwake ( )
inlineprotected
176 {
177 string cfg_item = "CfgVehicles " + m_ThisEntityAI.GetType();
178 string cfg_energy_manager = cfg_item + " EnergyManager ";
179
180 // Read all config parameters
181 m_EnergyUsage = GetGame().ConfigGetFloat(cfg_energy_manager + "energyUsagePerSecond");
182 bool switch_on = GetGame().ConfigGetFloat(cfg_energy_manager + "switchOnAtSpawn");
183 m_AutoSwitchOff = GetGame().ConfigGetFloat(cfg_energy_manager + "autoSwitchOff");
184 m_HasElectricityIcon = GetGame().ConfigGetFloat(cfg_energy_manager + "hasIcon");
185 m_AutoSwitchOffWhenInCargo = GetGame().ConfigGetFloat(cfg_energy_manager + "autoSwitchOffWhenInCargo");
186
187 m_EnergyAtSpawn = GetGame().ConfigGetFloat(cfg_energy_manager + "energyAtSpawn");
189 m_EnergyStorageMax = GetGame().ConfigGetFloat(cfg_energy_manager + "energyStorageMax");
190 m_ReduceMaxEnergyByDamageCoef = GetGame().ConfigGetFloat(cfg_energy_manager + "reduceMaxEnergyByDamageCoef");
191 m_SocketsCount = GetGame().ConfigGetFloat(cfg_energy_manager + "powerSocketsCount");
192
193 m_IsPassiveDevice = GetGame().ConfigGetFloat(cfg_energy_manager + "isPassiveDevice");
194 m_CordLength = GetGame().ConfigGetFloat(cfg_energy_manager + "cordLength");
195 m_PlugType = GetGame().ConfigGetFloat(cfg_energy_manager + "plugType");
196
197 m_AttachmentActionType = GetGame().ConfigGetFloat(cfg_energy_manager + "attachmentAction");
198 m_WetnessExposure = GetGame().ConfigGetFloat(cfg_energy_manager + "wetnessExposure");
199
200 float update_interval = GetGame().ConfigGetFloat(cfg_energy_manager + "updateInterval");
201
202 m_ConvertEnergyToQuantity = GetGame().ConfigGetFloat(cfg_energy_manager + "convertEnergyToQuantity");
203
204
205 // Check if energy->quantity converion is configured properly
206 float cfg_max_quantity = GetGame().ConfigGetFloat (cfg_item + " varQuantityMax");
207
209 {
210 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!";
211 Error(error);
213 }
214 else
215 {
217 {
220
221 m_UpdateQuantityTimer.Run( 0.3 , this, "OnEnergyAdded", NULL, false);
222 }
223 }
224
225 // Set update interval
226 if ( update_interval <= 0 )
228
230
231 // If energyAtSpawn is present, then use its value for energyStorageMax if that cfg param is not present (for convenience's sake)
232 string cfg_check_energy_limit = cfg_energy_manager + "energyStorageMax";
233
234 if ( !GetGame().ConfigIsExisting (cfg_check_energy_limit) && m_Energy > 0 )
235 {
237 }
238
239 // Fill m_CompatiblePlugTypes
240 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
241
242 if ( GetGame().ConfigIsExisting (cfg_check_plug_types) )
243 {
246 }
247
248 if (GetSocketsCount() > 0)
250
251 if ( m_CordLength < 0 )
252 {
253 m_CordLength = 0;
254 string error_message_cord = "Warning! " + m_ThisEntityAI.GetType() + ": config parameter 'cordLength' is less than 0! Cord length should not be negative!";
256 }
257
258 if (GetSocketsCount() > 0)
259 {
261 // Prepare the m_DeviceByPlugSelection
262 string cfg_animation_sources = "cfgVehicles " + m_ThisEntityAI.GetType() + " " + "AnimationSources ";
263 int animation_sources_count = GetGame().ConfigGetChildrenCount(cfg_animation_sources);
264
266 {
267 // TO DO: This could be optimized so not all selections on item are considered as plug/socket selections.
268 string selection;
269 GetGame().ConfigGetChildName(cfg_animation_sources, i_selection, selection);
270 m_DeviceByPlugSelection.Set(selection, NULL);
271 }
272 }
273
274
275
276 // Prepare sockets
278 {
280 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!";
282 }
283
284 m_Sockets[MAX_SOCKETS_COUNT]; // Handles selections for plugs in the sockets. Feel free to change the limit if needed.
285
286 GetGame().ConfigGetText(cfg_energy_manager + "cordTextureFile", m_CordTextureFile);
287
288 if ( switch_on )
289 {
290 SwitchOn();
291 }
292
293 for ( int i = 0; i <= GetSocketsCount(); ++i )
294 {
295 m_ThisEntityAI.HideSelection ( SOCKET_ + i.ToString() + _PLUGGED );
296 }
297
298 // Show/hide inventory sockets
300 if ( GetSocketsCount() > 0 && IsPlugCompatible(PLUG_COMMON_APPLIANCE) && m_ThisEntityAI.GetType() != "MetalWire" ) // metal wire filter is hopefully temporal.
301 {
303 }
304
306
307 m_ThisEntityAI.HideSelection( SEL_CORD_PLUGGED );
308
309
310 #ifdef DIAG_DEVELOPER
311 GetGame().m_EnergyManagerArray.Insert( this );
312 #endif
313 }
const int PLUG_COMMON_APPLIANCE
Definition _constants.c:25
float m_EnergyStorageMax
Definition ComponentEnergyManager.c:51
int m_AttachmentActionType
Definition ComponentEnergyManager.c:44
void SetUpdateInterval(float value)
Energy manager: Sets the interval of the OnWork(...) calls. Changing this value does not change the r...
Definition ComponentEnergyManager.c:723
ref array< EntityAI > m_PluggedDevices
Definition ComponentEnergyManager.c:70
EntityAI m_Sockets[MAX_SOCKETS_COUNT]
Definition ComponentEnergyManager.c:78
const float DEFAULT_UPDATE_INTERVAL
Definition ComponentEnergyManager.c:20
ref TIntArray m_CompatiblePlugTypes
Definition ComponentEnergyManager.c:68
bool m_AutoSwitchOffWhenInCargo
Definition ComponentEnergyManager.c:34
int m_PlugType
Definition ComponentEnergyManager.c:39
bool m_HasElectricityIcon
Definition ComponentEnergyManager.c:33
float m_CordLength
Definition ComponentEnergyManager.c:54
void SwitchOn()
Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
Definition ComponentEnergyManager.c:375
float m_EnergyAtSpawn
Definition ComponentEnergyManager.c:50
string m_CordTextureFile
Definition ComponentEnergyManager.c:59
float m_ReduceMaxEnergyByDamageCoef
Definition ComponentEnergyManager.c:52
float m_SocketsCount
Definition ComponentEnergyManager.c:53
static const string SOCKET_
Definition ComponentEnergyManager.c:62
ref map< string, EntityAI > m_DeviceByPlugSelection
Definition ComponentEnergyManager.c:71
bool HasEnoughStoredEnergy()
Energy manager: Returns true if this device has enough of stored energy for its own use.
Definition ComponentEnergyManager.c:906
const int MAX_SOCKETS_COUNT
Definition ComponentEnergyManager.c:77
int GetSocketsCount()
Energy manager: Returns the count of power sockets (whenever used or not)
Definition ComponentEnergyManager.c:1102
bool m_ShowSocketsInInventory
Definition ComponentEnergyManager.c:32
float m_Energy
Definition ComponentEnergyManager.c:49
bool m_ConvertEnergyToQuantity
Definition ComponentEnergyManager.c:36
static const string _PLUGGED
Definition ComponentEnergyManager.c:63
float m_EnergyUsage
Definition ComponentEnergyManager.c:48
ref Timer m_UpdateQuantityTimer
Definition ComponentEnergyManager.c:74
static const string SEL_CORD_PLUGGED
Definition ComponentEnergyManager.c:65
Definition DayZPlayerImplement.c:63
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
array< int > TIntArray
Definition EnScript.c:687
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

Перекрестные ссылки _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_ и SwitchOn().

◆ Event_OnInit()

override void Event_OnInit ( )
inlineprotected
102 {
103 m_ThisEntityAI.m_EM = this;
104 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnInitEnergy", NULL, 0);
105 }

Перекрестные ссылки GetGame() и Component::m_ThisEntityAI.

◆ FindAndConsumeEnergy()

bool FindAndConsumeEnergy ( EntityAI original_caller,
float amount,
bool ignore_switch_state = false )
inlineprotected
1685 {
1686 if ( (ignore_switch_state || IsSwitchedOn()) && !m_ThisEntityAI.IsRuined() )
1687 {
1688 float available_energy = AddEnergy(-amount);
1689
1690 if ( available_energy < 0 && IsPlugged() )
1691 {
1692 // 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)
1694
1695 if (next_power_source && next_power_source != original_caller) // Prevents infinite loop if the power source is the original caller itself
1696 {
1697 return next_power_source.GetCompEM().FindAndConsumeEnergy( original_caller, -available_energy );
1698 }
1699 }
1700
1701 if ( available_energy >= 0)
1702 {
1703 return true;
1704 }
1705
1706 return false;
1707 }
1708 else
1709 {
1710 return false;
1711 }
1712 }
float AddEnergy(float added_energy)
Energy manager: Adds energy to this device and clamps it within its min/max storage limits....
Definition ComponentEnergyManager.c:1220
bool IsPlugged()
Energy manager: Returns true if this device is plugged into some other device (even if they are OFF o...
Definition ComponentEnergyManager.c:887

Перекрестные ссылки AddEnergy(), GetEnergySource(), IsPlugged(), IsSwitchedOn() и Component::m_ThisEntityAI.

Используется в ConsumeEnergy().

◆ GetAttachmentAction()

int GetAttachmentAction ( )
inlineprotected
1115 {
1117 }

Перекрестные ссылки m_AttachmentActionType.

Используется в OnAttachmentAdded() и OnAttachmentRemoved().

◆ GetCompatiblePlugTypes()

void GetCompatiblePlugTypes ( out TIntArray IDs)
inlineprotected
616 {
618 }

Перекрестные ссылки m_CompatiblePlugTypes.

◆ GetCompType()

override int GetCompType ( )
inlineprotected
317 {
319 }
const int COMP_TYPE_ENERGY_MANAGER
Definition Component.c:9

Перекрестные ссылки COMP_TYPE_ENERGY_MANAGER.

◆ GetCordLength()

float GetCordLength ( )
inlineprotected

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

1287 {
1288 return m_CordLength;
1289 }

Перекрестные ссылки m_CordLength.

Используется в IsEnergySourceAtReach().

◆ GetCordTextureFile()

string GetCordTextureFile ( )
inlineprotected

Energy manager: Returns path to the cord texture file.

1327 {
1328 return m_CordTextureFile;
1329 }

Перекрестные ссылки m_CordTextureFile.

◆ GetCurrentUpdateTime()

float GetCurrentUpdateTime ( )
inlineprotected
1742 {
1743 return GetGame().GetTime();
1744 }

Перекрестные ссылки GetGame().

Используется в DeviceUpdate() и RememberLastUpdateTime().

◆ GetDebugPlugs()

bool GetDebugPlugs ( )
inlineprotected
358 {
359 return m_DebugPlugs;
360 }

Перекрестные ссылки m_DebugPlugs.

Используется в DebugUpdate().

◆ GetDeviceBySocketID()

EntityAI GetDeviceBySocketID ( int id)
inlineprotected

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

1299 {
1300 return m_Sockets[id];
1301 }

Перекрестные ссылки m_Sockets.

Используется в HasFreeSocket(), PlugCordIntoSocket(), UnplugCordFromSocket() и UpdateSelections().

◆ GetEnergy()

float GetEnergy ( )
inlineprotected

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

1215 {
1216 return m_Energy;
1217 }

Перекрестные ссылки m_Energy.

Используется в AddEnergy(), CanWork(), HasEnoughStoredEnergy() и Entity::OnStoreSave().

◆ GetEnergy0To1()

float GetEnergy0To1 ( )
inlineprotected

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

1180 {
1181 if ( m_EnergyStorageMax > 0 )
1182 {
1184 }
1185
1186 return 0;
1187 }

Перекрестные ссылки m_Energy и m_EnergyStorageMax.

◆ GetEnergy0To100()

int GetEnergy0To100 ( )
inlineprotected

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

1168 {
1169 if ( m_EnergyStorageMax > 0 )
1170 {
1171 int coef = Math.Round( m_Energy / m_EnergyStorageMax * 100 );
1172 return coef;
1173 }
1174
1175 return 0;
1176 }
static proto float Round(float f)
Returns mathematical round of value.

Перекрестные ссылки m_Energy, m_EnergyStorageMax и Math::Round().

◆ GetEnergyAtSpawn()

float GetEnergyAtSpawn ( )
inlineprotected
1281 {
1282 return m_EnergyAtSpawn;
1283 }

Перекрестные ссылки m_EnergyAtSpawn.

◆ GetEnergyMax()

float 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.

1253 {
1254 float max_health = 0;
1255
1256 if ( m_ThisEntityAI.HasDamageSystem() )
1257 max_health = m_ThisEntityAI.GetMaxHealth("","");
1258 //else if ( m_ReduceMaxEnergyByDamageCoef != 0 )
1259 // Error("[ERROR] ReduceMaxEnergyByDamageCoef is setup but " + m_ThisEntityAI.GetType() + " does not have a Damage System");
1260
1261 if ( max_health == 0 || m_ReduceMaxEnergyByDamageCoef == 0 )
1262 return GetEnergyMaxPristine();
1263
1264 float health = 100;
1265
1266 if (GetGame().IsServer() || !GetGame().IsMultiplayer()) // TO DO: Remove this IF when method GetHealth can be called on client!
1267 health = m_ThisEntityAI.GetHealth("","");
1268
1269 float damage_coef = 1 - (health / max_health);
1270
1272 }
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Definition ComponentEnergyManager.c:1275

Перекрестные ссылки GetEnergyMaxPristine(), GetGame(), m_ReduceMaxEnergyByDamageCoef и Component::m_ThisEntityAI.

Используется в AddEnergy() и SetEnergy0To1().

◆ GetEnergyMaxPristine()

float GetEnergyMaxPristine ( )
inlineprotected

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

1276 {
1277 return m_EnergyStorageMax;
1278 }

Перекрестные ссылки m_EnergyStorageMax.

Используется в GetEnergyMax().

◆ GetEnergySource()

EntityAI GetEnergySource ( )
inlineprotected

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

1293 {
1294 return m_EnergySource;
1295 }
EntityAI m_EnergySource
Definition ComponentEnergyManager.c:69

Перекрестные ссылки m_EnergySource.

Используется в CanWork(), DebugUpdate(), FindAndConsumeEnergy(), IsEnergySourceAtReach(), OnAttachmentRemoved(), Entity::OnStoreSave(), UnplugThis() и UpdateSelections().

◆ GetEnergySourceNetworkIDHigh()

int GetEnergySourceNetworkIDHigh ( )
inlineprotected
1151 {
1153 }
int m_EnergySourceNetworkIDHigh
Definition ComponentEnergyManager.c:46

Перекрестные ссылки m_EnergySourceNetworkIDHigh.

Используется в Entity::OnVariablesSynchronized().

◆ GetEnergySourceNetworkIDLow()

int GetEnergySourceNetworkIDLow ( )
inlineprotected
1145 {
1147 }
int m_EnergySourceNetworkIDLow
Definition ComponentEnergyManager.c:45

Перекрестные ссылки m_EnergySourceNetworkIDLow.

Используется в Entity::OnVariablesSynchronized().

◆ GetEnergySourceStorageIDb1()

int GetEnergySourceStorageIDb1 ( )
inlineprotected
1121 {
1123 }
int m_EnergySourceStorageIDb1
Definition ComponentEnergyManager.c:40

Перекрестные ссылки m_EnergySourceStorageIDb1.

Используется в Entity::EEOnAfterLoad().

◆ GetEnergySourceStorageIDb2()

int GetEnergySourceStorageIDb2 ( )
inlineprotected
1127 {
1129 }
int m_EnergySourceStorageIDb2
Definition ComponentEnergyManager.c:41

Перекрестные ссылки m_EnergySourceStorageIDb2.

Используется в Entity::EEOnAfterLoad().

◆ GetEnergySourceStorageIDb3()

int GetEnergySourceStorageIDb3 ( )
inlineprotected
1133 {
1135 }
int m_EnergySourceStorageIDb3
Definition ComponentEnergyManager.c:42

Перекрестные ссылки m_EnergySourceStorageIDb3.

Используется в Entity::EEOnAfterLoad().

◆ GetEnergySourceStorageIDb4()

int GetEnergySourceStorageIDb4 ( )
inlineprotected
1139 {
1141 }
int m_EnergySourceStorageIDb4
Definition ComponentEnergyManager.c:43

Перекрестные ссылки m_EnergySourceStorageIDb4.

Используется в Entity::EEOnAfterLoad().

◆ GetEnergyUsage()

float GetEnergyUsage ( )
inlineprotected

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

1209 {
1210 return m_EnergyUsage;
1211 }

Перекрестные ссылки m_EnergyUsage.

Используется в CanWork(), DeviceUpdate(), HasEnoughStoredEnergy() и SetEnergy().

◆ GetMySocketID()

int GetMySocketID ( )
inlineprotected
1716 {
1717 return m_MySocketID;
1718 }
int m_MySocketID
Definition ComponentEnergyManager.c:38

Перекрестные ссылки m_MySocketID.

◆ GetPluggedDevice()

EntityAI 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.

1316 {
1317 if ( GetPluggedDevicesCount() > 0 )
1318 {
1319 return GetPluggedDevices().Get(0);
1320 }
1321
1322 return NULL;
1323 }
array< EntityAI > GetPluggedDevices()
Energy manager: Returns an array of devices which are plugged into this one.
Definition ComponentEnergyManager.c:1332
int GetPluggedDevicesCount()
Energy manager: Returns the number of devices plugged into this one.
Definition ComponentEnergyManager.c:1156

Перекрестные ссылки GetPluggedDevices() и GetPluggedDevicesCount().

◆ GetPluggedDevices()

array< EntityAI > GetPluggedDevices ( )
inlineprotected

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

1333 {
1334 return m_PluggedDevices;
1335 }

Перекрестные ссылки m_PluggedDevices.

Используется в GetPluggedDevice(), GetPluggedDevicesCount(), GetPoweredDevices(), InteractBranch(), IsSelectionAPlug(), PlugInDevice(), UnplugAllDevices(), UnplugDevice() и WakeUpWholeBranch().

◆ GetPluggedDevicesCount()

int GetPluggedDevicesCount ( )
inlineprotected

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

1157 {
1158 if ( GetPluggedDevices() )
1159 {
1160 return GetPluggedDevices().Count();
1161 }
1162
1163 return 0;
1164 }

Перекрестные ссылки GetPluggedDevices().

Используется в GetPluggedDevice(), GetPoweredDevices(), HasFreeSocket(), UnplugAllDevices() и UnplugDevice().

◆ GetPlugOwner()

EntityAI GetPlugOwner ( string plug_selection_name)
inlineprotected

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

1305 {
1307 {
1309 }
1310
1311 return NULL;
1312 }

Перекрестные ссылки m_DeviceByPlugSelection.

◆ GetPlugType()

int GetPlugType ( )
inlineprotected

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

1109 {
1110 return m_PlugType;
1111 }

Перекрестные ссылки m_PlugType.

◆ GetPoweredDevices()

array< EntityAI > GetPoweredDevices ( )
inlineprotected

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

1339 {
1342 for ( int i = 0; i < plugged_devices_c; ++i )
1343 {
1345 if ( IsSwitchedOn() )
1346 {
1347 return_array.Insert(device);
1348 }
1349 }
1350
1351 return return_array;
1352 }

Перекрестные ссылки GetPluggedDevices(), GetPluggedDevicesCount() и IsSwitchedOn().

◆ GetPreviousSwitchState()

bool GetPreviousSwitchState ( )
inlineprotected
861 {
863 }
bool m_IsSwichedOnPreviousState
Definition ComponentEnergyManager.c:25

Перекрестные ссылки m_IsSwichedOnPreviousState.

Используется в Entity::OnVariablesSynchronized().

◆ GetRestorePlugState()

bool GetRestorePlugState ( )
inlineprotected
730 {
731 return m_RestorePlugState;
732 }
bool m_RestorePlugState
Definition ComponentEnergyManager.c:30

Перекрестные ссылки m_RestorePlugState.

Используется в Entity::EEOnAfterLoad().

◆ GetSocketsCount()

int GetSocketsCount ( )
inlineprotected

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

1103 {
1104 return m_SocketsCount;
1105 }

Перекрестные ссылки m_SocketsCount.

Используется в Event_OnAwake(), HasFreeSocket(), InteractBranch(), IsSelectionAPlug(), PlugCordIntoSocket(), UpdateSelections() и WakeUpWholeBranch().

◆ GetThisEntityAI()

EntityAI GetThisEntityAI ( )
inlineprotected
170 {
171 return m_ThisEntityAI;
172 }

Перекрестные ссылки Component::m_ThisEntityAI.

◆ GetUpdateInterval()

float GetUpdateInterval ( )
inlineprotected

Energy manager: Returns the update interval of this device.

1191 {
1192 #ifdef DIAG_DEVELOPER
1193 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_CONSUMPTION) || (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_RECHARGE)))
1194 {
1195 return 1;//when modifying time accel, we might want to see things happen when they should, instead of waiting for the next tick
1196 }
1197 #endif
1198 return m_UpdateInterval;
1199 }
float m_UpdateInterval
Definition ComponentEnergyManager.c:57

Перекрестные ссылки m_UpdateInterval.

Используется в StartUpdates().

◆ GetWetnessExposure()

float GetWetnessExposure ( )
inlineprotected

Returns wetness exposure value defined in config.

1203 {
1204 return m_WetnessExposure;
1205 }

Перекрестные ссылки m_WetnessExposure.

◆ HandleMoveInsideCargo()

void HandleMoveInsideCargo ( EntityAI container)
inlineprotected
712 {
714 {
715 if (IsSwitchedOn())
716 {
717 SwitchOff();
718 }
719 }
720 }

Перекрестные ссылки IsSwitchedOn(), m_AutoSwitchOffWhenInCargo и SwitchOff().

Используется в Entity::OnMovedInsideCargo().

◆ HasConversionOfEnergyToQuantity()

bool HasConversionOfEnergyToQuantity ( )
inlineprotected

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

1011 {
1013 }

Перекрестные ссылки m_ConvertEnergyToQuantity.

◆ HasElectricityIcon()

bool HasElectricityIcon ( )
inlineprotected

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

1005 {
1006 return m_HasElectricityIcon;
1007 }

Перекрестные ссылки m_HasElectricityIcon.

◆ HasEnoughStoredEnergy()

bool HasEnoughStoredEnergy ( )
inlineprotected

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

907 {
908 if ( GetEnergy() > GetEnergyUsage() )
909 {
910 return true;
911 }
912
913 return false;
914 }

Перекрестные ссылки GetEnergy() и GetEnergyUsage().

Используется в Event_OnAwake().

◆ HasFreeSocket()

bool 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.

918 {
919 if (socket_id == -1)
920 {
923
925 {
926 return true;
927 }
928
929 return false;
930 }
931 else
932 {
934
935 if (device)
936 {
937 return false;
938 }
939 else
940 {
941 return true;
942 }
943 }
944 }
EntityAI GetDeviceBySocketID(int id)
Energy manager: Returns the device which is plugged into the given socket ID.
Definition ComponentEnergyManager.c:1298

Перекрестные ссылки GetDeviceBySocketID(), GetPluggedDevicesCount() и GetSocketsCount().

Используется в CanReceivePlugFrom().

◆ HasVisibleSocketsInInventory()

bool HasVisibleSocketsInInventory ( )
inlineprotected
1073 {
1075 }

Перекрестные ссылки m_ShowSocketsInInventory.

◆ InteractBranch()

void 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

1503 {
1505 if ( GetSocketsCount() > 0 )
1506 {
1508
1509 foreach ( EntityAI device : devices)
1510 {
1511 if ( device != originalCaller ) // originalCaller check here prevents infinite loops
1512 {
1513 device.GetCompEM().InteractBranch( originalCaller, player, system );
1514 }
1515 }
1516 }
1517 }
void OnInteractBranch(EntityAI originalCaller, Man player, int system)
Called when the player is interacting with an item containing this energy component,...
Definition ComponentEnergyManager.c:1520

Перекрестные ссылки GetPluggedDevices(), GetSocketsCount() и OnInteractBranch().

Используется в PlugInDevice().

◆ IsCordFolded()

bool IsCordFolded ( )
inlineprotected

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

873 {
874 if ( IsPlugged() )
875 return false;
876
877 return true;
878 }

Перекрестные ссылки IsPlugged().

◆ IsEnergySourceAtReach()

bool 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.

Аргументы
from_positionvector position from where the measurement will be taken
add_tolerancefloat parameter will add to the cord's length in meters (optional)
Возвращает
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.
1032 {
1033 if ( !IsPlugged() && override_source_position == "-1 -1 -1" )
1034 {
1035 return false;
1036 }
1037
1038 if ( GetCordLength() == 0 ) // 0 is an exception, which means infinitely long cable.
1039 {
1040 return true;
1041 }
1042
1044 float distance;
1045
1046 if ( override_source_position == "-1 -1 -1" )
1047 {
1049
1050 if (!energy_source)
1051 return false;
1052
1053 source_pos = energy_source.GetPosition();
1055 }
1056 else
1057 {
1060 }
1061
1063 {
1064 return false;
1065 }
1066 else
1067 {
1068 return true;
1069 }
1070 }
float GetCordLength()
Energy manager: Returns the length of the virtual power cord.
Definition ComponentEnergyManager.c:1286
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

Перекрестные ссылки vector::Distance(), GetCordLength(), GetEnergySource() и IsPlugged().

Используется в UpdatePlugState().

◆ IsPassive()

bool IsPassive ( )
inlineprotected

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

882 {
883 return m_IsPassiveDevice;
884 }

Перекрестные ссылки m_IsPassiveDevice.

Используется в CanSwitchOff() и Entity::OnStoreSave().

◆ IsPlugCompatible()

bool IsPlugCompatible ( int plug_ID)
inlineprotected

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

948 {
949 if ( plug_ID == PLUG_UNDEFINED )
950 {
951 return true; // When plugType is undefined in config then make it compatible.
952 }
953
955 {
956 for ( int i = 0; i < m_CompatiblePlugTypes.Count(); i++ )
957 {
959
960 if ( plug_ID_to_Check == plug_ID )
961 {
962 return true;
963 }
964 }
965 }
966 else
967 {
968 // Since the config parameter compatiblePlugTypes is not present, then accept all plugs for simplicity's sake
969 return true;
970 }
971
972 return false;
973 }
const int PLUG_UNDEFINED
Definition _constants.c:23

Перекрестные ссылки m_CompatiblePlugTypes и PLUG_UNDEFINED.

Используется в CanReceivePlugFrom() и Event_OnAwake().

◆ IsPlugged()

bool 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.

888 {
889 return m_IsPlugged;
890 }
bool m_IsPlugged
Definition ComponentEnergyManager.c:35

Перекрестные ссылки m_IsPlugged.

Используется в FindAndConsumeEnergy(), IsCordFolded(), IsEnergySourceAtReach() и Entity::OnStoreSave().

◆ IsSelectionAPlug()

bool 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.

1079 {
1080 if ( GetPluggedDevices() )
1081 {
1083
1084 for ( int i = socket_count; i >= 0; --i )
1085 {
1086 string real_selection = SOCKET_ + i.ToString() +_PLUGGED;
1087
1089 {
1090 return true;
1091 }
1092 }
1093 }
1094
1095 return false;
1096 }

Перекрестные ссылки _PLUGGED, GetPluggedDevices(), GetSocketsCount() и SOCKET_.

◆ IsSwitchedOn()

bool 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.

867 {
868 return m_IsSwichedOn;
869 }
bool m_IsSwichedOn
Definition ComponentEnergyManager.c:24

Перекрестные ссылки m_IsSwichedOn.

Используется в CanSwitchOff(), CanSwitchOn(), DeviceUpdate(), FindAndConsumeEnergy(), GetPoweredDevices(), HandleMoveInsideCargo(), Entity::OnStoreSave() и Entity::OnVariablesSynchronized().

◆ IsWorking()

bool IsWorking ( )
inlineprotected

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

901 {
902 return m_IsWorking;
903 }
bool m_IsWorking
Definition ComponentEnergyManager.c:27

Перекрестные ссылки m_IsWorking.

Используется в DeviceUpdate(), Entity::IsIgnited() и SwitchOff().

◆ OnAttachmentAdded()

void OnAttachmentAdded ( EntityAI elec_device)
inlineprotected
1417 {
1419
1421 {
1422 if ( elec_device.GetCompEM().CanReceivePlugFrom( m_ThisEntityAI ) )
1423 {
1425 }
1426 }
1428 {
1429 elec_device.GetCompEM().PlugThisInto(m_ThisEntityAI);
1430 }
1431 }
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...
Definition ComponentEnergyManager.c:735
int GetAttachmentAction()
Definition ComponentEnergyManager.c:1114

Перекрестные ссылки GetAttachmentAction(), Component::m_ThisEntityAI, PLUG_ATTACHMENTS_INTO_THIS, PLUG_THIS_INTO_ATTACHMENT и PlugThisInto().

Используется в Entity::EEItemAttached().

◆ OnAttachmentRemoved()

void OnAttachmentRemoved ( EntityAI elec_device)
inlineprotected
1435 {
1437
1439 {
1440 if ( elec_device == GetEnergySource() )
1441 {
1442 UnplugThis();
1443 }
1444 }
1446 {
1447 elec_device.GetCompEM().UnplugThis();
1448 }
1449 }
void UnplugThis()
Energy manager: Unplugs this device from its power source.
Definition ComponentEnergyManager.c:494

Перекрестные ссылки GetAttachmentAction(), GetEnergySource(), PLUG_ATTACHMENTS_INTO_THIS, PLUG_THIS_INTO_ATTACHMENT и UnplugThis().

Используется в Entity::EEItemDetached().

◆ OnDeviceDestroyed()

void OnDeviceDestroyed ( )
inlineprotected
323 {
324 bool was_working = m_ThisEntityAI.GetCompEM().IsWorking();
325
326 SwitchOff();
328 UnplugThis();
329 SetPowered( false );
330
331 if ( was_working )
332 m_ThisEntityAI.OnWorkStop();
333 ;
334 }
void UnplugAllDevices()
Energy manager: Unplugs everything directly connected to this device.
Definition ComponentEnergyManager.c:506

Перекрестные ссылки Component::m_ThisEntityAI, SetPowered(), SwitchOff(), UnplugAllDevices() и UnplugThis().

Используется в Entity::EEDelete().

◆ OnEnergyAdded()

void OnEnergyAdded ( )
inlineprotected

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

1474 {
1476 {
1477 m_UpdateQuantityTimer.Stop();
1479 }
1480
1481 m_ThisEntityAI.OnEnergyAdded();
1482 }

Перекрестные ссылки Component::m_ThisEntityAI и m_UpdateQuantityTimer.

Используется в AddEnergy().

◆ OnEnergyConsumed()

void OnEnergyConsumed ( )
inlineprotected

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

1468 {
1469 m_ThisEntityAI.OnEnergyConsumed();
1470 }

Перекрестные ссылки Component::m_ThisEntityAI.

Используется в AddEnergy().

◆ OnInteractBranch()

void 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.

1521 {
1522 m_ThisEntityAI.IncreaseLifetime();
1523
1524 }

Перекрестные ссылки Component::m_ThisEntityAI.

Используется в InteractBranch().

◆ OnIsPlugged()

void OnIsPlugged ( EntityAI source_device)
inlineprotected
1367 {
1368 if (m_DebugPlugs)
1369 {
1370 if (!m_DebugUpdate)
1372
1373 if (!m_DebugUpdate.IsRunning())
1374 m_DebugUpdate.Run(0.01, this, "DebugUpdate", NULL, true);
1375 }
1376
1377 UpdateCanWork();
1378 m_ThisEntityAI.OnIsPlugged(source_device);
1379 }

Перекрестные ссылки CALL_CATEGORY_SYSTEM, m_DebugPlugs, m_DebugUpdate, Component::m_ThisEntityAI и UpdateCanWork().

◆ OnIsUnplugged()

void OnIsUnplugged ( EntityAI last_energy_source)
inlineprotected
1383 {
1384 UpdateCanWork();
1385 m_ThisEntityAI.OnIsUnplugged( last_energy_source );
1386 }

Перекрестные ссылки Component::m_ThisEntityAI и UpdateCanWork().

◆ OnOwnSocketReleased()

void OnOwnSocketReleased ( EntityAI device)
inlineprotected
1403 {
1404 //play sound
1405 if ( device.GetCompEM().GetPlugType() == PLUG_COMMON_APPLIANCE && m_ThisEntityAI.IsInitialized() )
1406 {
1408 m_ThisEntityAI.PlaySoundSet( sound_unplug, "cablereel_unplug_SoundSet", 0, 0 );
1409 }
1410
1411 m_ThisEntityAI.OnOwnSocketReleased( device );
1412 }
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5

Перекрестные ссылки Component::m_ThisEntityAI и PLUG_COMMON_APPLIANCE.

Используется в UnplugDevice().

◆ OnOwnSocketTaken()

void OnOwnSocketTaken ( EntityAI device)
inlineprotected
1390 {
1391 //play sound
1392 if ( device.GetCompEM().GetPlugType() == PLUG_COMMON_APPLIANCE && m_ThisEntityAI.IsInitialized() )
1393 {
1395 m_ThisEntityAI.PlaySoundSet( sound_plug, "cablereel_plugin_SoundSet", 0, 0 );
1396 }
1397
1398 m_ThisEntityAI.OnOwnSocketTaken(device);
1399 }

Перекрестные ссылки Component::m_ThisEntityAI и PLUG_COMMON_APPLIANCE.

Используется в PlugInDevice().

◆ OnWork()

void OnWork ( float consumed_energy)
inlineprotected
1361 {
1363 }

Перекрестные ссылки Component::m_ThisEntityAI.

Используется в DeviceUpdate().

◆ PlugCordIntoSocket()

void PlugCordIntoSocket ( EntityAI device_to_plug,
int socket_id = -1 )
inlineprotected
1551 {
1552 if (socket_id >= 0)
1553 {
1555
1557 {
1559 return;
1560 }
1561 }
1562
1563 int slots_c = GetSocketsCount();
1564
1565 for ( int i = 0; i < slots_c; ++i )
1566 {
1568
1569 if ( !plug_owner ) // Check if this socket is available
1570 {
1572 break;
1573 }
1574 }
1575 }
void UpdateSocketSelections(int socket_id, EntityAI device_to_plug)
Definition ComponentEnergyManager.c:1578

Перекрестные ссылки GetDeviceBySocketID(), GetSocketsCount() и UpdateSocketSelections().

Используется в PlugInDevice().

◆ PlugInDevice()

bool PlugInDevice ( EntityAI device_to_plug,
int socket_id = -1 )
inlineprotected
1620 {
1622 {
1623 device_to_plug.IncreaseLifetime();
1625 if (device_to_plug.GetCompEM().IsPlugged())
1626 device_to_plug.GetCompEM().UnplugThis();
1627
1629 device_to_plug.GetCompEM().SetEnergySource(m_ThisEntityAI);
1630
1631 PlugCordIntoSocket(device_to_plug, socket_id); // Visualisation
1633
1634 device_to_plug.GetCompEM().OnIsPlugged(m_ThisEntityAI);
1636
1637 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
1638 {
1639 device_to_plug.HideSelection(SEL_CORD_FOLDED);
1640 device_to_plug.ShowSelection(SEL_CORD_PLUGGED);
1641 }
1642
1643 return true;
1644 }
1645
1646 return false;
1647 }
void InteractBranch(EntityAI originalCaller, Man player=null, int system=0)
Definition ComponentEnergyManager.c:1502
static const string SEL_CORD_FOLDED
Definition ComponentEnergyManager.c:66
void OnOwnSocketTaken(EntityAI device)
Definition ComponentEnergyManager.c:1389
bool CanReceivePlugFrom(EntityAI device_to_plug)
Energy manager: Returns true if this device can receive power plug of the other device.
Definition ComponentEnergyManager.c:976
void PlugCordIntoSocket(EntityAI device_to_plug, int socket_id=-1)
Definition ComponentEnergyManager.c:1550

Перекрестные ссылки CanReceivePlugFrom(), GetGame(), GetPluggedDevices(), InteractBranch(), Component::m_ThisEntityAI, OnOwnSocketTaken(), PlugCordIntoSocket(), SEL_CORD_FOLDED, SEL_CORD_PLUGGED и WakeUpWholeBranch().

◆ PlugThisInto()

bool 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.

736 {
737 return energy_source.GetCompEM().PlugInDevice(m_ThisEntityAI, socket_id);
738 }

Перекрестные ссылки Component::m_ThisEntityAI.

Используется в Entity::EEOnAfterLoad(), OnAttachmentAdded() и Entity::OnVariablesSynchronized().

◆ RefreshDebug()

void RefreshDebug ( )
inlineprotected
338 {
339 if ( m_DebugPlugs )
340 {
341 if ( !m_DebugUpdate )
343
344 if ( !m_DebugUpdate.IsRunning() )
345 m_DebugUpdate.Run(0.01, this, "DebugUpdate", NULL, true);
346 }
347 else
348 {
349 if ( m_DebugPlugArrow )
350 {
351 m_DebugPlugArrow.Destroy();
353 }
354 }
355 }

Перекрестные ссылки CALL_CATEGORY_SYSTEM, m_DebugPlugArrow, m_DebugPlugs и m_DebugUpdate.

Используется в SetDebugPlugs().

◆ RememberLastUpdateTime()

void RememberLastUpdateTime ( )
inlineprotected
1737 {
1739 }

Перекрестные ссылки GetCurrentUpdateTime() и m_LastUpdateTime.

Используется в DeviceUpdate().

◆ ResetEnergyUsage()

void ResetEnergyUsage ( )
inlineprotected

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

661 {
662 string cfg_energy_usage = "CfgVehicles " + m_ThisEntityAI.GetType() + " EnergyManager ";
663 m_EnergyUsage = GetGame().ConfigGetFloat (cfg_energy_usage + "energyUsagePerSecond");
664 }

Перекрестные ссылки GetGame(), m_EnergyUsage и Component::m_ThisEntityAI.

◆ RestorePlugState()

void RestorePlugState ( bool state)
inlineprotected
520 {
522 }

Перекрестные ссылки m_RestorePlugState.

Используется в Entity::OnStoreLoad().

◆ SetAttachmentAction()

void SetAttachmentAction ( int new_action_type)
inlineprotected

Перекрестные ссылки m_AttachmentActionType.

◆ SetCordLength()

void SetCordLength ( float new_length)
inlineprotected

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

637 {
639 }

Перекрестные ссылки m_CordLength.

◆ SetCordTextureFile()

void SetCordTextureFile ( string new_path)
inlineprotected
668 {
670 }

Перекрестные ссылки m_CordTextureFile.

◆ SetDebugPlugs()

void SetDebugPlugs ( bool newVal)
inlineprotected
363 {
365 RefreshDebug();
366 }
void RefreshDebug()
Definition ComponentEnergyManager.c:337

Перекрестные ссылки m_DebugPlugs и RefreshDebug().

◆ SetDeviceBySocketID()

void SetDeviceBySocketID ( int id,
EntityAI plugged_device )
inlineprotected

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

680 {
682 }

Перекрестные ссылки m_Sockets.

Используется в UnplugCordFromSocket() и UpdateSocketSelections().

◆ SetElectricityIconVisibility()

void SetElectricityIconVisibility ( bool make_visible)
inlineprotected

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

687 {
689 }

Перекрестные ссылки m_HasElectricityIcon.

◆ SetEnergy()

void SetEnergy ( float new_energy)
inlineprotected

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

526 {
527 if (GetGame().IsServer() || !GetGame().IsMultiplayer()) // Client can't change energy value.
528 {
529 m_ThisEntityAI.SetWeightDirty();
530 float old_energy = m_Energy;
532
534 {
536 }
537 }
538 }
static proto float Min(float x, float y)
Returns smaller of two given values.

Перекрестные ссылки GetEnergyUsage(), GetGame(), m_Energy, Component::m_ThisEntityAI, Math::Min() и UpdateCanWork().

Используется в AddEnergy(), Entity::OnStoreLoad() и SetEnergy0To1().

◆ SetEnergy0To1()

void 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.

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

Перекрестные ссылки GetEnergyMax(), Math::Lerp() и SetEnergy().

◆ SetEnergyMaxPristine()

void SetEnergyMaxPristine ( float new_limit)
inlineprotected

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

631 {
633 }

Перекрестные ссылки m_EnergyStorageMax.

◆ SetEnergySource()

void SetEnergySource ( EntityAI source)
inlineprotected
1597 {
1599
1600 if (source)
1601 {
1602 m_IsPlugged = true;
1603 StartUpdates();
1604 }
1605 else
1606 {
1607 m_IsPlugged = false;
1610 }
1611
1612 if (m_EnergySource)
1614
1615 Synch();
1616 }
void Synch()
Definition ComponentEnergyManager.c:1726

Перекрестные ссылки m_EnergySource, m_EnergySourceNetworkIDHigh, m_EnergySourceNetworkIDLow, m_IsPlugged, StartUpdates() и Synch().

Используется в SetEnergySourceClient().

◆ SetEnergySourceClient()

void SetEnergySourceClient ( EntityAI source)
inlineprotected
674 {
676 }
void SetEnergySource(EntityAI source)
Definition ComponentEnergyManager.c:1596

Перекрестные ссылки SetEnergySource().

◆ SetEnergyUsage()

void SetEnergyUsage ( float new_usage)
inlineprotected

Energy manager: Changes the energy usage per second.

655 {
657 }

Перекрестные ссылки m_EnergyUsage.

◆ SetMySocketID()

void SetMySocketID ( int slot_ID)
inlineprotected
1722 {
1724 }

Перекрестные ссылки m_MySocketID.

◆ SetPassiveState()

void 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.

442 {
444 if ( !m_IsPassiveDevice )
445 {
446 DeviceUpdate();
447 }
448 }
void DeviceUpdate()
Definition ComponentEnergyManager.c:1747

Перекрестные ссылки DeviceUpdate() и m_IsPassiveDevice.

Используется в Entity::OnStoreLoad().

◆ SetPlugOwner()

void SetPlugOwner ( string selection_name,
EntityAI device )
inlineprotected
1651 {
1653 {
1655 }
1656 }

Перекрестные ссылки m_DeviceByPlugSelection.

Используется в UnplugCordFromSocket() и UpdateSocketSelections().

◆ SetPlugType()

void SetPlugType ( int new_type)
inlineprotected
643 {
645 }

Перекрестные ссылки m_PlugType.

◆ SetPowered()

void SetPowered ( bool state)
inlineprotected
1679 {
1681 }

Перекрестные ссылки m_IsWorking.

Используется в DeviceUpdate() и OnDeviceDestroyed().

◆ SetUpdateInterval()

void SetUpdateInterval ( float value)
inlineprotected

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

724 {
726 }

Перекрестные ссылки m_UpdateInterval.

Используется в Event_OnAwake().

◆ StartUpdates()

void StartUpdates ( )
inlineprotected
1453 {
1454 if (!m_IsPassiveDevice)
1455 {
1456 if (!m_UpdateTimer)
1458
1459 if (!m_UpdateTimer.IsRunning()) // Makes sure the timer is NOT running already
1460 {
1461 m_UpdateTimer.Run(GetUpdateInterval(), this, "DeviceUpdate", null, true);
1462 }
1463 }
1464 }
float GetUpdateInterval()
Energy manager: Returns the update interval of this device.
Definition ComponentEnergyManager.c:1190
ref Timer m_UpdateTimer
Definition ComponentEnergyManager.c:73

Перекрестные ссылки CALL_CATEGORY_SYSTEM, GetUpdateInterval(), m_IsPassiveDevice и m_UpdateTimer.

Используется в AddEnergy(), Entity::OnVariablesSynchronized(), SetEnergySource() и SwitchOn().

◆ StopUpdates()

void StopUpdates ( )
inlineprotected
1491 {
1492 if (m_UpdateTimer)
1493 {
1494 m_UpdateTimer.Stop();
1495 m_UpdateTimer = NULL; // Delete timer from memory
1496 }
1497 }

Перекрестные ссылки m_UpdateTimer.

Используется в DeviceUpdate() и SwitchOff().

◆ StoreEnergySourceIDs()

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

◆ SwitchOff()

void SwitchOff ( )
inlineprotected

Energy manager: Switches OFF the device.

407 {
409
410 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
411 {
412 if ( CanSwitchOff() )
413 {
414 m_IsSwichedOn = false;
415 Synch();
416
417 if ( IsWorking() )
418 {
419 StopUpdates();
420 DeviceUpdate();
421 }
422
423 // 'Wakes up' all connected devices
425
427
428 // Call event
429 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOff", NULL, 0);
430 }
431 }
432
433 if ( !GetGame().IsServer() && GetGame().IsMultiplayer() )
434 {
435 m_IsSwichedOn = false;
436 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOff", NULL, 0);
437 }
438 }
bool CanSwitchOff()
Energy manager: Checks if the device can be switched OFF.
Definition ComponentEnergyManager.c:849

Перекрестные ссылки CanSwitchOff(), DeviceUpdate(), GetGame(), IsWorking(), m_IsSwichedOn, m_IsSwichedOnPreviousState, Component::m_ThisEntityAI, StopUpdates(), Synch(), UpdateCanWork() и WakeUpWholeBranch().

Используется в DeviceUpdate(), HandleMoveInsideCargo(), OnDeviceDestroyed() и Entity::OnVariablesSynchronized().

◆ SwitchOn()

void SwitchOn ( )
inlineprotected

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

376 {
378
379 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
380 {
381 if ( CanSwitchOn() )
382 {
383 m_IsSwichedOn = true;
384 Synch();
385
386 DeviceUpdate(); // 'Wake up' this device now
387 StartUpdates();
388
389 // 'Wakes up' all connected devices
391
393
394 // Call event
395 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOn", NULL, 0);
396 }
397 }
398
399 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.)
400 {
401 GetGame().GameScript.CallFunction(m_ThisEntityAI, "OnSwitchOn", NULL, 0);
402 }
403 }
bool CanSwitchOn()
Energy manager: Checks if the device can be switched ON.
Definition ComponentEnergyManager.c:741

Перекрестные ссылки CanSwitchOn(), DeviceUpdate(), GetGame(), m_IsSwichedOn, m_IsSwichedOnPreviousState, Component::m_ThisEntityAI, StartUpdates(), Synch(), UpdateCanWork() и WakeUpWholeBranch().

Используется в Event_OnAwake(), Entity::OnStoreLoad() и Entity::OnVariablesSynchronized().

◆ Synch()

void Synch ( )
inlineprotected
1727 {
1728 m_ThisEntityAI.SetSynchDirty();
1729 }

Перекрестные ссылки Component::m_ThisEntityAI.

Используется в SetEnergySource(), SwitchOff(), SwitchOn() и UpdateCanWork().

◆ UnplugAllDevices()

void UnplugAllDevices ( )
inlineprotected

Energy manager: Unplugs everything directly connected to this device.

507 {
508 if ( GetPluggedDevices() ) // This check is necesarry in case this function is called before initialization
509 {
511 for (int i = indexStart; i >= 0; --i)
512 {
514 }
515 }
516 }
array< ref PlayerStatBase > Get()
Definition PlayerStatsPCO.c:103
void UnplugDevice(EntityAI device_to_unplug)
Energy manager: Unplugs the given device from this one.
Definition ComponentEnergyManager.c:451

Перекрестные ссылки Get(), GetPluggedDevices(), GetPluggedDevicesCount() и UnplugDevice().

Используется в OnDeviceDestroyed().

◆ UnplugCordFromSocket()

void UnplugCordFromSocket ( int socket_to_unplug_ID)
inlineprotected
1661 {
1663
1664 if ( plug_owner )
1665 {
1668 m_ThisEntityAI.ShowSelection ( unplugged_selection );
1669
1671 m_ThisEntityAI.HideSelection ( plugged_selection );
1673 plug_owner.GetCompEM().SetMySocketID(-1);
1674 }
1675 }
proto string ToString()
void SetDeviceBySocketID(int id, EntityAI plugged_device)
Energy manager: Stores the device which is plugged into the given socket ID.
Definition ComponentEnergyManager.c:679
static const string _AVAILABLE
Definition ComponentEnergyManager.c:64
void SetPlugOwner(string selection_name, EntityAI device)
Definition ComponentEnergyManager.c:1650

Перекрестные ссылки _AVAILABLE, _PLUGGED, GetDeviceBySocketID(), Component::m_ThisEntityAI, SetDeviceBySocketID(), SetPlugOwner(), SOCKET_ и ToString().

Используется в UnplugDevice().

◆ UnplugDevice()

void UnplugDevice ( EntityAI device_to_unplug)
inlineprotected

Energy manager: Unplugs the given device from this one.

452 {
453 if ( GetGame() )
454 {
456 bool deviceFound = false;
457
458 for (int i = indexStart; i >= 0; --i)
459 {
461
463 {
464 GetPluggedDevices().Remove(i);
465 deviceFound = true;
466 break;
467 }
468 }
469
470 if (deviceFound)
471 {
472 int socket_ID = device_to_unplug.GetCompEM().GetMySocketID();
474 device_to_unplug.GetCompEM().SetEnergySource(null);
475 device_to_unplug.GetCompEM().DeviceUpdate();
476 device_to_unplug.GetCompEM().StartUpdates();
477 device_to_unplug.GetCompEM().WakeUpWholeBranch(m_ThisEntityAI);
478
480 {
481 m_DebugPlugArrow.Destroy();
483 }
484
486 device_to_unplug.GetCompEM().OnIsUnplugged(m_ThisEntityAI);
487 device_to_unplug.ShowSelection(SEL_CORD_FOLDED);
488 device_to_unplug.HideSelection(SEL_CORD_PLUGGED);
489 }
490 }
491 }
void OnOwnSocketReleased(EntityAI device)
Definition ComponentEnergyManager.c:1402
void UnplugCordFromSocket(int socket_to_unplug_ID)
Definition ComponentEnergyManager.c:1660

Перекрестные ссылки GetGame(), GetPluggedDevices(), GetPluggedDevicesCount(), m_DebugPlugArrow, m_DebugPlugs, Component::m_ThisEntityAI, OnOwnSocketReleased(), SEL_CORD_FOLDED, SEL_CORD_PLUGGED и UnplugCordFromSocket().

Используется в UnplugAllDevices().

◆ UnplugThis()

void UnplugThis ( )
inlineprotected

Energy manager: Unplugs this device from its power source.

495 {
496 if (GetGame())
497 {
498 if (GetEnergySource())
499 {
500 GetEnergySource().GetCompEM().UnplugDevice(m_ThisEntityAI);
501 }
502 }
503 }

Перекрестные ссылки GetEnergySource(), GetGame() и Component::m_ThisEntityAI.

Используется в OnAttachmentRemoved(), OnDeviceDestroyed(), Entity::OnVariablesSynchronized() и UpdatePlugState().

◆ UpdateCanWork()

void UpdateCanWork ( )
inlineprotected
693 {
694 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
695 {
696 bool current_state = CanWork();
697
699 {
701 Synch();
702
703 if ( m_ThisEntityAI && m_ThisEntityAI.GetHierarchyParent() && m_ThisEntityAI.GetHierarchyParent().GetCompEM() )
704 {
705 m_ThisEntityAI.GetHierarchyParent().GetCompEM().UpdateCanWork();
706 }
707 }
708 }
709 }
bool CanWork(float test_energy=-1)
Energy manager: Checks whenever this device can do work or not.
Definition ComponentEnergyManager.c:757

Перекрестные ссылки CanWork(), GetGame(), m_CanWork, Component::m_ThisEntityAI и Synch().

Используется в DeviceUpdate(), OnIsPlugged(), OnIsUnplugged(), SetEnergy(), SwitchOff() и SwitchOn().

◆ UpdatePlugState()

void UpdatePlugState ( )
inlineprotected

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

588 {
589 if (m_ThisEntityAI.GetCompEM().GetEnergySource())
590 {
591 EntityAI player = m_ThisEntityAI.GetHierarchyRootPlayer();
592 // Check if the item is held in hands during advanced placement
593 if (player)
594 {
595 // Measure distance from the player
596 vector playerPosition = player.GetPosition();
598 UnplugThis();
599 }
600 else
601 {
602 // Measure distance from the device
603 vector itemPosition = m_ThisEntityAI.GetPosition();
604
605 if (m_ThisEntityAI.GetHierarchyParent())
606 itemPosition = m_ThisEntityAI.GetHierarchyParent().GetPosition();
607
609 UnplugThis();
610 }
611 }
612 }
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...
Definition ComponentEnergyManager.c:1031

Перекрестные ссылки IsEnergySourceAtReach(), Component::m_ThisEntityAI и UnplugThis().

◆ UpdateSelections()

void 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)

548 {
549 // Lets update sockets, if there are any
550 int slots_c = GetSocketsCount();
551
552 for ( int i = 0; i < slots_c; ++i )
553 {
555
556 if ( plug_owner )
557 {
558 string plugged_selection = SOCKET_ + (i+1).ToString() + _PLUGGED;
560 m_ThisEntityAI.ShowSelection ( plugged_selection );
561 m_ThisEntityAI.HideSelection ( available_selection );
562 string texture_path = plug_owner.GetCompEM().GetCordTextureFile();
563 int selection_index = m_ThisEntityAI.GetHiddenSelectionIndex( plugged_selection );
564 m_ThisEntityAI.SetObjectTexture(selection_index, texture_path );
565 }
566 else
567 {
568 m_ThisEntityAI.ShowSelection ( SOCKET_ + (i+1).ToString() + _AVAILABLE );
569 m_ThisEntityAI.HideSelection ( SOCKET_ + (i+1).ToString() + _PLUGGED );
570 }
571 }
572
573 // Now lets update the cord/plug state
574 if ( GetEnergySource() )
575 {
576 m_ThisEntityAI.ShowSelection ( SEL_CORD_PLUGGED );
577 m_ThisEntityAI.HideSelection ( SEL_CORD_FOLDED );
578 }
579 else
580 {
581 m_ThisEntityAI.ShowSelection ( SEL_CORD_FOLDED );
582 m_ThisEntityAI.HideSelection ( SEL_CORD_PLUGGED );
583 }
584 }

Перекрестные ссылки _AVAILABLE, _PLUGGED, GetDeviceBySocketID(), GetEnergySource(), GetSocketsCount(), Component::m_ThisEntityAI, SEL_CORD_FOLDED, SEL_CORD_PLUGGED, SOCKET_ и ToString().

◆ UpdateSocketSelections()

void UpdateSocketSelections ( int socket_id,
EntityAI device_to_plug )
inlineprotected
1579 {
1581
1584 m_ThisEntityAI.ShowSelection ( plugged_selection );
1585
1587 m_ThisEntityAI.HideSelection ( unplugged_selection );
1588 string texture_path = device_to_plug.GetCompEM().GetCordTextureFile();
1589 int selection_index = m_ThisEntityAI.GetHiddenSelectionIndex( plugged_selection );
1590 m_ThisEntityAI.SetObjectTexture( selection_index, texture_path );
1591 device_to_plug.GetCompEM().SetMySocketID(socket_id);
1592 }

Перекрестные ссылки _AVAILABLE, _PLUGGED, Component::m_ThisEntityAI, SetDeviceBySocketID(), SetPlugOwner(), SOCKET_ и ToString().

Используется в PlugCordIntoSocket().

◆ WakeUpWholeBranch()

void WakeUpWholeBranch ( EntityAI original_caller)
inlineprotected
1528 {
1529 if ( GetSocketsCount() > 0 )
1530 {
1532 int plugged_devices_c = plugged_devices.Count();
1533
1534 for ( int i = 0; i < plugged_devices_c; ++i )
1535 {
1537 if ( device != original_caller ) // original_caller check here prevents infinite loops
1538 {
1539 device.GetCompEM().UpdateCanWork();
1540 device.GetCompEM().DeviceUpdate();
1541 device.GetCompEM().StartUpdates();
1542 device.GetCompEM().WakeUpWholeBranch( original_caller );
1543 }
1544 }
1545 }
1546 }

Перекрестные ссылки GetPluggedDevices() и GetSocketsCount().

Используется в DeviceUpdate(), PlugInDevice(), SwitchOff() и SwitchOn().

Поля

◆ _AVAILABLE

const string _AVAILABLE = "_available"
staticprotected

◆ _PLUGGED

const string _PLUGGED = "_plugged"
staticprotected

◆ DEFAULT_UPDATE_INTERVAL

const float DEFAULT_UPDATE_INTERVAL = 15
protected

Используется в Event_OnAwake().

◆ m_AttachmentActionType

int m_AttachmentActionType
protected

◆ m_AutoSwitchOff

bool m_AutoSwitchOff
protected

Используется в DeviceUpdate() и Event_OnAwake().

◆ m_AutoSwitchOffWhenInCargo

bool m_AutoSwitchOffWhenInCargo
protected

Используется в Event_OnAwake() и HandleMoveInsideCargo().

◆ m_CanStopWork

bool m_CanStopWork
protected

Используется в DeviceUpdate().

◆ m_CanWork

bool m_CanWork
protected

Используется в CanWork(), DeviceUpdate(), Event_OnAwake() и UpdateCanWork().

◆ m_CompatiblePlugTypes

ref TIntArray m_CompatiblePlugTypes
protected

◆ m_ConvertEnergyToQuantity

bool m_ConvertEnergyToQuantity
protected

Используется в Event_OnAwake() и HasConversionOfEnergyToQuantity().

◆ m_CordLength

float m_CordLength
protected

Используется в Event_OnAwake(), GetCordLength() и SetCordLength().

◆ m_CordTextureFile

string m_CordTextureFile
protected

Используется в Event_OnAwake(), GetCordTextureFile() и SetCordTextureFile().

◆ m_DebugPlugArrow

Shape m_DebugPlugArrow
protected

◆ m_DebugPlugs

bool m_DebugPlugs = false
staticprotected

◆ m_DebugUpdate

ref Timer m_DebugUpdate
protected

Используется в DebugUpdate(), OnIsPlugged() и RefreshDebug().

◆ m_DeviceByPlugSelection

ref map<string,EntityAI> m_DeviceByPlugSelection
protected

Используется в Event_OnAwake(), GetPlugOwner() и SetPlugOwner().

◆ m_Energy

float m_Energy
protected

◆ m_EnergyAtSpawn

float m_EnergyAtSpawn
protected

Используется в Event_OnAwake() и GetEnergyAtSpawn().

◆ m_EnergySource

EntityAI m_EnergySource
protected

Используется в GetEnergySource() и SetEnergySource().

◆ m_EnergySourceNetworkIDHigh

int m_EnergySourceNetworkIDHigh = -1
protected

Используется в GetEnergySourceNetworkIDHigh() и SetEnergySource().

◆ m_EnergySourceNetworkIDLow

int m_EnergySourceNetworkIDLow = -1
protected

Используется в GetEnergySourceNetworkIDLow() и SetEnergySource().

◆ m_EnergySourceStorageIDb1

int m_EnergySourceStorageIDb1
protected

Используется в GetEnergySourceStorageIDb1() и StoreEnergySourceIDs().

◆ m_EnergySourceStorageIDb2

int m_EnergySourceStorageIDb2
protected

Используется в GetEnergySourceStorageIDb2() и StoreEnergySourceIDs().

◆ m_EnergySourceStorageIDb3

int m_EnergySourceStorageIDb3
protected

Используется в GetEnergySourceStorageIDb3() и StoreEnergySourceIDs().

◆ m_EnergySourceStorageIDb4

int m_EnergySourceStorageIDb4
protected

Используется в GetEnergySourceStorageIDb4() и StoreEnergySourceIDs().

◆ m_EnergyStorageMax

float m_EnergyStorageMax
protected

◆ m_EnergyUsage

float m_EnergyUsage
protected

◆ m_HasElectricityIcon

bool m_HasElectricityIcon
protected

◆ m_IsPassiveDevice

bool m_IsPassiveDevice
protected

◆ m_IsPlugged

bool m_IsPlugged
protected

Используется в IsPlugged() и SetEnergySource().

◆ m_IsSwichedOn

bool m_IsSwichedOn
protected

Используется в IsSwitchedOn(), SwitchOff() и SwitchOn().

◆ m_IsSwichedOnPreviousState

bool m_IsSwichedOnPreviousState
protected

Используется в GetPreviousSwitchState(), SwitchOff() и SwitchOn().

◆ m_IsWorking

bool m_IsWorking
protected

Используется в IsWorking() и SetPowered().

◆ m_LastUpdateTime

float m_LastUpdateTime
protected

◆ m_MySocketID

int m_MySocketID = -1
protected

Используется в GetMySocketID() и SetMySocketID().

◆ m_PluggedDevices

ref array<EntityAI> m_PluggedDevices
protected

Используется в Event_OnAwake() и GetPluggedDevices().

◆ m_PlugType

int m_PlugType
protected

Используется в Event_OnAwake(), GetPlugType() и SetPlugType().

◆ m_ReduceMaxEnergyByDamageCoef

float m_ReduceMaxEnergyByDamageCoef
protected

Используется в Event_OnAwake() и GetEnergyMax().

◆ m_RestorePlugState

bool m_RestorePlugState
protected

Используется в GetRestorePlugState() и RestorePlugState().

◆ m_ShowSocketsInInventory

bool m_ShowSocketsInInventory
protected

Используется в Event_OnAwake() и HasVisibleSocketsInInventory().

◆ m_Sockets

EntityAI m_Sockets[MAX_SOCKETS_COUNT]
protected

◆ m_SocketsCount

float m_SocketsCount
protected

Используется в Event_OnAwake() и GetSocketsCount().

◆ m_UpdateInterval

float m_UpdateInterval
protected

Используется в GetUpdateInterval() и SetUpdateInterval().

◆ m_UpdateQuantityTimer

ref Timer m_UpdateQuantityTimer
protected

Используется в Event_OnAwake() и OnEnergyAdded().

◆ m_UpdateTimer

ref Timer m_UpdateTimer
protected

Используется в StartUpdates() и StopUpdates().

◆ m_WetnessExposure

float m_WetnessExposure
protected

Используется в CheckWetness(), Event_OnAwake() и GetWetnessExposure().

◆ MAX_SOCKETS_COUNT

const int MAX_SOCKETS_COUNT = 4
protected

Используется в Event_OnAwake().

◆ SEL_CORD_FOLDED

const string SEL_CORD_FOLDED = "cord_folded"
staticprotected

Используется в PlugInDevice(), UnplugDevice() и UpdateSelections().

◆ SEL_CORD_PLUGGED

const string SEL_CORD_PLUGGED = "cord_plugged"
staticprotected

◆ SOCKET_

const string SOCKET_ = "socket_"
staticprotected

Объявления и описания членов класса находятся в файле: