2023-08-22 19:08:45 +08:00
|
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
|
|
|
using Gameplay.BT.Variables;
|
2023-12-13 16:20:41 +08:00
|
|
|
using Gameplay.Unit;
|
2024-11-06 14:22:53 +08:00
|
|
|
using Gameplay.AI;
|
|
|
|
|
using Framework;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
namespace Code.Scripts.Gameplay.BT.Task
|
|
|
|
|
{
|
|
|
|
|
public class BTMoveAway : Action
|
|
|
|
|
{
|
|
|
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
|
|
|
private GameUnit _owner;
|
|
|
|
|
|
|
|
|
|
public override void OnStart()
|
|
|
|
|
{
|
2024-10-25 17:58:28 +08:00
|
|
|
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
2024-10-25 17:58:28 +08:00
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
public override TaskStatus OnUpdate()
|
|
|
|
|
{
|
2024-11-04 15:24:11 +08:00
|
|
|
if (_owner != null && SharedBattleInfo.Value.theChosenOneId != Constants.INVALID_UINT_ID && !AIUtils.IsNeedStop(_owner))
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
2024-11-04 15:24:11 +08:00
|
|
|
if (GameUnitManager.instance.infightUnits.Contains(SharedBattleInfo.Value.theChosenOneId))
|
|
|
|
|
{
|
|
|
|
|
var enemy = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.theChosenOneId);
|
|
|
|
|
if (enemy != null && !enemy.statusData.isDead)
|
|
|
|
|
{
|
|
|
|
|
if (_owner.MoveAway(enemy))
|
|
|
|
|
SharedBattleInfo.Value.theChosenOneId = Constants.INVALID_UINT_ID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SharedBattleInfo.Value.theChosenOneId = Constants.INVALID_UINT_ID;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
2024-10-25 17:58:28 +08:00
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
return TaskStatus.Success;
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|