This commit is contained in:
Gurge44 committed 2024-07-26 16:26:05 +02:00
1 parent d3306027ba
commit 21a9956e83
9 files changed
+87 -66

No files matched your search

+1
View File
@@ -892,6 +892,7 @@ internal static class CustomRolesHelper
public static bool CheckAddonConflict(CustomRoles role, PlayerControl pc) => role.IsAdditionRole() && (!Main.NeverSpawnTogetherCombos.TryGetValue(OptionItem.CurrentPreset, out var neverList) || !neverList.TryGetValue(pc.GetCustomRole(), out var bannedAddonList) || !bannedAddonList.Contains(role)) && pc.GetCustomRole() is not CustomRoles.GuardianAngelEHR and not CustomRoles.God && !pc.Is(CustomRoles.Madmate) && !pc.Is(CustomRoles.GM) && role is not CustomRoles.Lovers && !pc.Is(CustomRoles.Needy) && (!pc.HasSubRole() || pc.GetCustomSubRoles().Count < Options.NoLimitAddonsNumMax.GetInt()) && (!Options.AddonCanBeSettings.TryGetValue(role, out var o) || ((o.Imp.GetBool() || !pc.GetCustomRole().IsImpostor()) && (o.Neutral.GetBool() || !pc.GetCustomRole().IsNeutral()) && (o.Crew.GetBool() || !pc.IsCrewmate()))) && (!role.IsImpOnlyAddon() || pc.IsImpostor()) && role switch
{
CustomRoles.Nimble when pc.Is(CustomRoles.Oxyman) => false,
CustomRoles.Magnet when pc.Is(Team.Impostor) => false,
CustomRoles.Swift when pc.Is(CustomRoles.Magnet) => false,
CustomRoles.Oblivious when pc.Is(CustomRoles.Amnesiac) && Amnesiac.RememberMode.GetValue() == 1 => false,
+33 -34
View File
@@ -17,16 +17,15 @@ namespace EHR;
public class ModUpdater
{
private const string URLGithub = "https://api.github.com/repos/Gurge44/EndlessHostRoles";
public static bool hasUpdate;
public static bool hasOutdate;
public static bool forceUpdate = false;
public static bool isBroken;
public static bool isChecked;
public static Version latestVersion;
public static string latestTitle;
public static string downloadUrl;
public static string notice = null;
public static GenericPopup InfoPopup;
public static bool HasUpdate;
private static bool HasOutdate;
public static bool ForceUpdate = false;
public static bool IsBroken;
private static bool IsChecked;
private static Version LatestVersion;
private static string LatestTitle;
public static string DownloadUrl;
private static GenericPopup InfoPopup;
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPrefix]
[HarmonyPriority(2)]
@@ -37,14 +36,14 @@ public class ModUpdater
InfoPopup = Object.Instantiate(TwitchManager.Instance.TwitchPopup);
InfoPopup.name = "InfoPopup";
InfoPopup.TextAreaTMP.GetComponent<RectTransform>().sizeDelta = new(2.5f, 2f);
if (!isChecked)
if (!IsChecked)
{
bool done = CheckReleaseFromGithub(Main.BetaBuildUrl.Value != "").GetAwaiter().GetResult();
Logger.Warn("done: " + done, "CheckRelease");
Logger.Info("hasupdate: " + hasUpdate, "CheckRelease");
Logger.Info("forceupdate: " + forceUpdate, "CheckRelease");
Logger.Info("downloadUrl: " + downloadUrl, "CheckRelease");
Logger.Info("latestVersionl: " + latestVersion, "CheckRelease");
Logger.Info("hasupdate: " + HasUpdate, "CheckRelease");
Logger.Info("forceupdate: " + ForceUpdate, "CheckRelease");
Logger.Info("downloadUrl: " + DownloadUrl, "CheckRelease");
Logger.Info("latestVersionl: " + LatestVersion, "CheckRelease");
}
}
@@ -90,47 +89,47 @@ public class ModUpdater
JObject data = JObject.Parse(result);
if (beta)
{
latestTitle = data["name"].ToString();
downloadUrl = data["url"].ToString();
hasUpdate = latestTitle != ThisAssembly.Git.Commit;
LatestTitle = data["name"].ToString();
DownloadUrl = data["url"].ToString();
HasUpdate = LatestTitle != ThisAssembly.Git.Commit;
}
else
{
latestVersion = new(data["tag_name"]?.ToString().TrimStart('v') ?? string.Empty);
latestTitle = $"Ver. {latestVersion}";
LatestVersion = new(data["tag_name"]?.ToString().TrimStart('v') ?? string.Empty);
LatestTitle = $"Ver. {LatestVersion}";
JArray assets = data["assets"].Cast<JArray>();
for (int i = 0; i < assets.Count; i++)
{
if (assets[i]["name"].ToString() == $"EHR.v{latestVersion}.zip")
if (assets[i]["name"].ToString() == $"EHR.v{LatestVersion}.zip")
{
downloadUrl = assets[i]["browser_download_url"].ToString();
DownloadUrl = assets[i]["browser_download_url"].ToString();
break;
}
}
hasUpdate = latestVersion.CompareTo(Main.Version) > 0;
hasOutdate = latestVersion.CompareTo(Main.Version) < 0;
HasUpdate = LatestVersion.CompareTo(Main.Version) > 0;
HasOutdate = LatestVersion.CompareTo(Main.Version) < 0;
}
Logger.Info("hasupdate: " + hasUpdate, "GitHub");
Logger.Info("hasoutdate: " + hasOutdate, "GitHub");
Logger.Info("forceupdate: " + forceUpdate, "GitHub");
Logger.Info("downloadUrl: " + downloadUrl, "GitHub");
Logger.Info("latestVersionl: " + latestVersion, "GitHub");
Logger.Info("latestTitle: " + latestTitle, "GitHub");
Logger.Info("hasupdate: " + HasUpdate, "GitHub");
Logger.Info("hasoutdate: " + HasOutdate, "GitHub");
Logger.Info("forceupdate: " + ForceUpdate, "GitHub");
Logger.Info("downloadUrl: " + DownloadUrl, "GitHub");
Logger.Info("latestVersionl: " + LatestVersion, "GitHub");
Logger.Info("latestTitle: " + LatestTitle, "GitHub");
if (string.IsNullOrEmpty(downloadUrl))
if (string.IsNullOrEmpty(DownloadUrl))
{
Logger.Error("No Download URL", "CheckRelease");
return false;
}
isChecked = true;
isBroken = false;
IsChecked = true;
IsBroken = false;
}
catch (Exception ex)
{
isBroken = true;
IsBroken = true;
Logger.Error($"Error while checking release from GitHub:\n{ex}", "CheckRelease", false);
return false;
}
+3 -2
View File
@@ -899,11 +899,12 @@ internal static class RPC
player.Exiled();
}
public static async void RpcVersionCheck()
public static void RpcVersionCheck()
{
Main.Instance.StartCoroutine(VersionCheck());
return;
System.Collections.IEnumerator VersionCheck()
static System.Collections.IEnumerator VersionCheck()
{
while (PlayerControl.LocalPlayer == null) yield return null;
MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionCheck);
+5 -5
View File
@@ -16,12 +16,12 @@ internal class MakePublicPatch
{
public static bool Prefix()
{
if (ModUpdater.isBroken || (ModUpdater.hasUpdate && ModUpdater.forceUpdate) || !VersionChecker.IsSupported)
if (ModUpdater.IsBroken || (ModUpdater.HasUpdate && ModUpdater.ForceUpdate) || !VersionChecker.IsSupported)
{
var message = string.Empty;
if (!VersionChecker.IsSupported) message = GetString("UnsupportedVersion");
if (ModUpdater.isBroken) message = GetString("ModBrokenMessage");
if (ModUpdater.hasUpdate) message = GetString("CanNotJoinPublicRoomNoLatest");
if (ModUpdater.IsBroken) message = GetString("ModBrokenMessage");
if (ModUpdater.HasUpdate) message = GetString("CanNotJoinPublicRoomNoLatest");
Logger.Info(message, "MakePublicPatch");
Logger.SendInGame(message);
return false;
@@ -37,7 +37,7 @@ internal class MMOnlineManagerStartPatch
{
public static void Postfix()
{
if (!((ModUpdater.hasUpdate && ModUpdater.forceUpdate) || ModUpdater.isBroken)) return;
if (!((ModUpdater.HasUpdate && ModUpdater.ForceUpdate) || ModUpdater.IsBroken)) return;
var obj = GameObject.Find("FindGameButton");
if (obj)
{
@@ -45,7 +45,7 @@ internal class MMOnlineManagerStartPatch
var textObj = Object.Instantiate(obj.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>());
textObj.transform.position = new(1f, -0.3f, 0);
textObj.name = "CanNotJoinPublic";
var message = ModUpdater.isBroken
var message = ModUpdater.IsBroken
? $"<size=2>{Utils.ColorString(Color.red, GetString("ModBrokenMessage"))}</size>"
: $"<size=2>{Utils.ColorString(Color.red, GetString("CanNotJoinPublicRoomNoLatest"))}</size>";
LateTask.New(() => { textObj.text = message; }, 0.01f, "CanNotJoinPublic");
+20 -2
View File
@@ -24,6 +24,7 @@ public static class ModGameOptionsMenu
public static class GameOptionsMenuPatch
{
public static GameOptionsMenu Instance;
[HarmonyPatch(nameof(GameOptionsMenu.Initialize)), HarmonyPrefix]
private static bool InitializePrefix(GameOptionsMenu __instance)
{
@@ -640,6 +641,23 @@ public static class StringOptionPatch
var item = OptionItem.AllOptions[index];
item.SetValue(__instance.GetInt());
if (item.Name == "GameMode") GameOptionsMenuPatch.ReloadUI(ModGameOptionsMenu.TabIndex);
var name = item.GetName();
string name1 = name;
if (Enum.GetValues<CustomRoles>().Find(x => Translator.GetString($"{x}") == name1.RemoveHtmlTags(), out var role))
{
name = name.RemoveHtmlTags();
if (Options.UsePets.GetBool() && role.PetActivatedAbility()) name += Translator.GetString("SupportsPetIndicator");
if (!Options.UsePets.GetBool() && role.OnlySpawnsWithPets()) name += Translator.GetString("RequiresPetIndicator");
__instance.TitleText.fontWeight = FontWeight.Black;
__instance.TitleText.outlineColor = new(255, 255, 255, 255);
__instance.TitleText.outlineWidth = 0.04f;
__instance.LabelBackground.color = Utils.GetRoleColor(role);
__instance.TitleText.color = Color.white;
name = $"<size=3.5>{name}</size>";
}
__instance.TitleText.text = name;
return false;
}
@@ -1007,7 +1025,7 @@ public class GameSettingMenuPatch
HiddenBySearch.Clear();
}
ModGameOptionsMenu.TabIndex = tabNum;
if (!previewOnly || tabNum != 1) ModGameOptionsMenu.TabIndex = tabNum;
GameOptionsMenu settingsTab;
PassiveButton button;
@@ -1030,7 +1048,7 @@ public class GameSettingMenuPatch
}
}
}
if (tabNum < 3) return true;
TabGroup tabGroup = (TabGroup)(tabNum - 3);
+1 -1
View File
@@ -70,7 +70,7 @@ public class GameStartManagerPatch
if (!AmongUsClient.Instance.AmHost) return;
if (ModUpdater.isBroken || (ModUpdater.hasUpdate && ModUpdater.forceUpdate) || !Main.AllowPublicRoom)
if (ModUpdater.IsBroken || (ModUpdater.HasUpdate && ModUpdater.ForceUpdate) || !Main.AllowPublicRoom)
{
// __instance.MakePublicButton.color = Palette.DisabledClear;
// __instance.privatePublicText.color = Palette.DisabledClear;
+19 -18
View File
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Neutral;
@@ -554,23 +553,23 @@ class BeginCrewmatePatch
}
}
if (Input.GetKey(KeyCode.RightShift))
{
__instance.TeamTitle.text = "明天就跑路啦";
__instance.ImpostorText.gameObject.SetActive(true);
__instance.ImpostorText.text = "嘿嘿嘿嘿嘿嘿";
__instance.TeamTitle.color = Color.cyan;
StartFadeIntro(__instance, Color.cyan, Color.yellow);
}
if (Input.GetKey(KeyCode.RightControl))
{
__instance.TeamTitle.text = "警告";
__instance.ImpostorText.gameObject.SetActive(true);
__instance.ImpostorText.text = "请远离无知的玩家";
__instance.TeamTitle.color = Color.magenta;
StartFadeIntro(__instance, Color.magenta, Color.magenta);
}
// if (Input.GetKey(KeyCode.RightShift))
// {
// __instance.TeamTitle.text = "明天就跑路啦";
// __instance.ImpostorText.gameObject.SetActive(true);
// __instance.ImpostorText.text = "嘿嘿嘿嘿嘿嘿";
// __instance.TeamTitle.color = Color.cyan;
// StartFadeIntro(__instance, Color.cyan, Color.yellow);
// }
//
// if (Input.GetKey(KeyCode.RightControl))
// {
// __instance.TeamTitle.text = "警告";
// __instance.ImpostorText.gameObject.SetActive(true);
// __instance.ImpostorText.text = "请远离无知的玩家";
// __instance.TeamTitle.color = Color.magenta;
// StartFadeIntro(__instance, Color.magenta, Color.magenta);
// }
return;
@@ -591,6 +590,7 @@ class BeginCrewmatePatch
return RoleManager.Instance.AllRoles.FirstOrDefault(role => role.Role == roleType)?.IntroSound;
}
/*
private static async void StartFadeIntro(IntroCutscene __instance, Color start, Color end)
{
await Task.Delay(1000);
@@ -610,6 +610,7 @@ class BeginCrewmatePatch
__instance.BackgroundBar.material.color = LerpingColor;
}
}
*/
}
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginImpostor))]
+4 -3
View File
@@ -49,6 +49,7 @@ public static class MainMenuManagerPatch
{
LateTask.New(() => { IsOnline = true; }, 0.1f, "Set Online Status");
}
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPrefix]
public static void Start_Prefix(MainMenuManager __instance)
{
@@ -62,12 +63,12 @@ public static class MainMenuManagerPatch
new(4.2f, -1.3f, 1f),
new(255, 165, 0, byte.MaxValue),
new(255, 200, 0, byte.MaxValue),
() => ModUpdater.StartUpdate(ModUpdater.downloadUrl, true),
() => ModUpdater.StartUpdate(ModUpdater.DownloadUrl, true),
Translator.GetString("updateButton"));
UpdateButton.transform.localScale = Vector3.one;
}
UpdateButton.gameObject.SetActive(ModUpdater.hasUpdate);
UpdateButton.gameObject.SetActive(ModUpdater.HasUpdate);
Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60;
}
@@ -191,4 +192,4 @@ public static class MainMenuManagerPatch
return button;
}
}
}
+1 -1
View File
@@ -1242,7 +1242,7 @@ class FixedUpdatePatch
bool alive = player.IsAlive();
if (AmongUsClient.Instance.AmHost)
{
if (GameStates.IsLobby && ((ModUpdater.hasUpdate && ModUpdater.forceUpdate) || ModUpdater.isBroken || !Main.AllowPublicRoom) && AmongUsClient.Instance.IsGamePublic)
if (GameStates.IsLobby && ((ModUpdater.HasUpdate && ModUpdater.ForceUpdate) || ModUpdater.IsBroken || !Main.AllowPublicRoom) && AmongUsClient.Instance.IsGamePublic)
AmongUsClient.Instance.ChangeGamePublic(false);
// Kick low level people