mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Merge branch 'master' into dev
This commit is contained in:
commit
9fc5044085
7 files changed
+32
-13
No files matched your search
@@ -45,7 +45,7 @@ public class TeleportButton : CustomActionButton
|
||||
if (Input.GetKey(KeyCode.Mouse0))
|
||||
{
|
||||
playerControl.NetTransform.RpcSnapTo(Camera.main.ScreenToWorldPoint(Input.mousePosition));
|
||||
ResetCooldown();
|
||||
ResetCooldownAndOrEffect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,11 @@ public static class ModdedOptionsManager
|
||||
plugin.PluginConfig.Save();
|
||||
plugin.PluginConfig.SaveOnConfigSet = true;
|
||||
}
|
||||
|
||||
if (LobbyInfoPane.Instance)
|
||||
{
|
||||
LobbyInfoPane.Instance.RefreshPane();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function to reset the cooldown of the button.
|
||||
/// A utility function to reset the cooldown and/or effect of the button.
|
||||
/// </summary>
|
||||
public void ResetCooldown()
|
||||
public void ResetCooldownAndOrEffect()
|
||||
{
|
||||
Timer = Cooldown;
|
||||
if (EffectActive)
|
||||
@@ -136,13 +136,13 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="playerControl">the local PlayerControl</param>
|
||||
protected virtual void FixedUpdate(PlayerControl playerControl) { }
|
||||
|
||||
/// <summary>
|
||||
/// Runs when the button is clicked.
|
||||
/// Callback method for the button click event.
|
||||
/// </summary>
|
||||
protected abstract void OnClick();
|
||||
|
||||
@@ -154,7 +154,8 @@ public abstract class CustomActionButton
|
||||
public abstract bool Enabled(RoleBehaviour? role);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// <br /> <br /> THIS IS A CALLBACK METHOD! Use <see cref="ResetCooldownAndOrEffect" /> if you want to end the effect.
|
||||
/// </summary>
|
||||
public virtual void OnEffectEnd() { }
|
||||
|
||||
@@ -270,7 +271,7 @@ public abstract class CustomActionButton<T> : CustomActionButton where T : MonoB
|
||||
/// <summary>
|
||||
/// Determines if the target object is valid.
|
||||
/// </summary>
|
||||
public virtual bool IsTargetValid(T target)
|
||||
public virtual bool IsTargetValid(T? target)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
@@ -278,10 +279,7 @@ public abstract class CustomActionButton<T> : CustomActionButton where T : MonoB
|
||||
/// <summary>
|
||||
/// The method used to get the target object.
|
||||
/// </summary>
|
||||
public virtual T? GetTarget()
|
||||
{
|
||||
return PlayerControl.LocalPlayer.GetNearestObjectOfType<T>(Distance, ColliderTag, IsTargetValid);
|
||||
}
|
||||
public abstract T? GetTarget();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the outline of the target object.
|
||||
@@ -298,7 +296,7 @@ public abstract class CustomActionButton<T> : CustomActionButton where T : MonoB
|
||||
SetOutline(false);
|
||||
}
|
||||
|
||||
Target = newTarget;
|
||||
Target = IsTargetValid(newTarget) ? newTarget : null;
|
||||
SetOutline(true);
|
||||
|
||||
return base.CanUse() && Target;
|
||||
|
||||
@@ -12,7 +12,7 @@ public static class MeetingHudPatches
|
||||
{
|
||||
foreach (var customActionButton in CustomButtonManager.CustomButtons)
|
||||
{
|
||||
customActionButton.ResetCooldown();
|
||||
customActionButton.ResetCooldownAndOrEffect();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<SpriteRenderer>().size = new Vector2(89.4628f, 100);
|
||||
|
||||
CreateAdvancedSettings(__instance, role);
|
||||
|
||||
foreach (var optionBehaviour in __instance.advancedSettingChildren)
|
||||
{
|
||||
if (optionBehaviour.IsCustom())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>(__instance.ValueChanged);
|
||||
if (AmongUsClient.Instance && !AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
|
||||
@@ -221,5 +221,10 @@ public static class CustomRoleManager
|
||||
plugin.PluginConfig.Save();
|
||||
plugin.PluginConfig.SaveOnConfigSet = oldConfigSetting[plugin];
|
||||
}
|
||||
|
||||
if (LobbyInfoPane.Instance)
|
||||
{
|
||||
LobbyInfoPane.Instance.RefreshPane();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user