refactor(kv): 整理存档接线并清理迁移冗余实现
This commit is contained in:
@@ -24,7 +24,11 @@ using UnityEngine.Rendering.Universal;
|
||||
|
||||
public class SubBoostrap
|
||||
{
|
||||
internal static game.PlayerDataStorage.PlayerKVRuntimeSelection RuntimeSelection { get; private set; }
|
||||
internal static game.KV.KvRuntimeSelection RuntimeSelection
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public static async Task RegisterServices(GameObject rootCtxGo, IConfig config)
|
||||
{
|
||||
@@ -32,14 +36,8 @@ public class SubBoostrap
|
||||
{
|
||||
throw new ArgumentNullException(nameof(config));
|
||||
}
|
||||
#if AGG
|
||||
const bool aggBuild=true;
|
||||
#else
|
||||
const bool aggBuild=false;
|
||||
#endif
|
||||
var selection=game.PlayerDataStorage.PlayerKVRuntimeSelection.Capture(
|
||||
config.Get<string>("SaveBackend","playfab"),
|
||||
config.Get<string>(GConstant.K_Event_API_URL,game.Account.S101AccountSession.DefaultApiUrl),aggBuild);
|
||||
var selection = game.KV.KvRuntimeSelection.CaptureForBuild(
|
||||
config.Get<string>(GConstant.K_Event_API_URL,CustomServerMgr.DefaultApiUrl));
|
||||
RuntimeSelection=selection;
|
||||
var container = GContext.container;
|
||||
container.RegisterInstance(selection);
|
||||
@@ -106,7 +104,7 @@ public class SubBoostrap
|
||||
}
|
||||
else
|
||||
{
|
||||
rootCtxGo.AddComponent<KVMgr>();
|
||||
rootCtxGo.AddComponent<KvMgr>();
|
||||
}
|
||||
// TODO Replace DataCenter with seprated data class
|
||||
// Create();
|
||||
@@ -382,21 +380,26 @@ public class InternalEditorBoost
|
||||
}
|
||||
private async Task Init()
|
||||
{
|
||||
var selection = GContext.container.Resolve<game.PlayerDataStorage.PlayerKVRuntimeSelection>();
|
||||
var selection = GContext.container.Resolve<game.KV.KvRuntimeSelection>();
|
||||
if (selection == null)
|
||||
{
|
||||
var startupConfig = GContext.container.Resolve<IConfig>();
|
||||
var backend = startupConfig?.Get<string>("SaveBackend", "playfab");
|
||||
if (!string.Equals(backend, "playfab", StringComparison.Ordinal))
|
||||
if (game.KV.KvRuntimeSelection.CompiledBackend != "playfab")
|
||||
{
|
||||
throw new InvalidOperationException("Editor direct scene boot only supports playfab; KV requires RegisterServices.");
|
||||
}
|
||||
// Editor direct scene boot is PF-only; KV and kv-loop must use RegisterServices.
|
||||
selection = game.PlayerDataStorage.PlayerKVRuntimeSelection.Capture("playfab", null, false);
|
||||
selection = game.KV.KvRuntimeSelection.CaptureForBuild(null);
|
||||
GContext.container.RegisterInstance(selection);
|
||||
if (!ReferenceEquals(GContext.container.Resolve<game.PlayerDataStorage.PlayerKVRuntimeSelection>(), selection))
|
||||
if (!ReferenceEquals(GContext.container.Resolve<game.KV.KvRuntimeSelection>(), selection))
|
||||
{
|
||||
throw new InvalidOperationException("Editor backend selection registration failed.");
|
||||
}
|
||||
}
|
||||
if (selection.IsKV)
|
||||
if (selection.IsKV || game.KV.KvRuntimeSelection.CompiledBackend != "playfab")
|
||||
{
|
||||
throw new InvalidOperationException("Editor direct scene boot cannot reuse a KV selection.");
|
||||
}
|
||||
SubBoostrap.RuntimeSelection = selection;
|
||||
var tables = await cfg.Tables.Init(x => { Debug.Log(x); });
|
||||
GContext.container.RegisterInstance(tables);
|
||||
GContext.container.Register<IFaceUIService, FaceUIService>().AsSingleton();
|
||||
@@ -410,7 +413,7 @@ public class InternalEditorBoost
|
||||
|
||||
using (var scope = GContext.container.InjectionScope())
|
||||
{
|
||||
GContext.container.Register<game.PlayerDataStorage.IPlayerSaveStore, game.PlayerDataStorage.PlayFabPlayerSaveStore>().AsSingleton();
|
||||
GContext.container.Register<Core.KV.IPlayerSaveStore, game.PlayerDataStorage.PlayFabSaveStore>().AsSingleton();
|
||||
// IAdsService 在 AfterAssetUpdate 中手动注册并调用 Init(),此处不再重复注册
|
||||
GContext.container.Register<PlayerFishData>().AsSingleton();
|
||||
GContext.container.Register<PlayerItemData>().AsSingleton();
|
||||
|
||||
Reference in New Issue
Block a user