@quenty/gameconfig 12.24.0 → 12.24.1-canary.545.2374fb2.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 +11 -0
- package/package.json +27 -27
- package/src/Client/Cmdr/GameConfigCommandServiceClient.lua +2 -1
- package/src/Client/Config/Asset/GameConfigAssetClient.lua +14 -3
- package/src/Client/GameConfigBindersClient.lua +2 -2
- package/src/Client/GameConfigServiceClient.lua +3 -2
- package/src/Server/Cmdr/GameConfigCommandService.lua +5 -4
- package/src/Server/Config/Config/GameConfig.lua +1 -1
- package/src/Server/GameConfigBindersServer.lua +2 -2
- package/src/Server/GameConfigService.lua +25 -12
- package/src/Server/Mantle/MantleConfigProvider.lua +4 -3
- package/src/Shared/Cmdr/GameConfigCmdrUtils.lua +7 -4
- package/src/Shared/Config/Asset/GameConfigAssetBase.lua +89 -48
- package/src/Shared/Config/Asset/GameConfigAssetUtils.lua +8 -2
- package/src/Shared/Config/AssetTypes/GameConfigAssetTypeUtils.lua +1 -1
- package/src/Shared/Config/AssetTypes/GameConfigAssetTypes.lua +38 -17
- package/src/Shared/Config/Config/GameConfigBase.lua +86 -37
- package/src/Shared/Config/Config/GameConfigUtils.lua +9 -4
- package/src/Shared/Config/Picker/GameConfigPicker.lua +129 -69
- package/src/Shared/GameConfigDataService.lua +3 -1
- package/test/scripts/Client/ClientMain.client.lua +1 -1
- package/test/scripts/Server/ServerMain.server.lua +1 -1
|
@@ -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:
|
|
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
|
|
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
|
-
:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
181
|
-
table.insert(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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(
|
|
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
|
-
:
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
64
|
+
local gameConfig = brio:GetValue()
|
|
65
|
+
local maid = brio:ToMaid()
|
|
45
66
|
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
```
|
|
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
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
177
|
-
for _, gameConfigAsset in
|
|
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
|
|
229
|
+
@return Promise<number>
|
|
191
230
|
]=]
|
|
192
|
-
function GameConfigPicker
|
|
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
|
|
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
|
|
235
|
-
for _, gameConfigAsset in
|
|
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
|
|
296
|
+
function GameConfigPicker.GetAllActiveAssetsOfType(
|
|
297
|
+
self: GameConfigPicker,
|
|
298
|
+
assetType: _GameConfigAssetTypes.GameConfigAssetType
|
|
299
|
+
)
|
|
250
300
|
local assetList = {}
|
|
251
|
-
for _, gameConfig in
|
|
252
|
-
for _, gameConfigAsset in
|
|
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
|
|
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
|
|
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
|
|
329
|
+
@return number?
|
|
277
330
|
]=]
|
|
278
|
-
function GameConfigPicker
|
|
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
|
|
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
|
|