Make hearthian recording actually work

This commit is contained in:
Nick 2023-07-01 19:08:22 -04:00
parent 642f6afdc0
commit f3c953faff
3 changed files with 51 additions and 2 deletions

View File

@ -199,8 +199,31 @@ namespace NewHorizons.Builder.Props
} }
else if (hearthianRecorder != null) else if (hearthianRecorder != null)
{ {
// #520 Delay.FireOnNextUpdate(() =>
hearthianRecorder._characterDialogueTree = dialogue; {
// #520
if (hearthianRecorder._characterDialogueTree != null)
{
hearthianRecorder._characterDialogueTree.OnStartConversation -= hearthianRecorder.OnPlayRecorder;
hearthianRecorder._characterDialogueTree.OnEndConversation -= hearthianRecorder.OnStopRecorder;
}
// Recorder props have their own dialogue on them already
// Make sure to delete it when we're trying to connect new dialogue to it
var existingDialogue = hearthianRecorder.GetComponent<CharacterDialogueTree>();
if (existingDialogue != dialogue && existingDialogue != null)
{
// Can't delete the existing dialogue because its a required component but we can make it unable to select at least
GameObject.Destroy(hearthianRecorder.GetComponent<OWCollider>());
GameObject.Destroy(hearthianRecorder.GetComponent<SphereCollider>());
GameObject.Destroy(existingDialogue._interactVolume);
existingDialogue.enabled = false;
}
hearthianRecorder._characterDialogueTree = dialogue;
hearthianRecorder._characterDialogueTree.OnStartConversation += hearthianRecorder.OnPlayRecorder;
hearthianRecorder._characterDialogueTree.OnEndConversation += hearthianRecorder.OnStopRecorder;
});
} }
else else
{ {

View File

@ -25,6 +25,8 @@ namespace NewHorizons.External.Modules.Props.Dialogue
/// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, /// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking,
/// HearthianRecorderEffects or SolanumAnimController. /// HearthianRecorderEffects or SolanumAnimController.
/// ///
/// If it's a Recorder this will also delete the existing dialogue already attached to that prop.
///
/// If none of those components are present it will add a FacePlayerWhenTalking component. /// If none of those components are present it will add a FacePlayerWhenTalking component.
/// </summary> /// </summary>
public string pathToAnimController; public string pathToAnimController;

View File

@ -0,0 +1,24 @@
using HarmonyLib;
namespace NewHorizons.Patches.DialoguePatches
{
[HarmonyPatch(typeof(HearthianRecorderEffects))]
public static class HearthianRecorderEffectsPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(HearthianRecorderEffects.Awake))]
public static bool HearthianRecorderEffects_Awake(HearthianRecorderEffects __instance)
{
// If we're adding custom dialogue to a recorder the CharacterDialogueTree isn't going to be on the object
if (__instance.GetComponent<CharacterDialogueTree>() == null)
{
__instance.enabled = false;
return false;
}
else
{
return true;
}
}
}
}