DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CheckSurfaceLiquid()

bool CCTLiquid::CheckSurfaceLiquid ( PlayerBase player,
Object targetObj,
vector hitPosition,
vector playerPos,
bool isValidInteract,
out string surfaceType )
inlineprotected

Valid object source wins, do not also check surface.

Preserve ValidateDistances() range check for surface-liquid hits.

Do not allow water merely below grass/terrain.

См. определение в файле CCTLiquid.c строка 180

181 {
182 surfaceType = string.Empty;
183
185 if (isValidInteract)
186 return false;
187
189 if (IsNearlyZero(hitPosition))
190 return false;
191
192 m_SurfaceDetectionParams.position = hitPosition;
193 SurfaceDetectionResult surfaceResult = new SurfaceDetectionResult();
194 if (!g_Game.GetSurface(m_SurfaceDetectionParams, surfaceResult))
195 return false;
196
197 if (!surfaceResult)
198 return false;
199
200 SurfaceInfo surfaceInfo = surfaceResult.surface;
201 if (!surfaceInfo)
202 return false;
203
204 surfaceType = surfaceInfo.GetSurfaceType();
205 if (surfaceType == string.Empty)
206 return false;
207
208 float surfaceHeight = surfaceResult.height;
209 float heightDiffSurface = Math.AbsFloat(hitPosition[1] - surfaceHeight);
210 float playerToSurfaceHeight = Math.AbsFloat(playerPos[1] - surfaceHeight);
211
212 int liquidType = g_Game.CorrectLiquidType(surfaceInfo.GetLiquidType());
213 if (liquidType == LIQUID_NONE)
214 return false;
215
216 vector liquidSurfacePos = hitPosition;
217 liquidSurfacePos[1] = surfaceHeight;
218
220 if (!IsCursorActuallyOnLiquidSurface(hitPosition, liquidSurfacePos))
221 return false;
222
223 vector surfacePos = liquidSurfacePos;
224 surfacePos[1] = surfacePos[1] + LIQUID_SURFACE_RAYCAST_OFFSET;
225
226 if (vector.Distance(playerPos, surfacePos) > m_MaxActionDistance)
227 return false;
228
229 if (targetObj)
230 {
231 if (heightDiffSurface > 0.25)
232 return false;
233
234 if (!HasClearPathToLiquidSurface(player, surfacePos))
235 return false;
236 }
237 else
238 {
239 if (!HasClearPathToLiquidSurface(player, surfacePos))
240 return false;
241 }
242
243 if (playerToSurfaceHeight > m_MaxVerticalReach)
244 return false;
245
246 m_LiquidType = liquidType;
247 return true;
248 }
DayZGame g_Game
Определения DayZGame.c:4074
Empty
Определения Hand_States.c:14
int[] SurfaceInfo
Определения SurfaceInfo.c:1
bool HasClearPathToLiquidSurface(PlayerBase player, vector surfacePos)
Определения CCTLiquid.c:250
bool IsCursorActuallyOnLiquidSurface(vector hitPosition, vector liquidSurfacePos)
Определения CCTLiquid.c:982
bool IsNearlyZero(vector value)
Определения CCTLiquid.c:1024
int m_LiquidType
Определения CCTLiquid.c:27
float m_MaxVerticalReach
Определения CCTLiquid.c:22
ref SurfaceDetectionParameters m_SurfaceDetectionParams
Определения CCTLiquid.c:25
float m_MaxActionDistance
Определения CCTLiquid.c:23
static const float LIQUID_SURFACE_RAYCAST_OFFSET
Определения CCTLiquid.c:16
SurfaceInfo surface
Returned SurfaceInfo, plain pointer.
Определения SurfaceInfo.c:134
float height
Height position.
Определения SurfaceInfo.c:122
proto int GetLiquidType()
See 'LiquidTypes' in 'constants.c'.
proto string GetSurfaceType()
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:566

Перекрестные ссылки Math::AbsFloat(), vector::Distance(), Empty, g_Game, SurfaceInfo::GetLiquidType(), SurfaceInfo::GetSurfaceType(), HasClearPathToLiquidSurface(), SurfaceDetectionResult::height, IsCursorActuallyOnLiquidSurface(), IsNearlyZero(), LIQUID_NONE, LIQUID_SURFACE_RAYCAST_OFFSET, m_LiquidType, m_MaxActionDistance, m_MaxVerticalReach, m_SurfaceDetectionParams и SurfaceDetectionResult::surface.

Используется в Can().