mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
some fixes & improvements
This commit is contained in:
1 parent
56d510116d
commit
47f7eb0c2b
15 files changed
+113
-87
No files matched your search
@@ -162,7 +162,7 @@ internal static class HotPotato
|
||||
if (HotPotatoState.TimeLeft <= 0)
|
||||
{
|
||||
holder.Suicide();
|
||||
RecordDeath(HotPotatoState.HolderID, (HotPotatoState.RoundNum - 1) * GetKillInterval());
|
||||
RecordDeath(HotPotatoState.HolderID, Options.IntegrateNaturalDisasters.GetBool() ? (int)(Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS - NaturalDisasters.FixedUpdatePatch.WaitTime) : (HotPotatoState.RoundNum - 1) * GetKillInterval());
|
||||
PassHotPotato();
|
||||
|
||||
if (holder.AmOwner)
|
||||
|
||||
@@ -870,6 +870,8 @@ public static class RoomRush
|
||||
case MapNames.Airship:
|
||||
time += previous switch
|
||||
{
|
||||
SystemTypes.MeetingRoom => 5,
|
||||
SystemTypes.Electrical => 4,
|
||||
SystemTypes.Engine => 3,
|
||||
SystemTypes.MainHall => 2,
|
||||
_ => 0
|
||||
|
||||
@@ -53,8 +53,8 @@ public class Main : BaseUnityPlugin
|
||||
private const string DebugKeyHash = "c0fd562955ba56af3ae20d7ec9e64c664f0facecef4b3e366e109306adeae29d";
|
||||
private const string DebugKeySalt = "59687b";
|
||||
public const string PluginGuid = "com.gurge44.endlesshostroles";
|
||||
public const string PluginVersion = "8.0.1";
|
||||
public const string PluginDisplayVersion = "8.0.1";
|
||||
public const string PluginVersion = "8.0.2";
|
||||
public const string PluginDisplayVersion = "8.0.2";
|
||||
public const int TestBuildNumber = 0; // 0 = Release
|
||||
|
||||
public const string NeutralColor = "#ffab1b";
|
||||
|
||||
@@ -25,7 +25,7 @@ public static class AmciRegistration
|
||||
/// <summary>
|
||||
/// Writes EHR's GUID into the game's mod registration slot so the matchmaker
|
||||
/// can filter lobby searches to EHR lobbies only.
|
||||
/// Call once from <see cref="Main.Load"/>.
|
||||
/// Call once when the mod loads.
|
||||
/// The base game code does the rest.
|
||||
/// </summary>
|
||||
public static void Apply()
|
||||
@@ -34,6 +34,15 @@ public static class AmciRegistration
|
||||
Logger.Info($"AMCI mod GUID registered: {ModGuidString}", nameof(AmciRegistration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reverts the AMCI mod GUID registration when the mod is unloaded.
|
||||
/// </summary>
|
||||
public static void Revert()
|
||||
{
|
||||
CurrentModRegistration.ModRegistrationGuidString = string.Empty;
|
||||
Logger.Info("AMCI mod GUID removed", nameof(AmciRegistration));
|
||||
}
|
||||
|
||||
// Fixes not being able to host local games when the mod GUID is registered
|
||||
[HarmonyPatch(typeof(CurrentModRegistration), nameof(CurrentModRegistration.TryGetModRegistrationGuid))]
|
||||
public static class TryGetModRegistrationGuidPatch
|
||||
|
||||
+52
-53
@@ -552,68 +552,67 @@ public class ClientControlGUI : MonoBehaviour
|
||||
bool canToggleHud = Main.IntroDestroyed && !inMeeting && !ExileController.Instance && !ReportDeadBodyPatch.MeetingStarted;
|
||||
|
||||
if (canZoom || canNoClip || canToggleHud)
|
||||
{
|
||||
Section(ref y, "Camera");
|
||||
|
||||
if (canZoom)
|
||||
if (canZoom)
|
||||
{
|
||||
// Sync slider to actual camera value so external changes (scroll wheel, touch pinch) are reflected
|
||||
if (_cam) _zoomValue = _cam.orthographicSize;
|
||||
|
||||
float newZoom = Slider(ref y, $"Zoom {_zoomValue:F1}x", _zoomValue, 3.0f, 18.0f, w);
|
||||
if (Mathf.Abs(newZoom - _zoomValue) > 0.01f)
|
||||
{
|
||||
// Sync slider to actual camera value so external changes (scroll wheel, touch pinch) are reflected
|
||||
if (_cam) _zoomValue = _cam.orthographicSize;
|
||||
|
||||
float newZoom = Slider(ref y, $"Zoom {_zoomValue:F1}x", _zoomValue, 3.0f, 18.0f, w);
|
||||
if (Mathf.Abs(newZoom - _zoomValue) > 0.01f)
|
||||
{
|
||||
_zoomValue = newZoom;
|
||||
Zoom.SetZoomSize(reset: false);
|
||||
if (_cam) _cam.orthographicSize = _zoomValue;
|
||||
if (HudManager.InstanceExists) HudManager.Instance.UICamera.orthographicSize = _zoomValue;
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(0, y, w, ButtonHeight), "Reset Zoom", _sAction))
|
||||
{
|
||||
Zoom.SetZoomSize(reset: true);
|
||||
_zoomValue = 3.0f;
|
||||
}
|
||||
y += ButtonHeight + Padding * 0.7f;
|
||||
_zoomValue = newZoom;
|
||||
Zoom.SetZoomSize(reset: false);
|
||||
if (_cam) _cam.orthographicSize = _zoomValue;
|
||||
if (HudManager.InstanceExists) HudManager.Instance.UICamera.orthographicSize = _zoomValue;
|
||||
}
|
||||
else if (!Mathf.Approximately(_zoomValue, 3.0f))
|
||||
|
||||
if (GUI.Button(new Rect(0, y, w, ButtonHeight), "Reset Zoom", _sAction))
|
||||
{
|
||||
Zoom.SetZoomSize(reset: true);
|
||||
_zoomValue = 3.0f;
|
||||
}
|
||||
|
||||
if (canNoClip)
|
||||
{
|
||||
// Reads live state every frame for correct label/colour; lambda also reads it on click to avoid stale values
|
||||
bool noclipOn = ControllerManagerUpdatePatch.NoClipEnabled;
|
||||
Btn(ref y, noclipOn ? "Noclip: ON" : "Noclip: OFF", noclipOn ? _sHost : _sAction, () =>
|
||||
{
|
||||
ControllerManagerUpdatePatch.NoClipEnabled = !ControllerManagerUpdatePatch.NoClipEnabled;
|
||||
if (OperatingSystem.IsAndroid()) PlayerControl.LocalPlayer.Collider.offset = ControllerManagerUpdatePatch.NoClipEnabled ? new Vector2(0f, 127f) : new Vector2(0f, -0.3636f);
|
||||
});
|
||||
}
|
||||
else if (ControllerManagerUpdatePatch.NoClipEnabled && OperatingSystem.IsAndroid() && PlayerControl.LocalPlayer)
|
||||
{
|
||||
PlayerControl.LocalPlayer.Collider.offset = new Vector2(0f, -0.3636f);
|
||||
ControllerManagerUpdatePatch.NoClipEnabled = false;
|
||||
}
|
||||
|
||||
if (canToggleHud)
|
||||
{
|
||||
Btn(ref y, HudHidden ? "Show HUD" : "Hide HUD", HudHidden ? _sHost : _sAction, () =>
|
||||
{
|
||||
HudHidden = !HudHidden;
|
||||
if (HudManager.InstanceExists)
|
||||
HudManager.Instance.gameObject.SetActive(!HudHidden);
|
||||
});
|
||||
}
|
||||
else if (HudHidden)
|
||||
{
|
||||
HudHidden = false;
|
||||
if (HudManager.InstanceExists)
|
||||
HudManager.Instance.gameObject.SetActive(true);
|
||||
}
|
||||
y += ButtonHeight + Padding * 0.7f;
|
||||
}
|
||||
else if (!Mathf.Approximately(_zoomValue, 3.0f))
|
||||
{
|
||||
Zoom.SetZoomSize(reset: true);
|
||||
_zoomValue = 3.0f;
|
||||
}
|
||||
|
||||
if (canNoClip)
|
||||
{
|
||||
// Reads live state every frame for correct label/colour; lambda also reads it on click to avoid stale values
|
||||
bool noclipOn = ControllerManagerUpdatePatch.NoClipEnabled;
|
||||
Btn(ref y, noclipOn ? "Noclip: ON" : "Noclip: OFF", noclipOn ? _sHost : _sAction, () =>
|
||||
{
|
||||
ControllerManagerUpdatePatch.NoClipEnabled = !ControllerManagerUpdatePatch.NoClipEnabled;
|
||||
if (OperatingSystem.IsAndroid()) PlayerControl.LocalPlayer.Collider.offset = ControllerManagerUpdatePatch.NoClipEnabled ? new Vector2(0f, 127f) : new Vector2(0f, -0.3636f);
|
||||
});
|
||||
}
|
||||
else if (ControllerManagerUpdatePatch.NoClipEnabled && OperatingSystem.IsAndroid() && PlayerControl.LocalPlayer)
|
||||
{
|
||||
PlayerControl.LocalPlayer.Collider.offset = new Vector2(0f, -0.3636f);
|
||||
ControllerManagerUpdatePatch.NoClipEnabled = false;
|
||||
}
|
||||
|
||||
if (canToggleHud)
|
||||
{
|
||||
Btn(ref y, HudHidden ? "Show HUD" : "Hide HUD", HudHidden ? _sHost : _sAction, () =>
|
||||
{
|
||||
HudHidden = !HudHidden;
|
||||
if (HudManager.InstanceExists)
|
||||
HudManager.Instance.gameObject.SetActive(!HudHidden);
|
||||
});
|
||||
}
|
||||
else if (HudHidden)
|
||||
{
|
||||
HudHidden = false;
|
||||
if (HudManager.InstanceExists)
|
||||
HudManager.Instance.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
Section(ref y, "Utilities");
|
||||
|
||||
|
||||
@@ -1507,9 +1507,7 @@ internal static class ExtendedPlayerControl
|
||||
|
||||
try
|
||||
{
|
||||
var queue = player.NetTransform.incomingPosQueue;
|
||||
|
||||
if (queue.Count > 0 && player.NetTransform.isActiveAndEnabled && !player.NetTransform.isPaused)
|
||||
if (player.NetTransform.incomingPosQueue.Count > 0 && player.NetTransform.isActiveAndEnabled && !player.NetTransform.isPaused)
|
||||
return CustomNetworkTransformHelper.CurrentPosition[player.PlayerId];
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
|
||||
@@ -605,6 +605,9 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.IntegrateNaturalDisasters.GetBool() && Options.CurrentGameMode != CustomGameMode.NaturalDisasters)
|
||||
NaturalDisasters.ApplyGameOptions(opt, player.PlayerId);
|
||||
|
||||
switch (player.GetCustomRoleTypes())
|
||||
{
|
||||
|
||||
+18
-2
@@ -2767,6 +2767,21 @@ public static class Utils
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
}
|
||||
|
||||
public static bool ChatDuringGame()
|
||||
{
|
||||
return Options.CurrentGameMode switch
|
||||
{
|
||||
CustomGameMode.SoloPVP => SoloPVP.SoloPVP_ChatDuringGame.GetBool(),
|
||||
CustomGameMode.FFA => FreeForAll.FFAChatDuringGame.GetBool(),
|
||||
CustomGameMode.Mingle => Mingle.ChatDuringGameOption.GetBool(),
|
||||
CustomGameMode.Quiz => Quiz.Chat,
|
||||
CustomGameMode.HideAndSeek => CustomHnS.Chat,
|
||||
CustomGameMode.NaturalDisasters => NaturalDisasters.Chat,
|
||||
CustomGameMode.Standard => Options.ChatDuringGame.GetBool(),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
public static string BuildSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false)
|
||||
{
|
||||
BuildSBSuffix.Clear().Append("<#ffffff>");
|
||||
@@ -3112,7 +3127,7 @@ public static class Utils
|
||||
SelfSuffix.Append($"\n\n<#ffffff>{GetString($"GameModeTutorial.{Options.CurrentGameMode}")}</color>\n");
|
||||
}
|
||||
|
||||
bool noRoleText = GameStates.IsLobby || Options.CurrentGameMode is CustomGameMode.CaptureTheFlag or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.TheMindGame or CustomGameMode.BedWars or CustomGameMode.Deathrace or CustomGameMode.Mingle or CustomGameMode.Snowdown or CustomGameMode.DoomTag;
|
||||
bool noRoleText = GameStates.IsLobby || ChatDuringGame() || Options.CurrentGameMode is CustomGameMode.CaptureTheFlag or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.TheMindGame or CustomGameMode.BedWars or CustomGameMode.Deathrace or CustomGameMode.Mingle or CustomGameMode.Snowdown or CustomGameMode.DoomTag;
|
||||
|
||||
// Combine the seer's job title and SelfTaskText with the seer's player name and SelfMark
|
||||
string selfRoleName = noRoleText ? string.Empty : $"<size={fontSize}>{seer.GetDisplayRoleName()}{selfTaskText}</size>";
|
||||
@@ -3469,7 +3484,8 @@ public static class Utils
|
||||
|
||||
var targetDeathReason = string.Empty;
|
||||
string newLineBeforeSuffix = !(Options.CurrentGameMode == CustomGameMode.BedWars && GameStates.InGame) ? "\r\n" : " - ";
|
||||
if (seer.KnowDeathReason(target) && !GameStates.IsLobby) targetDeathReason = $"{newLineBeforeSuffix}<size=1.7>({CustomRoles.Doctor.ColoredTextByRole(GetVitalText(target.PlayerId))})</size>";
|
||||
noRoleText = GameStates.IsLobby || ChatDuringGame() || Options.CurrentGameMode is CustomGameMode.CaptureTheFlag or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.TheMindGame or CustomGameMode.BedWars or CustomGameMode.Deathrace or CustomGameMode.Mingle or CustomGameMode.Snowdown or CustomGameMode.DoomTag;
|
||||
if (seer.KnowDeathReason(target) && !GameStates.IsLobby && !noRoleText) targetDeathReason = $"{newLineBeforeSuffix}<size=1.7>({CustomRoles.Doctor.ColoredTextByRole(GetVitalText(target.PlayerId))})</size>";
|
||||
|
||||
// Devourer
|
||||
if (Devourer.HideNameOfConsumedPlayer.GetBool() && !GameStates.IsLobby && !camouflageIsForMeeting)
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using EHR.Modules;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -127,6 +128,7 @@ public static class OptionsMenuBehaviourStartPatch
|
||||
{
|
||||
if (ClientControlGUI.Instance) Object.Destroy(ClientControlGUI.Instance);
|
||||
MainMenuManagerPatch.ShowRightPanelImmediately();
|
||||
AmciRegistration.Revert();
|
||||
|
||||
Main.Instance.Harmony.UnpatchSelf();
|
||||
#if IL2CPP
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AmongUs.GameOptions;
|
||||
using EHR.Modules;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace EHR.Patches;
|
||||
@@ -33,6 +34,7 @@ internal static class SwitchGameModePatch
|
||||
}
|
||||
|
||||
Zoom.SetZoomSize(reset: true);
|
||||
AmciRegistration.Revert();
|
||||
Main.Instance.Harmony.UnpatchSelf();
|
||||
#if IL2CPP
|
||||
Main.Instance.Unload();
|
||||
|
||||
+8
-12
@@ -1070,6 +1070,12 @@ internal static class BeginCrewmatePatch
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.IntegrateNaturalDisasters.GetBool() && Options.CurrentGameMode is not CustomGameMode.NaturalDisasters and not CustomGameMode.Standard)
|
||||
{
|
||||
__instance.ImpostorText.gameObject.SetActive(true);
|
||||
__instance.ImpostorText.text = $"+ {Utils.ColorString(Main.GameModeColors[CustomGameMode.NaturalDisasters], GetString("NDPlayer"))}";
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
AudioClip GetAudioClipFromCustomRoleType() =>
|
||||
@@ -1255,18 +1261,8 @@ internal static class IntroCutsceneDestroyPatch
|
||||
}
|
||||
}
|
||||
|
||||
switch (Options.CurrentGameMode)
|
||||
{
|
||||
case CustomGameMode.SoloPVP when SoloPVP.SoloPVP_ChatDuringGame.GetBool():
|
||||
case CustomGameMode.FFA when FreeForAll.FFAChatDuringGame.GetBool():
|
||||
case CustomGameMode.Mingle when Mingle.ChatDuringGameOption.GetBool():
|
||||
case CustomGameMode.Quiz when Quiz.Chat:
|
||||
case CustomGameMode.HideAndSeek when CustomHnS.Chat:
|
||||
case CustomGameMode.NaturalDisasters when NaturalDisasters.Chat:
|
||||
case CustomGameMode.Standard when Options.ChatDuringGame.GetBool():
|
||||
LateTask.New(() => Main.AllAlivePlayerControlsToList.SetChatVisible(true), 4f);
|
||||
break;
|
||||
}
|
||||
if (Utils.ChatDuringGame())
|
||||
LateTask.New(() => Main.AllAlivePlayerControlsToList.SetChatVisible(true), 4f);
|
||||
|
||||
// LateTask.New(() => Main.EnumeratePlayerControls().Do(pc ⇒ pc.RpcSetRoleDesync(RoleTypes.Shapeshifter, -3)), 2f, "SetImpostorForServer");
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ public static class MatchInfoGuidePatch
|
||||
__instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||
__instance.CreatePlayerEntries();
|
||||
ReColorTabButtons(__instance);
|
||||
SetAlternativeText(__instance);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,4 +150,12 @@ public static class MatchInfoGuidePatch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetAlternativeText(MatchInfoGuide __instance)
|
||||
{
|
||||
CustomGameMode currentGameMode = Options.CurrentGameMode;
|
||||
var tmp = __instance.rolesEnabledMessage.GetComponent<TextMeshPro>();
|
||||
tmp.DestroyTranslator();
|
||||
tmp.text = currentGameMode == CustomGameMode.Standard ? TranslationController.Instance.GetString(StringNames.MatchInfoGuideNoRolesMessage) : Translator.GetString(Main.HasPlayedGM.ContainsKey(currentGameMode) ? $"GameModeTutorial.{currentGameMode}" : $"ModeDescribe.{currentGameMode}");
|
||||
}
|
||||
}
|
||||
@@ -1439,10 +1439,6 @@ internal static class MeetingHudOnDestroyPatch
|
||||
}
|
||||
|
||||
if (Main.LIMap) Main.Instance.StartCoroutine(WaitForExileFinish());
|
||||
|
||||
GC.Collect();
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
return;
|
||||
|
||||
IEnumerator WaitForExileFinish()
|
||||
|
||||
@@ -800,13 +800,6 @@ internal static class SetEverythingUpPatch
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
GC.Collect();
|
||||
yield return null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
static string GetAdditionalWinnerRoleName(string role)
|
||||
|
||||
@@ -1657,7 +1657,7 @@ internal static class FixedUpdatePatch
|
||||
|
||||
if (self)
|
||||
{
|
||||
if (NumSnapToCallsThisRound > 80)
|
||||
if (NumSnapToCallsThisRound > 80 && !lowLoad)
|
||||
NumSnapToCallsThisRound = 80;
|
||||
|
||||
Zoom.OnFixedUpdate();
|
||||
@@ -2207,7 +2207,8 @@ internal static class FixedUpdatePatch
|
||||
|
||||
string suffix = Suffix.ToString().Trim();
|
||||
string newLineBeforeSuffix = !(Options.CurrentGameMode == CustomGameMode.BedWars && !self && GameStates.InGame) ? "\n" : " - ";
|
||||
string deathReason = !seer.IsAlive() && seer.KnowDeathReason(target) ? $"{newLineBeforeSuffix}<size=1.5>『{CustomRoles.Doctor.ColoredTextByRole(GetVitalText(target.PlayerId))}』</size>" : string.Empty;
|
||||
bool noRoleText = GameStates.IsLobby || ChatDuringGame() || Options.CurrentGameMode is CustomGameMode.CaptureTheFlag or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.TheMindGame or CustomGameMode.BedWars or CustomGameMode.Deathrace or CustomGameMode.Mingle or CustomGameMode.Snowdown or CustomGameMode.DoomTag;
|
||||
string deathReason = !seer.IsAlive() && seer.KnowDeathReason(target) && !noRoleText ? $"{newLineBeforeSuffix}<size=1.5>『{CustomRoles.Doctor.ColoredTextByRole(GetVitalText(target.PlayerId))}』</size>" : string.Empty;
|
||||
|
||||
target.cosmetics.nameText.text = $"{roleText}{realName}{deathReason}{Mark}{newLineBeforeSuffix}{suffix}";
|
||||
|
||||
|
||||
Reference in new issue
Block a user