Files
riversong-code-showcase/Source/Riversong/Game/World/Agents/Intents/FireProjectileExecutionLogic.cs
2026-05-21 16:04:49 +02:00

27 lines
876 B
C#

using Cysharp.Threading.Tasks;
namespace DanieleMarotta.RiversongCodeShowcase
{
public class FireProjectileExecutionLogic : IntentExecutionLogic
{
private IEntityCollection _entityCollection;
private IProjectileManager _projectileManager;
public override UniTask InitializeAsync(IServiceLocator serviceLocator)
{
_entityCollection = serviceLocator.GetService<IEntityCollection>();
_projectileManager = serviceLocator.GetService<IProjectileManager>();
return UniTask.CompletedTask;
}
public override IntentExecutionResult Execute(Agent agent, in AgentIntent intent)
{
var critter = _entityCollection.Get<Agent>(intent.TargetId);
_projectileManager.FireProjectile(agent, critter);
return IntentExecutionResult.Success;
}
}
}