xmaslights.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. class XmasLights extends Inventory_Base
  2. {
  3. private ItemBase m_AttachedTo = NULL;
  4. void XmasLights()
  5. {
  6. TurnOffItem( this );
  7. }
  8. override bool IsElectricAppliance()
  9. {
  10. return true;
  11. }
  12. override void OnWorkStart()
  13. {
  14. TurnOnItem( m_AttachedTo );
  15. TurnOnItem( this );
  16. }
  17. override void OnWorkStop()
  18. {
  19. TurnOffItem( m_AttachedTo );
  20. TurnOffItem( this );
  21. }
  22. void AttachToObject(ItemBase parent)
  23. {
  24. //SetPilotLight( false );
  25. m_AttachedTo = parent;
  26. TurnOnItem( parent );
  27. if ( GetCompEM().IsPlugged() )
  28. {
  29. parent.SetAnimationPhase( "Cord_plugged", 0);
  30. parent.SetAnimationPhase( "Cord_folded", 1);
  31. }
  32. else
  33. {
  34. parent.SetAnimationPhase( "Cord_plugged", 1);
  35. parent.SetAnimationPhase( "Cord_folded", 0);
  36. }
  37. }
  38. void DetachFromObject(ItemBase parent)
  39. {
  40. m_AttachedTo = NULL;
  41. HideOnItem( parent );
  42. TurnOnItem( this );
  43. GetCompEM().UnplugThis();
  44. }
  45. void TurnOnItem(ItemBase item)
  46. {
  47. if ( item != NULL )
  48. {
  49. if ( GetCompEM().IsWorking() )
  50. {
  51. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_r"), "dz\\gear\\camping\\data\\christmas_lights_red_on.rvmat" );
  52. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_g"), "dz\\gear\\camping\\data\\christmas_lights_green_on.rvmat" );
  53. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_b"), "dz\\gear\\camping\\data\\christmas_lights_blue_on.rvmat" );
  54. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_y"), "dz\\gear\\camping\\data\\christmas_lights_yellow_on.rvmat" );
  55. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_r"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  56. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_g"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  57. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_b"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  58. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_y"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  59. //item.SetPilotLight(true);
  60. }
  61. else
  62. {
  63. TurnOffItem( item );
  64. }
  65. }
  66. }
  67. void TurnOffItem(ItemBase item)
  68. {
  69. if ( item != NULL )
  70. {
  71. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_r"), "dz\\gear\\camping\\data\\christmass_ligths_string.rvmat" );
  72. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_g"), "dz\\gear\\camping\\data\\christmass_ligths_string.rvmat" );
  73. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_b"), "dz\\gear\\camping\\data\\christmass_ligths_string.rvmat" );
  74. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_y"), "dz\\gear\\camping\\data\\christmass_ligths_string.rvmat" );
  75. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_r"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  76. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_g"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  77. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_b"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  78. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_y"), "dz\\gear\\camping\\data\\christmas_lights_string_ca.paa" );
  79. //item.SetPilotLight(false);
  80. }
  81. }
  82. void HideOnItem(ItemBase item)
  83. {
  84. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_r"), "" );
  85. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_g"), "" );
  86. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_b"), "" );
  87. item.SetObjectMaterial( item.GetHiddenSelectionIndex("xlights_glass_y"), "" );
  88. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_r"), "" );
  89. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_g"), "" );
  90. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_b"), "" );
  91. item.SetObjectTexture( item.GetHiddenSelectionIndex("xlights_glass_y"), "" );
  92. // item.SetPilotLight(false);
  93. item.SetAnimationPhase( "Cord_plugged", 1);
  94. item.SetAnimationPhase( "Cord_folded", 1);
  95. }
  96. // --------------------------------------------------
  97. // Advanced placement
  98. //---------------------------------------------------
  99. override void SetActions()
  100. {
  101. super.SetActions();
  102. AddAction(ActionAttachOnProxy);
  103. AddAction(ActionPlugIn);
  104. AddAction(ActionUnplugThisByCord);
  105. }
  106. }