chore: initialize standalone UPM package
Publish UPM package / publish (push) Failing after 1s

This commit is contained in:
2026-08-26 02:50:31 +08:00
commit 78ccae3e07
142 changed files with 6572 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
using System;
namespace ShrinkModFramework
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class ShrinkModAttribute : Attribute
{
public string ModId { get; }
public string DisplayName { get; }
public string Version { get; }
public int LoadOrder { get; }
public bool AutoApplyHarmonyPatches { get; set; } = true;
public ShrinkModAttribute(string modId, string displayName, string version, int loadOrder = 0)
{
if (string.IsNullOrWhiteSpace(modId))
throw new ArgumentException("模组 ID 不能为空。", nameof(modId));
if (string.IsNullOrWhiteSpace(displayName))
throw new ArgumentException("模组显示名不能为空。", nameof(displayName));
if (string.IsNullOrWhiteSpace(version))
throw new ArgumentException("模组版本不能为空。", nameof(version));
ModId = modId.Trim();
DisplayName = displayName.Trim();
Version = version.Trim();
LoadOrder = loadOrder;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 976e55706c1035f4ba692957cd335f32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
using System;
namespace ShrinkModFramework
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class ShrinkModDependencyAttribute : Attribute
{
public string ModId { get; }
public string MinimumVersion { get; }
public bool Optional { get; }
public ShrinkModDependencyAttribute(string modId, string minimumVersion = null, bool optional = false)
{
if (string.IsNullOrWhiteSpace(modId))
throw new ArgumentException("依赖模组 ID 不能为空。", nameof(modId));
ModId = modId.Trim();
MinimumVersion = string.IsNullOrWhiteSpace(minimumVersion) ? null : minimumVersion.Trim();
Optional = optional;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4af615bbf25f3e429a341accf01b17b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+54
View File
@@ -0,0 +1,54 @@
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;
}
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 ShrinkModDependency(string modId, string minimumVersion, bool optional)
{
ModId = modId;
MinimumVersion = minimumVersion;
Optional = optional;
}
public override string ToString()
{
if (string.IsNullOrEmpty(MinimumVersion))
return Optional ? $"{ModId} (optional)" : ModId;
return Optional ? $"{ModId} >= {MinimumVersion} (optional)" : $"{ModId} >= {MinimumVersion}";
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6497d32d6e9e7084aac7d2c0c2996a78
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+12
View File
@@ -0,0 +1,12 @@
namespace ShrinkModFramework
{
public enum ShrinkModState
{
Discovered = 0,
Constructed = 1,
ContentRegistered = 2,
Initialized = 3,
Ready = 4,
Unloaded = 5
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf0b4d15f9b6083489f0b8a954447c17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+45
View File
@@ -0,0 +1,45 @@
using System;
namespace ShrinkModFramework
{
internal static class ShrinkVersionUtility
{
public static int Compare(string left, string right)
{
if (ReferenceEquals(left, right)) return 0;
if (left == null) return -1;
if (right == null) return 1;
var leftParts = left.Split('.');
var rightParts = right.Split('.');
var max = Math.Max(leftParts.Length, rightParts.Length);
for (var i = 0; i < max; i++)
{
var leftValue = i < leftParts.Length ? ParseSegment(leftParts[i]) : 0;
var rightValue = i < rightParts.Length ? ParseSegment(rightParts[i]) : 0;
if (leftValue != rightValue)
return leftValue.CompareTo(rightValue);
}
return string.CompareOrdinal(left, right);
}
private static int ParseSegment(string segment)
{
if (string.IsNullOrEmpty(segment))
return 0;
var digits = "";
for (var i = 0; i < segment.Length; i++)
{
if (!char.IsDigit(segment[i]))
break;
digits += segment[i];
}
return int.TryParse(digits, out var value) ? value : 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6fd43faddede97247997c7738c55fba6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: