using Cysharp.Threading.Tasks;
using ScenarioFlow.Tasks;
using System;
using System.Threading;
using UnityEngine;

namespace OtherFeatures
{
	public class ScenarioTaskExecutorTokenLoggingDecorator : IScenarioTaskExecutor
    {
        private readonly IScenarioTaskExecutor scenarioTaskExecutor;
        private readonly ITokenCodeGetter tokenCodeGetter;

        public ScenarioTaskExecutorTokenLoggingDecorator(IScenarioTaskExecutor scenarioTaskExecutor, ITokenCodeGetter tokenCodeGetter)
        {
            this.scenarioTaskExecutor = scenarioTaskExecutor ?? throw new ArgumentNullException(nameof(scenarioTaskExecutor));
            this.tokenCodeGetter = tokenCodeGetter ?? throw new ArgumentNullException(nameof(tokenCodeGetter));
        }

        public UniTask ExecuteAsync(UniTask scenarioTask, CancellationToken cancellationToken)
        {
            var tokenCode = tokenCodeGetter.TokenCode;
            Debug.Log(tokenCode);
            return scenarioTaskExecutor.ExecuteAsync(scenarioTask, cancellationToken);
        }
    }
}