@quenty/scoredactionservice 4.8.0 → 4.8.2-canary.4c04014.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 +16 -0
- package/package.json +12 -12
- package/src/Client/ScoredAction.lua +39 -7
- package/src/Client/ScoredActionService.lua +30 -5
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
|
+
## [4.8.2-canary.4c04014.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@4.8.1...@quenty/scoredactionservice@4.8.2-canary.4c04014.0) (2022-01-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/scoredactionservice
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [4.8.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@4.8.0...@quenty/scoredactionservice@4.8.1) (2022-01-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/scoredactionservice
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [4.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@4.7.0...@quenty/scoredactionservice@4.8.0) (2022-01-07)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @quenty/scoredactionservice
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/scoredactionservice",
|
|
3
|
-
"version": "4.8.0",
|
|
3
|
+
"version": "4.8.2-canary.4c04014.0",
|
|
4
4
|
"description": "Scores actions and picks the highest rated one every frame",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/baseobject": "
|
|
30
|
-
"@quenty/inputkeymaputils": "
|
|
31
|
-
"@quenty/inputmode": "
|
|
32
|
-
"@quenty/loader": "
|
|
33
|
-
"@quenty/maid": "
|
|
34
|
-
"@quenty/rx": "
|
|
35
|
-
"@quenty/signal": "
|
|
36
|
-
"@quenty/statestack": "
|
|
37
|
-
"@quenty/table": "
|
|
38
|
-
"@quenty/valueobject": "
|
|
29
|
+
"@quenty/baseobject": "3.4.1-canary.4c04014.0",
|
|
30
|
+
"@quenty/inputkeymaputils": "3.7.2-canary.4c04014.0",
|
|
31
|
+
"@quenty/inputmode": "3.7.2-canary.4c04014.0",
|
|
32
|
+
"@quenty/loader": "3.3.1-canary.4c04014.0",
|
|
33
|
+
"@quenty/maid": "2.0.3-canary.4c04014.0",
|
|
34
|
+
"@quenty/rx": "3.7.2-canary.4c04014.0",
|
|
35
|
+
"@quenty/signal": "2.1.0",
|
|
36
|
+
"@quenty/statestack": "3.4.2-canary.4c04014.0",
|
|
37
|
+
"@quenty/table": "2.1.1",
|
|
38
|
+
"@quenty/valueobject": "3.7.2-canary.4c04014.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "4c040145693283525ba3f4c793cead7abee28fb2"
|
|
44
44
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
--[=[
|
|
2
|
+
An action that has a score, and may recieve priority from [ScoredActionService]
|
|
3
|
+
|
|
4
|
+
@client
|
|
2
5
|
@class ScoredAction
|
|
3
6
|
]=]
|
|
4
7
|
|
|
@@ -12,21 +15,31 @@ local ScoredAction = setmetatable({}, BaseObject)
|
|
|
12
15
|
ScoredAction.ClassName = "ScoredAction"
|
|
13
16
|
ScoredAction.__index = ScoredAction
|
|
14
17
|
|
|
18
|
+
--[=[
|
|
19
|
+
Constructs a new ScoredAction. Should not be called directly. See [ScoredActionService.GetScoredAction].
|
|
20
|
+
|
|
21
|
+
@return ScoredAction
|
|
22
|
+
]=]
|
|
15
23
|
function ScoredAction.new()
|
|
16
24
|
local self = setmetatable(BaseObject.new(), ScoredAction)
|
|
17
25
|
|
|
18
|
-
-- @protected
|
|
19
26
|
self._score = -math.huge
|
|
20
|
-
|
|
21
|
-
-- @protected
|
|
22
27
|
self._createdTimeStamp = tick()
|
|
23
28
|
|
|
24
29
|
|
|
25
|
-
self._preferredStack = StateStack.new()
|
|
30
|
+
self._preferredStack = StateStack.new(false)
|
|
26
31
|
self._maid:GiveTask(self._preferredStack)
|
|
27
32
|
|
|
33
|
+
--[=[
|
|
34
|
+
@prop PreferredChanged Signal<boolean>
|
|
35
|
+
@within ScoredAction
|
|
36
|
+
]=]
|
|
28
37
|
self.PreferredChanged = self._preferredStack.Changed -- :Fire(newState)
|
|
29
38
|
|
|
39
|
+
--[=[
|
|
40
|
+
@prop Removing Signal<()>
|
|
41
|
+
@within ScoredAction
|
|
42
|
+
]=]
|
|
30
43
|
self.Removing = Signal.new()
|
|
31
44
|
self._maid:GiveTask(function()
|
|
32
45
|
self.Removing:Fire()
|
|
@@ -36,24 +49,43 @@ function ScoredAction.new()
|
|
|
36
49
|
return self
|
|
37
50
|
end
|
|
38
51
|
|
|
52
|
+
--[=[
|
|
53
|
+
Returns whether the action is currently preferred
|
|
54
|
+
@return boolean
|
|
55
|
+
]=]
|
|
39
56
|
function ScoredAction:IsPreferred()
|
|
40
57
|
return self._preferredStack:GetState()
|
|
41
58
|
end
|
|
42
59
|
|
|
43
|
-
--
|
|
44
|
-
|
|
60
|
+
--[=[
|
|
61
|
+
Sets the score
|
|
62
|
+
|
|
63
|
+
:::info
|
|
64
|
+
Big number is more important. At `-math.huge` we won't ever set preferred
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
@param score number
|
|
68
|
+
]=]
|
|
45
69
|
function ScoredAction:SetScore(score)
|
|
46
70
|
assert(type(score) == "number", "Bad score")
|
|
47
71
|
|
|
48
72
|
self._score = score
|
|
49
73
|
end
|
|
50
74
|
|
|
75
|
+
--[=[
|
|
76
|
+
Retrieves the score
|
|
77
|
+
@return number
|
|
78
|
+
]=]
|
|
51
79
|
function ScoredAction:GetScore()
|
|
52
80
|
return self._score
|
|
53
81
|
end
|
|
54
82
|
|
|
83
|
+
--[=[
|
|
84
|
+
Pushes that we're preferred
|
|
85
|
+
@return MaidTask
|
|
86
|
+
]=]
|
|
55
87
|
function ScoredAction:PushPreferred()
|
|
56
|
-
return self._preferredStack:PushState()
|
|
88
|
+
return self._preferredStack:PushState(true)
|
|
57
89
|
end
|
|
58
90
|
|
|
59
91
|
return ScoredAction
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
--[=[
|
|
2
|
-
Scores actions and picks the highest rated one every frame
|
|
2
|
+
Scores actions and picks the highest rated one every frame.
|
|
3
|
+
|
|
4
|
+
@client
|
|
3
5
|
@class ScoredActionService
|
|
4
6
|
]=]
|
|
5
7
|
|
|
@@ -15,19 +17,34 @@ local Observable = require("Observable")
|
|
|
15
17
|
|
|
16
18
|
local ScoredActionService = {}
|
|
17
19
|
|
|
20
|
+
--[=[
|
|
21
|
+
Initializes the ScoredActionService. Should be done via [ServiceBag].
|
|
22
|
+
@param _serviceBag ServiceBag
|
|
23
|
+
]=]
|
|
18
24
|
function ScoredActionService:Init(_serviceBag)
|
|
19
25
|
assert(not self._provider, "Already initialize")
|
|
20
26
|
|
|
27
|
+
self._maid = Maid.new()
|
|
21
28
|
self._provider = ScoredActionPickerProvider.new()
|
|
29
|
+
self._maid:GiveTask(self._provider)
|
|
22
30
|
end
|
|
23
31
|
|
|
32
|
+
--[=[
|
|
33
|
+
Starts the scored action service. Should be done via [ServiceBag].
|
|
34
|
+
]=]
|
|
24
35
|
function ScoredActionService:Start()
|
|
25
|
-
RunService.Stepped:Connect(function()
|
|
36
|
+
self._maid:GiveTask(RunService.Stepped:Connect(function()
|
|
26
37
|
-- TODO: Push to end of frame so we don't delay input by a frame?
|
|
27
38
|
self._provider:Update()
|
|
28
|
-
end)
|
|
39
|
+
end))
|
|
29
40
|
end
|
|
30
41
|
|
|
42
|
+
--[=[
|
|
43
|
+
Gets a new scored action to use
|
|
44
|
+
|
|
45
|
+
@param inputKeyMapList InputKeyMapList
|
|
46
|
+
@return ScoredAction
|
|
47
|
+
]=]
|
|
31
48
|
function ScoredActionService:GetScoredAction(inputKeyMapList)
|
|
32
49
|
assert(type(inputKeyMapList) == "table", "Bad inputKeyMapList")
|
|
33
50
|
assert(self._provider, "Not initialized")
|
|
@@ -47,8 +64,16 @@ function ScoredActionService:GetScoredAction(inputKeyMapList)
|
|
|
47
64
|
return scoredAction
|
|
48
65
|
end
|
|
49
66
|
|
|
50
|
-
--
|
|
51
|
-
|
|
67
|
+
--[=[
|
|
68
|
+
Observes a new scored action from a scoring value.
|
|
69
|
+
|
|
70
|
+
:::warning
|
|
71
|
+
This MUTATES state of the scored action service whenever an object is emitted.
|
|
72
|
+
:::
|
|
73
|
+
|
|
74
|
+
@param scoreValue NumberValue
|
|
75
|
+
@return (source: Observable<InputKeyMapList>) -> Observable<ScoredAction>
|
|
76
|
+
]=]
|
|
52
77
|
function ScoredActionService:ObserveNewFromInputKeyMapList(scoreValue)
|
|
53
78
|
assert(self._provider, "Not initialized")
|
|
54
79
|
assert(typeof(scoreValue) == "Instance" and scoreValue:IsA("NumberValue"), "Bad scoreValue")
|