存档完善和修复

This commit is contained in:
2026-05-20 15:10:35 +08:00
parent 84528403ec
commit ec633d9b79
17 changed files with 254 additions and 67 deletions

View File

@@ -10,7 +10,7 @@ namespace BaseGames.Player
/// 玩家数值管理组件。负责 HP、灵魂、灵气、弹簧充能、LingZhu、能力解锁与存档读写。
/// 实现 <see cref="IRewardTarget"/> 供 RewardSO 使用,避免 Quest 程序集直接依赖 Player 程序集。
/// </summary>
public class PlayerStats : MonoBehaviour, ISaveable, BaseGames.Core.IRestoreOnSave, IRewardTarget
public class PlayerStats : MonoBehaviour, ISaveable, BaseGames.Core.IRestoreOnSave, IRewardTarget, BaseGames.Core.ILingZhuProvider
{
[Header("配置")]
[SerializeField] private PlayerStatsSO _config;
@@ -36,6 +36,7 @@ namespace BaseGames.Player
public int MaxSpringCharges { get; private set; }
public int SpringKillPoints { get; private set; }
public int CurrentLingZhu { get; private set; }
private int _lifetimeLingZhu;
public bool IsInvincible => _invincibleTimer > 0f;
public bool IsAlive => CurrentHP > 0;
@@ -277,7 +278,8 @@ namespace BaseGames.Player
public void AddLingZhu(int amount)
{
if (amount <= 0) return;
CurrentLingZhu += amount;
CurrentLingZhu += amount;
_lifetimeLingZhu += amount;
_onLingZhuChanged?.Raise(CurrentLingZhu);
}
@@ -320,6 +322,7 @@ namespace BaseGames.Player
p.CurrentHP = CurrentHP;
p.MaxHP = MaxHP;
p.CurrentLingZhu = CurrentLingZhu;
p.LifetimeLingZhu = _lifetimeLingZhu;
p.AbilityFlags = (uint)_unlockedAbilities;
}
@@ -329,6 +332,7 @@ namespace BaseGames.Player
MaxHP = p.MaxHP;
CurrentHP = Mathf.Clamp(p.CurrentHP, 0, MaxHP);
CurrentLingZhu = p.CurrentLingZhu;
_lifetimeLingZhu = p.LifetimeLingZhu;
_unlockedAbilities = (AbilityType)p.AbilityFlags;
_onHPChanged?.Raise(CurrentHP);