Advertisement
Pro_Unit

MoveToTargetState

Aug 31st, 2023
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System.Threading;
  2.  
  3. using Cysharp.Threading.Tasks;
  4.  
  5. using Game.Extensions;
  6. using Game.UtilityAI;
  7.  
  8. using MalbersAnimations.Controller.AI;
  9.  
  10. using UnityEngine;
  11.  
  12. namespace Game.CameraLogic.Animals.StateMachine
  13. {
  14.     public class MoveToTargetState : IAnimalState
  15.     {
  16.         private readonly MAnimalAIControl _animalAIControl;
  17.         private readonly ITargetProvider _targetProvider;
  18.  
  19.         public MoveToTargetState(MAnimalAIControl animalAIControl, ITargetProvider targetProvider)
  20.         {
  21.             _animalAIControl = animalAIControl;
  22.             _targetProvider = targetProvider;
  23.         }
  24.  
  25.         public async UniTask Enter(CancellationToken cancellationToken)
  26.         {
  27.             Transform target = _targetProvider.GetTarget();
  28.  
  29.             await _animalAIControl.MoveToTarget(target, cancellationToken: cancellationToken, true);
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement