Files
zeling_v2/Assets/_Game/Scripts/Enemies/AI/BD_CanReachTarget.cs
Joywayer a1b4e629aa 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.
2026-05-23 19:10:29 +08:00

36 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#if GRAPH_DESIGNER
using UnityEngine;
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Conditionals;
using BaseGames.Enemies;
namespace BaseGames.Enemies.AI
{
/// <summary>
/// 条件:目标坐标从当前位置是否可到达(调用 NavAgent.CanReach无法寻路时 Failure
/// 用于 Boss 阶段切换或小怪决策能否追击到跨平台目标。
/// </summary>
[TaskName("Can Reach Target?")]
[TaskCategory("BaseGames/Enemy/Perception")]
[TaskDescription("检查 NavAgent 是否可以规划到目标的有效路径")]
public sealed class BD_CanReachTarget : Conditional
{
[Tooltip("检查目标(留空则使用玩家位置)")]
[SerializeField] private Transform m_Target;
private EnemyBase _enemy;
public override void OnAwake() => _enemy = gameObject.GetComponent<EnemyBase>();
public override TaskStatus OnUpdate()
{
if (_enemy?.Nav == null) return TaskStatus.Failure;
Vector2 pos = m_Target != null
? (Vector2)m_Target.position
: _enemy.PlayerTransform != null ? (Vector2)_enemy.PlayerTransform.position : Vector2.zero;
return _enemy.Nav.CanReach(pos) ? TaskStatus.Success : TaskStatus.Failure;
}
}
}
#endif