using BehaviorDesigner.Runtime.Tasks; using Framework; using Gameplay.AI; using Gameplay.BT.Variables; using Gameplay.Common; namespace Code.Scripts.Gameplay.BT.Task { public class BTMoveTo : Action { public SharedBattleInfo SharedBattleInfo; private GameUnit _owner; private uint _lastTarget; public override void OnStart() { _owner = GameUnitMapper.Inst.GetUnitById(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(GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.theChosenOneId)); DebugUtil.LogG($"BT move to update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}"); } return TaskStatus.Running; } return TaskStatus.Failure; } } }