Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DecoTestVehicleIsMoving.c
Go to the documentation of this file.
2{
3 protected const float MIN_SPEED_MPS = 0.5;
4 protected const float MIN_SPEED_RADS = 0.5;
7
8 protected override bool TestFunction(AIAgent agent, IEntity controlled)
9 {
10 if (!controlled)
11 return false;
12
13 // Iterate parents of entity until we find first Vehicle entity
14 IEntity parent = controlled;
15 BaseVehicle vehicle = BaseVehicle.Cast(controlled);
16 bool isMoving, isRotating, isInAir;
17
18 while (vehicle == null && parent != null)
19 {
20 parent = parent.GetParent();
21 if (parent)
22 vehicle = BaseVehicle.Cast(parent);
23 }
24
25 if (!vehicle)
26 return false;
27
28 if (m_vehicle != vehicle)
29 {
30 m_vehicle = vehicle;
32 }
33
34 Physics ph = m_vehicle.GetPhysics();
35 if (!ph || !ph.IsActive())
36 return false;
37
38 isMoving = ph.GetVelocity().Length() > MIN_SPEED_MPS;
39 isRotating = ph.GetAngularVelocity().Length() > MIN_SPEED_RADS;
40
42 {
43 vector positionActual;
44 positionActual = vehicle.GetOrigin();
45 isInAir = !m_heliSimulation.HasAnyGroundContact();
46 return isInAir || isMoving || isRotating;
47 }
48 return isMoving || isRotating;
49 }
50};
proto external IEntity GetParent()
override bool TestFunction(AIAgent agent, IEntity controlled)
VehicleHelicopterSimulation m_heliSimulation