多轮审查和修复
This commit is contained in:
50
Assets/Scripts/World/DeathShade.cs
Normal file
50
Assets/Scripts/World/DeathShade.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
using BaseGames.Core.Events;
|
||||
|
||||
namespace BaseGames.World
|
||||
{
|
||||
/// <summary>
|
||||
/// 死亡遗骸(Death Shade)。玩家死亡时在死亡地点留下遗骸,
|
||||
/// 再次到达并交互后回收存储的 Geo。
|
||||
/// 实现 <see cref="IInteractable"/> 接口以接入通用交互系统。
|
||||
/// </summary>
|
||||
public class DeathShade : MonoBehaviour, IInteractable
|
||||
{
|
||||
[SerializeField] private IntEventChannelSO _onGeoRecovered;
|
||||
[SerializeField] private StringEventChannelSO _onShadeCollected;
|
||||
|
||||
private int _storedGeo;
|
||||
private string _sceneId;
|
||||
|
||||
// ── IInteractable ────────────────────────────────────────────────
|
||||
public bool CanInteract => true;
|
||||
public string InteractPrompt => "回收遗骸";
|
||||
|
||||
/// <summary>
|
||||
/// 由死亡系统调用:设定存储 Geo 数量、所在场景 ID,并移动到死亡坐标。
|
||||
/// </summary>
|
||||
public void Initialize(int geo, string sceneId, Vector2 position)
|
||||
{
|
||||
_storedGeo = geo;
|
||||
_sceneId = sceneId;
|
||||
transform.position = position;
|
||||
}
|
||||
|
||||
public void OnPlayerEnterRange(Transform player) { }
|
||||
|
||||
public void OnPlayerExitRange() { }
|
||||
|
||||
/// <summary>
|
||||
/// 玩家交互:广播 Geo 回收事件和场景标记,然后销毁自身。
|
||||
/// PlayerStats 订阅 _onGeoRecovered 事件并自行添加 Geo,保持零耦合。
|
||||
/// </summary>
|
||||
public void Interact(Transform player)
|
||||
{
|
||||
if (_storedGeo > 0)
|
||||
_onGeoRecovered?.Raise(_storedGeo);
|
||||
|
||||
_onShadeCollected?.Raise(_sceneId);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user