contaminatedarea_local.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. class ContaminatedArea_Local : ContaminatedArea_DynamicBase
  2. {
  3. const float TICK_RATE = 1;
  4. ref Timer m_Timer1 = new Timer;
  5. float m_Lifetime = 360;
  6. void ContaminatedArea_Local()
  7. {
  8. m_EffectsPriority = -10;
  9. }
  10. override void SetupZoneData(EffectAreaParams params)
  11. {
  12. params.m_ParamPartId = ParticleList.CONTAMINATED_AREA_GAS_AROUND;
  13. params.m_ParamInnerRings = 0;
  14. params.m_ParamPosHeight = 3;
  15. params.m_ParamNegHeight = 3;
  16. params.m_ParamRadius = 10;
  17. params.m_ParamOuterToggle = false;
  18. params.m_ParamTriggerType = "ContaminatedTrigger_Local";
  19. params.m_ParamAroundPartId = 0;
  20. params.m_ParamTinyPartId = 0;
  21. super.SetupZoneData(params);
  22. InitZone();
  23. }
  24. override void EEInit()
  25. {
  26. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  27. m_Timer1.Run(TICK_RATE, this, "Tick", NULL, true);
  28. }
  29. override void DeferredInit()
  30. {
  31. super.DeferredInit();
  32. if (!m_ToxicClouds)
  33. m_ToxicClouds = new array<Particle>();
  34. SetupZoneData(new EffectAreaParams);
  35. }
  36. override void SpawnParticles(ParticlePropertiesArray props, vector centerPos, vector partPos, inout int count)
  37. {
  38. partPos[1] = GetGame().SurfaceRoadY(partPos[0], partPos[2]); // Snap particles to ground
  39. // We make sure that spawned particle is inside the trigger
  40. if (!Math.IsInRange(partPos[1], centerPos[1] - m_NegativeHeight, centerPos[1] + m_PositiveHeight))
  41. partPos[1] = centerPos[1];
  42. props.Insert(ParticleProperties(partPos, ParticlePropertiesFlags.PLAY_ON_CREATION, null, GetGame().GetSurfaceOrientation( partPos[0], partPos[2] ), this));
  43. ++count;
  44. }
  45. override float GetStartDecayLifetime()
  46. {
  47. return 20;
  48. }
  49. override float GetFinishDecayLifetime()
  50. {
  51. return 10;
  52. }
  53. override float GetRemainingTime()
  54. {
  55. return m_Lifetime;
  56. }
  57. override void Tick()
  58. {
  59. m_Lifetime -= TICK_RATE;
  60. if (m_Lifetime <= 0)
  61. Delete();
  62. }
  63. }