Compare commits

...
11 Commits
Author SHA1 Message Date
XtraCube 4fcfb2a9ee fix LobbyViewPanePatches.cs AGAIN 2024-09-07 10:38:37 -04:00
XtraCube 41bedd3e16 bump version 2024-09-07 10:24:18 -04:00
XtraCube d27bf67f65 fix lobby view pane issues 2024-09-07 10:23:59 -04:00
XtraCube 76ddfa4126 Merge branch 'dev' 2024-09-05 18:10:04 -04:00
XtraCube 400ad535a4 bump version 2024-09-05 18:09:50 -04:00
XtraCube eaf5890f67 Merge pull request #13 from CallOfCreator/dev 2024-09-05 08:08:52 -04:00
XtraCube b2651adcab adjustments 2024-09-05 07:18:20 -04:00
XtraCube c8c6ab1f61 Update README.md 2024-09-04 18:49:24 -04:00
XtraCube 7f65f2d5bb remove warning from example build 2024-09-04 18:34:45 -04:00
XtraCube 17da594207 fix notif popper issue 2024-09-04 18:34:36 -04:00
CallOfCreator 75dd5e8a35 Add CanUseSabotage support in ICustomRole 2024-09-04 16:27:57 +00:00
13 changed files with 86 additions and 27 deletions

No files matched your search

+1 -1
View File
@@ -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" />
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -43,4 +43,4 @@ public class ChameloenRole : CrewmateRole, ICustomRole
}
}
}
}
}
+1 -1
View File
@@ -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
View File
@@ -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 + "%"
);
+1 -1
View File
@@ -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)]),
};
}
+2 -1
View File
@@ -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;
}
}
+5
View File
@@ -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>
+2
View File
@@ -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