refridgerator.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. class Refridgerator extends ItemBase
  2. {
  3. SoundOnVehicle m_SoundLoopEntity;
  4. override bool IsElectricAppliance()
  5. {
  6. return true;
  7. }
  8. override void OnInitEnergy()
  9. {
  10. m_SoundLoopEntity = NULL;
  11. }
  12. //--- POWER EVENTS
  13. override void OnWorkStart()
  14. {
  15. // TO DO: Slow down or stop the aging of food inside of the fridge when such functionality is created.
  16. m_SoundLoopEntity = PlaySoundLoop("powerGeneratorLoop", 50); // using placeholder sound
  17. }
  18. override void OnWork( float consumed_energy )
  19. {
  20. }
  21. override void OnWorkStop()
  22. {
  23. // TO DO: Allow food inside the fridge to start aging again.
  24. GetGame().ObjectDelete(m_SoundLoopEntity);
  25. m_SoundLoopEntity = NULL;
  26. }
  27. //--- ACTION EVENTS
  28. override void OnSwitchOn()
  29. {
  30. }
  31. override void OnSwitchOff()
  32. {
  33. }
  34. override void OnVariablesSynchronized()
  35. {
  36. super.OnVariablesSynchronized();
  37. if ( IsPlaceSound() )
  38. {
  39. PlayPlaceSound();
  40. }
  41. }
  42. //================================================================
  43. // ADVANCED PLACEMENT
  44. //================================================================
  45. override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
  46. {
  47. super.OnPlacementComplete( player, position, orientation );
  48. SetIsPlaceSound( true );
  49. }
  50. override string GetPlaceSoundset()
  51. {
  52. return "placeRefridgerator_SoundSet";
  53. }
  54. override void SetActions()
  55. {
  56. super.SetActions();
  57. RemoveAction(ActionTakeItemToHands);
  58. AddAction(ActionPlugIn);
  59. AddAction(ActionTogglePlaceObject);
  60. AddAction(ActionUnplugThisByCord);
  61. AddAction(ActionTurnOnWhileOnGround);
  62. AddAction(ActionTurnOffWhileOnGround);
  63. AddAction(ActionRepositionPluggedItem);
  64. AddAction(ActionPlaceObject);
  65. AddAction(ActionTakeItemToHands);
  66. }
  67. }