RacesOfValheim/JotunnModStub/Skadi/SkadiFrostHeart.cs
kanym b177c89c71 feat(text): item, piece and creature names come from translation files
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>
2026-09-26 19:58:53 +02:00

57 lines
2.4 KiB
C#

using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
namespace RacesOfValheim
{
/// <summary>
/// Greater Frost Heart - the bought leg of the Skadi recipe, and the piece that keeps this chain
/// hooked to the faction merchant system the way every other race's does. 1500 coins from the
/// Cultist bench, which is the same price band as GreaterUlvsblod, GreaterCursedBone and
/// GreaterCursedSkull: the reagent that unlocks the last step of a race's chain.
///
/// A NOTE ON THE SHOP KEY, because it has already cost this project once: the Cultist shop in
/// FactionMerchantCatalog is mapped on the mob "Fenring_Cultist", NOT on "Fenring" - that one is
/// a different bench belonging to the Fenrir trough. Selling from the wrong one puts the item in
/// a shop nobody expects.
/// </summary>
public static class SkadiFrostHeart
{
public const string PrefabName = "GreaterFrostHeart";
public const string DisplayName = "$rov_item_skadi_greaterfrostheart_name";
public const int Price = 1500;
private const string SourcePrefab = "FreezeGland";
public static void Register()
{
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, SourcePrefab);
if (prefab == null)
{
Jotunn.Logger.LogWarning($"[Skadi] Could not clone {SourcePrefab}; {DisplayName} not registered.");
return;
}
ItemDrop drop = prefab.GetComponent<ItemDrop>();
if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null)
{
Jotunn.Logger.LogWarning($"[Skadi] {SourcePrefab} clone has no usable ItemDrop; {DisplayName} not registered.");
return;
}
SkadiIce.Apply(prefab);
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
shared.m_name = DisplayName;
shared.m_description = "$rov_item_skadi_greaterfrostheart_desc";
shared.m_itemType = ItemDrop.ItemData.ItemType.Material;
shared.m_weight = 0.5f;
shared.m_maxStackSize = 10;
shared.m_value = Price;
ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false));
Jotunn.Logger.LogInfo($"[Skadi] {DisplayName} registered at {Price} coins.");
}
}
}