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_position | vector position from where the measurement will be taken |
| add_tolerance | float 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.
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.
См. определение в файле ComponentEnergyManager.c строка 1076
1077 {
1078 if ( !
IsPlugged() && override_source_position ==
"-1 -1 -1" )
1079 {
1080 return false;
1081 }
1082
1084 {
1085 return true;
1086 }
1087
1088 vector source_pos;
1089 float distance;
1090
1091 if ( override_source_position == "-1 -1 -1" )
1092 {
1094
1095 if (!energy_source)
1096 return false;
1097
1098 source_pos = energy_source.GetPosition();
1099 distance = vector.Distance( from_position, source_pos );
1100 }
1101 else
1102 {
1103 source_pos = override_source_position;
1104 distance = vector.Distance( from_position, source_pos );
1105 }
1106
1108 {
1109 return false;
1110 }
1111 else
1112 {
1113 return true;
1114 }
1115 }
bool IsPlugged()
Energy manager: Returns true if this device is plugged into some other device (even if they are OFF o...
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
float GetCordLength()
Energy manager: Returns the length of the virtual power cord.
Перекрестные ссылки vector::Distance(), GetCordLength(), GetEnergySource() и IsPlugged().
Используется в Hologram::CorrectMaterialPathName() и UpdatePlugState().