Sum warmth insulation from worn items and refresh goldens for the new trait pool.
HeatLoving and ColdLoving shift later trait rolls; worn clothes now feed PersonInsulation instead of reflection. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -34,40 +34,15 @@ public readonly record struct PersonInsulation(float Value)
|
||||
return Naked;
|
||||
}
|
||||
|
||||
var worn = WornDefs(person);
|
||||
var worn = new List<string>();
|
||||
foreach (var item in person.Items)
|
||||
{
|
||||
if (item.Location.Equals(ItemLocations.Worn, StringComparison.Ordinal))
|
||||
{
|
||||
worn.Add(item.Def);
|
||||
}
|
||||
}
|
||||
|
||||
return worn.Count == 0 ? Naked : FromWorn(catalog, [.. worn]);
|
||||
}
|
||||
|
||||
private static List<string> WornDefs(Person person)
|
||||
{
|
||||
var worn = new List<string>();
|
||||
if (person.GetType().GetProperty("Items")?.GetValue(person) is not System.Collections.IEnumerable items)
|
||||
{
|
||||
return worn;
|
||||
}
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var type = item.GetType();
|
||||
var def = type.GetProperty("Def")?.GetValue(item) as string;
|
||||
var location = type.GetProperty("Location")?.GetValue(item) as string
|
||||
?? type.GetProperty("Place")?.GetValue(item) as string;
|
||||
if (def is null || location is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (location.Equals("worn", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
worn.Add(def);
|
||||
}
|
||||
}
|
||||
|
||||
return worn;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user