mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 11:39:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fcfb2a9ee | ||
|
|
41bedd3e16 | ||
|
|
d27bf67f65 | ||
|
|
76ddfa4126 | ||
|
|
400ad535a4 | ||
|
|
eaf5890f67 | ||
|
|
b2651adcab | ||
|
|
c8c6ab1f61 | ||
|
|
7f65f2d5bb | ||
|
|
17da594207 | ||
|
|
75dd5e8a35 |
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Reactor" Version="2.3.1" />
|
||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.697" Private="false" ExcludeAssets="runtime;native" />
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.8.13" PrivateAssets="all" />
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.9.4" PrivateAssets="all" />
|
||||
|
||||
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
|
||||
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1" PrivateAssets="all" ExcludeAssets="runtime" />
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
|
||||
<VersionPrefix>0.1.4</VersionPrefix>
|
||||
<VersionPrefix>0.1.7</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
|
||||
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
||||
|
||||
@@ -43,4 +43,4 @@ public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ internal interface IModdedOption
|
||||
string Title { get; }
|
||||
StringNames StringName { get; }
|
||||
IMiraPlugin? ParentMod { get; set; }
|
||||
BaseGameSetting? Data { get; }
|
||||
BaseGameSetting Data { get; }
|
||||
Type? AdvancedRole { get; set; }
|
||||
OptionBehaviour? OptionBehaviour { get; }
|
||||
Func<bool> Visible { get; set; }
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
/// <summary>
|
||||
/// Gets the BaseGameSetting data of the option.
|
||||
/// </summary>
|
||||
public BaseGameSetting? Data { get; protected init; }
|
||||
public BaseGameSetting Data { get; protected init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parent mod of the option.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Roles;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -6,6 +6,7 @@ using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
@@ -128,11 +129,6 @@ public static class LobbyViewPanePatches
|
||||
|
||||
foreach (var group in filteredGroups)
|
||||
{
|
||||
if (group.Options.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var categoryHeaderMasked = Object.Instantiate(
|
||||
instance.categoryHeaderOrigin,
|
||||
instance.settingsContainer,
|
||||
@@ -176,11 +172,6 @@ public static class LobbyViewPanePatches
|
||||
|
||||
var data = option.Data;
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.Type == OptionTypes.Checkbox)
|
||||
{
|
||||
viewSettingsInfoPanel.SetInfoCheckbox(
|
||||
@@ -399,11 +390,6 @@ public static class LobbyViewPanePatches
|
||||
|
||||
var value = option.GetFloatData();
|
||||
|
||||
if (baseGameSetting == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (baseGameSetting.Type == OptionTypes.Checkbox)
|
||||
{
|
||||
viewSettingsInfoPanel.SetInfoCheckbox(baseGameSetting.Title, maskLayer, value > 0f);
|
||||
|
||||
@@ -18,7 +18,7 @@ public static class NotificationPopperPatch
|
||||
[HarmonyArgument(3)] RoleTeamTypes teamType,
|
||||
[HarmonyArgument(4)] bool playSound)
|
||||
{
|
||||
if (CustomRoleManager.CustomRoles.Values.All(role => role.StringName != key))
|
||||
if (CustomRoleManager.CustomRoles.Values.FirstOrDefault(x=>x.StringName==key) is not ICustomRole customRole)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -29,10 +29,12 @@ public static class NotificationPopperPatch
|
||||
|
||||
var item = DestroyableSingleton<TranslationController>.Instance.GetString(
|
||||
StringNames.LobbyChangeSettingNotificationRole,
|
||||
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">",
|
||||
text,
|
||||
DestroyableSingleton<TranslationController>.Instance.GetString(key, Array.Empty<Object>()),
|
||||
"</color></font>",
|
||||
string.Concat(
|
||||
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">",
|
||||
text,
|
||||
DestroyableSingleton<TranslationController>.Instance.GetString(key, Array.Empty<Object>()),
|
||||
"</color></font>"
|
||||
),
|
||||
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + roleCount + "</font>",
|
||||
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + roleChance + "%"
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ public static class SettingPatches
|
||||
MiraNumberSuffixes.Percent => value.ToString(__instance.FormatString, NumberFormatInfo.InvariantInfo) + "%",
|
||||
_ => DestroyableSingleton<TranslationController>.Instance.GetString(
|
||||
StringNames.GameSecondsAbbrev,
|
||||
(Il2CppSystem.Object[]) [value.ToString(__instance.FormatString, CultureInfo.InvariantCulture)]),
|
||||
(Il2CppSystem.Object[])[value.ToString(__instance.FormatString, CultureInfo.InvariantCulture)]),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,11 @@ public static class HudManagerPatches
|
||||
{
|
||||
var flag = localPlayer.Data != null && localPlayer.Data.IsDead;
|
||||
|
||||
if (role is ICustomRole)
|
||||
if (role is ICustomRole customRole)
|
||||
{
|
||||
__instance.KillButton.ToggleVisible(isActive && role.CanUseKillButton && !flag);
|
||||
__instance.ImpostorVentButton.ToggleVisible(isActive && role.CanVent && !flag);
|
||||
__instance.SabotageButton.gameObject.SetActive(isActive && customRole.CanUseSabotage);
|
||||
}
|
||||
|
||||
if (_roleTab)
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Roles;
|
||||
|
||||
namespace MiraAPI.Patches.Roles;
|
||||
|
||||
[HarmonyPatch(typeof(SabotageButton))]
|
||||
public class SabotageButtonPatch
|
||||
{
|
||||
/// <summary>
|
||||
/// Patches the Sabotage button to check if the player's custom role can use sabotage.
|
||||
/// </summary>
|
||||
[HarmonyPatch(nameof(SabotageButton.DoClick))]
|
||||
[HarmonyPrefix]
|
||||
public static bool DoClickPrefix(SabotageButton __instance)
|
||||
{
|
||||
var player = PlayerControl.LocalPlayer;
|
||||
|
||||
if (player.Data.Role is not ICustomRole customRole)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!customRole.CanUseSabotage || PlayerControl.LocalPlayer.inVent || !GameManager.Instance.SabotagesEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DestroyableSingleton<HudManager>.Instance.ToggleMapVisible(
|
||||
new MapOptions
|
||||
{
|
||||
Mode = MapOptions.Modes.Sabotage,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(SabotageButton.Refresh))]
|
||||
public static bool RefreshPrefix(SabotageButton __instance)
|
||||
{
|
||||
var player = PlayerControl.LocalPlayer;
|
||||
if (GameManager.Instance == null || player == null)
|
||||
{
|
||||
__instance.ToggleVisible(false);
|
||||
__instance.SetDisabled();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.Data.Role is not ICustomRole customRole)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.inVent || !GameManager.Instance.SabotagesEnabled() || player.petting)
|
||||
{
|
||||
__instance.ToggleVisible(customRole.CanUseSabotage && GameManager.Instance.SabotagesEnabled());
|
||||
__instance.SetDisabled();
|
||||
return false;
|
||||
}
|
||||
__instance.SetEnabled();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,11 @@ public interface ICustomRole
|
||||
/// </summary>
|
||||
bool CanUseVent => Team == ModdedRoleTeams.Impostor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the role can use the sabotage button.
|
||||
/// </summary>
|
||||
bool CanUseSabotage => Team == ModdedRoleTeams.Impostor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the role's tasks count towards task progress.
|
||||
/// </summary>
|
||||
|
||||
@@ -23,6 +23,8 @@ To start using Mira API, you need to:
|
||||
2. Add a BepInDependency on your plugin class like this: `[BepInDependency(MiraApiPlugin.Id)]`
|
||||
3. Implement the IMiraPlugin interface on your plugin class.
|
||||
|
||||
Mira API also depends on [Reactor](https://github.com/NuclearPowered/Reactor) in order to function properly! Do not forget to include it as a reference and `BepInDependency`!
|
||||
|
||||
For a full example, see [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/ExamplePlugin.cs).
|
||||
|
||||
## Recommended Project Structure
|
||||
|
||||
Reference in new issue
Block a user