land_radio_panelbig.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class Land_Radio_PanelBig : StaticTransmitter
  2. {
  3. override bool DisableVicinityIcon()
  4. {
  5. return true;
  6. }
  7. // --- SYSTEM EVENTS
  8. override void OnStoreSave(ParamsWriteContext ctx)
  9. {
  10. super.OnStoreSave(ctx);
  11. //store tuned frequency
  12. ctx.Write(GetTunedFrequencyIndex());
  13. }
  14. override bool OnStoreLoad(ParamsReadContext ctx, int version)
  15. {
  16. if (!super.OnStoreLoad(ctx, version))
  17. return false;
  18. int tunedFrequencyIndex;
  19. if (!ctx.Read(tunedFrequencyIndex))
  20. tunedFrequencyIndex = 0;
  21. SetFrequencyByIndex(tunedFrequencyIndex);
  22. return true;
  23. }
  24. //--- BASE
  25. override bool IsStaticTransmitter()
  26. {
  27. return true;
  28. }
  29. void SetNextFrequency(PlayerBase player = null)
  30. {
  31. SetNextChannel();
  32. }
  33. //--- POWER EVENTS
  34. override void OnSwitchOn()
  35. {
  36. if (!GetCompEM().CanWork())
  37. GetCompEM().SwitchOff();
  38. }
  39. override void OnWorkStart()
  40. {
  41. //turn on broadcasting
  42. EnableBroadcast(true);
  43. EnableReceive(false);
  44. SwitchOn(true);
  45. }
  46. override void OnWorkStop()
  47. {
  48. //auto switch off (EM)
  49. GetCompEM().SwitchOff();
  50. //turn off broadcasting
  51. EnableBroadcast(false);
  52. SwitchOn(false);
  53. }
  54. override void SetActions()
  55. {
  56. super.SetActions();
  57. AddAction(ActionTuneFrequencyOnGround);
  58. }
  59. }