git please stop confusing me

This commit is contained in:
Az committed 2026-11-07 04:00:56 -05:00
1 parent 79f54f87ff
commit de37e4a3b0
1 file changed
+29 -9
+29 -9
View File
@@ -38,6 +38,9 @@ public static class ModdedOptionsManager
private static readonly Dictionary<Type, HarmonyMethod> ConcretisedGetters = [];
private static readonly Dictionary<Type, HarmonyMethod> ConcretisedSetters = [];
private static readonly Type OptionType = typeof(IModdedOption);
private static readonly Type OptionListType = typeof(IModdedOptionList);
internal static readonly Dictionary<OptionBehaviour, ModdedPlayerOption> CreatedPlayerOptions = [];
internal static readonly Dictionary<Type, List<AbstractOptionGroup>> GameModeOptionGroups = [];
internal static readonly Dictionary<uint, IModdedOption> ModdedOptions = [];
@@ -113,30 +116,47 @@ public static class ModdedOptionsManager
foreach (var property in type.GetProperties(MiraPluginManager.DeclaredInstanceMembers))
{
if (property.PropertyType.IsAssignableTo(typeof(IModdedOption)))
if (property.GetMethod == null)
{
Error($"Non-ignored option property {property.Name} in {type.Name} must at least have a getter.");
continue;
}
var propType = property.PropertyType;
if (propType.IsAssignableTo(OptionType))
{
RegisterPropertyOption(type, property, pluginInfo);
continue;
}
if (property.PropertyType.IsAssignableTo(typeof(IModdedOptionList)))
if (propType.IsAssignableTo(OptionListType))
{
RegisterPropertyOptionList(type, property, pluginInfo);
continue;
}
if (property.TryGetCustomAttribute<ModdedOptionAttribute>(out var attribute))
{
RegisterAttributeOption(type, attribute, property, pluginInfo);
continue;
}
var attributes = property.GetCustomAttributes(false);
if (property.TryGetCustomAttribute<ModdedOptionListAttribute>(out var listAttr))
foreach (var attr in attributes)
{
RegisterAttributeOptionList(type, listAttr, property, pluginInfo);
if (attr is ModdedOptionAttribute moddedAttr)
{
RegisterAttributeOption(type, moddedAttr, property, pluginInfo, propType, attributes);
break;
}
if (attr is ModdedOptionListAttribute listAttr)
{
RegisterAttributeOptionList(type, listAttr, property, pluginInfo, propType, attributes);
break;
}
}
}
if (!pluginInfo.DebugMode)
return true;
foreach (var field in type.GetFields(MiraPluginManager.DeclaredInstanceMembers)
.Where(f => !MiraPluginManager.IsAutoPropertyBackingField(f)
&& (f.FieldType.IsAssignableTo(typeof(IModdedOption)) || f.FieldType.IsAssignableTo(typeof(IModdedOptionList)))))