mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7727a55366 | ||
|
|
795fb3d576 |
No files matched your search
@@ -24,7 +24,9 @@ namespace Pal3.Core.FileSystem
|
||||
private readonly Crc32Hash _crcHash;
|
||||
private readonly int _codepage;
|
||||
|
||||
public CpkFileSystem(string rootPath, Crc32Hash crcHash, int codepage)
|
||||
public CpkFileSystem(string rootPath,
|
||||
Crc32Hash crcHash,
|
||||
int codepage)
|
||||
{
|
||||
if (!rootPath.EndsWith(Path.DirectorySeparatorChar))
|
||||
{
|
||||
@@ -260,7 +262,7 @@ namespace Pal3.Core.FileSystem
|
||||
{
|
||||
if (node.IsDirectory)
|
||||
{
|
||||
foreach (var result in SearchInternal(node.Children, keyword))
|
||||
foreach (string result in SearchInternal(node.Children, keyword))
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2024, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Core.FileSystem
|
||||
{
|
||||
public enum FileSystemMode
|
||||
{
|
||||
ArchiveOnly, // only read from archives
|
||||
DiskAndArchive, // read from disk first, then archives
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88e70785d9894247a8ab3a4d69878588
|
||||
timeCreated: 1711763327
|
||||
@@ -5,19 +5,11 @@
|
||||
|
||||
namespace Pal3.Core.FileSystem
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// File system wrapper for CPack archives
|
||||
/// </summary>
|
||||
public interface ICpkFileSystem
|
||||
public interface ICpkFileSystem : IFileSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Get file system's root path.
|
||||
/// </summary>
|
||||
/// <returns>Root directory path</returns>
|
||||
public string GetRootPath();
|
||||
|
||||
/// <summary>
|
||||
/// Mount a Cpk archive to the file system.
|
||||
/// </summary>
|
||||
@@ -25,14 +17,6 @@ namespace Pal3.Core.FileSystem
|
||||
/// <param name="codepage">Codepage CPK file uses for encoding text info</param>
|
||||
public void Mount(string cpkFileRelativePath, int codepage);
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists in the archive or any of the segmented archives using virtual path.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path {Cpk file name}\{File relative path inside archive}
|
||||
/// Example: music.cpk\music\PI01.mp3</param>
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath);
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists in the archive or any of the segmented archives using virtual path.
|
||||
/// </summary>
|
||||
@@ -42,13 +26,6 @@ namespace Pal3.Core.FileSystem
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath, out string archiveName);
|
||||
|
||||
/// <summary>
|
||||
/// Read all bytes of the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path inside CPK archive</param>
|
||||
/// <returns>Decompressed, ready-to-go file content in byte array</returns>
|
||||
public byte[] ReadAllBytes(string fileVirtualPath);
|
||||
|
||||
/// <summary>
|
||||
/// Preload archive into memory for faster read performance.
|
||||
/// </summary>
|
||||
@@ -68,20 +45,5 @@ namespace Pal3.Core.FileSystem
|
||||
/// Extract all archives to the specified destination
|
||||
/// </summary>
|
||||
public void ExtractTo(string outputFolder);
|
||||
|
||||
/// <summary>
|
||||
/// Searches for files in the file system that match the specified keyword.
|
||||
/// </summary>
|
||||
/// <param name="keyword">The keyword to search for. If empty, all files will be returned.</param>
|
||||
/// <returns>A list of file paths that match the specified keyword.</returns>
|
||||
public IList<string> Search(string keyword = "");
|
||||
|
||||
/// <summary>
|
||||
/// Searches for files in the CPK file system that match the specified keywords.
|
||||
/// </summary>
|
||||
/// <param name="keywords">The list of keywords to search for.</param>
|
||||
/// <returns>A dictionary where the keys are the file paths of the matching files,
|
||||
/// and the values are the lines in the files that contain the keywords.</returns>
|
||||
public IDictionary<string, IList<string>> BatchSearch(IList<string> keywords);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2024, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Core.FileSystem
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for file system operations.
|
||||
/// </summary>
|
||||
public interface IFileSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Get file system's root path.
|
||||
/// </summary>
|
||||
/// <returns>Root directory path</returns>
|
||||
public string GetRootPath();
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists in the archive or any of the segmented archives using virtual path.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path
|
||||
/// Example: music.cpk\music\PI01.mp3</param>
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath);
|
||||
|
||||
/// <summary>
|
||||
/// Read all bytes of the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path</param>
|
||||
/// <returns>File content in byte array</returns>
|
||||
public byte[] ReadAllBytes(string fileVirtualPath);
|
||||
|
||||
/// <summary>
|
||||
/// Searches for files in the file system that match the specified keyword.
|
||||
/// </summary>
|
||||
/// <param name="keyword">The keyword to search for. If empty, all files will be returned.</param>
|
||||
/// <returns>A list of file paths that match the specified keyword.</returns>
|
||||
public IList<string> Search(string keyword = "");
|
||||
|
||||
/// <summary>
|
||||
/// Searches for files in the CPK file system that match the specified keywords.
|
||||
/// </summary>
|
||||
/// <param name="keywords">The list of keywords to search for.</param>
|
||||
/// <returns>A dictionary where the keys are the file paths of the matching files,
|
||||
/// and the values are the lines in the files that contain the keywords.</returns>
|
||||
public IDictionary<string, IList<string>> BatchSearch(IList<string> keywords);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24423aca0f7b46f78c51a215ea28dccb
|
||||
timeCreated: 1711703961
|
||||
+2
-2
@@ -18,14 +18,14 @@ namespace Pal3.Game.Data
|
||||
/// <summary>
|
||||
/// Cache/dispose Cpk archive into memory based on scenarios.
|
||||
/// </summary>
|
||||
public sealed class FileSystemCacheManager : IDisposable,
|
||||
public sealed class CpkArchiveCacheManager : IDisposable,
|
||||
ICommandExecutor<ScenePreLoadingNotification>
|
||||
{
|
||||
private readonly ICpkFileSystem _fileSystem;
|
||||
private string _currentCityName;
|
||||
private string _currentSceneName;
|
||||
|
||||
public FileSystemCacheManager(ICpkFileSystem fileSystem)
|
||||
public CpkArchiveCacheManager(ICpkFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = Requires.IsNotNull(fileSystem, nameof(fileSystem));
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
File renamed without changes.
@@ -50,7 +50,7 @@ namespace Pal3.Game.Data
|
||||
|
||||
private const char DIR_SEPARATOR = CpkConstants.DirectorySeparatorChar;
|
||||
|
||||
private readonly ICpkFileSystem _fileSystem;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ITextureLoaderFactory _textureLoaderFactory;
|
||||
private readonly ITextureFactory _textureFactory;
|
||||
private readonly IMaterialManager _unlitMaterialManager;
|
||||
@@ -69,7 +69,7 @@ namespace Pal3.Game.Data
|
||||
|
||||
private readonly int _codepage;
|
||||
|
||||
public GameResourceProvider(ICpkFileSystem fileSystem,
|
||||
public GameResourceProvider(IFileSystem fileSystem,
|
||||
ITextureLoaderFactory textureLoaderFactory,
|
||||
ITextureFactory textureFactory,
|
||||
IMaterialManager unlitMaterialManager,
|
||||
|
||||
@@ -15,13 +15,13 @@ namespace Pal3.Game.Data
|
||||
|
||||
public sealed class TextureProvider : TextureProviderBase, ITextureResourceProvider
|
||||
{
|
||||
private readonly ICpkFileSystem _fileSystem;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ITextureLoaderFactory _textureLoaderFactory;
|
||||
private readonly ITextureFactory _textureFactory;
|
||||
private readonly ITextureCache _textureCache;
|
||||
private readonly string _relativeDirectoryPath;
|
||||
|
||||
public TextureProvider(ICpkFileSystem fileSystem,
|
||||
public TextureProvider(IFileSystem fileSystem,
|
||||
ITextureLoaderFactory textureLoaderFactory,
|
||||
ITextureFactory textureFactory,
|
||||
string relativeDirectoryPath,
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Pal3.Game.Data
|
||||
|
||||
public abstract class TextureProviderBase
|
||||
{
|
||||
protected ITexture2D GetTexture(ICpkFileSystem fileSystem,
|
||||
protected ITexture2D GetTexture(IFileSystem fileSystem,
|
||||
string texturePath,
|
||||
ITextureLoader textureLoader,
|
||||
out bool hasAlphaChannel)
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Pal3.Game
|
||||
private ICpkFileSystem _fileSystem;
|
||||
private GameResourceProvider _gameResourceProvider;
|
||||
private IPhysicsManager _physicsManager;
|
||||
private FileSystemCacheManager _fileSystemCacheManager;
|
||||
private CpkArchiveCacheManager _cpkArchiveCacheManager;
|
||||
private PlayerInputActions _inputActions;
|
||||
private InputManager _inputManager;
|
||||
private GameStateManager _gameStateManager;
|
||||
@@ -235,8 +235,8 @@ namespace Pal3.Game
|
||||
ServiceLocator.Instance.Register<IPhysicsManager>(_physicsManager =
|
||||
new PhysicsManager(mainCamera));
|
||||
|
||||
ServiceLocator.Instance.Register(_fileSystemCacheManager =
|
||||
new FileSystemCacheManager(_fileSystem)
|
||||
ServiceLocator.Instance.Register(_cpkArchiveCacheManager =
|
||||
new CpkArchiveCacheManager(_fileSystem)
|
||||
);
|
||||
|
||||
ServiceLocator.Instance.Register(_inputActions =
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.inputsystem": "1.7.0",
|
||||
"com.unity.memoryprofiler": "1.1.0",
|
||||
"com.unity.mobile.android-logcat": "1.4.0",
|
||||
"com.unity.mobile.android-logcat": "1.4.1",
|
||||
"com.unity.postprocessing": "3.4.0",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.textmeshpro": "3.0.8",
|
||||
@@ -16,7 +16,7 @@
|
||||
"com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.6",
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.visualscripting": "1.9.2",
|
||||
"com.unity.visualscripting": "1.9.4",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.mobile.android-logcat": {
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
@@ -205,7 +205,7 @@
|
||||
}
|
||||
},
|
||||
"com.unity.visualscripting": {
|
||||
"version": "1.9.2",
|
||||
"version": "1.9.4",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1014,6 +1014,7 @@ PlayerSettings:
|
||||
metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0}
|
||||
metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1}
|
||||
metroSplashScreenUseBackgroundColor: 0
|
||||
syncCapabilities: 0
|
||||
platformCapabilities: {}
|
||||
metroTargetDeviceFamilies: {}
|
||||
metroFTAName:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2022.3.22f1
|
||||
m_EditorVersionWithRevision: 2022.3.22f1 (887be4894c44)
|
||||
m_EditorVersion: 2022.3.26f1
|
||||
m_EditorVersionWithRevision: 2022.3.26f1 (ec6cd8118806)
|
||||
Reference in new issue
Block a user