多轮审查和修复

This commit is contained in:
2026-05-12 15:34:08 +08:00
parent f55d2a57c3
commit ebbbb7332e
805 changed files with 838724 additions and 1905 deletions

View File

@@ -0,0 +1,25 @@
using UnityEngine;
using BaseGames.Core;
namespace BaseGames.Core.Save
{
/// <summary>
/// 带自动注册/注销的 ISaveable MonoBehaviour 基类。
/// 继承此类可消除每个存档对象手动调用 ServiceLocator.GetOrDefault&lt;SaveManager&gt;()?.Register/Unregister 的样板代码。
///
/// 生命周期:
/// OnEnable → ServiceLocator.GetOrDefault&lt;SaveManager&gt;()?.Register(this)
/// OnDisable → ServiceLocator.GetOrDefault&lt;SaveManager&gt;()?.Unregister(this)
///
/// 子类只需实现 <see cref="OnSave"/> 和 <see cref="OnLoad"/>。
/// 若子类需要自定义 OnEnable/OnDisable请先调用 base.OnEnable() / base.OnDisable()。
/// </summary>
public abstract class SaveableMonoBehaviour : MonoBehaviour, ISaveable
{
protected virtual void OnEnable() => ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Register(this);
protected virtual void OnDisable() => ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Unregister(this);
public abstract void OnSave(SaveData saveData);
public abstract void OnLoad(SaveData saveData);
}
}