refactor(kv): 整理存档接线并清理迁移冗余实现

This commit is contained in:
Liubing\LB
2026-10-13 20:38:41 +08:00
parent 144e7f739f
commit edb8a056c7
166 changed files with 3828 additions and 13267 deletions

View File

@@ -7,7 +7,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
using game.PlayerDataStorage;
public class PlayFabMgr : MonoBehaviour
{
@@ -43,7 +42,6 @@ public class PlayFabMgr : MonoBehaviour
public Dictionary<string, string> CompareDatas(Dictionary<string, UserDataRecord> remoteDatas, string userId)
{
PlayerKVGameLoadGuard.RequireLegacyAllowed(PlayerKVGuardPoint.Compare);
Last_Update_Time_Key = $"{Last_Update_Time_Key_Prefix}_{userId}";
Local_Data_Key = $"{Local_Data_Key_prefix}_{userId}";
var lastUpdateTimeStr = PlayerPrefs.GetString(Last_Update_Time_Key, string.Empty);
@@ -117,7 +115,6 @@ public class PlayFabMgr : MonoBehaviour
void Awake()
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
_instance = this;
InitBuffer();
tokenSource = new CancellationTokenSource();
@@ -136,7 +133,6 @@ public class PlayFabMgr : MonoBehaviour
void OnApplicationPause(bool is_pause)
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
if (is_pause)
{
tokenSource.Cancel();
@@ -152,7 +148,6 @@ public class PlayFabMgr : MonoBehaviour
void OnApplicationQuit()
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
tokenSource.Cancel();
tokenSource = null;
SyncData();
@@ -160,16 +155,14 @@ public class PlayFabMgr : MonoBehaviour
void OnDestroy()
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
tokenSource?.Cancel();
tokenSource = null;
if(!PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.PrefsSave)) PlayerPrefs.Save();
PlayerPrefs.Save();
SyncData();
}
private async void UpdateUserDataValue(CancellationToken token)
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
try
{
while (!token.IsCancellationRequested)
@@ -183,7 +176,6 @@ public class PlayFabMgr : MonoBehaviour
public void UpdateUserDataValue(string key, string data, bool remoteStore = true)
{
PlayerKVGameLoadGuard.RequireLegacyAllowed(PlayerKVGuardPoint.Update);
if (remoteStore)
{
var cbuff = dataBuffer.First;
@@ -213,7 +205,6 @@ public class PlayFabMgr : MonoBehaviour
/// <returns></returns>
public string GetLocalData(string key)
{
PlayerKVGameLoadGuard.RequireLegacyAllowed(PlayerKVGuardPoint.ReadLocal);
if (localData.ContainsKey(key))
{
return localData[key];
@@ -226,7 +217,6 @@ public class PlayFabMgr : MonoBehaviour
private void SyncData()
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Sync)) return;
// Logout clears credentials before RootCtx is destroyed. Keep pending data local.
if (!PlayFabClientAPI.IsClientLoggedIn()) return;
var buf = dataBuffer.First;
@@ -282,7 +272,6 @@ public class PlayFabMgr : MonoBehaviour
public async Task<bool> SyncDataImmidiate(string key, string data)
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Immediate)) return false;
foreach (var buff in dataBuffer)
{
if (buff.ContainsKey(key))