Conversation
|
The target version has been changed to v17. |
|
I tried writing a patch like the one below, but applying it failed. I think it's difficult to merge these patches, because the type of |
|
@yukieiji i think the instance being |
|
@XtraCube don't work
[HarmonyPatch]
public static class InvalidOptionsPatches
{
[HarmonyTargetMethods]
public static IEnumerable<System.Reflection.MethodBase> TargetMethod()
{
var allType = AccessTools.AllTypes();
var optionType = allType
.Where(x => x.IsSubclassOf(typeof(IGameOptions)));
return optionType
.Select(x => AccessTools.Method(x, "AreInvalid"))
.Where(x => x != null);
}
[HarmonyPrefix]
public static bool IsOptionValid(Il2CppObjectBase __instance, [HarmonyArgument(0)] int maxExpectedPlayers)
{
var option = __instance.Cast<IGameOptions>();
return
option.MaxPlayers > maxExpectedPlayers ||
option.NumImpostors < 1 ||
option.NumImpostors + 1 > maxExpectedPlayers / 2 ||
option.GetInt(Int32OptionNames.KillDistance) is < 0 or > 2 ||
option.GetFloat(FloatOptionNames.PlayerSpeedMod) is <= 0f or > 3f;
}
}
|
|
Woah that does not look like a normal log, I'll see if I have time later today to look at it. |
|
Actually, dont use AccessTools.AllTypes(). Just use typeof(IGameOptions).Assembly.GetTypes() |
|
@XtraCube don't work
[HarmonyPatch]
public static class InvalidOptionsPatches
{
[HarmonyTargetMethods]
public static IEnumerable<System.Reflection.MethodBase> TargetMethod()
{
var allType = typeof(IGameOptions).Assembly.GetTypes();
var optionType = allType
.Where(x => x.IsSubclassOf(typeof(IGameOptions)));
return optionType
.Select(x => AccessTools.Method(x, "AreInvalid"))
.Where(x => x != null);
}
[HarmonyPrefix]
public static bool IsOptionValid(Il2CppObjectBase __instance, [HarmonyArgument(0)] int maxExpectedPlayers)
{
var option = __instance.Cast<IGameOptions>();
return
option.MaxPlayers > maxExpectedPlayers ||
option.NumImpostors < 1 ||
option.NumImpostors + 1 > maxExpectedPlayers / 2 ||
option.GetInt(Int32OptionNames.KillDistance) is < 0 or > 2 ||
option.GetFloat(FloatOptionNames.PlayerSpeedMod) is <= 0f or > 3f;
}
}
|
|
I figured out the issue, interfaces don't show up in inheritance. we have to use a different approach |
Update mod to 2025.4.15(v16)+
Fixed unity object cast