- ShrinkModComponentDiscovery.Discover 公开:只发现、不执行生命周期 - ShrinkModLoader.LoadComposed / ShrinkModCordisRuntime.ApplyComposedAsync:宿主提供元数据组合加载,支持纯数据包与 IShrinkModWrapper 公开真实实例 - 公开 TryAttachEventBusInstance,随生命周期逆操作释放 - 依赖新增 VersionRange(Maven/Forge 区间语法)与 Ordering(Before/After) - AssemblyResolvePolicy 可限制跨模组程序集解析
64 lines
2.5 KiB
C#
64 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ShrinkModFramework
|
|
{
|
|
[Serializable]
|
|
public sealed class ShrinkModInfo
|
|
{
|
|
public string ModId { get; }
|
|
public string DisplayName { get; }
|
|
public string Version { get; }
|
|
public int LoadOrder { get; }
|
|
public Type EntryType { get; }
|
|
public bool AutoApplyHarmonyPatches { get; }
|
|
public IReadOnlyList<ShrinkModDependency> Dependencies { get; }
|
|
|
|
public ShrinkModInfo(string modId, string displayName, string version, int loadOrder, Type entryType,
|
|
bool autoApplyHarmonyPatches, IReadOnlyList<ShrinkModDependency> dependencies)
|
|
{
|
|
ModId = modId;
|
|
DisplayName = displayName;
|
|
Version = version;
|
|
LoadOrder = loadOrder;
|
|
EntryType = entryType;
|
|
AutoApplyHarmonyPatches = autoApplyHarmonyPatches;
|
|
Dependencies = dependencies == null
|
|
? Array.Empty<ShrinkModDependency>()
|
|
: new List<ShrinkModDependency>(dependencies).AsReadOnly();
|
|
}
|
|
|
|
public override string ToString() => $"{DisplayName} ({ModId}@{Version})";
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class ShrinkModDependency
|
|
{
|
|
public string ModId { get; }
|
|
public string MinimumVersion { get; }
|
|
public bool Optional { get; }
|
|
public string VersionRange { get; }
|
|
public ShrinkModDependencyOrdering Ordering { get; }
|
|
|
|
public ShrinkModDependency(string modId, string minimumVersion, bool optional)
|
|
: this(modId, minimumVersion, optional, ShrinkModDependencyOrdering.After, null) { }
|
|
|
|
public ShrinkModDependency(string modId, string minimumVersion, bool optional,
|
|
ShrinkModDependencyOrdering ordering = ShrinkModDependencyOrdering.After, string versionRange = null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(modId)) throw new ArgumentException("ModId must not be empty.", nameof(modId));
|
|
if (!Enum.IsDefined(typeof(ShrinkModDependencyOrdering), ordering))
|
|
throw new ArgumentOutOfRangeException(nameof(ordering));
|
|
ModId = modId.Trim();
|
|
MinimumVersion = minimumVersion;
|
|
Optional = optional;
|
|
VersionRange = versionRange ?? minimumVersion;
|
|
Ordering = ordering;
|
|
ShrinkModVersionRange.Parse(VersionRange);
|
|
}
|
|
|
|
public override string ToString() =>
|
|
$"{ModId} {VersionRange ?? "*"} ({Ordering}{(Optional ? ", optional" : "")})";
|
|
}
|
|
}
|