DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ IsEnergySourceAtReach()

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

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

Аргументы
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 = g_Game.GetPlayer().GetPosition();
if ( my_device.GetCompEM().IsEnergySourceAtReach( position_player ) )
{
Print("Power source is at reach!");
}else{
Print("Power source is NOT at reach!");
}
DayZGame g_Game
Определения DayZGame.c:3942
Определения EnConvert.c:119
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
1083 if ( GetCordLength() == 0 ) // 0 is an exception, which means infinitely long cable.
1084 {
1085 return true;
1086 }
1087
1088 vector source_pos;
1089 float distance;
1090
1091 if ( override_source_position == "-1 -1 -1" )
1092 {
1093 EntityAI energy_source = GetEnergySource();
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
1107 if (distance > GetCordLength() + add_tolerance)
1108 {
1109 return false;
1110 }
1111 else
1112 {
1113 return true;
1114 }
1115 }
class LogManager EntityAI
bool IsPlugged()
Energy manager: Returns true if this device is plugged into some other device (even if they are OFF o...
Определения ComponentEnergyManager.c:918
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
Определения ComponentEnergyManager.c:1337
float GetCordLength()
Energy manager: Returns the length of the virtual power cord.
Определения ComponentEnergyManager.c:1331

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

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