From 7d06724dbad4ef145128adfe5d356f910808ced9 Mon Sep 17 00:00:00 2001 From: Eno9991 Date: Wed, 25 Oct 2023 03:58:21 +0200 Subject: [PATCH] Latest Among Us version support + portal & bomb null reference fix + portal open field location display fix --- BetterOtherRoles/BetterOtherRoles.csproj | 6 +- BetterOtherRoles/Buttons.cs | 16 +- BetterOtherRoles/Main.cs | 2 +- BetterOtherRoles/Modules/BepInExUpdater.cs | 4 +- BetterOtherRoles/Modules/ModUpdater.cs | 318 ------------------ BetterOtherRoles/Objects/Bomb.cs | 50 +-- BetterOtherRoles/Objects/Portal.cs | 7 +- .../Patches/PlayerControlPatch.cs | 6 +- .../Patches/ReactorSystemTypePatches.cs | 8 +- BetterOtherRoles/Patches/ShipStatusPatch.cs | 2 +- BetterOtherRoles/RPC.cs | 6 +- BetterOtherRoles/SubmergedCompatibility.cs | 2 +- BetterOtherRoles/packages.lock.json | 52 +-- 13 files changed, 85 insertions(+), 394 deletions(-) delete mode 100644 BetterOtherRoles/Modules/ModUpdater.cs diff --git a/BetterOtherRoles/BetterOtherRoles.csproj b/BetterOtherRoles/BetterOtherRoles.csproj index 176d18d..e7ac464 100644 --- a/BetterOtherRoles/BetterOtherRoles.csproj +++ b/BetterOtherRoles/BetterOtherRoles.csproj @@ -1,7 +1,7 @@  net6.0 - 1.4.8 + 1.5.0 BetterOtherRoles EnoPM latest @@ -15,8 +15,8 @@ - - + + diff --git a/BetterOtherRoles/Buttons.cs b/BetterOtherRoles/Buttons.cs index e82578a..b49b24a 100644 --- a/BetterOtherRoles/Buttons.cs +++ b/BetterOtherRoles/Buttons.cs @@ -312,18 +312,18 @@ public static void createButtonsPostfix(HudManager __instance) { AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.engineerFixLights(); } else if (task.TaskType == TaskTypes.RestoreOxy) { - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.LifeSupp, 0 | 64); - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.LifeSupp, 1 | 64); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.LifeSupp, 0 | 64); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.LifeSupp, 1 | 64); } else if (task.TaskType == TaskTypes.ResetReactor) { - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Reactor, 16); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.Reactor, 16); } else if (task.TaskType == TaskTypes.ResetSeismic) { - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Laboratory, 16); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.Laboratory, 16); } else if (task.TaskType == TaskTypes.FixComms) { - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Comms, 16 | 0); - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Comms, 16 | 1); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.Comms, 16 | 0); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.Comms, 16 | 1); } else if (task.TaskType == TaskTypes.StopCharles) { - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Reactor, 0 | 16); - MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Reactor, 1 | 16); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.Reactor, 0 | 16); + MapUtilities.CachedShipStatus.RpcUpdateSystem(SystemTypes.Reactor, 1 | 16); } else if (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.EngineerFixSubmergedOxygen, Hazel.SendOption.Reliable, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/BetterOtherRoles/Main.cs b/BetterOtherRoles/Main.cs index d3b2887..85133f5 100644 --- a/BetterOtherRoles/Main.cs +++ b/BetterOtherRoles/Main.cs @@ -31,7 +31,7 @@ public class BetterOtherRolesPlugin : BasePlugin { public const string Name = "Better Other Roles"; public const string Id = "betterohterroles.eno.pm"; - public const string VersionString = "1.4.8"; + public const string VersionString = "1.5.0"; public static Version Version = Version.Parse(VersionString); internal static BepInEx.Logging.ManualLogSource Logger; diff --git a/BetterOtherRoles/Modules/BepInExUpdater.cs b/BetterOtherRoles/Modules/BepInExUpdater.cs index 893261b..b274f54 100644 --- a/BetterOtherRoles/Modules/BepInExUpdater.cs +++ b/BetterOtherRoles/Modules/BepInExUpdater.cs @@ -19,8 +19,8 @@ namespace BetterOtherRoles.Modules; public class BepInExUpdater : MonoBehaviour { - public const string RequiredBepInExVersion = "6.0.0-be.672+472e950179f4a5ab2e4a89f26dba793795fb6811"; - public const string BepInExDownloadURL = "https://builds.bepinex.dev/projects/bepinex_be/670/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.670%2B42a6727.zip"; + public const string RequiredBepInExVersion = "6.0.0-be.674+82077ec7c91c97f0e5f8ada5d178fd7ece6c0099"; + public const string BepInExDownloadURL = "https://builds.bepinex.dev/projects/bepinex_be/674/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.674%2B82077ec.zip"; public static bool UpdateRequired => Paths.BepInExVersion.ToString() != RequiredBepInExVersion; public void Awake() diff --git a/BetterOtherRoles/Modules/ModUpdater.cs b/BetterOtherRoles/Modules/ModUpdater.cs deleted file mode 100644 index c9bd429..0000000 --- a/BetterOtherRoles/Modules/ModUpdater.cs +++ /dev/null @@ -1,318 +0,0 @@ -using System; -using System.Collections; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Reflection; -using System.Threading.Tasks; -using AmongUs.Data; -using Assets.InnerNet; -using BepInEx; -using BepInEx.Bootstrap; -using BepInEx.Unity.IL2CPP; -using BepInEx.Unity.IL2CPP.Utils; -using Mono.Cecil; -using Newtonsoft.Json.Linq; -using TMPro; -using Twitch; -using UnityEngine; -using UnityEngine.SceneManagement; -using UnityEngine.UI; -using Action = System.Action; -using IntPtr = System.IntPtr; -using Version = SemanticVersioning.Version; - -namespace BetterOtherRoles.Modules -{ - public class ModUpdateBehaviour : MonoBehaviour - { - public static readonly bool CheckForSubmergedUpdates = true; - public static bool showPopUp = true; - public static bool updateInProgress = false; - - public static ModUpdateBehaviour Instance { get; private set; } - public ModUpdateBehaviour(IntPtr ptr) : base(ptr) { } - public class UpdateData - { - public string Content; - public string Tag; - public string TimeString; - public JObject Request; - public Version Version => Version.Parse(Tag); - - public UpdateData(JObject data) - { - Tag = data["tag_name"]?.ToString().TrimStart('v'); - Content = data["body"]?.ToString(); - TimeString = DateTime.FromBinary(((Il2CppSystem.DateTime)data["published_at"]).ToBinaryRaw()).ToString(); - Request = data; - } - - public bool IsNewer(Version version) - { - if (!Version.TryParse(Tag, out var myVersion)) return false; - return myVersion.BaseVersion() > version.BaseVersion(); - } - } - - public UpdateData TORUpdate; - public UpdateData SubmergedUpdate; - - [HideFromIl2Cpp] - public UpdateData RequiredUpdateData => TORUpdate ?? SubmergedUpdate; - - public void Awake() - { - if (Instance) Destroy(this); - Instance = this; - - SceneManager.add_sceneLoaded((System.Action) (OnSceneLoaded)); - this.StartCoroutine(CoCheckUpdates()); - - foreach (var file in Directory.GetFiles(Paths.PluginPath, "*.old")) - { - File.Delete(file); - } - } - - private void OnSceneLoaded(Scene scene, LoadSceneMode mode) - { - if (updateInProgress || scene.name != "MainMenu") return; - if (RequiredUpdateData is null) { - showPopUp = false; - return; - } - - var template = GameObject.Find("ExitGameButton"); - if (!template) return; - - var button = Instantiate(template, null); - var buttonTransform = button.transform; - //buttonTransform.localPosition = new Vector3(-2f, -2f); - button.GetComponent().anchorPoint = new Vector2(0.458f, 0.124f); - - PassiveButton passiveButton = button.GetComponent(); - passiveButton.OnClick = new Button.ButtonClickedEvent(); - passiveButton.OnClick.AddListener((Action) (() => - { - this.StartCoroutine(CoUpdate()); - button.SetActive(false); - })); - - var text = button.transform.GetComponentInChildren(); - string t = "Update BOR"; - if (TORUpdate is null && SubmergedUpdate is not null) t = SubmergedCompatibility.Loaded ? $"Update\nSubmerged" : $"Download\nSubmerged"; - - StartCoroutine(Effects.Lerp(0.1f, (System.Action)(p => text.SetText(t)))); - passiveButton.OnMouseOut.AddListener((Action)(() => text.color = Color.red)); - passiveButton.OnMouseOver.AddListener((Action)(() => text.color = Color.white)); - - var isSubmerged = TORUpdate == null; - var announcement = $"A new {(isSubmerged ? "Submerged" : "BETTER OTHER ROLES")} update to {(isSubmerged ? SubmergedUpdate.Tag : TORUpdate.Tag)} is available\n{(isSubmerged ? SubmergedUpdate.Content : TORUpdate.Content)}"; - var mgr = FindObjectOfType(true); - - if (!isSubmerged) { - try { - string updateVersion = TORUpdate.Content[^5..]; - if (Version.Parse(BetterOtherRolesPlugin.VersionString).BaseVersion() < Version.Parse(updateVersion).BaseVersion()) { - passiveButton.OnClick.RemoveAllListeners(); - passiveButton.OnClick = new Button.ButtonClickedEvent(); - passiveButton.OnClick.AddListener((Action)(() => { - mgr.StartCoroutine(CoShowAnnouncement($"A MANUAL UPDATE IS REQUIRED")); - })); - } - } catch { - BetterOtherRolesPlugin.Logger.LogError("parsing version for auto updater failed :("); - } - - } - - if (isSubmerged && !SubmergedCompatibility.Loaded) showPopUp = false; - if (showPopUp) mgr.StartCoroutine(CoShowAnnouncement(announcement, shortTitle: isSubmerged ? "Submerged Update" : "BOR Update", date: isSubmerged ? SubmergedUpdate.TimeString : TORUpdate.TimeString)); - showPopUp = false; - } - - [HideFromIl2Cpp] - public IEnumerator CoUpdate() - { - updateInProgress = true; - var isSubmerged = TORUpdate is null; - var updateName = (isSubmerged ? "Submerged" : "Better Other Roles"); - - var popup = Instantiate(TwitchManager.Instance.TwitchPopup); - popup.TextAreaTMP.fontSize *= 0.7f; - popup.TextAreaTMP.enableAutoSizing = false; - - popup.Show(); - - var button = popup.transform.GetChild(2).gameObject; - button.SetActive(false); - popup.TextAreaTMP.text = $"Updating {updateName}\nPlease wait..."; - - var download = Task.Run(DownloadUpdate); - while (!download.IsCompleted) yield return null; - - button.SetActive(true); - popup.TextAreaTMP.text = download.Result ? $"{updateName}\nupdated successfully\nPlease restart the game." : "Update wasn't successful\nTry again later,\nor update manually."; - } - - - private static int announcementNumber = 501; - [HideFromIl2Cpp] - public IEnumerator CoShowAnnouncement(string announcement, bool show=true, string shortTitle="BOR Update", string title="", string date="") - { - var mgr = FindObjectOfType(true); - var popUpTemplate = UnityEngine.Object.FindObjectOfType(true); - if (popUpTemplate == null) { - BetterOtherRolesPlugin.Logger.LogError("couldnt show credits, popUp is null"); - yield return null; - } - var popUp = UnityEngine.Object.Instantiate(popUpTemplate); - - popUp.gameObject.SetActive(true); - - Assets.InnerNet.Announcement creditsAnnouncement = new() { - Id = "torAnnouncement", - Language = 0, - Number = announcementNumber++, - Title = title == "" ? "Better Other Roles Announcement" : title, - ShortTitle = shortTitle, - SubTitle = "", - PinState = false, - Date = date == "" ? DateTime.Now.Date.ToString() : date, - Text = announcement, - }; - mgr.StartCoroutine(Effects.Lerp(0.1f, new Action((p) => { - if (p == 1) { - var backup = DataManager.Player.Announcements.allAnnouncements; - DataManager.Player.Announcements.allAnnouncements = new(); - popUp.Init(false); - DataManager.Player.Announcements.SetAnnouncements(new Announcement[] { creditsAnnouncement }); - popUp.CreateAnnouncementList(); - popUp.UpdateAnnouncementText(creditsAnnouncement.Number); - popUp.visibleAnnouncements._items[0].PassiveButton.OnClick.RemoveAllListeners(); - DataManager.Player.Announcements.allAnnouncements = backup; - } - }))); - } - - [HideFromIl2Cpp] - public static IEnumerator CoCheckUpdates() - { - var torUpdateCheck = Task.Run(() => Instance.GetGithubUpdate("EnoPM", "BetterOtherRoles")); - while (!torUpdateCheck.IsCompleted) yield return null; - if (torUpdateCheck.Result != null && torUpdateCheck.Result.IsNewer(Version.Parse(BetterOtherRolesPlugin.VersionString))) - { - Instance.TORUpdate = torUpdateCheck.Result; - } - if (CheckForSubmergedUpdates) - { - var submergedUpdateCheck = Task.Run(() => Instance.GetGithubUpdate("SubmergedAmongUs", "Submerged")); - while (!submergedUpdateCheck.IsCompleted) yield return null; - if (submergedUpdateCheck.Result != null && (!SubmergedCompatibility.Loaded || submergedUpdateCheck.Result.IsNewer(SubmergedCompatibility.Version))) - { - Instance.SubmergedUpdate = submergedUpdateCheck.Result; - if (Instance.SubmergedUpdate.Tag.Equals("2022.10.26")) Instance.SubmergedUpdate = null; - } - } - Instance.OnSceneLoaded(SceneManager.GetActiveScene(), LoadSceneMode.Single); - } - - [HideFromIl2Cpp] - public async Task GetGithubUpdate(string owner, string repo) - { - var client = new HttpClient(); - client.DefaultRequestHeaders.Add("User-Agent", "BetterOtherRoles Updater"); - - try { - var req = await client.GetAsync($"https://api.github.com/repos/{owner}/{repo}/releases/latest", HttpCompletionOption.ResponseContentRead); - - if (!req.IsSuccessStatusCode) return null; - - var dataString = await req.Content.ReadAsStringAsync(); - JObject data = JObject.Parse(dataString); - return new UpdateData(data); - } catch (HttpRequestException) { - return null; - } - } - - private bool TryUpdateSubmergedInternally() - { - if (SubmergedUpdate == null) return false; - try - { - if (!SubmergedCompatibility.LoadedExternally) return false; - var thisAsm = Assembly.GetCallingAssembly(); - var resourceName = thisAsm.GetManifestResourceNames().FirstOrDefault(s => s.EndsWith("Submerged.dll")); - if (resourceName == default) return false; - - using var submergedStream = thisAsm.GetManifestResourceStream(resourceName)!; - var asmDef = AssemblyDefinition.ReadAssembly(submergedStream, TypeLoader.ReaderParameters); - var pluginType = asmDef.MainModule.Types.FirstOrDefault(t => t.IsSubtypeOf(typeof(BasePlugin))); - var info = IL2CPPChainloader.ToPluginInfo(pluginType, ""); - if (SubmergedUpdate.IsNewer(info.Metadata.Version)) return false; - File.Delete(SubmergedCompatibility.Assembly.Location); - - } - catch (Exception e) - { - BetterOtherRolesPlugin.Logger.LogError(e); - return false; - } - return true; - } - - - [HideFromIl2Cpp] - public async Task DownloadUpdate() - { - var isSubmerged = TORUpdate is null; - if (isSubmerged && TryUpdateSubmergedInternally()) return true; - var data = isSubmerged ? SubmergedUpdate : TORUpdate; - - var client = new HttpClient(); - client.DefaultRequestHeaders.Add("User-Agent", "BetterOtherRoles Updater"); - - JToken assets = data.Request["assets"]; - string downloadURI = ""; - for (JToken current = assets.First; current != null; current = current.Next) - { - string browser_download_url = current["browser_download_url"]?.ToString(); - if (browser_download_url != null && current["content_type"] != null) { - if (current["content_type"].ToString().Equals("application/x-msdownload") && - browser_download_url.EndsWith(".dll")) { - downloadURI = browser_download_url; - break; - } - } - } - - if (downloadURI.Length == 0) return false; - - var res = await client.GetAsync(downloadURI, HttpCompletionOption.ResponseContentRead); - string filePath = Path.Combine(Paths.PluginPath, isSubmerged ? "Submerged.dll" : Path.Combine("BetterOtherRoles", "BetterOtherRoles.dll")); - if (File.Exists(filePath + ".old")) File.Delete(filePath + ".old"); - if (File.Exists(filePath)) File.Move(filePath, filePath + ".old"); - - UpdateFiles(new [] { "TheOtherRoles.dll" }); - - await using var responseStream = await res.Content.ReadAsStreamAsync(); - await using var fileStream = File.Create(filePath); - await responseStream.CopyToAsync(fileStream); - - return true; - } - - [HideFromIl2Cpp] - private void UpdateFiles(string[] fileNames) - { - foreach (var fileName in fileNames) - { - var filePath = Path.Combine(Paths.PluginPath, fileName); - if (File.Exists(filePath + ".old")) File.Delete(filePath + ".old"); - if (File.Exists(filePath)) File.Move(filePath, filePath + ".old"); - } - } - } -} diff --git a/BetterOtherRoles/Objects/Bomb.cs b/BetterOtherRoles/Objects/Bomb.cs index c9ab3f7..00f257e 100644 --- a/BetterOtherRoles/Objects/Bomb.cs +++ b/BetterOtherRoles/Objects/Bomb.cs @@ -1,7 +1,6 @@ using Hazel; -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections; +using BepInEx.Unity.IL2CPP.Utils; using BetterOtherRoles.Players; using BetterOtherRoles.Utilities; using UnityEngine; @@ -55,29 +54,38 @@ public Bomb(Vector2 p) { bomb.SetActive(true); } Bomber.bomb = this; - Color c = Color.white; - Color g = Color.red; backgroundRenderer.color = Color.white; Bomber.isActive = false; - FastDestroyableSingleton.Instance.StartCoroutine(Effects.Lerp(Bomber.bombActiveAfter, new Action((x) => { - if (x == 1f && this != null) { - bomb.SetActive(true); - background.SetActive(true); - SoundEffectsManager.playAtPosition("bombFuseBurning", p, Bomber.destructionTime, Bomber.hearRange, true); - Bomber.isActive = true; - - FastDestroyableSingleton.Instance.StartCoroutine(Effects.Lerp(Bomber.destructionTime, new Action((x) => { // can you feel the pain? - Color combinedColor = Mathf.Clamp01(x) * g + Mathf.Clamp01(1 - x) * c; - if (backgroundRenderer) backgroundRenderer.color = combinedColor; - if (x == 1f && this != null) { - explode(this); - } - }))); + FastDestroyableSingleton.Instance.StartCoroutine(CoPlantBomb(backgroundRenderer, p)); + } + + private IEnumerator CoPlantBomb(SpriteRenderer backgroundRenderer, Vector2 p) + { + var timer = 0f; + while (timer < Bomber.bombActiveAfter) + { + timer += Time.deltaTime; + yield return new WaitForEndOfFrame(); + } + timer = 0f; + bomb.SetActive(true); + background.SetActive(true); + SoundEffectsManager.playAtPosition("bombFuseBurning", p, Bomber.destructionTime, Bomber.hearRange, true); + Bomber.isActive = true; + while (timer < Bomber.destructionTime) + { + timer += Time.deltaTime; + var x = timer / Bomber.destructionTime; + if (backgroundRenderer) + { + backgroundRenderer.color = Mathf.Clamp01(x) * Color.red + Mathf.Clamp01(1 - x) * Color.white; } - }))); - + yield return new WaitForEndOfFrame(); + } + if (bomb) explode(this); } + public static void explode(Bomb b) { if (b == null) return; if (Bomber.bomber != null) { diff --git a/BetterOtherRoles/Objects/Portal.cs b/BetterOtherRoles/Objects/Portal.cs index 6c76d24..79023e2 100644 --- a/BetterOtherRoles/Objects/Portal.cs +++ b/BetterOtherRoles/Objects/Portal.cs @@ -114,8 +114,11 @@ public Portal(Vector2 p) { else if (secondPortal == null) { secondPortal = this; } - var lastRoom = FastDestroyableSingleton.Instance?.roomTracker.LastRoom.RoomId; - this.room = lastRoom != null ? DestroyableSingleton.Instance.GetString((SystemTypes)lastRoom) : "Open Field"; + var hudManager = HudManager.Instance; + var lastRoom = hudManager && hudManager.roomTracker && hudManager.roomTracker.LastRoom + ? HudManager.Instance.roomTracker.LastRoom.RoomId + : SystemTypes.Outside; + this.room = DestroyableSingleton.Instance.GetString(lastRoom); } public static bool locationNearEntry(Vector2 p) { diff --git a/BetterOtherRoles/Patches/PlayerControlPatch.cs b/BetterOtherRoles/Patches/PlayerControlPatch.cs index f096dc9..b13c9d1 100644 --- a/BetterOtherRoles/Patches/PlayerControlPatch.cs +++ b/BetterOtherRoles/Patches/PlayerControlPatch.cs @@ -1295,10 +1295,6 @@ static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]GameData.Playe writer.Write(msg); AmongUsClient.Instance.FinishRpcImmediately(writer); } - if (msg.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0) - { - FastDestroyableSingleton.Instance.SendWho(); - } } } } @@ -1341,7 +1337,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC if ((Lovers.lover1 != null && target == Lovers.lover1) || (Lovers.lover2 != null && target == Lovers.lover2)) { PlayerControl otherLover = target == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1; if (otherLover != null && !otherLover.Data.IsDead && Lovers.bothDie) { - otherLover.MurderPlayer(otherLover); + otherLover.MurderPlayer(otherLover, MurderResultFlags.Succeeded); GameHistory.overrideDeathReasonAndKiller(otherLover, DeadPlayer.CustomDeathReason.LoverSuicide); } } diff --git a/BetterOtherRoles/Patches/ReactorSystemTypePatches.cs b/BetterOtherRoles/Patches/ReactorSystemTypePatches.cs index 9e024c3..a9d74b2 100644 --- a/BetterOtherRoles/Patches/ReactorSystemTypePatches.cs +++ b/BetterOtherRoles/Patches/ReactorSystemTypePatches.cs @@ -1,15 +1,19 @@ using BetterOtherRoles.Modules; using HarmonyLib; +using Hazel; namespace BetterOtherRoles.Patches; [HarmonyPatch(typeof(ReactorSystemType))] public static class ReactorSystemTypePatches { - [HarmonyPatch(nameof(ReactorSystemType.RepairDamage))] + [HarmonyPatch(nameof(ReactorSystemType.UpdateSystem))] [HarmonyPrefix] - private static bool RepairDamagePrefix(ReactorSystemType __instance, PlayerControl player, byte opCode) + private static bool RepairDamagePrefix(ReactorSystemType __instance, PlayerControl player, MessageReader msgReader) { + var oldPos = msgReader._position; + var opCode = msgReader.ReadByte(); + msgReader._position = oldPos; if (ShipStatus.Instance.Type != ShipStatus.MapType.Pb || opCode != 128 || __instance.IsActive) return true; __instance.Countdown = BetterPolus.ReactorCountdown.getFloat(); __instance.UserConsolePairs.Clear(); diff --git a/BetterOtherRoles/Patches/ShipStatusPatch.cs b/BetterOtherRoles/Patches/ShipStatusPatch.cs index 2043762..9c109be 100644 --- a/BetterOtherRoles/Patches/ShipStatusPatch.cs +++ b/BetterOtherRoles/Patches/ShipStatusPatch.cs @@ -105,7 +105,7 @@ public static bool Prefix(ShipStatus __instance) if (TORMapOptions.gameMode != CustomGamemodes.HideNSeek) { var commonTaskCount = __instance.CommonTasks.Count; - var normalTaskCount = __instance.NormalTasks.Count; + var normalTaskCount = __instance.ShortTasks.Count; var longTaskCount = __instance.LongTasks.Count; if (GameOptionsManager.Instance.currentNormalGameOptions.NumCommonTasks > commonTaskCount) GameOptionsManager.Instance.currentNormalGameOptions.NumCommonTasks = commonTaskCount; diff --git a/BetterOtherRoles/RPC.cs b/BetterOtherRoles/RPC.cs index 1527651..f249da3 100644 --- a/BetterOtherRoles/RPC.cs +++ b/BetterOtherRoles/RPC.cs @@ -214,7 +214,7 @@ public static void forceEnd() { GameData.Instance.GetPlayerById(player.PlayerId); // player.RemoveInfected(); (was removed in 2022.12.08, no idea if we ever need that part again, replaced by these 2 lines.) player.SetRole(RoleTypes.Crewmate); - player.MurderPlayer(player); + player.MurderPlayer(player, MurderResultFlags.Succeeded); player.Data.IsDead = true; } } @@ -447,7 +447,7 @@ public static void uncheckedMurderPlayer(byte sourceId, byte targetId, byte show PlayerControl target = Helpers.playerById(targetId); if (source != null && target != null) { if (showAnimation == 0) KillAnimationCoPerformKillPatch.hideNextAnimation = true; - source.MurderPlayer(target); + source.MurderPlayer(target, MurderResultFlags.Succeeded); } } @@ -1007,8 +1007,6 @@ public static void guesserShoot(byte killerId, byte dyingTargetId, byte guessedT string msg = $"{guesser.Data.PlayerName} guessed the role {roleInfo?.name ?? ""} for {guessedTarget.Data.PlayerName}!"; if (AmongUsClient.Instance.AmClient && FastDestroyableSingleton.Instance) FastDestroyableSingleton.Instance.Chat.AddChat(guesser, msg); - if (msg.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0) - FastDestroyableSingleton.Instance.SendWho(); } } diff --git a/BetterOtherRoles/SubmergedCompatibility.cs b/BetterOtherRoles/SubmergedCompatibility.cs index 9dd5741..54bd360 100644 --- a/BetterOtherRoles/SubmergedCompatibility.cs +++ b/BetterOtherRoles/SubmergedCompatibility.cs @@ -181,7 +181,7 @@ public static bool getInTransition() { public static void RepairOxygen() { if (!Loaded) return; try { - ShipStatus.Instance.RpcRepairSystem((SystemTypes)130, 64); + ShipStatus.Instance.RpcUpdateSystem((SystemTypes)130, 64); RepairDamageMethod.Invoke(SubmarineOxygenSystemInstanceField.Invoke(null, Array.Empty()), new object[] { CachedPlayer.LocalPlayer.PlayerControl, 64 }); } catch (System.NullReferenceException) { diff --git a/BetterOtherRoles/packages.lock.json b/BetterOtherRoles/packages.lock.json index 09de96a..cbc79fb 100644 --- a/BetterOtherRoles/packages.lock.json +++ b/BetterOtherRoles/packages.lock.json @@ -4,9 +4,9 @@ "net6.0": { "AmongUs.GameLibs.Steam": { "type": "Direct", - "requested": "[2023.7.11, )", - "resolved": "2023.7.11", - "contentHash": "e5zbU+4AYnp1zAQDizO5GRIh1kemkgCa8rFVAcr9bxeupkBu5dwwdHxArWv/pUybIJTZfOPjkOnicZ2qKWLX7g==" + "requested": "[2023.10.24, )", + "resolved": "2023.10.24", + "contentHash": "8N064B27cGIZZk902aCLinazPp5T02KNdAUOLBVc1NIua8vYz4muwNdSI0RDGEY0CWbICK+FVsfGXdzAVTeH9A==" }, "BepInEx.IL2CPP.MSBuild": { "type": "Direct", @@ -16,17 +16,17 @@ }, "BepInEx.Unity.IL2CPP": { "type": "Direct", - "requested": "[6.0.0-be.670, )", - "resolved": "6.0.0-be.670", - "contentHash": "dhzCrem44oFxhOICCJ9eoSUbaKSsGGyBUfUQW9WFljCwIK8o4Cx5BiuXAkYoRjr2DhpzLpPDyPZDRImUqH0bwA==", + "requested": "[6.0.0-be.674, )", + "resolved": "6.0.0-be.674", + "contentHash": "y6b5w0L5jDE8h67swHN3cDJ+FV+MzVcwrVqr9ssO37L9Laj87zYUtQVRTXwi5G/QFqeUQcUqi04gsYYR9yue3Q==", "dependencies": { - "BepInEx.Core": "6.0.0-be.670", - "BepInEx.Unity.Common": "6.0.0-be.670", + "BepInEx.Core": "6.0.0-be.674", + "BepInEx.Unity.Common": "6.0.0-be.674", "HarmonyX": "2.10.1", "Iced": "1.18.0", - "Il2CppInterop.Generator": "1.4.6-ci.354", - "Il2CppInterop.HarmonySupport": "1.4.6-ci.354", - "Il2CppInterop.Runtime": "1.4.6-ci.354", + "Il2CppInterop.Generator": "1.4.6-ci.389", + "Il2CppInterop.HarmonySupport": "1.4.6-ci.389", + "Il2CppInterop.Runtime": "1.4.6-ci.389", "MonoMod.RuntimeDetour": "22.5.1.1", "Samboy063.Cpp2IL.Core": "2022.1.0-development.866" } @@ -68,8 +68,8 @@ }, "BepInEx.Core": { "type": "Transitive", - "resolved": "6.0.0-be.670", - "contentHash": "7CbbMNZfb+1VHjFKh/ErFBOOEYrVCIkng/B3/HPcbNioySC7qdT1ztfYqs6YjQia4krEic+LV3ew86B/hTg+hw==", + "resolved": "6.0.0-be.674", + "contentHash": "onhAmi1nB36fVyQ25TRkWfDcYHBmw9pKxx758ut2hWou2gJpRpY2Dxc+GZrXCidPGy65mCi393zIU+07ShHTZw==", "dependencies": { "HarmonyX": "2.10.1", "MonoMod.Utils": "22.5.1.1", @@ -78,8 +78,8 @@ }, "BepInEx.Unity.Common": { "type": "Transitive", - "resolved": "6.0.0-be.670", - "contentHash": "FSzWILgwepZ7CpA34ew1WyO75lNjxkfX86uwo2172lbhmLkgoAdQbNun8dxKJCDlIevmTDga76yr/WPrTXELvA==", + "resolved": "6.0.0-be.674", + "contentHash": "CApjIS89Pl7sKsnxOXANWBq3ALrdAQzn/neK6E6sydjYQiiVKwC6Wo65c1wHdcctSylGhh+e59WuxVSlGuJW9w==", "dependencies": { "AssetRipper.VersionUtilities": "1.2.1", "MonoMod.Utils": "22.5.1.1" @@ -106,8 +106,8 @@ }, "Il2CppInterop.Common": { "type": "Transitive", - "resolved": "1.4.6-ci.354", - "contentHash": "aCP3kr39YQw5GVqE9Q8c5y7f9CEKdFxpUhIqYgQBtrEz5Z/KCbHhjuOf/lSuFrjl6Vub/BKk6k+UbMRdoSvC1w==", + "resolved": "1.4.6-ci.389", + "contentHash": "KTyf2f66Q2mS9a6xhvoPWwD0VzRIoskPMVQehaVMo1dx4Di1FPFsKqukQ+ob6wgP5Rbnx53kiH0PY+IRSb35XA==", "dependencies": { "Iced": "1.17.0", "Microsoft.Extensions.Logging.Abstractions": "6.0.1", @@ -116,29 +116,29 @@ }, "Il2CppInterop.Generator": { "type": "Transitive", - "resolved": "1.4.6-ci.354", - "contentHash": "y30sxc9mMv0bUzCPDr73xiI6fiu7ksmnEm6XULTGU/5JEGv2aw++/71bLOEYCscNbZTa2JT4yYrLCXCj3GSekg==", + "resolved": "1.4.6-ci.389", + "contentHash": "XJX4sn/RzAEBNIZZXuyDcLZrFx5tCoahujDu5aKWjApiMj/nTRQAxZn17daIIvd9aHqLaAfiWWth5QDLIt2bKw==", "dependencies": { - "Il2CppInterop.Common": "1.4.6-ci.354", + "Il2CppInterop.Common": "1.4.6-ci.389", "Mono.Cecil": "0.11.3" } }, "Il2CppInterop.HarmonySupport": { "type": "Transitive", - "resolved": "1.4.6-ci.354", - "contentHash": "mQV5A+B/qtI6kSXEGx/UswiqjFKw13/yyviawnStfRKbLMW+XFsdMgGSkOVZd/TiDtF9ZG4Xt7DbkbFu26WjyA==", + "resolved": "1.4.6-ci.389", + "contentHash": "Xd2zK6sLqwA0ReyUy83SWKcALwY99fq6vVL5gFOMN5Ct8OOVhtNIws0ysCWsfx1GL0RJiRYfR4pza/MmWRz4PQ==", "dependencies": { "HarmonyX": "2.10.0", - "Il2CppInterop.Runtime": "1.4.6-ci.354" + "Il2CppInterop.Runtime": "1.4.6-ci.389" } }, "Il2CppInterop.Runtime": { "type": "Transitive", - "resolved": "1.4.6-ci.354", - "contentHash": "Xe5md9z+KIthdEcjfUjmoOhvM3gTI3SPyocqvuzEHoov5jQ/HhIPv5hUZzTSm+2nzn3XplENNE8vlBPvQ1o6OA==", + "resolved": "1.4.6-ci.389", + "contentHash": "nzYjuVzDG/O8+AQ8ax3WVHf+ZVsQKrVtp/yvuW8XoEPLdkbgryIrMo75dvN+tPqxOU3o2MPt9MZ9j25P5aVJMw==", "dependencies": { "Iced": "1.17.0", - "Il2CppInterop.Common": "1.4.6-ci.354" + "Il2CppInterop.Common": "1.4.6-ci.389" } }, "js6pak.Gee.External.Capstone": {