test(upserver): 归档存档迁移与玩法闭环回归工具

This commit is contained in:
Liubing\LB
2026-09-28 18:16:14 +08:00
parent c4ae02def9
commit a6f5e107f8
232 changed files with 12903 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
--- Client/Assets/Scripts/Core/PlayFabMgr.cs (reviewed baseline)
+++ Client/Assets/Scripts/Core/PlayFabMgr.cs
@@ -45,6 +45,9 @@
public Dictionary<string, string> CompareDatas(Dictionary<string, UserDataRecord> remoteDatas, string userId)
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) throw PlayerKVGameplayLoop.Stop("PF archive comparison is disabled in KV loop.");
+#endif
PlayerKVGameLoadGuard.RequireLegacyAllowed(PlayerKVGuardPoint.Compare);
Last_Update_Time_Key = $"{Last_Update_Time_Key_Prefix}_{userId}";
Local_Data_Key = $"{Local_Data_Key_prefix}_{userId}";
@@ -121,11 +124,24 @@
{
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
_instance = this;
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) return;
+#endif
InitBuffer();
tokenSource = new CancellationTokenSource();
UpdateUserDataValue(tokenSource.Token);
}
+#if UNITY_EDITOR && !SERVICE_HOST
+ internal void StartKVGameplayLoopSync()
+ {
+ if(!PlayerKVGameplayLoop.Ready || tokenSource!=null) return;
+ tokenSource=new CancellationTokenSource();
+ UpdateUserDataValue(tokenSource.Token);
+ }
+ internal void StopKVGameplayLoopSync()
+ { tokenSource?.Cancel(); tokenSource?.Dispose(); tokenSource=null; }
+#endif
void InitBuffer()
{
dataBuffer = new LinkedList<Dictionary<string, string>>();
@@ -138,6 +154,14 @@
void OnApplicationPause(bool is_pause)
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled)
+ {
+ if(is_pause) { StopKVGameplayLoopSync(); _=PlayerKVGameplayLoop.FlushObservedAsync(); }
+ else StartKVGameplayLoopSync();
+ return;
+ }
+#endif
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
if (is_pause)
{
@@ -154,6 +178,9 @@
void OnApplicationQuit()
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) { StopKVGameplayLoopSync(); _=PlayerKVGameplayLoop.CloseAsync(); return; }
+#endif
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
tokenSource.Cancel();
tokenSource = null;
@@ -162,6 +189,9 @@
void OnDestroy()
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) { StopKVGameplayLoopSync(); _=PlayerKVGameplayLoop.CloseAsync(); return; }
+#endif
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Lifecycle)) return;
tokenSource?.Cancel();
tokenSource = null;
@@ -185,6 +215,9 @@
public void UpdateUserDataValue(string key, string data, bool remoteStore = true)
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) { PlayerKVGameplayLoop.Write(key,data,remoteStore); return; }
+#endif
PlayerKVGameLoadGuard.RequireLegacyAllowed(PlayerKVGuardPoint.Update);
if (remoteStore)
{
@@ -215,6 +248,9 @@
/// <returns></returns>
public string GetLocalData(string key)
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) return PlayerKVGameplayLoop.Read(key);
+#endif
PlayerKVGameLoadGuard.RequireLegacyAllowed(PlayerKVGuardPoint.ReadLocal);
if (localData.ContainsKey(key))
{
@@ -228,6 +264,9 @@
private void SyncData()
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) { _=PlayerKVGameplayLoop.FlushObservedAsync(); return; }
+#endif
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Sync)) return;
// Logout clears credentials before RootCtx is destroyed. Keep pending data local.
if (!PlayFabClientAPI.IsClientLoggedIn()) return;
@@ -283,6 +322,9 @@
public async Task<bool> SyncDataImmidiate(string key, string data)
{
+#if UNITY_EDITOR && !SERVICE_HOST
+ if(PlayerKVGameplayLoop.Enabled) throw PlayerKVGameplayLoop.Stop("Immediate/consuming saves are outside the equipment loop.");
+#endif
if(PlayerKVGameLoadGuard.Reject(PlayerKVGuardPoint.Immediate)) return false;
foreach (var buff in dataBuffer)
{