kitbase.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. class KitBase extends ItemBase
  2. {
  3. protected bool m_DeployedRegularly;
  4. override bool IsBasebuildingKit()
  5. {
  6. return true;
  7. }
  8. override bool HasProxyParts()
  9. {
  10. return true;
  11. }
  12. override bool CanProxyObstruct()
  13. {
  14. return false;
  15. }
  16. override void EEInit()
  17. {
  18. super.EEInit();
  19. //set visual on init
  20. UpdateVisuals();
  21. UpdatePhysics();
  22. if (GetGame().IsServer())
  23. {
  24. GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Call( AssembleKit );
  25. }
  26. }
  27. override bool DisassembleOnLastDetach()
  28. {
  29. return true;
  30. }
  31. override void EEItemDetached(EntityAI item, string slot_name)
  32. {
  33. super.EEItemDetached( item, slot_name );
  34. PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
  35. if ( player && player.IsPlayerDisconnected() )
  36. return;
  37. if (item && slot_name == "Rope")
  38. {
  39. if (GetGame().IsServer() && !m_DeployedRegularly)
  40. {
  41. DisassembleKit(ItemBase.Cast(item));
  42. Delete();
  43. }
  44. }
  45. }
  46. override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner )
  47. {
  48. super.OnItemLocationChanged( old_owner, new_owner );
  49. //update visuals after location change
  50. UpdatePhysics();
  51. }
  52. override void OnEndPlacement()
  53. {
  54. m_DeployedRegularly = true;
  55. }
  56. override void OnPlacementCancelled( Man player )
  57. {
  58. super.OnPlacementCancelled(player);
  59. m_DeployedRegularly = false;
  60. }
  61. override bool IsDeployable()
  62. {
  63. return true;
  64. }
  65. override bool CanAssignAttachmentsToQuickbar()
  66. {
  67. return false;
  68. }
  69. override string GetDeploySoundset()
  70. {
  71. return "putDown_FenceKit_SoundSet";
  72. }
  73. override string GetLoopDeploySoundset()
  74. {
  75. return "Shelter_Site_Build_Loop_SoundSet";
  76. }
  77. override void RefreshPhysics()
  78. {
  79. super.RefreshPhysics();
  80. UpdatePhysics();
  81. }
  82. //Update visuals and physics
  83. void UpdateVisuals()
  84. {
  85. SetAnimationPhase( "Inventory", 0 );
  86. SetAnimationPhase( "Placing", 1 );
  87. }
  88. void UpdatePhysics()
  89. {
  90. AddProxyPhysics( "Inventory" );
  91. RemoveProxyPhysics( "Placing" );
  92. }
  93. void AssembleKit()
  94. {
  95. if (!IsHologram())
  96. {
  97. Rope rope = Rope.Cast(GetInventory().CreateAttachment("Rope"));
  98. }
  99. }
  100. void DisassembleKit(ItemBase item) {}
  101. void CreateRope(Rope rope)
  102. {
  103. if (!rope)
  104. return;
  105. InventoryLocation targetLoc = rope.GetTargetLocation();
  106. if (targetLoc && targetLoc.GetType() != InventoryLocationType.GROUND)
  107. {
  108. MiscGameplayFunctions.TransferItemProperties(this, rope);
  109. return;
  110. }
  111. EntityAI newRope = EntityAI.Cast(GetGame().CreateObjectEx(rope.GetType(), GetPosition(), ECE_PLACE_ON_SURFACE));
  112. if (newRope)
  113. MiscGameplayFunctions.TransferItemProperties(this, newRope);
  114. rope.Delete();
  115. }
  116. override void SetActions()
  117. {
  118. super.SetActions();
  119. AddAction(ActionTogglePlaceObject);
  120. AddAction(ActionDeployObject);
  121. }
  122. //!DEPRECATED
  123. protected ref EffectSound m_DeployLoopSound; //DEPRECATED in favor of m_DeployLoopSoundEx
  124. void PlayDeployLoopSound(); //!DEPRECATED
  125. void StopDeployLoopSound(); //!DEPRECATED
  126. }