mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Add some missing stuff to the new AU version support (#256)
* Fix Crowded support * Fix set players 127 not loading lobby * Fix Crowded * Fix Dleks icon not showning in options menu * Fix Region sorting in the new matchmaking system
This commit is contained in:
1 parent
ee9bb76266
commit
fc569ead1e
5 files changed
+154
-17
No files matched your search
@@ -744,9 +744,9 @@ public class Main : BasePlugin
|
||||
ClassInjector.RegisterTypeInIl2Cpp<ShapeShifterPagingBehaviour>();
|
||||
ClassInjector.RegisterTypeInIl2Cpp<VitalsPagingBehaviour>();
|
||||
|
||||
NormalGameOptionsV09.RecommendedImpostors = NormalGameOptionsV09.MaxImpostors = Enumerable.Repeat(127, 127).ToArray();
|
||||
NormalGameOptionsV09.MinPlayers = Enumerable.Repeat(4, 127).ToArray();
|
||||
HideNSeekGameOptionsV08.MinPlayers = Enumerable.Repeat(4, 127).ToArray();
|
||||
NormalGameOptionsV09.RecommendedImpostors = NormalGameOptionsV09.MaxImpostors = Enumerable.Repeat(128, 128).ToArray();
|
||||
NormalGameOptionsV09.MinPlayers = Enumerable.Repeat(4, 128).ToArray();
|
||||
HideNSeekGameOptionsV09.MinPlayers = Enumerable.Repeat(4, 128).ToArray();
|
||||
|
||||
CustomLogger.ClearLog();
|
||||
|
||||
@@ -1031,4 +1031,4 @@ public enum TieMode
|
||||
Random
|
||||
}
|
||||
|
||||
public class Coroutines : MonoBehaviour { }
|
||||
public class Coroutines : MonoBehaviour { }
|
||||
+35
-3
@@ -163,6 +163,11 @@ internal static class Crowded
|
||||
if (GameOptionsManager.Instance.GameHostOptions != null && GameOptionsManager.Instance.GameHostOptions.MaxPlayers > 15)
|
||||
GameOptionsManager.Instance.GameHostOptions.SetInt(Int32OptionNames.MaxPlayers, 15);
|
||||
|
||||
if (GameOptionsManager.Instance.GameHostOptions.NumImpostors > 3)
|
||||
{
|
||||
GameOptionsManager.Instance.GameHostOptions.SetInt(Int32OptionNames.NumImpostors, 3);
|
||||
}
|
||||
|
||||
if (Instance)
|
||||
{
|
||||
for (var i = 1; i < 11; i++)
|
||||
@@ -341,6 +346,32 @@ internal static class Crowded
|
||||
__instance.gameObject.AddComponent<VitalsPagingBehaviour>().vitalsMinigame = __instance;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PSManager), nameof(PSManager.CreateGame))]
|
||||
[HarmonyPatch(typeof(CreateGameOptions), nameof(CreateGameOptions.ContinueStart))]
|
||||
public static class BeforeHostGamePatch
|
||||
{
|
||||
public static void Prefix()
|
||||
{
|
||||
Logger.Info("Host Game is being called!", "Crowded");
|
||||
|
||||
if (GameStates.IsVanillaServer && !GameStates.IsLocalGame)
|
||||
{
|
||||
if (GameOptionsManager.Instance.GameHostOptions != null)
|
||||
{
|
||||
if (GameOptionsManager.Instance.GameHostOptions.MaxPlayers > 15)
|
||||
{
|
||||
GameOptionsManager.Instance.GameHostOptions.SetInt(Int32OptionNames.MaxPlayers, 15);
|
||||
}
|
||||
|
||||
if (GameOptionsManager.Instance.GameHostOptions.NumImpostors > 3)
|
||||
{
|
||||
GameOptionsManager.Instance.GameHostOptions.SetInt(Int32OptionNames.NumImpostors, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AbstractPagingBehaviour(IntPtr ptr) : MonoBehaviour(ptr)
|
||||
@@ -367,9 +398,10 @@ public class AbstractPagingBehaviour(IntPtr ptr) : MonoBehaviour(ptr)
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.LeftArrow) || Input.mouseScrollDelta.y > 0f)
|
||||
bool chatIsOpen = HudManager.Instance.Chat.IsOpenOrOpening;
|
||||
if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.LeftArrow) || (!chatIsOpen && Input.mouseScrollDelta.y > 0f))
|
||||
Cycle(false);
|
||||
else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.RightArrow) || Input.mouseScrollDelta.y < 0f)
|
||||
else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.RightArrow) || (!chatIsOpen && Input.mouseScrollDelta.y < 0f))
|
||||
Cycle(true);
|
||||
}
|
||||
|
||||
@@ -527,4 +559,4 @@ public class VitalsPagingBehaviour(IntPtr ptr) : AbstractPagingBehaviour(ptr)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,6 +510,9 @@ public static class NumberOptionPatch
|
||||
__instance.Value = (float)Math.Round(__instance.Value, 2);
|
||||
if (DebugModeManager.AmDebugger) __instance.ValidRange.min = 0;
|
||||
break;
|
||||
case StringNames.CapacityLabel:
|
||||
__instance.ValidRange = new(4, 127);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ModGameOptionsMenu.OptionList.TryGetValue(__instance, out int index))
|
||||
@@ -1333,4 +1336,4 @@ public class RpcSyncSettingsPatch
|
||||
{
|
||||
OptionItem.SyncAllOptions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace EHR.Patches;
|
||||
|
||||
@@ -11,13 +12,15 @@ internal static class CreateOptionsPickerPatch
|
||||
public static bool SetDleks;
|
||||
private static MapSelectButton DleksButton;
|
||||
|
||||
[HarmonyPatch(typeof(GameOptionsMapPicker))]
|
||||
[HarmonyPatch]
|
||||
public static class GameOptionsMapPickerPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(GameOptionsMapPicker.Initialize))]
|
||||
[HarmonyPatch(typeof(GameOptionsMapPicker), nameof(GameOptionsMapPicker.SetupMapButtons))]
|
||||
[HarmonyPostfix]
|
||||
public static void Postfix_Initialize(GameOptionsMapPicker __instance)
|
||||
public static void Postfix_Initialize(CreateGameMapPicker __instance)
|
||||
{
|
||||
if (SceneManager.GetActiveScene().name == "FindAGame") return;
|
||||
|
||||
const int dleksPos = 3;
|
||||
|
||||
MapSelectButton[] AllMapButton = __instance.transform.GetComponentsInChildren<MapSelectButton>();
|
||||
@@ -29,7 +32,11 @@ internal static class CreateOptionsPickerPatch
|
||||
dlekS_ehT.transform.SetSiblingIndex(dleksPos + 2);
|
||||
var dlekS_ehT_MapButton = dlekS_ehT.GetComponent<MapSelectButton>();
|
||||
DleksButton = dlekS_ehT_MapButton;
|
||||
//dlekS_ehT_MapButton.MapIcon.transform.localScale = new(-1f, 1f, 1f);
|
||||
foreach (var icon in dlekS_ehT_MapButton.MapIcon)
|
||||
{
|
||||
if (icon == null || icon.transform == null) continue;
|
||||
icon.flipX = true;
|
||||
}
|
||||
dlekS_ehT_MapButton.Button.OnClick.RemoveAllListeners();
|
||||
|
||||
dlekS_ehT_MapButton.Button.OnClick.AddListener((Action)(() =>
|
||||
@@ -69,13 +76,37 @@ internal static class CreateOptionsPickerPatch
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(GameOptionsMapPicker.FixedUpdate))]
|
||||
[HarmonyPatch(typeof(GameOptionsMapPicker), nameof(GameOptionsMapPicker.FixedUpdate))]
|
||||
[HarmonyPrefix]
|
||||
public static bool Prefix_FixedUpdate(GameOptionsMapPicker __instance)
|
||||
{
|
||||
if (DleksButton != null) SetDleks = __instance.selectedMapId == 3;
|
||||
if (__instance == null) return true;
|
||||
|
||||
return __instance.selectedMapId != 3;
|
||||
if (__instance.MapName == null) return false;
|
||||
|
||||
if (DleksButton != null)
|
||||
{
|
||||
if (__instance.selectedMapId == 3)
|
||||
{
|
||||
SetDleks = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDleks = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.selectedMapId == 3)
|
||||
{
|
||||
if (SceneManager.GetActiveScene().name == "FindAGame")
|
||||
{
|
||||
__instance.SelectMap(0);
|
||||
SetDleks = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,4 +188,4 @@ internal static class CreateOptionsPickerPatch
|
||||
transform2.position = position2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace EHR.Patches;
|
||||
// https://github.com/0xDrMoe/TownofHost-Enhanced/blob/4ba167ac3009c54b14ee007534dc033227ded2a1/Patches/RegionMenuPatch.cs
|
||||
@@ -40,4 +41,74 @@ public static class RegionMenuPatch
|
||||
buttons[i].transform.localPosition = startPosition + new Vector3(col * buttonSpacingSide, -row * buttonSpacing, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class ServerDropDownPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(ServerDropdown), nameof(ServerDropdown.FillServerOptions))]
|
||||
[HarmonyPostfix]
|
||||
public static void AdjustButtonPositions(ServerDropdown __instance)
|
||||
{
|
||||
List<ServerListButton> allButtons = __instance.GetComponentsInChildren<ServerListButton>().ToList();
|
||||
|
||||
if (allButtons.Count == 0)
|
||||
return;
|
||||
|
||||
float buttonSpacing = 0.6f;
|
||||
float columnSpacing = 4.25f;
|
||||
|
||||
if (SceneManager.GetActiveScene().name == "FindAGame")
|
||||
{
|
||||
const int buttonsPerColumn = 7;
|
||||
|
||||
int columnCount = (allButtons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
|
||||
|
||||
Vector3 startPosition = new Vector3(0, -buttonSpacing, 0);
|
||||
|
||||
for (int i = 0; i < allButtons.Count; i++)
|
||||
{
|
||||
int col = i / buttonsPerColumn;
|
||||
int row = i % buttonsPerColumn;
|
||||
allButtons[i].transform.localPosition = startPosition + new Vector3(col * columnSpacing, -row * buttonSpacing, 0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Total 2 colums
|
||||
const int buttonsInFirstColumn = 5;
|
||||
|
||||
int buttonsInSecondColumn = allButtons.Count - buttonsInFirstColumn;
|
||||
|
||||
// If we have less than 5 buttons to show, skip following codes
|
||||
if (buttonsInFirstColumn <= 0 || buttonsInSecondColumn <= 0)
|
||||
{
|
||||
for (int i = 0; i < allButtons.Count; i++)
|
||||
{
|
||||
allButtons[i].transform.localPosition = new Vector3(0, -i * buttonSpacing, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 startPosition = new Vector3(0, -buttonSpacing, 0);
|
||||
|
||||
for (int i = 0; i < buttonsInFirstColumn; i++)
|
||||
{
|
||||
allButtons[i].transform.localPosition = startPosition + new Vector3(0, -i * buttonSpacing, 0);
|
||||
}
|
||||
|
||||
float secondColumnStartY = 0;
|
||||
if (buttonsInSecondColumn > 1)
|
||||
{
|
||||
// Last button in second column should be at the same height as the last button in the first column
|
||||
secondColumnStartY = -(buttonsInFirstColumn - buttonsInSecondColumn) * buttonSpacing;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buttonsInSecondColumn; i++)
|
||||
{
|
||||
int buttonIndex = buttonsInFirstColumn + i;
|
||||
allButtons[buttonIndex].transform.localPosition = startPosition + new Vector3(columnSpacing, secondColumnStartY - i * buttonSpacing, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user