@quenty/gameconfig 12.24.0 → 12.24.2-canary.547.11ae689.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.
@@ -15,18 +15,44 @@ local Rx = require("Rx")
15
15
  local RxBinderUtils = require("RxBinderUtils")
16
16
  local RxBrioUtils = require("RxBrioUtils")
17
17
  local RxInstanceUtils = require("RxInstanceUtils")
18
+ local _GameConfigAssetBase = require("GameConfigAssetBase")
19
+ local _Observable = require("Observable")
20
+ local _Brio = require("Brio")
18
21
 
19
22
  local GameConfigBase = setmetatable({}, BaseObject)
20
23
  GameConfigBase.ClassName = "GameConfigBase"
21
24
  GameConfigBase.__index = GameConfigBase
22
25
 
26
+ type GameConfigAssetType = GameConfigAssetTypes.GameConfigAssetType
27
+ type ObservableMapSet<K, V> = ObservableMapSet.ObservableMapSet<K, V>
28
+ type GameConfigAssetBase = _GameConfigAssetBase.GameConfigAssetBase
29
+
30
+ export type GameConfigBase = typeof(setmetatable(
31
+ {} :: {
32
+ _obj: Folder,
33
+ _setupObservation: boolean,
34
+ _gameConfigBindersServer: any,
35
+ _gameId: AttributeValue.AttributeValue<number>,
36
+ _assetTypeToAssetConfig: any,
37
+ _assetTypeToAssetKeyMappings: {
38
+ [GameConfigAssetType]: any,
39
+ },
40
+ _assetTypeToAssetIdMappings: {
41
+ [GameConfigAssetType]: any,
42
+ },
43
+ _assetKeyToAssetConfig: any,
44
+ _assetIdToAssetConfig: any,
45
+ },
46
+ { __index = GameConfigBase}
47
+ ))
48
+
23
49
  --[=[
24
50
  Constructs a new game config.
25
51
  @param folder
26
52
  @return GameConfigBase
27
53
  ]=]
28
- function GameConfigBase.new(folder: Instance)
29
- local self = setmetatable(BaseObject.new(folder), GameConfigBase)
54
+ function GameConfigBase.new(folder: Folder): GameConfigBase
55
+ local self = setmetatable(BaseObject.new(folder) :: any, GameConfigBase)
30
56
 
31
57
  self._gameId = AttributeValue.new(self._obj, GameConfigConstants.GAME_ID_ATTRIBUTE, game.GameId)
32
58
 
@@ -39,25 +65,28 @@ function GameConfigBase.new(folder: Instance)
39
65
  self._assetTypeToAssetIdMappings = {}
40
66
 
41
67
  -- Setup assetType mappings to key mapping observations
42
- for _, assetType in pairs(GameConfigAssetTypes) do
68
+ for _, assetType in GameConfigAssetTypes do
43
69
  self._assetTypeToAssetKeyMappings[assetType] = ObservableMapSet.new()
44
70
  self._maid:GiveTask(self._assetTypeToAssetKeyMappings[assetType])
45
71
 
46
72
  self._assetTypeToAssetIdMappings[assetType] = ObservableMapSet.new()
47
73
  self._maid:GiveTask(self._assetTypeToAssetIdMappings[assetType])
48
74
 
49
- self._maid:GiveTask(self._assetTypeToAssetConfig:ObserveItemsForKeyBrio(assetType)
50
- :Subscribe(function(brio)
51
- if brio:IsDead() then
52
- return
53
- end
54
-
55
- local gameAssetConfig = brio:GetValue()
56
- local maid = brio:ToMaid()
57
-
58
- maid:GiveTask(self._assetTypeToAssetKeyMappings[assetType]:Push(gameAssetConfig:ObserveAssetKey(), gameAssetConfig))
59
- maid:GiveTask(self._assetTypeToAssetIdMappings[assetType]:Push(gameAssetConfig:ObserveAssetId(), gameAssetConfig))
60
- end))
75
+ self._maid:GiveTask(self._assetTypeToAssetConfig:ObserveItemsForKeyBrio(assetType):Subscribe(function(brio)
76
+ if brio:IsDead() then
77
+ return
78
+ end
79
+
80
+ local gameAssetConfig = brio:GetValue()
81
+ local maid = brio:ToMaid()
82
+
83
+ maid:GiveTask(
84
+ self._assetTypeToAssetKeyMappings[assetType]:Push(gameAssetConfig:ObserveAssetKey(), gameAssetConfig)
85
+ )
86
+ maid:GiveTask(
87
+ self._assetTypeToAssetIdMappings[assetType]:Push(gameAssetConfig:ObserveAssetId(), gameAssetConfig)
88
+ )
89
+ end))
61
90
  end
62
91
 
63
92
  return self
@@ -67,7 +96,7 @@ end
67
96
  Gets the current folder
68
97
  @return Instance
69
98
  ]=]
70
- function GameConfigBase:GetFolder()
99
+ function GameConfigBase.GetFolder(self: GameConfigBase): Folder
71
100
  return self._obj
72
101
  end
73
102
 
@@ -75,7 +104,7 @@ end
75
104
  Returns an array of all the assets of that type underneath this config
76
105
  @return { GameConfigAssetBase }
77
106
  ]=]
78
- function GameConfigBase:GetAssetsOfType(assetType: string)
107
+ function GameConfigBase.GetAssetsOfType(self: GameConfigBase, assetType: GameConfigAssetType): { GameConfigAssetBase }
79
108
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
80
109
 
81
110
  return self._assetTypeToAssetConfig:GetListForKey(assetType)
@@ -87,7 +116,7 @@ end
87
116
  @param assetKey
88
117
  @return { GameConfigAssetBase }
89
118
  ]=]
90
- function GameConfigBase:GetAssetsOfTypeAndKey(assetType: string, assetKey: string)
119
+ function GameConfigBase.GetAssetsOfTypeAndKey(self: GameConfigBase, assetType: GameConfigAssetType, assetKey: string)
91
120
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
92
121
  assert(type(assetKey) == "string", "Bad assetKey")
93
122
 
@@ -100,7 +129,7 @@ end
100
129
  @param assetId
101
130
  @return { GameConfigAssetBase }
102
131
  ]=]
103
- function GameConfigBase:GetAssetsOfTypeAndId(assetType: string, assetId: number)
132
+ function GameConfigBase.GetAssetsOfTypeAndId(self: GameConfigBase, assetType: GameConfigAssetType, assetId: number)
104
133
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
105
134
  assert(type(assetId) == "number", "Bad assetId")
106
135
 
@@ -113,7 +142,11 @@ end
113
142
  @param assetKey
114
143
  @return Observable<Brio<GameConfigAssetBase>>
115
144
  ]=]
116
- function GameConfigBase:ObserveAssetByTypeAndKeyBrio(assetType: string, assetKey: string)
145
+ function GameConfigBase.ObserveAssetByTypeAndKeyBrio(
146
+ self: GameConfigBase,
147
+ assetType: GameConfigAssetType,
148
+ assetKey: string
149
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
117
150
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
118
151
  assert(type(assetKey) == "string", "Bad assetKey")
119
152
 
@@ -126,7 +159,11 @@ end
126
159
  @param assetId
127
160
  @return Observable<Brio<GameConfigAssetBase>>
128
161
  ]=]
129
- function GameConfigBase:ObserveAssetByTypeAndIdBrio(assetType: string, assetId: number)
162
+ function GameConfigBase.ObserveAssetByTypeAndIdBrio(
163
+ self: GameConfigBase,
164
+ assetType: GameConfigAssetType,
165
+ assetId: number
166
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
130
167
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
131
168
  assert(type(assetId) == "number", "Bad assetId")
132
169
 
@@ -138,7 +175,10 @@ end
138
175
  @param assetId
139
176
  @return Observable<Brio<GameConfigAssetBase>>
140
177
  ]=]
141
- function GameConfigBase:ObserveAssetByIdBrio(assetId: number)
178
+ function GameConfigBase.ObserveAssetByIdBrio(
179
+ self: GameConfigBase,
180
+ assetId: number
181
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
142
182
  assert(type(assetId) == "number", "Bad assetId")
143
183
 
144
184
  return self._assetIdToAssetConfig:ObserveItemsForKeyBrio(assetId)
@@ -149,7 +189,10 @@ end
149
189
  @param assetKey
150
190
  @return Observable<Brio<GameConfigAssetBase>>
151
191
  ]=]
152
- function GameConfigBase:ObserveAssetByKeyBrio(assetKey: string)
192
+ function GameConfigBase.ObserveAssetByKeyBrio(
193
+ self: GameConfigBase,
194
+ assetKey: string
195
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
153
196
  assert(type(assetKey) == "string", "Bad assetKey")
154
197
 
155
198
  return self._assetKeyToAssetConfig:ObserveItemsForKeyBrio(assetKey)
@@ -160,7 +203,10 @@ end
160
203
  @param assetType
161
204
  @return Observable<Brio<GameConfigAssetBase>>
162
205
  ]=]
163
- function GameConfigBase:ObserveAssetByTypeBrio(assetType: string)
206
+ function GameConfigBase.ObserveAssetByTypeBrio(
207
+ self: GameConfigBase,
208
+ assetType: GameConfigAssetType
209
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
164
210
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
165
211
 
166
212
  return self._assetTypeToAssetConfig:ObserveItemsForKeyBrio(assetType)
@@ -169,7 +215,7 @@ end
169
215
  --[=[
170
216
  Initializes the observation. Should be called by the class inheriting this object.
171
217
  ]=]
172
- function GameConfigBase:InitObservation()
218
+ function GameConfigBase.InitObservation(self: GameConfigBase)
173
219
  if self._setupObservation then
174
220
  return
175
221
  end
@@ -177,12 +223,15 @@ function GameConfigBase:InitObservation()
177
223
  self._setupObservation = true
178
224
 
179
225
  local observables = {}
180
- for _, assetType in pairs(GameConfigAssetTypes) do
181
- table.insert(observables, self:_observeAssetFolderBrio(assetType):Pipe({
182
- RxBrioUtils.switchMapBrio(function(folder)
183
- return RxBinderUtils.observeBoundChildClassBrio(self:GetGameConfigAssetBinder(), folder)
184
- end);
185
- }))
226
+ for _, assetType in GameConfigAssetTypes do
227
+ table.insert(
228
+ observables,
229
+ self:_observeAssetFolderBrio(assetType):Pipe({
230
+ RxBrioUtils.switchMapBrio(function(folder)
231
+ return RxBinderUtils.observeBoundChildClassBrio(self:GetGameConfigAssetBinder(), folder)
232
+ end),
233
+ })
234
+ )
186
235
  end
187
236
 
188
237
  -- hook up mapping
@@ -200,7 +249,7 @@ function GameConfigBase:InitObservation()
200
249
  end))
201
250
  end
202
251
 
203
- function GameConfigBase:_observeAssetFolderBrio(assetType)
252
+ function GameConfigBase._observeAssetFolderBrio(self: GameConfigBase, assetType: GameConfigAssetType)
204
253
  return GameConfigUtils.observeAssetFolderBrio(self._obj, assetType)
205
254
  end
206
255
 
@@ -208,7 +257,7 @@ end
208
257
  Returns the game id for this profile.
209
258
  @return Observable<number>
210
259
  ]=]
211
- function GameConfigBase:ObserveGameId()
260
+ function GameConfigBase.ObserveGameId(self: GameConfigBase): _Observable.Observable<number>
212
261
  return self._gameId:Observe()
213
262
  end
214
263
 
@@ -216,7 +265,7 @@ end
216
265
  Returns the game id
217
266
  @return number
218
267
  ]=]
219
- function GameConfigBase:GetGameId()
268
+ function GameConfigBase.GetGameId(self: GameConfigBase): number?
220
269
  return self._gameId.Value
221
270
  end
222
271
 
@@ -224,7 +273,7 @@ end
224
273
  Returns this configuration's name
225
274
  @return string
226
275
  ]=]
227
- function GameConfigBase:GetConfigName()
276
+ function GameConfigBase.GetConfigName(self: GameConfigBase): string
228
277
  return self._obj.Name
229
278
  end
230
279
 
@@ -232,11 +281,11 @@ end
232
281
  Observes this configs name
233
282
  @return Observable<string>
234
283
  ]=]
235
- function GameConfigBase:ObserveConfigName()
284
+ function GameConfigBase.ObserveConfigName(self: GameConfigBase): _Observable.Observable<string>
236
285
  return RxInstanceUtils.observeProperty(self._obj, "Name")
237
286
  end
238
287
 
239
- function GameConfigBase:GetGameConfigAssetBinder()
288
+ function GameConfigBase.GetGameConfigAssetBinder(_self: GameConfigBase)
240
289
  error("Not implemented")
241
290
  end
242
291
 
@@ -10,10 +10,12 @@ local GameConfigAssetTypes = require("GameConfigAssetTypes")
10
10
  local GameConfigAssetTypeUtils = require("GameConfigAssetTypeUtils")
11
11
  local Binder = require("Binder")
12
12
  local RxInstanceUtils = require("RxInstanceUtils")
13
+ local _Observable = require("Observable")
14
+ local _Brio = require("Brio")
13
15
 
14
16
  local GameConfigUtils = {}
15
17
 
16
- function GameConfigUtils.create(binder, gameId)
18
+ function GameConfigUtils.create(binder, gameId: number): Folder
17
19
  assert(Binder.isBinder(binder), "Bad binder")
18
20
  assert(type(gameId) == "number", "Bad gameId")
19
21
 
@@ -22,7 +24,7 @@ function GameConfigUtils.create(binder, gameId)
22
24
 
23
25
  AttributeUtils.initAttribute(config, GameConfigConstants.GAME_ID_ATTRIBUTE, gameId)
24
26
 
25
- for _, assetType in pairs(GameConfigAssetTypes) do
27
+ for _, assetType in GameConfigAssetTypes do
26
28
  GameConfigUtils.getOrCreateAssetFolder(config, assetType)
27
29
  end
28
30
 
@@ -31,7 +33,10 @@ function GameConfigUtils.create(binder, gameId)
31
33
  return config
32
34
  end
33
35
 
34
- function GameConfigUtils.getOrCreateAssetFolder(config, assetType)
36
+ function GameConfigUtils.getOrCreateAssetFolder(
37
+ config: Folder,
38
+ assetType: GameConfigAssetTypes.GameConfigAssetType
39
+ ): Folder
35
40
  assert(typeof(config) == "Instance", "Bad config")
36
41
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
37
42
 
@@ -47,7 +52,7 @@ function GameConfigUtils.getOrCreateAssetFolder(config, assetType)
47
52
  return folder
48
53
  end
49
54
 
50
- function GameConfigUtils.observeAssetFolderBrio(config, assetType)
55
+ function GameConfigUtils.observeAssetFolderBrio(config: Folder, assetType: GameConfigAssetTypes.GameConfigAssetType): _Observable.Observable<_Brio.Brio<Folder>>
51
56
  assert(typeof(config) == "Instance", "Bad config")
52
57
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
53
58
 
@@ -12,11 +12,29 @@ local RxBrioUtils = require("RxBrioUtils")
12
12
  local GameConfigAssetTypeUtils = require("GameConfigAssetTypeUtils")
13
13
  local Promise = require("Promise")
14
14
  local GameConfigAssetUtils = require("GameConfigAssetUtils")
15
+ local _ServiceBag = require("ServiceBag")
16
+ local _GameConfigAssetTypes = require("GameConfigAssetTypes")
17
+ local _Observable = require("Observable")
18
+ local _Brio = require("Brio")
19
+ local _GameConfigAssetBase = require("GameConfigAssetBase")
20
+ local _Promise = require("Promise")
21
+ local _Binder = require("Binder")
22
+ local _Maid = require("Maid")
15
23
 
16
24
  local GameConfigPicker = setmetatable({}, BaseObject)
17
25
  GameConfigPicker.ClassName = "GameConfigPicker"
18
26
  GameConfigPicker.__index = GameConfigPicker
19
27
 
28
+ export type GameConfigPicker = typeof(setmetatable(
29
+ {} :: {
30
+ _serviceBag: _ServiceBag.ServiceBag,
31
+ _maid: _Maid.Maid,
32
+ },
33
+ { __index = GameConfigPicker }
34
+ ))
35
+ type GameConfigAssetType = _GameConfigAssetTypes.GameConfigAssetType
36
+ type GameConfigAssetBase = _GameConfigAssetBase.GameConfigAssetBase
37
+
20
38
  --[=[
21
39
  Constructs a new game config picker. Should be gotten by [GameConfigService].
22
40
 
@@ -25,7 +43,11 @@ GameConfigPicker.__index = GameConfigPicker
25
43
  @param gameConfigAssetBinder Binder<GameConfigAsset>
26
44
  @return GameConfigPicker
27
45
  ]=]
28
- function GameConfigPicker.new(serviceBag, gameConfigBinder, gameConfigAssetBinder)
46
+ function GameConfigPicker.new(
47
+ serviceBag: _ServiceBag.ServiceBag,
48
+ gameConfigBinder,
49
+ gameConfigAssetBinder
50
+ ): GameConfigPicker
29
51
  local self = setmetatable(BaseObject.new(), GameConfigPicker)
30
52
 
31
53
  self._gameConfigBinder = assert(gameConfigBinder, "No gameConfigBinder")
@@ -34,17 +56,16 @@ function GameConfigPicker.new(serviceBag, gameConfigBinder, gameConfigAssetBinde
34
56
 
35
57
  self._gameIdToConfigSet = self._maid:Add(ObservableMapSet.new())
36
58
 
37
- self._maid:GiveTask(RxBinderUtils.observeAllBrio(self._gameConfigBinder)
38
- :Subscribe(function(brio)
39
- if brio:IsDead() then
40
- return
41
- end
59
+ self._maid:GiveTask(RxBinderUtils.observeAllBrio(self._gameConfigBinder):Subscribe(function(brio)
60
+ if brio:IsDead() then
61
+ return
62
+ end
42
63
 
43
- local gameConfig = brio:GetValue()
44
- local maid = brio:ToMaid()
64
+ local gameConfig = brio:GetValue()
65
+ local maid = brio:ToMaid()
45
66
 
46
- maid:GiveTask(self._gameIdToConfigSet:Push(gameConfig:ObserveGameId(), gameConfig))
47
- end))
67
+ maid:GiveTask(self._gameIdToConfigSet:Push(gameConfig:ObserveGameId(), gameConfig))
68
+ end))
48
69
 
49
70
  return self
50
71
  end
@@ -54,21 +75,23 @@ end
54
75
  @param assetType
55
76
  @return Observable<Brio<GameConfigAssetBase>>
56
77
  ]=]
57
- function GameConfigPicker:ObserveActiveAssetOfTypeBrio(assetType: string)
78
+ function GameConfigPicker.ObserveActiveAssetOfTypeBrio(
79
+ self: GameConfigPicker,
80
+ assetType: string
81
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
58
82
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
59
83
 
60
- return self:ObserveActiveConfigsBrio(game.GameId)
61
- :Pipe({
62
- RxBrioUtils.flatMapBrio(function(gameConfig)
63
- return gameConfig:ObserveAssetByTypeBrio(assetType)
64
- end);
65
- })
84
+ return self:ObserveActiveConfigsBrio(game.GameId):Pipe({
85
+ RxBrioUtils.flatMapBrio(function(gameConfig)
86
+ return gameConfig:ObserveAssetByTypeBrio(assetType)
87
+ end),
88
+ })
66
89
  end
67
90
 
68
91
  --[=[
69
92
  Observes all active assets of a type and key.
70
93
 
71
- ```lua
94
+ ```
72
95
  maid:GiveTask(picker:ObserveActiveAssetOfAssetTypeAndKeyBrio(GameConfigAssetType.BADGE, "myBadge")
73
96
  :Pipe({
74
97
  RxStateStackUtils.topOfStack();
@@ -81,15 +104,18 @@ end
81
104
  @param assetKey
82
105
  @return Observable<Brio<GameConfigAssetBase>>
83
106
  ]=]
84
- function GameConfigPicker:ObserveActiveAssetOfAssetTypeAndKeyBrio(assetType: string, assetKey: string)
107
+ function GameConfigPicker.ObserveActiveAssetOfAssetTypeAndKeyBrio(
108
+ self: GameConfigPicker,
109
+ assetType: string,
110
+ assetKey: string
111
+ )
85
112
  assert(type(assetKey) == "string", "Bad assetKey")
86
113
 
87
- return self:ObserveActiveConfigsBrio(game.GameId)
88
- :Pipe({
89
- RxBrioUtils.flatMapBrio(function(gameConfig)
90
- return gameConfig:ObserveAssetByTypeAndKeyBrio(assetType, assetKey)
91
- end);
92
- })
114
+ return self:ObserveActiveConfigsBrio(game.GameId):Pipe({
115
+ RxBrioUtils.flatMapBrio(function(gameConfig)
116
+ return gameConfig:ObserveAssetByTypeAndKeyBrio(assetType, assetKey)
117
+ end),
118
+ })
93
119
  end
94
120
 
95
121
  --[=[
@@ -99,15 +125,18 @@ end
99
125
  @param assetId
100
126
  @return Observable<Brio<GameConfigAssetBase>>
101
127
  ]=]
102
- function GameConfigPicker:ObserveActiveAssetOfAssetTypeAndIdBrio(assetType: string, assetId: number)
128
+ function GameConfigPicker.ObserveActiveAssetOfAssetTypeAndIdBrio(
129
+ self: GameConfigPicker,
130
+ assetType: string,
131
+ assetId: number
132
+ )
103
133
  assert(type(assetId) == "number", "Bad assetId")
104
134
 
105
- return self:ObserveActiveConfigsBrio(game.GameId)
106
- :Pipe({
107
- RxBrioUtils.flatMapBrio(function(gameConfig)
108
- return gameConfig:ObserveAssetByTypeAndIdBrio(assetType, assetId)
109
- end);
110
- })
135
+ return self:ObserveActiveConfigsBrio(game.GameId):Pipe({
136
+ RxBrioUtils.flatMapBrio(function(gameConfig)
137
+ return gameConfig:ObserveAssetByTypeAndIdBrio(assetType, assetId)
138
+ end),
139
+ })
111
140
  end
112
141
 
113
142
  --[=[
@@ -116,15 +145,17 @@ end
116
145
  @param assetId
117
146
  @return Observable<Brio<GameConfigAssetBase>>
118
147
  ]=]
119
- function GameConfigPicker:ObserveActiveAssetOfAssetIdBrio(assetId: number)
148
+ function GameConfigPicker.ObserveActiveAssetOfAssetIdBrio(
149
+ self: GameConfigPicker,
150
+ assetId: number
151
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
120
152
  assert(type(assetId) == "number", "Bad assetId")
121
153
 
122
- return self:ObserveActiveConfigsBrio(game.GameId)
123
- :Pipe({
124
- RxBrioUtils.flatMapBrio(function(gameConfig)
125
- return gameConfig:ObserveAssetByIdBrio(assetId)
126
- end);
127
- })
154
+ return self:ObserveActiveConfigsBrio(game.GameId):Pipe({
155
+ RxBrioUtils.flatMapBrio(function(gameConfig)
156
+ return gameConfig:ObserveAssetByIdBrio(assetId)
157
+ end),
158
+ })
128
159
  end
129
160
 
130
161
  --[=[
@@ -133,15 +164,17 @@ end
133
164
  @param assetKey
134
165
  @return Observable<Brio<GameConfigAssetBase>>
135
166
  ]=]
136
- function GameConfigPicker:ObserveActiveAssetOfKeyBrio(assetKey: string)
167
+ function GameConfigPicker.ObserveActiveAssetOfKeyBrio(
168
+ self: GameConfigPicker,
169
+ assetKey: string
170
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
137
171
  assert(type(assetKey) == "string", "Bad assetKey")
138
172
 
139
- return self:ObserveActiveConfigsBrio(game.GameId)
140
- :Pipe({
141
- RxBrioUtils.flatMapBrio(function(gameConfig)
142
- return gameConfig:ObserveAssetByKeyBrio(assetKey)
143
- end);
144
- })
173
+ return self:ObserveActiveConfigsBrio(game.GameId):Pipe({
174
+ RxBrioUtils.flatMapBrio(function(gameConfig)
175
+ return gameConfig:ObserveAssetByKeyBrio(assetKey)
176
+ end),
177
+ })
145
178
  end
146
179
 
147
180
  --[=[
@@ -149,7 +182,9 @@ end
149
182
 
150
183
  @return Observable<Brio<GameConfigAssetBase>>
151
184
  ]=]
152
- function GameConfigPicker:ObserveActiveConfigsBrio()
185
+ function GameConfigPicker.ObserveActiveConfigsBrio(
186
+ self: GameConfigPicker
187
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
153
188
  return self:_observeConfigsForGameIdBrio(game.GameId)
154
189
  end
155
190
 
@@ -158,7 +193,7 @@ end
158
193
 
159
194
  @return { GameConfigAssetBase }
160
195
  ]=]
161
- function GameConfigPicker:GetActiveConfigs()
196
+ function GameConfigPicker.GetActiveConfigs(self: GameConfigPicker): { GameConfigAssetBase }
162
197
  return self:_getConfigsForGameId(game.GameId)
163
198
  end
164
199
 
@@ -167,14 +202,18 @@ end
167
202
 
168
203
  @param assetType
169
204
  @param assetId
170
- @return GameConfigAssetBase
205
+ @return GameConfigAssetBase?
171
206
  ]=]
172
- function GameConfigPicker:FindFirstActiveAssetOfId(assetType: string, assetId: number)
207
+ function GameConfigPicker.FindFirstActiveAssetOfId(
208
+ self: GameConfigPicker,
209
+ assetType: string,
210
+ assetId: number
211
+ ): GameConfigAssetBase?
173
212
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
174
213
  assert(type(assetId) == "number", "Bad assetId")
175
214
 
176
- for _, gameConfig in pairs(self:GetActiveConfigs()) do
177
- for _, gameConfigAsset in pairs(gameConfig:GetAssetsOfTypeAndId(assetType, assetId)) do
215
+ for _, gameConfig in self:GetActiveConfigs() do
216
+ for _, gameConfigAsset in gameConfig:GetAssetsOfTypeAndId(assetType, assetId) do
178
217
  return gameConfigAsset
179
218
  end
180
219
  end
@@ -187,9 +226,13 @@ end
187
226
 
188
227
  @param assetType string
189
228
  @param assetIdOrKey string | number
190
- @return GameConfigAssetBase
229
+ @return Promise<number>
191
230
  ]=]
192
- function GameConfigPicker:PromisePriceInRobux(assetType, assetIdOrKey)
231
+ function GameConfigPicker.PromisePriceInRobux(
232
+ self: GameConfigPicker,
233
+ assetType: _GameConfigAssetTypes.GameConfigAssetType,
234
+ assetIdOrKey
235
+ ): _Promise.Promise<number>
193
236
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
194
237
  assert(type(assetIdOrKey) == "number" or type(assetIdOrKey) == "string", "Bad assetIdOrKey")
195
238
 
@@ -225,14 +268,18 @@ end
225
268
 
226
269
  @param assetType
227
270
  @param assetKey
228
- @return GameConfigAssetBase
271
+ @return GameConfigAssetBase?
229
272
  ]=]
230
- function GameConfigPicker:FindFirstActiveAssetOfKey(assetType: string, assetKey: string)
273
+ function GameConfigPicker.FindFirstActiveAssetOfKey(
274
+ self: GameConfigPicker,
275
+ assetType: _GameConfigAssetTypes.GameConfigAssetType,
276
+ assetKey: string
277
+ ): GameConfigAssetBase?
231
278
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
232
279
  assert(type(assetKey) == "string", "Bad assetKey")
233
280
 
234
- for _, gameConfig in pairs(self:GetActiveConfigs()) do
235
- for _, gameConfigAsset in pairs(gameConfig:GetAssetsOfTypeAndKey(assetType, assetKey)) do
281
+ for _, gameConfig in self:GetActiveConfigs() do
282
+ for _, gameConfigAsset in gameConfig:GetAssetsOfTypeAndKey(assetType, assetKey) do
236
283
  return gameConfigAsset
237
284
  end
238
285
  end
@@ -246,23 +293,29 @@ end
246
293
  @param assetType
247
294
  @return { GameConfigAssetBase }
248
295
  ]=]
249
- function GameConfigPicker:GetAllActiveAssetsOfType(assetType: string)
296
+ function GameConfigPicker.GetAllActiveAssetsOfType(
297
+ self: GameConfigPicker,
298
+ assetType: _GameConfigAssetTypes.GameConfigAssetType
299
+ )
250
300
  local assetList = {}
251
- for _, gameConfig in pairs(self:GetActiveConfigs()) do
252
- for _, gameConfigAsset in pairs(gameConfig:GetAssetsOfType(assetType)) do
301
+ for _, gameConfig in self:GetActiveConfigs() do
302
+ for _, gameConfigAsset in gameConfig:GetAssetsOfType(assetType) do
253
303
  table.insert(assetList, gameConfigAsset)
254
304
  end
255
305
  end
256
306
  return assetList
257
307
  end
258
308
 
259
- function GameConfigPicker:_observeConfigsForGameIdBrio(gameId: number)
309
+ function GameConfigPicker._observeConfigsForGameIdBrio(
310
+ self: GameConfigPicker,
311
+ gameId: number
312
+ ): _Observable.Observable<_Brio.Brio<GameConfigAssetBase>>
260
313
  assert(type(gameId) == "number", "Bad gameId")
261
314
 
262
315
  return self._gameIdToConfigSet:ObserveItemsForKeyBrio(gameId)
263
316
  end
264
317
 
265
- function GameConfigPicker:_getConfigsForGameId(gameId: number)
318
+ function GameConfigPicker._getConfigsForGameId(self: GameConfigPicker, gameId: number)
266
319
  assert(type(gameId) == "number", "Bad gameId")
267
320
 
268
321
  return self._gameIdToConfigSet:GetListForKey(gameId)
@@ -273,9 +326,13 @@ end
273
326
 
274
327
  @param assetType GameConfigAssetType
275
328
  @param assetIdOrKey number | string
276
- @return number | nil
329
+ @return number?
277
330
  ]=]
278
- function GameConfigPicker:ToAssetId(assetType, assetIdOrKey)
331
+ function GameConfigPicker.ToAssetId(
332
+ self: GameConfigPicker,
333
+ assetType: _GameConfigAssetTypes.GameConfigAssetType,
334
+ assetIdOrKey: string | number
335
+ ): number?
279
336
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
280
337
  assert(type(assetIdOrKey) == "number" or type(assetIdOrKey) == "string", "Bad assetIdOrKey")
281
338
 
@@ -298,7 +355,11 @@ end
298
355
  @param assetIdOrKey number | string
299
356
  @return Observable<Brio<number>>
300
357
  ]=]
301
- function GameConfigPicker:ObserveToAssetIdBrio(assetType, assetIdOrKey)
358
+ function GameConfigPicker.ObserveToAssetIdBrio(
359
+ self: GameConfigPicker,
360
+ assetType: _GameConfigAssetTypes.GameConfigAssetType,
361
+ assetIdOrKey: string | number
362
+ ): _Observable.Observable<_Brio.Brio<number>>
302
363
  assert(GameConfigAssetTypeUtils.isAssetType(assetType), "Bad assetType")
303
364
  assert(type(assetIdOrKey) == "number" or type(assetIdOrKey) == "string", "Bad assetIdOrKey")
304
365
 
@@ -306,7 +367,7 @@ function GameConfigPicker:ObserveToAssetIdBrio(assetType, assetIdOrKey)
306
367
  return self:ObserveActiveAssetOfAssetTypeAndKeyBrio(assetType, assetIdOrKey):Pipe({
307
368
  RxBrioUtils.switchMapBrio(function(asset)
308
369
  return asset:ObserveAssetId()
309
- end);
370
+ end),
310
371
  })
311
372
  elseif type(assetIdOrKey) == "number" then
312
373
  return RxBrioUtils.of(assetIdOrKey)
@@ -315,5 +376,4 @@ function GameConfigPicker:ObserveToAssetIdBrio(assetType, assetIdOrKey)
315
376
  end
316
377
  end
317
378
 
318
-
319
- return GameConfigPicker
379
+ return GameConfigPicker
@@ -4,10 +4,12 @@
4
4
 
5
5
  local require = require(script.Parent.loader).load(script)
6
6
 
7
+ local _ServiceBag = require("ServiceBag")
8
+
7
9
  local GameConfigDataService = {}
8
10
  GameConfigDataService.ServiceName = "GameConfigDataService"
9
11
 
10
- function GameConfigDataService:Init(serviceBag)
12
+ function GameConfigDataService:Init(serviceBag: _ServiceBag.ServiceBag)
11
13
  assert(not self._serviceBag, "Already initialized")
12
14
  self._serviceBag = assert(serviceBag, "No serviceBag")
13
15
 
@@ -9,4 +9,4 @@ local serviceBag = require("ServiceBag").new()
9
9
  serviceBag:GetService(require("GameConfigServiceClient"))
10
10
 
11
11
  serviceBag:Init()
12
- serviceBag:Start()
12
+ serviceBag:Start()