Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
portablegaslamp.c
Go to the documentation of this file.
1 class PortableGasLamp extends ItemBase
2 {
3  PortableGasLampLight m_Light;
4 
5  private const string GAS_LIGHT_MATERIAL_ON = "dz\\gear\\cooking\\data\\GasLightOn.rvmat";
6  private const string GAS_LIGHT_MATERIAL_OFF = "dz\\data\\data\\default.rvmat";
7 
8  //sound
9  const string SOUND_BURNING = "portablegaslamp_burn_SoundSet";
10  const string SOUND_TURN_ON = "portablegaslamp_turn_on_SoundSet";
11  const string SOUND_TURN_OFF = "portablegaslamp_turn_off_SoundSet";
12 
13  protected EffectSound m_SoundBurningLoop;
14  protected EffectSound m_SoundTurnOn;
15  protected EffectSound m_SoundTurnOff;
16 
17  //--- POWER EVENTS
18  override void OnSwitchOn()
19  {
20  super.OnSwitchOn();
21 
22  //sound (client only)
23  SoundTurnOn();
24  }
25 
26  override void OnSwitchOff()
27  {
28  super.OnSwitchOff();
29 
30  //sound (client only)
31  SoundTurnOff();
32  }
33 
34  override void OnWorkStart()
35  {
36  if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() ) // client side
37  {
38  m_Light = PortableGasLampLight.Cast( ScriptedLightBase.CreateLight( PortableGasLampLight, "0 0 0") );
39  m_Light.AttachOnMemoryPoint(this, "light");
40  }
41 
42  //refresh visual
43  SetObjectMaterial( 0, GAS_LIGHT_MATERIAL_ON );
44 
45  //sound (client only)
46  SoundBurningStart();
47  }
48 
49  override void OnWorkStop()
50  {
51  if (m_Light)
52  m_Light.FadeOut();
53 
54  //refresh visual
55  SetObjectMaterial( 0, GAS_LIGHT_MATERIAL_OFF );
56 
57  //sound (client only)
58  SoundBurningStop();
59  }
60 
61  //================================================================
62  // SOUNDS
63  //================================================================
64  protected void SoundBurningStart()
65  {
66  PlaySoundSetLoop( m_SoundBurningLoop, SOUND_BURNING, 0.1, 0.3 );
67  }
68 
69  protected void SoundBurningStop()
70  {
71  StopSoundSet( m_SoundBurningLoop );
72  }
73 
74  protected void SoundTurnOn()
75  {
76  PlaySoundSet( m_SoundTurnOn, SOUND_TURN_ON, 0.1, 0.1 );
77  }
78 
79  protected void SoundTurnOff()
80  {
81  PlaySoundSet( m_SoundTurnOff, SOUND_TURN_OFF, 0.1, 0.1 );
82  }
83 
84  override void SetActions()
85  {
86  super.SetActions();
87 
92  }
93 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionTurnOnWhileInHands
Definition: actionturnonwhileinhands.c:1
OnWorkStop
override void OnWorkStop()
Definition: m18smokegrenade_colorbase.c:2
m_Light
protected ExplosiveLight m_Light
light
Definition: explosivesbase.c:31
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
ScriptedLightBase
Definition: pointlightbase.c:1
SetActions
void SetActions()
Definition: advancedcommunication.c:79
ActionTurnOffWhileInHands
Definition: actionturnoffwhileinhands.c:1
ActionTurnOffWhileOnGround
Definition: actionturnoffwhileonground.c:1
ActionTurnOnWhileOnGround
Definition: actionturnonwhileonground.c:1
OnWorkStart
override void OnWorkStart()
Definition: smokegrenadebase.c:175