Sample outdoor weather from the climate preset so people can freeze and the clock can show it.

Protocol v8 adds tenths of a °C and precipitation to the clock frame; warmth drains from insulation versus place temperature.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 03:49:40 +03:00
co-authored by Cursor
parent d8f4958167
commit 8e7ab46e79
40 changed files with 1008 additions and 39 deletions
+26 -5
View File
@@ -1,6 +1,7 @@
using Arch.Core;
using HSchool.People;
using HSchool.Ai;
using HSchool.Content;
using HSchool.People;
namespace HSchool.Simulation;
@@ -10,7 +11,7 @@ public static class RosterSpawner
private static readonly QueryDescription People = new QueryDescription().WithAll<PersonIdentity>();
private static readonly QueryDescription Classes = new QueryDescription().WithAll<ClassIdentity>();
public static void Spawn(World world, Roster roster)
public static void Spawn(World world, Roster roster, DefCatalog? catalog = null)
{
foreach (var schoolClass in roster.Classes)
{
@@ -30,7 +31,8 @@ public static class RosterSpawner
new PersonBody(person.Numbers, person.Choices),
new PersonSkills(person.Skills.ToDictionary(pair => pair.Key, pair => (float)pair.Value, StringComparer.Ordinal)),
new PersonTraits(person.Traits),
new PersonNeeds(new Dictionary<string, float>(person.Needs, StringComparer.Ordinal)),
new PersonNeeds(NeedsOf(person, catalog)),
PersonInsulation.FromPerson(person, catalog),
new PersonRoles(
person.IsStudent,
person.IsStaff,
@@ -45,11 +47,30 @@ public static class RosterSpawner
}
/// <summary>Drops the previous composition and spawns <paramref name="roster"/>. Called on yearly intake.</summary>
public static void Replace(World world, Roster roster)
public static void Replace(World world, Roster roster, DefCatalog? catalog = null)
{
DestroyAll(world, People);
DestroyAll(world, Classes);
Spawn(world, roster);
Spawn(world, roster, catalog);
}
private static Dictionary<string, float> NeedsOf(Person person, DefCatalog? catalog)
{
var values = new Dictionary<string, float>(person.Needs, StringComparer.Ordinal);
if (catalog is null)
{
return values;
}
foreach (var need in catalog.Needs.Values)
{
if (!need.Abstract && !values.ContainsKey(need.DefName))
{
values[need.DefName] = need.Initial;
}
}
return values;
}
private static void DestroyAll(World world, QueryDescription query)