@quenty/ragdoll 15.51.1 → 15.53.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.
- package/CHANGELOG.md +15 -0
- package/package.json +9 -9
- package/src/Client/Classes/RagdollCameraShakeClient.lua +25 -13
- package/src/Client/Classes/RagdollClient.lua +13 -4
- package/src/Client/Classes/RagdollHumanoidOnDeathClient.lua +68 -49
- package/src/Client/Classes/RagdollHumanoidOnFallClient.lua +34 -10
- package/src/Client/Classes/RagdollableClient.lua +22 -11
- package/src/Client/RagdollServiceClient.lua +13 -5
- package/src/Server/Classes/Ragdoll.lua +6 -4
- package/src/Server/Classes/RagdollCameraShake.lua +17 -4
- package/src/Server/Classes/RagdollHumanoidOnDeath.lua +23 -9
- package/src/Server/Classes/RagdollHumanoidOnFall.lua +45 -23
- package/src/Server/Classes/Ragdollable.lua +52 -34
- package/src/Server/Classes/UnragdollAutomatically.lua +84 -62
- package/src/Server/RagdollBindersServer.lua +2 -2
- package/src/Shared/Classes/BindableRagdollHumanoidOnFall.lua +35 -18
- package/src/Shared/Classes/RagdollableBase.lua +30 -19
- package/src/Shared/Rigging/RagdollAdditionalAttachmentUtils.lua +24 -19
- package/src/Shared/Rigging/RagdollBallSocketUtils.lua +19 -10
- package/src/Shared/Rigging/RagdollCollisionUtils.lua +10 -10
- package/src/Shared/Rigging/RagdollMotorLimitData.lua +1 -1
- package/src/Shared/Rigging/RagdollMotorUtils.lua +43 -23
- package/src/Shared/Rigging/RxRagdollUtils.lua +28 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Ragdolls the humanoid on death. This class exports a [Binder].
|
|
4
4
|
@server
|
|
@@ -16,30 +16,44 @@ local RagdollHumanoidOnDeath = setmetatable({}, BaseObject)
|
|
|
16
16
|
RagdollHumanoidOnDeath.ClassName = "RagdollHumanoidOnDeath"
|
|
17
17
|
RagdollHumanoidOnDeath.__index = RagdollHumanoidOnDeath
|
|
18
18
|
|
|
19
|
+
export type RagdollHumanoidOnDeath =
|
|
20
|
+
typeof(setmetatable(
|
|
21
|
+
{} :: {
|
|
22
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
23
|
+
_ragdollBinder: typeof(Ragdoll),
|
|
24
|
+
},
|
|
25
|
+
{} :: typeof({ __index = RagdollHumanoidOnDeath })
|
|
26
|
+
))
|
|
27
|
+
& BaseObject.BaseObject
|
|
28
|
+
|
|
19
29
|
--[=[
|
|
20
30
|
Constructs a new RagdollHumanoidOnDeath. This class exports a [Binder].
|
|
21
31
|
@param humanoid Humanoid
|
|
22
32
|
@param serviceBag ServiceBag
|
|
23
33
|
@return RagdollHumanoidOnDeath
|
|
24
34
|
]=]
|
|
25
|
-
function RagdollHumanoidOnDeath.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag)
|
|
26
|
-
local self = setmetatable(BaseObject.new(humanoid), RagdollHumanoidOnDeath)
|
|
35
|
+
function RagdollHumanoidOnDeath.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag): RagdollHumanoidOnDeath
|
|
36
|
+
local self: RagdollHumanoidOnDeath = setmetatable(BaseObject.new(humanoid) :: any, RagdollHumanoidOnDeath)
|
|
27
37
|
|
|
28
38
|
self._serviceBag = assert(serviceBag, "Bad serviceBag")
|
|
29
39
|
self._ragdollBinder = self._serviceBag:GetService(Ragdoll)
|
|
30
40
|
|
|
31
|
-
self._obj
|
|
41
|
+
local humanoidObj = self._obj :: Humanoid
|
|
42
|
+
humanoidObj.BreakJointsOnDeath = false
|
|
32
43
|
self._maid:GiveTask(function()
|
|
33
|
-
|
|
44
|
+
humanoidObj.BreakJointsOnDeath = true
|
|
34
45
|
end)
|
|
35
46
|
|
|
36
|
-
self._maid:GiveTask(
|
|
37
|
-
if
|
|
38
|
-
self._ragdollBinder:Bind(
|
|
47
|
+
self._maid:GiveTask(humanoidObj:GetPropertyChangedSignal("Health"):Connect(function()
|
|
48
|
+
if humanoidObj.Health <= 0 then
|
|
49
|
+
self._ragdollBinder:Bind(humanoidObj)
|
|
39
50
|
end
|
|
40
51
|
end))
|
|
41
52
|
|
|
42
53
|
return self
|
|
43
54
|
end
|
|
44
55
|
|
|
45
|
-
return PlayerHumanoidBinder.new(
|
|
56
|
+
return PlayerHumanoidBinder.new(
|
|
57
|
+
"RagdollHumanoidOnDeath",
|
|
58
|
+
RagdollHumanoidOnDeath :: any
|
|
59
|
+
) :: PlayerHumanoidBinder.PlayerHumanoidBinder<RagdollHumanoidOnDeath>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
When a humanoid is bound with this, it will ragdoll upon falling. Recommended that you use
|
|
4
4
|
[UnragdollAutomatically] in conjunction with this.
|
|
@@ -12,6 +12,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
12
12
|
local BaseObject = require("BaseObject")
|
|
13
13
|
local BindableRagdollHumanoidOnFall = require("BindableRagdollHumanoidOnFall")
|
|
14
14
|
local CharacterUtils = require("CharacterUtils")
|
|
15
|
+
local Observable = require("Observable")
|
|
15
16
|
local PlayerHumanoidBinder = require("PlayerHumanoidBinder")
|
|
16
17
|
local Ragdoll = require("Ragdoll")
|
|
17
18
|
local RagdollHumanoidOnFallConstants = require("RagdollHumanoidOnFallConstants")
|
|
@@ -21,29 +22,43 @@ local RagdollHumanoidOnFall = setmetatable({}, BaseObject)
|
|
|
21
22
|
RagdollHumanoidOnFall.ClassName = "RagdollHumanoidOnFall"
|
|
22
23
|
RagdollHumanoidOnFall.__index = RagdollHumanoidOnFall
|
|
23
24
|
|
|
25
|
+
export type RagdollHumanoidOnFall =
|
|
26
|
+
typeof(setmetatable(
|
|
27
|
+
{} :: {
|
|
28
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
29
|
+
_ragdollBinder: typeof(Ragdoll),
|
|
30
|
+
_player: Player?,
|
|
31
|
+
_remoteEvent: RemoteEvent?,
|
|
32
|
+
_ragdollLogic: BindableRagdollHumanoidOnFall.BindableRagdollHumanoidOnFall?,
|
|
33
|
+
},
|
|
34
|
+
{} :: typeof({ __index = RagdollHumanoidOnFall })
|
|
35
|
+
))
|
|
36
|
+
& BaseObject.BaseObject
|
|
37
|
+
|
|
24
38
|
--[=[
|
|
25
39
|
Constructs a new RagdollHumanoidOnFall. Should be done via [Binder]. See [Ragdoll].
|
|
26
40
|
@param humanoid Humanoid
|
|
27
41
|
@param serviceBag ServiceBag
|
|
28
42
|
@return RagdollHumanoidOnFall
|
|
29
43
|
]=]
|
|
30
|
-
function RagdollHumanoidOnFall.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag)
|
|
31
|
-
local self = setmetatable(BaseObject.new(humanoid), RagdollHumanoidOnFall)
|
|
44
|
+
function RagdollHumanoidOnFall.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag): RagdollHumanoidOnFall
|
|
45
|
+
local self: RagdollHumanoidOnFall = setmetatable(BaseObject.new(humanoid) :: any, RagdollHumanoidOnFall)
|
|
32
46
|
|
|
33
47
|
self._serviceBag = assert(serviceBag, "Bad serviceBag")
|
|
34
48
|
self._ragdollBinder = self._serviceBag:GetService(Ragdoll)
|
|
35
49
|
|
|
36
|
-
local player = CharacterUtils.getPlayerFromCharacter(self._obj)
|
|
50
|
+
local player = CharacterUtils.getPlayerFromCharacter(self._obj :: Humanoid)
|
|
37
51
|
if player then
|
|
38
52
|
self._player = player
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
self.
|
|
54
|
+
local remoteEvent = Instance.new("RemoteEvent")
|
|
55
|
+
remoteEvent.Name = RagdollHumanoidOnFallConstants.REMOTE_EVENT_NAME
|
|
56
|
+
remoteEvent.Archivable = false
|
|
57
|
+
remoteEvent.Parent = self._obj
|
|
58
|
+
self._remoteEvent = remoteEvent
|
|
59
|
+
self._maid:GiveTask(remoteEvent)
|
|
45
60
|
|
|
46
|
-
self._maid:GiveTask(
|
|
61
|
+
self._maid:GiveTask(remoteEvent.OnServerEvent:Connect(function(...)
|
|
47
62
|
self:_handleServerEvent(...)
|
|
48
63
|
end))
|
|
49
64
|
else
|
|
@@ -55,40 +70,47 @@ function RagdollHumanoidOnFall.new(humanoid: Humanoid, serviceBag: ServiceBag.Se
|
|
|
55
70
|
return self
|
|
56
71
|
end
|
|
57
72
|
|
|
58
|
-
function RagdollHumanoidOnFall
|
|
73
|
+
function RagdollHumanoidOnFall.ObserveIsFalling(self: RagdollHumanoidOnFall): Observable.Observable<boolean>
|
|
59
74
|
-- TODO: Remove logic if nothing is observing it
|
|
60
75
|
return self:_getOrCreateRagdollLogic():ObserveIsFalling()
|
|
61
76
|
end
|
|
62
77
|
|
|
63
|
-
function RagdollHumanoidOnFall
|
|
78
|
+
function RagdollHumanoidOnFall._getOrCreateRagdollLogic(
|
|
79
|
+
self: RagdollHumanoidOnFall
|
|
80
|
+
): BindableRagdollHumanoidOnFall.BindableRagdollHumanoidOnFall
|
|
64
81
|
if self._ragdollLogic then
|
|
65
82
|
return self._ragdollLogic
|
|
66
83
|
end
|
|
67
84
|
|
|
68
|
-
|
|
85
|
+
local ragdollLogic = self._maid:Add(BindableRagdollHumanoidOnFall.new(self._obj :: Humanoid, self._ragdollBinder))
|
|
86
|
+
self._ragdollLogic = ragdollLogic
|
|
69
87
|
|
|
70
|
-
return
|
|
88
|
+
return ragdollLogic
|
|
71
89
|
end
|
|
72
90
|
|
|
73
|
-
function RagdollHumanoidOnFall
|
|
91
|
+
function RagdollHumanoidOnFall._handleServerEvent(self: RagdollHumanoidOnFall, player: Player, value: any): ()
|
|
74
92
|
assert(player == self._player, "Bad player")
|
|
75
93
|
assert(typeof(value) == "boolean", "Bad value")
|
|
76
94
|
|
|
77
95
|
if value then
|
|
78
|
-
self._ragdollBinder:Bind(self._obj)
|
|
96
|
+
self._ragdollBinder:Bind(self._obj :: Humanoid)
|
|
79
97
|
else
|
|
80
|
-
self._ragdollBinder:Unbind(self._obj)
|
|
98
|
+
self._ragdollBinder:Unbind(self._obj :: Humanoid)
|
|
81
99
|
end
|
|
82
100
|
end
|
|
83
101
|
|
|
84
|
-
function RagdollHumanoidOnFall
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
function RagdollHumanoidOnFall._update(self: RagdollHumanoidOnFall): ()
|
|
103
|
+
local ragdollLogic = self:_getOrCreateRagdollLogic()
|
|
104
|
+
if ragdollLogic.ShouldRagdoll.Value then
|
|
105
|
+
self._ragdollBinder:Bind(self._obj :: Humanoid)
|
|
87
106
|
else
|
|
88
|
-
if self._obj.Health > 0 then
|
|
89
|
-
self._ragdollBinder:Unbind(self._obj)
|
|
107
|
+
if (self._obj :: Humanoid).Health > 0 then
|
|
108
|
+
self._ragdollBinder:Unbind(self._obj :: Humanoid)
|
|
90
109
|
end
|
|
91
110
|
end
|
|
92
111
|
end
|
|
93
112
|
|
|
94
|
-
return PlayerHumanoidBinder.new(
|
|
113
|
+
return PlayerHumanoidBinder.new(
|
|
114
|
+
"RagdollHumanoidOnFall",
|
|
115
|
+
RagdollHumanoidOnFall :: any
|
|
116
|
+
) :: PlayerHumanoidBinder.PlayerHumanoidBinder<RagdollHumanoidOnFall>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Should be bound to any humanoid that is ragdollable. This class exports a [Binder].
|
|
4
4
|
@server
|
|
@@ -9,6 +9,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
9
9
|
|
|
10
10
|
local Maid = require("Maid")
|
|
11
11
|
local Motor6DStackHumanoid = require("Motor6DStackHumanoid")
|
|
12
|
+
local Observable = require("Observable")
|
|
12
13
|
local PlayerHumanoidBinder = require("PlayerHumanoidBinder")
|
|
13
14
|
local Ragdoll = require("Ragdoll")
|
|
14
15
|
local RagdollAdditionalAttachmentUtils = require("RagdollAdditionalAttachmentUtils")
|
|
@@ -26,78 +27,95 @@ local Ragdollable = setmetatable({}, RagdollableBase)
|
|
|
26
27
|
Ragdollable.ClassName = "Ragdollable"
|
|
27
28
|
Ragdollable.__index = Ragdollable
|
|
28
29
|
|
|
30
|
+
export type Ragdollable =
|
|
31
|
+
typeof(setmetatable(
|
|
32
|
+
{} :: {
|
|
33
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
34
|
+
_ragdollBinder: typeof(Ragdoll),
|
|
35
|
+
},
|
|
36
|
+
{} :: typeof({ __index = Ragdollable })
|
|
37
|
+
))
|
|
38
|
+
& RagdollableBase.RagdollableBase
|
|
39
|
+
|
|
29
40
|
--[=[
|
|
30
41
|
Constructs a new Ragdollable. This class exports a [Binder].
|
|
31
42
|
@param humanoid Humanoid
|
|
32
43
|
@param serviceBag ServiceBag
|
|
33
44
|
@return Ragdollable
|
|
34
45
|
]=]
|
|
35
|
-
function Ragdollable.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag)
|
|
36
|
-
local self = setmetatable(RagdollableBase.new(humanoid), Ragdollable)
|
|
46
|
+
function Ragdollable.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag): Ragdollable
|
|
47
|
+
local self: Ragdollable = setmetatable(RagdollableBase.new(humanoid) :: any, Ragdollable)
|
|
37
48
|
|
|
38
49
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
39
50
|
self._ragdollBinder = self._serviceBag:GetService(Ragdoll)
|
|
40
51
|
|
|
41
|
-
Motor6DStackHumanoid:Tag(self._obj)
|
|
52
|
+
Motor6DStackHumanoid:Tag(self._obj :: Instance)
|
|
42
53
|
|
|
43
54
|
-- Ensure predefined physics rig immediatelly on the server.
|
|
44
55
|
-- We do this so during replication loop-back there's no chance of death.
|
|
45
|
-
self._maid:GiveTask(RxBrioUtils
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
self._maid:GiveTask((RxBrioUtils :: any)
|
|
57
|
+
.flatCombineLatest({
|
|
58
|
+
character = RxRagdollUtils.observeCharacterBrio(self._obj :: Humanoid),
|
|
59
|
+
rigType = RxRagdollUtils.observeRigType(self._obj :: Humanoid),
|
|
60
|
+
})
|
|
61
|
+
:Subscribe(function(state)
|
|
62
|
+
if state.character and state.rigType then
|
|
63
|
+
local maid = Maid.new()
|
|
64
|
+
|
|
65
|
+
maid:GiveTask(
|
|
66
|
+
RagdollAdditionalAttachmentUtils.ensureAdditionalAttachments(state.character, state.rigType)
|
|
67
|
+
)
|
|
68
|
+
maid:GiveTask(RagdollBallSocketUtils.ensureBallSockets(state.character, state.rigType))
|
|
69
|
+
maid:GiveTask(RagdollCollisionUtils.ensureNoCollides(state.character, state.rigType))
|
|
70
|
+
|
|
71
|
+
-- Not super guarded against race conditions but it should be fine, as this is for debugging.
|
|
72
|
+
RagdollMotorUtils.initMotorAttributes(state.character, state.rigType)
|
|
73
|
+
|
|
74
|
+
self._maid._configure = maid
|
|
75
|
+
else
|
|
76
|
+
self._maid._configure = nil
|
|
77
|
+
end
|
|
78
|
+
end))
|
|
79
|
+
|
|
80
|
+
self._maid:GiveTask(self._ragdollBinder:ObserveInstance(self._obj :: Instance, function()
|
|
66
81
|
self:_onRagdollChanged()
|
|
67
82
|
end))
|
|
68
83
|
self:_onRagdollChanged()
|
|
69
84
|
|
|
70
|
-
self._maid:GiveTask(RagdollableInterface.Server:Implement(self._obj, self))
|
|
85
|
+
self._maid:GiveTask((RagdollableInterface :: any).Server:Implement(self._obj, self))
|
|
71
86
|
|
|
72
87
|
return self
|
|
73
88
|
end
|
|
74
89
|
|
|
75
|
-
function Ragdollable
|
|
76
|
-
return self._ragdollBinder:Observe(self._obj):Pipe({
|
|
77
|
-
Rx.map(function(value)
|
|
90
|
+
function Ragdollable.ObserveIsRagdolled(self: Ragdollable): Observable.Observable<boolean>
|
|
91
|
+
return (self._ragdollBinder:Observe(self._obj :: Instance) :: any):Pipe({
|
|
92
|
+
Rx.map(function(value): any
|
|
78
93
|
return value and true or false
|
|
79
94
|
end),
|
|
80
95
|
})
|
|
81
96
|
end
|
|
82
97
|
|
|
83
|
-
function Ragdollable
|
|
84
|
-
if self._ragdollBinder:Get(self._obj) then
|
|
98
|
+
function Ragdollable._onRagdollChanged(self: Ragdollable): ()
|
|
99
|
+
if self._ragdollBinder:Get(self._obj :: Instance) then
|
|
85
100
|
self:_setRagdollEnabled(true)
|
|
86
101
|
else
|
|
87
102
|
self:_setRagdollEnabled(false)
|
|
88
103
|
end
|
|
89
104
|
end
|
|
90
105
|
|
|
91
|
-
function Ragdollable
|
|
106
|
+
function Ragdollable._setRagdollEnabled(self: Ragdollable, isEnabled: boolean): ()
|
|
92
107
|
if isEnabled then
|
|
93
108
|
if self._maid._ragdoll then
|
|
94
109
|
return
|
|
95
110
|
end
|
|
96
111
|
|
|
97
|
-
self._maid._ragdoll = RxRagdollUtils.runLocal(self._obj)
|
|
112
|
+
self._maid._ragdoll = RxRagdollUtils.runLocal(self._obj :: Humanoid)
|
|
98
113
|
else
|
|
99
114
|
self._maid._ragdoll = nil
|
|
100
115
|
end
|
|
101
116
|
end
|
|
102
117
|
|
|
103
|
-
return PlayerHumanoidBinder.new(
|
|
118
|
+
return PlayerHumanoidBinder.new(
|
|
119
|
+
"Ragdollable",
|
|
120
|
+
Ragdollable :: any
|
|
121
|
+
) :: PlayerHumanoidBinder.PlayerHumanoidBinder<Ragdollable>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
When a humanoid is tagged with this, it will unragdoll automatically. This class exports a [Binder].
|
|
4
4
|
@server
|
|
@@ -27,26 +27,43 @@ local UnragdollAutomatically = setmetatable({}, BaseObject)
|
|
|
27
27
|
UnragdollAutomatically.ClassName = "UnragdollAutomatically"
|
|
28
28
|
UnragdollAutomatically.__index = UnragdollAutomatically
|
|
29
29
|
|
|
30
|
+
export type UnragdollAutomatically =
|
|
31
|
+
typeof(setmetatable(
|
|
32
|
+
{} :: {
|
|
33
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
34
|
+
_ragdollBinder: typeof(Ragdoll),
|
|
35
|
+
_ragdollHumanoidOnFallBinder: typeof(RagdollHumanoidOnFall),
|
|
36
|
+
_player: Player?,
|
|
37
|
+
_unragdollAutomatically: AttributeValue.AttributeValue<boolean>,
|
|
38
|
+
_unragdollAutomaticTime: AttributeValue.AttributeValue<number>,
|
|
39
|
+
},
|
|
40
|
+
{} :: typeof({ __index = UnragdollAutomatically })
|
|
41
|
+
))
|
|
42
|
+
& BaseObject.BaseObject
|
|
43
|
+
|
|
30
44
|
--[=[
|
|
31
45
|
Constructs a new UnragdollAutomatically. This class exports a [Binder].
|
|
32
46
|
@param humanoid Humanoid
|
|
33
47
|
@param serviceBag ServiceBag
|
|
34
48
|
@return UnragdollAutomatically
|
|
35
49
|
]=]
|
|
36
|
-
function UnragdollAutomatically.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag)
|
|
37
|
-
local self = setmetatable(BaseObject.new(humanoid), UnragdollAutomatically)
|
|
50
|
+
function UnragdollAutomatically.new(humanoid: Humanoid, serviceBag: ServiceBag.ServiceBag): UnragdollAutomatically
|
|
51
|
+
local self: UnragdollAutomatically = setmetatable(BaseObject.new(humanoid) :: any, UnragdollAutomatically)
|
|
38
52
|
|
|
39
53
|
self._serviceBag = assert(serviceBag, "Bad serviceBag")
|
|
40
54
|
self._ragdollBinder = self._serviceBag:GetService(Ragdoll)
|
|
41
55
|
self._ragdollHumanoidOnFallBinder = self._serviceBag:GetService(RagdollHumanoidOnFall)
|
|
42
|
-
self._player = CharacterUtils.getPlayerFromCharacter(self._obj)
|
|
56
|
+
self._player = CharacterUtils.getPlayerFromCharacter(self._obj :: Humanoid)
|
|
43
57
|
|
|
44
|
-
self._unragdollAutomatically =
|
|
45
|
-
|
|
58
|
+
self._unragdollAutomatically = AttributeValue.new(
|
|
59
|
+
self._obj :: Instance,
|
|
60
|
+
UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATICALLY_ATTRIBUTE,
|
|
61
|
+
true
|
|
62
|
+
)
|
|
46
63
|
self._unragdollAutomaticTime =
|
|
47
|
-
AttributeValue.new(self._obj, UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATIC_TIME_ATTRIBUTE, 5)
|
|
64
|
+
AttributeValue.new(self._obj :: Instance, UnragdollAutomaticallyConstants.UNRAGDOLL_AUTOMATIC_TIME_ATTRIBUTE, 5)
|
|
48
65
|
|
|
49
|
-
self._maid:GiveTask(self._ragdollBinder:ObserveInstance(self._obj, function()
|
|
66
|
+
self._maid:GiveTask(self._ragdollBinder:ObserveInstance(self._obj :: Instance, function()
|
|
50
67
|
self:_handleRagdollChanged(self._maid)
|
|
51
68
|
end))
|
|
52
69
|
self:_handleRagdollChanged(self._maid)
|
|
@@ -54,22 +71,22 @@ function UnragdollAutomatically.new(humanoid: Humanoid, serviceBag: ServiceBag.S
|
|
|
54
71
|
return self
|
|
55
72
|
end
|
|
56
73
|
|
|
57
|
-
function UnragdollAutomatically
|
|
58
|
-
if self._ragdollBinder:Get(self._obj) then
|
|
59
|
-
maid._unragdoll = self:_observeCanUnragdollTimer()
|
|
74
|
+
function UnragdollAutomatically._handleRagdollChanged(self: UnragdollAutomatically, maid: Maid.Maid): ()
|
|
75
|
+
if self._ragdollBinder:Get(self._obj :: Instance) then
|
|
76
|
+
maid._unragdoll = (self:_observeCanUnragdollTimer() :: any)
|
|
60
77
|
:Pipe({
|
|
61
|
-
Rx.switchMap(function(state)
|
|
78
|
+
Rx.switchMap(function(state): any
|
|
62
79
|
if state then
|
|
63
80
|
return self:_observeAlive()
|
|
64
81
|
else
|
|
65
82
|
return Rx.of(false)
|
|
66
83
|
end
|
|
67
|
-
end),
|
|
68
|
-
Rx.distinct(),
|
|
84
|
+
end) :: any,
|
|
85
|
+
Rx.distinct() :: any,
|
|
69
86
|
})
|
|
70
87
|
:Subscribe(function(canUnragdoll)
|
|
71
88
|
if canUnragdoll then
|
|
72
|
-
self._ragdollBinder:Unbind(self._obj)
|
|
89
|
+
self._ragdollBinder:Unbind(self._obj :: Instance)
|
|
73
90
|
end
|
|
74
91
|
end)
|
|
75
92
|
else
|
|
@@ -77,17 +94,17 @@ function UnragdollAutomatically:_handleRagdollChanged(maid)
|
|
|
77
94
|
end
|
|
78
95
|
end
|
|
79
96
|
|
|
80
|
-
function UnragdollAutomatically
|
|
81
|
-
return RxInstanceUtils.observeProperty(self._obj, "Health"):Pipe({
|
|
82
|
-
Rx.map(function(health)
|
|
97
|
+
function UnragdollAutomatically._observeAlive(self: UnragdollAutomatically): Observable.Observable<boolean>
|
|
98
|
+
return (RxInstanceUtils.observeProperty(self._obj :: Instance, "Health") :: any):Pipe({
|
|
99
|
+
Rx.map(function(health): any
|
|
83
100
|
return health > 0
|
|
84
|
-
end),
|
|
85
|
-
Rx.distinct(),
|
|
101
|
+
end) :: any,
|
|
102
|
+
Rx.distinct() :: any,
|
|
86
103
|
})
|
|
87
104
|
end
|
|
88
105
|
|
|
89
|
-
function UnragdollAutomatically
|
|
90
|
-
return Observable.new(function(sub)
|
|
106
|
+
function UnragdollAutomatically._observeCanUnragdollTimer(self: UnragdollAutomatically): Observable.Observable<boolean>
|
|
107
|
+
return Observable.new(function(sub): any
|
|
91
108
|
local maid = Maid.new()
|
|
92
109
|
|
|
93
110
|
local startTime = os.clock()
|
|
@@ -95,42 +112,44 @@ function UnragdollAutomatically:_observeCanUnragdollTimer()
|
|
|
95
112
|
isReady.Value = false
|
|
96
113
|
maid:GiveTask(isReady)
|
|
97
114
|
|
|
98
|
-
maid:GiveTask(RxBrioUtils
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
maid:GiveTask((RxBrioUtils :: any)
|
|
116
|
+
.flatCombineLatest({
|
|
117
|
+
canUnragdoll = (RxBrioUtils.flatCombineLatest({
|
|
118
|
+
enabled = self._unragdollAutomatically:Observe(),
|
|
119
|
+
isFallingRagdoll = self:_observeIsFallingRagdoll(),
|
|
120
|
+
}) :: any):Pipe({
|
|
121
|
+
Rx.map(function(state): any
|
|
122
|
+
return state.enabled and not state.isFallingRagdoll
|
|
123
|
+
end) :: any,
|
|
124
|
+
Rx.distinct() :: any,
|
|
125
|
+
Rx.tap(function(canUnragdoll): ()
|
|
126
|
+
-- Ensure we reset timer if we change state
|
|
127
|
+
if canUnragdoll then
|
|
128
|
+
startTime = os.clock()
|
|
129
|
+
end
|
|
130
|
+
end) :: any,
|
|
131
|
+
}),
|
|
132
|
+
time = self._unragdollAutomaticTime:Observe(),
|
|
133
|
+
})
|
|
134
|
+
:Subscribe(function(state: any)
|
|
135
|
+
if state.canUnragdoll then
|
|
136
|
+
maid._deferred = nil
|
|
137
|
+
|
|
138
|
+
local timeElapsed = os.clock() - startTime
|
|
139
|
+
local remainingTime = state.time - timeElapsed
|
|
140
|
+
if remainingTime <= 0 then
|
|
141
|
+
isReady.Value = true
|
|
142
|
+
else
|
|
143
|
+
isReady.Value = false
|
|
144
|
+
maid._deferred = cancellableDelay(remainingTime, function()
|
|
145
|
+
isReady.Value = true
|
|
146
|
+
end)
|
|
111
147
|
end
|
|
112
|
-
end),
|
|
113
|
-
}),
|
|
114
|
-
time = self._unragdollAutomaticTime:Observe(),
|
|
115
|
-
}):Subscribe(function(state)
|
|
116
|
-
if state.canUnragdoll then
|
|
117
|
-
maid._deferred = nil
|
|
118
|
-
|
|
119
|
-
local timeElapsed = os.clock() - startTime
|
|
120
|
-
local remainingTime = state.time - timeElapsed
|
|
121
|
-
if remainingTime <= 0 then
|
|
122
|
-
isReady.Value = true
|
|
123
148
|
else
|
|
124
149
|
isReady.Value = false
|
|
125
|
-
maid._deferred =
|
|
126
|
-
isReady.Value = true
|
|
127
|
-
end)
|
|
150
|
+
maid._deferred = nil
|
|
128
151
|
end
|
|
129
|
-
|
|
130
|
-
isReady.Value = false
|
|
131
|
-
maid._deferred = nil
|
|
132
|
-
end
|
|
133
|
-
end))
|
|
152
|
+
end))
|
|
134
153
|
|
|
135
154
|
maid:GiveTask(isReady.Changed:Connect(function()
|
|
136
155
|
sub:Fire(isReady.Value)
|
|
@@ -138,17 +157,20 @@ function UnragdollAutomatically:_observeCanUnragdollTimer()
|
|
|
138
157
|
sub:Fire(isReady.Value)
|
|
139
158
|
|
|
140
159
|
return maid
|
|
141
|
-
end)
|
|
160
|
+
end) :: any
|
|
142
161
|
end
|
|
143
162
|
|
|
144
|
-
function UnragdollAutomatically
|
|
145
|
-
return RxBinderUtils.observeBoundClassBrio(self._ragdollHumanoidOnFallBinder, self._obj):Pipe({
|
|
146
|
-
RxBrioUtils.switchMapBrio(function(ragdollHumanoidOnFall)
|
|
163
|
+
function UnragdollAutomatically._observeIsFallingRagdoll(self: UnragdollAutomatically): Observable.Observable<boolean>
|
|
164
|
+
return (RxBinderUtils.observeBoundClassBrio(self._ragdollHumanoidOnFallBinder, self._obj :: Instance) :: any):Pipe({
|
|
165
|
+
RxBrioUtils.switchMapBrio(function(ragdollHumanoidOnFall): any
|
|
147
166
|
return ragdollHumanoidOnFall:ObserveIsFalling()
|
|
148
|
-
end),
|
|
149
|
-
RxBrioUtils.emitOnDeath(false),
|
|
150
|
-
Rx.distinct(),
|
|
167
|
+
end) :: any,
|
|
168
|
+
RxBrioUtils.emitOnDeath(false) :: any,
|
|
169
|
+
Rx.distinct() :: any,
|
|
151
170
|
})
|
|
152
171
|
end
|
|
153
172
|
|
|
154
|
-
return PlayerHumanoidBinder.new(
|
|
173
|
+
return PlayerHumanoidBinder.new(
|
|
174
|
+
"UnragdollAutomatically",
|
|
175
|
+
UnragdollAutomatically :: any
|
|
176
|
+
) :: PlayerHumanoidBinder.PlayerHumanoidBinder<UnragdollAutomatically>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Holds binders for Ragdoll system. Be sure to initialize on the client too. See [RagdollBindersClient].
|
|
4
4
|
Be sure to use a [ServiceBag] to initialize this service.
|
|
@@ -17,7 +17,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
17
17
|
local BinderProvider = require("BinderProvider")
|
|
18
18
|
local ServiceBag = require("ServiceBag")
|
|
19
19
|
|
|
20
|
-
return BinderProvider.new(script.Name, function(self, serviceBag: ServiceBag.ServiceBag)
|
|
20
|
+
return BinderProvider.new(script.Name, function(self: BinderProvider.BinderProvider, serviceBag: ServiceBag.ServiceBag)
|
|
21
21
|
--[=[
|
|
22
22
|
Apply this [Binder] to a humanoid to ragdoll it. Humanoid must already have [Ragdollable] defined.
|
|
23
23
|
|