DayZ 1.27
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
40 string compName = building.GetActionComponentName( target.GetComponentIndex() );
41 if( compName.Length() < 6 || compName.Substring(0,6) != "ladder" )
42 {
43 return false;
44 }
45
46 // ze stringu compName dostat posledni cislo a to je index zebriku
47
48 //building.GetActionComponentNameList( action_data.m_Target.GetComponentIndex(), components );
49
50 string condCompName = string.Format("%1_con", compName);
51 vector pos = player.GetPosition();
52 //Print(w);
53 bool found = false;
54 vector ladderEnterPointGlobal;
55 vector ladderDirPointGlobal;
56 float minDistanceSq = 100.0;
57
58 string dirCompName = string.Format("%1_con_dir", compName);
59
60 for ( int i = 0; i < memSelection.Count(); i++ )
61 {
62 if ( memSelection[i].GetName() == condCompName )
63 {
64
65 for( int j = 0; j < memSelection[i].GetVertexCount(); j++ )
66 {
67 ladderEnterPointGlobal = building.ModelToWorld( memSelection[i].GetVertexPosition(lod, j) );
68 if( vector.DistanceSq(ladderEnterPointGlobal,pos) < UAMaxDistances.LADDERS * UAMaxDistances.LADDERS)
69 {
70 HumanCommandLadder.DebugDrawLadder(building, HumanCommandLadder.DebugGetLadderIndex(compName));
71 found = true;
72 break;
73 }
74 }
75 }
76 }
77
78 if (found)
79 {
80 for (int k = 0; k < memSelection.Count(); k++)
81 {
82 if( memSelection[k].GetName() == dirCompName )
83 {
84 for( int l = 0; l < memSelection[k].GetVertexCount(); l++ )
85 {
86 vector dirPoint = building.ModelToWorld( memSelection[k].GetVertexPosition(lod, l) );
87 float dst = vector.DistanceSq(ladderEnterPointGlobal,dirPoint);
88 if( dst < minDistanceSq)
89 {
90 minDistanceSq = dst;
91 ladderDirPointGlobal = dirPoint;
92 //HumanCommandLadder.DebugDrawLadder(building, HumanCommandLadder.DebugGetLadderIndex(compName));
93 //found = true;
94 }
95 }
96 }
97 }
98
99 pos = pos - ladderEnterPointGlobal;
100 ladderDirPointGlobal = ladderDirPointGlobal - ladderEnterPointGlobal;
101
102 float angle = Math.AbsFloat(pos.VectorToAngles()[0] - ladderDirPointGlobal.VectorToAngles()[0]);
103
104 if ( angle < 90 || angle > 270)
105 {
106 return true;
107 }
108 }
109
110 return false;
111 }
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 int Length()
Returns length of string.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native owned string GetName()
Test name getter. Strictly for UI porposes!
Определения SyncedValue.c:119
void HumanCommandLadder()
Определения human.c:674

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