Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cctwatersurface.c
Go to the documentation of this file.
2 {
3  protected const int HEIGHT_DIFF_LIMIT_METERS = 1.0;
4 
5  protected float m_MaximalActionDistanceSq;
6  protected string m_SurfaceType;
7  protected ref array<string> m_AllowedSurfaceList;
8 
9  void CCTWaterSurface(float maximal_target_distance = UAMaxDistances.DEFAULT, string surfaceType = "")
10  {
11  m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;
12  m_SurfaceType = surfaceType;
13 
14  m_AllowedSurfaceList = new array<string>();
15  surfaceType.Split("|", m_AllowedSurfaceList);
16  }
17 
18  override bool Can(PlayerBase player, ActionTarget target)
19  {
20  if (!target || (target && target.GetObject()))
21  return false;
22 
24  vector hitPosition = target.GetCursorHitPos();
25  if (hitPosition == vector.Zero)
26  hitPosition = player.GetPosition();
27 
28  string surfaceType;
29  float waterLevel = player.GetCurrentWaterLevel();
30  g_Game.SurfaceGetType3D(hitPosition[0], hitPosition[1] + waterLevel, hitPosition[2], surfaceType);
31 
32  if (waterLevel > 0.0)
33  return Surface.AllowedWaterSurface(hitPosition[1] + waterLevel, surfaceType, m_AllowedSurfaceList);
34 
35  float surfaceHeight = g_Game.SurfaceY(hitPosition[0], hitPosition[2]);
37  if (!surfaceType)
38  {
39  surfaceHeight = hitPosition[1];
40  }
41 
42  float heightDiff = Math.AbsFloat(hitPosition[1] - surfaceHeight);
43  if (surfaceType != "" && heightDiff > HEIGHT_DIFF_LIMIT_METERS)
44  return false;
45 
46  float distSq = vector.DistanceSq(player.GetPosition(), hitPosition);
47  if (distSq > m_MaximalActionDistanceSq)
48  return false;
49 
50  return Surface.AllowedWaterSurface(hitPosition[1], surfaceType, m_AllowedSurfaceList);
51  }
52 
53  override bool CanContinue(PlayerBase player, ActionTarget target)
54  {
55  return true;
56  }
57 }
CCTWaterSurface
Definition: cctwatersurface.c:1
CCTBase
Definition: cctbase.c:1
UAMaxDistances
Definition: actionconstants.c:104
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
Surface
Definition: surface.c:1
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
array< string >
Math
Definition: enmath.c:6