DayZ 1.27
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 = 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 native DayZPlayer GetPlayer()
Определения EnConvert.c:106
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.

См. определение в файле ComponentEnergyManager.c строка 1031

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
1043 vector source_pos;
1044 float distance;
1045
1046 if ( override_source_position == "-1 -1 -1" )
1047 {
1048 EntityAI energy_source = GetEnergySource();
1049
1050 if (!energy_source)
1051 return false;
1052
1053 source_pos = energy_source.GetPosition();
1054 distance = vector.Distance( from_position, source_pos );
1055 }
1056 else
1057 {
1058 source_pos = override_source_position;
1059 distance = vector.Distance( from_position, source_pos );
1060 }
1061
1062 if (distance > GetCordLength() + add_tolerance)
1063 {
1064 return false;
1065 }
1066 else
1067 {
1068 return true;
1069 }
1070 }
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:887
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
Определения ComponentEnergyManager.c:1292
float GetCordLength()
Energy manager: Returns the length of the virtual power cord.
Определения ComponentEnergyManager.c:1286

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

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