ValksGodotTools / Template

Template to be used for all Godot 4 C# starting projects
MIT License
65 stars 5 forks source link

Mod Loader can't handle two mods with two scripts in the same location #15

Open valkyrienyanko opened 1 week ago

valkyrienyanko commented 1 week ago

Issue

The following code

Godot.Bridge.ScriptManagerBridge.LookupScriptsInAssembly(assembly);

is giving the error

System.ArgumentException: An item with the same key has already been added. Key: res://Mod.cs

Steps to Reproduce

  1. Press "Load Mods" button twice

Expected

The key(s) if it exist(s) should be removed at the start of load mods function

Relevant Code

Entire Load Mods Function https://github.com/ValksGodotTools/Template/blob/836d67db6b4dc447099e5c8db7e647eb95719f62/Template/Scripts/UI/UIModLoader.cs#L42-L161

Code Causing Issues (line 130)

This code was copied from https://github.com/godotengine/godot/issues/75352 https://github.com/ValksGodotTools/Template/blob/836d67db6b4dc447099e5c8db7e647eb95719f62/Template/Scripts/UI/UIModLoader.cs#L122-L131

valkyrienyanko commented 1 week ago

I'm going to make the decision to force the user to restart the game if any mods were changed.

valkyrienyanko commented 1 week ago

Untitled

valkyrienyanko commented 1 week ago

So there are 2 things I want.

  1. I want to be able to unload the assembly and load it back again
  2. I want to be able to ignore certain scripts from being loaded in the assembly

For now I will remove CopyModDll.cs and enforce all modders to put their files in unique locations with respect to their username and mod name.