Browse Source

feat: 添加新的文件系统

LanzaSchneider 2 years ago
parent
commit
60e50c8b84

+ 27 - 32
Content.cs

@@ -1,40 +1,35 @@
 using System;
-using Zio.FileSystems;
 
-namespace TBL.GodotSharp.Content;
-
-/// <summary>
-/// 内容模块扩展功能类
-/// </summary>
-public static class Content
+namespace TBL.GodotSharp.Content
 {
     /// <summary>
-    /// 文件系统容器
-    /// </summary>
-    public static readonly AggregateFileSystem FileSystem = new AggregateFileSystem();
-    
-    /// <summary>
-    /// 判断 <paramref name="actualVersion"/> 能否满足 <paramref name="targetVersion"/> 的版本要求
-    /// <para>用于内容包之间的依赖可用性检测</para>
+    /// 内容模块扩展功能类
     /// </summary>
-    /// <param name="actualVersion">当前版本</param>
-    /// <param name="targetVersion">要求的版本</param>
-    /// <param name="level">兼容级别</param>
-    public static bool IsCompatibleWith(Version actualVersion, Version targetVersion, int level)
+    public static class Content
     {
-        // 主版本号
-        if (actualVersion.Major != targetVersion.Major)
-            return false;
-        if (level < 1)
-            return true;
-        // 次版本号
-        if (actualVersion.Minor != targetVersion.Minor)
-            return false;
-        if (level < 2)
+        /// <summary>
+        /// 判断 <paramref name="actualVersion"/> 能否满足 <paramref name="targetVersion"/> 的版本要求
+        /// <para>用于内容包之间的依赖可用性检测</para>
+        /// </summary>
+        /// <param name="actualVersion">当前版本</param>
+        /// <param name="targetVersion">要求的版本</param>
+        /// <param name="level">兼容级别</param>
+        public static bool IsCompatibleWith(Version actualVersion, Version targetVersion, int level)
+        {
+            // 主版本号
+            if (actualVersion.Major != targetVersion.Major)
+                return false;
+            if (level < 1)
+                return true;
+            // 次版本号
+            if (actualVersion.Minor != targetVersion.Minor)
+                return false;
+            if (level < 2)
+                return true;
+            // 构建版本号
+            if (actualVersion.Build != targetVersion.Build)
+                return false;
             return true;
-        // 构建版本号
-        if (actualVersion.Build != targetVersion.Build)
-            return false;
-        return true;
+        }
     }
-}
+}

+ 146 - 140
FileSystem/GodotFileSystem.cs

@@ -1,182 +1,188 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Text.RegularExpressions;
 using Godot;
 using TBL.GodotSharp.IO.File;
 using Zio;
 
-namespace TBL.GodotSharp.Content.FileSystem;
-
-/// <summary>
-/// Godot 文件系统
-/// </summary>
-public class GodotFileSystem : Zio.FileSystems.FileSystem
+namespace TBL.GodotSharp.Content.FileSystem
 {
     /// <summary>
-    /// 根目录
+    /// Godot 文件系统
     /// </summary>
-    private readonly string _rootPath;
+    public class GodotFileSystem : Zio.FileSystems.FileSystem
+    {
+        /// <summary>
+        /// 根目录
+        /// </summary>
+        private readonly string _rootPath;
 
-    /// <summary>
-    /// 目录工具
-    /// </summary>
-    private readonly Godot.Directory _directoryTool;
+        /// <summary>
+        /// 目录工具
+        /// </summary>
+        private readonly Godot.Directory _directoryTool;
 
-    public GodotFileSystem(string rootPath)
-    {
-        _rootPath = rootPath;
-        _directoryTool = new Godot.Directory();
-    }
+        public GodotFileSystem(string rootPath)
+        {
+            _rootPath = rootPath;
+            _directoryTool = new Godot.Directory();
+        }
 
-    private string GetFullPath(UPath uPath) => $"{_rootPath}{uPath}";
-    
-    protected override void CreateDirectoryImpl(UPath path)
-    {
-        _directoryTool.MakeDirRecursive(GetFullPath(path));
-    }
+        private string GetFullPath(UPath uPath) => $"{_rootPath}{uPath}";
 
-    protected override bool DirectoryExistsImpl(UPath path) => _directoryTool.DirExists(GetFullPath(path));
-    
-    protected override bool FileExistsImpl(UPath path) => _directoryTool.FileExists(GetFullPath(path));
-    
-    protected override Stream OpenFileImpl(UPath path, FileMode mode, FileAccess access, FileShare share)
-    {
-        if (mode == FileMode.Open && access == FileAccess.Read)
+        protected override void CreateDirectoryImpl(UPath path)
         {
-            return new GodotFileStream(GetFullPath(path), Godot.File.ModeFlags.Read);
+            _directoryTool.MakeDirRecursive(GetFullPath(path));
         }
 
-        throw new FileNotFoundException();
-    }
-    
-    protected override IEnumerable<UPath> EnumeratePathsImpl(
-        UPath path, 
-        string searchPattern, 
-        SearchOption searchOption, 
-        SearchTarget searchTarget
-        )
-    {
-        var directoryTool = new Godot.Directory();
-        var err = directoryTool.Open(GetFullPath(path));
-        if (err != Error.Ok)
-            throw new IOException($"{err}");
-        directoryTool.ListDirBegin();
-        for (var current = directoryTool.GetNext();; current = directoryTool.GetNext())
-        {
-            if (string.IsNullOrEmpty(current))
-                break;
-            if (current is ".." or ".")
-                continue;
-            if ((searchTarget == SearchTarget.Both || searchTarget == SearchTarget.File) &&
-                !directoryTool.CurrentIsDir())
-                yield return System.IO.Path.Combine(path.FullName, current);
-            if ((searchTarget == SearchTarget.Both || searchTarget == SearchTarget.Directory) &&
-                directoryTool.CurrentIsDir())
-                yield return System.IO.Path.Combine(path.FullName, current);
-            if (directoryTool.CurrentIsDir() && searchOption == SearchOption.AllDirectories)
+        protected override bool DirectoryExistsImpl(UPath path) => _directoryTool.DirExists(GetFullPath(path));
+        
+        protected override bool FileExistsImpl(UPath path) => _directoryTool.FileExists(GetFullPath(path));
+        
+        protected override Stream OpenFileImpl(UPath path, FileMode mode, FileAccess access, FileShare share)
+        {
+            if (mode == FileMode.Open && access == FileAccess.Read)
+            {
+                return new GodotFileStream(GetFullPath(path), Godot.File.ModeFlags.Read);
+            }
+
+            throw new FileNotFoundException();
+        }
+        
+        protected override IEnumerable<UPath> EnumeratePathsImpl(
+            UPath path, 
+            string searchPattern, 
+            SearchOption searchOption, 
+            SearchTarget searchTarget
+            )
+        {
+            var directoryTool = new Godot.Directory();
+            var err = directoryTool.Open(GetFullPath(path));
+            if (err != Error.Ok)
+                throw new IOException($"{err}");
+            directoryTool.ListDirBegin();
+
+            var searchPatternMatcher = SearchPattern.Parse(ref path, ref searchPattern);
+            
+            for (var current = directoryTool.GetNext();; current = directoryTool.GetNext())
             {
-                foreach (var sub in EnumeratePathsImpl(System.IO.Path.Combine(path.FullName, current), 
-                             searchPattern, searchOption, searchTarget))
+                if (string.IsNullOrEmpty(current))
+                    break;
+                if (current == ".." || current == ".")
+                    continue;
+                if ((searchTarget == SearchTarget.Both || searchTarget == SearchTarget.File) &&
+                    !directoryTool.CurrentIsDir() && searchPatternMatcher.Match(current))
+                    yield return System.IO.Path.Combine(path.FullName, current);
+                if ((searchTarget == SearchTarget.Both || searchTarget == SearchTarget.Directory) &&
+                    directoryTool.CurrentIsDir() && searchPatternMatcher.Match(current))
+                    yield return System.IO.Path.Combine(path.FullName, current);
+                if (directoryTool.CurrentIsDir() && searchOption == SearchOption.AllDirectories)
                 {
-                    yield return sub;
+                    foreach (var sub in EnumeratePathsImpl(System.IO.Path.Combine(path.FullName, current), 
+                                 searchPattern, searchOption, searchTarget))
+                    {
+                        yield return sub;
+                    }
                 }
             }
+            directoryTool.ListDirEnd();
         }
-        directoryTool.ListDirEnd();
-    }
 
-    protected override void MoveDirectoryImpl(UPath srcPath, UPath destPath)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void MoveDirectoryImpl(UPath srcPath, UPath destPath)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void DeleteDirectoryImpl(UPath path, bool isRecursive)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void DeleteDirectoryImpl(UPath path, bool isRecursive)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void CopyFileImpl(UPath srcPath, UPath destPath, bool overwrite)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void CopyFileImpl(UPath srcPath, UPath destPath, bool overwrite)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void ReplaceFileImpl(UPath srcPath, UPath destPath, UPath destBackupPath, bool ignoreMetadataErrors)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void ReplaceFileImpl(UPath srcPath, UPath destPath, UPath destBackupPath, bool ignoreMetadataErrors)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override long GetFileLengthImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override long GetFileLengthImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void MoveFileImpl(UPath srcPath, UPath destPath)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void MoveFileImpl(UPath srcPath, UPath destPath)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void DeleteFileImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void DeleteFileImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override FileAttributes GetAttributesImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override FileAttributes GetAttributesImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void SetAttributesImpl(UPath path, FileAttributes attributes)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void SetAttributesImpl(UPath path, FileAttributes attributes)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override DateTime GetCreationTimeImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override DateTime GetCreationTimeImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void SetCreationTimeImpl(UPath path, DateTime time)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void SetCreationTimeImpl(UPath path, DateTime time)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override DateTime GetLastAccessTimeImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override DateTime GetLastAccessTimeImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void SetLastAccessTimeImpl(UPath path, DateTime time)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void SetLastAccessTimeImpl(UPath path, DateTime time)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override DateTime GetLastWriteTimeImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override DateTime GetLastWriteTimeImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override void SetLastWriteTimeImpl(UPath path, DateTime time)
-    {
-        throw new NotImplementedException();
-    }
+        protected override void SetLastWriteTimeImpl(UPath path, DateTime time)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override IEnumerable<FileSystemItem> EnumerateItemsImpl(UPath path, SearchOption searchOption, SearchPredicate searchPredicate)
-    {
-        throw new NotImplementedException();
-    }
+        protected override IEnumerable<FileSystemItem> EnumerateItemsImpl(UPath path, SearchOption searchOption, SearchPredicate searchPredicate)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override IFileSystemWatcher WatchImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override IFileSystemWatcher WatchImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override string ConvertPathToInternalImpl(UPath path)
-    {
-        throw new NotImplementedException();
-    }
+        protected override string ConvertPathToInternalImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
 
-    protected override UPath ConvertPathFromInternalImpl(string innerPath)
-    {
-        throw new NotImplementedException();
+        protected override UPath ConvertPathFromInternalImpl(string innerPath)
+        {
+            throw new NotImplementedException();
+        }
     }
-}
+}
+

+ 148 - 0
FileSystem/NativeFileSystem.cs

@@ -0,0 +1,148 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Zio;
+
+namespace TBL.GodotSharp.Content.FileSystem
+{
+    public class NativeFileSystem : Zio.FileSystems.FileSystem
+    {
+        /// <summary>
+        /// 根目录
+        /// </summary>
+        private readonly string _rootPath;
+
+        public NativeFileSystem(string rootPath)
+        {
+            _rootPath = rootPath;
+        }
+        
+        private string GetFullPath(UPath uPath) => $"{_rootPath}{uPath}";
+
+        protected override bool DirectoryExistsImpl(UPath path) => Directory.Exists(GetFullPath(path));
+
+        protected override bool FileExistsImpl(UPath path) => File.Exists(GetFullPath(path));
+
+        protected override Stream OpenFileImpl(UPath path, FileMode mode, FileAccess access, FileShare share) =>
+            File.Open(GetFullPath(path), mode, access);
+
+        protected override IEnumerable<UPath> EnumeratePathsImpl(
+            UPath path,
+            string searchPattern,
+            SearchOption searchOption,
+            SearchTarget searchTarget
+        )
+        {
+            if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.File)
+                foreach (var current in Directory.EnumerateFiles(GetFullPath(path), searchPattern, searchOption))
+                {
+                    yield return current.Substring(_rootPath.Length);
+                }
+            if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.Directory)
+                foreach (var current in Directory.EnumerateDirectories(GetFullPath(path), searchPattern, searchOption))
+                {
+                    yield return current.Substring(_rootPath.Length);
+                }
+        }
+
+        protected override void CreateDirectoryImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void MoveDirectoryImpl(UPath srcPath, UPath destPath)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void DeleteDirectoryImpl(UPath path, bool isRecursive)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void CopyFileImpl(UPath srcPath, UPath destPath, bool overwrite)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void ReplaceFileImpl(UPath srcPath, UPath destPath, UPath destBackupPath, bool ignoreMetadataErrors)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override long GetFileLengthImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void MoveFileImpl(UPath srcPath, UPath destPath)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void DeleteFileImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override FileAttributes GetAttributesImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void SetAttributesImpl(UPath path, FileAttributes attributes)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override DateTime GetCreationTimeImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void SetCreationTimeImpl(UPath path, DateTime time)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override DateTime GetLastAccessTimeImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void SetLastAccessTimeImpl(UPath path, DateTime time)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override DateTime GetLastWriteTimeImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void SetLastWriteTimeImpl(UPath path, DateTime time)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override IEnumerable<FileSystemItem> EnumerateItemsImpl(UPath path, SearchOption searchOption, SearchPredicate searchPredicate)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override IFileSystemWatcher WatchImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override string ConvertPathToInternalImpl(UPath path)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override UPath ConvertPathFromInternalImpl(string innerPath)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 18 - 11
Package/InternalPackage.cs

@@ -2,16 +2,23 @@
 using TBL.GodotSharp.Content.FileSystem;
 using Zio;
 
-namespace TBL.GodotSharp.Content.Package;
-
-/// <summary>
-/// 内部内容包
-/// </summary>
-public class InternalPackage : PackageNode
+namespace TBL.GodotSharp.Content.Package
 {
-    public override IFileSystem SelfFileSystem { get; } = new GodotFileSystem("res://");
-    
-    public override Info SelfInfo { get; }
+    /// <summary>
+    /// 内部内容包
+    /// </summary>
+    public class InternalPackage : PackageNode
+    {
+        public override IFileSystem SelfFileSystem { get; } = new GodotFileSystem("res://");
+
+        public override Info SelfInfo { get; }
     
-    public override ICollection<DependencyInfo> Dependencies { get; }
-}
+        public override IEnumerable<DependencyInfo> Dependencies { get; }
+
+        public InternalPackage(Info info)
+        {
+            SelfInfo = info;
+            Dependencies = null;
+        }
+    }
+}

+ 21 - 0
PackageContainer.cs

@@ -0,0 +1,21 @@
+using Godot;
+using Zio.FileSystems;
+
+namespace TBL.GodotSharp.Content
+{
+    /// <summary>
+    /// 内容包容器
+    /// </summary>
+    public class PackageContainer : Node
+    {
+        /// <summary>
+        /// 叠加文件系统
+        /// </summary>
+        public readonly AggregateFileSystem FileSystem = new AggregateFileSystem();
+
+        public override void _Ready()
+        {
+            Name = nameof(PackageContainer);
+        }
+    }
+}

+ 76 - 68
PackageNode.DependencyInfo.cs

@@ -1,91 +1,99 @@
 using System;
 
-namespace TBL.GodotSharp.Content;
-
-public partial class PackageNode
+namespace TBL.GodotSharp.Content
 {
-    /// <summary>
-    /// 包信息
-    /// </summary>
-    public struct Info
+    public partial class PackageNode
     {
         /// <summary>
-        /// 包名称
+        /// 包信息
         /// </summary>
-        public readonly string Name;
+        public struct Info
+        {
+            /// <summary>
+            /// 包名称
+            /// </summary>
+            public readonly string Name;
 
-        /// <summary>
-        /// 作者信息
-        /// </summary>
-        public readonly string AuthorInfo;
-        
-        /// <summary>
-        /// 版本信息
-        /// </summary>
-        public readonly Version VersionInfo;
+            /// <summary>
+            /// 作者信息
+            /// </summary>
+            public readonly string AuthorInfo;
+            
+            /// <summary>
+            /// 版本信息
+            /// </summary>
+            public readonly Version VersionInfo;
 
-        public Info(string name, string author, string version)
-        {
-            Name = name;
-            AuthorInfo = author;
-            if (!Version.TryParse(version, out VersionInfo))
-                VersionInfo = new Version();
-        }
-        
-        /// <summary>
-        /// 判断本信息能否满足 <paramref name="target"/> 的版本要求
-        /// </summary>
-        /// <param name="target">依赖项信息</param>
-        public readonly bool IsCompatibleWith(DependencyInfo target)
-        {
-            return Content.IsCompatibleWith(VersionInfo, target.Target.VersionInfo,
-                (target.Flags & DependencyInfo.FlagsEnum.Strict) != 0 ? 1 : 0);
-        }
+            public Info(string name, string author, string version)
+            {
+                Name = name;
+                AuthorInfo = author;
+                if (!Version.TryParse(version, out VersionInfo))
+                    VersionInfo = new Version();
+            }
 
-        public override string ToString() => $"{Name}_{AuthorInfo}_{VersionInfo}";
-    }
+            public Info(string name, string author, Version version)
+            {
+                Name = name;
+                AuthorInfo = author;
+                VersionInfo = version;
+            }
 
-    /// <summary>
-    /// 包依赖信息
-    /// </summary>
-    public struct DependencyInfo
-    {
-        /// <summary>
-        /// 依赖目标
-        /// </summary>
-        public readonly Info Target;
+            /// <summary>
+            /// 判断本信息能否满足 <paramref name="target"/> 的版本要求
+            /// </summary>
+            /// <param name="target">依赖项信息</param>
+            public bool IsCompatibleWith(DependencyInfo target)
+            {
+                return Content.IsCompatibleWith(VersionInfo, target.Target.VersionInfo,
+                    (target.Flags & DependencyInfo.FlagsEnum.Strict) != 0 ? 1 : 0);
+            }
+
+            public override string ToString() => $"{Name}_{AuthorInfo}_{VersionInfo}";
+        }
 
         /// <summary>
-        /// 依赖属性
-        /// </summary>
-        public readonly FlagsEnum Flags;
-        
-        /// <summary>
-        /// 依赖项属性
+        /// 包依赖信息
         /// </summary>
-        [Flags]
-        public enum FlagsEnum
+        public struct DependencyInfo
         {
             /// <summary>
-            /// 无属性
+            /// 依赖目标
             /// </summary>
-            None,
-                
+            public readonly Info Target;
+
             /// <summary>
-            /// 非必须依赖项
+            /// 依赖属性
             /// </summary>
-            Unnecessary,
-
+            public readonly FlagsEnum Flags;
+            
             /// <summary>
-            /// 严格(次版本号)兼容依赖项
+            /// 依赖项属性
             /// </summary>
-            Strict
-        }
+            [Flags]
+            public enum FlagsEnum
+            {
+                /// <summary>
+                /// 无属性
+                /// </summary>
+                None,
+                    
+                /// <summary>
+                /// 非必须依赖项
+                /// </summary>
+                Unnecessary,
 
-        public DependencyInfo(Info target, FlagsEnum flags = FlagsEnum.None)
-        {
-            Target = target;
-            Flags = flags;
+                /// <summary>
+                /// 严格(次版本号)兼容依赖项
+                /// </summary>
+                Strict
+            }
+
+            public DependencyInfo(Info target, FlagsEnum flags = FlagsEnum.None)
+            {
+                Target = target;
+                Flags = flags;
+            }
         }
     }
-}
+}

+ 9 - 7
PackageNode.FileSystem.cs

@@ -1,11 +1,13 @@
 using Zio;
 
-namespace TBL.GodotSharp.Content;
-
-public partial class PackageNode
+namespace TBL.GodotSharp.Content
 {
-    /// <summary>
-    /// 本包文件系统
-    /// </summary>
-    public abstract IFileSystem SelfFileSystem { get; }
+    public partial class PackageNode
+    {
+        /// <summary>
+        /// 本包文件系统
+        /// </summary>
+        public abstract IFileSystem SelfFileSystem { get; }
+    }
+
 }

+ 28 - 27
PackageNode.cs

@@ -1,42 +1,43 @@
 using System.Collections.Generic;
 using Godot;
 
-namespace TBL.GodotSharp.Content;
-
-/// <summary>
-/// 资源包节点
-/// </summary>
-public abstract partial class PackageNode : Node
+namespace TBL.GodotSharp.Content
 {
     /// <summary>
-    /// 自身信息
+    /// 资源包节点
     /// </summary>
-    public abstract Info SelfInfo { get; }
+    public abstract partial class PackageNode : Node
+    {
+        /// <summary>
+        /// 自身信息
+        /// </summary>
+        public abstract Info SelfInfo { get; }
 
-    /// <summary>
-    /// 依赖项信息集
-    /// </summary>
-    public abstract ICollection<DependencyInfo> Dependencies { get; }
+        /// <summary>
+        /// 依赖项信息集
+        /// </summary>
+        public abstract IEnumerable<DependencyInfo> Dependencies { get; }
 
-    public override void _Ready()
-    {
-        Name = SelfInfo.ToString();
-    }
+        public override void _Ready()
+        {
+            Name = SelfInfo.ToString();
+        }
 
-    public override void _EnterTree()
-    {
-        if (SelfFileSystem != null)
+        public override void _EnterTree()
         {
-            Content.FileSystem.AddFileSystem(SelfFileSystem);
+            if (SelfFileSystem != null && GetParent() is PackageContainer packageContainer)
+            {
+                packageContainer.FileSystem.AddFileSystem(SelfFileSystem);
+            }
         }
-    }
 
-    public override void _ExitTree()
-    {
-        if (SelfFileSystem != null)
+        public override void _ExitTree()
         {
-            Content.FileSystem.RemoveFileSystem(SelfFileSystem);
-            SelfFileSystem.Dispose();
+            if (SelfFileSystem != null && GetParent() is PackageContainer packageContainer)
+            {
+                packageContainer.FileSystem.RemoveFileSystem(SelfFileSystem);
+                SelfFileSystem.Dispose();
+            }
         }
     }
-}
+}

+ 1 - 1
TBL.GodotSharp.Content.csproj

@@ -2,7 +2,7 @@
 <Project Sdk="Godot.NET.Sdk/3.3.0">
     <PropertyGroup>
         <TargetFramework>net472</TargetFramework>
-        <LangVersion>latest</LangVersion>
+        <LangVersion>7.3</LangVersion>
         <Company>lanzainc.xyz</Company>
     </PropertyGroup>
     <ItemGroup>