Add HSchool.Content project for JSONC definitions, catalog, and map validation. Update solution structure to include new content and tests projects. Enhance school management to support mod packs and map instances, ensuring proper loading and validation. Revise documentation to reflect these changes and update tests for new functionality.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using Arch.Core;
|
||||
using HSchool.Content;
|
||||
|
||||
namespace HSchool.Simulation;
|
||||
|
||||
/// <summary>
|
||||
/// One save: a name, a calendar and the ECS world that will hold everything the school is made of.
|
||||
/// The world is empty for now — pupils, rooms and staff land in it as the game grows — but it is
|
||||
/// created and destroyed with the school so ownership is never in question.
|
||||
/// One save: a name, a calendar, a frozen def catalog, a map instance, and the ECS world that will
|
||||
/// hold everything the school is made of. The world is empty for now — pupils, rooms and staff
|
||||
/// land in it as the game grows — but it is created and destroyed with the school so ownership is
|
||||
/// never in question.
|
||||
/// </summary>
|
||||
public sealed class School : IDisposable
|
||||
{
|
||||
@@ -14,21 +16,36 @@ public sealed class School : IDisposable
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
internal School(int id, string name, DateTime startDate)
|
||||
internal School(int id, string name, DateTime startDate, DefCatalog? catalog, MapLayout? map)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Clock = new GameClock(startDate);
|
||||
Catalog = catalog;
|
||||
Map = map;
|
||||
World = World.Create();
|
||||
}
|
||||
|
||||
/// <summary>A brand-new school: calendar running at the start date, empty world.</summary>
|
||||
public static School Create(int id, string name, DateTime startDate) => new(id, name, startDate);
|
||||
public static School Create(
|
||||
int id,
|
||||
string name,
|
||||
DateTime startDate,
|
||||
DefCatalog? catalog = null,
|
||||
MapLayout? map = null) =>
|
||||
new(id, name, startDate, catalog, map);
|
||||
|
||||
/// <summary>Rebuilds a school from a save. Time, pause and speed come from disk, not defaults.</summary>
|
||||
public static School Load(int id, string name, DateTime time, bool running, int speedIndex)
|
||||
public static School Load(
|
||||
int id,
|
||||
string name,
|
||||
DateTime time,
|
||||
bool running,
|
||||
int speedIndex,
|
||||
DefCatalog? catalog = null,
|
||||
MapLayout? map = null)
|
||||
{
|
||||
var school = new School(id, name, time);
|
||||
var school = new School(id, name, time, catalog, map);
|
||||
school.Clock.IsRunning = running;
|
||||
school.Clock.SpeedIndex = speedIndex;
|
||||
return school;
|
||||
@@ -40,6 +57,12 @@ public sealed class School : IDisposable
|
||||
|
||||
public GameClock Clock { get; }
|
||||
|
||||
/// <summary>Frozen at create/load. Null only in clock-only unit tests.</summary>
|
||||
public DefCatalog? Catalog { get; }
|
||||
|
||||
/// <summary>The school's map instance. Null only in clock-only unit tests.</summary>
|
||||
public MapLayout? Map { get; }
|
||||
|
||||
/// <summary>The Arch world backing this school. Only this school's worker thread may touch it.</summary>
|
||||
public World World { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user