diff --git a/TownOfPlus/CustomHats.cs b/TownOfPlus/CustomHats.cs index dc5d79b..e8092ed 100644 --- a/TownOfPlus/CustomHats.cs +++ b/TownOfPlus/CustomHats.cs @@ -416,21 +416,4 @@ public static CustomHats.HatExtension getHatExtension(this HatData hat) { return ret; } } - - [HarmonyPatch(typeof(PoolablePlayer), nameof(PoolablePlayer.UpdateFromPlayerOutfit))] - public static class PoolablePlayerPatch - { - public static void Postfix(PoolablePlayer __instance) - { - if (__instance.VisorSlot?.transform == null || __instance.HatSlot?.transform == null) return; - - // fixes a bug in the original where the visor will show up beneath the hat, - // instead of on top where it's supposed to be - __instance.VisorSlot.transform.localPosition = new Vector3( - __instance.VisorSlot.transform.localPosition.x, - __instance.VisorSlot.transform.localPosition.y, - __instance.HatSlot.transform.localPosition.z - 1 - ); - } - } } \ No newline at end of file diff --git a/TownOfPlus/Helpers.cs b/TownOfPlus/Helpers.cs index 04ffa01..128a495 100644 --- a/TownOfPlus/Helpers.cs +++ b/TownOfPlus/Helpers.cs @@ -119,7 +119,14 @@ public static Color GetPlayerColor(PlayerControl p) } public static string GetColorHEX(InnerNet.ClientData Client) { - return ColorToHex(Palette.PlayerColors[Client.ColorId]); + try + { + return ColorToHex(Palette.PlayerColors[Client.ColorId]); + } + catch + { + return ""; + } } public static string ColorToHex(Color32 color) { diff --git a/TownOfPlus/ModSetting/AddLobbySetting.cs b/TownOfPlus/ModSetting/AddLobbySetting.cs new file mode 100644 index 0000000..306405d --- /dev/null +++ b/TownOfPlus/ModSetting/AddLobbySetting.cs @@ -0,0 +1,85 @@ +using BepInEx; +using BepInEx.Configuration; +using BepInEx.IL2CPP; +using System; +using System.Linq; +using HarmonyLib; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using UnhollowerBaseLib; +using Hazel; +using Il2CppSystem.Collections.Generic; +using Il2CppSystem.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace TownOfPlus +{ + [HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.InitializeOptions))] + public static class GameSettingMenuPatch + { + public static void Prefix(GameSettingMenu __instance) + { + if (!main.RoomOption.Value) return; + // オンラインモードで部屋を立て直さなくてもマップを変更できるように変更 + __instance.HideForOnline = new Il2CppReferenceArray(0); + } + } + + [HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Start))] + [HarmonyPriority(Priority.First)] + public static class GameOptionsMenuPatch + { + public static void Postfix(GameOptionsMenu __instance) + { + if (!main.RoomOption.Value) return; + foreach (var ob in __instance.Children) + { + switch (ob.Title) + { + case StringNames.GameShortTasks: + case StringNames.GameLongTasks: + case StringNames.GameCommonTasks: + ob.Cast().ValidRange = new FloatRange(0, 99); + break; + case StringNames.GameKillCooldown: + ob.Cast().ValidRange = new FloatRange(0, 180); + break; + case StringNames.GameRecommendedSettings: + ob.enabled = false; + ob.gameObject.SetActive(false); + break; + default: + break; + } + } + } + } + [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))] + public static class KillCoolDown + { + public static bool flag = false; + public static void Prefix(GameStartManager __instance) + { + if (AmongUsClient.Instance.AmHost) + { + if (main.NokillCool.Value) + { + PlayerControl.GameOptions.KillCooldown = 0.00001f; + flag = true; + Helpers.SyncSettings(); + } + else + { + if (flag) + { + PlayerControl.GameOptions.KillCooldown = 0f; + Helpers.SyncSettings(); + flag = false; + } + } + } + } + } +} diff --git a/TownOfPlus/ModSetting/CPS.cs b/TownOfPlus/ModSetting/CPS.cs new file mode 100644 index 0000000..5694c08 --- /dev/null +++ b/TownOfPlus/ModSetting/CPS.cs @@ -0,0 +1,117 @@ +サソusing BepInEx; +using BepInEx.Configuration; +using BepInEx.IL2CPP; +using System; +using System.Linq; +using HarmonyLib; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using UnhollowerBaseLib; +using Hazel; +using Il2CppSystem.Collections.Generic; +using Il2CppSystem.Linq; +using Il2CppSystem; +using System.Threading; +using System.Threading.Tasks; +using System.Collections; +using System.Text; +using System.Text.RegularExpressions; +using UnityEngine.UI; + +namespace TownOfPlus +{ + [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] + public static class CPS + { + private static SpriteRenderer CPSUnderlay; + private static TMPro.TextMeshPro CPStext; + private static int count = 0; + + public static void Postfix(HudManager __instance) + { + if (!initializeOverlays()) return; + + HudManager hudManager = DestroyableSingleton.Instance; + if (PlayerControl.LocalPlayer == null || hudManager == null) + return; + + Transform parent; + parent = hudManager.transform; + + CPStext.transform.parent = parent; + CPSUnderlay.transform.parent = parent; + CPSUnderlay.color = new Color(0.1f, 0.1f, 0.1f, 0.88f); + CPSUnderlay.transform.localScale = new Vector3(1f, 0.25f, 0.5f); + CPSUnderlay.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f); + + CPStext.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f); + CPStext.text = count.ToString() + " CPS"; + if (main.CPS.Value) + { + if (Input.GetKeyDown(KeyCode.Mouse0)) + { + count += 1; + new Timer(() => + { + count -= 1; + },1f); + } + if (main.SettingCPS) + { + if (Input.GetKey(KeyCode.RightArrow)) + { + main.CPSpositionX.Value += 0.05f; + } + if (Input.GetKey(KeyCode.LeftArrow)) + { + main.CPSpositionX.Value -= 0.05f; + } + if (Input.GetKey(KeyCode.DownArrow)) + { + main.CPSpositionY.Value -= 0.05f; + } + if (Input.GetKey(KeyCode.UpArrow)) + { + main.CPSpositionY.Value += 0.05f; + } + } + CPStext.enabled = true; + CPSUnderlay.enabled = true; + + } + else + { + count = 0; + CPSUnderlay.enabled = false; + CPStext.enabled = false; + } + } + public static bool initializeOverlays() + { + HudManager hudManager = DestroyableSingleton.Instance; + if (hudManager == null) return false; + if (CPSUnderlay == null) + { + CPSUnderlay = UnityEngine.Object.Instantiate(hudManager.FullScreen, hudManager.transform); + CPSUnderlay.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f); + CPSUnderlay.gameObject.SetActive(true); + CPSUnderlay.enabled = false; + } + if (CPStext == null) + { + CPStext = UnityEngine.Object.Instantiate(hudManager.TaskText, hudManager.transform); + CPStext.fontSize = CPStext.fontSizeMin = CPStext.fontSizeMax = 1.15f; + CPStext.autoSizeTextContainer = false; + CPStext.enableWordWrapping = false; + CPStext.alignment = TMPro.TextAlignmentOptions.Center; + CPStext.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f); + CPStext.transform.localScale = Vector3.one * 1.5f; + CPStext.color = Palette.White; + CPStext.enabled = false; + } + return true; + } + } + +} \ No newline at end of file diff --git a/TownOfPlus/ModSetting/ChangeName.cs b/TownOfPlus/ModSetting/ChangeName.cs index dba9545..e487c24 100644 --- a/TownOfPlus/ModSetting/ChangeName.cs +++ b/TownOfPlus/ModSetting/ChangeName.cs @@ -30,6 +30,7 @@ public class ChangeName public static void Postfix(HudManager __instance) { var p = PlayerControl.LocalPlayer; + if (p == null) return; Color color = Helpers.GetPlayerColor(p); if (main.NameOutline.Value) color = Palette.Black; if (main.RainbowName.Value || main.TranslucentName.Value) diff --git a/TownOfPlus/ModSetting/ChangeSkin.cs b/TownOfPlus/ModSetting/ChangeSkin.cs index f9e47b6..434233c 100644 --- a/TownOfPlus/ModSetting/ChangeSkin.cs +++ b/TownOfPlus/ModSetting/ChangeSkin.cs @@ -22,270 +22,20 @@ namespace TownOfPlus { [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] - //繝九ャ繝亥クス public class ChangeSkin { - private static bool Hat_Rainbow = true; - private static int BeanieColorCount = 1; - private static int HoodColorCount = 1; - private static int BaseballColorCount = 1; - private static int PaperhatColorCount = 1; - private static int SlungColorCount = 1; - private static int BandanaColorCount = 1; - private static int DoctorColorCount = 1; - private static int DoragColorCount = 1; - private static int HeadphoneColorCount = 1; - private static int HardhatColorCount = 1; - private static bool Hat_Blink = true; - private static int LightColorCount = 1; - private static int SnowmanColorCount = 1; - private static bool Visor = true; - private static int StickynoteColorCount = 1; - private static int LolliColorCount = 1; - private static int MasqueColorCount = 1; public static void Postfix(HudManager __instance) { + if (PlayerControl.LocalPlayer == null) return; if (main.RainbowHat.Value) { - if (Hat_Rainbow) - { - Hat_Rainbow = false; - new Timer(() => - { - Hat_Rainbow = true; - System.Collections.Generic.List Beanie = new System.Collections.Generic.List(); - Beanie.Add("hat_Beanie_Black"); - Beanie.Add("hat_Beanie_Blue"); - Beanie.Add("hat_Beanie_Green"); - Beanie.Add("hat_Beanie_Lightblue"); - Beanie.Add("hat_Beanie_LightGreen"); - Beanie.Add("hat_Beanie_LightPurple"); - Beanie.Add("hat_Beanie_Pink"); - Beanie.Add("hat_Beanie_Purple"); - Beanie.Add("hat_Beanie_White"); - Beanie.Add("hat_Beanie_Yellow"); - Beanie.Add("hat_pk04_Beanie"); - BeanieColorCount = SkinCount(Beanie, BeanieColorCount, true); - RawSetSkin(Beanie, BeanieColorCount, false); - - System.Collections.Generic.List Hood = new System.Collections.Generic.List(); - Hood.Add("hat_pk02_HeroCap"); - Hood.Add("hat_Herohood_Black"); - Hood.Add("hat_Herohood_Blue"); - Hood.Add("hat_Herohood_Pink"); - Hood.Add("hat_Herohood_Purple"); - Hood.Add("hat_Herohood_Red"); - Hood.Add("hat_Herohood_White"); - Hood.Add("hat_Herohood_Yellow"); - HoodColorCount = SkinCount(Hood, HoodColorCount, false); - RawSetSkin(Hood, HoodColorCount, false); - - System.Collections.Generic.List Baseball = new System.Collections.Generic.List(); - Baseball.Add("hat_pk01_BaseballCap"); - Baseball.Add("hat_baseball_Black"); - Baseball.Add("hat_baseball_Green"); - Baseball.Add("hat_baseball_Lightblue"); - Baseball.Add("hat_baseball_LightGreen"); - Baseball.Add("hat_baseball_Lilac"); - Baseball.Add("hat_baseball_Orange"); - Baseball.Add("hat_baseball_Pink"); - Baseball.Add("hat_baseball_Purple"); - Baseball.Add("hat_baseball_Red"); - Baseball.Add("hat_baseball_White"); - Baseball.Add("hat_baseball_Yellow"); - BaseballColorCount = SkinCount(Baseball, BaseballColorCount, false); - RawSetSkin(Baseball, BaseballColorCount, false); - - System.Collections.Generic.List Paperhat = new System.Collections.Generic.List(); - Paperhat.Add("hat_paperhat"); - Paperhat.Add("hat_Paperhat_Black"); - Paperhat.Add("hat_Paperhat_Blue"); - Paperhat.Add("hat_Paperhat_Cyan"); - Paperhat.Add("hat_Paperhat_Lightblue"); - Paperhat.Add("hat_Paperhat_Pink"); - Paperhat.Add("hat_Paperhat_Yellow"); - PaperhatColorCount = SkinCount(Paperhat, PaperhatColorCount, false); - RawSetSkin(Paperhat, PaperhatColorCount, false); - - System.Collections.Generic.List Slung = new System.Collections.Generic.List(); - Slung.Add("hat_brainslug"); - Slung.Add("hat_headslug_Purple"); - Slung.Add("hat_headslug_Red"); - Slung.Add("hat_headslug_White"); - Slung.Add("hat_headslug_Yellow"); - SlungColorCount = SkinCount(Slung, SlungColorCount, false); - RawSetSkin(Slung, SlungColorCount, false); - - System.Collections.Generic.List Bandana = new System.Collections.Generic.List(); - Bandana.Add("hat_pk04_Bandana"); - Bandana.Add("hat_Bandana_Blue"); - Bandana.Add("hat_Bandana_Green"); - Bandana.Add("hat_Bandana_Pink"); - Bandana.Add("hat_Bandana_Red"); - Bandana.Add("hat_Bandana_White"); - Bandana.Add("hat_Bandana_Yellow"); - BandanaColorCount = SkinCount(Bandana, BandanaColorCount, false); - RawSetSkin(Bandana, BandanaColorCount, false); - - System.Collections.Generic.List Doctor = new System.Collections.Generic.List(); - Doctor.Add("hat_stethescope"); - Doctor.Add("hat_Doc_black"); - Doctor.Add("hat_Doc_Orange"); - Doctor.Add("hat_Doc_Purple"); - Doctor.Add("hat_Doc_Red"); - Doctor.Add("hat_Doc_White"); - DoctorColorCount = SkinCount(Doctor, DoctorColorCount, false); - RawSetSkin(Doctor, DoctorColorCount, false); - - System.Collections.Generic.List Dorag = new System.Collections.Generic.List(); - Dorag.Add("hat_pk04_Dorag"); - Dorag.Add("hat_Dorag_Black"); - Dorag.Add("hat_Dorag_Desert"); - Dorag.Add("hat_Dorag_Jungle"); - Dorag.Add("hat_Dorag_Purple"); - Dorag.Add("hat_Dorag_Sky"); - Dorag.Add("hat_Dorag_Snow"); - Dorag.Add("hat_Dorag_Yellow"); - DoragColorCount = SkinCount(Dorag, DoragColorCount, false); - RawSetSkin(Dorag, DoragColorCount, false); - - System.Collections.Generic.List Headphone = new System.Collections.Generic.List(); - Headphone.Add("hat_pk03_Headphones"); - Headphone.Add("hat_GovtHeadset"); - Headphone.Add("hat_mira_headset_blue"); - Headphone.Add("hat_mira_headset_pink"); - Headphone.Add("hat_mira_headset_yellow"); - HeadphoneColorCount = SkinCount(Headphone, HeadphoneColorCount, false); - RawSetSkin(Headphone, HeadphoneColorCount, false); - - System.Collections.Generic.List Hardhat = new System.Collections.Generic.List(); - Hardhat.Add("hat_hardhat"); - Hardhat.Add("hat_Hardhat_black"); - Hardhat.Add("hat_Hardhat_Blue"); - Hardhat.Add("hat_Hardhat_Green"); - Hardhat.Add("hat_Hardhat_Orange"); - Hardhat.Add("hat_Hardhat_Pink"); - Hardhat.Add("hat_Hardhat_Purple"); - Hardhat.Add("hat_Hardhat_Red"); - Hardhat.Add("hat_Hardhat_White"); - HardhatColorCount = SkinCount(Hardhat, HardhatColorCount, false); - RawSetSkin(Hardhat, HardhatColorCount, false); - }, 0.25f); - } - if (Hat_Blink) - { - Hat_Blink = false; - new Timer(() => - { - Hat_Blink = true; - System.Collections.Generic.List Light = new System.Collections.Generic.List(); - Light.Add("hat_pk06_Lights"); - Light.Add("hat_w21_lights_white"); - LightColorCount = SkinCount(Light, LightColorCount, false); - RawSetSkin(Light, LightColorCount, false); - - System.Collections.Generic.List Snowman = new System.Collections.Generic.List(); - Snowman.Add("hat_w21_snowman_greenred"); - Snowman.Add("hat_w21_snowman_redgreen"); - Snowman.Add("hat_pk06_Snowman"); - - SnowmanColorCount = SkinCount(Snowman, SnowmanColorCount, true); - RawSetSkin(Snowman, SnowmanColorCount, false); - }, 0.5f); - } - + PlayerControl.LocalPlayer.HatRenderer.color = Color.HSVToRGB(Time.time % 1, 1, 1); } if (main.RainbowVisor.Value) { - if (Visor) - { - Visor = false; - new Timer(() => - { - Visor = true; - System.Collections.Generic.List Stickynote = new System.Collections.Generic.List(); - Stickynote.Add("visor_pk01_DumStickerVisor"); - Stickynote.Add("visor_Stickynote_Cyan"); - Stickynote.Add("visor_Stickynote_Green"); - Stickynote.Add("visor_Stickynote_Orange"); - Stickynote.Add("visor_Stickynote_Pink"); - Stickynote.Add("visor_Stickynote_Purple"); - StickynoteColorCount = SkinCount(Stickynote, StickynoteColorCount, false); - RawSetSkin(Stickynote, StickynoteColorCount, true); - - System.Collections.Generic.List Lolli = new System.Collections.Generic.List(); - Lolli.Add("visor_LolliBlue"); - Lolli.Add("visor_LolliBrown"); - Lolli.Add("visor_LolliOrange"); - Lolli.Add("visor_LolliRed"); - LolliColorCount = SkinCount(Lolli, LolliColorCount, false); - RawSetSkin(Lolli, LolliColorCount, true); - - System.Collections.Generic.List Masque = new System.Collections.Generic.List(); - Masque.Add("visor_masque_blue"); - Masque.Add("visor_masque_green"); - Masque.Add("visor_masque_red"); - Masque.Add("visor_masque_white"); - MasqueColorCount = SkinCount(Masque, MasqueColorCount, false); - RawSetSkin(Masque, MasqueColorCount, true); - }, 0.25f); - } - } - } - public static int SkinCount(System.Collections.Generic.List List, int ColorCount, bool flag) - { - var Count = ColorCount; - var ListCount = 1; - if (flag) ListCount = 2; - if (ColorCount == List.Count - ListCount) Count = 0; - else Count += 1; - return Count; - } - public static void RawSetSkin(System.Collections.Generic.List SkinList, int ColorCount, bool visor) - { - var p = PlayerControl.LocalPlayer; - if (visor) - { - if (SkinList.Contains(p.CurrentOutfit.VisorId)) - { - p.RawSetVisor(SkinList[ColorCount]); - } - } - else - { - if (SkinList.Contains(p.CurrentOutfit.HatId)) - { - p.RawSetHat(SkinList[ColorCount], p.CurrentOutfit.ColorId); - } + PlayerControl.LocalPlayer.VisorSlot.color = Color.HSVToRGB(Time.time % 1, 1, 1); } } } - //[HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))] - //public class ShowSkinName - //{ - // public static string Text = ""; - // public static void Postfix(ChatController __instance) - // { - // if (!(PlayerControl.LocalPlayer.CurrentOutfit.HatId == Text)) - // { - // __instance.AddChat(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer.CurrentOutfit.HatId); - // Text = PlayerControl.LocalPlayer.CurrentOutfit.HatId; - // } - // } - //} - - //[HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))] - //public class ShowVisorName - //{ - // public static string Text = ""; - // public static void Postfix(ChatController __instance) - // { - // if (!(PlayerControl.LocalPlayer.CurrentOutfit.VisorId == Text)) - // { - // __instance.AddChat(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer.CurrentOutfit.VisorId); - // Text = PlayerControl.LocalPlayer.CurrentOutfit.VisorId; - // } - // } - //} } \ No newline at end of file diff --git a/TownOfPlus/ModSetting/DateTimeSetting.cs b/TownOfPlus/ModSetting/DateTimeSetting.cs new file mode 100644 index 0000000..2f0a82f --- /dev/null +++ b/TownOfPlus/ModSetting/DateTimeSetting.cs @@ -0,0 +1,106 @@ +サソusing BepInEx; +using BepInEx.Configuration; +using BepInEx.IL2CPP; +using System; +using System.Linq; +using HarmonyLib; +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using UnhollowerBaseLib; +using Hazel; +using Il2CppSystem.Collections.Generic; +using Il2CppSystem.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Collections; +using System.Text; +using System.Text.RegularExpressions; +using UnityEngine.UI; + +namespace TownOfPlus +{ + [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] + public static class DateTimeSetting + { + private static SpriteRenderer DateTimeUnderlay; + private static TMPro.TextMeshPro DateTimetext; + + public static void Postfix(HudManager __instance) + { + if (!initializeOverlays()) return; + + HudManager hudManager = DestroyableSingleton.Instance; + if (PlayerControl.LocalPlayer == null || hudManager == null) + return; + + Transform parent; + parent = hudManager.transform; + + DateTimetext.transform.parent = parent; + DateTimeUnderlay.transform.parent = parent; + DateTimeUnderlay.color = new Color(0.1f, 0.1f, 0.1f, 0.88f); + DateTimeUnderlay.transform.localScale = new Vector3(2f, 0.25f, 0.5f); + DateTimeUnderlay.transform.localPosition = new Vector3(main.DateTimepositionX.Value, main.DateTimepositionY.Value, -900f); + + DateTimetext.transform.localPosition = new Vector3(main.DateTimepositionX.Value, main.DateTimepositionY.Value, -900f); + DateTimetext.text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); + if (main.DateTimeSetting.Value) + { + if (main.SettingDateTime) + { + if (Input.GetKey(KeyCode.RightArrow)) + { + main.DateTimepositionX.Value += 0.05f; + } + if (Input.GetKey(KeyCode.LeftArrow)) + { + main.DateTimepositionX.Value -= 0.05f; + } + if (Input.GetKey(KeyCode.DownArrow)) + { + main.DateTimepositionY.Value -= 0.05f; + } + if (Input.GetKey(KeyCode.UpArrow)) + { + main.DateTimepositionY.Value += 0.05f; + } + } + DateTimetext.enabled = true; + DateTimeUnderlay.enabled = true; + + } + else + { + DateTimeUnderlay.enabled = false; + DateTimetext.enabled = false; + } + } + public static bool initializeOverlays() + { + HudManager hudManager = DestroyableSingleton.Instance; + if (hudManager == null) return false; + if (DateTimeUnderlay == null) + { + DateTimeUnderlay = UnityEngine.Object.Instantiate(hudManager.FullScreen, hudManager.transform); + DateTimeUnderlay.transform.localPosition = new Vector3(main.DateTimepositionX.Value, main.DateTimepositionY.Value, -900f); + DateTimeUnderlay.gameObject.SetActive(true); + DateTimeUnderlay.enabled = false; + } + if (DateTimetext == null) + { + DateTimetext = UnityEngine.Object.Instantiate(hudManager.TaskText, hudManager.transform); + DateTimetext.fontSize = DateTimetext.fontSizeMin = DateTimetext.fontSizeMax = 1.15f; + DateTimetext.autoSizeTextContainer = false; + DateTimetext.enableWordWrapping = false; + DateTimetext.alignment = TMPro.TextAlignmentOptions.Center; + DateTimetext.transform.localPosition = new Vector3(main.DateTimepositionX.Value, main.DateTimepositionY.Value, -900f); + DateTimetext.transform.localScale = Vector3.one * 1.5f; + DateTimetext.color = Palette.White; + DateTimetext.enabled = false; + } + return true; + } + } + +} \ No newline at end of file diff --git a/TownOfPlus/ModSetting/ModSetting.cs b/TownOfPlus/ModSetting/ModSetting.cs index 73126de..fa7359d 100644 --- a/TownOfPlus/ModSetting/ModSetting.cs +++ b/TownOfPlus/ModSetting/ModSetting.cs @@ -39,6 +39,7 @@ public static class ModOptionSetting new SelectionBehaviour("驛ィ螻玖ィュ螳壹ョ諡。蠑オ", () => main.RoomOption.Value = !main.RoomOption.Value, main.RoomOption.Value), new SelectionBehaviour("0.00001遘偵ョ繧ュ繝ォ繧ッ繝シ繝ォ", () => main.NokillCool.Value = !main.NokillCool.Value, main.NokillCool.Value), new SelectionBehaviour("CPS", () => main.CPS.Value = !main.CPS.Value, main.CPS.Value), + new SelectionBehaviour("DateTime", () => main.DateTimeSetting.Value = !main.DateTimeSetting.Value, main.DateTimeSetting.Value), }; diff --git a/TownOfPlus/ModSetting/Outline.cs b/TownOfPlus/ModSetting/Outline.cs index d4a134c..df74573 100644 --- a/TownOfPlus/ModSetting/Outline.cs +++ b/TownOfPlus/ModSetting/Outline.cs @@ -29,6 +29,7 @@ public static void Prefix() //繧ュ繝ォ蟇セ雎。 if (main.RainbowOutline.Value) { + if (PlayerControl.LocalPlayer == null) return; foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p != PlayerControl.LocalPlayer) p.MyRend.material.SetColor("_OutlineColor", Color.HSVToRGB(Time.time % 1, 1, 1)); @@ -36,6 +37,7 @@ public static void Prefix() } if (main.CrewColorOutline.Value) { + if (PlayerControl.LocalPlayer == null) return; foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p != PlayerControl.LocalPlayer) p.MyRend.material.SetColor("_OutlineColor", p.MyRend.material.GetColor("_BodyColor")); diff --git a/TownOfPlus/ModSetting/SendJoinPlayer.cs b/TownOfPlus/ModSetting/SendJoinPlayer.cs index 0c58b44..3cac626 100644 --- a/TownOfPlus/ModSetting/SendJoinPlayer.cs +++ b/TownOfPlus/ModSetting/SendJoinPlayer.cs @@ -23,6 +23,7 @@ public static class SendChat public static float count = 3.5f; public static void Prefix() { + if (PlayerControl.LocalPlayer == null) return; if (main.SendJoinPlayer.Value && AmongUsClient.Instance.AmHost) { foreach (PlayerControl player in PlayerControl.AllPlayerControls) diff --git a/TownOfPlus/ModSetting/Zoom.cs b/TownOfPlus/ModSetting/Zoom.cs index eede13d..9fc01ed 100644 --- a/TownOfPlus/ModSetting/Zoom.cs +++ b/TownOfPlus/ModSetting/Zoom.cs @@ -113,7 +113,7 @@ public static void Zoom() Camera.main.orthographicSize = 3.0f; HudManager.Instance.UICamera.orthographicSize = 3.0f; HudManager.Instance.transform.localScale = Vector3.one; - MeetingHud.Instance.transform.localScale = Vector3.one; + if (MeetingHud.Instance != null) MeetingHud.Instance.transform.localScale = Vector3.one; HudManager.Instance.Chat.transform.localScale = Vector3.one; } } diff --git a/TownOfPlus/Patches/ChatPlus.cs b/TownOfPlus/Patches/ChatPlus.cs index f24ad96..0a5a6dc 100644 --- a/TownOfPlus/Patches/ChatPlus.cs +++ b/TownOfPlus/Patches/ChatPlus.cs @@ -230,6 +230,10 @@ public static void Prefix(ChatController __instance) { CommandList.Add(("/CPS", "")); } + if (main.DateTimeSetting.Value) + { + CommandList.Add(("/DataTime", "")); + } if (CommandList == null) return; var ChatText = __instance.TextArea.text; if (Input.GetKeyDown(KeyCode.Tab) && ChatText.Substring(0, 1) == "/") @@ -377,6 +381,10 @@ public static bool Addchat(ChatController __instance) { AddChat += ("\n/CPS : CPS縺ョ菴咲スョ繧貞、画峩縺ァ縺阪∪縺吶"); } + if (main.DateTimeSetting.Value) + { + AddChat += ("\n/DataTime : DataTime縺ョ菴咲スョ繧貞、画峩縺ァ縺阪∪縺吶"); + } if (AddChat == "===繧ウ繝槭Φ繝我ク隕ァ===") AddChat += ("\n螳溯。悟庄閭ス縺ェ繧ウ繝槭Φ繝峨ッ縺ゅj縺セ縺帙s"); break; @@ -675,7 +683,7 @@ public static bool Addchat(ChatController __instance) OPkick = Math.Clamp(OPkick, 1, 10); if (main.SetOPkick.Value.Contains($"{OPkick},")) { - main.SetOPkick.Value = main.SetOPkick.Value.Replace($"{OPkick},",""); + main.SetOPkick.Value = main.SetOPkick.Value.Replace($"{OPkick},", ""); } else { @@ -730,6 +738,28 @@ public static bool Addchat(ChatController __instance) } break; + case "/dt": + case "/datatime": + if (!main.DateTimeSetting.Value) break; + if (Command1 == "reset") + { + main.DateTimepositionX.Value = 0f; + main.DateTimepositionY.Value = 2.75f; + AddChat = "DateTime縺ョ菴咲スョ繧偵Μ繧サ繝繝医@縺セ縺励◆"; + break; + } + if (main.SettingDateTime) + { + main.SettingDateTime = false; + AddChat = "DateTime縺ョ菴咲スョ險ュ螳壹r辟。蜉ケ蛹悶@縺セ縺励◆"; + } + else + { + main.SettingDateTime = true; + AddChat = "DateTime縺ョ菴咲スョ險ュ螳壹r譛牙柑蛹悶@縺セ縺励◆\n蜊∝ュ励く繝シ縺ァ蜍輔°縺励※縺上□縺輔>\n菴咲スョ繝ェ繧サ繝繝医ッ[/DateTime Reset]縺ァ縺吶"; + } + break; + default: break; } diff --git a/TownOfPlus/Patches/CustomOverlays.cs b/TownOfPlus/Patches/CustomOverlays.cs index 9e8baa8..114e31b 100644 --- a/TownOfPlus/Patches/CustomOverlays.cs +++ b/TownOfPlus/Patches/CustomOverlays.cs @@ -271,7 +271,9 @@ public static void Postfix(HudManager __instance) var FriendCode = player.Data.FriendCode; if (FriendCode != "") FriendCodeText = $"\nFriendCode : {FriendCode}"; } - PlayerText += $"\n笆{TOP}{(Client.Id == AmongUsClient.Instance.ClientId ? SaveManager.PlayerName : Client.PlayerName.Replace("\n", ""))} : {Platform.Replace("Standalone", "")}{FriendCodeText}"; + var HEXcolor = Helpers.GetColorHEX(Client); + if (HEXcolor == "") HEXcolor = "FF000000"; + PlayerText += $"\n笆{TOP}{(Client.Id == AmongUsClient.Instance.ClientId ? SaveManager.PlayerName : Client.PlayerName.Replace("\n", ""))} : {Platform.Replace("Standalone", "")}{FriendCodeText}"; } infoOverlayPlayer.text = PlayerText; @@ -285,6 +287,7 @@ public class PlayerVersion public PlayerVersion(Version version, Guid guid) { this.version = version; + this.guid = guid; } public bool GuidMatches() diff --git a/TownOfPlus/Patches/EndGame.cs b/TownOfPlus/Patches/EndGame.cs index ab55ea5..82b97ff 100644 --- a/TownOfPlus/Patches/EndGame.cs +++ b/TownOfPlus/Patches/EndGame.cs @@ -26,6 +26,7 @@ public static class EndGame { public static void Postfix(KeyboardJoystick __instance) { + if (ShipStatus.Instance == null) return; if (Input.GetKeyDown(KeyCode.Return) && Input.GetKey(KeyCode.L) && Input.GetKey(KeyCode.LeftShift) && AmongUsClient.Instance.AmHost) { ShipStatus.Instance.enabled = false; diff --git a/TownOfPlus/Patches/FixDisconnect.cs b/TownOfPlus/Patches/FixDisconnect.cs index d610529..868029f 100644 --- a/TownOfPlus/Patches/FixDisconnect.cs +++ b/TownOfPlus/Patches/FixDisconnect.cs @@ -30,9 +30,10 @@ static void Postfix(MeetingHud __instance) { if (pva == null) continue; PlayerControl player = Helpers.playerById(pva.TargetPlayerId); - if(player == null || player.Data == null || player.Data.IsDead || player.Data.Disconnected) + if(player == null || player.Data == null || player.Data.Disconnected) { - pva.Overlay.gameObject?.SetActive(true); + pva.Overlay.gameObject.SetActive(true); + if (player.Data.IsDead) pva.XMark.gameObject.SetActive(true); } } } diff --git a/TownOfPlus/Patches/JoinButton.cs b/TownOfPlus/Patches/JoinButton.cs index aa4061f..81afabc 100644 --- a/TownOfPlus/Patches/JoinButton.cs +++ b/TownOfPlus/Patches/JoinButton.cs @@ -17,18 +17,22 @@ class JoinButton { public static void Prefix(JoinGameButton __instance) { - var text = __instance.GameIdText.text; - if (Regex.IsMatch(GUIUtility.systemCopyBuffer, @"[A-Z]{6}")) + try { - if (text == "") __instance.GameIdText.SetText(GUIUtility.systemCopyBuffer); - } - if (__instance.GameIdText.text.Length == 5) - { - StringNames n = DestroyableSingleton.Instance.CurrentRegion.TranslateName; - if (n == StringNames.ServerNA) __instance.GameIdText.SetText(text + "G"); - if (n == StringNames.ServerEU) __instance.GameIdText.SetText(text + "F"); - if (n == StringNames.ServerAS) __instance.GameIdText.SetText(text + "F"); + var text = __instance.GameIdText.text; + if (Regex.IsMatch(GUIUtility.systemCopyBuffer, @"[A-Z]{6}")) + { + if (text == "") __instance.GameIdText.SetText(GUIUtility.systemCopyBuffer); + } + if (__instance.GameIdText.text.Length == 5) + { + StringNames n = DestroyableSingleton.Instance.CurrentRegion.TranslateName; + if (n == StringNames.ServerNA) __instance.GameIdText.SetText(text + "G"); + if (n == StringNames.ServerEU) __instance.GameIdText.SetText(text + "F"); + if (n == StringNames.ServerAS) __instance.GameIdText.SetText(text + "F"); + } } + catch { } } } } \ No newline at end of file diff --git a/TownOfPlus/Patches/KeyCommand.cs b/TownOfPlus/Patches/KeyCommand.cs index 638ff4e..ab7e42c 100644 --- a/TownOfPlus/Patches/KeyCommand.cs +++ b/TownOfPlus/Patches/KeyCommand.cs @@ -21,7 +21,7 @@ namespace TownOfPlus [HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))] public static class KeyCommand { - private static readonly System.Random random = new System.Random((int)DateTime.Now.Ticks); + private static readonly System.Random random = new System.Random((int)System.DateTime.Now.Ticks); private static List bots = new List(); public static void Postfix(ChatController __instance) { @@ -34,6 +34,18 @@ public static void Postfix(ChatController __instance) __instance.SetVisible(true); }, 0f); } + //繝√Ε繝繝医ヰ繧ー + if (__instance.IsOpen) + { + if (__instance.animating) + { + __instance.BanButton.SetVisible(false); + } + else + { + __instance.BanButton.SetVisible(true); + } + } } //[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.CheckEndCriteria))] //class CheckGameEndPatch diff --git a/TownOfPlus/Patches/StartButton.cs b/TownOfPlus/Patches/StartButton.cs index 7f27213..0e30587 100644 --- a/TownOfPlus/Patches/StartButton.cs +++ b/TownOfPlus/Patches/StartButton.cs @@ -29,10 +29,10 @@ public static void Prefix(GameStartManager __instance) __instance.MinPlayers = 1; } } - [HarmonyPatch(typeof(KeyboardJoystick), nameof(KeyboardJoystick.Update))] + [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))] public static class LobbyCountDownTimer { - public static void Postfix(KeyboardJoystick __instance) + public static void Postfix(GameStartManager __instance) { if (Input.GetKeyDown(KeyCode.LeftShift) && GameStartManager._instance && AmongUsClient.Instance.AmHost) { diff --git a/TownOfPlus/Patches/WallWalk.cs b/TownOfPlus/Patches/WallWalk.cs index c530138..d08a39b 100644 --- a/TownOfPlus/Patches/WallWalk.cs +++ b/TownOfPlus/Patches/WallWalk.cs @@ -26,6 +26,7 @@ public static class WallWalk { public static void Postfix(KeyboardJoystick __instance) { + if (PlayerControl.LocalPlayer == null) return; //螢∵栢縺 if (Input.GetKeyDown(KeyCode.LeftControl)) { diff --git a/TownOfPlus/main.cs b/TownOfPlus/main.cs index 7c88445..dd88782 100644 --- a/TownOfPlus/main.cs +++ b/TownOfPlus/main.cs @@ -26,7 +26,7 @@ public class main : BasePlugin //Mod縺ョ隧ウ邏ー public const string Id = "com.tugaru.TownOfPlus"; public const string Name = "TownOfPlus"; - public const string Version = "1.6.0"; + public const string Version = "1.6.1"; public static System.Version VersionId = System.Version.Parse(Version); public Harmony Harmony { get; } = new Harmony(Id); @@ -66,7 +66,7 @@ public class main : BasePlugin public static ConfigEntry CPS { get; private set; } public static ConfigEntry RoomOption { get; private set; } public static ConfigEntry NokillCool { get; private set; } - + public static ConfigEntry DateTimeSetting { get; private set; } //Mod隧ウ邏ー險ュ螳 //繝ゥ繝ウ繝繝繝槭ャ繝 @@ -100,8 +100,15 @@ public class main : BasePlugin //CPS public static ConfigEntry CPSpositionX { get; private set; } public static ConfigEntry CPSpositionY { get; private set; } + public static bool SettingCPS = false; + //DateTime + public static ConfigEntry DateTimepositionX { get; private set; } + public static ConfigEntry DateTimepositionY { get; private set; } + + public static bool SettingDateTime = false; + public static string NewHatURL = ""; @@ -145,6 +152,7 @@ public override void Load() CPS = Config.Bind("Client Options", "CPS", false); RoomOption = Config.Bind("Client Options", "RoomOption", true); NokillCool = Config.Bind("Client Options", "NokillCool", false); + DateTimeSetting = Config.Bind("Client Options", "DateTimeSetting", false); //繝ゥ繝ウ繝繝繝槭ャ繝 @@ -179,6 +187,10 @@ public override void Load() CPSpositionX = Config.Bind("CPS Options", "CPSpositionX", 0f); CPSpositionY = Config.Bind("CPS Options", "CPSpositionY", 2.75f); + //DateTime + DateTimepositionX = Config.Bind("DateTime Options", "DateTimepositionX", 0f); + DateTimepositionY = Config.Bind("DateTime Options", "DateTimepositionY", 2.75f); + Harmony.PatchAll(); } }