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

◆ ActionCondition()

override bool ActionEnterLadder::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

is action_data.m_Target ? not on ladder and not falling ?

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

20 {
22 if (!target || !target.GetObject() || player.GetCommand_Ladder() || player.GetCommand_Fall() )
23 return false;
24
25 Building building;
26 if (!Class.CastTo(building, target.GetObject()))
27 return false;
28
29 // TODO: direction tests
30 // Get memory LOD from p3d and save all its selections
31 LOD lod = building.GetLODByName(MEM_LOD_NAME);
32 if(lod == NULL)
33 return false;
34
35 array<Selection> memSelection = new array<Selection>();
36 if(!lod.GetSelections(memSelection))
37 return false;
38
39 array<string> selections = new array<string>();
40 string compName = "";
41 building.GetActionComponentNameList(target.GetComponentIndex(), selections);
42 foreach (string tmp : selections)
43 {
44 if (tmp.Length() >= 6 && tmp.Substring(0,6) == "ladder" && tmp.IndexOfFrom(6,"_") < 0)
45 {
46 compName = tmp;
47 break;
48 }
49 }
50
51 if (compName == string.Empty)
52 return false;
53
54 string condCompName = string.Format("%1_con", compName);
55 vector pos = player.GetPosition();
56
57 bool found = false;
58 vector ladderEnterPointGlobal;
59 vector ladderDirPointGlobal;
60 float minDistanceSq = 100.0;
61
62 string dirCompName = string.Format("%1_con_dir", compName);
63
64 for ( int i = 0; i < memSelection.Count(); i++ )
65 {
66 if ( memSelection[i].GetName() == condCompName )
67 {
68
69 for( int j = 0; j < memSelection[i].GetVertexCount(); j++ )
70 {
71 ladderEnterPointGlobal = building.ModelToWorld( memSelection[i].GetVertexPosition(lod, j) );
72 if( vector.DistanceSq(ladderEnterPointGlobal,pos) < UAMaxDistances.LADDERS * UAMaxDistances.LADDERS)
73 {
74 HumanCommandLadder.DebugDrawLadder(building, HumanCommandLadder.DebugGetLadderIndex(compName));
75 found = true;
76 break;
77 }
78 }
79 }
80 }
81
82 if (found)
83 {
84 for (int k = 0; k < memSelection.Count(); k++)
85 {
86 if( memSelection[k].GetName() == dirCompName )
87 {
88 for( int l = 0; l < memSelection[k].GetVertexCount(); l++ )
89 {
90 vector dirPoint = building.ModelToWorld( memSelection[k].GetVertexPosition(lod, l) );
91 float dst = vector.DistanceSq(ladderEnterPointGlobal,dirPoint);
92 if( dst < minDistanceSq)
93 {
94 minDistanceSq = dst;
95 ladderDirPointGlobal = dirPoint;
96 //HumanCommandLadder.DebugDrawLadder(building, HumanCommandLadder.DebugGetLadderIndex(compName));
97 //found = true;
98 }
99 }
100 }
101 }
102
103 pos = pos - ladderEnterPointGlobal;
104 ladderDirPointGlobal = ladderDirPointGlobal - ladderEnterPointGlobal;
105
106 float angle = Math.AbsFloat(pos.VectorToAngles()[0] - ladderDirPointGlobal.VectorToAngles()[0]);
107
108 if ( angle < 90 || angle > 270)
109 {
110 return true;
111 }
112 }
113
114 return false;
115 }
Empty
Определения Hand_States.c:14
const string MEM_LOD_NAME
Определения ActionEnterLadder.c:5
proto native bool GetSelections(notnull out array< Selection > selections)
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto native owned string GetName()
Test name getter. Strictly for UI porposes!
Определения SyncedValue.c:119
void HumanCommandLadder()
Определения human.c:696

Перекрестные ссылки Math::AbsFloat(), ActionTarget(), Class::CastTo(), HumanCommandLadder::DebugDrawLadder(), HumanCommandLadder::DebugGetLadderIndex(), vector::DistanceSq(), Empty, GetName(), LOD::GetSelections(), UAMaxDistances::LADDERS, MEM_LOD_NAME и vector::VectorToAngles().