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 строка 1063
1064 {
1065 if ( !
IsPlugged() && override_source_position ==
"-1 -1 -1" )
1066 {
1067 return false;
1068 }
1069
1071 {
1072 return true;
1073 }
1074
1075 vector source_pos;
1076 float distance;
1077
1078 if ( override_source_position == "-1 -1 -1" )
1079 {
1081
1082 if (!energy_source)
1083 return false;
1084
1085 source_pos = energy_source.GetPosition();
1086 distance = vector.Distance( from_position, source_pos );
1087 }
1088 else
1089 {
1090 source_pos = override_source_position;
1091 distance = vector.Distance( from_position, source_pos );
1092 }
1093
1095 {
1096 return false;
1097 }
1098 else
1099 {
1100 return true;
1101 }
1102 }
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().