riversong code showcase
This commit is contained in:
36
Source/Riversong/Game/World/Agents/ProviderAgentSystem.cs
Normal file
36
Source/Riversong/Game/World/Agents/ProviderAgentSystem.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
[GameSystemGroup(typeof(DayOnlyAgentSpawnSystemsGroup))]
|
||||
public class ProviderAgentSystem : GameSystem, IUpdatable
|
||||
{
|
||||
private const int MaxAgentCount = 10;
|
||||
|
||||
[InjectService]
|
||||
private GameConfig _config;
|
||||
|
||||
[InjectService]
|
||||
private IEntityCache _entityCache;
|
||||
|
||||
[InjectService]
|
||||
private IProductCatalog _productCatalog;
|
||||
|
||||
[InjectService]
|
||||
private IAgentCommonLogic _agentCommonLogic;
|
||||
|
||||
public ProviderAgentSystem(IServiceLocator serviceLocator) : base(serviceLocator)
|
||||
{
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var agentDefinition = (AgentDefinition)_config.Agents.GenericAgent.Asset;
|
||||
|
||||
foreach (var provider in _entityCache.GetProviders())
|
||||
if (provider.Definition.FetchesProducts)
|
||||
foreach (var (product, amount) in provider.Definition.ProvidedProducts)
|
||||
if (_agentCommonLogic.TryFetchProductFromStorage(agentDefinition, provider, _productCatalog.GetHandle(product), amount, MaxAgentCount))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user