Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
17c2cac
Add testing plugin
flibber-hk Mar 10, 2026
beb69f2
Add tests for multi-name game objects
flibber-hk Mar 10, 2026
87bfddb
Kill locking
flibber-hk Mar 10, 2026
17a862d
Add button to dump scene by name
flibber-hk Mar 10, 2026
6b75902
Add ManagedAssetList
flibber-hk Mar 11, 2026
719c9af
Add FsmUtil to testing plugin
flibber-hk Mar 11, 2026
509a9d1
Bump AHL version
flibber-hk Mar 11, 2026
59a9a4d
Restore old overload for backward compatibility
flibber-hk Mar 11, 2026
9131ad8
Have proper doc
flibber-hk Mar 11, 2026
e1a8649
Add comment
flibber-hk Mar 11, 2026
cc954bc
Support for multiple pkeys per asset
flibber-hk Mar 14, 2026
69461a6
Working implementation, pending tests
flibber-hk Mar 14, 2026
d18cb29
Bump AHL version
flibber-hk Mar 15, 2026
b615374
Add large test
flibber-hk Mar 15, 2026
51b2f63
Bug fixes
flibber-hk Mar 15, 2026
e60aa2a
Fix up non scene request test
flibber-hk Mar 15, 2026
c4e3e46
Add more tests
flibber-hk Mar 16, 2026
55e31f7
Housekeeping
flibber-hk Mar 16, 2026
4be5bb2
Note OS string in metadata
flibber-hk Mar 16, 2026
ecde025
Add default value handling attribute data
flibber-hk Mar 16, 2026
2352da7
Remove old repacking file
flibber-hk Mar 17, 2026
548c163
Rename SRR -> SR
flibber-hk Mar 17, 2026
7455271
Move aliases to the bottom
flibber-hk Mar 17, 2026
994d34e
Yield after setting loading screen text
flibber-hk Mar 17, 2026
8251280
Remove commented-out SceneRepacking from tasks list
flibber-hk Mar 17, 2026
746556e
Cite Architect on enemy fixes
flibber-hk Mar 17, 2026
21c53c5
Add test for Squirrm asset
flibber-hk Mar 17, 2026
9eaf3f2
Remove auto-load
flibber-hk Mar 17, 2026
264f80b
Bump DDC
flibber-hk Mar 18, 2026
e1934b1
Update docstrings
flibber-hk Mar 18, 2026
264e02a
Sort imports
flibber-hk Mar 18, 2026
0dc2327
yield after updating text
flibber-hk Mar 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AssetHelper.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Solution>
<Project Path="AssetHelper/AssetHelper.csproj" />
<Project Path="AssetHelperMenu/AssetHelperMenu.csproj" Id="2109f991-85c6-4e05-881e-59bf10836ab0" />
<Project Path="AssetHelperTesting/AssetHelperTesting.csproj" Id="eef3b27f-b627-48da-b2bf-45e0eba05226" />
</Solution>
51 changes: 30 additions & 21 deletions AssetHelper/AssetHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<RootNamespace>Silksong.AssetHelper</RootNamespace>
<!-- Ignore warning about processor architecture mismatch with PlayMaker ConditionalExpression -->
<NoWarn>$(NoWarn);MSB3270</NoWarn>
<RestorePackagesWithLockFile>True</RestorePackagesWithLockFile>
<!-- CI environment variable is automatically set by GitHub actions -->
<RestoreLockedMode Condition="'$(CI)' == 'true'">True</RestoreLockedMode>
<!-- Allow access of private members at runtime -->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Shortens and anonymizes paths in debug symbols relative to the project directory. Breakpoints will not work, however. -->
Expand All @@ -41,7 +38,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="UnityEngine.Modules" Version="6000.0.50" IncludeAssets="compile" />
<PackageReference Include="DataDrivenConstants" Version="1.1.0">
<PackageReference Include="DataDrivenConstants" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down Expand Up @@ -72,9 +69,32 @@

<ItemGroup>
<PackageReference Include="AssetsTools.NET" Version="3.0.4" GeneratePathProperty="true" />
<PackageReference Include="AssetHelperLib" Version="0.11.0" GeneratePathProperty="true" />
</ItemGroup>

<!--AssetHelperLib dependency-->
<PropertyGroup>
<!--
Set this to true to use a local copy of AssetHelperLib for development.
This should be false when pushed to main.
-->
<AssetHelperLibDevelopment>false</AssetHelperLibDevelopment>
<AssetHelperLibFolder>../../AssetHelperLib/AssetHelperLib/bin/Debug/netstandard2.1</AssetHelperLibFolder>
</PropertyGroup>

<ItemGroup Condition="'$(AssetHelperLibDevelopment)' == 'false'">
<PackageReference Include="AssetHelperLib" Version="0.12.1" GeneratePathProperty="true" />
</ItemGroup>

<ItemGroup Condition="'$(AssetHelperLibDevelopment)' == 'true'">
<Reference Include="AssetHelperLib">
<HintPath>$(AssetHelperLibFolder)/AssetHelperLib.dll</HintPath>
</Reference>
</ItemGroup>

<PropertyGroup Condition="'$(AssetHelperLibDevelopment)' == 'false'">
<AssetHelperLibFolder>$(PkgAssetHelperLib)/lib/netstandard2.1</AssetHelperLibFolder>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoDetour.HookGen" Version="0.7.*" PrivateAssets="all" />
<PackageReference Include="MonoDetour" Version="*" />
Expand All @@ -101,33 +121,22 @@
<Binaries Include="$(TargetDir)/$(TargetName).xml" LocalDir="/" PackDir="plugins" />
<Binaries Include="$(PkgAssetsTools_NET)/lib/netstandard2.0/AssetsTools.NET.dll" PackDir="plugins" />
<Binaries Include="$(PkgAssetsTools_NET)/lib/netstandard2.0/AssetsTools.NET.xml" PackDir="plugins" />
<Binaries Include="$(PkgAssetHelperLib)/lib/netstandard2.1/AssetHelperLib.dll" PackDir="plugins" />
<Binaries Include="$(PkgAssetHelperLib)/lib/netstandard2.1/AssetHelperLib.xml" PackDir="plugins" />
<Binaries Include="$(AssetHelperLibFolder)/AssetHelperLib.dll" PackDir="plugins" />
<Binaries Include="$(AssetHelperLibFolder)/AssetHelperLib.xml" PackDir="plugins" />
<Binaries Include="languages/*.json" LocalDir="languages" PackDir="plugins/languages" />
</ItemGroup>
<PropertyGroup>
<ThunderstoreDir>$(ProjectDir)/../thunderstore</ThunderstoreDir>
</PropertyGroup>

<!-- Local install -->
<Copy
SourceFiles="@(Binaries)"
DestinationFolder="$(SilksongPluginsFolder)/silksong_modding-$(AssemblyTitle)/%(Binaries.LocalDir)"
Condition="'$(SilksongPluginsFolder)' != '' And Exists('$(SilksongPluginsFolder)')"
/>
<Copy SourceFiles="@(Binaries)" DestinationFolder="$(SilksongPluginsFolder)/silksong_modding-$(AssemblyTitle)/%(Binaries.LocalDir)" Condition="'$(SilksongPluginsFolder)' != '' And Exists('$(SilksongPluginsFolder)')" />

<!-- Thunderstore packaging -->
<RemoveDir Directories="$(ThunderstoreDir)/temp;$(ThunderstoreDir)/dist" />
<MakeDir Directories="$(ThunderstoreDir)/temp" />
<Copy
SourceFiles="@(Binaries)"
DestinationFolder="$(ThunderstoreDir)/temp/%(Binaries.PackDir)"
/>
<Copy SourceFiles="@(Binaries)" DestinationFolder="$(ThunderstoreDir)/temp/%(Binaries.PackDir)" />
<Exec Command="dotnet tool restore" />
<Exec
Command="dotnet tcli build --config-path &quot;$(ThunderstoreDir)/assethelper.toml&quot; --package-name &quot;$(AssemblyTitle)&quot; --package-version $(Version)"
StandardOutputImportance="High"
StandardErrorImportance="High"
/>
<Exec Command="dotnet tcli build --config-path &quot;$(ThunderstoreDir)/assethelper.toml&quot; --package-name &quot;$(AssemblyTitle)&quot; --package-version $(Version)" StandardOutputImportance="High" StandardErrorImportance="High" />
</Target>
</Project>
46 changes: 25 additions & 21 deletions AssetHelper/CatalogTools/CatalogEntryUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static ContentCatalogDataEntry CreateBundleEntry(
return bundleEntry;
}

/// <inheritdoc cref="CreateAssetEntry(string, Type, List{string}, out string)" />
/// <inheritdoc cref="CreateAssetEntry(string, Type, List{string}, List{string})" />
public static ContentCatalogDataEntry CreateAssetEntry(
string internalId,
Type assetType,
Expand All @@ -66,7 +66,7 @@ out string primaryKey
{
primaryKey = internalId;

return CreateAssetEntry(internalId, assetType, dependencyKeys, primaryKey);
return CreateAssetEntry(internalId, assetType, dependencyKeys, [primaryKey]);
}

/// <summary>
Expand All @@ -75,33 +75,28 @@ out string primaryKey
/// <param name="internalId">The internal ID of the asset. This is the name of the asset within the bundle.</param>
/// <param name="assetType">Unity type of the asset. Eg: GameObject</param>
/// <param name="dependencyKeys">Primary keys of the bundle dependencies. These should be in the catalog.</param>
/// <param name="primaryKey">The primary key used to access the asset with Addressables.</param>
/// <param name="primaryKeys">The primary keys used to access the asset with Addressables.</param>
public static ContentCatalogDataEntry CreateAssetEntry(
string internalId,
Type assetType,
List<string> dependencyKeys,
string primaryKey
List<string> primaryKeys
)
{
object[] deps = dependencyKeys.Cast<object>().ToArray();
object[] pkeys = primaryKeys.Cast<object>().ToArray();

return new ContentCatalogDataEntry(
assetType,
internalId,
"UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider",
new object[] { primaryKey },
pkeys,
deps,
null
);
}

/// <summary>
/// Create a catalog entry representing a child gameobject of
/// the gameObject loaded by parentPrimaryKey.
/// </summary>
/// <param name="parentPrimaryKey">The primary key of the parent.</param>
/// <param name="relativePath">The path of the child relative to the parent, with no leading slash.</param>
/// <param name="primaryKey">The primary key of the added entry.</param>
/// <inheritdoc cref="CreateChildGameObjectEntry(string, string, List{string})" />
public static ContentCatalogDataEntry CreateChildGameObjectEntry(
string parentPrimaryKey,
string relativePath,
Expand All @@ -128,56 +123,65 @@ out string primaryKey
primaryKey = $"{parentPrimaryKey}/{relativePath}";
}

return CreateChildGameObjectEntry(parentPrimaryKey, relativePath, primaryKey);
return CreateChildGameObjectEntry(parentPrimaryKey, relativePath, [primaryKey]);
}

/// <inheritdoc cref="CreateChildGameObjectEntry(string, string, out string)" />
/// <summary>
/// Create a catalog entry representing a child gameobject of
/// the gameObject loaded by parentPrimaryKey.
/// </summary>
/// <param name="parentPrimaryKey">The primary key of the parent.</param>
/// <param name="relativePath">The path of the child relative to the parent, with no leading slash.</param>
/// <param name="primaryKeys">The primary keys of the added entry.</param>
public static ContentCatalogDataEntry CreateChildGameObjectEntry(
string parentPrimaryKey,
string relativePath,
string primaryKey
List<string> primaryKeys
)
{
object[] deps = new object[] { parentPrimaryKey };
object[] pkeys = primaryKeys.Cast<object>().ToArray();

return new ContentCatalogDataEntry(
typeof(GameObject),
// Put the parent primary key to ensure the internal ID is unique
$"{relativePath}/{ChildGameObjectProvider.InternalIdSeparator}/{parentPrimaryKey}",
ChildGameObjectProvider.ClassProviderId,
new object[] { primaryKey },
pkeys,
deps,
null
);
}

/// <inheritdoc cref="CreateEntryFromLocation(IResourceLocation, string)" />
/// <inheritdoc cref="CreateEntryFromLocation(IResourceLocation, List{string})" />
public static ContentCatalogDataEntry CreateEntryFromLocation(
IResourceLocation location,
out string primaryKey
)
{
primaryKey = $"{nameof(AssetHelper)}:{location.PrimaryKey}";

return CreateEntryFromLocation(location, primaryKey);
return CreateEntryFromLocation(location, [primaryKey]);
}

/// <summary>
/// Create a catalog entry based on the given location.
/// </summary>
/// <param name="location">The location.</param>
/// <param name="primaryKey">The primary key for the new catalog entry.</param>
/// <param name="primaryKeys">The primary keys for the new catalog entry.</param>
/// <returns></returns>
public static ContentCatalogDataEntry CreateEntryFromLocation(
IResourceLocation location,
string primaryKey
List<string> primaryKeys
)
{
object[] pkeys = primaryKeys.Cast<object>().ToArray();

return new ContentCatalogDataEntry(
location.ResourceType,
location.InternalId,
location.ProviderId,
new object[] { primaryKey },
pkeys,
null,
location.Data
);
Expand Down
2 changes: 1 addition & 1 deletion AssetHelper/Core/AddressablesData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ internal static bool TryLoadBundleKeys()
}

/// <summary>
/// Convert a name to an asset bundle key.
/// Convert a name to an asset bundle (addressables) key.
/// </summary>
public static string ToBundleKey(string name)
{
Expand Down
24 changes: 24 additions & 0 deletions AssetHelper/Internal/CachedFileMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Silksong.AssetHelper.Core;

namespace Silksong.AssetHelper.Internal;

internal class CachedFileMetadata
{
public required string SilksongVersion { get; init; }

public required string PluginVersion { get; init; }

public required string OSFolderName { get; init; }

public static CachedFileMetadata CreateNew()
{
CachedFileMetadata data = new()
{
SilksongVersion = VersionData.SilksongVersion,
PluginVersion = AssetHelperPlugin.Version,
OSFolderName = AssetPaths.OSFolderName,
};

return data;
}
}
23 changes: 13 additions & 10 deletions AssetHelper/Internal/CachedObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.IO;
using Newtonsoft.Json;
using Silksong.AssetHelper.Core;
Expand All @@ -15,28 +16,31 @@ internal class CachedObject<T>
{
private CachedObject() { }

[JsonProperty]
public required string SilksongVersion { get; init; }

[JsonProperty]
public required string PluginVersion { get; init; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
[DefaultValue(null)]
public required CachedFileMetadata Metadata { get; init; }

[JsonProperty]
public required T Value { get; set; }

private bool IsValid()
{
if (SilksongVersion == null || PluginVersion == null)
if (Metadata == null || Metadata.SilksongVersion == null || Metadata.PluginVersion == null)
{
return false;
}

if (Metadata.OSFolderName != AssetPaths.OSFolderName)
{
return false;
}

if (VersionData.SilksongVersion != SilksongVersion)
if (VersionData.SilksongVersion != Metadata.SilksongVersion)
{
return false;
}

if (!VersionData.EarliestAcceptableGeneralVersion.AllowCachedData(this.PluginVersion))
if (!VersionData.EarliestAcceptableGeneralVersion.AllowCachedData(Metadata.PluginVersion))
{
return false;
}
Expand Down Expand Up @@ -85,8 +89,7 @@ out CachedObject<T>? fromCache

CachedObject<T> created = new()
{
SilksongVersion = VersionData.SilksongVersion,
PluginVersion = AssetHelperPlugin.Version,
Metadata = CachedFileMetadata.CreateNew(),
Value = createDefault(),
};
created.SerializeToFile(filePath);
Expand Down
Loading