This commit is contained in:
Mister_Nebula 2021-11-23 08:41:05 +00:00
parent db6dceec47
commit f35613e23e
5 changed files with 66 additions and 3 deletions

View File

@ -1,5 +1,6 @@
using QSB.Animation.NPC.WorldObjects;
using QSB.Events;
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.Animation.NPC.Events
@ -26,9 +27,11 @@ namespace QSB.Animation.NPC.Events
switch (message.AnimationEvent)
{
case AnimationEvent.StartConversation:
DebugLog.DebugWrite($"Start conversation");
qsbObj.StartConversation();
break;
case AnimationEvent.EndConversation:
DebugLog.DebugWrite($"End conversation");
qsbObj.EndConversation();
break;
}

View File

@ -0,0 +1,58 @@
using HarmonyLib;
using QSB.Patches;
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QSB.Animation.NPC.Patches
{
[HarmonyPatch(typeof(TravelerController))]
public class TravelerControllerPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(nameof(TravelerController.OnStartConversation))]
public static bool OnStartConversation(TravelerController __instance)
{
DebugLog.DebugWrite($"{__instance.name} OnStartConversation");
__instance._talking = true;
if (__instance._animator != null && __instance._animator.enabled)
{
__instance._playingAnimID = __instance._animator.IsInTransition(0)
? __instance._animator.GetNextAnimatorStateInfo(0).fullPathHash
: __instance._animator.GetCurrentAnimatorStateInfo(0).fullPathHash;
__instance._animator.SetTrigger("Talking");
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(TravelerController.OnEndConversation))]
public static bool OnEndConversation(TravelerController __instance)
{
DebugLog.DebugWrite($"{__instance.name} OnEndConversation");
if (__instance._animator != null && __instance._animator.enabled)
{
if (__instance._delayToRestartAudio > 0f)
{
__instance._animator.CrossFadeInFixedTime(__instance._playingAnimID, __instance._delayToRestartAudio, -1, -__instance._delayToRestartAudio);
}
else
{
__instance._animator.SetTrigger("Playing");
}
}
__instance._talking = false;
return false;
}
}
}

View File

@ -32,9 +32,9 @@ namespace QSB.Animation.NPC.WorldObjects
}
public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject.GetValue<CharacterDialogueTree>("_dialogueTree");
=> AttachedObject._dialogueTree;
public override bool InConversation()
=> AttachedObject.GetValue<bool>("_inConversation");
=> AttachedObject._inConversation;
}
}

View File

@ -76,7 +76,8 @@ namespace QSB.Patches
new LightSensorPatches(),
new AnglerPatches(),
new MeteorClientPatches(),
new MeteorServerPatches()
new MeteorServerPatches(),
new TravelerControllerPatches()
};
TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>

View File

@ -53,6 +53,7 @@
<Compile Include="Animation\NPC\Events\NpcAnimationMessage.cs" />
<Compile Include="Animation\NPC\Patches\CharacterAnimationPatches.cs" />
<Compile Include="Animation\NPC\Patches\SolanumPatches.cs" />
<Compile Include="Animation\NPC\Patches\TravelerControllerPatches.cs" />
<Compile Include="Animation\NPC\WorldObjects\INpcAnimController.cs" />
<Compile Include="Animation\NPC\WorldObjects\NpcAnimController.cs" />
<Compile Include="Animation\NPC\WorldObjects\QSBCharacterAnimController.cs" />