feat: marble Bone Servant tables, bigger centred props, fix table hover name

The Smith's and Cook's Tables clone the black marble table: the
cartography table's map is baked into its texture. Anvil or meal and a
skull sit near the centre at the table's measured height. The bank loses
its lantern and its tankard grows. The servant table hover localizes its
title, which showed as a raw token once a servant stood there.
This commit is contained in:
kanym 2026-10-28 13:22:56 +01:00
commit b3edb2aed1
3 changed files with 36 additions and 32 deletions

View file

@ -61,7 +61,7 @@ namespace RacesOfValheim
/// making the situation impossible to build rather than by sharing state between them.</summary>
public const float TableSpacing = 40f;
private const float TableScale = 0.8f;
private const string TableSource = "piece_blackmarble_table";
/// <summary>
/// One skull, one wishbone, eight stone - the same price for both tables.
@ -197,19 +197,20 @@ namespace RacesOfValheim
private static void RegisterTable(string pieceName, string displayName, string servantPrefab,
ButlerFamily family, string description, string iconSource)
{
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(pieceName, "piece_cartographytable");
// The black marble table: "a slab of bone and slate". It was the cartography table once,
// whose map is baked into its own texture and could not be taken off.
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(pieceName, TableSource);
if (prefab == null)
{
Jotunn.Logger.LogWarning($"[Butler] Could not clone piece_cartographytable; " +
Jotunn.Logger.LogWarning($"[Butler] Could not clone {TableSource}; " +
$"the {displayName} is not registered.");
return;
}
// The MapTable trap, and it is the reason this is a blanket sweep by capability rather than
// a named DestroyImmediate: MapTable is Interactable AND Hoverable, so it takes the E key
// before our own Switch ever sees it and opens the shared map instead. Same bug as the
// barrel's Container on the Fenrir trough and the Trader on the vanilla wolf; the Dvergar
// contract bank pays for this lesson already.
// A blanket sweep by capability rather than a named DestroyImmediate. The cartography table
// taught it: its MapTable is Interactable AND Hoverable, so it took the E key before our own
// Switch ever saw it. The marble table carries nothing of the kind today, and the sweep
// keeps a future patch from adding one behind our back.
foreach (MonoBehaviour behaviour in prefab.GetComponentsInChildren<MonoBehaviour>(true))
{
if (behaviour == null) continue;
@ -217,7 +218,6 @@ namespace RacesOfValheim
Object.DestroyImmediate(behaviour);
}
prefab.transform.localScale = Vector3.one * TableScale;
Dress(prefab, family);
ServantTableBehaviour table = prefab.AddComponent<ServantTableBehaviour>();
@ -256,33 +256,40 @@ namespace RacesOfValheim
}));
}
// The look, in the table's own space BEFORE TableScale, like the Dvergar bank's coin pile.
// TableTop is that pile's height: the same vanilla mesh, so the same surface.
private static readonly Color BoneSlateTint = new Color(0.72f, 0.74f, 0.78f, 1f);
private const float TableTop = 1.05f;
private static readonly Vector3 SkullSpot = new Vector3(1.6f, TableTop, -0.5f);
private static readonly Vector3 TradeSpot = new Vector3(-1.55f, TableTop, 0.3f);
// The look. The marble table is 2.6 m by 1.5 m; both props sit either side of its centre, the
// trade's tool the bigger of the two. X and Z only: the height is the table's, measured.
private const float MarbleTableTop = 0.82f;
private static readonly Vector3 TradeSpot = new Vector3(-0.35f, 0f, 0f);
private static readonly Vector3 SkullSpot = new Vector3(0.6f, 0f, 0.1f);
private const float AnvilSize = 0.75f;
private const float MealSize = 0.6f;
private const float SkullSize = 0.45f;
/// <summary>
/// "A slab of bone and slate": the cartography table greyed down, a skeleton's skull on one end
/// and the trade's own tool on the other - an anvil for the smith, a mortar for the cook.
/// "A slab of bone and slate": the black marble table, with the trade's own work in the middle -
/// an anvil for the smith, a meal for the cook - and a skeleton's skull beside it.
/// </summary>
private static void Dress(GameObject prefab, ButlerFamily family)
{
PieceLook.Tint(prefab.transform, BoneSlateTint);
// The table's own height off its own mesh, with vanilla's 0.82 m as the fallback. The mesh
// stands on the piece's origin, so its height IS the height of the top.
Transform model = prefab.transform.Find("new");
float top = model != null ? ModelBorrow.HeightOf(model.gameObject) : 0f;
if (top <= 0f) top = MarbleTableTop;
Vector3 up = Vector3.up * top;
ModelBorrow.Attach(prefab.transform, "TableSkull", "TrophySkeleton",
SkullSpot, Quaternion.Euler(0f, -120f, 0f), 0.3f, "Butler", activeOnly: true);
SkullSpot + up, Quaternion.Euler(0f, -150f, 0f), SkullSize, "Butler", activeOnly: true);
if (family == ButlerFamily.Forge)
{
ModelBorrow.Attach(prefab.transform, "TableAnvil", "forge_ext2",
TradeSpot, Quaternion.identity, 0.55f, "Butler", activeOnly: true);
TradeSpot + up, Quaternion.identity, AnvilSize, "Butler", activeOnly: true);
}
else
{
ModelBorrow.Attach(prefab.transform, "TableMortar", "cauldron_ext5_mortarandpestle",
TradeSpot, Quaternion.identity, 0.6f, "Butler", activeOnly: true);
ModelBorrow.Attach(prefab.transform, "TableMeal", "MeatPlatter",
TradeSpot + up, Quaternion.identity, MealSize, "Butler", activeOnly: true);
}
}