Move goal weights into BehaviorDef so a pack can rebalance decisions without a fork.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,8 +2,9 @@ namespace HSchool.Content;
|
||||
|
||||
internal static class PeopleDefValidator
|
||||
{
|
||||
public static void Validate(DefCatalog catalog)
|
||||
public static void Validate(DefCatalog catalog, IContentLog? log = null)
|
||||
{
|
||||
log ??= NullContentLog.Instance;
|
||||
foreach (var body in catalog.BodyAttributes.Values)
|
||||
{
|
||||
ValidateBody(body);
|
||||
@@ -56,7 +57,7 @@ internal static class PeopleDefValidator
|
||||
|
||||
foreach (var behavior in catalog.Behavior.Values)
|
||||
{
|
||||
ValidateBehavior(behavior);
|
||||
ValidateBehavior(behavior, log);
|
||||
}
|
||||
|
||||
if (catalog.Staffing.Values.Count(def => !def.Abstract) > 1)
|
||||
@@ -476,7 +477,7 @@ internal static class PeopleDefValidator
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateBehavior(BehaviorDef behavior)
|
||||
private static void ValidateBehavior(BehaviorDef behavior, IContentLog log)
|
||||
{
|
||||
if (behavior.Abstract)
|
||||
{
|
||||
@@ -503,6 +504,22 @@ internal static class PeopleDefValidator
|
||||
throw new ContentLoadException(
|
||||
$"BehaviorDef '{behavior.DefName}' commute slack must be a non-negative range with min ≤ max.");
|
||||
}
|
||||
|
||||
if (behavior.DutyLessonWeight < 0f
|
||||
|| behavior.DutyTravelWeight < 0f
|
||||
|| behavior.NeedWeightAtZero < 0f
|
||||
|| behavior.LunchWeight < 0f)
|
||||
{
|
||||
throw new ContentLoadException($"BehaviorDef '{behavior.DefName}' goal weights cannot be negative.");
|
||||
}
|
||||
|
||||
// A pack may invert this on purpose — lunch then pulls the class out of the lesson.
|
||||
// The warning is the catch; refusing to load would make the number unmoddable.
|
||||
if (behavior.LunchWeight > behavior.DutyLessonWeight)
|
||||
{
|
||||
log.Warning(
|
||||
$"BehaviorDef '{behavior.DefName}' lunchWeight {behavior.LunchWeight} is above dutyLessonWeight {behavior.DutyLessonWeight}; pupils will leave class for lunch.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateHoliday(HolidayDef holiday)
|
||||
|
||||
Reference in New Issue
Block a user