@quenty/ragdoll 15.58.0 → 15.59.1
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 +14 -0
- package/deploy.nevermore.json +10 -0
- package/package.json +31 -27
- package/src/Client/Classes/RagdollCameraShakeClient.lua +8 -3
- package/src/Client/RagdollServiceClient.lua +19 -6
- package/src/Client/RagdollServiceClient.spec.lua +123 -0
- package/src/Server/RagdollService.spec.lua +166 -0
- package/src/Shared/RagdollTestUtils.lua +105 -0
- package/src/Shared/Rigging/RagdollMotorUtils.lua +6 -0
- package/src/jest.config.lua +3 -0
- package/test/default.project.json +25 -0
- package/test/scripts/Server/ServerMain.server.lua +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [15.59.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/ragdoll@15.59.0...@quenty/ragdoll@15.59.1) (2026-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/ragdoll
|
|
9
|
+
|
|
10
|
+
# [15.59.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/ragdoll@15.58.0...@quenty/ragdoll@15.59.0) (2026-07-23)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- Additional fixes ([8714d52](https://github.com/Quenty/NevermoreEngine/commit/8714d52ed996f2e41e6daa191554acca35860e36))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- Add baseline player-mock and support across Nevermore for mocked players. ([567d121](https://github.com/Quenty/NevermoreEngine/commit/567d121ffc014b42391554088189a1a6296dda83))
|
|
19
|
+
|
|
6
20
|
# [15.58.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/ragdoll@15.57.0...@quenty/ragdoll@15.58.0) (2026-07-22)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @quenty/ragdoll
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/ragdoll",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.59.1",
|
|
4
4
|
"description": "Quenty's Ragdoll system for Roblox - Floppy fun ragdolls",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,40 +28,44 @@
|
|
|
28
28
|
"Quenty"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/adorneedata": "7.
|
|
32
|
-
"@quenty/attributeutils": "14.
|
|
33
|
-
"@quenty/baseobject": "10.
|
|
34
|
-
"@quenty/binder": "14.
|
|
35
|
-
"@quenty/brio": "14.
|
|
36
|
-
"@quenty/camera": "14.
|
|
31
|
+
"@quenty/adorneedata": "7.38.0",
|
|
32
|
+
"@quenty/attributeutils": "14.33.0",
|
|
33
|
+
"@quenty/baseobject": "10.15.0",
|
|
34
|
+
"@quenty/binder": "14.41.0",
|
|
35
|
+
"@quenty/brio": "14.33.0",
|
|
36
|
+
"@quenty/camera": "14.46.1",
|
|
37
37
|
"@quenty/cancellabledelay": "3.6.2",
|
|
38
|
-
"@quenty/characterutils": "12.
|
|
39
|
-
"@quenty/draw": "7.
|
|
38
|
+
"@quenty/characterutils": "12.36.1",
|
|
39
|
+
"@quenty/draw": "7.16.0",
|
|
40
40
|
"@quenty/enumutils": "3.4.6",
|
|
41
41
|
"@quenty/hapticfeedbackutils": "3.3.3",
|
|
42
|
-
"@quenty/instanceutils": "13.
|
|
42
|
+
"@quenty/instanceutils": "13.33.0",
|
|
43
43
|
"@quenty/loader": "10.11.0",
|
|
44
|
-
"@quenty/maid": "3.
|
|
45
|
-
"@quenty/motor6d": "7.
|
|
46
|
-
"@quenty/
|
|
47
|
-
"@quenty/
|
|
48
|
-
"@quenty/
|
|
49
|
-
"@quenty/
|
|
50
|
-
"@quenty/
|
|
51
|
-
"@quenty/
|
|
52
|
-
"@quenty/
|
|
53
|
-
"@quenty/
|
|
54
|
-
"@quenty/
|
|
55
|
-
"@quenty/
|
|
44
|
+
"@quenty/maid": "3.11.0",
|
|
45
|
+
"@quenty/motor6d": "7.47.1",
|
|
46
|
+
"@quenty/nevermore-test-runner": "1.5.0",
|
|
47
|
+
"@quenty/physicsutils": "8.31.0",
|
|
48
|
+
"@quenty/playerhumanoidbinder": "14.42.1",
|
|
49
|
+
"@quenty/playermock": "1.1.1",
|
|
50
|
+
"@quenty/promise": "10.21.0",
|
|
51
|
+
"@quenty/qframe": "10.26.1",
|
|
52
|
+
"@quenty/r15utils": "13.34.0",
|
|
53
|
+
"@quenty/remoting": "12.36.1",
|
|
54
|
+
"@quenty/rigbuilderutils": "10.38.1",
|
|
55
|
+
"@quenty/rx": "13.31.0",
|
|
56
|
+
"@quenty/rxbinderutils": "14.41.0",
|
|
57
|
+
"@quenty/rxsignal": "7.31.0",
|
|
58
|
+
"@quenty/servicebag": "11.20.0",
|
|
56
59
|
"@quenty/spring": "10.12.0",
|
|
57
|
-
"@quenty/steputils": "3.
|
|
60
|
+
"@quenty/steputils": "3.7.0",
|
|
58
61
|
"@quenty/table": "3.9.2",
|
|
59
|
-
"@quenty/tie": "10.
|
|
60
|
-
"@quenty/valuebaseutils": "13.
|
|
61
|
-
"@quenty/valueobject": "13.
|
|
62
|
+
"@quenty/tie": "10.44.0",
|
|
63
|
+
"@quenty/valuebaseutils": "13.33.0",
|
|
64
|
+
"@quenty/valueobject": "13.34.0",
|
|
65
|
+
"@quentystudios/jest-lua": "3.10.0-quenty.2"
|
|
62
66
|
},
|
|
63
67
|
"publishConfig": {
|
|
64
68
|
"access": "public"
|
|
65
69
|
},
|
|
66
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "5ea0583dedebba6492f9ac6d719d32b45c5543fa"
|
|
67
71
|
}
|
|
@@ -115,11 +115,16 @@ function RagdollCameraShakeClient._setupCameraShake(self: RagdollCameraShakeClie
|
|
|
115
115
|
maid:GiveTask(RunService.Heartbeat:Connect(function()
|
|
116
116
|
debug.profilebegin("ragdollcamerashake")
|
|
117
117
|
|
|
118
|
-
local cameraCFrame = Workspace.CurrentCamera.CFrame
|
|
119
|
-
|
|
120
118
|
local velocity = getEstimatedVelocityFromUpperTorso()
|
|
121
119
|
local dVelocity = velocity - lastVelocity
|
|
122
|
-
|
|
120
|
+
|
|
121
|
+
-- CurrentCamera can be transiently nil on live clients (respawn, camera swap)
|
|
122
|
+
-- and is always nil in headless test runs -- skip the impulse for the frame
|
|
123
|
+
-- but keep tracking velocity so the camera's return doesn't spike.
|
|
124
|
+
local camera = Workspace.CurrentCamera
|
|
125
|
+
if camera ~= nil and dVelocity.magnitude >= 0 then
|
|
126
|
+
local cameraCFrame = camera.CFrame
|
|
127
|
+
|
|
123
128
|
if self._ragdollServiceClient:GetScreenShakeEnabled() then
|
|
124
129
|
-- Defaults, but we should tune these
|
|
125
130
|
local speed = 20
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
local require = require(script.Parent.loader).load(script)
|
|
10
10
|
|
|
11
|
-
local AttributeValue = require("AttributeValue")
|
|
12
|
-
|
|
13
11
|
local Players = game:GetService("Players")
|
|
12
|
+
|
|
13
|
+
local AttributeValue = require("AttributeValue")
|
|
14
|
+
local PlayerMock = require("PlayerMock")
|
|
14
15
|
local ServiceBag = require("ServiceBag")
|
|
15
16
|
|
|
16
17
|
local RagdollServiceClient = {}
|
|
@@ -19,7 +20,7 @@ RagdollServiceClient.ServiceName = "RagdollServiceClient"
|
|
|
19
20
|
export type RagdollServiceClient = typeof(setmetatable(
|
|
20
21
|
{} :: {
|
|
21
22
|
_serviceBag: ServiceBag.ServiceBag,
|
|
22
|
-
_screenShakeEnabled: AttributeValue.AttributeValue<boolean
|
|
23
|
+
_screenShakeEnabled: AttributeValue.AttributeValue<boolean>?,
|
|
23
24
|
},
|
|
24
25
|
{} :: typeof({ __index = RagdollServiceClient })
|
|
25
26
|
))
|
|
@@ -43,8 +44,20 @@ function RagdollServiceClient.Init(self: RagdollServiceClient, serviceBag: Servi
|
|
|
43
44
|
self._serviceBag:GetService((require :: any)("RagdollHumanoidOnFallClient"))
|
|
44
45
|
self._serviceBag:GetService((require :: any)("RagdollCameraShakeClient"))
|
|
45
46
|
self._serviceBag:GetService((require :: any)("RagdollBindersClient"))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
-- Resolved lazily rather than in Init so a headless boot (no LocalPlayer, and the PlayerMock
|
|
50
|
+
-- designated between Init and Start) never errors; both realms resolve on first use.
|
|
51
|
+
function RagdollServiceClient._getScreenShakeEnabled(self: RagdollServiceClient): AttributeValue.AttributeValue<boolean>
|
|
52
|
+
local screenShakeEnabled = self._screenShakeEnabled
|
|
53
|
+
if screenShakeEnabled then
|
|
54
|
+
return screenShakeEnabled
|
|
55
|
+
end
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
local localPlayer = assert(Players.LocalPlayer or PlayerMock.getMockedLocalPlayer(), "No local player")
|
|
58
|
+
local created = AttributeValue.new(localPlayer, "RagdollScreenShakeEnabled", true)
|
|
59
|
+
self._screenShakeEnabled = created
|
|
60
|
+
return created
|
|
48
61
|
end
|
|
49
62
|
|
|
50
63
|
--[=[
|
|
@@ -54,7 +67,7 @@ end
|
|
|
54
67
|
function RagdollServiceClient.SetScreenShakeEnabled(self: RagdollServiceClient, value: boolean): ()
|
|
55
68
|
assert(type(value) == "boolean", "Bad value")
|
|
56
69
|
|
|
57
|
-
self.
|
|
70
|
+
self:_getScreenShakeEnabled().Value = value
|
|
58
71
|
end
|
|
59
72
|
|
|
60
73
|
--[=[
|
|
@@ -64,7 +77,7 @@ end
|
|
|
64
77
|
function RagdollServiceClient.GetScreenShakeEnabled(self: RagdollServiceClient): boolean
|
|
65
78
|
assert(self._serviceBag, "Not initialized")
|
|
66
79
|
|
|
67
|
-
return self.
|
|
80
|
+
return self:_getScreenShakeEnabled().Value
|
|
68
81
|
end
|
|
69
82
|
|
|
70
83
|
return RagdollServiceClient
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[[
|
|
3
|
+
Integration coverage for RagdollServiceClient booted headless against a pre-designated mock
|
|
4
|
+
local player (designation must precede Init -- production parity, where Players.LocalPlayer
|
|
5
|
+
exists before any service runs). Client binders never auto-tag, so the rigging test drives the
|
|
6
|
+
same tags the server would replicate.
|
|
7
|
+
|
|
8
|
+
@class RagdollServiceClient.spec.lua
|
|
9
|
+
]]
|
|
10
|
+
|
|
11
|
+
local require = require(script.Parent.loader).load(script)
|
|
12
|
+
|
|
13
|
+
local Workspace = game:GetService("Workspace")
|
|
14
|
+
|
|
15
|
+
local Jest = require("Jest")
|
|
16
|
+
local PlayerMock = require("PlayerMock")
|
|
17
|
+
local RagdollClient = require("RagdollClient")
|
|
18
|
+
local RagdollServiceClient = require("RagdollServiceClient")
|
|
19
|
+
local RagdollTestUtils = require("RagdollTestUtils")
|
|
20
|
+
local RagdollableClient = require("RagdollableClient")
|
|
21
|
+
local RigBuilderUtils = require("RigBuilderUtils")
|
|
22
|
+
local ServiceBag = require("ServiceBag")
|
|
23
|
+
|
|
24
|
+
local afterEach = Jest.Globals.afterEach
|
|
25
|
+
local describe = Jest.Globals.describe
|
|
26
|
+
local expect = Jest.Globals.expect
|
|
27
|
+
local it = Jest.Globals.it
|
|
28
|
+
|
|
29
|
+
local specCounter = 0
|
|
30
|
+
local currentMock: Player? = nil
|
|
31
|
+
local currentServiceBag: ServiceBag.ServiceBag? = nil
|
|
32
|
+
|
|
33
|
+
local function setup()
|
|
34
|
+
specCounter += 1
|
|
35
|
+
|
|
36
|
+
local mock = PlayerMock.new({ UserId = 66123100 + specCounter })
|
|
37
|
+
mock.Parent = Workspace
|
|
38
|
+
PlayerMock.setMockedLocalPlayer(mock)
|
|
39
|
+
currentMock = mock
|
|
40
|
+
|
|
41
|
+
local serviceBag = ServiceBag.new()
|
|
42
|
+
local ragdollServiceClient = (
|
|
43
|
+
serviceBag:GetService(RagdollServiceClient) :: any
|
|
44
|
+
) :: RagdollServiceClient.RagdollServiceClient
|
|
45
|
+
|
|
46
|
+
serviceBag:Init()
|
|
47
|
+
serviceBag:Start()
|
|
48
|
+
currentServiceBag = serviceBag
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
mock = mock,
|
|
52
|
+
serviceBag = serviceBag,
|
|
53
|
+
ragdollServiceClient = ragdollServiceClient,
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
afterEach(function()
|
|
58
|
+
if currentServiceBag ~= nil then
|
|
59
|
+
currentServiceBag:Destroy()
|
|
60
|
+
currentServiceBag = nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
PlayerMock.setMockedLocalPlayer(nil)
|
|
64
|
+
|
|
65
|
+
if currentMock ~= nil then
|
|
66
|
+
currentMock:Destroy()
|
|
67
|
+
currentMock = nil
|
|
68
|
+
end
|
|
69
|
+
end)
|
|
70
|
+
|
|
71
|
+
describe("RagdollServiceClient with a mocked local player", function()
|
|
72
|
+
it("initializes, starts, and defaults screen shake to enabled", function()
|
|
73
|
+
local state = setup()
|
|
74
|
+
|
|
75
|
+
expect(state.ragdollServiceClient:GetScreenShakeEnabled()).toBe(true)
|
|
76
|
+
end)
|
|
77
|
+
|
|
78
|
+
it("writes screen shake changes to the local player attribute", function()
|
|
79
|
+
local state = setup()
|
|
80
|
+
|
|
81
|
+
state.ragdollServiceClient:SetScreenShakeEnabled(false)
|
|
82
|
+
expect(state.ragdollServiceClient:GetScreenShakeEnabled()).toBe(false)
|
|
83
|
+
expect(state.mock:GetAttribute("RagdollScreenShakeEnabled")).toBe(false)
|
|
84
|
+
|
|
85
|
+
state.ragdollServiceClient:SetScreenShakeEnabled(true)
|
|
86
|
+
expect(state.mock:GetAttribute("RagdollScreenShakeEnabled")).toBe(true)
|
|
87
|
+
end)
|
|
88
|
+
|
|
89
|
+
it("survives a character load while running", function()
|
|
90
|
+
local state = setup()
|
|
91
|
+
|
|
92
|
+
local character = RigBuilderUtils.createR6BaseRig()
|
|
93
|
+
PlayerMock.loadCharacterAsync(state.mock, character)
|
|
94
|
+
|
|
95
|
+
expect(character.Parent).toBe(Workspace)
|
|
96
|
+
expect(character:FindFirstChildOfClass("Humanoid")).toBeDefined()
|
|
97
|
+
end)
|
|
98
|
+
|
|
99
|
+
it("rigs and unrigs the character through the client binders", function()
|
|
100
|
+
local state = setup()
|
|
101
|
+
|
|
102
|
+
local character = RigBuilderUtils.createR6BaseRig()
|
|
103
|
+
PlayerMock.loadCharacterAsync(state.mock, character)
|
|
104
|
+
local humanoid = assert(character:FindFirstChildOfClass("Humanoid"), "No humanoid in rig")
|
|
105
|
+
|
|
106
|
+
local ragdollableBinder = state.serviceBag:GetService(RagdollableClient)
|
|
107
|
+
local ragdollBinder = state.serviceBag:GetService(RagdollClient)
|
|
108
|
+
|
|
109
|
+
ragdollableBinder:Bind(humanoid)
|
|
110
|
+
local ok = ragdollableBinder:Promise(humanoid):Yield()
|
|
111
|
+
assert(ok, "RagdollableClient never bound")
|
|
112
|
+
|
|
113
|
+
ragdollBinder:Bind(humanoid)
|
|
114
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
115
|
+
return RagdollTestUtils.areMotorsEnabled(character, false)
|
|
116
|
+
end)).toBe(true)
|
|
117
|
+
|
|
118
|
+
ragdollBinder:Unbind(humanoid)
|
|
119
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
120
|
+
return RagdollTestUtils.areMotorsEnabled(character, true)
|
|
121
|
+
end)).toBe(true)
|
|
122
|
+
end)
|
|
123
|
+
end)
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[[
|
|
3
|
+
Integration coverage for RagdollService booted the way production does -- through a ServiceBag
|
|
4
|
+
-- against a PlayerMock whose character is a local R6 rig. Discovery flows mock join ->
|
|
5
|
+
PlayerHumanoidBinder -> bind, so no test reaches in to Tag by hand; ragdolling drives the
|
|
6
|
+
public Ragdoll binder.
|
|
7
|
+
|
|
8
|
+
@class RagdollService.spec.lua
|
|
9
|
+
]]
|
|
10
|
+
|
|
11
|
+
local require = require(script.Parent.loader).load(script)
|
|
12
|
+
|
|
13
|
+
local Workspace = game:GetService("Workspace")
|
|
14
|
+
|
|
15
|
+
local Jest = require("Jest")
|
|
16
|
+
local PlayerMock = require("PlayerMock")
|
|
17
|
+
local PlayerMockService = require("PlayerMockService")
|
|
18
|
+
local Ragdoll = require("Ragdoll")
|
|
19
|
+
local RagdollHumanoidOnFall = require("RagdollHumanoidOnFall")
|
|
20
|
+
local RagdollHumanoidOnFallConstants = require("RagdollHumanoidOnFallConstants")
|
|
21
|
+
local RagdollService = require("RagdollService")
|
|
22
|
+
local RagdollTestUtils = require("RagdollTestUtils")
|
|
23
|
+
local Ragdollable = require("Ragdollable")
|
|
24
|
+
local RigBuilderUtils = require("RigBuilderUtils")
|
|
25
|
+
local ServiceBag = require("ServiceBag")
|
|
26
|
+
|
|
27
|
+
local describe = Jest.Globals.describe
|
|
28
|
+
local expect = Jest.Globals.expect
|
|
29
|
+
local it = Jest.Globals.it
|
|
30
|
+
|
|
31
|
+
local specCounter = 0
|
|
32
|
+
|
|
33
|
+
local function setup()
|
|
34
|
+
specCounter += 1
|
|
35
|
+
|
|
36
|
+
local container = Instance.new("Folder")
|
|
37
|
+
container.Name = string.format("RagdollServiceSpecContainer_%d", specCounter)
|
|
38
|
+
container.Parent = Workspace
|
|
39
|
+
|
|
40
|
+
local serviceBag = ServiceBag.new()
|
|
41
|
+
local ragdollService: any = serviceBag:GetService(RagdollService)
|
|
42
|
+
local playerMockService = serviceBag:GetService(PlayerMockService)
|
|
43
|
+
|
|
44
|
+
serviceBag:Init()
|
|
45
|
+
serviceBag:Start()
|
|
46
|
+
|
|
47
|
+
local mock = playerMockService:CreatePlayer({ UserId = 66123200 + specCounter })
|
|
48
|
+
mock.Parent = container
|
|
49
|
+
|
|
50
|
+
local character = RigBuilderUtils.createR6BaseRig()
|
|
51
|
+
PlayerMock.loadCharacterAsync(mock, character)
|
|
52
|
+
|
|
53
|
+
local humanoid = assert(character:FindFirstChildOfClass("Humanoid"), "No humanoid in rig")
|
|
54
|
+
|
|
55
|
+
local bagDestroyed = false
|
|
56
|
+
local function destroyBag()
|
|
57
|
+
if not bagDestroyed then
|
|
58
|
+
bagDestroyed = true
|
|
59
|
+
serviceBag:Destroy()
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
local function destroy()
|
|
64
|
+
destroyBag()
|
|
65
|
+
mock:Destroy()
|
|
66
|
+
container:Destroy()
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
serviceBag = serviceBag,
|
|
71
|
+
ragdollService = ragdollService,
|
|
72
|
+
mock = mock,
|
|
73
|
+
character = character,
|
|
74
|
+
humanoid = humanoid,
|
|
75
|
+
destroyBag = destroyBag,
|
|
76
|
+
destroy = destroy,
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe("RagdollService with a mock player R6 character", function()
|
|
81
|
+
it("binds Ragdollable through mock discovery and pre-rigs ball sockets", function()
|
|
82
|
+
local state = setup()
|
|
83
|
+
|
|
84
|
+
local ragdollableBinder = state.serviceBag:GetService(Ragdollable)
|
|
85
|
+
local ok = ragdollableBinder:Promise(state.humanoid):Yield()
|
|
86
|
+
assert(ok, "Ragdollable never bound")
|
|
87
|
+
|
|
88
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
89
|
+
return RagdollTestUtils.countBallSockets(state.character) == 5
|
|
90
|
+
end)).toBe(true)
|
|
91
|
+
|
|
92
|
+
local torso = assert(state.character:FindFirstChild("Torso"), "No torso")
|
|
93
|
+
expect(torso:FindFirstChild("NeckAttachment")).toBeDefined()
|
|
94
|
+
expect(torso:FindFirstChild("LeftShoulderRagdollAttachment")).toBeDefined()
|
|
95
|
+
|
|
96
|
+
state.destroy()
|
|
97
|
+
end)
|
|
98
|
+
|
|
99
|
+
it("suppresses motors while Ragdoll is bound and restores them on unbind", function()
|
|
100
|
+
local state = setup()
|
|
101
|
+
|
|
102
|
+
local ragdollableBinder = state.serviceBag:GetService(Ragdollable)
|
|
103
|
+
local ok = ragdollableBinder:Promise(state.humanoid):Yield()
|
|
104
|
+
assert(ok, "Ragdollable never bound")
|
|
105
|
+
|
|
106
|
+
local ragdollBinder = state.serviceBag:GetService(Ragdoll)
|
|
107
|
+
expect(RagdollTestUtils.areMotorsEnabled(state.character, true)).toBe(true)
|
|
108
|
+
|
|
109
|
+
ragdollBinder:Bind(state.humanoid)
|
|
110
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
111
|
+
return RagdollTestUtils.areMotorsEnabled(state.character, false)
|
|
112
|
+
end)).toBe(true)
|
|
113
|
+
expect(ragdollBinder:Get(state.humanoid)).toBeDefined()
|
|
114
|
+
|
|
115
|
+
ragdollBinder:Unbind(state.humanoid)
|
|
116
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
117
|
+
return RagdollTestUtils.areMotorsEnabled(state.character, true)
|
|
118
|
+
end)).toBe(true)
|
|
119
|
+
expect(ragdollBinder:Get(state.humanoid)).toBeNil()
|
|
120
|
+
|
|
121
|
+
state.destroy()
|
|
122
|
+
end)
|
|
123
|
+
|
|
124
|
+
it("tears down while ragdolled, despawning the mock character", function()
|
|
125
|
+
local state = setup()
|
|
126
|
+
|
|
127
|
+
local ragdollableBinder = state.serviceBag:GetService(Ragdollable)
|
|
128
|
+
local ok = ragdollableBinder:Promise(state.humanoid):Yield()
|
|
129
|
+
assert(ok, "Ragdollable never bound")
|
|
130
|
+
|
|
131
|
+
state.serviceBag:GetService(Ragdoll):Bind(state.humanoid)
|
|
132
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
133
|
+
return RagdollTestUtils.areMotorsEnabled(state.character, false)
|
|
134
|
+
end)).toBe(true)
|
|
135
|
+
|
|
136
|
+
state.destroyBag()
|
|
137
|
+
|
|
138
|
+
-- The bag's PlayerMockService owns the mock, so teardown despawns the character with it.
|
|
139
|
+
expect(RagdollTestUtils.waitFor(function()
|
|
140
|
+
return state.character.Parent == nil
|
|
141
|
+
end)).toBe(true)
|
|
142
|
+
|
|
143
|
+
state.destroy()
|
|
144
|
+
end)
|
|
145
|
+
|
|
146
|
+
it("SetRagdollOnFall toggles automatic tagging and the fall remote event", function()
|
|
147
|
+
local state = setup()
|
|
148
|
+
|
|
149
|
+
local onFallBinder = state.serviceBag:GetService(RagdollHumanoidOnFall)
|
|
150
|
+
expect(onFallBinder:Get(state.humanoid)).toBeNil()
|
|
151
|
+
|
|
152
|
+
state.ragdollService:SetRagdollOnFall(true)
|
|
153
|
+
|
|
154
|
+
local ok = onFallBinder:Promise(state.humanoid):Yield()
|
|
155
|
+
assert(ok, "RagdollHumanoidOnFall never bound")
|
|
156
|
+
expect(state.humanoid:FindFirstChild(RagdollHumanoidOnFallConstants.REMOTE_EVENT_NAME)).toBeDefined()
|
|
157
|
+
|
|
158
|
+
state.ragdollService:SetRagdollOnFall(false)
|
|
159
|
+
RagdollTestUtils.awaitUnbound(onFallBinder, state.humanoid)
|
|
160
|
+
|
|
161
|
+
expect(onFallBinder:Get(state.humanoid)).toBeNil()
|
|
162
|
+
expect(state.humanoid:FindFirstChild(RagdollHumanoidOnFallConstants.REMOTE_EVENT_NAME)).toBeNil()
|
|
163
|
+
|
|
164
|
+
state.destroy()
|
|
165
|
+
end)
|
|
166
|
+
end)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[=[
|
|
3
|
+
Shared helpers for the ragdoll specs. Rigging is asserted against the local R6 rig from
|
|
4
|
+
[RigBuilderUtils.createR6BaseRig] -- the R15 builders need InsertService, which headless test
|
|
5
|
+
places cannot reach. Suppression/restore assertions poll: motor suppression settles a couple of
|
|
6
|
+
task resumptions after the Ragdoll bind (velocity-recording promise, then the rigging
|
|
7
|
+
subscriptions).
|
|
8
|
+
|
|
9
|
+
@class RagdollTestUtils
|
|
10
|
+
]=]
|
|
11
|
+
|
|
12
|
+
local require = require(script.Parent.loader).load(script)
|
|
13
|
+
|
|
14
|
+
local Binder = require("Binder")
|
|
15
|
+
|
|
16
|
+
local RagdollTestUtils = {}
|
|
17
|
+
|
|
18
|
+
-- The R6 base rig's Torso motors that ragdoll suppression disables. The root joint is
|
|
19
|
+
-- deliberately absent: suppression looks for Torso["Root"], which neither the base rig nor a
|
|
20
|
+
-- real R6 character carries under that name.
|
|
21
|
+
RagdollTestUtils.R6_RAGDOLL_MOTOR_NAMES = {
|
|
22
|
+
"Neck",
|
|
23
|
+
"Left Shoulder",
|
|
24
|
+
"Right Shoulder",
|
|
25
|
+
"Left Hip",
|
|
26
|
+
"Right Hip",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
--[=[
|
|
30
|
+
Polls until the condition passes or the timeout elapses. Returns the final condition result so
|
|
31
|
+
specs can `expect(...).toBe(true)` on it.
|
|
32
|
+
|
|
33
|
+
@param condition () -> boolean
|
|
34
|
+
@param timeout number?
|
|
35
|
+
@return boolean
|
|
36
|
+
]=]
|
|
37
|
+
function RagdollTestUtils.waitFor(condition: () -> boolean, timeout: number?): boolean
|
|
38
|
+
local deadline = os.clock() + (timeout or 5)
|
|
39
|
+
while os.clock() < deadline do
|
|
40
|
+
if condition() then
|
|
41
|
+
return true
|
|
42
|
+
end
|
|
43
|
+
task.wait(0.05)
|
|
44
|
+
end
|
|
45
|
+
return condition()
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
--[=[
|
|
49
|
+
Returns whether every R6 ragdoll motor in the character matches the given Enabled state.
|
|
50
|
+
|
|
51
|
+
@param character Model
|
|
52
|
+
@param enabled boolean
|
|
53
|
+
@return boolean
|
|
54
|
+
]=]
|
|
55
|
+
function RagdollTestUtils.areMotorsEnabled(character: Model, enabled: boolean): boolean
|
|
56
|
+
local torso = character:FindFirstChild("Torso")
|
|
57
|
+
if not torso then
|
|
58
|
+
return false
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
for _, motorName in RagdollTestUtils.R6_RAGDOLL_MOTOR_NAMES do
|
|
62
|
+
local motor = torso:FindFirstChild(motorName)
|
|
63
|
+
if not (motor and motor:IsA("Motor6D")) then
|
|
64
|
+
return false
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if motor.Enabled ~= enabled then
|
|
68
|
+
return false
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
return true
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
--[=[
|
|
76
|
+
Counts the RagdollBallSocket constraints in the character.
|
|
77
|
+
|
|
78
|
+
@param character Model
|
|
79
|
+
@return number
|
|
80
|
+
]=]
|
|
81
|
+
function RagdollTestUtils.countBallSockets(character: Model): number
|
|
82
|
+
local count = 0
|
|
83
|
+
for _, descendant in character:GetDescendants() do
|
|
84
|
+
if descendant:IsA("BallSocketConstraint") and descendant.Name == "RagdollBallSocket" then
|
|
85
|
+
count += 1
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
return count
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
--[=[
|
|
93
|
+
Returns once `inst` is no longer bound. Removal is usually already done by the time we check;
|
|
94
|
+
the guarded wait also covers a deferred case.
|
|
95
|
+
|
|
96
|
+
@param binder Binder
|
|
97
|
+
@param inst Instance
|
|
98
|
+
]=]
|
|
99
|
+
function RagdollTestUtils.awaitUnbound(binder: Binder.Binder<any>, inst: Instance)
|
|
100
|
+
if binder:Get(inst) ~= nil then
|
|
101
|
+
binder:GetClassRemovedSignal():Wait()
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
return RagdollTestUtils
|
|
@@ -491,6 +491,12 @@ function RagdollMotorUtils.promiseVelocityRecordings(
|
|
|
491
491
|
end
|
|
492
492
|
|
|
493
493
|
function RagdollMotorUtils.yieldUntilStepped(): number
|
|
494
|
+
if not RunService:IsRunning() then
|
|
495
|
+
-- Physics never steps in a non-running DataModel (headless test runs), so there is no
|
|
496
|
+
-- settling to wait on. Report a nominal frame time so velocity math stays finite.
|
|
497
|
+
return 1 / 60
|
|
498
|
+
end
|
|
499
|
+
|
|
494
500
|
local start = time()
|
|
495
501
|
local dt: number
|
|
496
502
|
repeat
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "RagdollTest",
|
|
3
|
+
"globIgnorePaths": [
|
|
4
|
+
"**/.package-lock.json",
|
|
5
|
+
"**/.pnpm",
|
|
6
|
+
"**/.pnpm-workspace-state-v1.json",
|
|
7
|
+
"**/.modules.yaml",
|
|
8
|
+
"**/.ignored",
|
|
9
|
+
"**/.ignored_*"
|
|
10
|
+
],
|
|
11
|
+
"tree": {
|
|
12
|
+
"$className": "DataModel",
|
|
13
|
+
"ServerScriptService": {
|
|
14
|
+
"$properties": {
|
|
15
|
+
"LoadStringEnabled": true
|
|
16
|
+
},
|
|
17
|
+
"ragdoll": {
|
|
18
|
+
"$path": ".."
|
|
19
|
+
},
|
|
20
|
+
"Script": {
|
|
21
|
+
"$path": "scripts/Server"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
@class ServerMain
|
|
3
|
+
]]
|
|
4
|
+
local ServerScriptService = game:GetService("ServerScriptService")
|
|
5
|
+
|
|
6
|
+
local root = ServerScriptService.ragdoll
|
|
7
|
+
local loader = root:FindFirstChild("LoaderUtils", true).Parent
|
|
8
|
+
local require = require(loader).bootstrapGame(root)
|
|
9
|
+
|
|
10
|
+
local NevermoreTestRunnerUtils = require("NevermoreTestRunnerUtils")
|
|
11
|
+
if NevermoreTestRunnerUtils.runTestsIfNeededAsync(root) then
|
|
12
|
+
return
|
|
13
|
+
end
|