Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AleLuduMod/AleLuduMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>
<PropertyGroup>
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
<GameVersion>2025.3.25</GameVersion>
<GameVersion>2025.9.9</GameVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Reactor" Version="2.4.0-ci.344" />
Expand Down
10 changes: 7 additions & 3 deletions src/AleLuduMod/AleLuduModPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ public partial class AleLuduModPlugin : BasePlugin

public override void Load()
{
NormalGameOptionsV09.RecommendedImpostors = NormalGameOptionsV09.MaxImpostors = Enumerable.Repeat(36, 36).ToArray();
NormalGameOptionsV09.MinPlayers = Enumerable.Repeat(4, 36).ToArray();
HideNSeekGameOptionsV09.MinPlayers = Enumerable.Repeat(4, 36).ToArray();
NormalGameOptionsV10.RecommendedImpostors = NormalGameOptionsV10.MaxImpostors = Enumerable.Repeat(36, 36).ToArray();
NormalGameOptionsV10.MinPlayers = Enumerable.Repeat(4, 36).ToArray();
HideNSeekGameOptionsV10.MinPlayers = Enumerable.Repeat(4, 36).ToArray();

IL2CPPChainloader.Instance.Finished +=
ModCompatibility
.Initialize; // Initialise AFTER the mods are loaded to ensure maximum parity

Force4Columns = Config.Bind("Settings", "Force 4 columns", true, "Always display 4 columns in meeting, vitals, etc.");

Expand Down
81 changes: 81 additions & 0 deletions src/AleLuduMod/ModCompatibility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@


using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Reactor.Utilities;
using UnityEngine;

namespace AleLuduMod;

public static class ModCompatibility
{
public const string MiraApiGuid = "mira.api";
public static bool MiraApiLoaded { get; private set; }
private static BasePlugin MiraApiPlugin { get; set; }
private static Assembly MiraApiAssembly { get; set; }
private static Type[] MiraApiTypes { get; set; }
public static float XStart = -0.8f;
public static float YStart = 2.15f;
public static float XOffset = 1.95f;
public static float YOffset = -0.65f;

public static void Initialize()
{
InitMiraApi();
}

private static void InitMiraApi()
{
if (!IL2CPPChainloader.Instance.Plugins.TryGetValue(MiraApiGuid, out var value))
{
return;
}

MiraApiPlugin = (value.Instance as BasePlugin)!;
MiraApiAssembly = MiraApiPlugin.GetType().Assembly;

MiraApiTypes = AccessTools.GetTypesFromAssembly(MiraApiAssembly);

var playerMenu = MiraApiTypes.First(t => t.Name == "CustomPlayerMenu");
var menuBegin = AccessTools.Method(playerMenu, "Begin", new [] {typeof(Func<PlayerControl, bool>), typeof(Action<PlayerControl?>)});

var compatType = typeof(ModCompatibility);
var harmony = new Harmony("aleludu.miraapi.patch");
harmony.Patch(menuBegin, null,
new HarmonyMethod(AccessTools.Method(compatType, nameof(BeginPostfix))));

MiraApiLoaded = true;
Logger<AleLuduModPlugin>.Message("MiraAPI was detected and patched");
}
public static void BeginPostfix(dynamic __instance, Func<PlayerControl, bool> playerMatch, Action<PlayerControl?> onClick)
{
var targets = __instance.potentialVictims as List<ShapeshifterPanel>;
if (targets == null || targets.Count() < 16 && !AleLuduModPlugin.Force4Columns.Value)
{
// dont change layout if players count is below 16
return;
}

var i = 0;

foreach (var panel in targets)
{
panel.gameObject.SetActive(true);

var row = i / 4;
var col = i % 4;
var buttonTransform = panel.transform;
buttonTransform.localScale *= 0.75f;
buttonTransform.localPosition = new Vector3(
XStart + XOffset * col * 1.1f - 2.4f,
YStart + YOffset * row * 0.9255f - 0.65f,
buttonTransform.localPosition.z
);
i++;
}
}
}