riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
using Cysharp.Threading.Tasks;
using Unity.Mathematics;
using UnityEngine;
namespace DanieleMarotta.RiversongCodeShowcase
{
public class FollowPathIntentExecutionLogic : IntentExecutionLogic
{
private ITileSpace _tileSpace;
private IAgentCommonLogic _agentCommonLogic;
public override UniTask InitializeAsync(IServiceLocator serviceLocator)
{
_tileSpace = serviceLocator.GetService<ITileSpace>();
_agentCommonLogic = serviceLocator.GetService<IAgentCommonLogic>();
return UniTask.CompletedTask;
}
public override IntentExecutionResult OnStartingIntent(Agent agent, in AgentIntent intent)
{
agent.PathIndex = 0;
return IntentExecutionResult.Success;
}
public override IntentExecutionResult Execute(Agent agent, in AgentIntent intent)
{
ref var path = ref agent.GetPathRW();
if (path.StepCount <= 1) return IntentExecutionResult.Success;
var nextTile = path.Steps[agent.PathIndex + 1];
var targetPosition = (float3)_tileSpace.TileToWorld(nextTile);
var targetReached = _agentCommonLogic.MoveAgent(agent, targetPosition, Time.deltaTime);
var lastStepReached = targetReached && ++agent.PathIndex >= path.StepCount - 1 - intent.StopBeforeGoalStepCount;
return lastStepReached ? IntentExecutionResult.Success : IntentExecutionResult.InProgress;
}
}
}