Merge branch 'main' into localisation

This commit is contained in:
kanym 2026-10-17 16:22:29 +02:00
commit b6e085e378
2 changed files with 22 additions and 2 deletions

View file

@ -89,6 +89,11 @@ namespace RacesOfValheim
copy.transform.localRotation = localRotation;
copy.transform.localScale = Vector3.one;
// An item's "attach" child is stored switched off in its prefab (VisEquipment turns it on
// when it is worn), so a copy of one comes out switched off too. The holder above is still
// inactive, so turning the copy on wakes nothing.
if (!copy.activeSelf) copy.SetActive(true);
// Everything that is not a Renderer or a Transform. Order matters for the same reason it did
// on the Aswid's lights: behaviours first, then the things they hold references to.
foreach (MonoBehaviour behaviour in copy.GetComponentsInChildren<MonoBehaviour>(true))

View file

@ -239,7 +239,7 @@ namespace RacesOfValheim
// The look the player asked for: the totem itself, not a log with a head on it. Grounded on
// its own base, so Vector3.zero really is "standing on the spot the hammer picked".
GameObject totemModel = ModelBorrow.Attach(prefab.transform, "TotemModel", "GoblinTotem",
GameObject totemModel = ModelBorrow.Attach(prefab.transform, "TotemModel", ItemMesh("GoblinTotem"),
Vector3.zero, Quaternion.identity, TotemHeight, "Trol");
TrolTotemBehaviour totem = prefab.AddComponent<TrolTotemBehaviour>();
@ -293,7 +293,7 @@ namespace RacesOfValheim
Jotunn.Logger.LogInfo($"[Trol] Totem crown measured at {crown:0.##} m; the king's head is " +
$"{HeadSize} m across and sunk {HeadSize * HeadSink:0.##} m into it.");
totem.m_yagluthHead = ModelBorrow.Attach(prefab.transform, "TotemHeadYagluth", YagluthHead,
totem.m_yagluthHead = ModelBorrow.Attach(prefab.transform, "TotemHeadYagluth", ItemMesh(YagluthHead),
new Vector3(0f, crown - HeadSize * HeadSink, 0f),
HeadTilt, HeadSize, "Trol");
totem.m_yagluthHead.SetActive(false);
@ -329,6 +329,21 @@ namespace RacesOfValheim
}));
}
/// <summary>
/// The part of an item that IS the item: its "attach" child, which holds the mesh, rather than
/// the whole prefab. GoblinTotem carries a ParticleSystem on its root, and
/// Player.SetupPlacementGhost switches off every GameObject that has one - taking the root and,
/// with it, the mesh underneath. That is why the War Totem showed no ghost anywhere while every
/// other station did. TrophyGoblinKing is built the same way. Falls back to the whole prefab
/// for an item without an attach.
/// </summary>
private static GameObject ItemMesh(string itemPrefab)
{
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>(itemPrefab);
Transform attach = source != null ? source.transform.Find("attach") : null;
return attach != null ? attach.gameObject : source;
}
public static void EnsureKnown(Player player)
{
if (player == null) return;