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:
@@ -1,4 +1,4 @@
|
||||
#if GRAPH_DESIGNER
|
||||
#if GRAPH_DESIGNER
|
||||
using UnityEngine;
|
||||
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
||||
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
|
||||
@@ -12,28 +12,40 @@ namespace BaseGames.Enemies.AI
|
||||
/// BD Action:Boss 专用召唤小兵。
|
||||
/// 通过 GlobalObjectPool 在 Boss 周围生成 MinionPrefabKey 对应的敌人。
|
||||
/// </summary>
|
||||
[TaskName("Summon Minions")]
|
||||
[TaskCategory("BaseGames/Enemy/Boss")]
|
||||
[TaskDescription("在指定位置生成小怪预制体(支持延迟和数量配置)")]
|
||||
public class BD_SummonMinions : Action
|
||||
{
|
||||
[Header("召唤配置")]
|
||||
[Tooltip("对象池 Key,对应 PoolRegistry 中注册的小怪预制体。")]
|
||||
[SerializeField] private string m_MinionPrefabKey = "";
|
||||
[Tooltip("单次召唤的小兵数量。")]
|
||||
[Min(1)]
|
||||
[SerializeField] private int m_Count = 2;
|
||||
[Tooltip("小兵生成位置距 Boss 中心的横向散开半径(m)。")]
|
||||
[Min(0.1f)]
|
||||
[SerializeField] private float m_SpawnRadius = 3f;
|
||||
|
||||
// 延迟缓存:首次调用时解析,避免每帧服务定位开销
|
||||
private IObjectPoolService _pool;
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_MinionPrefabKey)) return TaskStatus.Failure;
|
||||
|
||||
var pool = ServiceLocator.GetOrDefault<IObjectPoolService>();
|
||||
if (pool == null) return TaskStatus.Failure;
|
||||
_pool ??= ServiceLocator.GetOrDefault<IObjectPoolService>();
|
||||
if (_pool == null) return TaskStatus.Failure;
|
||||
|
||||
for (int i = 0; i < m_Count; i++)
|
||||
{
|
||||
var angle = Random.Range(0f, 360f) * Mathf.Deg2Rad;
|
||||
var offset = new Vector2(Mathf.Cos(angle), 0f) * m_SpawnRadius;
|
||||
var spawnPos = new Vector3(
|
||||
float angleRad = (i / (float)m_Count) * Mathf.PI * 2f;
|
||||
var offset = new Vector2(Mathf.Cos(angleRad), 0f) * m_SpawnRadius;
|
||||
var spawnPos = new Vector3(
|
||||
transform.position.x + offset.x,
|
||||
transform.position.y + offset.y,
|
||||
transform.position.y,
|
||||
0f);
|
||||
pool.Spawn(m_MinionPrefabKey, spawnPos, Quaternion.identity);
|
||||
_pool.Spawn(m_MinionPrefabKey, spawnPos, Quaternion.identity);
|
||||
}
|
||||
|
||||
return TaskStatus.Success;
|
||||
|
||||
Reference in New Issue
Block a user