diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index d4b5c844..2d0c2bbc 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -160,14 +160,48 @@ namespace NewHorizons.Builder.Props // At most one of these should ever not be null var nomaiController = character.GetComponent(); var controller = character.GetComponent(); + var traveler = character.GetComponent(); + var travelerEye = character.GetComponent(); 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(); + } + + var facePlayerWhenTalking = character.GetComponent(); + 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) diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 3072bb45..27a92187 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -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 { diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index a6058299..3fc44d0c 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -476,7 +476,9 @@ namespace NewHorizons.External.Modules /// /// 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. /// public string pathToAnimController; diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 8da78e60..332e0d4a 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -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.",