fix(forms): hair comes back after a form with Valkyr
Valkyr sets its hair's forceRenderingOff on every visual update. The hider read that flag as "not hidden yet", recorded the hair a second time with enabled already false, and the revert left it off. Track hidden renderers in a set instead of trusting the flag.
This commit is contained in:
parent
f1d00f6eff
commit
5dff5e1b84
1 changed files with 19 additions and 1 deletions
|
|
@ -33,6 +33,11 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
private readonly List<HiddenRenderer> m_hidden = new List<HiddenRenderer>();
|
||||
|
||||
// What we hid, kept apart from forceRenderingOff. Other mods write that flag too: Valkyr
|
||||
// sets its hair's forceRenderingOff on every visual update, so the flag alone made the
|
||||
// rescan record the hair a second time, already disabled, and the revert left it off.
|
||||
private readonly HashSet<Renderer> m_tracked = new HashSet<Renderer>();
|
||||
private float m_nextRescan;
|
||||
private float m_nextLog;
|
||||
private string m_context = "";
|
||||
|
|
@ -107,8 +112,20 @@ namespace RacesOfValheim
|
|||
// the cape along with the body mesh itself.
|
||||
foreach (Renderer r in GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if (r == null || r.forceRenderingOff) continue; // already ours
|
||||
if (r == null) continue;
|
||||
|
||||
if (m_tracked.Contains(r))
|
||||
{
|
||||
// Already ours: re-assert in case another mod cleared the flag.
|
||||
r.forceRenderingOff = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Hidden by someone else (Valkyr hides the vanilla body and hair this way): leave
|
||||
// it to them, or the revert would show it.
|
||||
if (r.forceRenderingOff) continue;
|
||||
|
||||
m_tracked.Add(r);
|
||||
m_hidden.Add(new HiddenRenderer { Renderer = r, WasEnabled = r.enabled });
|
||||
r.enabled = false;
|
||||
r.forceRenderingOff = true;
|
||||
|
|
@ -132,6 +149,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
m_hidden.Clear();
|
||||
m_tracked.Clear();
|
||||
enabled = false;
|
||||
return restored;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue