Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
infectedsoundeventhandler.c
Go to the documentation of this file.
2 {
6  //MINDSTATE_CHASE_IDLE,
10  //--------------
12 }
13 
14 class InfectedSoundEventHandler extends SoundEventHandler
15 {
16  const int SOUND_EVENTS_MAX = EInfectedSoundEventID.ENUM_COUNT;
17  static ref InfectedSoundEventBase m_AvailableStates[SOUND_EVENTS_MAX];
20 
22  {
23  m_Infected = pInfected;
24  m_AvailableStates[EInfectedSoundEventID.MINDSTATE_CALM_IDLE] = new CalmIdleSoundEvent();
25  m_AvailableStates[EInfectedSoundEventID.MINDSTATE_CALM_MOVE] = new CalmMoveSoundEvent();
26  m_AvailableStates[EInfectedSoundEventID.MINDSTATE_DISTURBED_IDLE] = new DisturbedIdleSoundEvent();
27  //m_AvailableStates[EInfectedSoundEventID.MINDSTATE_CHASE_IDLE] = new ChaseIdleSoundEvent();
28  m_AvailableStates[EInfectedSoundEventID.MINDSTATE_CHASE_MOVE] = new ChaseMoveSoundEvent();
29  m_AvailableStates[EInfectedSoundEventID.MINDSTATE_ALERTED_IDLE] = new AlertedIdleSoundEvent();
30  m_AvailableStates[EInfectedSoundEventID.MINDSTATE_ALERTED_MOVE] = new AlertedMoveSoundEvent();
31  }
32 
33  override static int GetSoundEventType(int id)
34  {
35  return m_AvailableStates[id].GetSoundEventType();
36  }
37 
38  override int GetCurrentStateEventID()
39  {
40  if (m_CurrentState)
41  {
42  return m_CurrentState.GetSoundEventID();
43  }
44  return -1;
45  }
46 
47  override int GetCurrentStateEventType()
48  {
49  if (m_CurrentState)
50  {
51  return m_CurrentState.GetSoundEventType();
52  }
53  return -1;
54  }
55 
56  void Stop()
57  {
58  if ( m_CurrentState )
59  {
60  m_CurrentState.Stop();
61  }
62  }
63 
64  void SoftStop()
65  {
66  if ( m_CurrentState )
67  {
68  m_CurrentState.SoftStop();
69  }
70  }
71 
72  bool IsPlaying()
73  {
74  if ( m_CurrentState && m_CurrentState.IsSoundCallbackExist() )
75  {
76  return true;
77  }
78 
79  return false;
80  }
81 
82  override bool PlayRequest(int id, bool sent_from_server = false)
83  {
84  InfectedSoundEventBase requested_state = m_AvailableStates[id];
85 
86  if ( !requested_state.CanPlay() )
87  {
88  return false;
89  }
90 
91  if (m_CurrentState)
92  {
93  if (!m_CurrentState.IsSoundCallbackExist())
94  {
95  //Print("Missing callback - cleanup and continue");
96  delete m_CurrentState;
97  }
98 
100  if (GetCurrentStateEventID() == id)
101  {
102  //Print("Same ID - skipping");
103  return false;
104  }
105  }
106 
107  if (m_CurrentState)
108  {
109  m_CurrentState.SoftStop();
110  m_CurrentState = InfectedSoundEventBase.Cast(requested_state.ClassName().ToType().Spawn());
112  m_CurrentState.Play();
113  return true;
114  }
115  else
116  {
117  m_CurrentState = InfectedSoundEventBase.Cast(requested_state.ClassName().ToType().Spawn());
119  m_CurrentState.Play();
120  return true;
121  }
122 
123  return false;//should never get here
124  }
125 }
SOUND_EVENTS_MAX
enum EInfectedSoundEventID SOUND_EVENTS_MAX
IsPlaying
bool IsPlaying()
Definition: infectedsoundeventhandler.c:72
MINDSTATE_DISTURBED_IDLE
@ MINDSTATE_DISTURBED_IDLE
Definition: infectedsoundeventhandler.c:5
Stop
void Stop()
Definition: infectedsoundeventhandler.c:56
MINDSTATE_CALM_IDLE
@ MINDSTATE_CALM_IDLE
Definition: infectedsoundeventhandler.c:3
AlertedIdleSoundEvent
class ChaseMoveSoundEvent extends MindStateSoundEventBase AlertedIdleSoundEvent()
Definition: mindstates.c:55
CalmMoveSoundEvent
void CalmMoveSoundEvent()
Definition: mindstates.c:2
MINDSTATE_CALM_MOVE
@ MINDSTATE_CALM_MOVE
Definition: infectedsoundeventhandler.c:4
m_CurrentState
ref InfectedSoundEventBase m_CurrentState
Definition: infectedsoundeventhandler.c:18
MINDSTATE_CHASE_MOVE
@ MINDSTATE_CHASE_MOVE
Definition: infectedsoundeventhandler.c:7
GetCurrentStateEventType
override int GetCurrentStateEventType()
Definition: infectedsoundeventhandler.c:47
ChaseMoveSoundEvent
void ChaseMoveSoundEvent()
Definition: mindstates.c:2
MINDSTATE_ALERTED_MOVE
@ MINDSTATE_ALERTED_MOVE
Definition: infectedsoundeventhandler.c:9
InfectedSoundEventBase
Definition: mindstates.c:1
MINDSTATE_ALERTED_IDLE
@ MINDSTATE_ALERTED_IDLE
Definition: infectedsoundeventhandler.c:8
PlayRequest
override bool PlayRequest(int id, bool sent_from_server=false)
Definition: infectedsoundeventhandler.c:82
DisturbedIdleSoundEvent
class CalmMoveSoundEvent extends MindStateSoundEventBase DisturbedIdleSoundEvent()
Definition: mindstates.c:35
m_Infected
ZombieBase m_Infected
Definition: infectedsoundeventhandler.c:19
GetCurrentStateEventID
override int GetCurrentStateEventID()
Definition: infectedsoundeventhandler.c:38
InfectedSoundEventHandler
void InfectedSoundEventHandler(ZombieBase pInfected)
Definition: infectedsoundeventhandler.c:21
CalmIdleSoundEvent
class MindStateSoundEventBase extends InfectedSoundEventBase CalmIdleSoundEvent()
Definition: mindstates.c:15
EInfectedSoundEventID
EInfectedSoundEventID
Definition: infectedsoundeventhandler.c:1
ZombieBase
Definition: zombiefemalebase.c:1
SoftStop
void SoftStop()
Definition: infectedsoundeventhandler.c:64
ENUM_COUNT
@ ENUM_COUNT
Definition: infectedsoundeventhandler.c:11