// // /*=============================================================================== // // Copyright (C) 2024 PhantomsXR Ltd. All Rights Reserved. // // // // This file is part of the Miscellaneous Files. // // // // The Nin1 cannot be copied, distributed, or made available to // // third-parties for commercial purposes without written permission of PhantomsXR Ltd. // // // // Contact nswell@phantomsxr.com for licensing requests. // // ===============================================================================*/ using System.Collections.Generic; using System.Threading.Tasks; using Unity.Services.CloudSave; using Unity.Services.CloudSave.Models; using Unity.Services.CloudSave.Models.Data.Player; using DeleteOptions = Unity.Services.CloudSave.Models.Data.Player.DeleteOptions; namespace Phantom.XRMOD.GameServices.Runtime { public class UnityCloudSavePlayerDataGameDataProvider : ICloudSaveGameData, ICloudSaveGameDataQuery, IDeleteData { /// /// Batch save player data /// /// Data to store /// The operation completed public async Task SavePlayerData(Dictionary _gameData) { await CloudSaveService.Instance.Data.Player.SaveAsync(_gameData); return true; } /// /// Batch load the player data /// /// The batch loading data keys /// The loaded data dict public async Task> LoadPlayerData(HashSet _keys) { return await CloudSaveService.Instance.Data.Player.LoadAsync(_keys); } /// /// Delete the player data /// /// The deleting player data key public async void DeletePlayerData(string _key) { await CloudSaveService.Instance.Data.Player.DeleteAsync(_key, new DeleteOptions()); } /// /// Query the player data /// /// The Query options /// The query data public async Task> QueryPlayerData(Query _options) { return await CloudSaveService.Instance.Data.Player.QueryAsync(_options, new QueryOptions()); } /// /// Save the player file /// /// The saving file name /// The file data bytes /// The operation completed public async Task SavePlayerFile(string _fileName, byte[] _fileBytes) { await CloudSaveService.Instance.Files.Player.SaveAsync(_fileName, _fileBytes); return true; } /// /// Delete the player file /// /// The file name to delete /// The operation completed public async Task DeletePlayerFile(string _fileName) { await CloudSaveService.Instance.Files.Player.DeleteAsync(_fileName); return true; } /// /// Get the player file /// /// The file name to query /// The file bytes public async Task GetPlayerFileAsByteArray(string _fileName) { return await CloudSaveService.Instance.Files.Player.LoadBytesAsync(_fileName); } } }