27 lines
876 B
C#
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;
|
|
}
|
|
}
|
|
}
|