RacesOfValheim/JotunnModStub/Trenta/TrentaProgression.cs
Ferdinando d0ed92c553 feat(trenta): add the Trenta race
A vegan, tree-born race unlocking new perks per boss defeated: skin/hair
tint, blocked non-vegan food, awakened seed foods after Eikthyr, a mob
hostility list, Photosynthesis, elemental resistances, Purple Rain after
the Elder, swim/poison/wet immunity after Bonemass, Last Stand and Thorns
after Moder, a Homecoming Portal after Yagluth, Hornet's Nest after the
Queen, and Muspell (a half-size Elder transformation with Stomp/Spike
attacks) after Fader.

Also fixes RaceScale never listing Trenta as self-sizing, which let a
shared Player.Update postfix fight Muspell's own scale changes every
frame.
2026-08-04 20:58:01 +02:00

45 lines
1.7 KiB
C#

using UnityEngine;
namespace RacesOfValheim
{
/// <summary>
/// Turns a boss progression state into the set of Trenta perks active at that tier, the same
/// way SkeletonProgression and DvergarProgression do for their races.
///
/// Nothing is decided here - every figure comes out of TrentaConfig - so the tuning pass can
/// happen without touching a single patch.
/// </summary>
public static class TrentaProgression
{
public struct TrentaRules
{
/// <summary>Points added to max health at this tier.</summary>
public float HealthBonus;
// TODO: one field per perk, each read by exactly one patch.
}
// GetRules runs from Update loops and from damage patches, so the per-state result is
// built once and handed back on every later call.
private static readonly TrentaRules[] cache = new TrentaRules[BossProgressionManager.MaxState + 1];
private static readonly bool[] cached = new bool[BossProgressionManager.MaxState + 1];
public static TrentaRules GetRules(int state)
{
state = Mathf.Clamp(state, BossProgressionManager.MinState, BossProgressionManager.MaxState);
if (cached[state]) return cache[state];
TrentaRules rules = new TrentaRules
{
HealthBonus = TrentaConfig.Lookup(TrentaConfig.HealthBonusByState, state)
};
cache[state] = rules;
cached[state] = true;
return rules;
}
/// <summary>Rules for whatever tier the local player is currently on.</summary>
public static TrentaRules Current => GetRules(BossProgressionManager.GetCurrentProgressionState());
}
}