RacesOfValheim/JotunnModStub/RaceScale.cs
2026-08-11 16:30:20 +02:00

41 lines
1.7 KiB
C#

namespace RacesOfValheim
{
/// <summary>
/// Which races size their own body.
///
/// Several races postfix Player.Update and set the player's "Visual" scale from there. Each of
/// them also wants to undo that scale once the player is no longer of their race, and the
/// straightforward way to write that - "if this isn't my race, force the scale back to 1" -
/// makes every such race stamp on every other one, with the winner decided by whichever
/// postfix Harmony happened to run last.
///
/// That is what left the Dvergar at full height: Trol's reset ran on the same frame and put it
/// straight back to 1. Asking here first means a race only ever resets a player that nobody
/// else is sizing.
/// </summary>
public static class RaceScale
{
private static readonly string[] SelfSizingRaces =
{
"Trol",
"Furling",
DvergarConfig.RaceId,
TrentaConfig.RaceId,
// Sverm sizes itself only from the Queen on (Surrenal Glands, +10%). It is listed here
// for every tier all the same: below that tier its own ApplyScale asks for 1, which is
// the same answer another race's reset would give, and being on the list is what stops
// those resets from fighting it once the +10% does arrive.
SvermConfig.RaceId
};
public static bool ManagesOwnScale(string race)
{
if (string.IsNullOrEmpty(race)) return false;
foreach (string self in SelfSizingRaces)
{
if (race == self) return true;
}
return false;
}
}
}