From 5ae0dbbf3dc624ad22efdc58df22d862db1e67e4 Mon Sep 17 00:00:00 2001 From: Jackie Liu Date: Sun, 20 Nov 2022 14:36:24 -0800 Subject: [PATCH] Minor tweaks and bug fixes --- Assets/Scripts/Pal3/Actor/ActorFactory.cs | 2 +- .../Scripts/Pal3/Actor/FlyingActorController.cs | 15 +++++++++++++-- Assets/Scripts/Pal3/Actor/HuaYingController.cs | 4 ++-- Assets/Scripts/Pal3/Feature/HotelManager.cs | 4 +++- .../Pal3/Player/PlayerActorNpcInfoFactory.cs | 4 ++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Pal3/Actor/ActorFactory.cs b/Assets/Scripts/Pal3/Actor/ActorFactory.cs index 9e7ceeb1..57b9ccfe 100644 --- a/Assets/Scripts/Pal3/Actor/ActorFactory.cs +++ b/Assets/Scripts/Pal3/Actor/ActorFactory.cs @@ -56,7 +56,7 @@ namespace Pal3.Actor switch (actor.Info.Id) { case (byte)PlayerActorId.TaoZi: - actorGameObject.AddComponent().Init(actor, actionController); + actorGameObject.AddComponent().Init(actor, actorController, actionController); break; } #endif diff --git a/Assets/Scripts/Pal3/Actor/FlyingActorController.cs b/Assets/Scripts/Pal3/Actor/FlyingActorController.cs index ac2bda41..3f694132 100644 --- a/Assets/Scripts/Pal3/Actor/FlyingActorController.cs +++ b/Assets/Scripts/Pal3/Actor/FlyingActorController.cs @@ -10,6 +10,7 @@ namespace Pal3.Actor using Command.InternalCommands; using Command.SceCommands; using Core.GameBox; + using Player; using Script.Waiter; using UnityEngine; @@ -23,11 +24,13 @@ namespace Pal3.Actor private const float MAX_TARGET_DISTANCE = 20f; private Actor _actor; + private ActorController _actorController; private ActorActionController _actionController; - public void Init(Actor actor, ActorActionController actionController) + public void Init(Actor actor, ActorController actorController, ActorActionController actionController) { _actor = actor; + _actorController = actorController; _actionController = actionController; } @@ -47,7 +50,15 @@ namespace Pal3.Actor command.GameBoxXPosition, command.GameBoxYPosition, command.GameBoxZPosition)); - + + // If actor is inactive or at it's init position, just teleport to target position + if (!_actorController.IsActive || + Vector3.Distance(transform.position, PlayerActorNpcInfoFactory.ActorInitPosition) < float.Epsilon) + { + transform.position = targetPosition; + return; + } + // In case the target position is too far away if (Vector3.Distance(transform.position, targetPosition) > MAX_TARGET_DISTANCE) { diff --git a/Assets/Scripts/Pal3/Actor/HuaYingController.cs b/Assets/Scripts/Pal3/Actor/HuaYingController.cs index 80ac72d7..6ebb3e6a 100644 --- a/Assets/Scripts/Pal3/Actor/HuaYingController.cs +++ b/Assets/Scripts/Pal3/Actor/HuaYingController.cs @@ -42,11 +42,11 @@ namespace Pal3.Actor private bool _followTarget = true; private int _currentMode = 1; // defaults to follow target actor - public void Init(Actor actor, + public new void Init(Actor actor, ActorController actorController, ActorActionController actionController) { - base.Init(actor, actionController); + base.Init(actor, actorController, actionController); _actor = actor; _actorController = actorController; _actorActionController = actionController; diff --git a/Assets/Scripts/Pal3/Feature/HotelManager.cs b/Assets/Scripts/Pal3/Feature/HotelManager.cs index 570d0013..725d0464 100644 --- a/Assets/Scripts/Pal3/Feature/HotelManager.cs +++ b/Assets/Scripts/Pal3/Feature/HotelManager.cs @@ -41,6 +41,7 @@ namespace Pal3.Feature { _sceneManager.LoadScene(sceneFileName, sceneName); CommandDispatcher.Instance.Dispatch(new GameStateChangeRequest(GameState.Cutscene)); + CommandDispatcher.Instance.Dispatch(new CameraFadeInCommand()); _scriptManager.AddScript(afterRestTalkScript); } @@ -64,7 +65,8 @@ namespace Pal3.Feature if (vars[ScriptConstants.MainStoryVariableName] == 120301) { vars[ScriptConstants.MainStoryVariableName] = 120302; - _scriptManager.AddScript((uint)command.AfterRestScriptId); + Rest("Q13", "n06", (uint)command.AfterRestScriptId); + CommandDispatcher.Instance.Dispatch(new CameraSetDefaultTransformCommand(2)); } } #elif PAL3A diff --git a/Assets/Scripts/Pal3/Player/PlayerActorNpcInfoFactory.cs b/Assets/Scripts/Pal3/Player/PlayerActorNpcInfoFactory.cs index 912f6c2f..3ea19ee8 100644 --- a/Assets/Scripts/Pal3/Player/PlayerActorNpcInfoFactory.cs +++ b/Assets/Scripts/Pal3/Player/PlayerActorNpcInfoFactory.cs @@ -16,11 +16,11 @@ namespace Pal3.Player public static class PlayerActorNpcInfoFactory { // This is a position that is far away from the camera to prevent glitches. - private static readonly Vector3 InitPosition = new (777f, 777f, 777f); // Unity position + public static readonly Vector3 ActorInitPosition = new (777f, 777f, 777f); // Unity position public static ScnNpcInfo Create(PlayerActorId actorId) { - Vector3 gameBoxInitPosition = GameBoxInterpreter.ToGameBoxPosition(InitPosition); + Vector3 gameBoxInitPosition = GameBoxInterpreter.ToGameBoxPosition(ActorInitPosition); return new ScnNpcInfo {