RacesOfValheim/JotunnModStub/Skadi/SkadiStatusEffects.cs
2026-08-18 16:51:07 +02:00

66 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace RacesOfValheim
{
// Timed dragon forms. m_ttl is set when the form is entered, which is all Valheim needs to
// render the countdown: StatusEffect.GetIconText() prints the remaining time by itself.
public class SE_SkadiForm : StatusEffect
{
}
// Short ability cooldowns, shown purely so the HUD can count them down. Silent by design,
// unlike SE_FormCooldown which announces "... is Ready!" when it stops: tolerable once every
// few minutes for a dragon form, unbearable every three seconds for an attack.
public class SE_SkadiAbilityCooldown : StatusEffect
{
}
public class SE_SkadiStats : SE_Stats
{
public override void Setup(Character character)
{
base.Setup(character);
name = "SE_SkadiStats";
m_name = "Skadi's Aura";
m_tooltip = "Empowered by the frost.";
}
// What the last UpdateStats call actually wrote. SEMan.AddStatusEffect stores a Clone() of
// the registered prototype, so the effect running on the player is a separate object that
// has to be refreshed too (SkadiRace.Update does that) - and both of them are asked to
// update every frame. Rebuilding the mod list each time would churn a List per frame per
// instance, so nothing is rewritten until a tier change actually moves a value. These
// fields are not serialized, so a fresh clone starts at "never applied" and rebuilds once.
private bool statsApplied = false;
private float appliedFrostResistance = 0f;
private float appliedEitrRegenMultiplier = 0f;
public void UpdateStats(SkadiProgression.FormRules rules)
{
if (statsApplied &&
rules.FrostResistance == appliedFrostResistance &&
rules.EitrRegenMultiplier == appliedEitrRegenMultiplier)
{
return;
}
statsApplied = true;
appliedFrostResistance = rules.FrostResistance;
appliedEitrRegenMultiplier = rules.EitrRegenMultiplier;
m_mods = new List<HitData.DamageModPair>();
if (rules.FrostResistance >= 1f)
{
m_mods.Add(new HitData.DamageModPair() { m_type = HitData.DamageType.Frost, m_modifier = HitData.DamageModifier.Immune });
}
else if (rules.FrostResistance >= 0.5f)
{
m_mods.Add(new HitData.DamageModPair() { m_type = HitData.DamageType.Frost, m_modifier = HitData.DamageModifier.Resistant });
}
m_eitrRegenMultiplier = rules.EitrRegenMultiplier;
}
}
}