Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DecoTestVehicleIsMoving.c
Go to the documentation of this file.
1 class SCR_AIDecoTestVehicleIsMoving : DecoratorTestScripted
2 {
3  protected const float MIN_SPEED_MPS = 0.5;
4  protected const float MIN_SPEED_RADS = 0.5;
5  protected BaseVehicle m_vehicle;
6  protected VehicleHelicopterSimulation m_heliSimulation;
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;
31  m_heliSimulation = VehicleHelicopterSimulation.Cast(vehicle.FindComponent(VehicleHelicopterSimulation));
32  }
33 
34  Physics ph = controlled.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 
41  if (m_heliSimulation)
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 };
SCR_AIDecoTestVehicleIsMoving
Definition: SCR_DecoTestVehicleIsMoving.c:1