RopeEntity.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ----------------------------------------------------------------------------------------------------
  2. --
  3. -- Copyright (c) Contributors to the Open 3D Engine Project.
  4. -- For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. --
  6. -- SPDX-License-Identifier: Apache-2.0 OR MIT
  7. --
  8. --
  9. --
  10. ----------------------------------------------------------------------------------------------------
  11. Script.ReloadScript("scripts/Utils/EntityUtils.lua")
  12. RopeEntity =
  13. {
  14. Properties=
  15. {
  16. MultiplayerOptions = {
  17. bNetworked = 0,
  18. },
  19. },
  20. }
  21. ------------------------------------------------------------------------------------------------------
  22. function RopeEntity:OnSpawn()
  23. if (self.Properties.MultiplayerOptions.bNetworked == 0) then
  24. self:SetFlags(ENTITY_FLAG_CLIENT_ONLY,0);
  25. end
  26. end
  27. ------------------------------------------------------------------------------------------------------
  28. function RopeEntity:OnPhysicsBreak( vPos,nPartId,nOtherPartId )
  29. self:ActivateOutput("Break",nPartId+1 );
  30. end
  31. ------------------------------------------------------------------------------------------------------
  32. function RopeEntity:Event_Remove()
  33. self:DrawSlot(0,0);
  34. self:DestroyPhysics();
  35. self:ActivateOutput( "Remove", true );
  36. end
  37. ------------------------------------------------------------------------------------------------------
  38. function RopeEntity:Event_Hide()
  39. self:Hide(1);
  40. self:ActivateOutput( "Hide", true );
  41. end
  42. ------------------------------------------------------------------------------------------------------
  43. function RopeEntity:Event_UnHide()
  44. self:Hide(0);
  45. self:ActivateOutput( "UnHide", true );
  46. end
  47. ------------------------------------------------------------------------------------------------------
  48. function RopeEntity:Event_BreakStart( vPos,nPartId,nOtherPartId )
  49. local RopeParams = {}
  50. RopeParams.entity_name_1 = "#unattached";
  51. self:SetPhysicParams(PHYSICPARAM_ROPE,RopeParams);
  52. end
  53. function RopeEntity:Event_BreakEnd( vPos,nPartId,nOtherPartId )
  54. local RopeParams = {}
  55. RopeParams.entity_name_2 = "#unattached";
  56. self:SetPhysicParams(PHYSICPARAM_ROPE,RopeParams);
  57. end
  58. function RopeEntity:Event_BreakDist( sender, dist )
  59. local RopeParams = {}
  60. RopeParams.break_point = dist;
  61. self:SetPhysicParams(PHYSICPARAM_ROPE,RopeParams);
  62. end
  63. function RopeEntity:Event_Disable()
  64. local RopeParams = {}
  65. RopeParams.bDisabled = 1;
  66. self:SetPhysicParams(PHYSICPARAM_ROPE,RopeParams);
  67. end
  68. function RopeEntity:Event_Enable()
  69. local RopeParams = {}
  70. RopeParams.bDisabled = 0;
  71. self:SetPhysicParams(PHYSICPARAM_ROPE,RopeParams);
  72. end
  73. RopeEntity.FlowEvents =
  74. {
  75. Inputs =
  76. {
  77. Hide = { RopeEntity.Event_Hide, "bool" },
  78. UnHide = { RopeEntity.Event_UnHide, "bool" },
  79. Remove = { RopeEntity.Event_Remove, "bool" },
  80. BreakStart = { RopeEntity.Event_BreakStart, "bool" },
  81. BreakEnd = { RopeEntity.Event_BreakEnd, "bool" },
  82. BreakDist = { RopeEntity.Event_BreakDist, "float" },
  83. Disable = { RopeEntity.Event_Disable, "bool" },
  84. Enable = { RopeEntity.Event_Enable, "bool" },
  85. },
  86. Outputs =
  87. {
  88. Hide = "bool",
  89. UnHide = "bool",
  90. Remove = "bool",
  91. Break = "int",
  92. },
  93. }