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,47 @@
namespace DanieleMarotta.RiversongCodeShowcase
{
[GameSystemGroup(typeof(DayOnlyAgentSpawnSystemsGroup))]
public class HarvesterAgentSystem : GameSystem, IUpdatable
{
[InjectService]
private IEntityCollection _entityCollection;
[InjectService]
private IEntityCache _entityCache;
[InjectService]
private ITileSpace _tileSpace;
[InjectService]
private IAgentFactory _agentFactory;
[InjectService]
private IProductCatalog _productCatalog;
[InjectService]
private IBuildingSpatialQuery _buildingSpatialQuery;
[InjectService]
private IAgentCommonLogic _agentCommonLogic;
public HarvesterAgentSystem(IServiceLocator serviceLocator) : base(serviceLocator)
{
}
public void Update()
{
foreach (var harvester in _entityCache.GetHarvesterBuildings())
{
if (!_agentFactory.CanSpawnAgent(harvester, 1, AgentJob.Harvester)) continue;
var resourceDefinition = harvester.Definition.HarvestedResource;
var position = _tileSpace.TileToWorld(harvester.Rect.Center);
var agent = _agentFactory.CreateVillager(resourceDefinition.HarvesterAgent, harvester, position, AgentJob.Harvester);
var range = harvester.Definition.Range;
IntentQueue.Harvest(ref agent.GetIntentQueueRW(), harvester.Rect, harvester.Id, resourceDefinition, range);
}
}
}
}