35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using BehaviorDesigner.Runtime.Tasks;
|
|
using Framework;
|
|
using Gameplay.AI;
|
|
using Gameplay.BT.Variables;
|
|
using Gameplay.Common;
|
|
|
|
namespace Code.Scripts.Gameplay.BT.Task
|
|
{
|
|
public class BTMoveAway : Action
|
|
{
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
private GameUnit _owner;
|
|
|
|
public override void OnStart()
|
|
{
|
|
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
|
|
|
|
if (_owner != null)
|
|
{
|
|
DebugUtil.Log("BT move away start, owner: {0}",_owner?.GetID());
|
|
}
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (SharedBattleInfo.Value.theChosenOneId != Constants.INVALID_UINT_ID && !AIUtils.IsNeedStop(_owner))
|
|
{
|
|
_owner?.MoveAway(GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.theChosenOneId));
|
|
DebugUtil.LogG($"BT move away update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}");
|
|
|
|
}
|
|
return TaskStatus.Success;
|
|
}
|
|
}
|
|
} |