fix(trol): War Totem ghost invisible everywhere
The totem borrowed its look from the GoblinTotem item, whose root holds a ParticleSystem while the mesh sits in its attach child. Player.SetupPlacementGhost switches off every GameObject with a ParticleSystem, so it took the root and the mesh with it: the F8 dump showed TotemModel/model/attach/model active=False on the ghost. The Yagluth head (TrophyGoblinKing) is built the same way. Both now borrow the item's attach child, which is the mesh itself. ModelBorrow switches the copy on, since an item's attach is stored inactive in its prefab.
This commit is contained in:
parent
edc7fd33b7
commit
e1bd3b66e1
2 changed files with 22 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue