46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using BehaviorDesigner.Runtime.Tasks;
|
|
using Framework;
|
|
using Gameplay.AI;
|
|
using Gameplay.BT.Variables;
|
|
using Gameplay.Common;
|
|
using Gameplay.Unit;
|
|
|
|
namespace Code.Scripts.Gameplay.BT.Task
|
|
{
|
|
public class BTMoveTo : Action
|
|
{
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
|
|
private GameUnit _owner;
|
|
|
|
private uint _lastTarget;
|
|
|
|
public override void OnStart()
|
|
{
|
|
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
|
|
|
|
if (_owner != null)
|
|
{
|
|
DebugUtil.Log("BT move to start, owner: {0}",_owner?.GetID());
|
|
}
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (SharedBattleInfo.Value.theChosenOneId != Constants.INVALID_UINT_ID)
|
|
{
|
|
if(_lastTarget != SharedBattleInfo.Value.theChosenOneId && !AIUtils.IsNeedStop(_owner))
|
|
{
|
|
_lastTarget = SharedBattleInfo.Value.theChosenOneId;
|
|
_owner?.MoveTo(GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.theChosenOneId));
|
|
DebugUtil.LogG($"BT move to update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}");
|
|
}
|
|
|
|
return TaskStatus.Running;
|
|
}
|
|
|
|
return TaskStatus.Failure;
|
|
|
|
}
|
|
}
|
|
} |