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();
}
}
diff --git a/MiraAPI/GameOptions/ModdedOptionsManager.cs b/MiraAPI/GameOptions/ModdedOptionsManager.cs
index 231d36a..76410e4 100644
--- a/MiraAPI/GameOptions/ModdedOptionsManager.cs
+++ b/MiraAPI/GameOptions/ModdedOptionsManager.cs
@@ -143,6 +143,11 @@ public static class ModdedOptionsManager
plugin.PluginConfig.Save();
plugin.PluginConfig.SaveOnConfigSet = true;
}
+
+ if (LobbyInfoPane.Instance)
+ {
+ LobbyInfoPane.Instance.RefreshPane();
+ }
}
diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs
index cabe3e0..c24f5ea 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)
@@ -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();
@@ -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() { }
@@ -270,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;
}
@@ -278,10 +279,7 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB
///
/// 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.
@@ -298,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;
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
diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
index ad6870f..b65cc2b 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)
{
diff --git a/MiraAPI/Roles/CustomRoleManager.cs b/MiraAPI/Roles/CustomRoleManager.cs
index e21568d..f124a30 100644
--- a/MiraAPI/Roles/CustomRoleManager.cs
+++ b/MiraAPI/Roles/CustomRoleManager.cs
@@ -221,5 +221,10 @@ public static class CustomRoleManager
plugin.PluginConfig.Save();
plugin.PluginConfig.SaveOnConfigSet = oldConfigSetting[plugin];
}
+
+ if (LobbyInfoPane.Instance)
+ {
+ LobbyInfoPane.Instance.RefreshPane();
+ }
}
}
\ No newline at end of file
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.