DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerImplementSwimming Class Reference
Collaboration diagram for DayZPlayerImplementSwimming:
[legend]

Private Member Functions

void DayZPlayerImplementSwimming (DayZPlayer pPlayer)
 
float GetWaterDepth ()
 
float GetCharacterDepth ()
 
bool CheckSwimmingStart (out vector waterLevel)
 
bool HandleSwimming (int pCurrentCommandID, HumanCommandMove pCMove, HumanMovementState pState)
 ha
 

Private Attributes

DayZPlayer m_pPlayer
 
SHumanCommandSwimSettings m_pSettings
 
bool m_bWasSwimming = false
 

Detailed Description

Definition at line 2 of file DayZPlayerImplementSwimming.c.

Constructor & Destructor Documentation

◆ DayZPlayerImplementSwimming()

void DayZPlayerImplementSwimming::DayZPlayerImplementSwimming ( DayZPlayer pPlayer)
inlineprivate

Definition at line 9 of file DayZPlayerImplementSwimming.c.

10 {
12 m_pSettings = pPlayer.GetDayZPlayerType().CommandSwimSettingsW();
13 }
SHumanCommandSwimSettings m_pSettings

References m_pPlayer, and m_pSettings.

Member Function Documentation

◆ CheckSwimmingStart()

bool DayZPlayerImplementSwimming::CheckSwimmingStart ( out vector waterLevel)
inlineprivate

Definition at line 31 of file DayZPlayerImplementSwimming.c.

32 {
33 return DayZPlayerUtils.CheckWaterLevel(m_pPlayer, waterLevel) == EWaterLevels.LEVEL_SWIM_START;
34 }
void DayZPlayerUtils()
cannot be instantiated
EWaterLevels
Definition EWaterLevels.c:2

References DayZPlayerUtils(), and m_pPlayer.

Referenced by HandleSwimming().

◆ GetCharacterDepth()

float DayZPlayerImplementSwimming::GetCharacterDepth ( )
inlineprivate

Definition at line 23 of file DayZPlayerImplementSwimming.c.

24 {
25 vector pp = m_pPlayer.GetPosition();
26 vector wl = HumanCommandSwim.WaterLevelCheck(m_pPlayer, pp);
27
28 return wl[1];
29 }
class HumanCommandLadder HumanCommandSwim()
Definition human.c:669

References HumanCommandSwim(), and m_pPlayer.

◆ GetWaterDepth()

float DayZPlayerImplementSwimming::GetWaterDepth ( )
inlineprivate

Definition at line 15 of file DayZPlayerImplementSwimming.c.

16 {
17 vector pp = m_pPlayer.GetPosition();
18 vector wl = HumanCommandSwim.WaterLevelCheck(m_pPlayer, pp);
19
20 return wl[0];
21 }

References HumanCommandSwim(), and m_pPlayer.

Referenced by HandleSwimming().

◆ HandleSwimming()

bool DayZPlayerImplementSwimming::HandleSwimming ( int pCurrentCommandID,
HumanCommandMove pCMove,
HumanMovementState pState )
inlineprivate

ha

get water level

now movement

handled !

Definition at line 37 of file DayZPlayerImplementSwimming.c.

38 {
39 if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE)
40 return false;
41
42 m_bWasSwimming = false;
43
45 if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_SWIM)
46 {
47 vector wl;
49 {
50 m_pPlayer.StartCommand_Swim();
51 m_bWasSwimming = true;
52 return true;
53 }
54
56 if ((pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE) && (pCMove != null))
57 {
58 pCMove.SetCurrentWaterLevel(wl[1]);
60
61 if (wl[1] > m_pSettings.m_fToErectLevel && pState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_ERECT && pState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDERECT)
62 {
63 if (DayZPlayerUtils.PlayerCanChangeStance(m_pPlayer, DayZPlayerConstants.STANCEIDX_ERECT))
64 pCMove.ForceStanceUp(DayZPlayerConstants.STANCEIDX_ERECT);
65 else
66 {
67 m_pPlayer.StartCommand_Swim();
68 m_bWasSwimming = true;
69 return true;
70 }
71 }
72 else if (wl[1] > m_pSettings.m_fToCrouchLevel && (pState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || pState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE))
73 {
74 if (DayZPlayerUtils.PlayerCanChangeStance(m_pPlayer, DayZPlayerConstants.STANCEIDX_CROUCH))
75 pCMove.ForceStanceUp(DayZPlayerConstants.STANCEIDX_CROUCH);
76 else
77 {
78 m_pPlayer.StartCommand_Swim();
79 m_bWasSwimming = true;
80 return true;
81 }
82 }
83 }
84
85 // not handled
86 return false;
87 }
88 else // if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM)
89 {
91 {
92 if (DayZPlayerUtils.PlayerCanChangeStance(m_pPlayer, DayZPlayerConstants.STANCEIDX_ERECT, true))
93 {
94 HumanCommandSwim hcs = m_pPlayer.GetCommand_Swim();
95 hcs.StopSwimming();
96 m_bWasSwimming = false;
97 return true;
98 }
99 }
100
102 m_bWasSwimming = true;
103 return true;
104 }
105 }
override void SetCurrentWaterLevel(float pWaterLevel)
bool CheckSwimmingStart(out vector waterLevel)
float m_fWaterLevelOut
what water level causes to stop swimming (1.2m)
float m_fToCrouchLevel
when to crouch
float m_fToErectLevel
when to stand
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References CheckSwimmingStart(), DayZPlayerUtils(), GetWaterDepth(), HumanCommandSwim(), m_bWasSwimming, SHumanCommandSwimSettings::m_fToCrouchLevel, SHumanCommandSwimSettings::m_fToErectLevel, SHumanCommandSwimSettings::m_fWaterLevelOut, m_pPlayer, m_pSettings, and DayZPlayer::SetCurrentWaterLevel().

Member Data Documentation

◆ m_bWasSwimming

bool DayZPlayerImplementSwimming::m_bWasSwimming = false
private

Definition at line 7 of file DayZPlayerImplementSwimming.c.

Referenced by HandleSwimming().

◆ m_pPlayer

DayZPlayer DayZPlayerImplementSwimming::m_pPlayer
private

◆ m_pSettings

SHumanCommandSwimSettings DayZPlayerImplementSwimming::m_pSettings
private

Definition at line 6 of file DayZPlayerImplementSwimming.c.

Referenced by DayZPlayerImplementSwimming(), and HandleSwimming().


The documentation for this class was generated from the following file: