feat: Implement Room Streaming System

- Add RoomStreamingManager to manage room loading and unloading based on player proximity.
- Create StreamingBudgetConfigSO for memory and performance budgeting of the streaming system.
- Introduce TransitionDirector to handle seamless and atmospheric fade transitions between rooms.
- Develop WorldGraph to represent room connectivity and facilitate neighbor queries and distance calculations.
- Implement RoomNode and RoomEdge classes to structure room data and connections.
This commit is contained in:
2026-05-23 19:10:29 +08:00
parent 81c326af53
commit a1b4e629aa
165 changed files with 7904 additions and 313 deletions

View File

@@ -0,0 +1,54 @@
using UnityEngine;
namespace BaseGames.Enemies.Perception
{
/// <summary>
/// 威胁评估器:在原始 LOS 结果上叠加感知反应延迟,使敌人不会瞬间发现玩家。
///
/// 工作原理:
/// <list type="bullet">
/// <item>读取 <see cref="EnemyBase.HasLineOfSight"/>(原始 LOSBatchLOSSystem 写入)。</item>
/// <item>连续感知到玩家超过 <see cref="reactionDelay"/> 秒后,<see cref="IsThreatDetected"/> 才变为 true。</item>
/// <item>一旦丢失 LOS<see cref="IsThreatDetected"/> 立即重置为 false保持对"躲起来"的快速响应)。</item>
/// </list>
///
/// 挂载:添加到与 <see cref="EnemyBase"/> 相同的 GameObject。
/// <see cref="EnemyBase.IsPlayerVisible()"/> 会自动路由至此组件(如果存在)。
/// </summary>
[RequireComponent(typeof(EnemyBase))]
public class EnemyThreatAssessor : MonoBehaviour
{
[Tooltip("持续感知此时长s后判定为威胁模拟敌人的反应时间")]
[SerializeField] [Min(0f)] private float reactionDelay = 0.15f;
private EnemyBase _enemy;
private float _losAccumulator;
/// <summary>是否已将玩家判定为当前威胁(含反应延迟)。</summary>
public bool IsThreatDetected { get; private set; }
private void Awake()
{
_enemy = GetComponent<EnemyBase>();
}
private void Update()
{
if (_enemy == null) return;
bool hasLos = _enemy.HasLineOfSight;
if (hasLos)
{
_losAccumulator += Time.deltaTime;
if (_losAccumulator >= reactionDelay)
IsThreatDetected = true;
}
else
{
_losAccumulator = 0f;
IsThreatDetected = false;
}
}
}
}