mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
* Well lets try check this * Some changes * Change * Well * Change ControllerManager.Update * Nothing * Optimaze more? * Fix error build * Fix win check * Change * Fix * Optimaze some roles in OnCheckPlayerPosition * More optimaze * Full optimaze roles in OnGlobalFixedUpdate * Optimaze some add-ons * ProgressText * Change * Optimaze NameNotifyManager * Optimaze NotifyRoles and some roles * Move the displayed version * Some changes * Optimaze OnFixedUpdate in some roles * Fix bugs * Optimaze IsActive & V4 version * Optimaze MapRoom.DoorsUpdate * Cache TryCatch in IsActive * Change * Fix * More optimze TaskPanelBehaviour * Cache GetRoleColor & ColorString & AllStringNames & Change RemoveHtmlTags * Cache TryCast VentilationSystem & ICriticalSabotage & IUsable and more optimaze * Fix CountAlivePlayers * Fix exceptios * Replace some CachedAllPlayerControls to EnumeratePlayerControls * Replace some CachedAlivePlayerControls to EnumerateAlivePlayerControls * Fixes * Fix modded clients * Fix errors * Fix again * Optimaze & add null check * Fix crash in Starlight * Use only Main.PluginVersion in LobbySharingAPI * Optimaze code in FixedUpdate * Fix * Optimize GetProgressText for Roles * Some changes in Translations * Cache Enum.GetValues and StringBuilder * Changes * CustomRole.ColoredTextByRole() * Optimaze Lobby & Meeting * ColorStringPrefix => ColorPrefix * Add null check * Remove * Fixes & optimaze * Fixes * Changes * Fix * Fix * Fix * Remove * Fix * Change * Revert
78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using HarmonyLib;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace EHR.Patches;
|
|
|
|
// Thanks TOU-R: https://github.com/eDonnes124/Town-Of-Us-R/blob/master/source/Patches/ShowHostMeetingPatch.cs
|
|
|
|
[HarmonyPatch]
|
|
public static class ShowHostMeetingPatch
|
|
{
|
|
private static PlayerControl HostControl;
|
|
private static string HostName = string.Empty;
|
|
private static int HostColor = int.MaxValue;
|
|
|
|
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.OnDestroy))]
|
|
[HarmonyPostfix]
|
|
public static void OnDestroy_Postfix()
|
|
{
|
|
try
|
|
{
|
|
Main.ForceRebuildCachesPlayerControls();
|
|
GameEndChecker.ForceCheckEnd();
|
|
|
|
if (GameStates.IsInGame && HostControl == null)
|
|
{
|
|
PlayerControl host = AmongUsClient.Instance.GetHost().Character;
|
|
NetworkedPlayerInfo.PlayerOutfit outfit = Main.PlayerStates[host.Data.PlayerId].NormalOutfit;
|
|
|
|
HostControl = host;
|
|
HostName = Main.AllPlayerNames.GetValueOrDefault(host.PlayerId, outfit.PlayerName);
|
|
HostColor = outfit.ColorId;
|
|
|
|
if (GameStates.IsMeeting)
|
|
SetMasksEnabled_Postfix(MeetingHud.Instance);
|
|
}
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
// [HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowRole))]
|
|
// [HarmonyPostfix]
|
|
public static void ShowRole_Postfix()
|
|
{
|
|
PlayerControl host = AmongUsClient.Instance.GetHost().Character;
|
|
|
|
HostControl = host;
|
|
HostName = Main.AllPlayerNames.GetValueOrDefault(host.PlayerId, host.CurrentOutfit.PlayerName);
|
|
HostColor = host.CurrentOutfit.ColorId;
|
|
}
|
|
|
|
|
|
[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.SetMasksEnabled))]
|
|
[HarmonyPostfix]
|
|
public static void SetMasksEnabled_Postfix(MeetingHud __instance)
|
|
{
|
|
// Don't display it in local games, because it would be impossible to end meetings
|
|
if (!GameStates.IsOnlineGame) return;
|
|
|
|
PlayerMaterial.SetColors(HostColor, __instance.HostIcon);
|
|
__instance.ProceedButton.gameObject.GetComponentInChildren<TextMeshPro>().text = string.Format(Translator.GetString("HostIconInMeeting"), HostName);
|
|
}
|
|
|
|
//[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.Start))]
|
|
//[HarmonyPostfix]
|
|
public static void Setup_Postfix(MeetingHud __instance)
|
|
{
|
|
if (!GameStates.IsOnlineGame) return;
|
|
|
|
__instance.ProceedButton.gameObject.transform.localPosition = new(-2.5f, 2.2f, 0);
|
|
__instance.ProceedButton.gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
|
__instance.ProceedButton.GetComponent<PassiveButton>().enabled = false;
|
|
__instance.HostIcon.enabled = true;
|
|
__instance.HostIcon.gameObject.SetActive(true);
|
|
__instance.ProceedButton.gameObject.SetActive(true);
|
|
}
|
|
} |