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

◆ IsAttachmentReachable()

static bool AttachmentsOutOfReach::IsAttachmentReachable ( EntityAI e,
string att_slot_name = "",
int slot_id = -1,
float range = 1.5 )
inlinestaticprotected

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

6 {
7 if (!e.IgnoreOutOfReachCondition())
8 {
9 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
10 if (player.IsInVehicle())
11 {
12 return false;
13 }
14 else
15 {
16 vector posAtt;
17 if (slot_id != -1)
18 {
19 att_slot_name = InventorySlots.GetSlotName(slot_id);
20 }
21 if (att_slot_name != "")
22 {
23 if (e.MemoryPointExists(att_slot_name))
24 {
25 vector mem_point = e.GetMemoryPointPos(att_slot_name);
26 posAtt = e.ModelToWorld(mem_point);
27 }
28 else
29 {
30 posAtt = e.ModelToWorld(GetAttachmentPosition(e, InventorySlots.GetSlotIdFromString(att_slot_name)));
31 }
32 }
33
34 vector posPlayer = player.GetPosition();
35 float heightDiff = posAtt[1] - posPlayer[1];
36 //float negativeTolerance = -range / 5; //TODO: maybe flat value?
37 float negativeTolerance = -1.0; //-1m tolerance to test with
38 if (heightDiff >= negativeTolerance && (Math.AbsFloat(heightDiff) < range)) //sort of 'dome' shaped detection with some negative leeway
39 {
40 posPlayer[1] = 0;
41 posAtt[1] = 0;
42 return vector.Distance(posPlayer, posAtt) <= range;
43 }
44
45 return false;
46 }
47 }
48 else
49 {
50 return true;
51 }
52 }
DayZGame g_Game
Определения DayZGame.c:4074
static vector GetAttachmentPosition(EntityAI e, int slot_id)
Определения AttachmentsOutOfReach.c:54
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

Перекрестные ссылки Math::AbsFloat(), vector::Distance(), g_Game, GetAttachmentPosition(), InventorySlots::GetSlotIdFromString() и InventorySlots::GetSlotName().

Используется в Icon::MouseClick(), AttachmentCategoriesRow::RefreshSlot(), Attachments::Select(), UpdateConsoleToolbar() и Attachments::UpdateInterval().