DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CCTWaterSurface.c
См. документацию.
2{
3 protected const int HEIGHT_DIFF_LIMIT_METERS = 1.0;
4
5 protected float m_MaximalActionDistanceSq;
6 protected string m_SurfaceType;
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
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
26 string surfaceType;
27 float waterLevel = player.GetCurrentWaterLevel();
28 g_Game.SurfaceGetType3D(hitPosition[0], hitPosition[1] + waterLevel, hitPosition[2], surfaceType);
29
30 if (waterLevel > 0.0)
31 return Surface.AllowedWaterSurface(hitPosition[1] + waterLevel, surfaceType, m_AllowedSurfaceList);
32
33 float surfaceHeight = g_Game.SurfaceY(hitPosition[0], hitPosition[2]);
35 if (!surfaceType)
36 {
37 surfaceHeight = hitPosition[1];
38 }
39
40 float heightDiff = Math.AbsFloat(hitPosition[1] - surfaceHeight);
41 if (surfaceType != "" && heightDiff > HEIGHT_DIFF_LIMIT_METERS)
42 return false;
43
44 float distSq = vector.DistanceSq(player.GetPosition(), hitPosition);
45 if (distSq > m_MaximalActionDistanceSq)
46 return false;
47
48 return Surface.AllowedWaterSurface(hitPosition[1], surfaceType, m_AllowedSurfaceList);
49 }
50
51 override bool CanContinue(PlayerBase player, ActionTarget target)
52 {
53 return true;
54 }
55}
56
58{
60 protected int m_AllowedLiquidSource;
61 protected int m_LiquidType = LIQUID_NONE;
62
63 void CCTWaterSurfaceEx(float maximal_target_distance, int allowedLiquidSource)
64 {
65 m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;
66 m_AllowedLiquidSource = allowedLiquidSource;
67 }
68
69 override bool Can(PlayerBase player, ActionTarget target)
70 {
71 if (!target)
72 return false;
73
74 vector hitPosition = target.GetCursorHitPos();
75 float distSq = vector.DistanceSq(player.GetPosition(), hitPosition);
76 if (distSq > m_MaximalActionDistanceSq)
77 return false;
78
79 int liquidType = GetSurfaceLiquidType(target);
80 string surfaceName = target.GetSurfaceName();
81 return CheckLiquidSource(hitPosition, surfaceName, liquidType, m_AllowedLiquidSource);
82 }
83
84 bool CheckLiquidSource(vector hitPos, string surfaceName, int liquidType, int allowedWaterSourceMask)
85 {
86 bool success = false;
87 if (surfaceName == "" && hitPos != vector.Zero)
88 {
90 bool isSea = g_Game.SurfaceIsSea(hitPos[0], hitPos[2]);
91 if (allowedWaterSourceMask & LIQUID_SALTWATER && isSea)
92 {
93 success = hitPos[1] <= (g_Game.SurfaceGetSeaLevel() + 0.25);
94 }
95 }
96 else
97 {
98 success = allowedWaterSourceMask & liquidType;
99 }
100
101 return success;
102 }
103
105 {
107
109 if (target.GetSurfaceLiquidType() != LIQUID_NONE)
110 {
111 m_LiquidType = target.GetSurfaceLiquidType();
112 }
113
115 Object targetObject = target.GetObject();
116 if (m_LiquidType == LIQUID_NONE && targetObject)
117 {
118 m_LiquidType = targetObject.GetLiquidSourceType();
119 }
120
121 return m_LiquidType;
122 }
123
124 override bool CanContinue(PlayerBase player, ActionTarget target)
125 {
126 return true;
127 }
128
130 {
131 return m_LiquidType;
132 }
133}
int GetSurfaceLiquidType()
Определения ActionTargets.c:180
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:121
int m_AllowedLiquidSource
Определения CCTWaterSurface.c:60
void CCTWaterSurfaceEx(float maximal_target_distance, int allowedLiquidSource)
Определения CCTWaterSurface.c:63
bool CheckLiquidSource(vector hitPos, string surfaceName, int liquidType, int allowedWaterSourceMask)
Определения CCTWaterSurface.c:84
int GetLiquidType()
Определения CCTWaterSurface.c:129
CCTWaterSurface m_MaximalActionDistanceSq
DayZGame g_Game
Определения DayZGame.c:3868
int m_LiquidType
Определения Environment.c:61
bool CanContinue(PlayerBase player, ActionTarget target)
Определения CCTBase.c:8
bool Can(PlayerBase player, ActionTarget target)
Определения CCTBase.c:3
Определения CCTBase.c:2
float m_MaximalActionDistanceSq
Определения CCTWaterSurface.c:5
override bool CanContinue(PlayerBase player, ActionTarget target)
Определения CCTWaterSurface.c:51
override bool Can(PlayerBase player, ActionTarget target)
Определения CCTWaterSurface.c:18
void CCTWaterSurface(float maximal_target_distance=UAMaxDistances.DEFAULT, string surfaceType="")
Определения CCTWaterSurface.c:9
const int HEIGHT_DIFF_LIMIT_METERS
Определения CCTWaterSurface.c:3
string m_SurfaceType
Определения CCTWaterSurface.c:6
ref array< string > m_AllowedSurfaceList
DEPRECATED.
Определения CCTWaterSurface.c:7
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
static bool AllowedWaterSurface(float pHeight, string pSurface, array< string > pAllowedSurfaceList)
Определения Surface.c:31
Определения Surface.c:2
const float DEFAULT
Определения ActionConstants.c:112
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
const int LIQUID_NONE
Определения 3_Game/constants.c:529
const int LIQUID_SALTWATER
Определения 3_Game/constants.c:550
static proto float AbsFloat(float f)
Returns absolute value.