AdditionalDataService
All actions and storage of additional data are controlled by this class.
- Subscribe to an event
*You should subscribe to events in “OnEnable” and unsubscribe in “OnDisable” methods.
AdditionalDataService.DataRequested += OnAllDataRequested;
AdditionalDataService.DataUpdated += OnAllDataUpdated;
. . .
DataRequested – all data requested (UserInventory, TitleData, UserReadOnlyData, SkinCatalogItems).
DataUpdated – all data is ready to use.
AllDataRequestError – error while requesting all data.
TitleDataReceived – data “TitleData” received.
TitleDataUpdated – “TitleData” data is ready to be used.
UserReadOnlyDataReceived – “UserReadOnlyData” data received.
UserReadOnlyDataUpdated – “UserReadOnlyData” data is ready to be used.
SkinCatalogReceived – skin catalog data received.
SkinCatalogUpdated – skin catalog data is ready to use.
UserInventoryReceived – User inventory data received. Further, the data is processed in the “UserInventory” class.
SavedGameplayDataUpdated – Additional gameplay data has been updated.
- Skin Data
List<SkinCatalogItem> skinCatalog = new(AdditionalDataService.AllSkinsInCatalog);
List<BigInteger> nftIDs = new(AdditionalDataService.NFTIDs);
List<string> equippedSkins = new(AdditionalDataService.EquippedSkins);
*Arrays are assigned via the new(. . .) operator, because arrays are “IReadOnlyList”.
AllSkinsInCatalog (List<SkinCatalogItem>) – an array with information about all skins in the catalog.
NFTIDs (List<BigInteger>) – array with information about all NFT identifiers.
EquippedSkins (List<string>) – array with identifiers of all skins equipped by the player.
- Methods
AdditionalDataService.RequestAllData();
AdditionalDataService.RequestUserInventory();
AdditionalDataService.GetTitleData("wallet");
or
AdditionalDataService.GetTitleData(TitleDataKey.wallet);
AdditionalDataService.GetUserReadOnlyData(UserReadOnlyDataKey.saved_gameplay_data);
or
AdditionalDataService.GetUserReadOnlyData("saved_gameplay_data");
. . .
RequestAllData – get all data at once. (UserInventory, TitleData, UserReadOnlyData, SkinCatalogItems) Below is an example to get all the data.
RequestUserInventory – request the player’s inventory.
RequestTitleData – request “TitleData” of the project.
RequestUserReadOnlyData – request “UserReadOnlyData” of the user.
RequestSkinCatalogItems – request a catalog of project skins.
GetTitleData – You can get “TitleData” via string or enum both above.
GetUserReadOnlyData – You can get “UserReadOnlyData” via string or enum.
GetSkinItem – returns a “SkinCatalogItem” instance that contains all the necessary information about the skin from the catalog by ID.
IsSkinEquipped – returns whether the skin is equipped or not by ID.
GetSkinRarityByCollection – returns an enum of skin rarity by collection.
GetSkinProfitByCollection – returns skin profit by collection.
UpdateEquippedSkins – update equipped skins by passing an array of identifiers.
UpdateSavedGameplayData – update game play data by passing json string.
ValidateVIPSubscription – allows you to verify your VIP subscription. If you do not pass a receipt in the argument, then the database will look for the user’s last subscription and verify it.
*On the stage, as indicated in the demo scene, there must be an “InitialDataLoader” script, it loads all the necessary data in the “Start” method.
