- 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.
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
#if GRAPH_DESIGNER
|
||
using UnityEngine;
|
||
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
||
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
|
||
using BaseGames.Core;
|
||
using BaseGames.Core.Pool;
|
||
using BaseGames.Enemies;
|
||
|
||
namespace BaseGames.Enemies.AI
|
||
{
|
||
/// <summary>
|
||
/// 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;
|
||
|
||
_pool ??= ServiceLocator.GetOrDefault<IObjectPoolService>();
|
||
if (_pool == null) return TaskStatus.Failure;
|
||
|
||
for (int i = 0; i < m_Count; i++)
|
||
{
|
||
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,
|
||
0f);
|
||
_pool.Spawn(m_MinionPrefabKey, spawnPos, Quaternion.identity);
|
||
}
|
||
|
||
return TaskStatus.Success;
|
||
}
|
||
}
|
||
}
|
||
#endif
|