public async Task <(ResourceType resource, int quantity)?> GenerateResource(CancellationToken cancellationToken) { CanGenerateResource = false; await timeAdapter.Delay(TimeSpan.FromSeconds(productionData.Seconds), cancellationToken); CanGenerateResource = true; var generatedResources = (productionData.Resource, productionData.Quantity); resourcesExchanger.AddResources(generatedResources); return(generatedResources); }
private async Task GenerateResourcesIndefinitelly(CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested || !this.gameObject.activeInHierarchy) { return; } while (!cancellationToken.IsCancellationRequested && this.gameObject.activeInHierarchy) { await timeAdapter.Delay(TimeSpan.FromSeconds(productionData.Seconds), cancellationToken); var generatedResources = (productionData.Resource, productionData.Quantity); resourcesExchanger.AddResources(generatedResources); } }