Enhance school simulation and management by integrating roster functionality, allowing for the installation and persistence of student and staff data. Update the school architecture to include a roster alongside existing components, ensuring proper validation against map layouts. Revise room definitions to support homeroom designations and update related tests to validate new functionalities and ensure robustness in roster handling.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Arch.Core;
|
||||
using HSchool.Content;
|
||||
|
||||
namespace HSchool.Simulation;
|
||||
|
||||
/// <summary>
|
||||
/// Drains needs by <see cref="NeedDef.DecayPerHour"/> × simulated hours. Core ships decay at zero
|
||||
/// so this is a no-op until something exists that can refill them.
|
||||
/// </summary>
|
||||
public static class NeedDecay
|
||||
{
|
||||
private static readonly QueryDescription PeopleWithNeeds = new QueryDescription().WithAll<PersonNeeds>();
|
||||
|
||||
public static void Apply(World world, DefCatalog catalog, double gameMinutes)
|
||||
{
|
||||
if (gameMinutes <= 0 || catalog.Needs.Count == 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user