Via Ferrea: fondamenta, economia, rete ferroviaria, server e client, manutenzione e pendolarismo (F0–F4) #1
@@ -47,14 +47,18 @@ public sealed class TownSystem : ISimSystem
|
||||
continue;
|
||||
}
|
||||
int cat = (int)data.Goods[g].Town!.Category;
|
||||
int stockBefore = town.Stock[g];
|
||||
town.DemandAccumulator[g] += demand;
|
||||
int want = (int)Math.Floor(town.DemandAccumulator[g]);
|
||||
int used = Math.Min(want, town.Stock[g]);
|
||||
int used = Math.Min(want, stockBefore);
|
||||
town.Stock[g] -= used;
|
||||
w.Goods.Consumed[g] += used;
|
||||
town.DemandAccumulator[g] -= want; // la domanda non servita non si accumula
|
||||
// quota servita: con domande frazionarie il consumo è a scatti, quindi conta se la
|
||||
// scorta copriva la richiesta del giorno, non il rapporto tra unità intere e decimali
|
||||
double served = want > 0 ? (double)used / want : stockBefore > 0 ? 1.0 : 0.0;
|
||||
_catDemand[cat] += demand;
|
||||
_catConsumed[cat] += used;
|
||||
_catConsumed[cat] += demand * served;
|
||||
}
|
||||
for (int c = 0; c < Town.CategoryCount; c++)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user