Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 4 additions & 8 deletions WorldBoxMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using NeoModLoader.services;
using NeoModLoader.ui;
using NeoModLoader.utils;
using NeoModLoader.utils.Builders;
using UnityEngine;

namespace NeoModLoader;
Expand Down Expand Up @@ -103,7 +102,6 @@
Harmony.CreateAndPatchAll(typeof(LM), Others.harmony_id);
Harmony.CreateAndPatchAll(typeof(ResourcesPatch), Others.harmony_id);
Harmony.CreateAndPatchAll(typeof(CustomAudioManager), Others.harmony_id);
Harmony.CreateAndPatchAll(typeof(AssetPatches), Others.harmony_id);
if (!SmoothLoader.isLoading()) SmoothLoader.prepare();

SmoothLoader.add(() =>
Expand Down Expand Up @@ -148,19 +146,17 @@
}
}, "Compile Mod " + mod.mod_decl.Name);
}
MasterBuilder Builder = new();
AssetLinker Linker = new();
foreach (var mod in mod_nodes)
{
SmoothLoader.add(() =>
{
if (mods_to_load.Contains(mod.mod_decl))
{
ResourcesPatch.LoadResourceFromFolder(Path.Combine(mod.mod_decl.FolderPath,
Paths.ModResourceFolderName), out List<Builder> builders);
Builder.AddBuilders(builders);
Paths.ModResourceFolderName), Linker);
ResourcesPatch.LoadResourceFromFolder(Path.Combine(mod.mod_decl.FolderPath,
Paths.NCMSAdditionModResourceFolderName), out List<Builder> builders2);
Builder.AddBuilders(builders2);
Paths.NCMSAdditionModResourceFolderName), Linker);
ResourcesPatch.LoadAssetBundlesFromFolder(Path.Combine(mod.mod_decl.FolderPath,
Paths.ModAssetBundleFolderName));
}
Expand All @@ -170,7 +166,7 @@
SmoothLoader.add(() =>
{
ModCompileLoadService.loadMods(mods_to_load);
Builder.BuildAll();
Linker.AddAssets();
if (startup_enable_plan != null)
{
if (startup_enable_plan.RequestedRoots.All(ModCompileLoadService.IsModLoaded))
Expand Down Expand Up @@ -367,7 +363,7 @@
LogService.LogInfo($"NeoModLoader.dll is newer than AutoUpdate.dll, " +
$"re-extract AutoUpdate.dll from NeoModLoader.dll");
}
catch (Exception e)

Check warning on line 366 in WorldBoxMod.cs

View workflow job for this annotation

GitHub Actions / Windows

The variable 'e' is declared but never used
{
// ignored
}
Expand Down
12 changes: 5 additions & 7 deletions services/ModCompileLoadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using NeoModLoader.General;
using NeoModLoader.ncms_compatible_layer;
using NeoModLoader.utils;
using NeoModLoader.utils.Builders;
using UnityEngine;

namespace NeoModLoader.services;
Expand Down Expand Up @@ -495,7 +494,7 @@
bool any_loaded = false;
foreach (var type in mod_assembly.GetTypes())
{
var mod_entry = Attribute.GetCustomAttribute(type, typeof(ModEntry));

Check warning on line 497 in services/ModCompileLoadService.cs

View workflow job for this annotation

GitHub Actions / Windows

'ModEntry' is obsolete: 'Compatible Layer will not be maintained and be removed in the future'
if (!type.IsSubclassOf(typeof(MonoBehaviour)) ||
(type.GetInterface(nameof(IMod)) == null && mod_entry == null) || type.IsAbstract) continue;

Expand All @@ -514,7 +513,7 @@
pMod.IsNCMSMod = true;
Type ncmsGlobalObjectType = mod_assembly.GetType("Mod");
ncmsGlobalObjectType.GetField("Info")
?.SetValue(null, new Info(NCMSCompatibleLayer.GenerateNCMSMod(pMod)));

Check warning on line 516 in services/ModCompileLoadService.cs

View workflow job for this annotation

GitHub Actions / Windows

'Info' is obsolete: 'Compatible Layer will not be maintained and be removed in the future'
ncmsGlobalObjectType.GetField("GameObject")?.SetValue(null, mod_instance);
}

Expand Down Expand Up @@ -672,17 +671,16 @@

private static bool TryLoadCompiledModAtRuntime(ModDeclare pModDeclare)
{
MasterBuilder builder = new MasterBuilder();
AssetLinker linker = new AssetLinker();
ResourcesPatch.LoadResourceFromFolder(Path.Combine(pModDeclare.FolderPath, Paths.ModResourceFolderName),
out List<Builder> builders);
linker);
ResourcesPatch.LoadResourceFromFolder(Path.Combine(pModDeclare.FolderPath,
Paths.NCMSAdditionModResourceFolderName), out List<Builder> builders2);
Paths.NCMSAdditionModResourceFolderName), linker);
ResourcesPatch.LoadAssetBundlesFromFolder(Path.Combine(pModDeclare.FolderPath, Paths.ModAssetBundleFolderName));

LoadMod(pModDeclare);
builder.AddBuilders(builders);
builder.AddBuilders(builders2);
builder.BuildAll();

linker.AddAssets();

if (IsModLoaded(pModDeclare.UID))
{
Expand Down
12 changes: 5 additions & 7 deletions services/ModReloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using NeoModLoader.constants;
using NeoModLoader.General;
using NeoModLoader.utils;
using NeoModLoader.utils.Builders;

namespace NeoModLoader.services;

Expand Down Expand Up @@ -59,14 +58,13 @@ public static bool ReloadMod(IReloadable pMod, ModDeclare pModDeclare)
/// </summary>
public static bool ReloadResources(IMod pMod)
{
MasterBuilder Builder = new();
AssetLinker linker = new();
ResourcesPatch.LoadResourceFromFolder(Path.Combine(pMod.GetDeclaration().FolderPath,
Paths.ModResourceFolderName), out List<Builder> builders);
Paths.ModResourceFolderName), linker);
ResourcesPatch.LoadResourceFromFolder(Path.Combine(pMod.GetDeclaration().FolderPath,
Paths.NCMSAdditionModResourceFolderName), out List<Builder> builders2);
Builder.AddBuilders(builders);
Builder.AddBuilders(builders2);
Builder.BuildAll();
Paths.NCMSAdditionModResourceFolderName), linker);

linker.AddAssets();
return true;
}

Expand Down
Loading
Loading