This commit is contained in:
2026-07-07 03:34:56 +08:00
parent e7891d7e00
commit ecb20cf370
81 changed files with 2108 additions and 293 deletions
+21 -6
View File
@@ -1,6 +1,7 @@
using System;
using UnityEngine;
using GameFramework;
using Architecture.Core;
namespace IndianOceanAssets.Engine2_5D
{
@@ -20,11 +21,8 @@ namespace IndianOceanAssets.Engine2_5D
/// </summary>
public class EchoSystem : MonoBehaviour
{
/// <summary>
/// 按 E 释放回声(摇铃)时触发,参数为释放时的玩家世界位置。
/// 敌人聆听系统等可订阅此事件。
/// </summary>
public static event Action<Vector3> OnEchoReleased;
[Header("SO 事件通道(替代 static OnEchoReleased 事件,参数为释放时玩家世界位置)")]
[SerializeField] private Vector3Event echoReleasedEvent;
[Header("按键")]
[SerializeField] private KeyCode echoKey = KeyCode.E;
@@ -101,6 +99,7 @@ namespace IndianOceanAssets.Engine2_5D
private float _lastEchoTime = -999f;
private float _ringAlpha = 0f;
private float _ringRadius = 0f;
private bool _warnedEcho = false; // 防止 echoReleasedEvent 空引用告警刷屏
private void Start()
{
@@ -219,7 +218,13 @@ namespace IndianOceanAssets.Engine2_5D
}
// 通知订阅者(敌人聆听等)
OnEchoReleased?.Invoke(p);
if (echoReleasedEvent != null)
echoReleasedEvent.Raise(p);
else if (!_warnedEcho)
{
Debug.LogWarning("[EchoSystem] echoReleasedEvent 未接线!敌人不会响应摇铃。请在 EchoSystem 的 Echo Released Event 字段拖入 EchoReleased 资产。", this);
_warnedEcho = true;
}
}
private void UpdateExpanding()
@@ -309,6 +314,16 @@ namespace IndianOceanAssets.Engine2_5D
public bool IsActive => _state != State.Idle;
/// <summary>摇铃冷却剩余/总时长(供 HUD 显示,替代反射读取私有字段)。</summary>
public (float remaining, float total) BellCooldown
=> (Mathf.Max(0f, (_lastEchoTime + cooldown) - Time.time), cooldown);
private void OnValidate()
{
if (echoReleasedEvent == null)
Debug.LogWarning($"[EchoSystem] Echo Released Event 未接线({gameObject.name})。按 E 摇铃时敌人不会响应。", this);
}
// ===== 编辑器可视化 =====
private void OnDrawGizmosSelected()
{