From 7a0396fe5ce3d7a0c7757f7d99a19ae7546b9c70 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:11:36 -0400 Subject: [PATCH 1/8] Make lobby view pane sync on options change --- MiraAPI/GameOptions/ModdedOptionsManager.cs | 5 +++++ MiraAPI/Roles/CustomRoleManager.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/MiraAPI/GameOptions/ModdedOptionsManager.cs b/MiraAPI/GameOptions/ModdedOptionsManager.cs index f130864..082758e 100644 --- a/MiraAPI/GameOptions/ModdedOptionsManager.cs +++ b/MiraAPI/GameOptions/ModdedOptionsManager.cs @@ -129,6 +129,11 @@ public static class ModdedOptionsManager option.HandleNetData(netData.Data); } + + if (LobbyInfoPane.Instance) + { + LobbyInfoPane.Instance.RefreshPane(); + } } diff --git a/MiraAPI/Roles/CustomRoleManager.cs b/MiraAPI/Roles/CustomRoleManager.cs index 74e0bcf..fcdf814 100644 --- a/MiraAPI/Roles/CustomRoleManager.cs +++ b/MiraAPI/Roles/CustomRoleManager.cs @@ -205,5 +205,10 @@ public static class CustomRoleManager Logger.Error(e); } } + + if (LobbyInfoPane.Instance) + { + LobbyInfoPane.Instance.RefreshPane(); + } } } \ No newline at end of file From e211c4c49c0a249b5ee0a5e68ba41a8815154053 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:21:06 -0400 Subject: [PATCH 2/8] rename ResetCooldown to ResetCooldownAndOrEffect, add warning in doc --- MiraAPI/Hud/CustomActionButton.cs | 7 ++++--- MiraAPI/Patches/MeetingHudPatches.cs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 16e72a4..53955e4 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -101,9 +101,9 @@ public abstract class CustomActionButton } /// - /// A utility function to reset the cooldown of the button. + /// A utility function to reset the cooldown and/or effect of the button. /// - public void ResetCooldown() + public void ResetCooldownAndOrEffect() { Timer = Cooldown; if (EffectActive) @@ -154,7 +154,8 @@ public abstract class CustomActionButton public abstract bool Enabled(RoleBehaviour? role); /// - /// Given that there is an effect, this method that runs when the effect ends. + /// Given that there is an effect, this method runs when the effect ends. + ///

THIS IS A CALLBACK METHOD! Use if you want to end the effect. ///
public virtual void OnEffectEnd() { } diff --git a/MiraAPI/Patches/MeetingHudPatches.cs b/MiraAPI/Patches/MeetingHudPatches.cs index 92fa311..e813730 100644 --- a/MiraAPI/Patches/MeetingHudPatches.cs +++ b/MiraAPI/Patches/MeetingHudPatches.cs @@ -12,7 +12,7 @@ public static class MeetingHudPatches { foreach (var customActionButton in CustomButtonManager.CustomButtons) { - customActionButton.ResetCooldown(); + customActionButton.ResetCooldownAndOrEffect(); } } } \ No newline at end of file From f187a15f2ed0eb09ae5432806885440534e64759 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:23:53 -0400 Subject: [PATCH 3/8] more documentaion stuff --- MiraAPI/Hud/CustomActionButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 53955e4..01ace81 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -136,13 +136,13 @@ public abstract class CustomActionButton } /// - /// A utility function that runs with the local PlayerControl's FixedUpdate. + /// A utility function that runs with the local PlayerControl's FixedUpdate if the button is enabled. /// /// the local PlayerControl protected virtual void FixedUpdate(PlayerControl playerControl) { } /// - /// Runs when the button is clicked. + /// Callback method for the button click event. /// protected abstract void OnClick(); From 16fd8e02aa6dfef7585a27ffadca5d97108928d2 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:44:25 -0400 Subject: [PATCH 4/8] fix bug with advanced roles settings --- MiraAPI/Patches/Options/RoleSettingMenuPatches.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index 6a2904f..0e86326 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -224,11 +224,20 @@ public static class RoleSettingMenuPatches __instance.roleScreenshot.drawMode = SpriteDrawMode.Sliced; __instance.roleHeaderSprite.color = customRole.RoleColor; __instance.roleHeaderText.color = customRole.RoleColor.GetAlternateColor(); + + var bg = __instance.AdvancedRolesSettings.transform.Find("Background"); + bg.localPosition = new Vector3(1.4041f, -7.08f, 0); + bg.GetComponent().size = new Vector2(89.4628f, 100); CreateAdvancedSettings(__instance, role); foreach (var optionBehaviour in __instance.advancedSettingChildren) { + if (optionBehaviour.IsCustom()) + { + continue; + } + optionBehaviour.OnValueChanged = new Action(__instance.ValueChanged); if (AmongUsClient.Instance && !AmongUsClient.Instance.AmHost) { From 763017b6e263ca74432b7e6ba46f49a769b25042 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:44:37 -0400 Subject: [PATCH 5/8] make GetTarget abstract instead of virtual --- MiraAPI/Hud/CustomActionButton.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 01ace81..a390750 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -275,14 +275,11 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB { return target; } - + /// /// The method used to get the target object. /// - public virtual T? GetTarget() - { - return PlayerControl.LocalPlayer.GetNearestObjectOfType(Distance, ColliderTag, IsTargetValid); - } + public abstract T? GetTarget(); /// /// Sets the outline of the target object. From 4bef2f838d6acc7da5ece3f431574f2d94e6b055 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:46:15 -0400 Subject: [PATCH 6/8] can use fix --- MiraAPI/Hud/CustomActionButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index a390750..c2db82d 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -271,7 +271,7 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB /// /// Determines if the target object is valid. /// - public virtual bool IsTargetValid(T target) + public virtual bool IsTargetValid(T? target) { return target; } @@ -296,7 +296,7 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB SetOutline(false); } - Target = newTarget; + Target = IsTargetValid(newTarget) ? newTarget : null; SetOutline(true); return base.CanUse() && Target; From 8d167596d2c2a90ffd844b604c513ed675d277eb Mon Sep 17 00:00:00 2001 From: Ang <106892549+ang-xd@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:29:29 -0400 Subject: [PATCH 7/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 487204a..01c3d2c 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ Roles are very simple in Mira API. There are 3 things you need to do to create a 2. Implement the `ICustomRole` interface from Mira API. 3. Add the `[RegisterCustomRole]` attribute to the class. +**Disclaimer: Make sure your plugin class has the following attribute `[ReactorModFlags(ModFlags.RequireOnAllClients)]` or else your roles will not register correctly.** + Note: For step 1, if you are making neutral roles, choose either `CrewmateRole` or `ImpostorRole` as the base depending on if it can kill or not! Mira API handles everything else, from adding the proper options to the settings menu, to managing the role assignment at the start of the game. There are no extra steps on the developer's part. From 19c7e386902a10485d62910beb13f35b1409e329 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:56:33 -0400 Subject: [PATCH 8/8] what the freak --- MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs b/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs index a860d36..8491b99 100644 --- a/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs +++ b/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs @@ -45,7 +45,7 @@ public class TeleportButton : CustomActionButton if (Input.GetKey(KeyCode.Mouse0)) { playerControl.NetTransform.RpcSnapTo(Camera.main.ScreenToWorldPoint(Input.mousePosition)); - ResetCooldown(); + ResetCooldownAndOrEffect(); } }