From c3893fbf47646f1adb60b772b82b12fccdbb4013 Mon Sep 17 00:00:00 2001 From: Jiaqi Liu Date: Wed, 2 Aug 2023 19:42:22 -0700 Subject: [PATCH] Implement PAL3A SceneEnableFogCommand + code refactoring - Implement PAL3A SceneEnableFogCommand - Improves logging - Object 46 in scene M03-1 should block player - --- .../Core/DataLoader/AudioClipLoader.cs | 4 +- .../Core/DataLoader/DxtTextureLoader.cs | 2 +- .../Scripts/Core/DataReader/Cpk/CpkArchive.cs | 7 +- .../Core/DataReader/Cpk/CpkConstants.cs | 2 +- Assets/Scripts/Core/DataReader/Cpk/CrcHash.cs | 5 +- .../Scripts/Core/FileSystem/CpkFileSystem.cs | 37 ++++---- .../Scripts/Core/FileSystem/ICpkFileSystem.cs | 5 +- .../Scripts/Core/Services/ServiceLocator.cs | 15 +++- Assets/Scripts/Core/Utils/FpsCounter.cs | 2 +- Assets/Scripts/Core/Utils/Utility.cs | 14 ++- Assets/Scripts/Editor/GameVariantSwitcher.cs | 4 +- Assets/Scripts/Editor/ReleaseBuildPipeline.cs | 28 +++--- .../SourceGenerator/ConsoleCommandsAutoGen.cs | 2 +- .../Editor/SourceGeneratorEditorOptions.cs | 6 +- Assets/Scripts/Pal3/Actor/Actor.cs | 2 +- .../Pal3/Actor/ActorActionController.cs | 2 +- .../Pal3/Actor/ActorMovementController.cs | 6 +- .../SkeletalAnimationActorActionController.cs | 7 +- .../VertexAnimationActorActionController.cs | 9 +- .../Scripts/Pal3/Command/CommandDispatcher.cs | 4 +- .../Pal3/Command/CommandExecutorRegistry.cs | 12 +-- .../Pal3/Command/ConsoleCommands.PAL3A.g.cs | 16 ++-- .../SceCommands/SceneEnableFogCommand.cs | 42 +++++++++ ....cs.meta => SceneEnableFogCommand.cs.meta} | 0 .../Command/SceCommands/UnknownCommand162.cs | 40 --------- .../Pal3/Data/FileSystemCacheManager.cs | 8 +- .../Scripts/Pal3/Data/GameResourceProvider.cs | 51 +++-------- Assets/Scripts/Pal3/Data/TextureCache.cs | 5 +- Assets/Scripts/Pal3/Data/TextureProvider.cs | 18 ++-- .../Pal3/Dev/UnknownSceCommandAnalyzer.cs | 5 +- Assets/Scripts/Pal3/Effect/FireEffect.cs | 3 +- .../Pal3/GamePlay/PlayerGamePlayController.cs | 8 +- .../Scripts/Pal3/GameResourceInitializer.cs | 26 +++--- .../Pal3/GameSystem/DialogueManager.cs | 2 +- .../Scripts/Pal3/GameSystem/FavorManager.cs | 2 +- .../Pal3/GameSystem/InventoryManager.cs | 6 +- Assets/Scripts/Pal3/GameSystem/TeamManager.cs | 4 +- .../Scripts/Pal3/Input/PlayerInputActions.cs | 2 +- .../Scripts/Pal3/MetaData/EffectConstants.cs | 32 +++---- Assets/Scripts/Pal3/MetaData/FileConstants.cs | 86 +++++++++---------- Assets/Scripts/Pal3/Pal3.cs | 5 ++ .../Scripts/Pal3/Renderer/CvdModelRenderer.cs | 2 +- Assets/Scripts/Pal3/Scene/Scene.cs | 36 ++++++-- Assets/Scripts/Pal3/Scene/SceneBase.cs | 6 +- Assets/Scripts/Pal3/Scene/SceneManager.cs | 4 +- .../Scripts/Pal3/Scene/SceneObjectFactory.cs | 2 +- .../Scene/SceneObjects/ClimbableObject.cs | 2 +- .../Scene/SceneObjects/GeneralSceneObject.cs | 5 ++ .../Scene/SceneObjects/ImpulsiveObject.cs | 3 +- .../Scene/SceneObjects/RotatingWallObject.cs | 3 +- .../Pal3/Scene/SceneObjects/SceneObject.cs | 11 ++- .../Pal3/Scene/SceneObjects/SwitchObject.cs | 2 +- Assets/Scripts/Pal3/Scene/Tilemap.cs | 6 +- Assets/Scripts/Pal3/Script/PalScriptRunner.cs | 9 +- Assets/Scripts/Pal3/Script/ScriptManager.cs | 16 ++-- Assets/Scripts/Pal3/Settings/GameSettings.cs | 25 ++++-- .../Scripts/Pal3/Settings/PlayerPrefsStore.cs | 2 +- Assets/Scripts/Pal3/State/GameStateManager.cs | 2 +- Assets/Scripts/Pal3/State/SaveManager.cs | 6 +- .../Pal3/UI/RoundedFrostedGlassImage.cs | 2 +- Assets/Scripts/Pal3/Video/VideoManager.cs | 2 +- .../ResourceViewer/GameResourceViewer.cs | 30 +++---- Packages/manifest.json | 1 + Packages/packages-lock.json | 7 ++ 64 files changed, 384 insertions(+), 336 deletions(-) create mode 100644 Assets/Scripts/Pal3/Command/SceCommands/SceneEnableFogCommand.cs rename Assets/Scripts/Pal3/Command/SceCommands/{UnknownCommand162.cs.meta => SceneEnableFogCommand.cs.meta} (100%) delete mode 100644 Assets/Scripts/Pal3/Command/SceCommands/UnknownCommand162.cs diff --git a/Assets/Scripts/Core/DataLoader/AudioClipLoader.cs b/Assets/Scripts/Core/DataLoader/AudioClipLoader.cs index 8a69419e4..b612e6d21 100644 --- a/Assets/Scripts/Core/DataLoader/AudioClipLoader.cs +++ b/Assets/Scripts/Core/DataLoader/AudioClipLoader.cs @@ -34,7 +34,7 @@ public static IEnumerator LoadAudioClipAsync(string filePath, if (request.result == UnityWebRequest.Result.ConnectionError) { - Debug.LogError($"Failed to load {url} with error: {request.error}"); + Debug.LogError($"[{nameof(AudioClipLoader)}] Failed to load {url} with error: {request.error}"); } else { @@ -49,7 +49,7 @@ public static IEnumerator LoadAudioClipAsync(string filePath, } catch (Exception ex) { - Debug.LogError($"Failed to get audio clip: {filePath} with exception: {ex}"); + Debug.LogError($"[{nameof(AudioClipLoader)}] Failed to get audio clip: {filePath} with exception: {ex}"); } } } diff --git a/Assets/Scripts/Core/DataLoader/DxtTextureLoader.cs b/Assets/Scripts/Core/DataLoader/DxtTextureLoader.cs index 88b6a4b49..989e8a997 100644 --- a/Assets/Scripts/Core/DataLoader/DxtTextureLoader.cs +++ b/Assets/Scripts/Core/DataLoader/DxtTextureLoader.cs @@ -57,7 +57,7 @@ private bool IsValidDxtFile(BinaryReader reader) { var header = new string(reader.ReadChars(4)); if (header == "DDS ") return true; - Debug.Log($"Invalid DXT header: {header}"); + Debug.Log($"[{nameof(DxtTextureLoader)}] Invalid DXT header: {header}"); return false; } diff --git a/Assets/Scripts/Core/DataReader/Cpk/CpkArchive.cs b/Assets/Scripts/Core/DataReader/Cpk/CpkArchive.cs index f971f1869..7a2514210 100644 --- a/Assets/Scripts/Core/DataReader/Cpk/CpkArchive.cs +++ b/Assets/Scripts/Core/DataReader/Cpk/CpkArchive.cs @@ -107,7 +107,7 @@ private void ExtractToInternal(string outputFolder, IEnumerable nodes) foreach (CpkEntry node in nodes) { var relativePath = node.VirtualPath.Replace( - CpkConstants.DirectorySeparator, Path.DirectorySeparatorChar); + CpkConstants.DirectorySeparatorChar, Path.DirectorySeparatorChar); if (node.IsDirectory) { @@ -313,7 +313,10 @@ private IEnumerable GetChildren(uint fatherCrc, string rootPath = "") yield break; } - if (rootPath != string.Empty) rootPath += CpkConstants.DirectorySeparator; + if (!string.IsNullOrEmpty(rootPath)) + { + rootPath += CpkConstants.DirectorySeparatorChar; + } foreach (var childCrc in _fatherCrcToChildCrcTableIndexMap[fatherCrc]) { diff --git a/Assets/Scripts/Core/DataReader/Cpk/CpkConstants.cs b/Assets/Scripts/Core/DataReader/Cpk/CpkConstants.cs index 270e95633..49e06d182 100644 --- a/Assets/Scripts/Core/DataReader/Cpk/CpkConstants.cs +++ b/Assets/Scripts/Core/DataReader/Cpk/CpkConstants.cs @@ -7,7 +7,7 @@ namespace Core.DataReader.Cpk { public static class CpkConstants { - public const char DirectorySeparator = '\\'; + public const char DirectorySeparatorChar = '\\'; public const string FileExtension = ".cpk"; } diff --git a/Assets/Scripts/Core/DataReader/Cpk/CrcHash.cs b/Assets/Scripts/Core/DataReader/Cpk/CrcHash.cs index 3eff96f79..74be4c7a1 100644 --- a/Assets/Scripts/Core/DataReader/Cpk/CrcHash.cs +++ b/Assets/Scripts/Core/DataReader/Cpk/CrcHash.cs @@ -8,6 +8,7 @@ namespace Core.DataReader.Cpk using System; using System.Collections.Generic; using System.Text; + using UnityEngine; /// /// Crc32 hash provider. @@ -39,6 +40,8 @@ public void Init() } _initialized = true; + + Debug.Log($"[{nameof(Crc32Hash)}] CRC32 table initialized."); } public uint Compute(string str, int codepage, bool useCache = true) @@ -64,7 +67,7 @@ public uint Compute(string str, int codepage, bool useCache = true) private unsafe uint ComputeInternal(byte[] data) { - if (!_initialized) throw new InvalidOperationException("CrcHash not initialized yet."); + if (!_initialized) throw new InvalidOperationException($"{nameof(Crc32Hash)} not initialized yet."); if (data == null || data.Length == 0 || data[0] == 0) { diff --git a/Assets/Scripts/Core/FileSystem/CpkFileSystem.cs b/Assets/Scripts/Core/FileSystem/CpkFileSystem.cs index 9e35dc5ea..1bef9efba 100644 --- a/Assets/Scripts/Core/FileSystem/CpkFileSystem.cs +++ b/Assets/Scripts/Core/FileSystem/CpkFileSystem.cs @@ -59,15 +59,15 @@ public string GetRootPath() /// Codepage CPK file uses for encoding text info public void Mount(string cpkFileRelativePath, int codepage) { - var cpkFileName = Path.GetFileName(cpkFileRelativePath).ToLower(); + var cpkFileName = Utility.GetFileName(cpkFileRelativePath, Path.DirectorySeparatorChar).ToLower(); if (_cpkArchives.ContainsKey(cpkFileName)) { - Debug.LogWarning($"{cpkFileRelativePath} already mounted."); + Debug.LogWarning($"[{nameof(CpkFileSystem)}] {cpkFileRelativePath} already mounted."); return; } - Debug.Log($"CpkFileSystem mounting: {_rootPath + cpkFileRelativePath}"); + Debug.Log($"[{nameof(CpkFileSystem)}] Mounting: {_rootPath + cpkFileRelativePath}"); var cpkArchive = new CpkArchive(_rootPath + cpkFileRelativePath, _crcHash, codepage); cpkArchive.Init(); _cpkArchives[cpkFileName] = cpkArchive; @@ -76,7 +76,7 @@ public void Mount(string cpkFileRelativePath, int codepage) /// /// Check if file exists in any of the segmented archives using virtual path. /// - /// File virtual path {Cpk file name}.cpk\{File relative path inside archive} + /// File virtual path {Cpk file name}\{File relative path inside archive} /// Name of the segmented archive if exists /// True if file exists in segmented archive public bool FileExistsInSegmentedArchive(string fileVirtualPath, out string segmentedArchiveName) @@ -108,7 +108,7 @@ public bool FileExistsInSegmentedArchive(string fileVirtualPath, out string segm /// /// Check if file exists in the archive using virtual path. /// - /// File virtual path {Cpk file name}.cpk\{File relative path inside archive} + /// File virtual path {Cpk file name}\{File relative path inside archive} /// Example: music.cpk\music\PI01.mp3 /// True if file exists public bool FileExists(string fileVirtualPath) @@ -168,12 +168,12 @@ public void LoadArchiveIntoMemory(string cpkFileName) { if (_cpkArchives.ContainsKey(cpkFileName.ToLower())) { - Debug.Log($"File system caching {cpkFileName} into memory."); + Debug.Log($"[{nameof(CpkFileSystem)}] Caching {cpkFileName} archive into memory."); _cpkArchives[cpkFileName.ToLower()].LoadArchiveIntoMemory(); } else { - throw new Exception($"{cpkFileName} not mounted yet."); + throw new Exception($"{cpkFileName} archive not mounted yet."); } } @@ -184,12 +184,12 @@ public void DisposeInMemoryArchive(string cpkFileName) { if (_cpkArchives.ContainsKey(cpkFileName.ToLower())) { - Debug.Log($"File system disposing in-memory cache: {cpkFileName}"); + Debug.Log($"[{nameof(CpkFileSystem)}] Disposing in-memory cache: {cpkFileName}"); _cpkArchives[cpkFileName.ToLower()].DisposeInMemoryArchive(); } else { - throw new Exception($"{cpkFileName} not mounted yet."); + throw new Exception($"{cpkFileName} archive not mounted yet."); } } @@ -219,7 +219,7 @@ public void ExtractTo(string outputFolder) } cpkArchive.ExtractTo(outputDir); - Debug.Log($"{cpkFileName} extracted to {outputDir}"); + Debug.Log($"[{nameof(CpkFileSystem)}] {cpkFileName} extracted to {outputDir}"); } } @@ -236,7 +236,7 @@ public IEnumerable Search(string keyword = "") { var rootNodes = archive.Value.GetRootEntries(); results.Add(from result in SearchInternal(rootNodes, keyword) - select archive.Key + CpkConstants.DirectorySeparator + result); + select archive.Key + CpkConstants.DirectorySeparatorChar + result); }); var resultList = new List(); @@ -247,14 +247,21 @@ public IEnumerable Search(string keyword = "") return resultList; } + /// + /// Parse file virtual path into cpk file name and relative virtual path. + /// + /// File virtual path {Cpk file name}\{File relative path inside archive} + /// {Cpk file name} + /// {File relative path inside archive} private void ParseFileVirtualPath(string fullVirtualPath, out string cpkFileName, out string relativeVirtualPath) { - if (!fullVirtualPath.Contains(CpkConstants.DirectorySeparator)) + if (!fullVirtualPath.Contains(CpkConstants.DirectorySeparatorChar)) { - throw new ArgumentException($"File virtual path is invalid: {fullVirtualPath}."); + throw new ArgumentException($"[{nameof(CpkFileSystem)}] File virtual path is invalid: {fullVirtualPath}."); } - cpkFileName = fullVirtualPath[..fullVirtualPath.IndexOf(CpkConstants.DirectorySeparator)].ToLower(); - relativeVirtualPath = fullVirtualPath[(fullVirtualPath.IndexOf(CpkConstants.DirectorySeparator) + 1)..]; + + cpkFileName = fullVirtualPath[..fullVirtualPath.IndexOf(CpkConstants.DirectorySeparatorChar)].ToLower(); + relativeVirtualPath = fullVirtualPath[(fullVirtualPath.IndexOf(CpkConstants.DirectorySeparatorChar) + 1)..]; } private IEnumerable SearchInternal(IEnumerable nodes, string keyword) diff --git a/Assets/Scripts/Core/FileSystem/ICpkFileSystem.cs b/Assets/Scripts/Core/FileSystem/ICpkFileSystem.cs index e84bf0d6f..8c9adb01e 100644 --- a/Assets/Scripts/Core/FileSystem/ICpkFileSystem.cs +++ b/Assets/Scripts/Core/FileSystem/ICpkFileSystem.cs @@ -6,7 +6,6 @@ namespace Core.FileSystem { using System.Collections.Generic; - using System.IO; /// /// File system wrapper for CPack archives @@ -29,7 +28,7 @@ public interface ICpkFileSystem /// /// Check if file exists in any of the segmented archives using virtual path. /// - /// File virtual path {Cpk file name}.cpk\{File relative path inside archive} + /// File virtual path {Cpk file name}\{File relative path inside archive} /// Name of the segmented archive if exists /// True if file exists in segmented archive public bool FileExistsInSegmentedArchive(string fileVirtualPath, out string segmentedArchiveName); @@ -37,7 +36,7 @@ public interface ICpkFileSystem /// /// Check if file exists in the archive using virtual path. /// - /// File virtual path {Cpk file name}.cpk\{File relative path inside archive} + /// File virtual path {Cpk file name}\{File relative path inside archive} /// Example: music.cpk\music\PI01.mp3 /// True if file exists public bool FileExists(string fileVirtualPath); diff --git a/Assets/Scripts/Core/Services/ServiceLocator.cs b/Assets/Scripts/Core/Services/ServiceLocator.cs index 64bed28ca..a70dbe851 100644 --- a/Assets/Scripts/Core/Services/ServiceLocator.cs +++ b/Assets/Scripts/Core/Services/ServiceLocator.cs @@ -30,7 +30,7 @@ public T Get() { if (!_services.ContainsKey(typeof(T))) { - string error = $"{typeof(T)} not registered with {GetType().Name}"; + string error = $"[{nameof(ServiceLocator)}] {typeof(T)} is not registered with name: {GetType().Name}"; Debug.LogError(error); throw new InvalidOperationException(error); } @@ -50,9 +50,13 @@ public void Register(T service) if (_services.ContainsKey(typeof(T))) { - Debug.LogWarning($"{typeof(T)} already registered."); + Debug.LogWarning($"[{nameof(ServiceLocator)}] {typeof(T)} already registered."); return; } + else + { + Debug.Log($"[{nameof(ServiceLocator)}] Service type {typeof(T)} registered."); + } _services.Add(typeof(T), service); } @@ -65,9 +69,13 @@ public void Unregister() { if (!_services.ContainsKey(typeof(T))) { - Debug.LogWarning($"Failed to unregister since {typeof(T)} is not registered yet."); + Debug.LogWarning($"[{nameof(ServiceLocator)}] Failed to unregister service since {typeof(T)} is not registered yet."); return; } + else + { + Debug.Log($"[{nameof(ServiceLocator)}] Service type {typeof(T)} unregistered."); + } _services.Remove(typeof(T)); } @@ -77,6 +85,7 @@ public void Unregister() /// public void UnregisterAll() { + Debug.Log($"[{nameof(ServiceLocator)}] All services unregistered."); _services.Clear(); } } diff --git a/Assets/Scripts/Core/Utils/FpsCounter.cs b/Assets/Scripts/Core/Utils/FpsCounter.cs index 12fb28cd4..8ab68de95 100644 --- a/Assets/Scripts/Core/Utils/FpsCounter.cs +++ b/Assets/Scripts/Core/Utils/FpsCounter.cs @@ -9,7 +9,7 @@ namespace Core.Utils public class FpsCounter : MonoBehaviour { - private const float UPDATE_INTERVAL = 0.2f; + private const float UPDATE_INTERVAL = 0.1f; private int _frameCount = 0; private float _deltaTime = 0f; diff --git a/Assets/Scripts/Core/Utils/Utility.cs b/Assets/Scripts/Core/Utils/Utility.cs index eded3f74e..7c0255808 100644 --- a/Assets/Scripts/Core/Utils/Utility.cs +++ b/Assets/Scripts/Core/Utils/Utility.cs @@ -116,20 +116,18 @@ public static void Rgb565ToRgb888(ushort rgb565Color, out byte r, out byte g, ou b = (byte) ((temp / 32 + temp) / 32); } - public static string GetRelativeDirectoryPath(string filePath, - char directoryPathSeparator = CpkConstants.DirectorySeparator) + public static string GetDirectoryName(string filePath, char directorySeparatorChar) { - return !filePath.Contains(directoryPathSeparator) ? + return !filePath.Contains(directorySeparatorChar) ? string.Empty : - filePath[..filePath.LastIndexOf(directoryPathSeparator)]; + filePath[..filePath.LastIndexOf(directorySeparatorChar)]; } - public static string GetFileName(string filePath, - char directoryPathSeparator = CpkConstants.DirectorySeparator) + public static string GetFileName(string filePath, char directorySeparatorChar) { - return !filePath.Contains(directoryPathSeparator) ? + return !filePath.Contains(directorySeparatorChar) ? string.Empty : - filePath[(filePath.LastIndexOf(directoryPathSeparator)+1)..]; + filePath[(filePath.LastIndexOf(directorySeparatorChar)+1)..]; } public static bool IsHandheldDevice() diff --git a/Assets/Scripts/Editor/GameVariantSwitcher.cs b/Assets/Scripts/Editor/GameVariantSwitcher.cs index 750834f30..5d42dd884 100644 --- a/Assets/Scripts/Editor/GameVariantSwitcher.cs +++ b/Assets/Scripts/Editor/GameVariantSwitcher.cs @@ -26,7 +26,7 @@ public static void SwitchToPal3() ApplyPlayerSettingsForVariant("PAL3"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - Debug.Log("Switched to PAL3"); + Debug.Log($"[{nameof(GameVariantSwitcher)}] Switched to PAL3"); } #if PAL3 @@ -51,7 +51,7 @@ public static void SwitchToPal3A() ApplyPlayerSettingsForVariant("PAL3A"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - Debug.Log("Switched to PAL3A"); + Debug.Log($"[{nameof(GameVariantSwitcher)}] Switched to PAL3A"); } #if PAL3 diff --git a/Assets/Scripts/Editor/ReleaseBuildPipeline.cs b/Assets/Scripts/Editor/ReleaseBuildPipeline.cs index 3af5fcf33..de86e60dd 100644 --- a/Assets/Scripts/Editor/ReleaseBuildPipeline.cs +++ b/Assets/Scripts/Editor/ReleaseBuildPipeline.cs @@ -34,7 +34,7 @@ public static class ReleaseBuildPipeline { private static readonly string[] BuildLevels = { "Assets/Scenes/Game.unity" }; - private static readonly char PathSeparator = Path.DirectorySeparatorChar; + private static readonly char DirSeparator = Path.DirectorySeparatorChar; #if PAL3 [MenuItem("PAL3/Build Pipelines/Build [Windows_x86] IL2CPP Release Executable")] @@ -129,7 +129,7 @@ private static void BuildGame(Pal3BuildTarget buildTarget) string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", ""); if (string.IsNullOrWhiteSpace(buildOutputPath)) return; - buildOutputPath += $"{PathSeparator}{PlayerSettings.bundleVersion}{PathSeparator}"; + buildOutputPath += $"{DirSeparator}{PlayerSettings.bundleVersion}{DirSeparator}"; var buildConfigurations = new[] { @@ -162,7 +162,7 @@ private static void BuildGame(Pal3BuildTarget buildTarget) // Execute report log actions logActions.ForEach(action => action.Invoke()); - Debug.Log($"Build for version {PlayerSettings.bundleVersion} complete! Output path: " + + Debug.Log($"[{nameof(ReleaseBuildPipeline)}] Build for version {PlayerSettings.bundleVersion} complete! Output path: " + $"{buildOutputPath}{GameConstants.AppName}"); } @@ -174,14 +174,14 @@ private static void Build(string folderName, List logActions, bool deletePdbFiles = true) { - string outputFolder = buildOutputPath + $"{GameConstants.AppName}{PathSeparator}" + - $"{folderName}{PathSeparator}"; + string outputFolder = buildOutputPath + $"{GameConstants.AppName}{DirSeparator}" + + $"{folderName}{DirSeparator}"; if (buildTarget is BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64 or BuildTarget.StandaloneLinux64) { - outputFolder += $"{GameConstants.AppName}{PathSeparator}"; + outputFolder += $"{GameConstants.AppName}{DirSeparator}"; } else if (buildTarget is BuildTarget.StandaloneOSX) { @@ -211,7 +211,7 @@ private static void WriteBuildReport(BuildReport report, List logActions switch (report.summary.result) { case BuildResult.Succeeded: - string successReport = $"Build [{report.summary.platform}] succeeded. " + + string successReport = $"[{nameof(ReleaseBuildPipeline)}] Build [{report.summary.platform}] succeeded. " + $"Finished in {report.summary.totalTime.TotalMinutes:F2} minutes. " + $"Build size: {(report.summary.totalSize / 1024f / 1024f):F2} MB"; logActions.Add(() => Debug.Log(successReport)); @@ -244,22 +244,22 @@ private static void ZipReleaseFiles() return; } - string releaseDirPath = $"{buildOutputPath}{PathSeparator}Release"; + string releaseDirPath = $"{buildOutputPath}{DirSeparator}Release"; Directory.CreateDirectory(releaseDirPath); List<(string FolderPath, Pal3BuildTarget Target)> buildTargets = new() { - ($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Android.ToString()}{PathSeparator}{GameConstants.AppName}.apk", Pal3BuildTarget.Android), - ($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Windows_x86.ToString()}", Pal3BuildTarget.Windows_x86), - ($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Windows_x64.ToString()}", Pal3BuildTarget.Windows_x64), - ($"{GameConstants.AppName}{PathSeparator}{Pal3BuildTarget.Linux_x86_x64.ToString()}", Pal3BuildTarget.Linux_x86_x64) + ($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Android.ToString()}{DirSeparator}{GameConstants.AppName}.apk", Pal3BuildTarget.Android), + ($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Windows_x86.ToString()}", Pal3BuildTarget.Windows_x86), + ($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Windows_x64.ToString()}", Pal3BuildTarget.Windows_x64), + ($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Linux_x86_x64.ToString()}", Pal3BuildTarget.Linux_x86_x64) }; foreach ((string folderPath, Pal3BuildTarget target) in buildTargets) { - string fullPath = $"{buildOutputPath}{PathSeparator}{folderPath}"; + string fullPath = $"{buildOutputPath}{DirSeparator}{folderPath}"; string zipFileName = $"{GameConstants.AppName}_v{PlayerSettings.bundleVersion}_{target.ToString()}.zip"; - string zipFilePath = $"{releaseDirPath}{PathSeparator}{zipFileName}"; + string zipFilePath = $"{releaseDirPath}{DirSeparator}{zipFileName}"; if (File.Exists(fullPath) || Directory.Exists(fullPath)) { diff --git a/Assets/Scripts/Editor/SourceGenerator/ConsoleCommandsAutoGen.cs b/Assets/Scripts/Editor/SourceGenerator/ConsoleCommandsAutoGen.cs index 451dfe542..7ea7d7df8 100644 --- a/Assets/Scripts/Editor/SourceGenerator/ConsoleCommandsAutoGen.cs +++ b/Assets/Scripts/Editor/SourceGenerator/ConsoleCommandsAutoGen.cs @@ -48,7 +48,7 @@ public void GenerateSourceClass(CodeWriter writer, string className, string name var commands = Utility.GetTypesOfInterface(commandInterfaceType) .Where(IsCommandAvailableInConsole).ToArray(); - Debug.Log($"Found {commands.Length} available console commands"); + Debug.Log($"[{nameof(ConsoleCommandsAutoGen)}] Found {commands.Length} available console commands"); for (var i = 0; i < commands.Length; i++) { diff --git a/Assets/Scripts/Editor/SourceGeneratorEditorOptions.cs b/Assets/Scripts/Editor/SourceGeneratorEditorOptions.cs index 0abe98707..47a604061 100644 --- a/Assets/Scripts/Editor/SourceGeneratorEditorOptions.cs +++ b/Assets/Scripts/Editor/SourceGeneratorEditorOptions.cs @@ -46,11 +46,11 @@ private static void GenerateSourceInternal(string fileName, { if (!overwrite && File.Exists(writePath)) { - Debug.LogError($"File already generated: {writePath}\n"); + Debug.LogError($"[{nameof(SourceGeneratorEditorOptions)}] File already generated: {writePath}\n"); return; } - Debug.Log("Generating source file: " + writePath); + Debug.Log($"[{nameof(SourceGeneratorEditorOptions)}] Generating source file: " + writePath); var writer = new CodeWriter { @@ -67,7 +67,7 @@ private static void GenerateSourceInternal(string fileName, using StreamWriter sw = new StreamWriter(writePath); sw.Write(output); - Debug.Log($"{fileName} generated."); + Debug.Log($"[{nameof(SourceGeneratorEditorOptions)}] {fileName} generated."); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); diff --git a/Assets/Scripts/Pal3/Actor/Actor.cs b/Assets/Scripts/Pal3/Actor/Actor.cs index 19a98fde2..a88f57ed7 100644 --- a/Assets/Scripts/Pal3/Actor/Actor.cs +++ b/Assets/Scripts/Pal3/Actor/Actor.cs @@ -66,7 +66,7 @@ public string GetIdleAction() return ActorConstants.ActionToNameMap[ActorActionType.NpcStand2]; } - Debug.LogError($"No default idle animation found for {Info.Id}_{Info.Name}"); + Debug.LogError($"[{nameof(Actor)}] No default idle animation found for {Info.Id}_{Info.Name}"); return ActorConstants.ActionToNameMap[ActorActionType.NpcStand1]; } diff --git a/Assets/Scripts/Pal3/Actor/ActorActionController.cs b/Assets/Scripts/Pal3/Actor/ActorActionController.cs index 88ef0a62d..c6689d892 100644 --- a/Assets/Scripts/Pal3/Actor/ActorActionController.cs +++ b/Assets/Scripts/Pal3/Actor/ActorActionController.cs @@ -291,7 +291,7 @@ public void Execute(ActorPerformActionCommand command) { if (!_actor.IsActive && !_actor.IsMainActor()) { - Debug.LogError($"Failed to perform action since actor {command.ActorId} is inactive."); + Debug.LogError($"[{nameof(ActorActionController)}] Failed to perform action since actor {command.ActorId} is inactive."); return; } diff --git a/Assets/Scripts/Pal3/Actor/ActorMovementController.cs b/Assets/Scripts/Pal3/Actor/ActorMovementController.cs index c16080211..5c2207a81 100644 --- a/Assets/Scripts/Pal3/Actor/ActorMovementController.cs +++ b/Assets/Scripts/Pal3/Actor/ActorMovementController.cs @@ -405,7 +405,7 @@ public void PortalToPosition(Vector3 position, int layerIndex, bool isPositionOn SetNavLayer(layerIndex); transform.position = position; - Debug.LogWarning($"Portal to standing platform: {position}, " + + Debug.LogWarning($"[{nameof(ActorMovementController)}] Portal to standing platform: {position}, " + $"layer: {layerIndex}"); } else if (_tilemap.TryGetTile(position, layerIndex, out NavTile tile) && tile.IsWalkable()) @@ -419,7 +419,7 @@ public void PortalToPosition(Vector3 position, int layerIndex, bool isPositionOn position.z); Vector2Int tilePosition = _tilemap.GetTilePosition(position, layerIndex); - Debug.LogWarning($"Portal to: {position}, " + + Debug.LogWarning($"[{nameof(ActorMovementController)}] Portal to: {position}, " + $"layer: {layerIndex}, " + $"tile: {tilePosition} DistanceToNearestObstacle: {tile.DistanceToNearestObstacle}, FloorKind: {tile.FloorKind}"); } @@ -784,7 +784,7 @@ private IEnumerator FindPathAndMoveToTilePositionAsync(Vector2Int toTilePosition else { _movementWaiter?.CancelWait(); - Debug.LogError($"Failed to find path from tile position {fromTilePosition} " + + Debug.LogError($"[{nameof(ActorMovementController)}] Failed to find path from tile position {fromTilePosition} " + $"to tile position: {toTilePosition}"); } yield break; diff --git a/Assets/Scripts/Pal3/Actor/SkeletalAnimationActorActionController.cs b/Assets/Scripts/Pal3/Actor/SkeletalAnimationActorActionController.cs index 174156d0e..1afd2643e 100644 --- a/Assets/Scripts/Pal3/Actor/SkeletalAnimationActorActionController.cs +++ b/Assets/Scripts/Pal3/Actor/SkeletalAnimationActorActionController.cs @@ -9,6 +9,7 @@ namespace Pal3.Actor using Command; using Command.SceCommands; using Core.DataLoader; + using Core.DataReader.Cpk; using Core.DataReader.Mov; using Core.DataReader.Msh; using Core.DataReader.Mtl; @@ -73,7 +74,7 @@ public override void PerformAction(string actionName, if (!_actor.HasAction(actionName)) { - Debug.LogError($"Action {actionName} not found for actor {_actor.Info.Name}."); + Debug.LogError($"[{nameof(SkeletalAnimationActorActionController)}] Action {actionName} not found for actor {_actor.Info.Name}."); waiter?.CancelWait(); return; } @@ -94,11 +95,11 @@ public override void PerformAction(string actionName, movFile = _resourceProvider.GetGameResourceFile(movFilePath); textureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(mtlFilePath)); + Utility.GetDirectoryName(mtlFilePath, CpkConstants.DirectorySeparatorChar)); } catch (Exception ex) { - Debug.LogError(ex); + Debug.LogError($"[{nameof(SkeletalAnimationActorActionController)}] Exception: {ex}"); waiter?.CancelWait(); return; } diff --git a/Assets/Scripts/Pal3/Actor/VertexAnimationActorActionController.cs b/Assets/Scripts/Pal3/Actor/VertexAnimationActorActionController.cs index 11f8efba4..458865049 100644 --- a/Assets/Scripts/Pal3/Actor/VertexAnimationActorActionController.cs +++ b/Assets/Scripts/Pal3/Actor/VertexAnimationActorActionController.cs @@ -10,6 +10,7 @@ namespace Pal3.Actor using Command.InternalCommands; using Command.SceCommands; using Core.DataLoader; + using Core.DataReader.Cpk; using Core.DataReader.Mv3; using Core.DataReader.Pol; using Core.DataReader.Scn; @@ -97,7 +98,7 @@ public override void PerformAction(string actionName, if (!_actor.HasAction(actionName)) { - Debug.LogError($"Action {actionName} not found for actor {_actor.Info.Name}."); + Debug.LogError($"[{nameof(VertexAnimationActorActionController)}] Action {actionName} not found for actor {_actor.Info.Name}."); _animationLoopPointWaiter?.CancelWait(); waiter?.CancelWait(); return; @@ -110,11 +111,11 @@ public override void PerformAction(string actionName, string mv3FilePath = _actor.GetActionFilePath(actionName); mv3File = _resourceProvider.GetGameResourceFile(mv3FilePath); textureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(mv3FilePath)); + Utility.GetDirectoryName(mv3FilePath, CpkConstants.DirectorySeparatorChar)); } catch (Exception ex) { - Debug.LogError(ex); + Debug.LogError($"[{nameof(VertexAnimationActorActionController)}] Exception: {ex}"); _animationLoopPointWaiter?.CancelWait(); waiter?.CancelWait(); return; @@ -136,7 +137,7 @@ public override void PerformAction(string actionName, string weaponPath = FileConstants.GetWeaponModelFileVirtualPath(weaponName); PolFile polFile = _resourceProvider.GetGameResourceFile(weaponPath); ITextureResourceProvider weaponTextureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(weaponPath)); + Utility.GetDirectoryName(weaponPath, CpkConstants.DirectorySeparatorChar)); _mv3ModelRenderer.Init(mv3File, _materialFactory, textureProvider, diff --git a/Assets/Scripts/Pal3/Command/CommandDispatcher.cs b/Assets/Scripts/Pal3/Command/CommandDispatcher.cs index 55406f384..c75603a55 100644 --- a/Assets/Scripts/Pal3/Command/CommandDispatcher.cs +++ b/Assets/Scripts/Pal3/Command/CommandDispatcher.cs @@ -48,7 +48,7 @@ public void Dispatch(T command) where T : TCommand } else if (Attribute.GetCustomAttribute(typeof(T), typeof(SceCommandAttribute)) != null) { - Debug.LogWarning($"No command executor found for sce command: {typeof(T).Name}"); + Debug.LogWarning($"[{nameof(CommandDispatcher)}] No command executor found for sce command: {typeof(T).Name}"); } } @@ -74,7 +74,7 @@ public void Dispatch(TCommand command) } else if (Attribute.GetCustomAttribute(command.GetType(), typeof(SceCommandAttribute)) != null) { - Debug.LogWarning($"No command executor found for sce command: {command.GetType().Name}"); + Debug.LogWarning($"[{nameof(CommandDispatcher)}] No command executor found for sce command: {command.GetType().Name}"); } } diff --git a/Assets/Scripts/Pal3/Command/CommandExecutorRegistry.cs b/Assets/Scripts/Pal3/Command/CommandExecutorRegistry.cs index ae2faf918..799eab5f7 100644 --- a/Assets/Scripts/Pal3/Command/CommandExecutorRegistry.cs +++ b/Assets/Scripts/Pal3/Command/CommandExecutorRegistry.cs @@ -30,7 +30,7 @@ public void Register(ICommandExecutor executor) where T : TCommand { if (_executors[typeof(ICommandExecutor)].Contains(executor)) { - Debug.LogError($"Executor already registered: {executor.GetType()}"); + Debug.LogError($"[{nameof(CommandExecutorRegistry)}] Executor already registered: {executor.GetType()}"); } else _executors[typeof(ICommandExecutor)].Add(executor); } @@ -48,7 +48,7 @@ public void Register(object executor) if (executorTypes.Count == 0) { - Debug.LogError($"No ICommandExecutor interface found for type: {executor.GetType()}"); + Debug.LogError($"[{nameof(CommandExecutorRegistry)}] No ICommandExecutor interface found for type: {executor.GetType()}"); return; } @@ -58,7 +58,7 @@ public void Register(object executor) { if (_executors[executorType].Contains(executor)) { - Debug.LogError($"Executor already registered: {executor.GetType()}"); + Debug.LogError($"[{nameof(CommandExecutorRegistry)}] Executor already registered: {executor.GetType()}"); } else _executors[executorType].Add(executor); } @@ -74,7 +74,7 @@ public void UnRegister(ICommandExecutor executor) where T : TCommand { if (!_executors.ContainsKey(typeof(ICommandExecutor))) { - Debug.LogError($"Executor has not been registered yet: {executor.GetType()}"); + Debug.LogError($"[{nameof(CommandExecutorRegistry)}] Executor has not been registered yet: {executor.GetType()}"); return; } _executors[typeof(ICommandExecutor)].Remove(executor); @@ -92,7 +92,7 @@ public void UnRegister(object executor) if (executorTypes.Count == 0) { - Debug.LogError($"No ICommandExecutor interface found for type: {executor.GetType()}"); + Debug.LogError($"[{nameof(CommandExecutorRegistry)}] No ICommandExecutor interface found for type: {executor.GetType()}"); return; } @@ -100,7 +100,7 @@ public void UnRegister(object executor) { if (!_executors.ContainsKey(executorType)) { - Debug.LogError($"Executor has not been registered yet: {executor.GetType()}"); + Debug.LogError($"[{nameof(CommandExecutorRegistry)}] Executor has not been registered yet: {executor.GetType()}"); return; } _executors[executorType].Remove(executor); diff --git a/Assets/Scripts/Pal3/Command/ConsoleCommands.PAL3A.g.cs b/Assets/Scripts/Pal3/Command/ConsoleCommands.PAL3A.g.cs index 1da216449..ef9198b2d 100644 --- a/Assets/Scripts/Pal3/Command/ConsoleCommands.PAL3A.g.cs +++ b/Assets/Scripts/Pal3/Command/ConsoleCommands.PAL3A.g.cs @@ -775,6 +775,14 @@ public static void SceneCloseDoor(System.Int32 objectId) new SceneCloseDoorCommand(objectId)); } + // + [ConsoleMethodAttribute("SceneEnableFog", "设置并开启场景内的雾气显示,参数:起始距离(原GameBox引擎下的距离单位),结束距离(原GameBox引擎下的距离单位),强度值,蓝色(0f-255f),绿色(0f-255f),红色(0f-255f),透明度(0f-1f)")] + public static void SceneEnableFog(System.Single startDistance, System.Single endDistance, System.Single intensity, System.Single blue, System.Single green, System.Single red, System.Single alpha) + { + CommandDispatcher.Instance.Dispatch( + new SceneEnableFogCommand(startDistance, endDistance, intensity, blue, green, red, alpha)); + } + // [ConsoleMethodAttribute("SceneLoad", "切换场景,参数:场景关(文件)名称,场景区块名称")] public static void SceneLoad(System.String sceneFileName, System.String sceneName) @@ -1175,14 +1183,6 @@ public static void UIShowSmeltingMenu(System.Int32 smeltingScriptId) new UIShowSmeltingMenuCommand(smeltingScriptId)); } - // - [ConsoleMethodAttribute("Unknown162", "仙三外设置场景内的雾气特效和颜色???")] - public static void Unknown162(System.Single unknown1, System.Single unknown2, System.Single unknown3, System.Single red, System.Single green, System.Single blue, System.Single unknown7) - { - CommandDispatcher.Instance.Dispatch( - new UnknownCommand162(unknown1, unknown2, unknown3, red, green, blue, unknown7)); - } - // [ConsoleMethodAttribute("Unknown166", "???")] public static void Unknown166(System.Int32 unknown1, System.Int32 unknown2) diff --git a/Assets/Scripts/Pal3/Command/SceCommands/SceneEnableFogCommand.cs b/Assets/Scripts/Pal3/Command/SceCommands/SceneEnableFogCommand.cs new file mode 100644 index 000000000..59532dbcb --- /dev/null +++ b/Assets/Scripts/Pal3/Command/SceCommands/SceneEnableFogCommand.cs @@ -0,0 +1,42 @@ +// --------------------------------------------------------------------------------------------- +// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved. +// See LICENSE file in the project root for license information. +// --------------------------------------------------------------------------------------------- + +namespace Pal3.Command.SceCommands +{ + #if PAL3A + [AvailableInConsole] + [SceCommand(162, "设置并开启场景内的雾气显示," + + "参数:起始距离(原GameBox引擎下的距离单位),结束距离(原GameBox引擎下的距离单位),强度值," + + "蓝色(0f-255f),绿色(0f-255f),红色(0f-255f),透明度(0f-1f)")] + public class SceneEnableFogCommand : ICommand + { + public SceneEnableFogCommand( + float startDistance, + float endDistance, + float intensity, + float blue, + float green, + float red, + float alpha) + { + StartDistance = startDistance; + EndDistance = endDistance; + Intensity = intensity; + Blue = blue; + Green = green; + Red = red; + Alpha = alpha; + } + + public float StartDistance { get; } + public float EndDistance { get; } + public float Intensity { get; } + public float Blue { get; } + public float Green { get; } + public float Red { get; } + public float Alpha { get; } + } + #endif +} \ No newline at end of file diff --git a/Assets/Scripts/Pal3/Command/SceCommands/UnknownCommand162.cs.meta b/Assets/Scripts/Pal3/Command/SceCommands/SceneEnableFogCommand.cs.meta similarity index 100% rename from Assets/Scripts/Pal3/Command/SceCommands/UnknownCommand162.cs.meta rename to Assets/Scripts/Pal3/Command/SceCommands/SceneEnableFogCommand.cs.meta diff --git a/Assets/Scripts/Pal3/Command/SceCommands/UnknownCommand162.cs b/Assets/Scripts/Pal3/Command/SceCommands/UnknownCommand162.cs deleted file mode 100644 index b86249cc8..000000000 --- a/Assets/Scripts/Pal3/Command/SceCommands/UnknownCommand162.cs +++ /dev/null @@ -1,40 +0,0 @@ -// --------------------------------------------------------------------------------------------- -// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved. -// See LICENSE file in the project root for license information. -// --------------------------------------------------------------------------------------------- - -namespace Pal3.Command.SceCommands -{ - #if PAL3A - [AvailableInConsole] - [SceCommand(162, "仙三外设置场景内的雾气特效和颜色???")] - public class UnknownCommand162 : ICommand - { - public UnknownCommand162( - float unknown1, - float unknown2, - float unknown3, - float red, - float green, - float blue, - float unknown7) - { - Unknown1 = unknown1; - Unknown2 = unknown2; - Unknown3 = unknown3; - Red = red; - Green = green; - Blue = blue; - Unknown7 = unknown7; - } - - public float Unknown1 { get; } - public float Unknown2 { get; } - public float Unknown3 { get; } - public float Red { get; } - public float Green { get; } - public float Blue { get; } - public float Unknown7 { get; } - } - #endif -} \ No newline at end of file diff --git a/Assets/Scripts/Pal3/Data/FileSystemCacheManager.cs b/Assets/Scripts/Pal3/Data/FileSystemCacheManager.cs index e3dd6220b..8465db6b6 100644 --- a/Assets/Scripts/Pal3/Data/FileSystemCacheManager.cs +++ b/Assets/Scripts/Pal3/Data/FileSystemCacheManager.cs @@ -44,8 +44,8 @@ public void Execute(ScenePreLoadingNotification notification) // Dispose current scene cpk if (!string.IsNullOrEmpty(_currentCityName)) { - var currentSceneFolderPath = _currentCityName + CpkConstants.FileExtension + CpkConstants.DirectorySeparator - + _currentSceneName; + var currentSceneFolderPath = $"{_currentCityName}{CpkConstants.FileExtension}" + + $"{CpkConstants.DirectorySeparatorChar}{_currentSceneName}"; if (_fileSystem.FileExistsInSegmentedArchive(currentSceneFolderPath, out string segmentedArchiveName)) { @@ -59,8 +59,8 @@ public void Execute(ScenePreLoadingNotification notification) // Load new scene cpk into memory { - var newSceneFolderPath = newCityName + CpkConstants.FileExtension + CpkConstants.DirectorySeparator - + newSceneName; + var newSceneFolderPath = $"{newCityName}{CpkConstants.FileExtension}" + + $"{CpkConstants.DirectorySeparatorChar}{newSceneName}"; if (_fileSystem.FileExistsInSegmentedArchive(newSceneFolderPath, out string segmentedArchiveName)) { diff --git a/Assets/Scripts/Pal3/Data/GameResourceProvider.cs b/Assets/Scripts/Pal3/Data/GameResourceProvider.cs index e6f2373b5..3d1077ebf 100644 --- a/Assets/Scripts/Pal3/Data/GameResourceProvider.cs +++ b/Assets/Scripts/Pal3/Data/GameResourceProvider.cs @@ -48,7 +48,7 @@ public sealed class GameResourceProvider : IDisposable, private const string CACHE_FOLDER_NAME = "CacheData"; private const string MV3_ACTOR_CONFIG_HEADER = ";#MV3#"; - private const char PathSeparator = CpkConstants.DirectorySeparator; + private const char DirSeparator = CpkConstants.DirectorySeparatorChar; private readonly ICpkFileSystem _fileSystem; private readonly ITextureLoaderFactory _textureLoaderFactory; @@ -214,7 +214,7 @@ public string GetMusicFilePathInCacheFolder(string musicFileVirtualPath) + CACHE_FOLDER_NAME + Path.DirectorySeparatorChar + musicFileVirtualPath - .Replace(PathSeparator, Path.DirectorySeparatorChar) + .Replace(CpkConstants.DirectorySeparatorChar, Path.DirectorySeparatorChar) .Replace(CpkConstants.FileExtension, string.Empty); } @@ -229,7 +229,7 @@ public IEnumerator ExtractAndMoveMp3FileToCacheFolderAsync(string musicFileVirtu { if (File.Exists(musicFileCachePath)) yield break; - Debug.Log($"Writing MP3 file to App's persistent folder: {musicFileVirtualPath}"); + Debug.Log($"[{nameof(GameResourceProvider)}] Writing MP3 file to App's persistent folder: {musicFileVirtualPath}"); var dataMovementThread = new Thread(() => { try @@ -351,13 +351,13 @@ public Texture2D[] GetSkyBoxTextures(int skyBoxId) var relativeFilePath = string.Format(FileConstants.SkyBoxTexturePathFormat.First(), skyBoxId); ITextureResourceProvider textureProvider = CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(relativeFilePath)); + Utility.GetDirectoryName(relativeFilePath, DirSeparator)); var textures = new Texture2D[FileConstants.SkyBoxTexturePathFormat.Length]; for (var i = 0; i < FileConstants.SkyBoxTexturePathFormat.Length; i++) { var textureNameFormat = Utility.GetFileName( - string.Format(FileConstants.SkyBoxTexturePathFormat[i], skyBoxId), PathSeparator); + string.Format(FileConstants.SkyBoxTexturePathFormat[i], skyBoxId), DirSeparator); Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i)); // Set wrap mode to clamp to remove "edges" between sides texture.wrapMode = TextureWrapMode.Clamp; @@ -499,7 +499,7 @@ public string GetVideoFilePath(string videoName) public (Texture2D texture, bool hasAlphaChannel)[] GetEffectTextures(GraphicsEffect effect, string texturePathFormat) { ITextureResourceProvider textureProvider = CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(texturePathFormat)); + Utility.GetDirectoryName(texturePathFormat, DirSeparator)); if (effect == GraphicsEffect.Fire) { @@ -507,7 +507,7 @@ public string GetVideoFilePath(string videoName) var textures = new (Texture2D texture, bool hasAlphaChannel)[numberOfFrames]; for (var i = 0; i < numberOfFrames; i++) { - var textureNameFormat = Utility.GetFileName(texturePathFormat, PathSeparator); + var textureNameFormat = Utility.GetFileName(texturePathFormat, DirSeparator); Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i + 1), out var hasAlphaChannel); textures[i] = (texture, hasAlphaChannel); } @@ -534,7 +534,7 @@ public Object GetVfxEffectPrefab(int effectGroupId) if (vfxPrefab == null) { - Debug.LogWarning("VFX prefab not found: " + effectGroupId); + Debug.LogWarning($"[{nameof(GameResourceProvider)}] VFX prefab not found: " + effectGroupId); } _vfxEffectPrefabCache[effectGroupId] = vfxPrefab; @@ -557,11 +557,11 @@ public IEnumerator PreLoadVfxEffectAsync(int effectGroupId) if (request.asset == null) { - Debug.LogWarning("VFX prefab not found: " + effectGroupId); + Debug.LogWarning($"[{nameof(GameResourceProvider)}] VFX prefab not found: " + effectGroupId); } else { - Debug.Log("VFX prefab preloaded: " + effectGroupId); + Debug.Log($"[{nameof(GameResourceProvider)}] VFX prefab preloaded: " + effectGroupId); } _vfxEffectPrefabCache[effectGroupId] = request.asset; @@ -575,35 +575,6 @@ public Texture2D GetCursorTexture() return cursorTexture; } - /// - /// To warm up the main actor action cache to reduce gameplay shutters. - /// - public void PreLoadMainActorMv3() - { - var cachedActions = new HashSet() - { - ActorConstants.ActionToNameMap[ActorActionType.Stand], - ActorConstants.ActionToNameMap[ActorActionType.Walk], - ActorConstants.ActionToNameMap[ActorActionType.Run], - ActorConstants.ActionToNameMap[ActorActionType.StepBack], - }; - - foreach (var name in ActorConstants.MainActorNameMap.Values) - { - ActorActionConfig actorActionConfig = GetActorActionConfig(name, $"{name}.ini"); - - foreach (ActorAction actorAction in actorActionConfig.ActorActions) - { - // Cache known actions only. - if (!cachedActions.Contains(actorAction.ActionName.ToLower())) continue; - - var mv3FilePath = FileConstants.GetActorFolderVirtualPath(name) + actorAction.ActionFileName; - - _ = GetGameResourceFile(mv3FilePath); // Call GetMv3 to cache the mv3 file. - } - } - } - private string _currentCityName; public void Execute(ScenePreLoadingNotification notification) { @@ -647,7 +618,7 @@ private void DisposeTemporaryInMemoryGameResources() { // Dispose non-main actor mv3 files // All main actor names start with "1" - var mainActorMv3 = $"{FileConstants.GetActorFolderName()}{PathSeparator}1".ToLower(); + var mainActorMv3 = $"{FileConstants.GetActorFolderName()}{DirSeparator}1".ToLower(); var mv3FilesToDispose = fileCache.Value.Keys .Where(mv3FilePath => !mv3FilePath.Contains(mainActorMv3)) .ToArray(); diff --git a/Assets/Scripts/Pal3/Data/TextureCache.cs b/Assets/Scripts/Pal3/Data/TextureCache.cs index 0a4bc3bf7..f2818fb68 100644 --- a/Assets/Scripts/Pal3/Data/TextureCache.cs +++ b/Assets/Scripts/Pal3/Data/TextureCache.cs @@ -5,7 +5,6 @@ namespace Pal3.Data { - using System; using System.Collections.Generic; using UnityEngine; @@ -24,7 +23,7 @@ public void Add(string key, Texture2D texture, bool hasAlphaChannel) if (_textureCache.ContainsKey(key)) { - Debug.LogError($"Texture {key} already existed in cache."); + Debug.LogError($"[{nameof(TextureCache)}] Texture {key} already existed in cache."); } else { @@ -50,7 +49,7 @@ public bool TryGetTextureFromCache(string key, public void DisposeAll() { - Debug.Log($"Disposing all cached textures: {_textureCache.Count}"); + Debug.Log($"[{nameof(TextureCache)}] Disposing all cached textures: {_textureCache.Count}"); foreach ((Texture2D texture, _) in _textureCache.Values) { UnityEngine.Object.Destroy(texture); diff --git a/Assets/Scripts/Pal3/Data/TextureProvider.cs b/Assets/Scripts/Pal3/Data/TextureProvider.cs index 22e9633bb..91c06211e 100644 --- a/Assets/Scripts/Pal3/Data/TextureProvider.cs +++ b/Assets/Scripts/Pal3/Data/TextureProvider.cs @@ -17,21 +17,21 @@ public class TextureProvider : TextureProviderBase, ITextureResourceProvider private readonly ICpkFileSystem _fileSystem; private readonly ITextureLoaderFactory _textureLoaderFactory; private readonly TextureCache _textureCache; - private readonly string _relativePath; + private readonly string _relativeDirectoryPath; public TextureProvider(ICpkFileSystem fileSystem, ITextureLoaderFactory textureLoaderFactory, - string relativePath, + string relativeDirectoryPath, TextureCache textureCache = null) { - if (!relativePath.EndsWith(CpkConstants.DirectorySeparator)) + if (!relativeDirectoryPath.EndsWith(CpkConstants.DirectorySeparatorChar)) { - relativePath += CpkConstants.DirectorySeparator; + relativeDirectoryPath += CpkConstants.DirectorySeparatorChar; } _fileSystem = fileSystem; _textureLoaderFactory = textureLoaderFactory; - _relativePath = relativePath.ToLower(); // Texture path is case insensitive + _relativeDirectoryPath = relativeDirectoryPath.ToLower(); // Texture path is case insensitive _textureCache = textureCache; } @@ -49,7 +49,7 @@ private bool TryGetTextureFromCache(string textureFullPath, public string GetTexturePath(string name) { - return _relativePath + name; + return _relativeDirectoryPath + name; } public Texture2D GetTexture(string name) @@ -66,7 +66,7 @@ public Texture2D GetTexture(string name, out bool hasAlphaChannel) return Texture2D.whiteTexture; } - var texturePath = _relativePath + name; + var texturePath = _relativeDirectoryPath + name; // Note: Most texture files used in (.pol, .cvd) files are stored inside Pal3's CPack // archives and they are pre-compressed to DXT format (DXT1 & DXT3). So we need to @@ -78,7 +78,7 @@ public Texture2D GetTexture(string name, out bool hasAlphaChannel) } catch (Exception ex) { - Debug.LogWarning($"Failed to change path extension for texture: {texturePath}, ex: {ex}"); + Debug.LogWarning($"[{nameof(TextureProvider)}] Failed to change path extension for texture: {texturePath}, ex: {ex}"); hasAlphaChannel = false; return Texture2D.whiteTexture; } @@ -113,7 +113,7 @@ public Texture2D GetTexture(string name, out bool hasAlphaChannel) { textureLoader = _textureLoaderFactory.GetTextureLoader(Path.GetExtension(name)); texture = base.GetTexture(_fileSystem, texturePath, textureLoader, out hasAlphaChannel); - if (texture == null) Debug.LogWarning($"Texture not found: {texturePath}"); + if (texture == null) Debug.LogWarning($"[{nameof(TextureProvider)}] Texture not found: {texturePath}"); else _textureCache?.Add(texturePath, texture, hasAlphaChannel); } diff --git a/Assets/Scripts/Pal3/Dev/UnknownSceCommandAnalyzer.cs b/Assets/Scripts/Pal3/Dev/UnknownSceCommandAnalyzer.cs index 680f426b3..cfa519cd3 100644 --- a/Assets/Scripts/Pal3/Dev/UnknownSceCommandAnalyzer.cs +++ b/Assets/Scripts/Pal3/Dev/UnknownSceCommandAnalyzer.cs @@ -13,6 +13,7 @@ namespace Pal3.Dev using UnityEditor; using UnityEngine; + [Obsolete] public static class UnknownSceCommandAnalyzer { public static void AnalyzeCommand(BinaryReader reader, @@ -20,7 +21,7 @@ public static void AnalyzeCommand(BinaryReader reader, ushort parameterFlag, int codepage) { - Debug.LogError($"Unknown Command Id: {commandId} ParameterFlag: {parameterFlag}"); + Debug.LogError($"[{nameof(UnknownSceCommandAnalyzer)}] Unknown Command Id: {commandId} ParameterFlag: {parameterFlag}"); var initPosition = reader.BaseStream.Position; var length = 0; @@ -40,7 +41,7 @@ public static void AnalyzeCommand(BinaryReader reader, if (nextCmdType != null) { ICommand command = SceCommandParser.ParseSceCommand(reader, id, flag, codepage); - Debug.Log($"Possible length: {length}, " + + Debug.Log($"[{nameof(UnknownSceCommandAnalyzer)}] Possible length: {length}, " + $"next command: {nextCmdType.Name}-{id}-{flag}-{JsonConvert.SerializeObject(command)}"); maxSearchCount--; diff --git a/Assets/Scripts/Pal3/Effect/FireEffect.cs b/Assets/Scripts/Pal3/Effect/FireEffect.cs index e26bb8fe7..0b45ed709 100644 --- a/Assets/Scripts/Pal3/Effect/FireEffect.cs +++ b/Assets/Scripts/Pal3/Effect/FireEffect.cs @@ -7,6 +7,7 @@ namespace Pal3.Effect { using System; using Core.DataLoader; + using Core.DataReader.Cpk; using Core.DataReader.Pol; using Core.Renderer; using Core.Utils; @@ -35,7 +36,7 @@ public void Init(GameResourceProvider resourceProvider, uint effectParameter) { PolFile polFile = resourceProvider.GetGameResourceFile(info.ModelPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(info.ModelPath)); + Utility.GetDirectoryName(info.ModelPath, CpkConstants.DirectorySeparatorChar)); _sceneObjectRenderer = gameObject.AddComponent(); _sceneObjectRenderer.Render(polFile, textureProvider, diff --git a/Assets/Scripts/Pal3/GamePlay/PlayerGamePlayController.cs b/Assets/Scripts/Pal3/GamePlay/PlayerGamePlayController.cs index 52470a8d4..521b93787 100644 --- a/Assets/Scripts/Pal3/GamePlay/PlayerGamePlayController.cs +++ b/Assets/Scripts/Pal3/GamePlay/PlayerGamePlayController.cs @@ -880,7 +880,7 @@ public void Execute(PlayerInteractWithObjectCommand command) } else { - Debug.LogError($"Scene object not found or not activated yet: {command.SceneObjectId}."); + Debug.LogError($"[{nameof(PlayerGamePlayController)}] Scene object not found or not activated yet: {command.SceneObjectId}."); } } @@ -891,7 +891,7 @@ public void Execute(ActorPerformClimbActionCommand command) GameObject climbableObject = climbableSceneObject.GetGameObject(); if (climbableObject == null) { - Debug.LogError($"Scene object not found or not activated yet: {command.ObjectId}."); + Debug.LogError($"[{nameof(PlayerGamePlayController)}] Scene object not found or not activated yet: {command.ObjectId}."); return; } @@ -1030,8 +1030,8 @@ public void Execute(ActorEnablePlayerControlCommand command) // Check if actor is player actor. if (!Enum.IsDefined(typeof(PlayerActorId), command.ActorId)) { - Debug.LogError($"Cannot enable player control for actor {command.ActorId} " + - $"since actor is not a player actor."); + Debug.LogError($"[{nameof(PlayerGamePlayController)}] Cannot enable player control for actor " + + $"{command.ActorId} since actor is not a player actor."); return; } diff --git a/Assets/Scripts/Pal3/GameResourceInitializer.cs b/Assets/Scripts/Pal3/GameResourceInitializer.cs index d4a77eb84..86822ab58 100644 --- a/Assets/Scripts/Pal3/GameResourceInitializer.cs +++ b/Assets/Scripts/Pal3/GameResourceInitializer.cs @@ -82,6 +82,8 @@ private IEnumerator Start() private IEnumerator InitResourceAsync() { + Debug.Log($"[{nameof(GameResourceInitializer)}] Initializing game resources..."); + // TODO: let user to choose language? Or auto-detect encoding? int codepage = DEFAULT_CODE_PAGE; @@ -107,7 +109,7 @@ private IEnumerator InitResourceAsync() if (gameDataFolderSearchLocations.Count == 0) { - Debug.LogError("No game data folder search locations found."); + Debug.LogError($"[{nameof(GameResourceInitializer)}] No game data folder search locations found."); yield break; } @@ -197,8 +199,7 @@ private IEnumerator InitResourceAsync() gameSettings); ServiceLocator.Instance.Register(resourceProvider); - // Cache warm up - resourceProvider.PreLoadMainActorMv3(); + Debug.Log($"[{nameof(GameResourceInitializer)}] Game resources initialized."); // Instantiate starting component GameObject startingGameObject = Instantiate(startingComponent, null); @@ -289,7 +290,8 @@ private IEnumerator InitFileSystemAsync(string gameDataFolderPath, timer.Start(); cpkFileSystem = InitializeCpkFileSystem(path, crcHash, codepage); timer.Stop(); - Debug.Log($"All cpk files mounted successfully under {path}. Total time: {timer.Elapsed.TotalSeconds:0.000}s"); + Debug.Log($"[{nameof(GameResourceInitializer)}] All .cpk files mounted successfully. " + + $"Total time: {timer.Elapsed.TotalSeconds:0.000}s"); } catch (Exception ex) { @@ -336,23 +338,23 @@ private ICpkFileSystem InitializeCpkFileSystem(string gameRootPath, Crc32Hash cr List filesToMount = new () { - FileConstants.BaseDataCpkFilePath, - FileConstants.MusicCpkFilePath + FileConstants.BaseDataCpkFileRelativePath, + FileConstants.MusicCpkFileRelativePath }; - foreach (string sceneCpkFileName in FileConstants.SceneCpkFileNames) + foreach (var sceneCpkFileName in FileConstants.SceneCpkFileNames) { - filesToMount.Add(FileConstants.GetSceneCpkFilePath(sceneCpkFileName)); + filesToMount.Add(FileConstants.GetSceneCpkFileRelativePath(sceneCpkFileName)); } #if PAL3A - filesToMount.Add(FileConstants.ScnCpkFilePath); - filesToMount.Add(FileConstants.SceCpkFilePath); + filesToMount.Add(FileConstants.ScnCpkFileRelativePath); + filesToMount.Add(FileConstants.SceCpkFileRelativePath); #endif - foreach (var cpkFilePath in filesToMount) + foreach (var cpkFileRelativePath in filesToMount) { - cpkFileSystem.Mount(cpkFilePath, codepage); + cpkFileSystem.Mount(cpkFileRelativePath, codepage); } return cpkFileSystem; diff --git a/Assets/Scripts/Pal3/GameSystem/DialogueManager.cs b/Assets/Scripts/Pal3/GameSystem/DialogueManager.cs index 507a7671c..6f3f95de8 100644 --- a/Assets/Scripts/Pal3/GameSystem/DialogueManager.cs +++ b/Assets/Scripts/Pal3/GameSystem/DialogueManager.cs @@ -316,7 +316,7 @@ private IEnumerator RenderDialogueAndWaitAsync(string text, _flashingAnimationCts.Cancel(); _reactionTimer.Stop(); _totalTimeUsedBeforeSkippingTheLastDialogue = _reactionTimer.Elapsed.TotalSeconds; - Debug.LogWarning($"Reaction time: {_totalTimeUsedBeforeSkippingTheLastDialogue:0.00f}"); + Debug.LogWarning($"[{nameof(DialogueManager)}] Reaction time: {_totalTimeUsedBeforeSkippingTheLastDialogue:0.00f}"); } yield return PlayDialogueBackgroundPopAnimationAsync(false); diff --git a/Assets/Scripts/Pal3/GameSystem/FavorManager.cs b/Assets/Scripts/Pal3/GameSystem/FavorManager.cs index 37f493c47..d34737636 100644 --- a/Assets/Scripts/Pal3/GameSystem/FavorManager.cs +++ b/Assets/Scripts/Pal3/GameSystem/FavorManager.cs @@ -67,7 +67,7 @@ public void Execute(FavorAddCommand command) } else { - Debug.LogError($"Actor ID {command.ActorId} is not supported for favor system. " + + Debug.LogError($"[{nameof(FavorManager)}] Actor ID {command.ActorId} is not supported for favor system. " + $"Valid IDs are: {string.Join(", ", _actorFavor.Keys)}"); } } diff --git a/Assets/Scripts/Pal3/GameSystem/InventoryManager.cs b/Assets/Scripts/Pal3/GameSystem/InventoryManager.cs index b782b9624..de8070179 100644 --- a/Assets/Scripts/Pal3/GameSystem/InventoryManager.cs +++ b/Assets/Scripts/Pal3/GameSystem/InventoryManager.cs @@ -97,7 +97,7 @@ public void Execute(InventoryAddItemCommand command) CommandDispatcher.Instance.Dispatch(new UIDisplayNoteCommand($"得到{itemName}")); - Debug.LogWarning($"Add item: {itemName}({command.ItemId}) count: {command.Count}"); + Debug.LogWarning($"[{nameof(InventoryManager)}] Add item: {itemName}({command.ItemId}) count: {command.Count}"); } public void Execute(InventoryRemoveItemCommand command) @@ -116,7 +116,7 @@ public void Execute(InventoryRemoveItemCommand command) CommandDispatcher.Instance.Dispatch(new UIDisplayNoteCommand($"失去{itemName}")); - Debug.LogWarning($"Remove item: {itemName}({command.ItemId})"); + Debug.LogWarning($"[{nameof(InventoryManager)}] Remove item: {itemName}({command.ItemId})"); } public void Execute(InventoryAddMoneyCommand command) @@ -138,7 +138,7 @@ public void Execute(InventoryAddMoneyCommand command) CommandDispatcher.Instance.Dispatch(new UIDisplayNoteCommand($"失去{-command.ChangeAmount}文钱")); } - Debug.LogWarning($"Add money: {command.ChangeAmount} current total: {_items[MONEY_ITEM_ID]}"); + Debug.LogWarning($"[{nameof(InventoryManager)}] Add money: {command.ChangeAmount} current total: {_items[MONEY_ITEM_ID]}"); } public void Execute(ResetGameStateCommand command) diff --git a/Assets/Scripts/Pal3/GameSystem/TeamManager.cs b/Assets/Scripts/Pal3/GameSystem/TeamManager.cs index d2e8c5f7b..4c383696e 100644 --- a/Assets/Scripts/Pal3/GameSystem/TeamManager.cs +++ b/Assets/Scripts/Pal3/GameSystem/TeamManager.cs @@ -171,7 +171,7 @@ public void Execute(TeamAddOrRemoveActorCommand command) { if (!Enum.IsDefined(typeof(PlayerActorId), command.ActorId)) { - Debug.LogError($"Cannot add non-player actor to the team."); + Debug.LogError($"[{nameof(TeamManager)}] Cannot add non-player actor to the team."); return; } @@ -183,7 +183,7 @@ public void Execute(TeamAddOrRemoveActorCommand command) if (actor == PlayerActorId.TaoZi) #endif { - Debug.LogError($"{actor} cannot be added to the team."); + Debug.LogError($"[{nameof(TeamManager)}] {actor} cannot be added to the team."); return; } diff --git a/Assets/Scripts/Pal3/Input/PlayerInputActions.cs b/Assets/Scripts/Pal3/Input/PlayerInputActions.cs index b9c92d32c..5613d6abb 100644 --- a/Assets/Scripts/Pal3/Input/PlayerInputActions.cs +++ b/Assets/Scripts/Pal3/Input/PlayerInputActions.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator -// version 1.6.1 +// version 1.6.3 // from Assets/Scripts/Pal3/Input/PlayerInputActions.inputactions // // Changes to this file may cause incorrect behavior and will be lost if diff --git a/Assets/Scripts/Pal3/MetaData/EffectConstants.cs b/Assets/Scripts/Pal3/MetaData/EffectConstants.cs index a2309650a..1db69914e 100644 --- a/Assets/Scripts/Pal3/MetaData/EffectConstants.cs +++ b/Assets/Scripts/Pal3/MetaData/EffectConstants.cs @@ -36,49 +36,49 @@ public static class EffectConstants public const int AnimatedFireEffectFrameRate = 10; - private const char PathSeparator = CpkConstants.DirectorySeparator; + private const char DirSeparator = CpkConstants.DirectorySeparatorChar; #if PAL3 public static readonly Dictionary FireEffectInfo = new() { {FireEffectType.Type1, new ( - FileConstants.EffectScnFolderVirtualPath + "Fire1" + PathSeparator + "torch{0:00}.tga", + FileConstants.EffectScnFolderVirtualPath + "Fire1" + DirSeparator + "torch{0:00}.tga", "", 3.3f, 0.5f) }, {FireEffectType.Type2, new ( - FileConstants.EffectScnFolderVirtualPath + "Fire2" + PathSeparator + "{0:00}.tga", + FileConstants.EffectScnFolderVirtualPath + "Fire2" + DirSeparator + "{0:00}.tga", "", 1f, 0.2f) }, {FireEffectType.Type3, new ( - FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga", - $"{FileConstants.EffectScnFolderVirtualPath}Candle{PathSeparator}candle.pol", 1f, 0.2f) }, + FileConstants.EffectScnFolderVirtualPath + "Candle" + DirSeparator + "{0:000}.tga", + $"{FileConstants.EffectScnFolderVirtualPath}Candle{DirSeparator}candle.pol", 1f, 0.2f) }, {FireEffectType.Type4, new ( - FileConstants.EffectScnFolderVirtualPath + "Fire4" + PathSeparator + "{0:00}.tga", + FileConstants.EffectScnFolderVirtualPath + "Fire4" + DirSeparator + "{0:00}.tga", "", 5.8f, 0.5f) }, {FireEffectType.Type5, new ( - FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga", - $"{FileConstants.EffectScnFolderVirtualPath}Lamp{PathSeparator}lamp.pol", 0.7f, 0.2f) }, + FileConstants.EffectScnFolderVirtualPath + "Candle" + DirSeparator + "{0:000}.tga", + $"{FileConstants.EffectScnFolderVirtualPath}Lamp{DirSeparator}lamp.pol", 0.7f, 0.2f) }, }; #elif PAL3A public static readonly Dictionary FireEffectInfo = new() { {FireEffectType.Type1, new ( - FileConstants.EffectScnFolderVirtualPath + "Fire4" + PathSeparator + "{0:00}.tga", + FileConstants.EffectScnFolderVirtualPath + "Fire4" + DirSeparator + "{0:00}.tga", "", 5.8f, 0.5f) }, {FireEffectType.Type2, new ( - FileConstants.EffectScnFolderVirtualPath + "Fire1" + PathSeparator + "torch{0:00}.tga", + FileConstants.EffectScnFolderVirtualPath + "Fire1" + DirSeparator + "torch{0:00}.tga", "", 3.3f, 0.5f) }, {FireEffectType.Type3, new ( - FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga", - $"{FileConstants.EffectScnFolderVirtualPath}Lamp{PathSeparator}lamp.pol", 0.7f, 0.2f) }, + FileConstants.EffectScnFolderVirtualPath + "Candle" + DirSeparator + "{0:000}.tga", + $"{FileConstants.EffectScnFolderVirtualPath}Lamp{DirSeparator}lamp.pol", 0.7f, 0.2f) }, {FireEffectType.Type4, new ( - FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga", - $"{FileConstants.EffectScnFolderVirtualPath}Candle{PathSeparator}candle.pol", 1f, 0.2f) }, + FileConstants.EffectScnFolderVirtualPath + "Candle" + DirSeparator + "{0:000}.tga", + $"{FileConstants.EffectScnFolderVirtualPath}Candle{DirSeparator}candle.pol", 1f, 0.2f) }, {FireEffectType.Type5, new ( - FileConstants.EffectScnFolderVirtualPath + "Fire2" + PathSeparator + "{0:00}.tga", + FileConstants.EffectScnFolderVirtualPath + "Fire2" + DirSeparator + "{0:00}.tga", "", 1f, 0.3f) }, {FireEffectType.Type6, new ( - FileConstants.EffectScnFolderVirtualPath + "Candle" + PathSeparator + "{0:000}.tga", + FileConstants.EffectScnFolderVirtualPath + "Candle" + DirSeparator + "{0:000}.tga", "", 1f, 0.6f) }, }; #endif diff --git a/Assets/Scripts/Pal3/MetaData/FileConstants.cs b/Assets/Scripts/Pal3/MetaData/FileConstants.cs index 3339e4126..961bdae1b 100644 --- a/Assets/Scripts/Pal3/MetaData/FileConstants.cs +++ b/Assets/Scripts/Pal3/MetaData/FileConstants.cs @@ -78,23 +78,23 @@ public static class FileConstants #region Platform specific file names and paths - public static readonly string BaseDataCpkFilePath = + public static readonly string BaseDataCpkFileRelativePath = $"{BASE_DATA_FOLDER_NAME}{Path.DirectorySeparatorChar}{BASE_DATA_CPK_FILE_NAME}"; - public static readonly string MusicCpkFilePath = + public static readonly string MusicCpkFileRelativePath = $"{MUSIC_FOLDER_NAME}{Path.DirectorySeparatorChar}{MUSIC_CPK_FILE_NAME}"; #if PAL3A - public static readonly string ScnCpkFilePath = $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{SCN_CPK_FILE_NAME}"; - public static readonly string SceCpkFilePath = $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{SCE_CPK_FILE_NAME}"; + public static readonly string ScnCpkFileRelativePath = $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{SCN_CPK_FILE_NAME}"; + public static readonly string SceCpkFileRelativePath = $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{SCE_CPK_FILE_NAME}"; #endif - public static string GetSceneCpkFilePath(string sceneCpkFileName) + public static string GetSceneCpkFileRelativePath(string sceneCpkFileName) { return $"{SCENE_FOLDER_NAME}{Path.DirectorySeparatorChar}{sceneCpkFileName}"; } - public static string GetMovieCpkFilePath(string movieCpkFileName) + public static string GetMovieCpkFileRelativePath(string movieCpkFileName) { return $"{MovieFolderName}{Path.DirectorySeparatorChar}{movieCpkFileName}"; } @@ -103,94 +103,94 @@ public static string GetMovieCpkFilePath(string movieCpkFileName) #region CPK file system virtual file names and paths - private const char CpkPathSeparator = CpkConstants.DirectorySeparator; + private const char DirSeparator = CpkConstants.DirectorySeparatorChar; #if PAL3 public static readonly string GameDatabaseFileVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{COMBAT_DATA_FOLDER_NAME}{CpkPathSeparator}PAL3_Softstar.gdb"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{COMBAT_DATA_FOLDER_NAME}{DirSeparator}PAL3_Softstar.gdb"; #elif PAL3A public static readonly string GameDatabaseFileVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{COMBAT_DATA_FOLDER_NAME}{CpkPathSeparator}PAL3A_Softstar.gdb"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{COMBAT_DATA_FOLDER_NAME}{DirSeparator}PAL3A_Softstar.gdb"; #endif public static readonly string EffectFolderVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{EFFECT_FOLDER_NAME}{CpkPathSeparator}"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{EFFECT_FOLDER_NAME}{DirSeparator}"; public static readonly string EffectScnFolderVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{EFFECT_SCN_FOLDER_NAME}{CpkPathSeparator}"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{EFFECT_SCN_FOLDER_NAME}{DirSeparator}"; - public static readonly string SystemSceFileVirtualPath = $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}init.sce"; + public static readonly string SystemSceFileVirtualPath = $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}init.sce"; public static readonly string BigMapSceFileVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}{BIG_MAP_FOLDER_NAME}{CpkPathSeparator}BigMap.sce"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}{BIG_MAP_FOLDER_NAME}{DirSeparator}BigMap.sce"; public static readonly string UISceneFolderVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}scene{CpkPathSeparator}"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}scene{DirSeparator}"; public static readonly string[] SkyBoxTexturePathFormat = { - EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_lf.tga", - EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_fr.tga", - EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_rt.tga", - EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_bk.tga", - EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_up.tga", - EffectScnFolderVirtualPath + "skybox" + CpkPathSeparator + "{0:00}" + CpkPathSeparator + "{0:00}_dn.tga", + EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_lf.tga", + EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_fr.tga", + EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_rt.tga", + EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_bk.tga", + EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_up.tga", + EffectScnFolderVirtualPath + "skybox" + DirSeparator + "{0:00}" + DirSeparator + "{0:00}_dn.tga", }; public static readonly string EmojiSpriteSheetFolderVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}{EMOJI_FOLDER_NAME}{CpkPathSeparator}"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}{EMOJI_FOLDER_NAME}{DirSeparator}"; public static readonly string CursorSpriteFolderVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{UI_FOLDER_NAME}{CpkPathSeparator}{CURSOR_FOLDER_NAME}{CpkPathSeparator}"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{UI_FOLDER_NAME}{DirSeparator}{CURSOR_FOLDER_NAME}{DirSeparator}"; public static readonly string CaptionFolderVirtualPath = - $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{CAPTION_FOLDER_NAME}{CpkPathSeparator}"; + $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{CAPTION_FOLDER_NAME}{DirSeparator}"; public static string GetWeaponModelFileVirtualPath(string weaponName) { - return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}" + - $"{WEAPON_FOLDER_NAME}{CpkPathSeparator}{weaponName}{CpkPathSeparator}{weaponName}.pol"; + return $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}" + + $"{WEAPON_FOLDER_NAME}{DirSeparator}{weaponName}{DirSeparator}{weaponName}.pol"; } public static string GetGameItemModelFileVirtualPath(string itemName) { - return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}item" + - $"{CpkPathSeparator}{itemName}{CpkPathSeparator}{itemName}.pol"; + return $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}item" + + $"{DirSeparator}{itemName}{DirSeparator}{itemName}.pol"; } public static string GetGameObjectModelFileVirtualPath(string objectFileName) { - return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}{OBJECT_FOLDER_NAME}" + - CpkConstants.DirectorySeparator + objectFileName; + return $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}{OBJECT_FOLDER_NAME}" + + CpkConstants.DirectorySeparatorChar + objectFileName; } public static string GetGameObjectModelFileVirtualPath(ScnSceneInfo sceneInfo, string objectName) { - return $"{sceneInfo.CityName}{CpkConstants.FileExtension}{CpkPathSeparator}" + - $"{sceneInfo.Model}{CpkPathSeparator}{objectName}"; + return $"{sceneInfo.CityName}{CpkConstants.FileExtension}{DirSeparator}" + + $"{sceneInfo.Model}{DirSeparator}{objectName}"; } public static string GetMusicFileVirtualPath(string musicName) { - var separator = CpkConstants.DirectorySeparator; + var separator = CpkConstants.DirectorySeparatorChar; return $"{MUSIC_CPK_FILE_NAME}{separator}" + $"{MUSIC_FOLDER_NAME}{separator}{musicName}.mp3"; } public static string GetActorFolderVirtualPath(string actorName) { - return $"{BASE_DATA_CPK_FILE_NAME}{CpkPathSeparator}" + - $"{ACTOR_FOLDER_NAME}{CpkPathSeparator}{actorName}{CpkPathSeparator}"; + return $"{BASE_DATA_CPK_FILE_NAME}{DirSeparator}" + + $"{ACTOR_FOLDER_NAME}{DirSeparator}{actorName}{DirSeparator}"; } public static string GetNavFileVirtualPath(string sceneFileName, string sceneName) { #if PAL3 - var navFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{CpkPathSeparator}" + - $"{sceneName}{CpkPathSeparator}{sceneName}.nav"; + var navFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{DirSeparator}" + + $"{sceneName}{DirSeparator}{sceneName}.nav"; #elif PAL3A - var navFilePath = $"{SCN_CPK_FILE_NAME}{CpkPathSeparator}SCN{CpkPathSeparator}" + - $"{sceneFileName}{CpkPathSeparator}{sceneName}{CpkPathSeparator}{sceneName}.nav"; + var navFilePath = $"{SCN_CPK_FILE_NAME}{DirSeparator}SCN{DirSeparator}" + + $"{sceneFileName}{DirSeparator}{sceneName}{DirSeparator}{sceneName}.nav"; #endif return navFilePath; } @@ -198,10 +198,10 @@ public static string GetNavFileVirtualPath(string sceneFileName, string sceneNam public static string GetScnFileVirtualPath(string sceneFileName, string sceneName) { #if PAL3 - var scnFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{CpkPathSeparator}{sceneName}.scn"; + var scnFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{DirSeparator}{sceneName}.scn"; #elif PAL3A - var scnFilePath = $"{SCN_CPK_FILE_NAME}{CpkPathSeparator}SCN{CpkPathSeparator}" + - $"{sceneFileName}{CpkPathSeparator}{sceneFileName}_{sceneName}.scn"; + var scnFilePath = $"{SCN_CPK_FILE_NAME}{DirSeparator}SCN{DirSeparator}" + + $"{sceneFileName}{DirSeparator}{sceneFileName}_{sceneName}.scn"; #endif return scnFilePath; } @@ -209,9 +209,9 @@ public static string GetScnFileVirtualPath(string sceneFileName, string sceneNam public static string GetSceneSceFileVirtualPath(string sceneFileName) { #if PAL3 - var sceFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{CpkPathSeparator}{sceneFileName}.sce"; + var sceFilePath = $"{sceneFileName}{CpkConstants.FileExtension}{DirSeparator}{sceneFileName}.sce"; #elif PAL3A - var sceFilePath = $"{SCE_CPK_FILE_NAME}{CpkPathSeparator}Sce{CpkPathSeparator}{sceneFileName}.sce"; + var sceFilePath = $"{SCE_CPK_FILE_NAME}{DirSeparator}Sce{DirSeparator}{sceneFileName}.sce"; #endif return sceFilePath; } diff --git a/Assets/Scripts/Pal3/Pal3.cs b/Assets/Scripts/Pal3/Pal3.cs index 52cd65103..d417701d9 100644 --- a/Assets/Scripts/Pal3/Pal3.cs +++ b/Assets/Scripts/Pal3/Pal3.cs @@ -155,6 +155,8 @@ public sealed class Pal3 : Singleton private void OnEnable() { + Debug.Log($"[{nameof(Pal3)}] Game setup and initialization started..."); + _gameSettings = ServiceLocator.Instance.Get(); _fileSystem = ServiceLocator.Instance.Get(); _gameResourceProvider = ServiceLocator.Instance.Get(); @@ -340,10 +342,13 @@ private void OnEnable() DebugLogConsole.AddCommand("fov", "Set camera FOV.", SetCameraFov); DisableInGameDebugConsoleButtonNavigation(); + + Debug.Log($"[{nameof(Pal3)}] Game initialized."); } private void Start() { + Debug.Log($"[{nameof(Pal3)}] Game started."); _mainMenu.ShowInitView(); _mainMenu.ShowMenu(); } diff --git a/Assets/Scripts/Pal3/Renderer/CvdModelRenderer.cs b/Assets/Scripts/Pal3/Renderer/CvdModelRenderer.cs index 88df5a80b..e71f27510 100644 --- a/Assets/Scripts/Pal3/Renderer/CvdModelRenderer.cs +++ b/Assets/Scripts/Pal3/Renderer/CvdModelRenderer.cs @@ -394,7 +394,7 @@ public IEnumerator PlayAnimationAsync(float timeScale, _animationDuration < Mathf.Epsilon || _renderers.Count == 0) { - Debug.LogError("Invalid parameters for playing CVD animation."); + Debug.LogError($"[{nameof(CvdModelRenderer)}] Invalid parameters for playing CVD animation."); yield break; } diff --git a/Assets/Scripts/Pal3/Scene/Scene.cs b/Assets/Scripts/Pal3/Scene/Scene.cs index dd91d57f9..bf1a57919 100644 --- a/Assets/Scripts/Pal3/Scene/Scene.cs +++ b/Assets/Scripts/Pal3/Scene/Scene.cs @@ -35,6 +35,7 @@ public class Scene : SceneBase, ICommandExecutor, ICommandExecutor, ICommandExecutor, + ICommandExecutor, #endif ICommandExecutor, ICommandExecutor @@ -90,6 +91,9 @@ private void OnEnable() private void OnDisable() { + // Remove fog when scene is disabled + if (RenderSettings.fog) RenderSettings.fog = false; + CommandExecutorRegistry.Instance.UnRegister(this); Destroy(_mesh); @@ -132,7 +136,8 @@ public void Load(ScnFile scnFile, GameObject parent) scnFile, _sceneStateManager, _sceneObjectIdsToNotLoadFromSaveState); - //Debug.LogError($"InitTotal: {timer.ElapsedMilliseconds} ms"); + + Debug.Log($"[{nameof(Scene)}] Scene data initialized in {timer.ElapsedMilliseconds} ms."); timer.Restart(); _tilemap = new Tilemap(NavFile); @@ -144,7 +149,7 @@ public void Load(ScnFile scnFile, GameObject parent) timer.Restart(); RenderMesh(); - //Debug.LogError($"RenderMesh: {timer.ElapsedMilliseconds} ms"); + Debug.Log($"[{nameof(Scene)}] Mesh initialized in {timer.ElapsedMilliseconds} ms"); timer.Restart(); RenderSkyBox(); @@ -153,15 +158,15 @@ public void Load(ScnFile scnFile, GameObject parent) { SetupEnvironmentLighting(); } - //Debug.LogError($"SkyBox+NavMesh+Lights: {timer.ElapsedMilliseconds} ms"); + Debug.Log($"[{nameof(Scene)}] SkyBox + NavMesh initialized in {timer.ElapsedMilliseconds} ms"); timer.Restart(); InitActorObjects(actorTintColor, _tilemap); - //Debug.LogError($"CreateActors: {timer.ElapsedMilliseconds} ms"); + Debug.Log($"[{nameof(Scene)}] Actors initialized in {timer.ElapsedMilliseconds} ms"); timer.Restart(); InitSceneObjects(); - //Debug.LogError($"ActivateSceneObjects: {timer.ElapsedMilliseconds} ms"); + Debug.Log($"[{nameof(Scene)}] Objects initialized in {timer.ElapsedMilliseconds} ms"); timer.Stop(); } @@ -621,7 +626,7 @@ public void Execute(SceneOpenDoorCommand command) } else { - Debug.LogError($"Scene object not found or not activated yet: {command.ObjectId}."); + Debug.LogError($"[{nameof(Scene)}] Scene object not found or not activated yet: {command.ObjectId}."); } } @@ -648,7 +653,7 @@ public void Execute(SceneMoveObjectCommand command) Vector3.Distance(originalPosition + gameBoxPositionOffset, sceneObject.ObjectInfo.GameBoxPosition) < 0.01f) { // Don't do anything since this object has already been moved by the SceneStateManager - Debug.LogWarning($"Won't move object {command.ObjectId} since it has already been " + + Debug.LogWarning($"[{nameof(Scene)}] Won't move object {command.ObjectId} since it has already been " + $"moved by the SceneStateManager on scene load."); return; } @@ -667,7 +672,7 @@ public void Execute(SceneMoveObjectCommand command) } else { - Debug.LogError($"Scene object not found or not activated yet: {command.ObjectId}."); + Debug.LogError($"[{nameof(Scene)}] Scene object not found or not activated yet: {command.ObjectId}."); } } @@ -699,10 +704,23 @@ public void Execute(SceneCloseDoorCommand command) } else { - Debug.LogError($"Scene object not found or not activated yet: {command.ObjectId}."); + Debug.LogError($"[{nameof(Scene)}] Scene object not found or not activated yet: {command.ObjectId}."); } } + public void Execute(SceneEnableFogCommand command) + { + RenderSettings.fogMode = FogMode.Linear; + RenderSettings.fogColor = new Color( + command.Red / 255f, + command.Green / 255f, + command.Blue / 255f, + command.Alpha); + RenderSettings.fogStartDistance = GameBoxInterpreter.ToUnityDistance(command.StartDistance); + RenderSettings.fogEndDistance = GameBoxInterpreter.ToUnityDistance(command.EndDistance); + RenderSettings.fog = true; + } + public void Execute(FengYaSongCommand command) { switch (command.ModelType) diff --git a/Assets/Scripts/Pal3/Scene/SceneBase.cs b/Assets/Scripts/Pal3/Scene/SceneBase.cs index 16242c8d3..93a294f2c 100644 --- a/Assets/Scripts/Pal3/Scene/SceneBase.cs +++ b/Assets/Scripts/Pal3/Scene/SceneBase.cs @@ -80,7 +80,7 @@ protected bool IsNightScene() private void InitMeshData() { - var separator = CpkConstants.DirectorySeparator; + var separator = CpkConstants.DirectorySeparatorChar; var meshFileRelativePath = $"{ScnFile.SceneInfo.CityName}{CpkConstants.FileExtension}{separator}" + $"{ScnFile.SceneInfo.Model}{separator}"; @@ -94,7 +94,7 @@ private void InitMeshData() var sceneMetadataFilePrefix = meshFileRelativePath + ScnFile.SceneInfo.Model; ITextureResourceProvider sceneTextureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(sceneMetadataFilePrefix)); + Utility.GetDirectoryName(sceneMetadataFilePrefix, separator)); PolFile polFile = _resourceProvider.GetGameResourceFile(sceneMetadataFilePrefix + ".pol"); ScenePolyMesh = (polFile, sceneTextureProvider); @@ -165,7 +165,7 @@ private void InitActorData() } else { - Debug.LogError("FengYsSong actor id is already used by another actor!"); + Debug.LogError($"[{nameof(SceneBase)}] FengYsSong actor id is already used by another actor!"); } } #endif diff --git a/Assets/Scripts/Pal3/Scene/SceneManager.cs b/Assets/Scripts/Pal3/Scene/SceneManager.cs index 9b368b56d..cdd1297ee 100644 --- a/Assets/Scripts/Pal3/Scene/SceneManager.cs +++ b/Assets/Scripts/Pal3/Scene/SceneManager.cs @@ -79,7 +79,7 @@ public void LoadScene(string sceneFileName, string sceneName) ScnFile scnFile = _resourceProvider.GetScnFile(sceneFileName, sceneName); CommandDispatcher.Instance.Dispatch(new ScenePreLoadingNotification(scnFile.SceneInfo)); - Debug.Log("Loading scene: " + JsonConvert.SerializeObject(scnFile.SceneInfo)); + Debug.Log($"[{nameof(SceneManager)}] Loading scene: " + JsonConvert.SerializeObject(scnFile.SceneInfo)); _currentSceneRoot = new GameObject($"Scene_{sceneFileName}_{sceneName}"); _currentSceneRoot.transform.SetParent(null); @@ -101,7 +101,7 @@ public void LoadScene(string sceneFileName, string sceneName) ? new ScenePostLoadingNotification(scnFile.SceneInfo, sceneScriptId) : new ScenePostLoadingNotification(scnFile.SceneInfo, ScriptConstants.InvalidScriptId)); - Debug.Log($"Scene loaded in {timer.Elapsed.TotalSeconds} seconds."); + Debug.Log($"[{nameof(SceneManager)}] Scene loaded in {timer.Elapsed.TotalSeconds} seconds."); // Also a good time to collect garbage System.GC.Collect(); diff --git a/Assets/Scripts/Pal3/Scene/SceneObjectFactory.cs b/Assets/Scripts/Pal3/Scene/SceneObjectFactory.cs index e42701a0b..6c6f94a1d 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjectFactory.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjectFactory.cs @@ -47,7 +47,7 @@ public static SceneObject Create(ScnObjectInfo objectInfo, ScnSceneInfo sceneInf } } - Debug.LogError($"Scene object type: {objectInfo.Type} is not supported."); + Debug.LogError($"[{nameof(SceneObjectFactory)}] Scene object type: {objectInfo.Type} is not supported."); return null; } } diff --git a/Assets/Scripts/Pal3/Scene/SceneObjects/ClimbableObject.cs b/Assets/Scripts/Pal3/Scene/SceneObjects/ClimbableObject.cs index 175b3db33..4285780ee 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjects/ClimbableObject.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjects/ClimbableObject.cs @@ -62,7 +62,7 @@ public override GameObject Activate(GameResourceProvider resourceProvider, Color string indicatorModelPath = FileConstants.GetGameObjectModelFileVirtualPath(INTERACTION_INDICATOR_MODEL_FILE_NAME); CvdFile indicatorCvdFile = resourceProvider.GetGameResourceFile(indicatorModelPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(indicatorModelPath)); + Utility.GetDirectoryName(indicatorModelPath, CpkConstants.DirectorySeparatorChar)); // Upper indicator { diff --git a/Assets/Scripts/Pal3/Scene/SceneObjects/GeneralSceneObject.cs b/Assets/Scripts/Pal3/Scene/SceneObjects/GeneralSceneObject.cs index e0f05a42e..501e3e6f6 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjects/GeneralSceneObject.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjects/GeneralSceneObject.cs @@ -58,6 +58,11 @@ public override GameObject Activate(GameResourceProvider resourceProvider, Color _meshCollider = sceneGameObject.AddComponent(); } #elif PAL3A + // Object 46 in scene M03-1 should block player + if (SceneInfo.Is("m03", "1") && ObjectInfo.Id == 46) + { + _meshCollider = sceneGameObject.AddComponent(); + } // Object 15 in scene M12-1 should block player if (SceneInfo.Is("m12", "1") && ObjectInfo.Id == 15) { diff --git a/Assets/Scripts/Pal3/Scene/SceneObjects/ImpulsiveObject.cs b/Assets/Scripts/Pal3/Scene/SceneObjects/ImpulsiveObject.cs index b65b88ff4..88117865e 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjects/ImpulsiveObject.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjects/ImpulsiveObject.cs @@ -16,6 +16,7 @@ namespace Pal3.Scene.SceneObjects using Common; using Core.Animation; using Core.DataLoader; + using Core.DataReader.Cpk; using Core.DataReader.Pol; using Core.DataReader.Scn; using Core.Utils; @@ -62,7 +63,7 @@ public override GameObject Activate(GameResourceProvider resourceProvider, Color var subObjectModelPath = ModelFileVirtualPath.Insert(ModelFileVirtualPath.LastIndexOf('.'), "a"); PolFile polFile = resourceProvider.GetGameResourceFile(subObjectModelPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(subObjectModelPath)); + Utility.GetDirectoryName(subObjectModelPath, CpkConstants.DirectorySeparatorChar)); var subObjectModelRenderer = _subObjectGameObject.AddComponent(); subObjectModelRenderer.Render(polFile, textureProvider, diff --git a/Assets/Scripts/Pal3/Scene/SceneObjects/RotatingWallObject.cs b/Assets/Scripts/Pal3/Scene/SceneObjects/RotatingWallObject.cs index 628ab0977..14ffe572f 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjects/RotatingWallObject.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjects/RotatingWallObject.cs @@ -11,6 +11,7 @@ namespace Pal3.Scene.SceneObjects using Common; using Core.Animation; using Core.DataLoader; + using Core.DataReader.Cpk; using Core.DataReader.Pol; using Core.DataReader.Scn; using Core.Utils; @@ -48,7 +49,7 @@ public override GameObject Activate(GameResourceProvider resourceProvider, Color var subObjectModelPath = ModelFileVirtualPath.Replace("1.pol", "2.pol"); PolFile polFile = resourceProvider.GetGameResourceFile(subObjectModelPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(subObjectModelPath)); + Utility.GetDirectoryName(subObjectModelPath, CpkConstants.DirectorySeparatorChar)); var subObjectModelRenderer = _subObjectGameObject.AddComponent(); subObjectModelRenderer.Render(polFile, textureProvider, diff --git a/Assets/Scripts/Pal3/Scene/SceneObjects/SceneObject.cs b/Assets/Scripts/Pal3/Scene/SceneObjects/SceneObject.cs index 17bac8fe2..031bd9982 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjects/SceneObject.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjects/SceneObject.cs @@ -15,6 +15,7 @@ namespace Pal3.Scene.SceneObjects using Command.SceCommands; using Core.Animation; using Core.DataLoader; + using Core.DataReader.Cpk; using Core.DataReader.Cvd; using Core.DataReader.Pol; using Core.DataReader.Scn; @@ -66,7 +67,9 @@ protected SceneObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo, bool has ModelFileVirtualPath = hasModel && !string.IsNullOrEmpty(objectInfo.Name) ? GetModelFilePath(objectInfo, sceneInfo) : string.Empty; - ModelType = SceneObjectModelTypeResolver.GetType(Utility.GetFileName(ModelFileVirtualPath)); + ModelType = SceneObjectModelTypeResolver.GetType( + Utility.GetFileName(ModelFileVirtualPath, CpkConstants.DirectorySeparatorChar)); + GraphicsEffect = GetEffectType(objectInfo); } @@ -126,7 +129,7 @@ public virtual GameObject Activate(GameResourceProvider resourceProvider, { PolFile polFile = resourceProvider.GetGameResourceFile(ModelFileVirtualPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(ModelFileVirtualPath)); + Utility.GetDirectoryName(ModelFileVirtualPath, CpkConstants.DirectorySeparatorChar)); _polyModelRenderer = _sceneObjectGameObject.AddComponent(); _polyModelRenderer.Render(polFile, textureProvider, @@ -137,7 +140,7 @@ public virtual GameObject Activate(GameResourceProvider resourceProvider, { CvdFile cvdFile = resourceProvider.GetGameResourceFile(ModelFileVirtualPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(ModelFileVirtualPath)); + Utility.GetDirectoryName(ModelFileVirtualPath, CpkConstants.DirectorySeparatorChar)); _cvdModelRenderer = _sceneObjectGameObject.AddComponent(); _cvdModelRenderer.Init(cvdFile, textureProvider, @@ -168,7 +171,7 @@ public virtual GameObject Activate(GameResourceProvider resourceProvider, #elif PAL3A var effectParameter = (uint)ObjectInfo.Parameters[5]; #endif - Debug.Log($"Adding {GraphicsEffect} [{effectParameter}] effect for scene object {ObjectInfo.Id}"); + Debug.Log($"[{nameof(SceneObject)}] Adding {GraphicsEffect} [{effectParameter}] effect for scene object {ObjectInfo.Id}"); _effectComponent!.Init(resourceProvider, effectParameter); } diff --git a/Assets/Scripts/Pal3/Scene/SceneObjects/SwitchObject.cs b/Assets/Scripts/Pal3/Scene/SceneObjects/SwitchObject.cs index fcec3c66e..846011a92 100644 --- a/Assets/Scripts/Pal3/Scene/SceneObjects/SwitchObject.cs +++ b/Assets/Scripts/Pal3/Scene/SceneObjects/SwitchObject.cs @@ -77,7 +77,7 @@ public override GameObject Activate(GameResourceProvider resourceProvider, Color CvdFile cvdFile = resourceProvider.GetGameResourceFile(interactionIndicatorModelPath); ITextureResourceProvider textureProvider = resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(interactionIndicatorModelPath)); + Utility.GetDirectoryName(interactionIndicatorModelPath, CpkConstants.DirectorySeparatorChar)); _interactionIndicatorRenderer = _interactionIndicatorGameObject.AddComponent(); _interactionIndicatorRenderer.Init(cvdFile, textureProvider, diff --git a/Assets/Scripts/Pal3/Scene/Tilemap.cs b/Assets/Scripts/Pal3/Scene/Tilemap.cs index afb3d7870..e3fbeba15 100644 --- a/Assets/Scripts/Pal3/Scene/Tilemap.cs +++ b/Assets/Scripts/Pal3/Scene/Tilemap.cs @@ -115,13 +115,13 @@ public Vector2Int[] FindPathToTilePositionThreadSafe(Vector2Int from, { if (!IsTilePositionInsideTileMap(from, layerIndex)) { - Debug.LogWarning("From position is not inside tilemap bounds."); + Debug.LogWarning($"[{nameof(Tilemap)}] From position is not inside tilemap bounds."); return Array.Empty(); } if (!IsTilePositionInsideTileMap(to, layerIndex)) { - Debug.LogWarning("To position is not inside tilemap bounds."); + Debug.LogWarning($"[{nameof(Tilemap)}] To position is not inside tilemap bounds."); return Array.Empty(); } @@ -135,7 +135,7 @@ public Vector2Int[] FindPathToTilePositionThreadSafe(Vector2Int from, } else { - Debug.LogWarning("To position is not walkable."); + Debug.LogWarning($"[{nameof(Tilemap)}] To position is not walkable."); return Array.Empty(); } } diff --git a/Assets/Scripts/Pal3/Script/PalScriptRunner.cs b/Assets/Scripts/Pal3/Script/PalScriptRunner.cs index 400e0b229..7b4dc524d 100644 --- a/Assets/Scripts/Pal3/Script/PalScriptRunner.cs +++ b/Assets/Scripts/Pal3/Script/PalScriptRunner.cs @@ -93,7 +93,7 @@ public static PalScriptRunner Create(SceFile sceFile, } SceScriptBlock sceScriptBlock = sceFile.ScriptBlocks[scriptId]; - Debug.Log($"Create script runner: {sceScriptBlock.Id} {sceScriptBlock.Description}"); + Debug.Log($"[{nameof(PalScriptRunner)}] Create script runner: {sceScriptBlock.Id} {sceScriptBlock.Description}"); return new PalScriptRunner(scriptType, scriptId, sceScriptBlock, globalVariables, sceFile.Codepage); } @@ -183,7 +183,8 @@ private void ExecuteNextCommand() if (command == null) { - UnknownSceCommandAnalyzer.AnalyzeCommand(_scriptDataReader, commandId, parameterFlag, _codepage); + // All commands are fully implemented, so this should never happen + //UnknownSceCommandAnalyzer.AnalyzeCommand(_scriptDataReader, commandId, parameterFlag, _codepage); } else { @@ -213,12 +214,12 @@ private void SetVariableValue(int variableName, int value) { if (variableName < 0) { - Debug.LogWarning($"Set global var {variableName} with value: {value}"); + Debug.LogWarning($"[{nameof(PalScriptRunner)}] Set global var {variableName} with value: {value}"); _globalVariables[variableName] = value; } else { - Debug.LogWarning($"Setting value for user var: {variableName}, value: {value}"); + Debug.LogWarning($"[{nameof(PalScriptRunner)}] Setting value for user var: {variableName}, value: {value}"); _localVariables[variableName] = value; } } diff --git a/Assets/Scripts/Pal3/Script/ScriptManager.cs b/Assets/Scripts/Pal3/Script/ScriptManager.cs index 62dfb341c..8b8ba2899 100644 --- a/Assets/Scripts/Pal3/Script/ScriptManager.cs +++ b/Assets/Scripts/Pal3/Script/ScriptManager.cs @@ -95,24 +95,24 @@ public bool AddScript(uint scriptId, bool isBigMapScript = false) if (_pendingScripts.Any(s => s.ScriptId == scriptId) || _runningScripts.Any(s => s.ScriptId == scriptId)) { - Debug.LogError($"Script is already running: {scriptId}"); + Debug.LogError($"[{nameof(ScriptManager)}] Script is already running: {scriptId}"); return false; } PalScriptRunner scriptRunner; if (isBigMapScript) { - Debug.Log($"Add BigMap script id: {scriptId}"); + Debug.Log($"[{nameof(ScriptManager)}] Add BigMap script id: {scriptId}"); scriptRunner = PalScriptRunner.Create(_bigMapSceFile, PalScriptType.BigMap, scriptId, _globalVariables); } else if (scriptId <= ScriptConstants.SystemScriptIdMax) { - Debug.Log($"Add system script id: {scriptId}"); + Debug.Log($"[{nameof(ScriptManager)}] Add system script id: {scriptId}"); scriptRunner = PalScriptRunner.Create(_systemSceFile, PalScriptType.System, scriptId, _globalVariables); } else { - Debug.Log($"Add scene script id: {scriptId}"); + Debug.Log($"[{nameof(ScriptManager)}] Add scene script id: {scriptId}"); scriptRunner = PalScriptRunner.Create(_currentSceFile, PalScriptType.Scene, scriptId, _globalVariables); } @@ -125,8 +125,8 @@ private void OnCommandExecutionRequested(object sender, ICommand command) { var sceCommandId = command.GetType().GetCustomAttribute()?.Id; - Debug.Log($"{((PalScriptRunner)sender).ScriptType} Script {((PalScriptRunner)sender).ScriptId} : [{sceCommandId}] " + - $"{command.GetType().Name.Replace("Command", "")} " + + Debug.Log($"[{nameof(ScriptManager)}] {((PalScriptRunner)sender).ScriptType} Script {((PalScriptRunner)sender).ScriptId} : " + + $"[{sceCommandId}] {command.GetType().Name.Replace("Command", "")} " + $"{JsonConvert.SerializeObject(command)}"); CommandDispatcher.Instance.Dispatch(command); @@ -155,7 +155,7 @@ public void Update(float deltaTime) finishedScript.OnCommandExecutionRequested -= OnCommandExecutionRequested; finishedScript.Dispose(); - Debug.Log($"Script {finishedScript.ScriptId} finished running."); + Debug.Log($"[{nameof(ScriptManager)}] Script {finishedScript.ScriptId} finished running."); CommandDispatcher.Instance.Dispatch( new ScriptFinishedRunningNotification(finishedScript.ScriptId, finishedScript.ScriptType)); } @@ -206,7 +206,7 @@ public void Execute(ScriptVarSetValueCommand command) { if (command.Variable < 0) { - Debug.LogWarning($"Set global var {command.Variable} with value: {command.Value}"); + Debug.LogWarning($"[{nameof(ScriptManager)}] Set global var {command.Variable} with value: {command.Value}"); SetGlobalVariable(command.Variable, command.Value); } } diff --git a/Assets/Scripts/Pal3/Settings/GameSettings.cs b/Assets/Scripts/Pal3/Settings/GameSettings.cs index 6ebbd217a..8628d5c12 100644 --- a/Assets/Scripts/Pal3/Settings/GameSettings.cs +++ b/Assets/Scripts/Pal3/Settings/GameSettings.cs @@ -10,6 +10,7 @@ namespace Pal3.Settings using System.ComponentModel; using System.IO; using System.Reflection; + using System.Text; using Command; using Command.InternalCommands; using Core.Utils; @@ -69,7 +70,7 @@ public GameSettings(ITransactionalKeyValueStore settingsStore, bool isOpenSource DebugLogConsole.AddCommand("Settings.Reset", "重置所有设置", ResetSettings); DebugLogConsole.AddCommand("Settings.Print", - "打印所有设置", PrintSettings); + "打印所有设置", PrintCurrentSettings); } private void OnPropertyChanged(object sender, PropertyChangedEventArgs args) @@ -234,19 +235,19 @@ public void InitOrLoadSettings() } else { + #if UNITY_ANDROID // AO not working well with OpenGL on Android + IsAmbientOcclusionEnabled = false; + #else if (SettingsStore.TryGet(nameof(IsAmbientOcclusionEnabled), out bool isAmbientOcclusionEnabled)) { IsAmbientOcclusionEnabled = isAmbientOcclusionEnabled; } else { - #if UNITY_ANDROID // AO not working well with OpenGL on Android - IsAmbientOcclusionEnabled = false; - #else // Enable ambient occlusion by default on desktop devices IsAmbientOcclusionEnabled = Utility.IsDesktopDevice(); - #endif } + #endif } if (SettingsStore.TryGet(nameof(IsVoiceOverEnabled), out bool isVoiceOverEnabled)) @@ -263,6 +264,9 @@ public void InitOrLoadSettings() { GameDataFolderPath = gameDataFolderPath; } + + Debug.Log($"[{nameof(GameSettings)}] Settings initialized."); + PrintCurrentSettings(); } public IEnumerable GetGameDataFolderSearchLocations() @@ -308,14 +312,19 @@ public void ResetSettings() SaveSettings(); } - public void PrintSettings() + public void PrintCurrentSettings() { - Debug.Log("Current game settings:"); + Debug.Log($"[{nameof(GameSettings)}] Current settings: {this}"); + } + public override string ToString() + { + StringBuilder sb = new (); foreach (PropertyInfo property in typeof(SettingsBase).GetProperties()) { - Debug.Log($"{property.Name}: {property.GetValue(this)}"); + sb.Append($", {property.Name}: {property.GetValue(this)}"); } + return sb.Length == 0 ? string.Empty : sb.ToString()[2..]; } public void Dispose() diff --git a/Assets/Scripts/Pal3/Settings/PlayerPrefsStore.cs b/Assets/Scripts/Pal3/Settings/PlayerPrefsStore.cs index 3fcc17abb..5fa80ea5a 100644 --- a/Assets/Scripts/Pal3/Settings/PlayerPrefsStore.cs +++ b/Assets/Scripts/Pal3/Settings/PlayerPrefsStore.cs @@ -73,7 +73,7 @@ public bool TryGet(string key, out T value) return true; } - Debug.LogError("Unsupported type: " + typeof(T).Name); + Debug.LogError($"[{nameof(PlayerPrefsStore)}] Unsupported type: " + typeof(T).Name); value = default; return false; } diff --git a/Assets/Scripts/Pal3/State/GameStateManager.cs b/Assets/Scripts/Pal3/State/GameStateManager.cs index 89967ecd9..ad4b2be47 100644 --- a/Assets/Scripts/Pal3/State/GameStateManager.cs +++ b/Assets/Scripts/Pal3/State/GameStateManager.cs @@ -78,7 +78,7 @@ public void GoToState(GameState newState) } } - Debug.Log($"Goto State: {newState.ToString()}"); + Debug.Log($"[{nameof(GameStateManager)}] Goto State: {newState.ToString()}"); _previousState = _currentState; _currentState = newState; diff --git a/Assets/Scripts/Pal3/State/SaveManager.cs b/Assets/Scripts/Pal3/State/SaveManager.cs index 9f88165d3..930fa6320 100644 --- a/Assets/Scripts/Pal3/State/SaveManager.cs +++ b/Assets/Scripts/Pal3/State/SaveManager.cs @@ -135,12 +135,12 @@ public bool SaveGameStateToSlot(int slotIndex, IList stateCommands) try { File.WriteAllText(saveFilePath, string.Join('\n', stateCommands.Select(CommandExtensions.ToString).ToList())); - Debug.Log($"Game state saved to: {saveFilePath}"); + Debug.Log($"[{nameof(SaveManager)}] Game state saved to: {saveFilePath}"); return true; } catch (Exception ex) { - Debug.LogError($"Failed to save game state to file: {saveFilePath} with exception: {ex}"); + Debug.LogError($"[{nameof(SaveManager)}] Failed to save game state to file: {saveFilePath} with exception: {ex}"); return false; } } @@ -371,7 +371,7 @@ public void Execute(GameStateChangedNotification command) _lastAutoSaveTime = Time.realtimeSinceStartupAsDouble; } - Debug.LogWarning($"Game state auto-saved to slot {AutoSaveSlotIndex}."); + Debug.LogWarning($"[{nameof(SaveManager)}] Game state auto-saved to slot {AutoSaveSlotIndex}."); } } diff --git a/Assets/Scripts/Pal3/UI/RoundedFrostedGlassImage.cs b/Assets/Scripts/Pal3/UI/RoundedFrostedGlassImage.cs index 755a5a2ae..c5613cede 100644 --- a/Assets/Scripts/Pal3/UI/RoundedFrostedGlassImage.cs +++ b/Assets/Scripts/Pal3/UI/RoundedFrostedGlassImage.cs @@ -67,7 +67,7 @@ private void Init() _shader = Shader.Find("Pal3/RoundedFrostedGlass"); if (_shader == null) { - Debug.LogError("Shader not found: Pal3/RoundedFrostedGlass"); + Debug.LogError($"[{nameof(RoundedFrostedGlassImage)}] Shader not found: Pal3/RoundedFrostedGlass"); return; } } diff --git a/Assets/Scripts/Pal3/Video/VideoManager.cs b/Assets/Scripts/Pal3/Video/VideoManager.cs index 0655f5173..27f521c27 100644 --- a/Assets/Scripts/Pal3/Video/VideoManager.cs +++ b/Assets/Scripts/Pal3/Video/VideoManager.cs @@ -114,7 +114,7 @@ public void Execute(PlayVideoCommand command) } catch (Exception ex) { - Debug.LogError(ex); + Debug.LogError($"[{nameof(VideoManager)}] Exception: {ex}"); _videoPlayingWaiter.CancelWait(); _gameStateManager.GoToPreviousState(); } diff --git a/Assets/Scripts/ResourceViewer/GameResourceViewer.cs b/Assets/Scripts/ResourceViewer/GameResourceViewer.cs index 635873dfb..a23beecc5 100644 --- a/Assets/Scripts/ResourceViewer/GameResourceViewer.cs +++ b/Assets/Scripts/ResourceViewer/GameResourceViewer.cs @@ -263,9 +263,9 @@ private bool LoadPol(string filePath) { PolFile polyFile = _resourceProvider.GetGameResourceFile(filePath); ITextureResourceProvider textureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(filePath)); + Utility.GetDirectoryName(filePath, CpkConstants.DirectorySeparatorChar)); - var mesh = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator)); + var mesh = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparatorChar)); var meshRenderer = mesh.AddComponent(); mesh.transform.SetParent(_renderingRoot.transform); meshRenderer.Render(polyFile, @@ -298,9 +298,9 @@ private bool LoadCvd(string filePath) { CvdFile cvdFile = _resourceProvider.GetGameResourceFile(filePath); ITextureResourceProvider textureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(filePath)); + Utility.GetDirectoryName(filePath, CpkConstants.DirectorySeparatorChar)); - var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator)); + var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparatorChar)); var meshRenderer = animationNode.AddComponent(); animationNode.transform.SetParent(_renderingRoot.transform); @@ -335,14 +335,14 @@ private bool LoadMv3(string filePath) { Mv3File mv3File = _resourceProvider.GetGameResourceFile(filePath); ITextureResourceProvider textureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(filePath)); + Utility.GetDirectoryName(filePath, CpkConstants.DirectorySeparatorChar)); if (mv3File.Meshes.Length > 1) { Debug.LogWarning($"{filePath} has {mv3File.Meshes.Length} meshes."); } - var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator)); + var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparatorChar)); animationNode.transform.SetParent(_renderingRoot.transform); var mv3AnimationRenderer = animationNode.AddComponent(); @@ -397,26 +397,26 @@ private bool LoadMov(string filePath) try { - var actorFolderPath = Utility.GetRelativeDirectoryPath(filePath); - var actorName = Utility.GetFileName(actorFolderPath); + var actorFolderPath = Utility.GetDirectoryName(filePath, CpkConstants.DirectorySeparatorChar); + var actorName = Utility.GetFileName(actorFolderPath, CpkConstants.DirectorySeparatorChar); var mshFilePath = filePath.Replace(".mov", ".msh", StringComparison.OrdinalIgnoreCase); if (!_fileSystem.FileExists(mshFilePath)) { - mshFilePath = actorFolderPath + CpkConstants.DirectorySeparator + actorName + ".msh"; + mshFilePath = actorFolderPath + CpkConstants.DirectorySeparatorChar + actorName + ".msh"; } var mshFile = _resourceProvider.GetGameResourceFile(mshFilePath); - string mtlFilePath = actorFolderPath + CpkConstants.DirectorySeparator + actorName + ".mtl"; + string mtlFilePath = actorFolderPath + CpkConstants.DirectorySeparatorChar + actorName + ".mtl"; var mtlFile = _resourceProvider.GetGameResourceFile(mtlFilePath); var movFile = _resourceProvider.GetGameResourceFile(filePath); ITextureResourceProvider textureProvider = _resourceProvider.CreateTextureResourceProvider( - Utility.GetRelativeDirectoryPath(mtlFilePath)); + Utility.GetDirectoryName(mtlFilePath, CpkConstants.DirectorySeparatorChar)); - var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparator)); + var animationNode = new GameObject(Utility.GetFileName(filePath, CpkConstants.DirectorySeparatorChar)); animationNode.transform.SetParent(_renderingRoot.transform); var skeletalModelRenderer = animationNode.GetOrAddComponent(); @@ -489,7 +489,7 @@ private IEnumerator ExtractAllCpkArchivesInternalAsync(string outputFolderPath) { foreach (string movieCpkFileName in FileConstants.MovieCpkFileNames) { - var movieCpkFilePath = FileConstants.GetMovieCpkFilePath(movieCpkFileName); + var movieCpkFilePath = FileConstants.GetMovieCpkFileRelativePath(movieCpkFileName); if (File.Exists(_fileSystem.GetRootPath() + movieCpkFilePath)) { _fileSystem.Mount(movieCpkFilePath, DEFAULT_CODE_PAGE); @@ -607,7 +607,7 @@ private bool DecompileSce(string filePath, string outputFolderPath, bool dialogu : $"{scriptDataReader.BaseStream.Length} __END__\n"); } - var cpkFileName = filePath.Substring(filePath.LastIndexOf(CpkConstants.DirectorySeparator) + 1).Replace(".sce", ""); + var cpkFileName = filePath.Substring(filePath.LastIndexOf(CpkConstants.DirectorySeparatorChar) + 1).Replace(".sce", ""); var sceneName = SceneConstants.SceneCpkNameInfos .FirstOrDefault(_ => string.Equals(_.cpkName, cpkFileName + CpkConstants.FileExtension, StringComparison.OrdinalIgnoreCase)).sceneName; @@ -633,7 +633,7 @@ private bool DecompileSce(string filePath, string outputFolderPath, bool dialogu private bool LoadMp3(string filePath) { - nowPlayingTextUI.text = "* Now Playing: " + Utility.GetFileName(filePath, CpkConstants.DirectorySeparator); + nowPlayingTextUI.text = "* Now Playing: " + Utility.GetFileName(filePath, CpkConstants.DirectorySeparatorChar); StartCoroutine(LoadMp3AudioClipAsync(filePath, _resourceProvider.GetMusicFilePathInCacheFolder(filePath))); return true; diff --git a/Packages/manifest.json b/Packages/manifest.json index 3b71ec8da..ede5ca1b5 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -8,6 +8,7 @@ "com.unity.ide.vscode": "1.2.5", "com.unity.inputsystem": "1.6.3", "com.unity.memoryprofiler": "1.0.0", + "com.unity.mobile.android-logcat": "1.3.2", "com.unity.postprocessing": "3.2.2", "com.unity.test-framework": "1.1.33", "com.unity.textmeshpro": "3.0.6", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 24468032f..da5bfed29 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -87,6 +87,13 @@ }, "url": "https://packages.unity.com" }, + "com.unity.mobile.android-logcat": { + "version": "1.3.2", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.performance.profile-analyzer": { "version": "1.2.2", "depth": 1,