using Cysharp.Threading.Tasks; namespace DanieleMarotta.RiversongCodeShowcase { public class HarvestResourceIntentExecutionLogic : IntentExecutionLogic { private World _world; private ISignalBus _signalBus; public override UniTask InitializeAsync(IServiceLocator serviceLocator) { _world = serviceLocator.GetService(); _signalBus = serviceLocator.GetService(); return UniTask.CompletedTask; } public override IntentExecutionResult Execute(Agent agent, in AgentIntent intent) { ref var jobState = ref agent.GetJobStateRW(); var resourceNodeId = jobState.Harvester.ResourceNodeId; if (!_world.RawResources.Exists(resourceNodeId)) return IntentExecutionResult.Failure; _signalBus.Raise(new RawResourceHarvestedSignal(resourceNodeId)); return IntentExecutionResult.Success; } } }