shelterkit.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. class ShelterKit extends KitBase
  2. {
  3. override bool CanReceiveAttachment(EntityAI attachment, int slotId)
  4. {
  5. if ( !super.CanReceiveAttachment(attachment, slotId) )
  6. return false;
  7. ItemBase att = ItemBase.Cast(GetInventory().FindAttachment(slotId));
  8. if (att)
  9. return false;
  10. return true;
  11. }
  12. //================================================================
  13. // ADVANCED PLACEMENT
  14. //================================================================
  15. override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
  16. {
  17. super.OnPlacementComplete( player, position, orientation );
  18. if ( GetGame().IsServer() )
  19. {
  20. //Create shelter site
  21. ShelterSite site = ShelterSite.Cast( GetGame().CreateObjectEx( "ShelterSite", GetPosition(), ECE_PLACE_ON_SURFACE ) );
  22. site.SetPosition( position );
  23. site.SetOrientation( orientation );
  24. //make the kit invisible, so it can be destroyed from deploy UA when action ends
  25. HideAllSelections();
  26. }
  27. }
  28. override bool DoPlacingHeightCheck()
  29. {
  30. return true;
  31. }
  32. override float HeightCheckOverride()
  33. {
  34. return 1.6;
  35. }
  36. override string GetPlaceSoundset()
  37. {
  38. return "Shelter_Site_Build_Start_SoundSet";
  39. }
  40. override string GetDeploySoundset()
  41. {
  42. return "Shelter_Site_Build_Finish_SoundSet";
  43. }
  44. override void DisassembleKit(ItemBase item)
  45. {
  46. if (!IsHologram())
  47. {
  48. ItemBase stick = ItemBase.Cast(GetGame().CreateObjectEx("WoodenStick",GetPosition(),ECE_PLACE_ON_SURFACE));
  49. MiscGameplayFunctions.TransferItemProperties(this, stick);
  50. stick.SetQuantity(4);
  51. Rope rope = Rope.Cast(item);
  52. CreateRope(rope);
  53. }
  54. }
  55. //Debug menu Spawn Ground Special
  56. override void OnDebugSpawn()
  57. {
  58. SpawnEntityOnGroundPos("Shovel", GetPosition());
  59. SpawnEntityOnGroundPos("Hammer", GetPosition());
  60. SpawnEntityOnGroundPos("Pliers", GetPosition());
  61. for (int i0 = 0; i0 < 4; ++i0)
  62. {
  63. SpawnEntityOnGroundPos("LongWoodenStick", GetPosition());
  64. }
  65. for (int i1 = 0; i1 < 8; ++i1)
  66. {
  67. SpawnEntityOnGroundPos("TannedLeather", GetPosition());
  68. }
  69. for (int i2 = 0; i2 < 4; ++i2)
  70. {
  71. SpawnEntityOnGroundPos("Fabric", GetPosition());
  72. }
  73. for (int i3 = 0; i3 < 50; ++i3)
  74. {
  75. SpawnEntityOnGroundPos("WoodenStick", GetPosition());
  76. }
  77. }
  78. }