- 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.
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
#if GRAPH_DESIGNER
|
||
using UnityEngine;
|
||
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
||
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
|
||
using BaseGames.Enemies.Abilities;
|
||
|
||
namespace BaseGames.Enemies.AI
|
||
{
|
||
/// <summary>
|
||
/// 通用:触发能力。OnStart 调用 ability.Execute(),OnUpdate 等待结束。
|
||
/// 失败条件:能力不存在、能力 CanUse=false 或 Execute 返回 false。
|
||
/// </summary>
|
||
[TaskName("Use Ability")]
|
||
[TaskCategory("BaseGames/Enemy/Combat")]
|
||
[TaskDescription("触发指定能力(拖拽 EnemyAbilitySO 或填写 ID),等待执行结束")]
|
||
public sealed class BD_UseAbility : Action
|
||
{
|
||
[Tooltip("可直接拖拽 EnemyAbilitySO 资产(推荐),或填写裸字符串 ID 作为兜底")]
|
||
[SerializeField] private EnemyAbilitySO m_AbilitySO;
|
||
[SerializeField] private string m_AbilityId = "";
|
||
|
||
private EnemyBase _enemy;
|
||
private EnemyAbilityBase _ability;
|
||
private bool _startedSuccessfully;
|
||
|
||
public override void OnAwake()
|
||
{
|
||
_enemy = gameObject.GetComponent<EnemyBase>();
|
||
}
|
||
|
||
public override void OnStart()
|
||
{
|
||
_startedSuccessfully = false;
|
||
if (_enemy == null) return;
|
||
|
||
// SO 拖拽优先;裸字符串兜底
|
||
string id = m_AbilitySO != null ? m_AbilitySO.abilityId : m_AbilityId;
|
||
if (string.IsNullOrEmpty(id)) return;
|
||
|
||
_ability = _enemy.Abilities.Get(id);
|
||
if (_ability == null) return;
|
||
_startedSuccessfully = _ability.Execute();
|
||
}
|
||
|
||
public override TaskStatus OnUpdate()
|
||
{
|
||
if (!_startedSuccessfully || _ability == null) return TaskStatus.Failure;
|
||
return _ability.IsRunning ? TaskStatus.Running : TaskStatus.Success;
|
||
}
|
||
|
||
public override void OnEnd()
|
||
{
|
||
_ability = null;
|
||
_startedSuccessfully = false;
|
||
}
|
||
}
|
||
}
|
||
#endif
|