The mod's own items, build pieces and summoned creatures now carry $rov_item_, $rov_piece_ and $rov_creature_ tokens for their names and descriptions, and items.json holds the texts in English and Italian. Valheim localizes these fields wherever it shows them: tooltips, hover texts, messages, the build menu. Where a name doubles as an identifier, both sides use the same constant, so the comparisons still hold. The Aswid foods keep their prefix as a constant for the refinery's check and now name the creature with its vanilla token, so "Boar" translates too. The Furling crops get one whole description per crop instead of an English sentence with the metal dropped in. The Race Menu Ward's panel title is a mod UI Text, so it reads the translation directly. Saves are unaffected: items and eaten foods are stored by prefab name. The Sverm hive's goods stay for the merchant step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
106 lines
4.6 KiB
C#
106 lines
4.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// Driver for the Sverm: an armoured insect that never dresses, never disarms, and grows a
|
|
/// colony instead of a wardrobe.
|
|
///
|
|
/// Only the per-frame upkeep that does not belong to a Harmony hook lives here. The perks are
|
|
/// SvermPatches, the passive is SE_SvermStats, the numbers are SvermConfig by way of
|
|
/// SvermProgression, and the look is SvermVisuals.
|
|
/// </summary>
|
|
public class SvermRace : MonoBehaviour
|
|
{
|
|
public static SvermRace Instance;
|
|
|
|
private float nextStatePublish;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public void CreateModAssets()
|
|
{
|
|
SvermStatusEffects.RegisterStatusEffects();
|
|
|
|
// Registered HERE and not lazily at spawn: this method runs on
|
|
// PrefabManager.OnVanillaPrefabsAvailable, which is the one moment Jotunn will take a
|
|
// new item into ObjectDB. Registering later builds a prefab nobody can spawn.
|
|
SvermClawSlot.EnsureRegistered();
|
|
|
|
// Same window, same reason: every edible is a cloned item, and Jotunn only takes new
|
|
// items here.
|
|
SvermFood.Register();
|
|
|
|
// Same window again: the worker is a cloned creature prefab.
|
|
SvermWorker.Register();
|
|
|
|
// And the four troops, which are cloned creatures too - Jotunn only takes a new prefab
|
|
// in this window, so a roster registered later is a roster nothing can spawn.
|
|
SvermBrood.Register();
|
|
|
|
// The bomb tick is a cloned creature too, and its blast is priced off two vanilla
|
|
// projectiles it reads at registration.
|
|
SvermBlisterTick.Register();
|
|
|
|
// The nest, its density cap and its Elder gate all live in SvermHive now.
|
|
//
|
|
// HONEST LIMIT on that cap, and it is PieceDensityLimit's own: a client holds only the
|
|
// ZDOs the server has sent it, and 908 m is far outside the loaded zones. Exact in
|
|
// singleplayer and on the host; on a remote client it can undercount and let a third
|
|
// nest through far from the other two. It still closes the case that matters.
|
|
SvermHive.Register();
|
|
|
|
// The shop counter, a building of its own rather than a second mouth on the nest - two
|
|
// launches proved a mouth on a shared body is a race between colliders. It has to come
|
|
// after the nest: its placement gate asks whether one is standing nearby.
|
|
SvermHiveMarketPiece.Register();
|
|
|
|
// Ravager Strain's worn model, stripped down to a costume here because this is the
|
|
// one safe moment to do it - see SvermRavagerForm.BuildTemplate.
|
|
SvermRavagerForm.BuildTemplate();
|
|
}
|
|
|
|
public static bool IsSverm()
|
|
{
|
|
return Player.m_localPlayer != null &&
|
|
Player.m_localPlayer.m_customData.ContainsKey("Race") &&
|
|
Player.m_localPlayer.m_customData["Race"] == SvermConfig.RaceId;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
// Antennae first and outside the race guard: it has to be able to put its own lights
|
|
// out when the player stops being a Sverm, and a guard above it would leave them lit
|
|
// on every creature in range forever.
|
|
SvermAntennae.Tick(Player.m_localPlayer);
|
|
|
|
// Also outside the race guard, and for the same reason: it has to be able to drop the
|
|
// form and give the player their body back if they stop being a Sverm mid-transformation.
|
|
SvermRavagerForm.Tick(Player.m_localPlayer);
|
|
|
|
if (Player.m_localPlayer == null || !IsSverm()) return;
|
|
|
|
// Republished on a timer rather than only at spawn: the tier changes the moment a boss
|
|
// dies, and a remote Sverm that still reads as tier 4 renders in the wrong colour with
|
|
// the wrong wings until it next loads.
|
|
if (Time.time >= nextStatePublish)
|
|
{
|
|
nextStatePublish = Time.time + 5f;
|
|
SvermPatches.PublishState(Player.m_localPlayer);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Names the colony half will register, declared here so the body half can cap the hive before
|
|
/// that half exists. One string, one place, no duplicate literal to drift.
|
|
/// </summary>
|
|
public static class SvermHiveNames
|
|
{
|
|
public const string PieceName = "SvermBroodMound";
|
|
public const string PieceDisplayName = "$rov_piece_sverm_broodmound_name";
|
|
}
|
|
}
|