mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
Fix gamemodes not being properly added to the option
This commit is contained in:
1 parent
cbe44a40d0
commit
317e0b6ea9
2 files changed
+8
-11
No files matched your search
@@ -21,12 +21,13 @@ public static class CustomGameModeManager
|
||||
/// </summary>
|
||||
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="AbstractGameMode"/>.</param>
|
||||
/// <param name="pluginInfo">The custom plugin info of the mod.</param>
|
||||
internal static void RegisterGameMode(Type gameModeType, MiraPluginInfo pluginInfo)
|
||||
/// <returns>Whether the gamemode was successfully registered.</returns>
|
||||
internal static bool RegisterGameMode(Type gameModeType, MiraPluginInfo pluginInfo)
|
||||
{
|
||||
if (!typeof(AbstractGameMode).IsAssignableFrom(gameModeType))
|
||||
{
|
||||
Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var instance = Activator.CreateInstance(gameModeType);
|
||||
@@ -34,13 +35,14 @@ public static class CustomGameModeManager
|
||||
if (instance is not AbstractGameMode mode)
|
||||
{
|
||||
Error($"Failed to create instance of {gameModeType.Name}");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
IdToModeMap.Add(GetNextId(), mode);
|
||||
pluginInfo.GameModes.Add(LastId, mode);
|
||||
GameModeOption.AddOption(mode);
|
||||
mode.ID = LastId;
|
||||
GameModeOption.AddOption(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -449,18 +449,13 @@ public sealed class MiraPluginManager
|
||||
{
|
||||
try
|
||||
{
|
||||
if (type.IsAssignableTo(typeof(AbstractGameMode)))
|
||||
{
|
||||
// TODO: bool
|
||||
CustomGameModeManager.RegisterGameMode(type, pluginInfo);
|
||||
return true;
|
||||
}
|
||||
if (typeof(AbstractGameMode).IsAssignableFrom(type))
|
||||
return CustomGameModeManager.RegisterGameMode(type, pluginInfo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to register gamemode {type.Name}: {e}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user