Traveler anim fixes (#470)

## Improvements
- `pathToAnimController` now works for `TravelerController` and
`TravelerEyeController`. Means entering dialogue can stop them playing
their instruments, change their animation, and make them look at you.
This commit is contained in:
Will Corby 2022-12-28 14:16:48 -08:00 committed by GitHub
commit f2194d59b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 7 deletions

View File

@ -160,14 +160,48 @@ namespace NewHorizons.Builder.Props
// At most one of these should ever not be null
var nomaiController = character.GetComponent<SolanumAnimController>();
var controller = character.GetComponent<CharacterAnimController>();
var traveler = character.GetComponent<TravelerController>();
var travelerEye = character.GetComponent<TravelerEyeController>();
var lookOnlyWhenTalking = info.lookAtRadius <= 0;
// To have them look when you start talking
if (controller != null)
{
if (controller._dialogueTree != null)
{
controller._dialogueTree.OnStartConversation -= controller.OnStartConversation;
controller._dialogueTree.OnEndConversation -= controller.OnEndConversation;
}
controller._dialogueTree = dialogue;
controller.lookOnlyWhenTalking = lookOnlyWhenTalking;
controller._dialogueTree.OnStartConversation += controller.OnStartConversation;
controller._dialogueTree.OnEndConversation += controller.OnEndConversation;
}
else if (traveler != null)
{
if (traveler._dialogueSystem != null)
{
traveler._dialogueSystem.OnStartConversation -= traveler.OnStartConversation;
traveler._dialogueSystem.OnEndConversation -= traveler.OnEndConversation;
}
traveler._dialogueSystem = dialogue;
traveler._dialogueSystem.OnStartConversation += traveler.OnStartConversation;
traveler._dialogueSystem.OnEndConversation += traveler.OnEndConversation;
}
else if (travelerEye != null)
{
if (travelerEye._dialogueTree != null)
{
travelerEye._dialogueTree.OnStartConversation -= travelerEye.OnStartConversation;
travelerEye._dialogueTree.OnEndConversation -= travelerEye.OnEndConversation;
}
travelerEye._dialogueTree = dialogue;
travelerEye._dialogueTree.OnStartConversation += travelerEye.OnStartConversation;
travelerEye._dialogueTree.OnEndConversation += travelerEye.OnEndConversation;
}
else if (nomaiController != null)
{
@ -179,7 +213,22 @@ namespace NewHorizons.Builder.Props
}
else
{
// TODO: make a custom controller for basic characters to just turn them to face you
// If they have nothing else just put the face player when talking thing on them
character.gameObject.GetAddComponent<FacePlayerWhenTalking>();
}
var facePlayerWhenTalking = character.GetComponent<FacePlayerWhenTalking>();
if (facePlayerWhenTalking != null)
{
if (facePlayerWhenTalking._dialogueTree != null)
{
facePlayerWhenTalking._dialogueTree.OnStartConversation -= facePlayerWhenTalking.OnStartConversation;
facePlayerWhenTalking._dialogueTree.OnEndConversation -= facePlayerWhenTalking.OnEndConversation;
}
facePlayerWhenTalking._dialogueTree = dialogue;
facePlayerWhenTalking._dialogueTree.OnStartConversation += facePlayerWhenTalking.OnStartConversation;
facePlayerWhenTalking._dialogueTree.OnEndConversation += facePlayerWhenTalking.OnEndConversation;
}
if (info.lookAtRadius > 0)

View File

@ -1,13 +1,10 @@
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.Components;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using OWML.Common;
using System;
using OWML.Utils;
using System.Collections.Generic;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using OWML.Utils;
namespace NewHorizons.Builder.Props
{

View File

@ -476,7 +476,9 @@ namespace NewHorizons.External.Modules
/// <summary>
/// If this dialogue is meant for a character, this is the relative path from the planet to that character's
/// CharacterAnimController or SolanumAnimController.
/// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController.
///
/// If none of those components are present it will add a FacePlayerWhenTalking component.
/// </summary>
public string pathToAnimController;

View File

@ -1103,7 +1103,7 @@
},
"pathToAnimController": {
"type": "string",
"description": "If this dialogue is meant for a character, this is the relative path from the planet to that character's\nCharacterAnimController or SolanumAnimController."
"description": "If this dialogue is meant for a character, this is the relative path from the planet to that character's\nCharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController.\n\nIf none of those components are present it will add a FacePlayerWhenTalking component."
},
"position": {
"description": "When you enter into dialogue, you will look here.",