using System;
namespace TBL.GodotSharp.Content
{
public partial class PackageNode
{
///
/// 包信息
///
public struct Info
{
///
/// 包名称
///
public readonly string Name;
///
/// 作者信息
///
public readonly string AuthorInfo;
///
/// 版本信息
///
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();
}
public Info(string name, string author, Version version)
{
Name = name;
AuthorInfo = author;
VersionInfo = version;
}
///
/// 判断本信息能否满足 的版本要求
///
/// 依赖项信息
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}]";
}
///
/// 包依赖信息
///
public struct DependencyInfo
{
///
/// 依赖目标
///
public readonly Info Target;
///
/// 依赖属性
///
public readonly FlagsEnum Flags;
///
/// 依赖项属性
///
[Flags]
public enum FlagsEnum
{
///
/// 无属性
///
None,
///
/// 非必须依赖项
///
Unnecessary,
///
/// 严格(次版本号)兼容依赖项
///
Strict
}
public DependencyInfo(Info target, FlagsEnum flags = FlagsEnum.None)
{
Target = target;
Flags = flags;
}
}
}
}