Merge branch 'fix/ulv-footsteps'
This commit is contained in:
commit
e4694f6cd9
3 changed files with 52 additions and 1 deletions
|
|
@ -383,6 +383,8 @@ namespace RacesOfValheim {
|
||||||
Component animEvent = currentTransformation.GetComponent("AnimEvent");
|
Component animEvent = currentTransformation.GetComponent("AnimEvent");
|
||||||
if (animEvent != null) Destroy(animEvent);
|
if (animEvent != null) Destroy(animEvent);
|
||||||
|
|
||||||
|
FormFootsteps.Detach(currentTransformation, prefabName);
|
||||||
|
|
||||||
// The creature's own animations carry their sounds as events; this is what hears
|
// The creature's own animations carry their sounds as events; this is what hears
|
||||||
// them. On the object that owns the Animator, because that is where Unity delivers
|
// them. On the object that owns the Animator, because that is where Unity delivers
|
||||||
// an animation event - for the wolf that is WolfSmooth, two levels down, not the
|
// an animation event - for the wolf that is WolfSmooth, two levels down, not the
|
||||||
|
|
|
||||||
47
JotunnModStub/Fenrir/FormFootsteps.cs
Normal file
47
JotunnModStub/Fenrir/FormFootsteps.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RacesOfValheim
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stops a Fenrir form's own animations from stepping on the player's FootStep.
|
||||||
|
///
|
||||||
|
/// The form's CharacterAnimEvent resolves its FootStep in Awake, from
|
||||||
|
/// GetComponentInParent<Character>() - and a form parented under the player finds the
|
||||||
|
/// PLAYER. So when the Ulv's 'Run' clip fires FootStep('LeftHand') and FootStep('RightHand')
|
||||||
|
/// for its front paws, vanilla looks for feet with those names on a human rig, finds none, and
|
||||||
|
/// logs "FAiled to find foot:LeftHand" twice per stride. That is the warning a user reported.
|
||||||
|
///
|
||||||
|
/// Nothing is lost by cutting the link. The player's hidden Visual keeps animating (the hider
|
||||||
|
/// only switches renderers off), and FootStep drives its steps from that animator's footstep
|
||||||
|
/// curve, so the form already has footsteps. A form event naming a foot the player does have
|
||||||
|
/// would only play a second step on top of that one.
|
||||||
|
///
|
||||||
|
/// CharacterAnimEvent.FootStep checks m_footStep before calling it, so nulling the field is
|
||||||
|
/// all it takes. It has to happen after Instantiate, which is when that Awake has run.
|
||||||
|
/// </summary>
|
||||||
|
internal static class FormFootsteps
|
||||||
|
{
|
||||||
|
private static readonly HashSet<string> logged = new HashSet<string>();
|
||||||
|
|
||||||
|
public static void Detach(GameObject form, string formName)
|
||||||
|
{
|
||||||
|
if (form == null) return;
|
||||||
|
|
||||||
|
int detached = 0;
|
||||||
|
foreach (CharacterAnimEvent cae in form.GetComponentsInChildren<CharacterAnimEvent>(true))
|
||||||
|
{
|
||||||
|
var field = HarmonyLib.Traverse.Create(cae).Field("m_footStep");
|
||||||
|
if (field.GetValue() == null) continue;
|
||||||
|
field.SetValue(null);
|
||||||
|
detached++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logged.Add(formName))
|
||||||
|
{
|
||||||
|
Jotunn.Logger.LogInfo(
|
||||||
|
$"[FenrirForm] '{formName}': {detached} animation-event receiver(s) cut from the player's FootStep.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -212,7 +212,9 @@ namespace RacesOfValheim
|
||||||
m_currentFormInstance.transform.localRotation = Quaternion.identity;
|
m_currentFormInstance.transform.localRotation = Quaternion.identity;
|
||||||
Component animEvent = m_currentFormInstance.GetComponent("AnimEvent");
|
Component animEvent = m_currentFormInstance.GetComponent("AnimEvent");
|
||||||
if (animEvent != null) Destroy(animEvent);
|
if (animEvent != null) Destroy(animEvent);
|
||||||
|
|
||||||
|
FormFootsteps.Detach(m_currentFormInstance, currentForm);
|
||||||
|
|
||||||
// Clean up colliders on remote visuals
|
// Clean up colliders on remote visuals
|
||||||
foreach (var col in m_currentFormInstance.GetComponentsInChildren<Collider>())
|
foreach (var col in m_currentFormInstance.GetComponentsInChildren<Collider>())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue