diff --git a/JotunnModStub/ModelBorrow.cs b/JotunnModStub/ModelBorrow.cs index b064361..20b2ded 100644 --- a/JotunnModStub/ModelBorrow.cs +++ b/JotunnModStub/ModelBorrow.cs @@ -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(true)) diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs index 5bd38f8..f3d567f 100644 --- a/JotunnModStub/Trol/TrolTotem.cs +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -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(); @@ -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 })); } + /// + /// 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. + /// + private static GameObject ItemMesh(string itemPrefab) + { + GameObject source = PrefabManager.Cache.GetPrefab(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;