warheadstoragelight.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. class WarheadStorageLight extends PointLightBase
  2. {
  3. bool m_IsDimmed;
  4. bool m_IsLowEnergyDim;
  5. Land_WarheadStorage_Main m_Bunker;
  6. const string LIGHT_MAT_ON = "DZ\\structures_sakhal\\military\\storage\\data\\Warhead_Storage_Lamp_Glass_e_int.rvmat";
  7. const string LIGHT_MAT_DIM = "DZ\\structures_sakhal\\military\\storage\\data\\Warhead_Storage_Lamp_Glass_dim_int.rvmat";
  8. const string LIGHT_MAT_OFF = "DZ\\structures_sakhal\\military\\storage\\data\\Warhead_Storage_Lamp_Glass_int.rvmat";
  9. void WarheadStorageLight()
  10. {
  11. SetVisibleDuringDaylight(true);
  12. SetRadiusTo(7.5);
  13. SetBrightnessTo(6.5);
  14. FadeIn(1);
  15. SetFadeOutTime(2);
  16. SetFlareVisible(false);
  17. SetCastShadow(true);
  18. SetAmbientColor(1, 0.7, 0.3);
  19. SetDiffuseColor(1, 0.7, 0.3);
  20. UpdateLightSourceMaterial(LIGHT_MAT_ON);
  21. DimmingConfig dimCfg = new DimmingConfig();
  22. dimCfg.AddDimmingPattern({60, 40, 45, 35}, {0.5, 0.1, 0.1, 0.3}, {0, 0, 0, 0}, {0.4, 0.1, 0.3, 0.6}, {3.5, 0, 0.5, 2.5});
  23. dimCfg.AddDimmingPattern({42, 50, 55, 38}, { 0.2, 0.5, 0.1, 0.1}, {0, 0, 0, 0}, {0.2, 0.5, 0.1, 1}, {0.2, 2, 1.2, 1.8});
  24. dimCfg.AddDimmingPattern({50, 40, 35, 55}, { 0.1, 0.2, 0.5, 0.2}, {0, 0, 0, 0}, {0.1, 1, 0.5, 0.3}, {1.25, 0.4, 1.5, 0.5});
  25. DimmingConfig dimCfgSecondary = new DimmingConfig();
  26. dimCfgSecondary.AddDimmingPattern({15, 15, 15, 15}, {0.1, 0.1, 0.1, 0.1}, {2, 0.3, 0.3, 2.5}, {0.7, 1.2, 0.9, 0.7}, {0.5, 0.9, 0.6, 0.7});
  27. dimCfgSecondary.AddDimmingPattern({10, 10, 10, 10}, {0.1, 0.1, 0.1, 0.1}, {2, 0.3, 0.3, 2.5}, {0.7, 1.2, 0.9, 0.7}, {0.5, 0.9, 0.6, 0.7});
  28. dimCfgSecondary.AddDimmingPattern({5, 5, 5, 5}, {0.1, 0.1, 0.1, 0.1}, {2, 0.3, 0.3, 2.5}, {0.7, 1.2, 0.9, 0.7}, {0.5, 0.9, 0.6, 0.7});
  29. dimCfgSecondary.AddDimmingPattern({0, 0, 0, 0}, {0.1, 0.1, 0.1, 0.1}, {2, 0.3, 0.3, 2.5}, {0.7, 1.2, 0.9, 0.7}, {0.5, 0.9, 0.6, 0.7});
  30. dimCfgSecondary.AddDimmingPattern({0, 0, 0, 0}, {0.1, 0.1, 0.1, 0.1}, {2, 0.3, 0.3, 2.5}, {0.7, 1.2, 0.9, 0.7}, {0.5, 0.9, 0.6, 0.7});
  31. dimCfgSecondary.AddDimmingPattern({0, 0, 0, 0}, {0.1, 0.1, 0.1, 0.1}, {2, 0.3, 0.3, 2.5}, {0.7, 1.2, 0.9, 0.7}, {0.5, 0.9, 0.6, 0.7});
  32. EnableDimming(6.5, dimCfg);
  33. GetDimming().AddConfig(dimCfgSecondary);
  34. }
  35. void ~WarheadStorageLight()
  36. {
  37. UpdateLightSourceMaterial(LIGHT_MAT_OFF);
  38. }
  39. override void EOnFrame(IEntity other, float timeSlice)
  40. {
  41. if (!m_LightDimming)
  42. return;
  43. if (!m_Bunker)
  44. m_Bunker = Land_WarheadStorage_Main.Cast(m_Parent);
  45. if (!m_IsDimmed && m_LightDimming.GetState() == ELightDimmingState.DIMMING)
  46. {
  47. m_IsDimmed = true;
  48. if(m_IsLowEnergyDim)
  49. {
  50. UpdateLightSourceMaterial(LIGHT_MAT_OFF);
  51. }
  52. else
  53. {
  54. UpdateLightSourceMaterial(LIGHT_MAT_DIM);
  55. };
  56. }
  57. else if (m_IsDimmed && m_LightDimming.GetState() == ELightDimmingState.BRIGHTENING)
  58. {
  59. m_IsDimmed = false;
  60. UpdateLightSourceMaterial(LIGHT_MAT_ON);
  61. }
  62. if (m_Bunker.IsLowEnergy() && !m_IsLowEnergyDim)
  63. {
  64. m_IsLowEnergyDim = true;
  65. GetDimming().SwapConfig(1);
  66. }
  67. else if (!m_Bunker.IsLowEnergy() && m_IsLowEnergyDim)
  68. {
  69. m_IsLowEnergyDim = false;
  70. GetDimming().SwapConfig(0);
  71. UpdateLightSourceMaterial(LIGHT_MAT_ON);
  72. }
  73. }
  74. }