38 lines
1.2 KiB
C#
38 lines
1.2 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 BTMoveAway : Action
|
|
{
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
private GameUnit _owner;
|
|
|
|
public override void OnStart()
|
|
{
|
|
_owner = GameUnitManager.instance.infightUnits.Search(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))
|
|
{
|
|
var unit = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.theChosenOneId);
|
|
if (unit != null)
|
|
_owner?.MoveAway(unit);
|
|
// DebugUtil.LogG($"BT move away update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}");
|
|
}
|
|
|
|
return TaskStatus.Success;
|
|
}
|
|
}
|
|
} |