@quenty/ragdoll 15.23.3 → 15.23.4-canary.559.339cfa7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.json +32 -32
  3. package/src/Client/Classes/RagdollCameraShakeClient.lua +72 -64
  4. package/src/Client/Classes/RagdollClient.lua +1 -2
  5. package/src/Client/Classes/RagdollHumanoidOnDeathClient.lua +2 -2
  6. package/src/Client/Classes/RagdollHumanoidOnFallClient.lua +1 -1
  7. package/src/Client/Classes/RagdollableClient.lua +5 -5
  8. package/src/Client/RagdollBindersClient.lua +5 -5
  9. package/src/Client/RagdollServiceClient.lua +3 -3
  10. package/src/Server/Classes/Ragdoll.lua +3 -3
  11. package/src/Server/Classes/RagdollCameraShake.lua +2 -3
  12. package/src/Server/Classes/RagdollHumanoidOnDeath.lua +2 -2
  13. package/src/Server/Classes/RagdollHumanoidOnFall.lua +1 -2
  14. package/src/Server/Classes/Ragdollable.lua +7 -7
  15. package/src/Server/Classes/UnragdollAutomatically.lua +37 -35
  16. package/src/Server/Classes/UnragdollAutomaticallyConstants.lua +3 -3
  17. package/src/Server/RagdollBindersServer.lua +6 -6
  18. package/src/Server/RagdollService.lua +3 -3
  19. package/src/Shared/Classes/BindableRagdollHumanoidOnFall.lua +3 -5
  20. package/src/Shared/Classes/RagdollHumanoidOnFallConstants.lua +2 -2
  21. package/src/Shared/Classes/RagdollableBase.lua +1 -1
  22. package/src/Shared/Interfaces/RagdollableInterface.lua +7 -8
  23. package/src/Shared/RagdollServiceConstants.lua +2 -2
  24. package/src/Shared/Rigging/RagdollAdditionalAttachmentUtils.lua +44 -22
  25. package/src/Shared/Rigging/RagdollBallSocketUtils.lua +163 -163
  26. package/src/Shared/Rigging/RagdollCollisionUtils.lua +60 -61
  27. package/src/Shared/Rigging/RagdollMotorData.lua +3 -3
  28. package/src/Shared/Rigging/RagdollMotorLimitData.lua +78 -78
  29. package/src/Shared/Rigging/RagdollMotorUtils.lua +2 -2
  30. package/src/Shared/Rigging/RxRagdollUtils.lua +3 -3
@@ -8,7 +8,6 @@ local require = require(script.Parent.loader).load(script)
8
8
 
9
9
  local AttributeValue = require("AttributeValue")
10
10
  local BaseObject = require("BaseObject")
11
- local cancellableDelay = require("cancellableDelay")
12
11
  local CharacterUtils = require("CharacterUtils")
13
12
  local Maid = require("Maid")
14
13
  local Observable = require("Observable")
@@ -20,6 +19,7 @@ local RxBinderUtils = require("RxBinderUtils")
20
19
  local RxBrioUtils = require("RxBrioUtils")
21
20
  local RxInstanceUtils = require("RxInstanceUtils")
22
21
  local UnragdollAutomaticallyConstants = require("UnragdollAutomaticallyConstants")
22
+ local cancellableDelay = require("cancellableDelay")
23
23
 
24
24
  local UnragdollAutomatically = setmetatable({}, BaseObject)
25
25
  UnragdollAutomatically.ClassName = "UnragdollAutomatically"
@@ -39,8 +39,10 @@ function UnragdollAutomatically.new(humanoid, serviceBag)
39
39
  self._ragdollHumanoidOnFallBinder = self._serviceBag:GetService(RagdollHumanoidOnFall)
40
40
  self._player = CharacterUtils.getPlayerFromCharacter(self._obj)
41
41
 
42
- self._unragdollAutomatically = AttributeValue.new(self._obj, UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATICALLY_ATTRIBUTE, true)
43
- self._unragdollAutomaticTime = AttributeValue.new(self._obj, UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATIC_TIME_ATTRIBUTE, 5)
42
+ self._unragdollAutomatically =
43
+ AttributeValue.new(self._obj, UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATICALLY_ATTRIBUTE, true)
44
+ self._unragdollAutomaticTime =
45
+ AttributeValue.new(self._obj, UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATIC_TIME_ATTRIBUTE, 5)
44
46
 
45
47
  self._maid:GiveTask(self._ragdollBinder:ObserveInstance(self._obj, function()
46
48
  self:_handleRagdollChanged(self._maid)
@@ -52,20 +54,22 @@ end
52
54
 
53
55
  function UnragdollAutomatically:_handleRagdollChanged(maid)
54
56
  if self._ragdollBinder:Get(self._obj) then
55
- maid._unragdoll = self:_observeCanUnragdollTimer():Pipe({
56
- Rx.switchMap(function(state)
57
- if state then
58
- return self:_observeAlive()
59
- else
60
- return Rx.of(false);
57
+ maid._unragdoll = self:_observeCanUnragdollTimer()
58
+ :Pipe({
59
+ Rx.switchMap(function(state)
60
+ if state then
61
+ return self:_observeAlive()
62
+ else
63
+ return Rx.of(false)
64
+ end
65
+ end),
66
+ Rx.distinct(),
67
+ })
68
+ :Subscribe(function(canUnragdoll)
69
+ if canUnragdoll then
70
+ self._ragdollBinder:Unbind(self._obj)
61
71
  end
62
- end);
63
- Rx.distinct();
64
- }):Subscribe(function(canUnragdoll)
65
- if canUnragdoll then
66
- self._ragdollBinder:Unbind(self._obj)
67
- end
68
- end)
72
+ end)
69
73
  else
70
74
  maid._unragdoll = nil
71
75
  end
@@ -75,8 +79,8 @@ function UnragdollAutomatically:_observeAlive()
75
79
  return RxInstanceUtils.observeProperty(self._obj, "Health"):Pipe({
76
80
  Rx.map(function(health)
77
81
  return health > 0
78
- end);
79
- Rx.distinct();
82
+ end),
83
+ Rx.distinct(),
80
84
  })
81
85
  end
82
86
 
@@ -91,21 +95,21 @@ function UnragdollAutomatically:_observeCanUnragdollTimer()
91
95
 
92
96
  maid:GiveTask(RxBrioUtils.flatCombineLatest({
93
97
  canUnragdoll = RxBrioUtils.flatCombineLatest({
94
- enabled = self._unragdollAutomatically:Observe();
95
- isFallingRagdoll = self:_observeIsFallingRagdoll();
98
+ enabled = self._unragdollAutomatically:Observe(),
99
+ isFallingRagdoll = self:_observeIsFallingRagdoll(),
96
100
  }):Pipe({
97
101
  Rx.map(function(state)
98
102
  return state.enabled and not state.isFallingRagdoll
99
- end);
100
- Rx.distinct();
103
+ end),
104
+ Rx.distinct(),
101
105
  Rx.tap(function(canUnragdoll)
102
106
  -- Ensure we reset timer if we change state
103
107
  if canUnragdoll then
104
108
  startTime = os.clock()
105
109
  end
106
- end);
107
- });
108
- time = self._unragdollAutomaticTime:Observe();
110
+ end),
111
+ }),
112
+ time = self._unragdollAutomaticTime:Observe(),
109
113
  }):Subscribe(function(state)
110
114
  if state.canUnragdoll then
111
115
  maid._deferred = nil
@@ -121,7 +125,6 @@ function UnragdollAutomatically:_observeCanUnragdollTimer()
121
125
  end)
122
126
  end
123
127
  else
124
-
125
128
  isReady.Value = false
126
129
  maid._deferred = nil
127
130
  end
@@ -137,14 +140,13 @@ function UnragdollAutomatically:_observeCanUnragdollTimer()
137
140
  end
138
141
 
139
142
  function UnragdollAutomatically:_observeIsFallingRagdoll()
140
- return RxBinderUtils.observeBoundClassBrio(self._ragdollHumanoidOnFallBinder, self._obj)
141
- :Pipe({
142
- RxBrioUtils.switchMapBrio(function(ragdollHumanoidOnFall)
143
- return ragdollHumanoidOnFall:ObserveIsFalling()
144
- end);
145
- RxBrioUtils.emitOnDeath(false);
146
- Rx.distinct();
147
- })
143
+ return RxBinderUtils.observeBoundClassBrio(self._ragdollHumanoidOnFallBinder, self._obj):Pipe({
144
+ RxBrioUtils.switchMapBrio(function(ragdollHumanoidOnFall)
145
+ return ragdollHumanoidOnFall:ObserveIsFalling()
146
+ end),
147
+ RxBrioUtils.emitOnDeath(false),
148
+ Rx.distinct(),
149
+ })
148
150
  end
149
151
 
150
- return PlayerHumanoidBinder.new("UnragdollAutomatically", UnragdollAutomatically)
152
+ return PlayerHumanoidBinder.new("UnragdollAutomatically", UnragdollAutomatically)
@@ -7,6 +7,6 @@ local require = require(script.Parent.loader).load(script)
7
7
  local Table = require("Table")
8
8
 
9
9
  return Table.readonly({
10
- UNRAGDOLL_AUTOMATICALLY_ATTRIBUTE = "UnragdollAutomatically";
11
- UNRAGDOLL_AUTOMATIC_TIME_ATTRIBUTE = "UnragdollAutomaticTime";
12
- })
10
+ UNRAGDOLL_AUTOMATICALLY_ATTRIBUTE = "UnragdollAutomatically",
11
+ UNRAGDOLL_AUTOMATIC_TIME_ATTRIBUTE = "UnragdollAutomaticTime",
12
+ })
@@ -16,7 +16,7 @@ local require = require(script.Parent.loader).load(script)
16
16
  local BinderProvider = require("BinderProvider")
17
17
 
18
18
  return BinderProvider.new(script.Name, function(self, serviceBag)
19
- --[=[
19
+ --[=[
20
20
  Apply this [Binder] to a humanoid to ragdoll it. Humanoid must already have [Ragdollable] defined.
21
21
 
22
22
  ```lua
@@ -57,31 +57,31 @@ return BinderProvider.new(script.Name, function(self, serviceBag)
57
57
  ]=]
58
58
  self:Add(serviceBag:GetService(require("Ragdoll")))
59
59
 
60
- --[=[
60
+ --[=[
61
61
  Enables ragdolling on a humanoid.
62
62
  @prop Ragdollable PlayerHumanoidBinder<Ragdollable>
63
63
  @within RagdollBindersServer
64
64
  ]=]
65
65
  self:Add(serviceBag:GetService(require("Ragdollable")))
66
66
 
67
- --[=[
67
+ --[=[
68
68
  Automatically applies ragdoll upon humanoid death.
69
69
  @prop RagdollHumanoidOnDeath PlayerHumanoidBinder<RagdollHumanoidOnDeath>
70
70
  @within RagdollBindersServer
71
71
  ]=]
72
72
  self:Add(serviceBag:GetService(require("RagdollHumanoidOnDeath")))
73
73
 
74
- --[=[
74
+ --[=[
75
75
  Automatically applies ragdoll upon humanoid fall.
76
76
  @prop RagdollHumanoidOnFall PlayerHumanoidBinder<RagdollHumanoidOnFall>
77
77
  @within RagdollBindersServer
78
78
  ]=]
79
79
  self:Add(serviceBag:GetService(require("RagdollHumanoidOnFall")))
80
80
 
81
- --[=[
81
+ --[=[
82
82
  Automatically unragdolls the humanoid.
83
83
  @prop UnragdollAutomatically PlayerHumanoidBinder<UnragdollAutomatically>
84
84
  @within RagdollBindersServer
85
85
  ]=]
86
86
  self:Add(serviceBag:GetService(require("UnragdollAutomatically")))
87
- end)
87
+ end)
@@ -8,7 +8,7 @@
8
8
 
9
9
  local require = require(script.Parent.loader).load(script)
10
10
 
11
- local _ServiceBag = require("ServiceBag")
11
+ local ServiceBag = require("ServiceBag")
12
12
 
13
13
  local RagdollService = {}
14
14
  RagdollService.ServiceName = "RagdollService"
@@ -17,7 +17,7 @@ RagdollService.ServiceName = "RagdollService"
17
17
  Initializes the ragdoll service on the server. Should be done via [ServiceBag].
18
18
  @param serviceBag ServiceBag
19
19
  ]=]
20
- function RagdollService:Init(serviceBag: _ServiceBag.ServiceBag)
20
+ function RagdollService:Init(serviceBag: ServiceBag.ServiceBag)
21
21
  assert(not self._serviceBag, "Already initialized")
22
22
  self._serviceBag = assert(serviceBag, "No serviceBag")
23
23
 
@@ -74,4 +74,4 @@ function RagdollService:SetUnragdollAutomatically(unragdollAutomatically)
74
74
  self._serviceBag:GetService(require("UnragdollAutomatically")):SetAutomaticTagging(unragdollAutomatically)
75
75
  end
76
76
 
77
- return RagdollService
77
+ return RagdollService
@@ -42,7 +42,7 @@ function BindableRagdollHumanoidOnFall.new(humanoid, ragdollBinder)
42
42
  end)
43
43
 
44
44
  task.spawn(function()
45
- task.wait(math.random()*FRAME_TIME) -- Apply jitter
45
+ task.wait(math.random() * FRAME_TIME) -- Apply jitter
46
46
  while alive do
47
47
  self:_updateVelocity()
48
48
  task.wait(FRAME_TIME)
@@ -152,12 +152,10 @@ function BindableRagdollHumanoidOnFall:_updateVelocity()
152
152
  end
153
153
 
154
154
  local currentState = self._obj:GetState()
155
- if currentState == Enum.HumanoidStateType.Physics
156
- or currentState == Enum.HumanoidStateType.Swimming then
155
+ if currentState == Enum.HumanoidStateType.Physics or currentState == Enum.HumanoidStateType.Swimming then
157
156
  return
158
157
  end
159
158
 
160
-
161
159
  if (os.clock() - self._lastRagDollTime) <= RAGDOLL_DEBOUNCE_TIME then
162
160
  return
163
161
  end
@@ -165,4 +163,4 @@ function BindableRagdollHumanoidOnFall:_updateVelocity()
165
163
  self:_ragdollFromFall()
166
164
  end
167
165
 
168
- return BindableRagdollHumanoidOnFall
166
+ return BindableRagdollHumanoidOnFall
@@ -8,5 +8,5 @@ local require = require(script.Parent.loader).load(script)
8
8
  local Table = require("Table")
9
9
 
10
10
  return Table.readonly({
11
- REMOTE_EVENT_NAME = "RagdollHumanoidOnFallRemoteEvent";
12
- })
11
+ REMOTE_EVENT_NAME = "RagdollHumanoidOnFallRemoteEvent",
12
+ })
@@ -5,8 +5,8 @@
5
5
  local require = require(script.Parent.loader).load(script)
6
6
 
7
7
  local BaseObject = require("BaseObject")
8
- local RxSignal = require("RxSignal")
9
8
  local Rx = require("Rx")
9
+ local RxSignal = require("RxSignal")
10
10
 
11
11
  local RagdollableBase = setmetatable({}, BaseObject)
12
12
  RagdollableBase.ClassName = "RagdollableBase"
@@ -1,4 +1,3 @@
1
-
2
1
  --[=[
3
2
  @class RagdollableInterface
4
3
  ]=]
@@ -8,11 +7,11 @@ local require = require(script.Parent.loader).load(script)
8
7
  local TieDefinition = require("TieDefinition")
9
8
 
10
9
  return TieDefinition.new("Ragdollable", {
11
- Ragdolled = TieDefinition.Types.SIGNAL;
12
- Unragdolled = TieDefinition.Types.SIGNAL;
10
+ Ragdolled = TieDefinition.Types.SIGNAL,
11
+ Unragdolled = TieDefinition.Types.SIGNAL,
13
12
 
14
- Ragdoll = TieDefinition.Types.METHOD;
15
- Unragdoll = TieDefinition.Types.METHOD;
16
- ObserveIsRagdolled = TieDefinition.Types.METHOD;
17
- IsRagdolled = TieDefinition.Types.METHOD;
18
- })
13
+ Ragdoll = TieDefinition.Types.METHOD,
14
+ Unragdoll = TieDefinition.Types.METHOD,
15
+ ObserveIsRagdolled = TieDefinition.Types.METHOD,
16
+ IsRagdolled = TieDefinition.Types.METHOD,
17
+ })
@@ -7,5 +7,5 @@ local require = require(script.Parent.loader).load(script)
7
7
  local Table = require("Table")
8
8
 
9
9
  return Table.readonly({
10
- SCREEN_SHAKE_ENABLED_ATTRIBUTE = "RagdollScreenShakeEnabled"
11
- })
10
+ SCREEN_SHAKE_ENABLED_ATTRIBUTE = "RagdollScreenShakeEnabled",
11
+ })
@@ -7,8 +7,8 @@ local require = require(script.Parent.loader).load(script)
7
7
  local EnumUtils = require("EnumUtils")
8
8
  local Maid = require("Maid")
9
9
  local RxBrioUtils = require("RxBrioUtils")
10
- local RxR15Utils = require("RxR15Utils")
11
10
  local RxInstanceUtils = require("RxInstanceUtils")
11
+ local RxR15Utils = require("RxR15Utils")
12
12
 
13
13
  local RagdollAdditionalAttachmentUtils = {}
14
14
 
@@ -23,27 +23,47 @@ local V3_LEFT = Vector3.new(-1, 0, 0)
23
23
  -- of non-ideal axis orientation, but it's not as noticable there since the limits for natural
24
24
  -- motion are tighter for those joints anyway.
25
25
  local R15_ADDITIONAL_ATTACHMENTS = {
26
- {"UpperTorso", "RightShoulderRagdollAttachment", CFrame.fromMatrix(V3_ZERO, V3_RIGHT, V3_UP), "RightShoulderRigAttachment"},
27
- {"RightUpperArm", "RightShoulderRagdollAttachment", CFrame.fromMatrix(V3_ZERO, V3_DOWN, V3_RIGHT), "RightShoulderRigAttachment"},
28
- {"UpperTorso", "LeftShoulderRagdollAttachment", CFrame.fromMatrix(V3_ZERO, V3_LEFT, V3_UP), "LeftShoulderRigAttachment"},
29
- {"LeftUpperArm", "LeftShoulderRagdollAttachment", CFrame.fromMatrix(V3_ZERO, V3_DOWN, V3_LEFT), "LeftShoulderRigAttachment"},
26
+ {
27
+ "UpperTorso",
28
+ "RightShoulderRagdollAttachment",
29
+ CFrame.fromMatrix(V3_ZERO, V3_RIGHT, V3_UP),
30
+ "RightShoulderRigAttachment",
31
+ },
32
+ {
33
+ "RightUpperArm",
34
+ "RightShoulderRagdollAttachment",
35
+ CFrame.fromMatrix(V3_ZERO, V3_DOWN, V3_RIGHT),
36
+ "RightShoulderRigAttachment",
37
+ },
38
+ {
39
+ "UpperTorso",
40
+ "LeftShoulderRagdollAttachment",
41
+ CFrame.fromMatrix(V3_ZERO, V3_LEFT, V3_UP),
42
+ "LeftShoulderRigAttachment",
43
+ },
44
+ {
45
+ "LeftUpperArm",
46
+ "LeftShoulderRagdollAttachment",
47
+ CFrame.fromMatrix(V3_ZERO, V3_DOWN, V3_LEFT),
48
+ "LeftShoulderRigAttachment",
49
+ },
30
50
  }
31
51
 
32
52
  local R6_ADDITIONAL_ATTACHMENTS = {
33
- {"Head", "NeckAttachment", CFrame.new(0, -0.5, 0)},
34
- {"Torso", "NeckAttachment", CFrame.new(0, 1, 0)},
53
+ { "Head", "NeckAttachment", CFrame.new(0, -0.5, 0) },
54
+ { "Torso", "NeckAttachment", CFrame.new(0, 1, 0) },
35
55
 
36
- {"Torso", "RightShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(1, 0.5, 0), V3_RIGHT, V3_UP)},
37
- {"Right Arm", "RightShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(-0.5, 0.5, 0), V3_DOWN, V3_RIGHT)},
56
+ { "Torso", "RightShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(1, 0.5, 0), V3_RIGHT, V3_UP) },
57
+ { "Right Arm", "RightShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(-0.5, 0.5, 0), V3_DOWN, V3_RIGHT) },
38
58
 
39
- {"Torso", "LeftShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(-1, 0.5, 0), V3_LEFT, V3_UP)},
40
- {"Left Arm", "LeftShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(0.5, 0.5, 0), V3_DOWN, V3_LEFT)},
59
+ { "Torso", "LeftShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(-1, 0.5, 0), V3_LEFT, V3_UP) },
60
+ { "Left Arm", "LeftShoulderRagdollAttachment", CFrame.fromMatrix(Vector3.new(0.5, 0.5, 0), V3_DOWN, V3_LEFT) },
41
61
 
42
- {"Torso", "RightHipAttachment", CFrame.new(0.5, -1, 0)},
43
- {"Right Leg", "RightHipAttachment", CFrame.new(0, 1, 0)},
62
+ { "Torso", "RightHipAttachment", CFrame.new(0.5, -1, 0) },
63
+ { "Right Leg", "RightHipAttachment", CFrame.new(0, 1, 0) },
44
64
 
45
- {"Torso", "LeftHipAttachment", CFrame.new(-0.5, -1, 0)},
46
- {"Left Leg", "LeftHipAttachment", CFrame.new(0, 1, 0)},
65
+ { "Torso", "LeftHipAttachment", CFrame.new(-0.5, -1, 0) },
66
+ { "Left Leg", "LeftHipAttachment", CFrame.new(0, 1, 0) },
47
67
  }
48
68
 
49
69
  function RagdollAdditionalAttachmentUtils.getAdditionalAttachmentData(rigType)
@@ -67,8 +87,8 @@ function RagdollAdditionalAttachmentUtils.ensureAdditionalAttachments(character,
67
87
 
68
88
  if baseAttachmentName then
69
89
  local observable = RxBrioUtils.flatCombineLatest({
70
- part = RxR15Utils.observeCharacterPartBrio(character, partName);
71
- baseAttachment = RxR15Utils.observeRigAttachmentBrio(character, partName, baseAttachmentName);
90
+ part = RxR15Utils.observeCharacterPartBrio(character, partName),
91
+ baseAttachment = RxR15Utils.observeRigAttachmentBrio(character, partName, baseAttachmentName),
72
92
  })
73
93
 
74
94
  topMaid:GiveTask(observable:Subscribe(function(state)
@@ -78,10 +98,12 @@ function RagdollAdditionalAttachmentUtils.ensureAdditionalAttachments(character,
78
98
  local attachment = Instance.new("Attachment")
79
99
  attachment.Name = attachmentName
80
100
 
81
- maid:GiveTask(RxInstanceUtils.observeProperty(state.baseAttachment, "CFrame"):Subscribe(function(baseCFrame)
82
- attachment.CFrame = baseCFrame * cframe
83
- attachment.Parent = state.part -- event ordering...
84
- end))
101
+ maid:GiveTask(
102
+ RxInstanceUtils.observeProperty(state.baseAttachment, "CFrame"):Subscribe(function(baseCFrame)
103
+ attachment.CFrame = baseCFrame * cframe
104
+ attachment.Parent = state.part -- event ordering...
105
+ end)
106
+ )
85
107
 
86
108
  maid:GiveTask(attachment)
87
109
 
@@ -111,4 +133,4 @@ function RagdollAdditionalAttachmentUtils.ensureAdditionalAttachments(character,
111
133
  return topMaid
112
134
  end
113
135
 
114
- return RagdollAdditionalAttachmentUtils
136
+ return RagdollAdditionalAttachmentUtils