Skip to content

Commit cda0ec1

Browse files
committed
Fixed IPathfinderMod types not loading
1 parent c2d4802 commit cda0ec1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Pathfinder/Pathfinder.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ public static void LoadMods()
6161
{
6262
var modAssembly = Assembly.LoadFile(dll);
6363
Type modType = null;
64-
foreach (Type t in (modAssembly.GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(PathfinderMod)))))
64+
foreach (Type t in (modAssembly.GetExportedTypes().Where(t =>
65+
t.IsClass && !t.IsAbstract
66+
&& typeof(IPathfinderMod).IsAssignableFrom(t)))
67+
)
6568
{
69+
string name = null;
6670
try
6771
{
6872
modType = t;
@@ -72,20 +76,22 @@ public static void LoadMods()
7276
if (methodInfo == null)
7377
throw new NotSupportedException("Method 'Identifier' doesn't exist, mod '"
7478
+ Path.GetFileName(modAssembly.Location) + "' is invalid");
75-
var name = (string)methodInfo.Invoke(modInstance, null);
79+
name = (string)methodInfo.Invoke(modInstance, null);
7680
if (IsModLoaded(name))
7781
throw new ExceptionInvalidId("Mod with identifier '" + name + "' is either already loaded or is reserved");
7882
if (name.Contains('.'))
7983
throw new ExceptionInvalidId("Mod identifier '" + name + "' contains a period, mod identifiers may not contain a period (.)");
8084
Logger.Info("Loading mod '{0}'", name);
8185

82-
modInstance.Load();
83-
8486
mods.Add(name, modInstance);
87+
88+
modInstance.Load();
8589
}
8690
catch (Exception ex)
8791
{
8892
Logger.Error("Mod '{0}' of file '{1}' failed to load:\n\t{2}", t.FullName, Path.GetFileName(dll), ex);
93+
if (mods.ContainsKey(name))
94+
mods.Remove(name);
8995
}
9096
}
9197
}

0 commit comments

Comments
 (0)