Content.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using Zio.FileSystems;
  3. namespace TBL.GodotSharp.Content;
  4. /// <summary>
  5. /// 内容模块扩展功能类
  6. /// </summary>
  7. public static class Content
  8. {
  9. /// <summary>
  10. /// 文件系统容器
  11. /// </summary>
  12. public static readonly AggregateFileSystem FileSystem = new AggregateFileSystem();
  13. /// <summary>
  14. /// 判断 <paramref name="actualVersion"/> 能否满足 <paramref name="targetVersion"/> 的版本要求
  15. /// <para>用于内容包之间的依赖可用性检测</para>
  16. /// </summary>
  17. /// <param name="actualVersion">当前版本</param>
  18. /// <param name="targetVersion">要求的版本</param>
  19. /// <param name="level">兼容级别</param>
  20. public static bool IsCompatibleWith(Version actualVersion, Version targetVersion, int level)
  21. {
  22. // 主版本号
  23. if (actualVersion.Major != targetVersion.Major)
  24. return false;
  25. if (level < 1)
  26. return true;
  27. // 次版本号
  28. if (actualVersion.Minor != targetVersion.Minor)
  29. return false;
  30. if (level < 2)
  31. return true;
  32. // 构建版本号
  33. if (actualVersion.Build != targetVersion.Build)
  34. return false;
  35. return true;
  36. }
  37. }