多轮审查和修复

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,67 @@
using System.Collections;
using UnityEngine;
using BaseGames.Core;
using BaseGames.Core.Events;
using BaseGames.Input;
namespace BaseGames.Progression
{
/// <summary>
/// HP 容器拾取物(架构 09_ProgressionModule §14
/// 永久 MaxHP +2 的可拾取物件,拾取后通过事件频道通知 SaveSystem。
/// 利用 SaveManager.Data.World.CollectedIds 防止重复拾取。
/// </summary>
public class HPContainerPickup : MonoBehaviour
{
[SerializeField] private string _collectibleId; // 存档用唯一 ID
[SerializeField] private InputReaderSO _inputReader;
[Header("Event Channels")]
[SerializeField] private StringEventChannelSO _onMaxHPContainerPickedUp; // → SaveSystem
[SerializeField] private IntEventChannelSO _onMaxHPChanged; // → HUDController
private bool _pickedUp;
private void Start()
{
// 若本局已拾取(存档),直接隐藏
if (!string.IsNullOrEmpty(_collectibleId) &&
ServiceLocator.GetOrDefault<ISaveService>()?.IsWorldCollected(_collectibleId) == true)
{
gameObject.SetActive(false);
_pickedUp = true;
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (_pickedUp || !other.CompareTag("Player")) return;
if (!string.IsNullOrEmpty(_collectibleId) &&
ServiceLocator.GetOrDefault<ISaveService>()?.IsWorldCollected(_collectibleId) == true) return;
StartCoroutine(PickupSequence());
}
private IEnumerator PickupSequence()
{
_pickedUp = true;
// 禁用输入(切换到 UI 模式)
_inputReader?.EnableUIInput();
gameObject.SetActive(false);
// 等待特效播放Feel MMF_Player 可通过外部引用补充)
yield return new WaitForSeconds(0.8f);
// 零耦合:通过事件频道通知 SaveSystemSaveSystem 负责 MaxHP+2 及写入 CollectedIds
_onMaxHPContainerPickedUp?.Raise(_collectibleId);
// 通知 HUD 更新SaveSystem 写入后应重新查询 PlayerStats.MaxHP
_onMaxHPChanged?.Raise((ServiceLocator.GetOrDefault<ISaveService>()?.GetPlayerMaxHP() ?? 0) + 2);
yield return new WaitForSeconds(0.5f);
// 恢复输入
_inputReader?.EnableGameplayInput();
}
}
}