Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
playersoundeventbase.c
Go to the documentation of this file.
2 {
3  GENERAL = 0x00000001,
4  MELEE = 0x00000002,
5  STAMINA = 0x00000004,
6  DAMAGE = 0x00000008,
7  DUMMY = 0x00000010,
8  INJURY = 0x00000020,
9  DROWNING = 0x00000040,
10  //HEAT_COMFORT = 0x00000080,
11 }
12 
13 enum EPlayerSoundEventParam
14 {
15  SKIP_CONTROLLED_PLAYER = 0x00000001,
16  HIGHEST_PRIORITY = 0x00000002,
17  /*
18  STAMINA = 0x00000004,
19  DAMAGE = 0x00000008,
20  DUMMY = 0x00000010,
21  INJURY = 0x00000020,
22  HEAT_COMFORT = 0x00000040,
23  */
24 
25  // ONLY COUNT BELLOW
26  ENUM_COUNT,
27 
28 }
29 
31 {
37  float m_PlayTime;
38 
41 
42  bool IsDummy()
43  {
44  return m_IsDummyType;
45  }
46 
48  {
50  }
51 
52  // !can this event play during hold breath
53  bool HasHoldBreathException()
54  {
55  return false;
56  }
57 
59  {
60  m_Type = EPlayerSoundEventType.GENERAL;
61  }
62 
64  {
65  if(!m_SoundSetCallback)
66  OnEnd();
67  }
68 
70  {
72  }
73 
74  bool HasPriorityOverCurrent(PlayerBase player, EPlayerSoundEventID other_state_id, EPlayerSoundEventType type_other)
75  {
76  return true;
77  }
78 
79  bool IsFinished()
80  {
81  if(IsDummy())
82  {
83  return IsDummyFinished();
84  }
85  else
86  {
87  return !IsSoundCallbackExist();
88  }
89  }
90 
92  {
93  return GetGame().GetTime() > (m_DummyStartTime + m_DummySoundLength);
94  }
95 
96 
97  void OnTick(float delta_time)
98  {
99  if ( m_SoundSetCallback )
100  {
101  m_SoundSetCallback.SetPosition(m_Player.GetPosition());
102  //---------- Playback event -------------
103  if( delta_time > 0 && m_ProcessPlaybackEvent )//delta_time 0 is for remotes
104  {
105 
106  m_PlayTime += delta_time;
107  //this is not 100% precise as the playback position is not obtained from the sound system
108  float playback01 = Math.Clamp(m_PlayTime / m_SoundSetCallback.GetLength(),0,1);
109  SendEvent(playback01);
110  //---------- Playback event -------------
111  }
112  }
113  }
114 
115  bool CanPlay(PlayerBase player)
116  {
117  player.GetMovementState(m_Hms);
118 
119  if (player.IsHoldingBreath() && !HasHoldBreathException())
120  {
121  return false;
122  }
123  if (player.m_IsDrowning || (player.IsSwimming() && m_Hms.m_iMovement != 0))
124  {
125  return false;
126  }
127  return true;
128  }
129 
130  void Init(PlayerBase player)
131  {
132  InitEx(player,0);
133  }
134 
135  void InitEx(PlayerBase player, int param)
136  {
137  m_Player = player;
138  m_Param = param;
139  if (param & EPlayerSoundEventParam.HIGHEST_PRIORITY)
140  {
142  }
143  }
144 
145  void OnEnd()
146  {
148  SendEvent(1);
149  }
150 
151  void SendEvent(float time)
152  {
153  if(m_PlayTime < 0 || !m_SoundSetCallback)//negative m_PlayTime value indicates the event has already been sent for playback01 = 1
154  return;
155 
156  m_Player.OnVoiceEventPlayback(this, m_SoundSetCallback, time);
157  if(time >= 1)
158  m_PlayTime = -float.MAX;
159  }
160 
161  void OnInterupt()
162  {
163 
164  }
165 
166  override void OnPlay(PlayerBase player)
167  {
168  super.OnPlay(player);
169  //Print("start playing -------------------->" + m_Type);
170  player.OnVoiceEvent(this);
171  //m_Player.OnVoiceEventDuration(m_SoundSetCallback, 0);
172  }
173 
174  override bool Play()
175  {
176  if(!super.Play())
177  return false;
178 
179  if( !IsDummy() )
180  {
181  m_SoundSetCallback = m_Player.ProcessVoiceEvent("","", m_SoundVoiceAnimEventClassID);
182 
184  {
185  AbstractWaveEvents events = AbstractWaveEvents.Cast(m_SoundSetCallback.GetUserData());
186  events.Event_OnSoundWaveEnded.Insert( OnEnd );
187  events.Event_OnSoundWaveStopped.Insert( OnInterupt );
188  return true;
189  }
190  else
191  return false;
192  }
193  else
194  {
195  m_DummyStartTime = GetGame().GetTime();
196  return true;
197  }
198  return false;
199 
200  }
201 }
SoundEventBase
Definition: soundevents.c:1
GetGame
proto native CGame GetGame()
IsSoundCallbackExist
bool IsSoundCallbackExist()
Definition: soundevents.c:31
DROWNING
@ DROWNING
Definition: playersoundeventbase.c:9
m_IsDummyType
bool m_IsDummyType
Definition: playersoundeventbase.c:35
STAMINA
@ STAMINA
Definition: playersoundeventbase.c:5
m_Type
eBleedingSourceType m_Type
Definition: bleedingsource.c:25
DUMMY
@ DUMMY
Definition: playersoundeventbase.c:7
m_ProcessPlaybackEvent
bool m_ProcessPlaybackEvent
Definition: playersoundeventbase.c:36
~PlayerSoundEventBase
void ~PlayerSoundEventBase()
Definition: playersoundeventbase.c:63
OnInterupt
void OnInterupt()
Definition: playersoundeventbase.c:161
m_PlayTime
float m_PlayTime
Definition: playersoundeventbase.c:37
OnTick
void OnTick(float delta_time)
Definition: playersoundeventbase.c:97
GENERAL
@ GENERAL
Definition: playersoundeventbase.c:3
SendEvent
void SendEvent(float time)
Definition: playersoundeventbase.c:151
m_HasPriorityOverTypes
EPlayerSoundEventType m_HasPriorityOverTypes
Definition: playersoundeventbase.c:40
MELEE
@ MELEE
Definition: playersoundeventbase.c:4
SKIP_CONTROLLED_PLAYER
enum EPlayerSoundEventType SKIP_CONTROLLED_PLAYER
GetPriorityOverTypes
EPlayerSoundEventType GetPriorityOverTypes()
Definition: playersoundeventbase.c:47
m_SoundSetCallback
AbstractWave m_SoundSetCallback
Definition: soundevents.c:2
HumanMovementState
Definition: human.c:1125
IsDummy
bool IsDummy()
Definition: playersoundeventbase.c:42
m_Hms
ref HumanMovementState m_Hms
Definition: playersoundeventbase.c:39
PlayerBase
Definition: playerbaseclient.c:1
IsDummyFinished
bool IsDummyFinished()
Definition: playersoundeventbase.c:91
PlayerSoundEventBase
Definition: damageevents.c:1
DAMAGE
@ DAMAGE
Definition: playersoundeventbase.c:6
m_DummyStartTime
float m_DummyStartTime
Definition: playersoundeventbase.c:34
InitEx
void InitEx(PlayerBase player, int param)
Definition: playersoundeventbase.c:135
Play
override bool Play()
Definition: playersoundeventbase.c:174
HIGHEST_PRIORITY
enum EPlayerSoundEventType HIGHEST_PRIORITY
IsFinished
bool IsFinished()
Definition: playersoundeventbase.c:79
m_Param
int m_Param
Definition: soundevents.c:9
ENUM_COUNT
enum EPlayerSoundEventType ENUM_COUNT
INJURY
@ INJURY
Definition: playersoundeventbase.c:8
m_Player
enum EPlayerSoundEventType m_Player
EPlayerSoundEventType
EPlayerSoundEventType
Definition: playersoundeventbase.c:1
PlayerSoundEventBase
void PlayerSoundEventBase()
Definition: playersoundeventbase.c:58
Math
Definition: enmath.c:6
EPlayerSoundEventID
EPlayerSoundEventID
Definition: playersoundeventhandler.c:1
Init
void Init(PlayerBase player)
Definition: playersoundeventbase.c:130
GetSoundVoiceAnimEventClassID
int GetSoundVoiceAnimEventClassID()
Definition: playersoundeventbase.c:69
m_DummySoundLength
float m_DummySoundLength
Definition: playersoundeventbase.c:33
m_SoundVoiceAnimEventClassID
int m_SoundVoiceAnimEventClassID
Definition: soundevents.c:5