27 static protected const int INITIAL_BURNING_STATE_TIME = 5;
28 static protected const int FINAL_BURNING_STATE_TIME = 60;
29 static protected vector m_FlameLocalPos =
"0 0.285 0";
33 RoadflareLight m_Light;
41 static protected int PARTICLE_INIT_FIRE =
ParticleList.ROADFLARE_BURNING_INIT;
42 static protected int PARTICLE_MAIN_FIRE =
ParticleList.ROADFLARE_BURNING_MAIN;
43 static protected int PARTICLE_FINAL_FIRE =
ParticleList.ROADFLARE_BURNING_ENDING;
44 static protected int PARTICLE_FINAL_SMOKE =
ParticleList.ROADFLARE_BURNING_SMOKE;
49 static protected const string BURNING_SOUND =
"roadflareLoop_SoundSet";
50 static protected const string IGNITE_SOUND =
"roadflareTurnOn_SoundSet";
51 static protected const int BURNING_NOISE_RANGE = 30;
54 ref
Timer m_FinalSmokeTimer;
60 static const string STANDS_FOLDED =
"Sticks_Flare_Folded";
61 static const string STANDS_UNFOLDED =
"Sticks_Flare_Unfolded";
62 static const string FLARE_CAP =
"Flare_cap";
63 static const string UNIGNITED_TIP =
"Pristine";
64 static const string IGNITED_TIP =
"Burning";
65 static const string EXTINGUISHED_TIP =
"Burned_out";
67 static const int SELECTION_Burning = 0;
68 static const int SELECTION_Burned_out = 1;
69 static const int SELECTION_Pristine = 2;
70 static const int SELECTION_All = 3;
72 static const string DEFAULT_TEXTURE =
"dz\\gear\\consumables\\data\\road_flare_co.paa";
73 static const string BURNING_TEXTURE =
"dz\\gear\\consumables\\data\\road_flare_e_co.paa";
75 static const string DEFAULT_MATERIAL =
"dz\\gear\\consumables\\data\\road_flare.rvmat";
76 static const string BURNING_MATERIAL =
"dz\\gear\\consumables\\data\\road_flare_on.rvmat";
80 private float m_NoiseTimer;
84 RegisterNetSyncVariableInt(
"m_BurningState");
88 void SetModelState(
int enum_state)
90 m_ModelState = enum_state;
91 UpdateModelSelections();
94 override void EEDelete(
EntityAI parent)
96 super.EEDelete(parent);
102 delete m_FinalSmokeTimer;
105 DestroyAllParticles();
113 super.OnStoreSave(ctx);
115 ctx.Write( m_ModelState );
120 if ( !super.OnStoreLoad(ctx, version) )
124 if ( !ctx.Read(state) )
127 SetModelState(state);
132 void UpdateModelSelections()
134 switch (m_ModelState)
138 ShowSelection(FLARE_CAP);
139 ShowSelection(UNIGNITED_TIP);
141 HideSelection(IGNITED_TIP);
142 HideSelection(EXTINGUISHED_TIP);
144 SetObjectTexture(SELECTION_Pristine, DEFAULT_TEXTURE);
145 SetObjectMaterial(SELECTION_Pristine, DEFAULT_MATERIAL);
151 ShowSelection(UNIGNITED_TIP);
153 HideSelection(FLARE_CAP);
154 HideSelection(IGNITED_TIP);
155 HideSelection(EXTINGUISHED_TIP);
157 SetObjectTexture(SELECTION_Pristine, DEFAULT_TEXTURE);
158 SetObjectMaterial(SELECTION_Pristine, DEFAULT_MATERIAL);
164 ShowSelection(IGNITED_TIP);
166 HideSelection(UNIGNITED_TIP);
167 HideSelection(FLARE_CAP);
168 HideSelection(EXTINGUISHED_TIP);
176 ShowSelection(EXTINGUISHED_TIP);
178 HideSelection(UNIGNITED_TIP);
179 HideSelection(FLARE_CAP);
180 HideSelection(IGNITED_TIP);
182 SetObjectTexture(SELECTION_Burned_out, DEFAULT_TEXTURE);
183 SetObjectMaterial(SELECTION_Burned_out, DEFAULT_MATERIAL);
190 override void OnWorkStart()
195 PlaySoundSet( m_IgniteSound, IGNITE_SOUND, 0, 0 );
220 void SetBurningState(
int state_number)
222 m_BurningState = state_number;
226 void SetBurningStateSynchronized(
int state_number)
230 m_BurningState = state_number;
236 override void OnWork(
float consumed_energy)
240 float burning_time = GetCompEM().GetEnergyMax() - GetCompEM().GetEnergy();
245 if (burning_time >= INITIAL_BURNING_STATE_TIME)
261 if ( burning_time >= GetCompEM().GetEnergyMax() - FINAL_BURNING_STATE_TIME )
282 UpdateActiveParticles();
286 override void OnWorkStop()
288 if (
GetGame().IsMissionMainMenu() )
291 UpdateActiveParticles();
311 UpdateActiveParticles();
313 m_FinalSmokeTimer.Run(60,
this,
"StopSmoking", NULL,
false);
327 void UpdateActiveParticles()
329 if (
GetGame().IsDedicatedServer() )
332 switch (m_BurningState)
336 DestroyAllParticles();
341 if (!m_ParInitialFire)
343 DestroyAllParticles();
344 m_ParInitialFire =
ParticleManager.GetInstance().PlayOnObject( PARTICLE_INIT_FIRE,
this, m_FlameLocalPos);
345 m_ParInitialFire.SetWiggle( 10, 0.3 );
357 DestroyParticleEx(m_ParInitialFire);
365 DestroyAllParticles();
366 m_ParFinalFire =
ParticleManager.GetInstance().PlayOnObject( PARTICLE_FINAL_FIRE,
this, m_FlameLocalPos);
367 m_ParFinalFire.SetWiggle( 4, 0.3 );
375 DestroyAllParticles();
376 m_ParJustSmoke =
ParticleManager.GetInstance().PlayOnObject( PARTICLE_FINAL_SMOKE,
this, m_FlameLocalPos);
377 m_ParJustSmoke.SetWiggle( 2, 0.3 );
393 void DestroyParticleEx( out
Particle p )
400 void DestroyAllParticles()
402 DestroyParticleEx(m_ParInitialFire);
404 DestroyParticleEx(m_ParFinalFire);
405 DestroyParticleEx(m_ParJustSmoke);
412 UpdateActiveParticles();
416 override void OnInventoryExit(Man player)
418 super.OnInventoryExit(player);
422 HideSelection(STANDS_FOLDED);
423 ShowSelection(STANDS_UNFOLDED);
427 vector ori_rotate = player.GetOrientation();
428 ori_rotate = ori_rotate +
Vector(180, 32, 0);
429 SetOrientation(ori_rotate);
434 override bool CanPutInCargo(
EntityAI parent )
436 if ( !super.CanPutInCargo(parent) )
448 override void OnInventoryEnter(Man player)
450 super.OnInventoryEnter(player);
452 HideSelection(STANDS_UNFOLDED);
453 ShowSelection(STANDS_FOLDED);
456 override void OnActivatedByItem(notnull
ItemBase item)
460 GetCompEM().SwitchOn();
464 override bool CanIgniteItem(
EntityAI ignite_target = NULL)
466 return GetCompEM().IsWorking();
469 override void OnVariablesSynchronized()
471 super.OnVariablesSynchronized();
473 UpdateActiveParticles();
476 override void SetActions()