@quenty/idleservice 2.2.1 → 3.0.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
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
# [3.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/idleservice@2.3.0...@quenty/idleservice@3.0.0) (2022-01-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/idleservice
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/idleservice@2.2.1...@quenty/idleservice@2.3.0) (2022-01-17)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/idleservice
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/idleservice@2.2.0...@quenty/idleservice@2.2.1) (2022-01-16)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @quenty/idleservice
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/idleservice",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Helps track whether or not a player is idle and if so, then can show UI or other cute things.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"Quenty"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@quenty/humanoidtracker": "^3.
|
|
31
|
-
"@quenty/loader": "^3.
|
|
32
|
-
"@quenty/maid": "^2.0
|
|
33
|
-
"@quenty/ragdoll": "^5.
|
|
34
|
-
"@quenty/servicebag": "^3.
|
|
35
|
-
"@quenty/statestack": "^
|
|
30
|
+
"@quenty/humanoidtracker": "^3.8.0",
|
|
31
|
+
"@quenty/loader": "^3.4.0",
|
|
32
|
+
"@quenty/maid": "^2.1.0",
|
|
33
|
+
"@quenty/ragdoll": "^5.3.0",
|
|
34
|
+
"@quenty/servicebag": "^3.5.0",
|
|
35
|
+
"@quenty/statestack": "^4.0.0",
|
|
36
|
+
"@quenty/valuebaseutils": "^3.8.0"
|
|
36
37
|
},
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "cbd40cfd2fd23c14978a3154cad9d1e3d1c78edf"
|
|
41
42
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
--[=[
|
|
2
|
-
Helps track whether or not a player is idle and if so, then can show UI or other cute things
|
|
3
|
-
|
|
2
|
+
Helps track whether or not a player is idle and if so, then can show UI or other cute things.
|
|
3
|
+
|
|
4
|
+
@client
|
|
5
|
+
@class IdleServiceClient
|
|
4
6
|
]=]
|
|
5
7
|
|
|
6
8
|
local require = require(script.Parent.loader).load(script)
|
|
@@ -11,20 +13,29 @@ local VRService = game:GetService("VRService")
|
|
|
11
13
|
local HumanoidTrackerService = require("HumanoidTrackerService")
|
|
12
14
|
local Maid = require("Maid")
|
|
13
15
|
local RagdollBindersClient = require("RagdollBindersClient")
|
|
16
|
+
local RxValueBaseUtils = require("RxValueBaseUtils")
|
|
14
17
|
local StateStack = require("StateStack")
|
|
15
18
|
|
|
16
|
-
local
|
|
19
|
+
local IdleServiceClient = {}
|
|
17
20
|
|
|
18
21
|
local STANDING_TIME_REQUIRED = 0.5
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
--[=[
|
|
24
|
+
Initializes the idle service on the client. Should be done via [ServiceBag].
|
|
25
|
+
@param serviceBag ServiceBag
|
|
26
|
+
]=]
|
|
27
|
+
function IdleServiceClient:Init(serviceBag)
|
|
21
28
|
assert(not self._maid, "Already initialized")
|
|
22
29
|
|
|
23
30
|
self._maid = Maid.new()
|
|
24
|
-
self.
|
|
25
|
-
self._ragdollBindersClient = serviceBag:GetService(RagdollBindersClient)
|
|
31
|
+
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
-- External
|
|
34
|
+
self._serviceBag:GetService(require("RagdollServiceClient"))
|
|
35
|
+
self._humanoidTracker = self._serviceBag:GetService(HumanoidTrackerService):GetHumanoidTracker()
|
|
36
|
+
self._ragdollBindersClient = self._serviceBag:GetService(RagdollBindersClient)
|
|
37
|
+
|
|
38
|
+
self._disabledStack = StateStack.new(false)
|
|
28
39
|
self._maid:GiveTask(self._disabledStack)
|
|
29
40
|
|
|
30
41
|
self._enabled = Instance.new("BoolValue")
|
|
@@ -38,7 +49,12 @@ function IdleService:Init(serviceBag)
|
|
|
38
49
|
self._humanoidIdle = Instance.new("BoolValue")
|
|
39
50
|
self._humanoidIdle.Value = false
|
|
40
51
|
self._maid:GiveTask(self._humanoidIdle)
|
|
52
|
+
end
|
|
41
53
|
|
|
54
|
+
--[=[
|
|
55
|
+
Starts idle service on the client. Should be done via [ServiceBag].
|
|
56
|
+
]=]
|
|
57
|
+
function IdleServiceClient:Start()
|
|
42
58
|
self._maid:GiveTask(self._humanoidIdle.Changed:Connect(function()
|
|
43
59
|
self:_updateShowIdleUI()
|
|
44
60
|
end))
|
|
@@ -59,39 +75,63 @@ function IdleService:Init(serviceBag)
|
|
|
59
75
|
self:_updateShowIdleUI()
|
|
60
76
|
end
|
|
61
77
|
|
|
62
|
-
|
|
78
|
+
--[=[
|
|
79
|
+
Returns whether the humanoid is idle.
|
|
80
|
+
@return boolean
|
|
81
|
+
]=]
|
|
82
|
+
function IdleServiceClient:IsHumanoidIdle()
|
|
63
83
|
return self._humanoidIdle.Value
|
|
64
84
|
end
|
|
65
85
|
|
|
66
|
-
|
|
86
|
+
--[=[
|
|
87
|
+
Returns whether UI should be shown (if the humanoid is idle)
|
|
88
|
+
@return boolean
|
|
89
|
+
]=]
|
|
90
|
+
function IdleServiceClient:DoShowIdleUI()
|
|
67
91
|
return self._showIdleUI.Value
|
|
68
92
|
end
|
|
69
93
|
|
|
70
|
-
|
|
94
|
+
--[=[
|
|
95
|
+
Observes whether to show the the idle UI
|
|
96
|
+
@return Observable<boolean>
|
|
97
|
+
]=]
|
|
98
|
+
function IdleServiceClient:ObserveShowIdleUI()
|
|
99
|
+
return RxValueBaseUtils.observeValue(self._showIdleUI)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
--[=[
|
|
103
|
+
Returns a show idle bool value.
|
|
104
|
+
@return BoolValue
|
|
105
|
+
]=]
|
|
106
|
+
function IdleServiceClient:GetShowIdleUIBoolValue()
|
|
71
107
|
assert(self._showIdleUI, "Not initialized")
|
|
72
108
|
|
|
73
109
|
return self._showIdleUI
|
|
74
110
|
end
|
|
75
111
|
|
|
76
|
-
|
|
112
|
+
--[=[
|
|
113
|
+
Pushes a disabling function that disables idle UI
|
|
114
|
+
@return boolean
|
|
115
|
+
]=]
|
|
116
|
+
function IdleServiceClient:PushDisable()
|
|
77
117
|
if not RunService:IsRunning() then
|
|
78
118
|
return function() end
|
|
79
119
|
end
|
|
80
120
|
|
|
81
121
|
assert(self._disabledStack, "Not initialized")
|
|
82
|
-
return self._disabledStack:PushState()
|
|
122
|
+
return self._disabledStack:PushState(true)
|
|
83
123
|
end
|
|
84
124
|
|
|
85
|
-
function
|
|
125
|
+
function IdleServiceClient:_setEnabled(enabled)
|
|
86
126
|
assert(type(enabled) == "boolean", "Bad enabled")
|
|
87
127
|
self._enabled.Value = enabled
|
|
88
128
|
end
|
|
89
129
|
|
|
90
|
-
function
|
|
130
|
+
function IdleServiceClient:_updateShowIdleUI()
|
|
91
131
|
self._showIdleUI.Value = self._humanoidIdle.Value and self._enabled.Value and not VRService.VREnabled
|
|
92
132
|
end
|
|
93
133
|
|
|
94
|
-
function
|
|
134
|
+
function IdleServiceClient:_handleAliveHumanoidChanged()
|
|
95
135
|
local humanoid = self._humanoidTracker.AliveHumanoid.Value
|
|
96
136
|
if not humanoid then
|
|
97
137
|
self._maid._humanoidMaid = nil
|
|
@@ -100,14 +140,14 @@ function IdleService:_handleAliveHumanoidChanged()
|
|
|
100
140
|
|
|
101
141
|
local maid = Maid.new()
|
|
102
142
|
|
|
103
|
-
local lastMove =
|
|
143
|
+
local lastMove = os.clock()
|
|
104
144
|
|
|
105
145
|
maid:GiveTask(function()
|
|
106
146
|
self._humanoidIdle.Value = false
|
|
107
147
|
end)
|
|
108
148
|
|
|
109
149
|
local function update()
|
|
110
|
-
if
|
|
150
|
+
if os.clock() - lastMove >= STANDING_TIME_REQUIRED then
|
|
111
151
|
self._humanoidIdle.Value = true
|
|
112
152
|
else
|
|
113
153
|
self._humanoidIdle.Value = false
|
|
@@ -115,17 +155,17 @@ function IdleService:_handleAliveHumanoidChanged()
|
|
|
115
155
|
end
|
|
116
156
|
|
|
117
157
|
maid:GiveTask(self._enabled.Changed:Connect(function()
|
|
118
|
-
lastMove =
|
|
158
|
+
lastMove = os.clock()
|
|
119
159
|
end))
|
|
120
160
|
|
|
121
161
|
maid:GiveTask(RunService.Stepped:Connect(function()
|
|
122
162
|
local rootPart = humanoid.RootPart
|
|
123
163
|
|
|
124
164
|
if self._ragdollBindersClient.Ragdoll:Get(humanoid) then
|
|
125
|
-
lastMove =
|
|
165
|
+
lastMove = os.clock()
|
|
126
166
|
elseif rootPart then
|
|
127
167
|
if rootPart.Velocity.magnitude > 2.5 then
|
|
128
|
-
lastMove =
|
|
168
|
+
lastMove = os.clock()
|
|
129
169
|
end
|
|
130
170
|
end
|
|
131
171
|
|
|
@@ -135,4 +175,4 @@ function IdleService:_handleAliveHumanoidChanged()
|
|
|
135
175
|
self._maid._humanoidMaid = maid
|
|
136
176
|
end
|
|
137
177
|
|
|
138
|
-
return
|
|
178
|
+
return IdleServiceClient
|