using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class InteractAction : BaseAction
{
private void Start() {
maxDistance = (Range)2;
}
public override string GetActionName()
{
return "Interact";
}
public override EnemyAIAction GetEnemyAIAction(GridPosition gridPosition)
{
return new EnemyAIAction {
gridPosition = gridPosition,
actionValue = 0,
};
}
public override CancellationToken TakeAction(in GridPosition gridPosition, out CancellationToken cancellationToken)
{
(LevelGrid.Instance.GetInteractableAtGridPosition(gridPosition)).Interact(OnInteractComplete);
StartAction(out cancellationToken);
return cancellationToken;
}
private void OnInteractComplete() {
StopAction();
}
protected override bool IsValidTargetPositionSpecific(in GridPosition unitGridPosition, in GridPosition testGridPosition) =>
(LevelGrid.Instance.GetInteractableAtGridPosition(testGridPosition)) != null;
}