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,45 @@
namespace DanieleMarotta.RiversongCodeShowcase
{
[GameSystemGroup(typeof(DayOnlyAgentSpawnSystemsGroup))]
public class HunterSpawnSystem : GameSystem, IUpdatable
{
[InjectService]
private GameConfig _config;
[InjectService]
private IEntityCache _entityCache;
[InjectService]
private ITileSpace _tileSpace;
[InjectService]
private IAgentFactory _agentFactory;
public HunterSpawnSystem(IServiceLocator serviceLocator) : base(serviceLocator)
{
}
public void Update()
{
var agentDefinition = (AgentDefinition)_config.Agents.HunterAgent.Asset;
foreach (var hunterBuilding in _entityCache.GetHunterBuildings()) SpawnHunterAgent(hunterBuilding, agentDefinition);
}
private void SpawnHunterAgent(Building hunterBuilding, AgentDefinition agentDefinition)
{
if (!_agentFactory.CanSpawnAgent(hunterBuilding, 1, AgentJob.Hunter)) return;
var position = _tileSpace.TileToWorld(hunterBuilding.Rect.Center);
var critterId = hunterBuilding.Definition.TargetCritter.RuntimeId;
var agent = _agentFactory.CreateVillager(agentDefinition, hunterBuilding, position, AgentJob.Hunter);
ref var jobState = ref agent.GetJobStateRW();
jobState.StateMachineStep = AgentStateMachineStep.Hunter_SeekingPrey;
IntentQueue.SeekPrey(ref agent.GetIntentQueueRW(), critterId, hunterBuilding.Definition.Range);
}
}
}