Skip to content

Commit

Permalink
Merge pull request #96 from Kalobi/assetconflicts
Browse files Browse the repository at this point in the history
Add non-conflict asset types for mod root files
  • Loading branch information
maddie480 authored Jan 25, 2024
2 parents 951412c + 0a39c0e commit 39707b4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
4 changes: 4 additions & 0 deletions AssetTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Celeste.Mod.CollabUtils2;

public sealed class AssetTypeCollabID : AssetTypeNonConflict { private AssetTypeCollabID() { } }
public sealed class AssetTypeLazyLoadingYaml : AssetTypeNonConflict { private AssetTypeLazyLoadingYaml() { } }
19 changes: 19 additions & 0 deletions CollabModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public override void Load() {
OuiJournalCoverWithStickers.Load();

Everest.Content.OnUpdate += onModAssetUpdate;
Everest.Content.OnGuessType += onGuessType;

hookOrigSessionCtor = new Hook(typeof(Session).GetMethod("orig_ctor"), typeof(CollabModule).GetMethod(nameof(onNewSession), BindingFlags.NonPublic | BindingFlags.Static));
}
Expand All @@ -74,6 +75,7 @@ public override void Unload() {
OuiJournalCoverWithStickers.Unload();

Everest.Content.OnUpdate -= onModAssetUpdate;
Everest.Content.OnGuessType -= onGuessType;

hookOrigSessionCtor?.Dispose();
hookOrigSessionCtor = null;
Expand All @@ -94,6 +96,23 @@ private void onModAssetUpdate(ModAsset oldAsset, ModAsset newAsset) {
reloadCrystalHeartSwapSpriteBanks();
}
}

private static string onGuessType(string file, out Type type, out string format) {
switch (file) {
case "CollabUtils2CollabID.txt":
type = typeof(AssetTypeCollabID);
format = "txt";
return "CollabUtils2CollabID";
case "CollabUtils2LazyLoading.yaml" or "CollabUtils2LazyLoading.yml":
type = typeof(AssetTypeLazyLoadingYaml);
format = "yml";
return "CollabUtils2LazyLoading";
default:
type = null;
format = null;
return null;
}
}

public override void LoadContent(bool firstLoad) {
reloadCrystalHeartSwapSpriteBanks();
Expand Down
19 changes: 10 additions & 9 deletions CollabUtils2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net452</TargetFrameworks>
<LangVersion>11</LangVersion>
<AssemblyName>CollabUtils2</AssemblyName>
<RootNamespace>Celeste.Mod.CollabUtils2</RootNamespace>
</PropertyGroup>
Expand All @@ -15,15 +16,15 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<Reference Include="CelesteNet.Client">
<HintPath>lib-stripped\CelesteNet.Client.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="CelesteNet.Shared">
<HintPath>lib-stripped\CelesteNet.Shared.dll</HintPath>
<Private>false</Private>
</Reference>
<ItemGroup>
<Reference Include="CelesteNet.Client">
<HintPath>lib-stripped\CelesteNet.Client.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="CelesteNet.Shared">
<HintPath>lib-stripped\CelesteNet.Shared.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>

<Choose>
Expand Down

0 comments on commit 39707b4

Please sign in to comment.