2023-08-22 19:08:45 +08:00
|
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
|
|
|
using Framework;
|
2023-10-19 15:00:19 +08:00
|
|
|
using Gameplay.AI;
|
2023-08-22 19:08:45 +08:00
|
|
|
using Gameplay.BT.Variables;
|
|
|
|
|
using Gameplay.Common;
|
2023-12-13 16:20:41 +08:00
|
|
|
using Gameplay.Unit;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
namespace Code.Scripts.Gameplay.BT.Task
|
|
|
|
|
{
|
|
|
|
|
public class BTMoveTo : Action
|
|
|
|
|
{
|
|
|
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
|
|
|
|
|
|
|
|
private GameUnit _owner;
|
|
|
|
|
|
|
|
|
|
private uint _lastTarget;
|
|
|
|
|
|
|
|
|
|
public override void OnStart()
|
|
|
|
|
{
|
2023-12-14 18:25:52 +08:00
|
|
|
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
if (_owner != null)
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
DebugUtil.Log("BT move to start, owner: {0}",_owner?.GetID());
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override TaskStatus OnUpdate()
|
|
|
|
|
{
|
|
|
|
|
if (SharedBattleInfo.Value.theChosenOneId != Constants.INVALID_UINT_ID)
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
if(_lastTarget != SharedBattleInfo.Value.theChosenOneId && !AIUtils.IsNeedStop(_owner))
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
|
|
|
|
_lastTarget = SharedBattleInfo.Value.theChosenOneId;
|
2023-12-14 18:25:52 +08:00
|
|
|
_owner?.MoveTo(GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.theChosenOneId));
|
2023-08-22 19:08:45 +08:00
|
|
|
DebugUtil.LogG($"BT move to update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TaskStatus.Running;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TaskStatus.Failure;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|