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,33 @@
namespace DanieleMarotta.RiversongCodeShowcase
{
[GameSystemGroup(typeof(EconomySystemGroup))]
public class ProductionRequirementsGameSystem : GameSystem, IUpdatable
{
[InjectService]
private IEntityCache _entityCache;
public ProductionRequirementsGameSystem(IServiceLocator serviceLocator) : base(serviceLocator)
{
}
public void Update()
{
foreach (var producer in _entityCache.GetProducers())
{
ref var productionState = ref producer.GetProductionStateRW();
ref var recipe = ref productionState.Recipe;
ref var storage = ref producer.GetStorageRW();
productionState.MetRequirements = ProductionRequirements.All;
foreach (var (product, amount) in recipe.Inputs)
if (storage.AvailableNow(product) < amount)
{
productionState.MetRequirements &= ~ProductionRequirements.InputsAvailable;
break;
}
}
}
}
}