2024-07-22 14:46:20 +08:00
|
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
|
|
|
using Gameplay.BT.Variables;
|
|
|
|
|
using Gameplay.Unit;
|
2024-12-20 19:56:53 +08:00
|
|
|
using Gameplay.AI;
|
|
|
|
|
using Framework;
|
2024-07-22 14:46:20 +08:00
|
|
|
|
|
|
|
|
public class BTEventMoveTo : Action
|
|
|
|
|
{
|
|
|
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
|
|
|
|
|
|
|
|
private GameUnit _owner;
|
|
|
|
|
private GameUnit _target;
|
|
|
|
|
|
|
|
|
|
public override void OnStart()
|
|
|
|
|
{
|
2025-02-19 13:44:13 +08:00
|
|
|
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerID);
|
2024-07-22 14:46:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override TaskStatus OnUpdate()
|
|
|
|
|
{
|
2024-12-20 19:56:53 +08:00
|
|
|
if (_owner == null) return TaskStatus.Failure;
|
2025-03-11 13:41:53 +08:00
|
|
|
|
2025-02-19 13:44:13 +08:00
|
|
|
if (SharedBattleInfo.Value.targetID != Constants.INVALID_UINT_ID && !AIUtils.IsNeedStop(_owner))
|
2024-07-22 14:46:20 +08:00
|
|
|
{
|
|
|
|
|
{
|
2025-02-19 13:44:13 +08:00
|
|
|
if (GameUnitManager.instance.infightUnits.Contains(SharedBattleInfo.Value.targetID))
|
2024-07-23 14:00:45 +08:00
|
|
|
{
|
2025-02-19 13:44:13 +08:00
|
|
|
var target = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.targetID);
|
2024-07-23 14:00:45 +08:00
|
|
|
if (target != null)
|
2024-10-21 15:44:25 +08:00
|
|
|
AIUtils.CheckAndMove(_owner, target.transData.cellIndex);
|
2024-07-23 14:00:45 +08:00
|
|
|
}
|
2024-07-22 14:46:20 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-07-23 14:00:45 +08:00
|
|
|
|
2024-07-22 14:46:20 +08:00
|
|
|
return TaskStatus.Failure;
|
|
|
|
|
}
|
|
|
|
|
}
|