@quenty/scoredactionservice 7.3.1 → 8.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,14 @@
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
+ # [8.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@7.3.1...@quenty/scoredactionservice@8.0.0) (2022-08-14)
7
+
8
+ **Note:** Version bump only for package @quenty/scoredactionservice
9
+
10
+
11
+
12
+
13
+
6
14
  ## [7.3.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@7.3.0...@quenty/scoredactionservice@7.3.1) (2022-08-11)
7
15
 
8
16
  **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": "7.3.1",
3
+ "version": "8.0.0",
4
4
  "description": "Scores actions and picks the highest rated one every frame",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -27,19 +27,19 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@quenty/baseobject": "^5.1.0",
30
- "@quenty/brio": "^6.2.0",
31
- "@quenty/inputkeymaputils": "^5.3.1",
32
- "@quenty/inputmode": "^5.2.0",
30
+ "@quenty/brio": "^7.0.0",
31
+ "@quenty/inputkeymaputils": "^6.0.0",
32
+ "@quenty/inputmode": "^6.0.0",
33
33
  "@quenty/loader": "^5.0.0",
34
34
  "@quenty/maid": "^2.4.0",
35
- "@quenty/rx": "^5.2.0",
35
+ "@quenty/rx": "^6.0.0",
36
36
  "@quenty/signal": "^2.2.0",
37
- "@quenty/statestack": "^6.2.0",
37
+ "@quenty/statestack": "^7.0.0",
38
38
  "@quenty/table": "^3.1.0",
39
- "@quenty/valueobject": "^5.2.0"
39
+ "@quenty/valueobject": "^6.0.0"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "45ffe88b893e29690163a42c3830c983f6098a59"
44
+ "gitHead": "dbb62609f980983cc32da90acfef13e30ed41113"
45
45
  }
@@ -7,16 +7,18 @@ local require = require(script.Parent.loader).load(script)
7
7
 
8
8
  local BaseObject = require("BaseObject")
9
9
  local InputKeyMapList = require("InputKeyMapList")
10
- local Set = require("Set")
10
+ local InputKeyMapListUtils = require("InputKeyMapListUtils")
11
11
  local Rx = require("Rx")
12
+ local Set = require("Set")
12
13
 
13
14
  local InputListScoreHelper = setmetatable({}, BaseObject)
14
15
  InputListScoreHelper.ClassName = "InputListScoreHelper"
15
16
  InputListScoreHelper.__index = InputListScoreHelper
16
17
 
17
- function InputListScoreHelper.new(provider, scoredAction, inputKeyMapList)
18
+ function InputListScoreHelper.new(serviceBag, provider, scoredAction, inputKeyMapList)
18
19
  local self = setmetatable(BaseObject.new(), InputListScoreHelper)
19
20
 
21
+ self._serviceBag = assert(serviceBag, "No serviceBag")
20
22
  self._provider = assert(provider, "No provider")
21
23
  self._scoredAction = assert(scoredAction, "No scoredAction")
22
24
  self._inputKeyMapList = assert(inputKeyMapList, "No inputKeyMapList")
@@ -25,7 +27,7 @@ function InputListScoreHelper.new(provider, scoredAction, inputKeyMapList)
25
27
 
26
28
  self._currentTypes = {}
27
29
 
28
- self._maid:GiveTask(self._inputKeyMapList:ObserveActiveInputKeyMap():Pipe({
30
+ self._maid:GiveTask(InputKeyMapListUtils.observeActiveInputKeyMap(self._inputKeyMapList, self._serviceBag):Pipe({
29
31
  Rx.switchMap(function(activeInputKeyMap)
30
32
  if activeInputKeyMap then
31
33
  return activeInputKeyMap:ObserveInputTypesList()
@@ -1,5 +1,5 @@
1
1
  --[=[
2
- An action that has a score, and may recieve priority from [ScoredActionService]
2
+ An action that has a score, and may recieve priority from [ScoredActionServiceClient]
3
3
 
4
4
  @client
5
5
  @class ScoredAction
@@ -16,7 +16,7 @@ ScoredAction.ClassName = "ScoredAction"
16
16
  ScoredAction.__index = ScoredAction
17
17
 
18
18
  --[=[
19
- Constructs a new ScoredAction. Should not be called directly. See [ScoredActionService.GetScoredAction].
19
+ Constructs a new ScoredAction. Should not be called directly. See [ScoredActionServiceClient.GetScoredAction].
20
20
 
21
21
  @return ScoredAction
22
22
  ]=]
@@ -2,7 +2,7 @@
2
2
  Scores actions and picks the highest rated one every frame.
3
3
 
4
4
  @client
5
- @class ScoredActionService
5
+ @class ScoredActionServiceClient
6
6
  ]=]
7
7
 
8
8
  local require = require(script.Parent.loader).load(script)
@@ -16,16 +16,23 @@ local InputListScoreHelper = require("InputListScoreHelper")
16
16
  local Observable = require("Observable")
17
17
  local InputKeyMapList = require("InputKeyMapList")
18
18
 
19
- local ScoredActionService = {}
19
+ local ScoredActionServiceClient = {}
20
+ ScoredActionServiceClient.ServiceName = "ScoredActionServiceClient"
20
21
 
21
22
  --[=[
22
- Initializes the ScoredActionService. Should be done via [ServiceBag].
23
- @param _serviceBag ServiceBag
23
+ Initializes the ScoredActionServiceClient. Should be done via [ServiceBag].
24
+ @param serviceBag ServiceBag
24
25
  ]=]
25
- function ScoredActionService:Init(_serviceBag)
26
+ function ScoredActionServiceClient:Init(serviceBag)
26
27
  assert(not self._provider, "Already initialize")
27
28
 
28
29
  self._maid = Maid.new()
30
+ self._serviceBag = assert(serviceBag, "No serviceBag")
31
+
32
+ -- External
33
+ self._serviceBag:GetService(require("InputModeServiceClient"))
34
+ self._serviceBag:GetService(require("InputKeyMapServiceClient"))
35
+
29
36
  self._provider = ScoredActionPickerProvider.new()
30
37
  self._maid:GiveTask(self._provider)
31
38
  end
@@ -33,7 +40,7 @@ end
33
40
  --[=[
34
41
  Starts the scored action service. Should be done via [ServiceBag].
35
42
  ]=]
36
- function ScoredActionService:Start()
43
+ function ScoredActionServiceClient:Start()
37
44
  self._maid:GiveTask(RunService.Stepped:Connect(function()
38
45
  -- TODO: Push to end of frame so we don't delay input by a frame?
39
46
  self._provider:Update()
@@ -46,7 +53,7 @@ end
46
53
  @param inputKeyMapList InputKeyMapList
47
54
  @return ScoredAction
48
55
  ]=]
49
- function ScoredActionService:GetScoredAction(inputKeyMapList)
56
+ function ScoredActionServiceClient:GetScoredAction(inputKeyMapList)
50
57
  assert(InputKeyMapList.isInputKeyMapList(inputKeyMapList), "Bad inputKeyMapList")
51
58
  assert(self._provider, "Not initialized")
52
59
 
@@ -55,7 +62,7 @@ function ScoredActionService:GetScoredAction(inputKeyMapList)
55
62
  local maid = Maid.new()
56
63
  maid:GiveTask(scoredAction)
57
64
 
58
- maid:GiveTask(InputListScoreHelper.new(self._provider, scoredAction, inputKeyMapList))
65
+ maid:GiveTask(InputListScoreHelper.new(self._serviceBag, self._provider, scoredAction, inputKeyMapList))
59
66
 
60
67
  -- Couple cleanup to the scored action
61
68
  maid:GiveTask(scoredAction.Removing:Connect(function()
@@ -75,7 +82,7 @@ end
75
82
  @param scoreValue NumberValue
76
83
  @return (source: Observable<InputKeyMapList>) -> Observable<ScoredAction>
77
84
  ]=]
78
- function ScoredActionService:ObserveNewFromInputKeyMapList(scoreValue)
85
+ function ScoredActionServiceClient:ObserveNewFromInputKeyMapList(scoreValue)
79
86
  assert(self._provider, "Not initialized")
80
87
  assert(typeof(scoreValue) == "Instance" and scoreValue:IsA("NumberValue"), "Bad scoreValue")
81
88
 
@@ -113,4 +120,4 @@ function ScoredActionService:ObserveNewFromInputKeyMapList(scoreValue)
113
120
  end
114
121
  end
115
122
 
116
- return ScoredActionService
123
+ return ScoredActionServiceClient
@@ -0,0 +1,18 @@
1
+ --[=[
2
+ @class ScoredActionService
3
+ ]=]
4
+
5
+ local require = require(script.Parent.loader).load(script)
6
+
7
+ local ScoredActionService = {}
8
+ ScoredActionService.ServiceName = "ScoredActionService"
9
+
10
+ function ScoredActionService:Init(serviceBag)
11
+ assert(not self._serviceBag, "Already initialized")
12
+ self._serviceBag = assert(serviceBag, "No serviceBag")
13
+
14
+ -- External
15
+ self._serviceBag:GetService(require("InputKeyMapService"))
16
+ end
17
+
18
+ return ScoredActionService