123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.IO;
- using Godot;
- namespace TBL.GodotSharp.Content;
- public static class Content
- {
-
-
-
-
-
-
- public static Stream OpenFileStreamWithDependency(
- this Package package, string path)
- {
- var stream = package.OpenFileStream(path);
-
- if (stream != null)
- return stream;
-
- Node container;
- if (null != (container = package.GetParent()))
- {
- for (int i = 0, count = container.GetChildCount();
- i < count;
- i++)
- {
- if (container.GetChild(i) is not Package dependency)
- continue;
-
- foreach (var info in package.Dependencies)
- {
-
- if (dependency.SelfInfo.IsCompatibleWith(info))
- {
- stream = dependency.OpenFileStreamWithDependency(path);
-
-
- if (stream != null)
- return stream;
- }
- }
- }
- }
-
- return null;
- }
-
-
-
-
-
-
-
-
- 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;
- }
- }
|