using Arch.Core; using HSchool.Content; namespace HSchool.Simulation; /// /// Drains needs by × simulated hours. Core ships decay at zero /// so this is a no-op until something exists that can refill them. /// public static class NeedDecay { private static readonly QueryDescription PeopleWithNeeds = new QueryDescription().WithAll(); public static void Apply(World world, DefCatalog catalog, double gameMinutes) { if (gameMinutes <= 0 || !catalog.AnyNeedDecays) { return; } var hours = gameMinutes / 60d; world.Query(in PeopleWithNeeds, (ref PersonNeeds needs) => { foreach (var def in catalog.Needs.Values) { if (def.Abstract || !needs.Values.TryGetValue(def.DefName, out var current)) { continue; } var next = current - (float)(def.DecayPerHour * hours); needs.Values[def.DefName] = Math.Clamp(next, def.Min, def.Max); } }); } }