Compare commits

...
81 Commits
Author SHA1 Message Date
Atony fc94c8e67e Bump version 2026-08-02 20:13:16 -05:00
Atony 83e550c1f2 Merge pull request #96 from All-Of-Us-Mods/dev
MiraAPI 0.4.2
2026-08-02 20:11:59 -05:00
Atony edee889ffe Fix hidden local tabs breaking the menu 2026-07-30 23:15:24 -05:00
Atony 8c5aee4beb Fix vanilla roles tab being broken 2026-07-26 11:56:21 -05:00
Atony 30a39fa223 Add DisplayOnOptionsMenu for mira api mods 2026-07-26 11:12:28 -05:00
Atony 228ed9711a Add mod name abbreviation 2026-07-26 11:05:13 -05:00
Atony 7c085b1072 Add modifier post assignment-check 2026-07-25 18:03:29 -05:00
Atony 8750e5c894 Reorder modifier validity checks 2026-07-25 17:20:14 -05:00
XtraCube 1b40b1c5e4 attempt to improve gc behavior 2026-07-20 20:23:38 -04:00
XtraCube 0a0ad74419 improve GC collection 2026-07-20 20:02:29 -04:00
XtraCube 992bdbcbf8 cleanup usings 2026-07-20 19:10:06 -04:00
XtraCube f9721a8d69 improve stability and FPS on 17.4+ 2026-07-20 19:06:52 -04:00
XtraCube e541840da9 improve lag issues in settings menu on 17.4 2026-07-20 16:35:52 -04:00
Atony eb18d82d8e Allow overriding configuration on modded option 2026-07-17 21:34:10 -05:00
Atony 7afd899e56 Improve example options 2026-07-17 15:47:53 -05:00
Atony 5cccc192b1 Add support for better option notfs 2026-07-17 15:07:40 -05:00
Atony 9d7e41a3c9 Fix duplicated Populate Results Event 2026-07-09 23:03:02 -05:00
Atony 662b52f78d Allow populated votes to be modified 2026-07-09 22:57:59 -05:00
Atony dac1d82d5c Reduce heavy garbage collection temporarily 2026-07-09 22:57:31 -05:00
Atony 1b718092ee Move GC clearing out of coroutines 2026-07-08 18:13:34 -05:00
Atony 3eb0a4fdb3 Fix some instant crashing
Happens very quickly on practice mode when spam switching tasks
2026-07-08 17:31:20 -05:00
Atony 850e82155c Improve tmp offsets 2026-07-01 23:39:57 -05:00
Atony ff30d5fdd6 Add tmp sprite scaling support 2026-07-01 20:30:44 -05:00
Atony 2eecba2e51 Add TMP icon support for roles 2026-07-01 19:57:29 -05:00
Atony 84321f290e Fix game option checks 2026-06-30 16:25:53 -05:00
Atony d8d3cc202a Merge pull request #94 from All-Of-Us-Mods/dev
MiraAPI v0.4.1
2026-06-29 09:22:38 -05:00
Atony e08e7e5f4b Merge branch 'master' into dev 2026-06-29 09:22:03 -05:00
Atony a5f0ed5975 Bump version 2026-06-29 09:13:24 -05:00
Atony d1f5e56cb9 Merge pull request #93 from TheDavSmasher/documentation-improvement
Documentation improvement
2026-06-29 09:12:15 -05:00
Atony 127e3f600e Fix misc warnings 2026-06-29 09:05:35 -05:00
Atony 47e02d3dcf Add documentation for menu categories 2026-06-29 08:47:21 -05:00
Atony f53e4fdc38 Add more option documentation 2026-06-29 08:44:56 -05:00
Atony b1f0ec6da3 Fix settings button breaking 2026-06-28 21:15:30 -05:00
Atony d0d5056e39 Fix hat tab being severely broken on v17.4 2026-06-28 20:30:28 -05:00
Atony 57e3f20cba Improve role option garbage collection further 2026-06-27 21:00:57 -05:00
David Higueros 7fdfd506e0 Added missing method cref 2026-06-23 21:18:05 -06:00
David Higueros edf61e722f Updated added method 2026-06-23 21:17:43 -06:00
David Higueros 791daa08ad Merge branch 'dev' into documentation-improvement 2026-06-23 21:08:22 -06:00
David Higueros e4d2509895 Added href tags for links 2026-06-23 21:01:45 -06:00
David Higueros 62c8e27535 Fixed annotations with double > annotations 2026-06-23 20:55:47 -06:00
David Higueros 8852c014ab Replaced true, false, and null with langword annotations 2026-06-23 20:54:23 -06:00
David Higueros adb9a2823d Updated docstrings to reference classes, fields, and methods directly 2026-06-23 20:43:32 -06:00
Atony ff658db6f1 Remove destroyable singletons 2026-06-20 15:08:22 -05:00
Atony 750e00d06d Run GC when destroying multiple objects 2026-06-20 14:53:45 -05:00
Atony 3a5a397846 Only run gc when using v17.4 2026-06-20 14:28:08 -05:00
David Higueros c846109d07 Changed to use obsolete annotation 2026-06-19 17:07:31 -06:00
Atony e3b0eb68c0 Temporary measures for clearing up memory leaks 2026-06-12 18:03:13 -05:00
amber 90921ff786 Remove UseVanillaVentButton as it's unnecessary 2026-06-11 22:37:10 -04:00
amber c1d0bb5d26 Seperate vanilla vent data receiving from the actual button 2026-06-11 22:34:27 -04:00
Atony c59ed8eaa6 Fix screenshake within options menu 2026-05-31 09:17:26 -05:00
Atony d2fafc3650 Fix errors in How to Play menu 2026-05-04 09:55:37 -05:00
Atony 0c0157fed2 Add soft-support for Corsac Cosmetics 2026-05-04 07:43:53 -05:00
Atony 90bf402cbc Fix UI resizing with the top right buttons 2026-05-03 11:57:04 -05:00
Atony 245f2e6919 Merge pull request #83 from All-Of-Us-Mods/dev
## What's Changed
- Guardian Angel protection is checked properly.
- The Options Menu no longer throws errors on Android
- Framerate slider applies properly on PC again
- StateMachineWrapper now allows overriding existing states and returns for Coroutines.
2026-04-18 08:41:18 -05:00
Atony fed3abafb2 Bump version 2026-04-18 08:31:59 -05:00
Atony 925d47a275 Fix framerate slider 2026-04-18 08:29:11 -05:00
Atony 45a3597ab2 Update dependencies 2026-04-04 20:50:27 -05:00
Chipseq faeb39d3de use AccessTools to allow any method to be an event handler 2026-04-04 22:05:41 +02:00
Atony 6b46cffe5e Add isKilling check for basic kills 2026-04-03 20:31:27 -05:00
Atony 00a60bb7ad Add methods for StateMachineWrapper 2026-04-03 09:46:44 -05:00
Atony d89bce6956 Merge branch 'master' into dev 2026-04-01 21:33:21 -05:00
Atony 7f92e94293 Fix options menu error on mobile 2026-04-01 21:30:28 -05:00
Atony 6199e55110 Add Guardian Angel protection checks 2026-04-01 21:30:19 -05:00
Pietro420 eac442443b Random Snapshot for kill anim 2026-03-29 22:34:43 -03:00
Pietro420 6321753ec0 Don't use nullable for kill anim 2026-03-29 22:26:07 -03:00
XtraCube e66d45bd21 revert ID change for now 2026-03-23 19:33:16 -04:00
XtraCube 1e00181220 Change plugin identifier for Mira API 2026-03-23 12:07:08 -04:00
Atony fcd7856571 Merge pull request #82 from All-Of-Us-Mods/dev
MiraAPI 0.3.9
2026-03-21 16:25:04 -05:00
Atony 5680d27db1 Merge branch 'master' into dev 2026-03-21 16:22:27 -05:00
Atony 49d77fcf40 Fix issues with PlayerControl.Die race condition 2026-03-11 15:40:50 -05:00
Atony dcb4a3876f Fix neutral color in view pane 2026-03-11 00:23:32 -05:00
XtraCube 6cc1d4b762 updated readme 2026-02-27 12:11:41 -05:00
Atony 9dfad78df6 Merge pull request #81 from All-Of-Us-Mods/dev
MiraAPI 0.3.8
2026-02-11 11:50:15 -06:00
Atony e8536e5d4b Merge pull request #80 from All-Of-Us-Mods/dev
## What's New
- Individual game options can be reset if they are a part of a preset.
- A new meeting-specific murder rpc is now available for use, checking for kills happening within and outside of a meeting.
- ## What's Changed
- Framerate Slider has been renamed to be more accurate
- Memory usage per frame has been improved
2026-02-08 16:30:05 -06:00
Atony 50030c113b Merge pull request #78 from All-Of-Us-Mods/dev
## What's New
- Screen shake no longer interferes with scrolling in the host options menu
## What's Changed
- Sabotage flashes no longer break on Starlight
- Using the button scale setting no longer breaks the UI.
- If a role fails to register to a marshalling error (nullables) the game will no longer crash.
2026-01-04 12:41:46 -06:00
Atony fe3bfcdbc4 Merge pull request #77 from All-Of-Us-Mods/dev
- Added Vanilla Button Click Event (and respective Cancel Event)
- Added accessibility settings for sabotage flashes and blares
- Added an in-game slider for resizing ability buttons
2025-12-28 18:00:57 -06:00
Atony 7ad003ed1e Merge pull request #75 from All-Of-Us-Mods/dev
- Adds custom game tabs, with their own names and description blurbs.
- All keybinds have been moved to the right for consistency and to prevent hide and seek vent uses being obscured.
- Holding shift will change most options to be split in half, like 2.5s -> 1.25s
- Vanilla roles can be blacklisted from spawning or appearing in menus via other mira mods.
- Roles can check if they can spawn on the current gamemode or under specific conditions, such as the current map.
- Adds options that can have customizable text for -1 and 0 values respectively.
- Adds support for modded roles in Hide and Seek
- Fixes vanilla roles bypassing murder attempts
- Fixes keybinds not being hidden on buttons
- Fixes buttons used via keybinds bypassing ButtonClickEvents
- Fixes crashing for Epic Games users when opening the keybinds menu.
2025-12-14 07:58:01 -06:00
Atony 056a9b6102 Merge pull request #72 from All-Of-Us-Mods/dev
Fix Logger error for v0.3.3
2025-10-14 13:53:21 -05:00
Atony ae917a9c77 Merge pull request #71 from All-Of-Us-Mods/dev
MiraAPI v0.3.3
2025-10-14 13:46:58 -05:00
Atony fc9e9740be Merge pull request #70 from All-Of-Us-Mods/dev
MiraAPI v0.3.2
2025-10-14 09:08:53 -05:00
Atony f9096b6160 Merge pull request #69 from All-Of-Us-Mods/dev
MiraAPI v0.3.1
2025-09-28 13:17:06 -05:00
195 changed files with 2101 additions and 1527 deletions

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
<Project> <Project>
<ItemGroup> <ItemGroup>
<PackageReference Include="Reactor" Version="2.3.1" /> <PackageReference Include="Reactor" Version="2.5.0-ci.371" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" /> <PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2025.10.14" PrivateAssets="all" /> <PackageReference Include="AmongUs.GameLibs.Steam" Version="2026.3.31" PrivateAssets="all" />
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" /> <PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" /> <PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
+1 -1
View File
@@ -8,7 +8,7 @@
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<VersionPrefix>0.3.8</VersionPrefix> <VersionPrefix>0.4.2</VersionPrefix>
<VersionSuffix>dev</VersionSuffix> <VersionSuffix>dev</VersionSuffix>
<Authors>All Of Us, XtraCube, Angxl</Authors> <Authors>All Of Us, XtraCube, Angxl</Authors>
+1 -2
View File
@@ -1,5 +1,4 @@
using System.Linq; using BepInEx;
using BepInEx;
using BepInEx.Configuration; using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP;
using HarmonyLib; using HarmonyLib;
@@ -9,7 +9,7 @@ public class GeneralModifierOptions : AbstractOptionGroup
public override uint GroupPriority => 0; public override uint GroupPriority => 0;
public override bool ShowInModifiersMenu => true; public override MenuCategory ParentMenu => MenuCategory.Modifiers;
[ModdedToggleOption("Some Boolean Option")] [ModdedToggleOption("Some Boolean Option")]
public bool SomeBooleanOption { get; set; } = true; public bool SomeBooleanOption { get; set; } = true;
@@ -2,11 +2,17 @@
using MiraAPI.GameOptions; using MiraAPI.GameOptions;
using MiraAPI.GameOptions.Attributes; using MiraAPI.GameOptions.Attributes;
using MiraAPI.Utilities; using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
namespace MiraAPI.Example.Options.Roles; namespace MiraAPI.Example.Options.Roles;
public class FreezerRoleSettings : AbstractOptionGroup<FreezerRole> public class FreezerRoleSettings : AbstractOptionGroup<FreezerRole>
{ {
public override OptionNotifConfiguration Configuration => new(
Palette.Blue,
TmpSpriteUtils.CreateSpriteAsset(
MiraAssets.ImpostorFile.LoadAsset(),
"ApiExample.Role.Impostor.FreezerRole"));
public override string GroupName => "Custom Role"; public override string GroupName => "Custom Role";
[ModdedNumberOption("Freeze Duration", 1, 15, 1, MiraNumberSuffixes.Seconds)] [ModdedNumberOption("Freeze Duration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
namespace MiraAPI.Example.Options.Roles; namespace MiraAPI.Example.Options.Roles;
public class TeleporterOptions : AbstractOptionGroup<TeleporterRole> public class TeleporterOptions : AbstractRoleOptionGroup<TeleporterRole>
{ {
public override string GroupName => "Teleporter"; public override string GroupName => "Teleporter";
+3
View File
@@ -1,6 +1,7 @@
using AmongUs.GameOptions; using AmongUs.GameOptions;
using MiraAPI.Patches.Stubs; using MiraAPI.Patches.Stubs;
using MiraAPI.Roles; using MiraAPI.Roles;
using MiraAPI.Utilities.Assets;
using Reactor.Utilities; using Reactor.Utilities;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@@ -20,6 +21,8 @@ public class ChameloenRole : CrewmateRole, ICustomRole
public CustomRoleConfiguration Configuration => new(this) public CustomRoleConfiguration Configuration => new(this)
{ {
OptionsScreenshot = ExampleAssets.Banner, OptionsScreenshot = ExampleAssets.Banner,
Icon = MiraAssets.CrewmateFile,
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.CrewmateFile.LoadAsset(), "ApiExample.Role.Impostor.ChameleonRole"),
IntroSound = CustomRoleUtils.GetIntroSound(RoleTypes.Shapeshifter), IntroSound = CustomRoleUtils.GetIntroSound(RoleTypes.Shapeshifter),
}; };
+3
View File
@@ -1,4 +1,5 @@
using MiraAPI.Roles; using MiraAPI.Roles;
using MiraAPI.Utilities.Assets;
using UnityEngine; using UnityEngine;
namespace MiraAPI.Example.Roles; namespace MiraAPI.Example.Roles;
@@ -13,6 +14,8 @@ public class FreezerRole : ImpostorRole, ICustomRole
public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this) public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this)
{ {
Icon = MiraAssets.ImpostorFile,
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.ImpostorFile.LoadAsset(), "ApiExample.Role.Impostor.FreezerRole"),
OptionsScreenshot = ExampleAssets.Banner, OptionsScreenshot = ExampleAssets.Banner,
MaxRoleCount = 2, MaxRoleCount = 2,
}; };
+2 -2
View File
@@ -5,12 +5,12 @@ using HarmonyLib;
namespace MiraAPI.Colors; namespace MiraAPI.Colors;
/// <summary> /// <summary>
/// Used to register and track custom colors. /// Used to register and track <see cref="CustomColor"/>s.
/// </summary> /// </summary>
public static class PaletteManager public static class PaletteManager
{ {
/// <summary> /// <summary>
/// Gets all registered custom colors. /// Gets all registered <see cref="CustomColor"/>s.
/// </summary> /// </summary>
public static CustomColor[] RegisteredColors => [.. CustomColors]; public static CustomColor[] RegisteredColors => [.. CustomColors];
@@ -3,7 +3,7 @@
namespace MiraAPI.Colors; namespace MiraAPI.Colors;
/// <summary> /// <summary>
/// Used to mark a class for custom colors registration. /// Used to mark a class for <see cref="CustomColor"/> registration.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomColorsAttribute : Attribute; public class RegisterCustomColorsAttribute : Attribute;
@@ -3,20 +3,20 @@
namespace MiraAPI.Events.Mira; namespace MiraAPI.Events.Mira;
/// <summary> /// <summary>
/// Invoked when a Mira Button click is cancelled. Do not use for vanilla buttons. /// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary> /// </summary>
/// <typeparam name="T">The Mira Button type.</typeparam> /// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActionButton public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActionButton
{ {
/// <summary> /// <summary>
/// Gets Mira Button whose click was cancelled. /// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
/// </summary> /// </summary>
public T Button { get; } public T Button { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MiraButtonCancelledEvent{T}"/> class. /// Initializes a new instance of the <see cref="MiraButtonCancelledEvent{T}"/> class.
/// </summary> /// </summary>
/// <param name="button">The Mira Button whose click was cancelled.</param> /// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
public MiraButtonCancelledEvent(T button) public MiraButtonCancelledEvent(T button)
{ {
Button = button; Button = button;
@@ -24,19 +24,19 @@ public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActi
} }
/// <summary> /// <summary>
/// Invoked when a Mira Button click is cancelled. Do not use for vanilla buttons. /// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary> /// </summary>
public sealed class MiraButtonCancelledEvent : MiraEvent public sealed class MiraButtonCancelledEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets Mira Button whose click was cancelled. /// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
/// </summary> /// </summary>
public CustomActionButton Button { get; } public CustomActionButton Button { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MiraButtonCancelledEvent"/> class. /// Initializes a new instance of the <see cref="MiraButtonCancelledEvent"/> class.
/// </summary> /// </summary>
/// <param name="button">The Mira Button whose click was cancelled.</param> /// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
public MiraButtonCancelledEvent(CustomActionButton button) public MiraButtonCancelledEvent(CustomActionButton button)
{ {
Button = button; Button = button;
+9 -9
View File
@@ -3,26 +3,26 @@
namespace MiraAPI.Events.Mira; namespace MiraAPI.Events.Mira;
/// <summary> /// <summary>
/// Button click event for Mira Buttons only. Do not use for vanilla buttons. /// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary> /// </summary>
/// <typeparam name="T">The Mira Button type.</typeparam> /// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
{ {
/// <summary> /// <summary>
/// Gets Mira Button that was clicked. /// Gets the <see cref="CustomActionButton"/> that was clicked.
/// </summary> /// </summary>
public T Button { get; } public T Button { get; }
/// <summary> /// <summary>
/// Gets the generic click event that is invoked before this button-specific event. /// Gets the generic <see cref="MiraButtonClickEvent"/> that is invoked before this button-specific event.
/// </summary> /// </summary>
public MiraButtonClickEvent GenericClickEvent { get; } public MiraButtonClickEvent GenericClickEvent { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MiraButtonClickEvent{T}"/> class. /// Initializes a new instance of the <see cref="MiraButtonClickEvent{T}"/> class.
/// </summary> /// </summary>
/// <param name="button">The Mira Button that was clicked.</param> /// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
/// <param name="genericClickEvent">The generic click event invoked before button-specific events.</param> /// <param name="genericClickEvent">The generic <see cref="MiraButtonClickEvent"/> invoked before button-specific events.</param>
public MiraButtonClickEvent(T button, MiraButtonClickEvent genericClickEvent) public MiraButtonClickEvent(T button, MiraButtonClickEvent genericClickEvent)
{ {
GenericClickEvent = genericClickEvent; GenericClickEvent = genericClickEvent;
@@ -31,19 +31,19 @@ public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : Cust
} }
/// <summary> /// <summary>
/// Button click event for Mira Buttons only. Do not use for vanilla buttons. /// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary> /// </summary>
public sealed class MiraButtonClickEvent : MiraCancelableEvent public sealed class MiraButtonClickEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets Mira Button that was clicked. /// Gets the <see cref="CustomActionButton"/> that was clicked.
/// </summary> /// </summary>
public CustomActionButton Button { get; } public CustomActionButton Button { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MiraButtonClickEvent"/> class. /// Initializes a new instance of the <see cref="MiraButtonClickEvent"/> class.
/// </summary> /// </summary>
/// <param name="button">The Mira Button that was clicked.</param> /// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
public MiraButtonClickEvent(CustomActionButton button) public MiraButtonClickEvent(CustomActionButton button)
{ {
Button = button; Button = button;
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Events; namespace MiraAPI.Events;
/// <summary> /// <summary>
/// Event handle to use when unregistering an event. /// Event handle to use when unregistering a <see cref="MiraEvent"/>.
/// </summary> /// </summary>
public class MiraEventHandle public class MiraEventHandle
{ {
+15 -16
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Reactor.Utilities;
namespace MiraAPI.Events; namespace MiraAPI.Events;
@@ -13,11 +12,11 @@ public static class MiraEventManager
private static readonly Dictionary<Type, List<MiraEventWrapper>> EventWrappers = []; private static readonly Dictionary<Type, List<MiraEventWrapper>> EventWrappers = [];
/// <summary> /// <summary>
/// Invoke an event. /// Invoke a <see cref="MiraEvent"/>.
/// </summary> /// </summary>
/// <param name="eventInstance">The event instance.</param> /// <param name="eventInstance">The <typeparamref name="T"/> instance.</param>
/// <typeparam name="T">Type of Event.</typeparam> /// <typeparam name="T">Type of Event.</typeparam>
/// <returns>If there was an event handler invoked for this event, return true. Otherwise, return false.</returns> /// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
public static bool InvokeEvent<T>(T eventInstance) where T : MiraEvent public static bool InvokeEvent<T>(T eventInstance) where T : MiraEvent
{ {
EventWrappers.TryGetValue(typeof(T), out var handlers); EventWrappers.TryGetValue(typeof(T), out var handlers);
@@ -42,11 +41,11 @@ public static class MiraEventManager
} }
/// <summary> /// <summary>
/// Invoke an event and use a specific type to find the handlers. /// Invoke a <see cref="MiraEvent"/> and use a specific type to find the handlers.
/// </summary> /// </summary>
/// <param name="eventInstance">The event instance.</param> /// <param name="eventInstance">The <see cref="MiraEvent"/> instance.</param>
/// <param name="type">The type to use for handler lookup.</param> /// <param name="type">The type to use for handler lookup.</param>
/// <returns>If there was an event handler invoked for this event, return true. Otherwise, return false.</returns> /// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
public static bool InvokeEvent(MiraEvent eventInstance, Type type) public static bool InvokeEvent(MiraEvent eventInstance, Type type)
{ {
EventWrappers.TryGetValue(type, out var handlers); EventWrappers.TryGetValue(type, out var handlers);
@@ -71,12 +70,12 @@ public static class MiraEventManager
} }
/// <summary> /// <summary>
/// Register an event. /// Register a <see cref="MiraEvent"/> handler.
/// </summary> /// </summary>
/// <param name="type">The type of event.</param> /// <param name="type">The type of <see cref="MiraEvent"/> event.</param>
/// <param name="methodInfo">The MethodInfo of the event handler.</param> /// <param name="methodInfo">The <see cref="MethodInfo"/> of the event handler.</param>
/// <param name="priority">The priority of the event handler. Lower values are called first.</param> /// <param name="priority">The priority of the event handler. Lower values are called first.</param>
/// <returns>An event handle to use when unregistering the event.</returns> /// <returns>A <see cref="MiraEventHandle"/> to use when unregistering the event.</returns>
public static MiraEventHandle RegisterEventHandler(Type type, MethodInfo methodInfo, int priority = 0) public static MiraEventHandle RegisterEventHandler(Type type, MethodInfo methodInfo, int priority = 0)
{ {
if (!type.IsSubclassOf(typeof(MiraEvent))) if (!type.IsSubclassOf(typeof(MiraEvent)))
@@ -102,12 +101,12 @@ public static class MiraEventManager
} }
/// <summary> /// <summary>
/// Register an event. /// Register a <typeparamref name="T"/> handler.
/// </summary> /// </summary>
/// <param name="handler">The callback method/handler for the event.</param> /// <param name="handler">The callback method/handler for the event.</param>
/// <param name="priority">The priority of the event handler. Lower values are called first.</param> /// <param name="priority">The priority of the event handler. Lower values are called first.</param>
/// <typeparam name="T">Type of event.</typeparam> /// <typeparam name="T">Type of <see cref="MiraEvent"/> event.</typeparam>
/// <returns>An event handle to use when unregistering the event.</returns> /// <returns>A <see cref="MiraEventHandle"/> to use when unregistering the event.</returns>
public static MiraEventHandle RegisterEventHandler<T>(Action<T> handler, int priority = 0) where T : MiraEvent public static MiraEventHandle RegisterEventHandler<T>(Action<T> handler, int priority = 0) where T : MiraEvent
{ {
EventWrappers.TryAdd(typeof(T), []); EventWrappers.TryAdd(typeof(T), []);
@@ -127,10 +126,10 @@ public static class MiraEventManager
} }
/// <summary> /// <summary>
/// Unregister an event using the event handle. /// Unregister a <see cref="MiraEvent"/> handler using the <see cref="MiraEventHandle"/>.
/// </summary> /// </summary>
/// <param name="eventHandle">A handle to the event.</param> /// <param name="eventHandle">A handle to the event.</param>
/// <returns>True if the event was unregistered successfully, false otherwise.</returns> /// <returns><see langword="true"/> if the event was unregistered successfully, <see langword="false"/> otherwise.</returns>
public static bool UnregisterEventHandler(MiraEventHandle eventHandle) public static bool UnregisterEventHandler(MiraEventHandle eventHandle)
{ {
if (!EventWrappers.TryGetValue(eventHandle.EventType, out var handlers)) if (!EventWrappers.TryGetValue(eventHandle.EventType, out var handlers))
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Events; namespace MiraAPI.Events;
/// <summary> /// <summary>
/// Wrapper for event handlers. /// Wrapper for <see cref="MiraEvent"/> handlers.
/// </summary> /// </summary>
public class MiraEventWrapper public class MiraEventWrapper
{ {
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Events; namespace MiraAPI.Events;
/// <summary> /// <summary>
/// Register an event. /// Register a <see cref="MiraEvent"/> handler.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class RegisterEventAttribute : Attribute public class RegisterEventAttribute : Attribute
@@ -6,17 +6,17 @@
public class AfterMurderEvent : MiraEvent public class AfterMurderEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the player that killed the target. /// Gets the <see cref="PlayerControl"/> that killed the <see cref="Target"/>.
/// </summary> /// </summary>
public PlayerControl Source { get; } public PlayerControl Source { get; }
/// <summary> /// <summary>
/// Gets the player that was killed. /// Gets the <see cref="PlayerControl"/> that was killed.
/// </summary> /// </summary>
public PlayerControl Target { get; } public PlayerControl Target { get; }
/// <summary> /// <summary>
/// Gets the player's body, if it exists. /// Gets the <see cref="Target"/>'s <see cref="global::DeadBody"/>, if it exists.
/// </summary> /// </summary>
public DeadBody? DeadBody { get; } public DeadBody? DeadBody { get; }
@@ -24,8 +24,8 @@ public class AfterMurderEvent : MiraEvent
/// Initializes a new instance of the <see cref="AfterMurderEvent"/> class. /// Initializes a new instance of the <see cref="AfterMurderEvent"/> class.
/// </summary> /// </summary>
/// <param name="source">The killer.</param> /// <param name="source">The killer.</param>
/// <param name="target">The killed player.</param> /// <param name="target">The killed <see cref="PlayerControl"/>.</param>
/// <param name="deadBody">The player's vody, if it exists.</param> /// <param name="deadBody">The <paramref name="target"/>'s <see cref="global::DeadBody"/>, if it exists.</param>
public AfterMurderEvent(PlayerControl source, PlayerControl target, DeadBody? deadBody) public AfterMurderEvent(PlayerControl source, PlayerControl target, DeadBody? deadBody)
{ {
Source = source; Source = source;
@@ -1,7 +1,7 @@
namespace MiraAPI.Events.Vanilla.Gameplay; namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary> /// <summary>
/// Invoked before RpcEndGame is called, allowing cancellation of the game end entirely. /// Invoked before <see cref="GameManager.RpcEndGame"/> is called, allowing cancellation of the game end entirely.
/// </summary> /// </summary>
public class BeforeGameEndEvent : MiraCancelableEvent public class BeforeGameEndEvent : MiraCancelableEvent
{ {
@@ -8,25 +8,25 @@ namespace MiraAPI.Events.Vanilla.Gameplay;
public sealed class BeforeMurderEvent : MiraCancelableEvent public sealed class BeforeMurderEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets the player that is killing the target. /// Gets the <see cref="PlayerControl"/> that is killing the <see cref="Target"/>.
/// </summary> /// </summary>
public PlayerControl Source { get; } public PlayerControl Source { get; }
/// <summary> /// <summary>
/// Gets the player that is being killed. /// Gets the <see cref="PlayerControl"/> that is being killed.
/// </summary> /// </summary>
public PlayerControl Target { get; } public PlayerControl Target { get; }
/// <summary> /// <summary>
/// Gets whether the murder was meant to be done in a meeting via an enum. /// Gets whether the murder was meant to be done in a meeting, via an enum.
/// </summary> /// </summary>
public MeetingCheck InMeeting { get; } public MeetingCheck InMeeting { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class. /// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
/// </summary> /// </summary>
/// <param name="source">The player that is killing the target.</param> /// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
/// <param name="target">The player that is being killed.</param> /// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
/// <param name="inMeeting">Whether the murder is intended to be triggered in a meeting.</param> /// <param name="inMeeting">Whether the murder is intended to be triggered in a meeting.</param>
public BeforeMurderEvent(PlayerControl source, PlayerControl target, MeetingCheck inMeeting) public BeforeMurderEvent(PlayerControl source, PlayerControl target, MeetingCheck inMeeting)
{ {
@@ -38,8 +38,8 @@ public sealed class BeforeMurderEvent : MiraCancelableEvent
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class. /// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
/// </summary> /// </summary>
/// <param name="source">The player that is killing the target.</param> /// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
/// <param name="target">The player that is being killed.</param> /// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
public BeforeMurderEvent(PlayerControl source, PlayerControl target) public BeforeMurderEvent(PlayerControl source, PlayerControl target)
{ {
Source = source; Source = source;
@@ -1,12 +1,13 @@
namespace MiraAPI.Events.Vanilla.Gameplay; namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary> /// <summary>
/// Event invoked on IntroCutscene.OnDestroy and ExileController.WrapUp to determine if it should run the round event or not. /// Event invoked on <see cref="IntroCutscene.OnDestroy"/> and <see cref="ExileController.WrapUp"/>
/// to determine if it should run the <see cref="RoundStartEvent"/> event or not.
/// </summary> /// </summary>
public class BeforeRoundStartEvent : MiraCancelableEvent public class BeforeRoundStartEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController. /// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
/// </summary> /// </summary>
public bool TriggeredByIntro { get; } public bool TriggeredByIntro { get; }
@@ -6,14 +6,14 @@
public class GameEndEvent : MiraEvent public class GameEndEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the EndGameManager. /// Gets the <see cref="global::EndGameManager"/> instance.
/// </summary> /// </summary>
public EndGameManager EndGameManager { get; } public EndGameManager EndGameManager { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GameEndEvent"/> class. /// Initializes a new instance of the <see cref="GameEndEvent"/> class.
/// </summary> /// </summary>
/// <param name="manager">The instance of the EndGameManager.</param> /// <param name="manager">The <see cref="global::EndGameManager"/> instance.</param>
public GameEndEvent(EndGameManager manager) public GameEndEvent(EndGameManager manager)
{ {
EndGameManager = manager; EndGameManager = manager;
@@ -6,7 +6,7 @@
public class IntroBeginEvent : MiraEvent public class IntroBeginEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the IntroCutscene. /// Gets the <see cref="global::IntroCutscene"/> instance.
/// </summary> /// </summary>
public IntroCutscene IntroCutscene { get; } public IntroCutscene IntroCutscene { get; }
@@ -6,7 +6,7 @@
public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the IntroCutscene. /// Gets the <see cref="global::IntroCutscene"/> instance.
/// </summary> /// </summary>
public IntroCutscene IntroCutscene { get; } = introCutscene; public IntroCutscene IntroCutscene { get; } = introCutscene;
} }
@@ -6,7 +6,7 @@
public class IntroRoleRevealEvent : MiraEvent public class IntroRoleRevealEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the IntroCutscene. /// Gets the <see cref="global::IntroCutscene"/> instance.
/// </summary> /// </summary>
public IntroCutscene IntroCutscene { get; } public IntroCutscene IntroCutscene { get; }
@@ -1,12 +1,13 @@
namespace MiraAPI.Events.Vanilla.Gameplay; namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary> /// <summary>
/// Start Round event, invoked on IntroCutscene.OnDestroy and ExileController.WrapUp if the event isn't cancelled. /// Start Round event, invoked on <see cref="IntroCutscene.OnDestroy"/> and <see cref="ExileController.WrapUp"/>
/// if the <see cref="BeforeRoundStartEvent"/> isn't cancelled.
/// </summary> /// </summary>
public class RoundStartEvent : MiraEvent public class RoundStartEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController. /// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
/// </summary> /// </summary>
public bool TriggeredByIntro { get; } public bool TriggeredByIntro { get; }
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Gameplay;
public class SetRoleEvent : MiraEvent public class SetRoleEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the player whos role was changed. /// Gets the <see cref="PlayerControl"/> whose role was changed.
/// </summary> /// </summary>
public PlayerControl Player { get; } public PlayerControl Player { get; }
@@ -3,20 +3,20 @@
namespace MiraAPI.Events.Vanilla.Gameplay; namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary> /// <summary>
/// Invoked when a Vanilla Button click is cancelled. Do not use for custom buttons. /// Invoked when a Vanilla <see cref="AbilityButton"/> click is cancelled. Do not use for <see cref="CustomActionButton"/>.
/// </summary> /// </summary>
/// <typeparam name="T">The Vanilla Button type.</typeparam> /// <typeparam name="T">The vanilla <see cref="AbilityButton"/> type.</typeparam>
public sealed class VanillaButtonCancelledEvent<T> : MiraEvent where T : AbilityButton public sealed class VanillaButtonCancelledEvent<T> : MiraEvent where T : AbilityButton
{ {
/// <summary> /// <summary>
/// Gets Vanilla Button whose click was cancelled. /// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
/// </summary> /// </summary>
public T Button { get; } public T Button { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent{T}"/> class. /// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent{T}"/> class.
/// </summary> /// </summary>
/// <param name="button">The Mira Button whose click was cancelled.</param> /// <param name="button">The vanilla <see cref="AbilityButton"/> whose click was cancelled.</param>
public VanillaButtonCancelledEvent(T button) public VanillaButtonCancelledEvent(T button)
{ {
Button = button; Button = button;
@@ -24,19 +24,19 @@ public sealed class VanillaButtonCancelledEvent<T> : MiraEvent where T : Ability
} }
/// <summary> /// <summary>
/// Invoked when a Vanilla Button click is cancelled. Do not use for custom buttons. /// Invoked when a Vanilla <see cref="AbilityButton"/> click is cancelled. Do not use for <see cref="CustomActionButton"/>s.
/// </summary> /// </summary>
public sealed class VanillaButtonCancelledEvent : MiraEvent public sealed class VanillaButtonCancelledEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets Vanilla Button whose click was cancelled. /// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
/// </summary> /// </summary>
public AbilityButton Button { get; } public AbilityButton Button { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent"/> class. /// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent"/> class.
/// </summary> /// </summary>
/// <param name="button">The Vanilla Button whose click was cancelled.</param> /// <param name="button">The vanilla <see cref="AbilityButton"/> whose click was cancelled.</param>
public VanillaButtonCancelledEvent(AbilityButton button) public VanillaButtonCancelledEvent(AbilityButton button)
{ {
Button = button; Button = button;
@@ -3,26 +3,26 @@
namespace MiraAPI.Events.Vanilla.Gameplay; namespace MiraAPI.Events.Vanilla.Gameplay;
/// <summary> /// <summary>
/// Button click event for Vanilla Buttons only. Do not use for custom buttons. /// Button click event for Vanilla <see cref="AbilityButton"/>s only. Do not use for <see cref="CustomActionButton"/>s.
/// </summary> /// </summary>
/// <typeparam name="T">The Vanilla Button type.</typeparam> /// <typeparam name="T">The vanilla <see cref="AbilityButton"/> type.</typeparam>
public sealed class VanillaButtonClickEvent<T> : MiraCancelableEvent where T : AbilityButton public sealed class VanillaButtonClickEvent<T> : MiraCancelableEvent where T : AbilityButton
{ {
/// <summary> /// <summary>
/// Gets Vanilla Button that was clicked. /// Gets the vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary> /// </summary>
public T Button { get; } public T Button { get; }
/// <summary> /// <summary>
/// Gets the generic click event that is invoked before this button-specific event. /// Gets the generic <see cref="VanillaButtonClickEvent"/> that is invoked before this button-specific event.
/// </summary> /// </summary>
public VanillaButtonClickEvent GenericClickEvent { get; } public VanillaButtonClickEvent GenericClickEvent { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent{T}"/> class. /// Initializes a new instance of the <see cref="VanillaButtonClickEvent{T}"/> class.
/// </summary> /// </summary>
/// <param name="button">The Mira Button that was clicked.</param> /// <param name="button">The vanilla <see cref="AbilityButton"/> that was clicked.</param>
/// <param name="genericClickEvent">The generic click event invoked before button-specific events.</param> /// <param name="genericClickEvent">The generic <see cref="VanillaButtonClickEvent"/> invoked before button-specific events.</param>
public VanillaButtonClickEvent(T button, VanillaButtonClickEvent genericClickEvent) public VanillaButtonClickEvent(T button, VanillaButtonClickEvent genericClickEvent)
{ {
GenericClickEvent = genericClickEvent; GenericClickEvent = genericClickEvent;
@@ -31,31 +31,31 @@ public sealed class VanillaButtonClickEvent<T> : MiraCancelableEvent where T : A
} }
/// <summary> /// <summary>
/// Button click event for Vanilla Buttons only. Do not use for custom buttons. /// Button click event for Vanilla <see cref="AbilityButton"/> only. Do not use for <see cref="CustomActionButton"/>s.
/// </summary> /// </summary>
public sealed class VanillaButtonClickEvent : MiraCancelableEvent public sealed class VanillaButtonClickEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets Vanilla Button that was clicked. /// Gets the Vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary> /// </summary>
public AbilityButton Button { get; } public AbilityButton Button { get; }
/// <summary> /// <summary>
/// Gets the target player, if any, of the Vanilla Button that was clicked. /// Gets the target <see cref="PlayerControl"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary> /// </summary>
public PlayerControl? PlayerTarget { get; } public PlayerControl? PlayerTarget { get; }
/// <summary> /// <summary>
/// Gets the target vent, if any, of the Vanilla Button that was clicked. /// Gets the target <see cref="Vent"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
/// </summary> /// </summary>
public Vent? VentTarget { get; } public Vent? VentTarget { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent"/> class. /// Initializes a new instance of the <see cref="VanillaButtonClickEvent"/> class.
/// </summary> /// </summary>
/// <param name="button">The Vanilla Button that was clicked.</param> /// <param name="button">The Vanilla <see cref="AbilityButton"/> that was clicked.</param>
/// <param name="playerTarget">The Player target, if any.</param> /// <param name="playerTarget">The <see cref="PlayerControl"/> target, if any.</param>
/// <param name="ventTarget">The Vent target, if any.</param> /// <param name="ventTarget">The <see cref="Vent"/> target, if any.</param>
public VanillaButtonClickEvent(AbilityButton button, PlayerControl? playerTarget = null, Vent? ventTarget = null) public VanillaButtonClickEvent(AbilityButton button, PlayerControl? playerTarget = null, Vent? ventTarget = null)
{ {
Button = button; Button = button;
@@ -6,14 +6,14 @@
public class PlayerOpenSabotageEvent : MiraCancelableEvent public class PlayerOpenSabotageEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets the MapBehaviour. /// Gets the <see cref="global::MapBehaviour"/>.
/// </summary> /// </summary>
public MapBehaviour MapBehaviour { get; } public MapBehaviour MapBehaviour { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PlayerOpenSabotageEvent"/> class. /// Initializes a new instance of the <see cref="PlayerOpenSabotageEvent"/> class.
/// </summary> /// </summary>
/// <param name="mapBehaviour">The MapBehaviour.</param> /// <param name="mapBehaviour">The <see cref="global::MapBehaviour"/>.</param>
public PlayerOpenSabotageEvent(MapBehaviour mapBehaviour) public PlayerOpenSabotageEvent(MapBehaviour mapBehaviour)
{ {
MapBehaviour = mapBehaviour; MapBehaviour = mapBehaviour;
@@ -1,7 +1,7 @@
namespace MiraAPI.Events.Vanilla.Map; namespace MiraAPI.Events.Vanilla.Map;
/// <summary> /// <summary>
/// Cancelable event that is invoked before a system is updated. Usually used for sabotage events. /// <see cref="MiraCancelableEvent"/> that is invoked before a system is updated. Usually used for sabotage events.
/// </summary> /// </summary>
public class UpdateSystemEvent : MiraCancelableEvent public class UpdateSystemEvent : MiraCancelableEvent
{ {
@@ -11,7 +11,7 @@ public class UpdateSystemEvent : MiraCancelableEvent
public SystemTypes SystemType { get; } public SystemTypes SystemType { get; }
/// <summary> /// <summary>
/// Gets the player that is updating the system. /// Gets the <see cref="PlayerControl"/> that is updating the system.
/// </summary> /// </summary>
public PlayerControl Player { get; } public PlayerControl Player { get; }
@@ -21,10 +21,10 @@ public class UpdateSystemEvent : MiraCancelableEvent
public byte Amount { get; } public byte Amount { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class. /// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class.
/// </summary> /// </summary>
/// <param name="systemType">The SystemType being updated.</param> /// <param name="systemType">The <see cref="SystemTypes"/> being updated.</param>
/// <param name="player">The player that is updating the system.</param> /// <param name="player">The <see cref="PlayerControl"/> that is updating the system.</param>
/// <param name="amount">Amount to update System to.</param> /// <param name="amount">Amount to update System to.</param>
public UpdateSystemEvent(SystemTypes systemType, PlayerControl player, byte amount) public UpdateSystemEvent(SystemTypes systemType, PlayerControl player, byte amount)
{ {
@@ -6,14 +6,14 @@
public class EjectionEvent : MiraEvent public class EjectionEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the ExileController. /// Gets the <see cref="global::ExileController"/> instance.
/// </summary> /// </summary>
public ExileController ExileController { get; } public ExileController ExileController { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="EjectionEvent"/> class. /// Initializes a new instance of the <see cref="EjectionEvent"/> class.
/// </summary> /// </summary>
/// <param name="controller">The exile controller.</param> /// <param name="controller">The <see cref="global::ExileController"/> instance.</param>
public EjectionEvent(ExileController controller) public EjectionEvent(ExileController controller)
{ {
ExileController = controller; ExileController = controller;
@@ -6,7 +6,7 @@
public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the MeetingHud instance. /// Gets the <see cref="global::MeetingHud"/> instance.
/// </summary> /// </summary>
public MeetingHud MeetingHud { get; } = meetingHud; public MeetingHud MeetingHud { get; } = meetingHud;
} }
@@ -2,7 +2,7 @@
/// <summary> /// <summary>
/// The event that is invoked when a body is reported. /// The event that is invoked when a body is reported.
/// This is invoked in CmdReportBody. /// This is invoked in <see cref="PlayerControl.CmdReportDeadBody(NetworkedPlayerInfo)"/>.
/// </summary> /// </summary>
public class ReportBodyEvent : MiraCancelableEvent public class ReportBodyEvent : MiraCancelableEvent
{ {
@@ -12,12 +12,12 @@ public class ReportBodyEvent : MiraCancelableEvent
public PlayerControl Reporter { get; } public PlayerControl Reporter { get; }
/// <summary> /// <summary>
/// Gets the player that is being reported. Will be null for emergency meeting. /// Gets the player that is being reported. Will be <see langword="null"/> for emergency meeting.
/// </summary> /// </summary>
public NetworkedPlayerInfo? Target { get; } public NetworkedPlayerInfo? Target { get; }
/// <summary> /// <summary>
/// Gets the body that is being reported. Will be null for emergency meeting. /// Gets the <see cref="DeadBody"/> that is being reported. Will be <see langword="null"/> for emergency meeting.
/// </summary> /// </summary>
public DeadBody? Body { get; } public DeadBody? Body { get; }
@@ -26,7 +26,7 @@ public class ReportBodyEvent : MiraCancelableEvent
/// </summary> /// </summary>
/// <param name="reporter">The player who reported the body.</param> /// <param name="reporter">The player who reported the body.</param>
/// <param name="target">The player being reported.</param> /// <param name="target">The player being reported.</param>
/// <param name="body">The body being reported.</param> /// <param name="body">The <see cref="DeadBody"/> being reported.</param>
public ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body) public ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body)
{ {
Reporter = reporter; Reporter = reporter;
@@ -7,14 +7,14 @@
public class StartMeetingEvent : MiraEvent public class StartMeetingEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the MeetingHud instance. /// Gets the <see cref="global::MeetingHud"/> instance.
/// </summary> /// </summary>
public MeetingHud MeetingHud { get; } public MeetingHud MeetingHud { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="StartMeetingEvent"/> class. /// Initializes a new instance of the <see cref="StartMeetingEvent"/> class.
/// </summary> /// </summary>
/// <param name="meetingHud">The MeetingHud instance.</param> /// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
public StartMeetingEvent(MeetingHud meetingHud) public StartMeetingEvent(MeetingHud meetingHud)
{ {
MeetingHud = meetingHud; MeetingHud = meetingHud;
@@ -1,6 +1,4 @@
using MiraAPI.Voting; namespace MiraAPI.Events.Vanilla.Meeting.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary> /// <summary>
/// Event that is invoked after the local player successfully votes a player or skips. This event is not cancelable. /// Event that is invoked after the local player successfully votes a player or skips. This event is not cancelable.
@@ -8,7 +6,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
public class AfterVoteEvent : MiraEvent public class AfterVoteEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the voter's vote data. /// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
/// </summary> /// </summary>
public PlayerVoteArea VoteArea { get; } public PlayerVoteArea VoteArea { get; }
@@ -20,7 +18,7 @@ public class AfterVoteEvent : MiraEvent
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AfterVoteEvent"/> class. /// Initializes a new instance of the <see cref="AfterVoteEvent"/> class.
/// </summary> /// </summary>
/// <param name="playerVoteArea">The player vote area that was voted on.</param> /// <param name="playerVoteArea">The <see cref="PlayerVoteArea"/> that was voted on.</param>
/// <param name="voter">The player who voted.</param> /// <param name="voter">The player who voted.</param>
public AfterVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter) public AfterVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
{ {
@@ -1,6 +1,4 @@
using MiraAPI.Voting; namespace MiraAPI.Events.Vanilla.Meeting.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary> /// <summary>
/// Event that is invoked before the local player confirms a vote on a player or when skipping. This event is cancelable. /// Event that is invoked before the local player confirms a vote on a player or when skipping. This event is cancelable.
@@ -8,7 +6,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
public class BeforeVoteEvent : MiraCancelableEvent public class BeforeVoteEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the voter's vote data. /// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
/// </summary> /// </summary>
public PlayerVoteArea VoteArea { get; } public PlayerVoteArea VoteArea { get; }
@@ -20,7 +18,7 @@ public class BeforeVoteEvent : MiraCancelableEvent
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BeforeVoteEvent"/> class. /// Initializes a new instance of the <see cref="BeforeVoteEvent"/> class.
/// </summary> /// </summary>
/// <param name="playerVoteArea">The player vote area that was voted on.</param> /// <param name="playerVoteArea">The <see cref="PlayerVoteArea"/> that was voted on.</param>
/// <param name="voter">The player who voted.</param> /// <param name="voter">The player who voted.</param>
public BeforeVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter) public BeforeVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
{ {
@@ -18,7 +18,7 @@ public class CheckForEndVotingEvent : MiraCancelableEvent
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CheckForEndVotingEvent"/> class. /// Initializes a new instance of the <see cref="CheckForEndVotingEvent"/> class.
/// </summary> /// </summary>
/// <param name="isVotingComplete">>True if voting is complete, false otherwise.</param> /// <param name="isVotingComplete"><see langword="true"/> if voting is complete, <see langword="false"/> otherwise.</param>
public CheckForEndVotingEvent(bool isVotingComplete) public CheckForEndVotingEvent(bool isVotingComplete)
{ {
IsVotingComplete = isVotingComplete; IsVotingComplete = isVotingComplete;
@@ -15,7 +15,7 @@ public class DummyVoteEvent : MiraCancelableEvent
public DummyBehaviour Dummy { get; } public DummyBehaviour Dummy { get; }
/// <summary> /// <summary>
/// Gets the instance of the dummy's vote data. /// Gets the instance of the dummy's <see cref="PlayerVoteData"/>.
/// </summary> /// </summary>
public PlayerVoteData VoteData { get; } public PlayerVoteData VoteData { get; }
@@ -5,12 +5,12 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary> /// <summary>
/// The event that is invoked when Mira handles a vote. This is invoked before Mira's behaviour, so be cautious. /// The event that is invoked when Mira handles a vote. This is invoked before Mira's behaviour, so be cautious.
/// If you intend on adding custom vote behaviour, cancel the event and do so. /// If you intend on adding custom vote behaviour, cancel the event and do so.
/// If you are NOT canceling the event, keep in mind that Mira automatically removes a vote and adds the suspect to the VotedPlayers list after this event is invoked. /// If you are NOT canceling the event, keep in mind that Mira automatically removes a vote and adds the suspect to the <see cref="PlayerVoteData.Votes"/> list after this event is invoked.
/// </summary> /// </summary>
public class HandleVoteEvent : MiraCancelableEvent public class HandleVoteEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the voter's vote data. /// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
/// </summary> /// </summary>
public PlayerVoteData VoteData { get; } public PlayerVoteData VoteData { get; }
@@ -30,14 +30,14 @@ public class HandleVoteEvent : MiraCancelableEvent
public bool PreventVote { get; } public bool PreventVote { get; }
/// <summary> /// <summary>
/// Gets the player info of the target. /// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
/// </summary> /// </summary>
public NetworkedPlayerInfo TargetPlayerInfo { get; } public NetworkedPlayerInfo TargetPlayerInfo { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="HandleVoteEvent"/> class. /// Initializes a new instance of the <see cref="HandleVoteEvent"/> class.
/// </summary> /// </summary>
/// <param name="playerVoteData">The voter's data.</param> /// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
/// <param name="targetId">The target's playerId.</param> /// <param name="targetId">The target's playerId.</param>
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId) public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId)
{ {
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
public class MeetingSelectEvent : MiraEvent public class MeetingSelectEvent : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the instance of the voter's vote data. /// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
/// </summary> /// </summary>
public PlayerVoteData VoteData { get; } public PlayerVoteData VoteData { get; }
@@ -18,7 +18,7 @@ public class MeetingSelectEvent : MiraEvent
public int TargetId { get; } public int TargetId { get; }
/// <summary> /// <summary>
/// Gets the player info of the target. /// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
/// </summary> /// </summary>
public NetworkedPlayerInfo TargetPlayerInfo { get; } public NetworkedPlayerInfo TargetPlayerInfo { get; }
@@ -30,9 +30,9 @@ public class MeetingSelectEvent : MiraEvent
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MeetingSelectEvent"/> class. /// Initializes a new instance of the <see cref="MeetingSelectEvent"/> class.
/// </summary> /// </summary>
/// <param name="playerVoteData">The voter's data.</param> /// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
/// <param name="targetId">The target's playerId.</param> /// <param name="targetId">The target's playerId.</param>
/// <param name="allowSelect">>Whether the player is allowed to select the target.</param> /// <param name="allowSelect">Whether the player is allowed to select the target.</param>
public MeetingSelectEvent(PlayerVoteData playerVoteData, int targetId, bool allowSelect) public MeetingSelectEvent(PlayerVoteData playerVoteData, int targetId, bool allowSelect)
{ {
VoteData = playerVoteData; VoteData = playerVoteData;
@@ -4,20 +4,20 @@ using MiraAPI.Voting;
namespace MiraAPI.Events.Vanilla.Meeting.Voting; namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <summary> /// <summary>
/// Called in VotingUtils.HandlePopulateResults. /// Called in <see cref="VotingUtils.HandlePopulateResults"/>.
/// Cancelling is NOT advised but if you do plan on cancelling, please ensure you account for displaying ALL player's votes. /// Cancelling is NOT advised but if you do plan on cancelling, please ensure you account for displaying ALL player's votes.
/// </summary> /// </summary>
public class PopulateResultsEvent : MiraCancelableEvent public class PopulateResultsEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets a list of networked votes. /// Gets a list of networked <see cref="CustomVote"/>s.
/// </summary> /// </summary>
public List<CustomVote> Votes { get; } public List<CustomVote> Votes { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PopulateResultsEvent"/> class. /// Initializes a new instance of the <see cref="PopulateResultsEvent"/> class.
/// </summary> /// </summary>
/// <param name="votes">The list of votes.</param> /// <param name="votes">The list of <see cref="CustomVote"/>s.</param>
public PopulateResultsEvent(List<CustomVote> votes) public PopulateResultsEvent(List<CustomVote> votes)
{ {
Votes = votes; Votes = votes;
@@ -10,8 +10,8 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
/// <remarks> /// <remarks>
/// Initializes a new instance of the <see cref="ProcessVotesEvent"/> class. /// Initializes a new instance of the <see cref="ProcessVotesEvent"/> class.
/// </remarks> /// </remarks>
/// <param name="votes">>The list of votes that are being processed.</param> /// <param name="votes">The list of <see cref="CustomVote"/>s that are being processed.</param>
/// <param name="exiledPlayer">The player to be exiled. Will be null if no player is to be exiled.</param> /// <param name="exiledPlayer">The player to be exiled. Will be <see langword="null"/> if no player is to be exiled.</param>
public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exiledPlayer = null) : MiraEvent public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exiledPlayer = null) : MiraEvent
{ {
private readonly List<CustomVote> _originalVotes = [.. votes]; private readonly List<CustomVote> _originalVotes = [.. votes];
@@ -29,12 +29,12 @@ public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exil
public bool VotesModified => !Votes.SequenceEqual(_originalVotes); public bool VotesModified => !Votes.SequenceEqual(_originalVotes);
/// <summary> /// <summary>
/// Gets the list of votes that are being processed. /// Gets the list of <see cref="CustomVote"/>s that are being processed.
/// </summary> /// </summary>
public List<CustomVote> Votes { get; } = votes; public List<CustomVote> Votes { get; } = votes;
/// <summary> /// <summary>
/// Gets or sets the player to be exiled. Will be null if no player is to be exiled. /// Gets or sets the player to be exiled. Will be <see langword="null"/> if no player is to be exiled.
/// </summary> /// </summary>
public NetworkedPlayerInfo? ExiledPlayer public NetworkedPlayerInfo? ExiledPlayer
{ {
@@ -3,11 +3,11 @@
/// <summary> /// <summary>
/// The event that is invoked when the voting phase of a meeting is complete. /// The event that is invoked when the voting phase of a meeting is complete.
/// </summary> /// </summary>
/// <param name="meetingHud">The MeetingHud instance.</param> /// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent
{ {
/// <summary> /// <summary>
/// Gets the MeetingHud instance. /// Gets the <see cref="global::MeetingHud"/> instance.
/// </summary> /// </summary>
public MeetingHud MeetingHud { get; } = meetingHud; public MeetingHud MeetingHud { get; } = meetingHud;
} }
@@ -16,14 +16,14 @@ public class CompleteHnsTaskEvent : MiraEvent
public PlayerTask Task { get; } public PlayerTask Task { get; }
/// <summary> /// <summary>
/// Gets the instance of the <see cref="HnsManager"/> attached to the game. /// Gets the instance of the <see cref="HideAndSeekManager"/> attached to the game.
/// </summary> /// </summary>
public HideAndSeekManager HnsManager { get; } public HideAndSeekManager HnsManager { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CompleteHnsTaskEvent"/> class. /// Initializes a new instance of the <see cref="CompleteHnsTaskEvent"/> class.
/// </summary> /// </summary>
/// <param name="hnsManager">The Hide and Seek Manager currently active.</param> /// <param name="hnsManager">The <see cref="HideAndSeekManager"/> currently active.</param>
/// <param name="player">The player who completed the task.</param> /// <param name="player">The player who completed the task.</param>
/// <param name="task">The task that the player completed.</param> /// <param name="task">The task that the player completed.</param>
public CompleteHnsTaskEvent(HideAndSeekManager hnsManager, PlayerControl player, PlayerTask task) public CompleteHnsTaskEvent(HideAndSeekManager hnsManager, PlayerControl player, PlayerTask task)
@@ -16,7 +16,7 @@ public class PlayerDeathEvent : MiraEvent
public DeathReason DeathReason { get; } public DeathReason DeathReason { get; }
/// <summary> /// <summary>
/// Gets the dead body associated with the player, if any. /// Gets the <see cref="global::DeadBody"/> associated with the player, if any.
/// </summary> /// </summary>
public DeadBody? DeadBody { get; } public DeadBody? DeadBody { get; }
@@ -25,7 +25,7 @@ public class PlayerDeathEvent : MiraEvent
/// </summary> /// </summary>
/// <param name="player">The player who died.</param> /// <param name="player">The player who died.</param>
/// <param name="reason">The reason the player died.</param> /// <param name="reason">The reason the player died.</param>
/// <param name="deadBody">The player's body, if it exists.</param> /// <param name="deadBody">The player's <see cref="global::DeadBody"/>, if it exists.</param>
public PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody? deadBody) public PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody? deadBody)
{ {
Player = player; Player = player;
@@ -6,20 +6,20 @@
public class EnterVentEvent : MiraCancelableEvent public class EnterVentEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets the player that is entering the vent. /// Gets the <see cref="PlayerControl"/> that is entering the <see cref="Vent"/>.
/// </summary> /// </summary>
public PlayerControl Player { get; } public PlayerControl Player { get; }
/// <summary> /// <summary>
/// Gets the vent that the player is entering. /// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is entering.
/// </summary> /// </summary>
public Vent? Vent { get; } public Vent? Vent { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="EnterVentEvent"/> class. /// Initializes a new instance of the <see cref="EnterVentEvent"/> class.
/// </summary> /// </summary>
/// <param name="player">The player that is entering the vent.</param> /// <param name="player">The <see cref="PlayerControl"/> that is entering the <paramref name="vent"/>.</param>
/// <param name="vent">The vent being entered.</param> /// <param name="vent">The <see cref="global::Vent"/> being entered.</param>
public EnterVentEvent(PlayerControl player, Vent? vent) public EnterVentEvent(PlayerControl player, Vent? vent)
{ {
Player = player; Player = player;
@@ -6,20 +6,20 @@
public class ExitVentEvent : MiraCancelableEvent public class ExitVentEvent : MiraCancelableEvent
{ {
/// <summary> /// <summary>
/// Gets the player that is exiting the vent. /// Gets the <see cref="PlayerControl"/> that is exiting the <see cref="Vent"/>.
/// </summary> /// </summary>
public PlayerControl Player { get; } public PlayerControl Player { get; }
/// <summary> /// <summary>
/// Gets the vent that the player is exiting. /// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is exiting.
/// </summary> /// </summary>
public Vent? Vent { get; } public Vent? Vent { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ExitVentEvent"/> class. /// Initializes a new instance of the <see cref="ExitVentEvent"/> class.
/// </summary> /// </summary>
/// <param name="player">The player who is exiting the vent.</param> /// <param name="player">The <see cref="PlayerControl"/> who is exiting the <paramref name="vent"/>.</param>
/// <param name="vent">The vent being exited from.</param> /// <param name="vent">The <see cref="global::Vent"/> being exited from.</param>
public ExitVentEvent(PlayerControl player, Vent? vent) public ExitVentEvent(PlayerControl player, Vent? vent)
{ {
Player = player; Player = player;
@@ -8,7 +8,7 @@ public class PlayerCanUseEvent : PlayerUseEvent
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PlayerCanUseEvent"/> class. /// Initializes a new instance of the <see cref="PlayerCanUseEvent"/> class.
/// </summary> /// </summary>
/// <param name="usable">The IUsable.</param> /// <param name="usable">The <see cref="IUsable"/>.</param>
public PlayerCanUseEvent(IUsable usable) : base(usable) public PlayerCanUseEvent(IUsable usable) : base(usable)
{ {
} }
@@ -11,19 +11,19 @@ public class PlayerUseEvent : MiraCancelableEvent
public IUsable Usable { get; } public IUsable Usable { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether the IUsable is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>. /// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>.
/// </summary> /// </summary>
public bool IsPrimaryConsole { get; } public bool IsPrimaryConsole { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether the IUsable is a <see cref="Vent"/>. /// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Vent"/>.
/// </summary> /// </summary>
public bool IsVent { get; } public bool IsVent { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PlayerUseEvent"/> class. /// Initializes a new instance of the <see cref="PlayerUseEvent"/> class.
/// </summary> /// </summary>
/// <param name="usable">The IUsable.</param> /// <param name="usable">The <see cref="IUsable"/>.</param>
public PlayerUseEvent(IUsable usable) public PlayerUseEvent(IUsable usable)
{ {
Usable = usable; Usable = usable;
+14 -14
View File
@@ -10,44 +10,44 @@ namespace MiraAPI.GameEnd;
public abstract class CustomGameOver public abstract class CustomGameOver
{ {
/// <summary> /// <summary>
/// Gets the current CustomGameOver. /// Gets the current <see cref="CustomGameOver"/>.
/// </summary> /// </summary>
public static CustomGameOver? Instance { get; internal set; } public static CustomGameOver? Instance { get; internal set; }
/// <summary> /// <summary>
/// Verifies if the condition for this CustomGameOver is met. /// Verifies if the condition for this <see cref="CustomGameOver"/> is met.
/// </summary> /// </summary>
/// <param name="playerControl">The PlayerControl that requested the Game Over.</param> /// <param name="playerControl">The <see cref="PlayerControl"/> that requested the Game Over.</param>
/// <param name="winners">The collection of winners.</param> /// <param name="winners">The collection of winners.</param>
/// <returns>True if the condition is met, otherwise false.</returns> /// <returns><see langword="true"/> if the condition is met, otherwise <see langword="false"/>.</returns>
public virtual bool VerifyCondition(PlayerControl playerControl, NetworkedPlayerInfo[] winners) public virtual bool VerifyCondition(PlayerControl playerControl, NetworkedPlayerInfo[] winners)
{ {
return true; return true;
} }
/// <summary> /// <summary>
/// Runs before the base game calls EndGameManager.SetEverythingUp. /// Runs before the base game calls <see cref="EndGameManager.SetEverythingUp"/>.
/// </summary> /// </summary>
/// <param name="endGameManager">The EndGameManager instance.</param> /// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
/// <returns>Return True to use the run the original method, return False to skip it.</returns> /// <returns>Return <see langword="true"/> to use the run the original method, return <see langword="false"/> to skip it.</returns>
public virtual bool BeforeEndGameSetup(EndGameManager endGameManager) public virtual bool BeforeEndGameSetup(EndGameManager endGameManager)
{ {
return true; return true;
} }
/// <summary> /// <summary>
/// Runs after the base game calls EndGameManager.SetEverythingUp. /// Runs after the base game calls <see cref="EndGameManager.SetEverythingUp"/>.
/// </summary> /// </summary>
/// <param name="endGameManager">The EndGameManager instance.</param> /// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
public virtual void AfterEndGameSetup(EndGameManager endGameManager) public virtual void AfterEndGameSetup(EndGameManager endGameManager)
{ {
} }
/// <summary> /// <summary>
/// Get the GameOverReason associated with this CustomGameOver. /// Get the <see cref="global::GameOverReason"/> associated with this <see cref ="CustomGameOver"/>.
/// </summary> /// </summary>
/// <typeparam name="T">Type of the custom game over.</typeparam> /// <typeparam name="T">Type of the custom game over.</typeparam>
/// <returns>The GameOverReason associated with the custom game over.</returns> /// <returns>The <see cref="global::GameOverReason"/> associated with the custom game over.</returns>
public static GameOverReason GameOverReason<T>() where T : CustomGameOver public static GameOverReason GameOverReason<T>() where T : CustomGameOver
{ {
return (GameOverReason)GameOverManager.GetGameOverId<T>(); return (GameOverReason)GameOverManager.GetGameOverId<T>();
@@ -67,10 +67,10 @@ public abstract class CustomGameOver
} }
/// <summary> /// <summary>
/// Implicitly convert a CustomGameOver to a GameOverReason. /// Implicitly convert a <see cref="CustomGameOver"/> to a <see cref="global::GameOverReason"/>.
/// </summary> /// </summary>
/// <param name="gameOver">The CustomGameOver instance.</param> /// <param name="gameOver">The <see cref="CustomGameOver"/> instance.</param>
/// <returns>The GameOverReason associated with the CustomGameOver.</returns> /// <returns>The <see cref="global::GameOverReason"/> associated with the CustomGameOver.</returns>
public static implicit operator GameOverReason(CustomGameOver gameOver) public static implicit operator GameOverReason(CustomGameOver gameOver)
{ {
return (GameOverReason)GameOverManager.GetGameOverId(gameOver.GetType()); return (GameOverReason)GameOverManager.GetGameOverId(gameOver.GetType());
+15 -16
View File
@@ -1,12 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Reactor.Utilities;
namespace MiraAPI.GameEnd; namespace MiraAPI.GameEnd;
/// <summary> /// <summary>
/// Manage custom game overs. /// Manage <see cref="CustomGameOver"/>s.
/// </summary> /// </summary>
public static class GameOverManager public static class GameOverManager
{ {
@@ -16,11 +15,11 @@ public static class GameOverManager
private static int _nextId = Enum.GetNames<GameOverReason>().Length; private static int _nextId = Enum.GetNames<GameOverReason>().Length;
/// <summary> /// <summary>
/// Register a custom game over. /// Register a <see cref="CustomGameOver"/>.
/// </summary> /// </summary>
/// <param name="gameOverType">Type of the custom game over.</param> /// <param name="gameOverType">Type of the <see cref="CustomGameOver"/>.</param>
/// <exception cref="ArgumentException">Thrown when the type is not a subclass of CustomGameOver, is abstract, or does not have a parameterless constructor.</exception> /// <exception cref="ArgumentException">Thrown when the type is not a subclass of <see cref="CustomGameOver"/>, is abstract, or does not have a parameterless constructor.</exception>
/// <returns>>True if the game over was registered successfully, false otherwise.</returns> /// <returns><see langword="true"/> if the game over was registered successfully, <see langword="false"/> otherwise.</returns>
public static bool RegisterGameOver(Type gameOverType) public static bool RegisterGameOver(Type gameOverType)
{ {
if (!typeof(CustomGameOver).IsAssignableFrom(gameOverType)) if (!typeof(CustomGameOver).IsAssignableFrom(gameOverType))
@@ -47,11 +46,11 @@ public static class GameOverManager
} }
/// <summary> /// <summary>
/// Create an instance of a custom game over. /// Create an instance of a <see cref="CustomGameOver"/>.
/// </summary> /// </summary>
/// <param name="id">ID of the custom game over.</param> /// <param name="id">ID of the <see cref="CustomGameOver"/>.</param>
/// <param name="customGameOver">The created instance of the custom game over.</param> /// <param name="customGameOver">The created instance of the <see cref="CustomGameOver"/>.</param>
/// <returns>An instance of the custom game over.</returns> /// <returns>An instance of the <see cref="CustomGameOver"/>.</returns>
public static bool TryGetGameOver(int id, [NotNullWhen(true)] out CustomGameOver? customGameOver) public static bool TryGetGameOver(int id, [NotNullWhen(true)] out CustomGameOver? customGameOver)
{ {
if (GameOverTypes.TryGetValue(id, out var gameOverType)) if (GameOverTypes.TryGetValue(id, out var gameOverType))
@@ -65,20 +64,20 @@ public static class GameOverManager
} }
/// <summary> /// <summary>
/// Get the ID of a custom game over. /// Get the ID of a <see cref="CustomGameOver"/>.
/// </summary> /// </summary>
/// <typeparam name="T">Type of the custom game over.</typeparam> /// <typeparam name="T">Type of the <see cref="CustomGameOver"/>.</typeparam>
/// <returns>The ID of the custom game over.</returns> /// <returns>The ID of the <see cref="CustomGameOver"/>.</returns>
public static int GetGameOverId<T>() where T : CustomGameOver public static int GetGameOverId<T>() where T : CustomGameOver
{ {
return GetGameOverId(typeof(T)); return GetGameOverId(typeof(T));
} }
/// <summary> /// <summary>
/// Get the ID of a custom game over. /// Get the ID of a <see cref="CustomGameOver"/>.
/// </summary> /// </summary>
/// <param name="gameOverType">Type of the custom game over.</param> /// <param name="gameOverType">Type of the <see cref="CustomGameOver"/>.</param>
/// <returns>The ID of the custom game over.</returns> /// <returns>The ID of the <see cref="CustomGameOver"/>.</returns>
/// <exception cref="ArgumentException">Thrown when the type is not registered.</exception> /// <exception cref="ArgumentException">Thrown when the type is not registered.</exception>
public static int GetGameOverId(Type gameOverType) public static int GetGameOverId(Type gameOverType)
{ {
+24 -24
View File
@@ -23,24 +23,24 @@ public abstract class CustomGameMode
public abstract int Id { get; } public abstract int Id { get; }
/// <summary> /// <summary>
/// Called when Intro Cutscene is destroyed. /// Called when <see cref="IntroCutscene"/> is destroyed.
/// </summary> /// </summary>
public virtual void Initialize() public virtual void Initialize()
{ {
} }
/// <summary> /// <summary>
/// Called on HudManager.Start(). /// Called on <see cref="HudManager.Start"/>.
/// </summary> /// </summary>
/// <param name="instance">Instance of HudManager.</param> /// <param name="instance">Instance of <see cref="HudManager"/>.</param>
public virtual void HudStart(HudManager instance) public virtual void HudStart(HudManager instance)
{ {
} }
/// <summary> /// <summary>
/// Called every frame on HudManager.Update(). /// Called every frame on <see cref="HudManager.Update"/>.
/// </summary> /// </summary>
/// <param name="instance">Instance of HudManager.</param> /// <param name="instance">Instance of <see cref="HudManager"/>.</param>
public virtual void HudUpdate(HudManager instance) public virtual void HudUpdate(HudManager instance)
{ {
} }
@@ -48,7 +48,7 @@ public abstract class CustomGameMode
/// <summary> /// <summary>
/// Called when a player is killed. /// Called when a player is killed.
/// </summary> /// </summary>
/// <param name="player">PlayerControl that was killed.</param> /// <param name="player"><see cref="PlayerControl"/> that was killed.</param>
public virtual void OnDeath(PlayerControl player) public virtual void OnDeath(PlayerControl player)
{ {
} }
@@ -57,7 +57,7 @@ public abstract class CustomGameMode
/// Calculate Game End logic. /// Calculate Game End logic.
/// </summary> /// </summary>
/// <param name="runOriginal">Should original game end logic be used.</param> /// <param name="runOriginal">Should original game end logic be used.</param>
/// <param name="instance">Instance of LogicGameFlowNormal.</param> /// <param name="instance">Instance of <see cref="LogicGameFlowNormal"/>.</param>
public virtual void CheckGameEnd(out bool runOriginal, LogicGameFlowNormal instance) public virtual void CheckGameEnd(out bool runOriginal, LogicGameFlowNormal instance)
{ {
runOriginal = true; runOriginal = true;
@@ -67,7 +67,7 @@ public abstract class CustomGameMode
/// Custom role assignment. /// Custom role assignment.
/// </summary> /// </summary>
/// <param name="runOriginal">Should original role assignment be used.</param> /// <param name="runOriginal">Should original role assignment be used.</param>
/// <param name="instance">Instance of LogicRoleSelection.</param> /// <param name="instance">Instance of <see cref="LogicRoleSelection"/>.</param>
public virtual void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance) public virtual void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance)
{ {
runOriginal = true; runOriginal = true;
@@ -78,7 +78,7 @@ public abstract class CustomGameMode
/// </summary> /// </summary>
/// <param name="runOriginal">Should the original murder logic be used.</param> /// <param name="runOriginal">Should the original murder logic be used.</param>
/// <param name="result">Result of custom murder logic.</param> /// <param name="result">Result of custom murder logic.</param>
/// <param name="target">Target player for murder.</param> /// <param name="target">Target <see cref="PlayerControl"/> for murder.</param>
public virtual void CanKill(out bool runOriginal, out bool result, PlayerControl target) public virtual void CanKill(out bool runOriginal, out bool result, PlayerControl target)
{ {
result = false; result = false;
@@ -88,60 +88,60 @@ public abstract class CustomGameMode
/// <summary> /// <summary>
/// Should Roles Settings be available when this gamemode is selected. /// Should Roles Settings be available when this gamemode is selected.
/// </summary> /// </summary>
/// <returns>True if Role Settings are enabled in this game mode.</returns> /// <returns><see langword="true"/> if Role Settings are enabled in this game mode.</returns>
public virtual bool AreRoleSettingsEnabled() => true; public virtual bool AreRoleSettingsEnabled() => true;
/// <summary> /// <summary>
/// Should Game Settings be available when this gamemode is selected. /// Should Game Settings be available when this gamemode is selected.
/// </summary> /// </summary>
/// <returns>True if Game Settings are enabled in this mode.</returns> /// <returns><see langword="true"/> if Game Settings are enabled in this mode.</returns>
public virtual bool AreGameSettingsEnabled() => true; public virtual bool AreGameSettingsEnabled() => true;
/// <summary> /// <summary>
/// Custom winner selection. /// Custom winner selection.
/// </summary> /// </summary>
/// <returns>List of winners or null.</returns> /// <returns>List of winners or <see langword="null"/>.</returns>
public virtual List<NetworkedPlayerInfo>? CalculateWinners() => null; public virtual List<NetworkedPlayerInfo>? CalculateWinners() => null;
/// <summary> /// <summary>
/// Show gamemode in Intro Cutscene. /// Show gamemode in <see cref="IntroCutscene"/>.
/// </summary> /// </summary>
/// <returns>True if the game mode should be shown in the intro cutscene.</returns> /// <returns><see langword="true"/> if the game mode should be shown in the intro cutscene.</returns>
public virtual bool ShowGameModeIntroCutscene() => false; public virtual bool ShowGameModeIntroCutscene() => false;
/// <summary> /// <summary>
/// Can Admin be used in this gamemode. /// Can Admin be used in this gamemode.
/// </summary> /// </summary>
/// <param name="console">Admin Console.</param> /// <param name="console">Admin Console.</param>
/// <returns>True if Admin console is enabled.</returns> /// <returns><see langword="true"/> if Admin console is enabled.</returns>
public virtual bool CanUseMapConsole(MapConsole console) => true; public virtual bool CanUseMapConsole(MapConsole console) => true;
/// <summary> /// <summary>
/// Can a body be reported in this gamemode. /// Can a <see cref="DeadBody"/> be reported in this gamemode.
/// </summary> /// </summary>
/// <param name="body">Target body for reporting.</param> /// <param name="body">Target <see cref="DeadBody"/> for reporting.</param>
/// <returns>True if dead bodies can be reported.</returns> /// <returns><see langword="true"/> if <see cref="DeadBody"/>s can be reported.</returns>
public virtual bool CanReport(DeadBody body) => true; public virtual bool CanReport(DeadBody body) => true;
/// <summary> /// <summary>
/// Can system consoles be used in this gamemode. /// Can <see cref="SystemConsole"/>s be used in this gamemode.
/// </summary> /// </summary>
/// <param name="console">System Console.</param> /// <param name="console">System Console.</param>
/// <returns>True if system consoles are enabled in this mode.</returns> /// <returns><see langword="true"/> if <see cref="SystemConsole"/>s are enabled in this mode.</returns>
public virtual bool CanUseSystemConsole(SystemConsole console) => true; public virtual bool CanUseSystemConsole(SystemConsole console) => true;
/// <summary> /// <summary>
/// Can tasks be interacted with in this gamemode. /// Can tasks be interacted with in this gamemode.
/// </summary> /// </summary>
/// <param name="console">Task console.</param> /// <param name="console">Task console.</param>
/// <returns>True if tasks are enabled in this mode.</returns> /// <returns><see langword="true"/> if tasks are enabled in this mode.</returns>
public virtual bool CanUseTasks(Console console) => true; public virtual bool CanUseTasks(Console console) => true;
/// <summary> /// <summary>
/// Should the sabotage map be used when attempting to open sabotage overlay. /// Should the sabotage map be used when attempting to open sabotage overlay.
/// </summary> /// </summary>
/// <param name="map">MapBehaviour object.</param> /// <param name="map"><see cref="MapBehaviour"/> object.</param>
/// <returns>True if the sabotage map should be shown.</returns> /// <returns><see langword="true"/> if the sabotage map should be shown.</returns>
public virtual bool ShouldShowSabotageMap(MapBehaviour map) => true; public virtual bool ShouldShowSabotageMap(MapBehaviour map) => true;
/// <summary> /// <summary>
@@ -149,6 +149,6 @@ public abstract class CustomGameMode
/// </summary> /// </summary>
/// <param name="vent">Target vent.</param> /// <param name="vent">Target vent.</param>
/// <param name="playerInfo">Player attempting to vent.</param> /// <param name="playerInfo">Player attempting to vent.</param>
/// <returns>True if venting is enabled in this mode.</returns> /// <returns><see langword="true"/> if venting is enabled in this mode.</returns>
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true; public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
} }
+7 -8
View File
@@ -1,17 +1,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Reactor.Utilities;
namespace MiraAPI.GameModes; namespace MiraAPI.GameModes;
/// <summary> /// <summary>
/// Manages custom gamemodes. /// Manages <see cref="CustomGameMode"/>s.
/// </summary> /// </summary>
public static class CustomGameModeManager public static class CustomGameModeManager
{ {
/// <summary> /// <summary>
/// List of registered gamemodes. /// List of registered <see cref="CustomGameMode"/>.
/// </summary> /// </summary>
internal static readonly Dictionary<int, CustomGameMode> GameModes = []; internal static readonly Dictionary<int, CustomGameMode> GameModes = [];
@@ -21,14 +20,14 @@ public static class CustomGameModeManager
} }
/// <summary> /// <summary>
/// Gets the current gamemode. /// Gets the current <see cref="CustomGameMode"/>.
/// </summary> /// </summary>
public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode(); public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode();
/// <summary> /// <summary>
/// Set current gamemode. /// Set current <see cref="CustomGameMode"/>.
/// </summary> /// </summary>
/// <param name="id">gamemode ID.</param> /// <param name="id"><see cref="CustomGameMode"/> ID.</param>
public static void SetGameMode(int id) public static void SetGameMode(int id)
{ {
if (GameModes.TryGetValue(id, out var gameMode)) if (GameModes.TryGetValue(id, out var gameMode))
@@ -41,9 +40,9 @@ public static class CustomGameModeManager
} }
/// <summary> /// <summary>
/// Register gamemode from type. /// Register <see cref="CustomGameMode"/> from type.
/// </summary> /// </summary>
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="CustomGameMode"/>.</param> /// <param name="gameModeType">Type of <see cref="CustomGameMode"/>, should inherit from <see cref="CustomGameMode"/>.</param>
internal static void RegisterGameMode(Type gameModeType) internal static void RegisterGameMode(Type gameModeType)
{ {
if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType)) if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType))
+67 -8
View File
@@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using MiraAPI.Modifiers; using MiraAPI.Modifiers;
using MiraAPI.Roles;
using UnityEngine; using UnityEngine;
namespace MiraAPI.GameOptions; namespace MiraAPI.GameOptions;
@@ -29,15 +31,18 @@ public abstract class AbstractOptionGroup
public virtual Type? OptionableType => null; public virtual Type? OptionableType => null;
/// <summary> /// <summary>
/// Gets a value indicating whether the group should be shown in the modifiers menu. This is deprecated, please use ParentMenu! /// Gets a value indicating whether the group should be shown in the modifiers menu.
/// </summary> /// </summary>
// TODO: make this not a boolean // TODO: make this not a boolean
#pragma warning disable S1133
[Obsolete("Use ParentMenu instead.")]
#pragma warning restore S1133
public virtual bool ShowInModifiersMenu => false; public virtual bool ShowInModifiersMenu => false;
/// <summary> /// <summary>
/// Gets a value indicating which menu the group is in. /// Gets a value indicating which menu the group is in.
/// </summary> /// </summary>
public virtual MenuCategory ParentMenu => MenuCategory.Roles; public virtual MenuCategory ParentMenu => MenuCategory.Game;
/// <summary> /// <summary>
/// Gets the function that determines whether the group should be visible or not. /// Gets the function that determines whether the group should be visible or not.
@@ -45,19 +50,26 @@ public abstract class AbstractOptionGroup
public virtual Func<bool> GroupVisible => () => true; public virtual Func<bool> GroupVisible => () => true;
/// <summary> /// <summary>
/// Gets the group color. This is used to color the group in the options menu. /// Gets the group <see cref="Color"/>. This is used to color the group in the options menu.
/// </summary> /// </summary>
public virtual Color GroupColor => MiraApiPlugin.DefaultHeaderColor; public virtual Color GroupColor => MiraApiPlugin.DefaultHeaderColor;
/// <summary> /// <summary>
/// Gets the group priority. This is used to determine the order in which groups are displayed in the options menu. /// Gets the group priority. This is used to determine the order in which groups are displayed in the options menu.
/// Zero is the highest priority, and the default value is the max uint value. /// Zero is the highest priority, and the default value is the max <see langword="uint"/> value.
/// </summary> /// </summary>
public virtual uint GroupPriority => uint.MaxValue; public virtual uint GroupPriority => uint.MaxValue;
/// <summary>
/// Gets the default notification settings for the group.
/// </summary>
public virtual OptionNotifConfiguration Configuration => new(new Color(0.7333f, 0.7333f, 0.7333f, 1));
internal bool AllOptionsHidden { get; set; } internal bool AllOptionsHidden { get; set; }
internal CategoryHeaderMasked? Header { get; set; } internal CategoryHeaderMasked? Header { get; set; }
internal Coroutine? CreationCoroutine { get; set; }
} }
/// <summary> /// <summary>
@@ -69,9 +81,7 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
/// <inheritdoc /> /// <inheritdoc />
public override Type OptionableType => typeof(T); public override Type OptionableType => typeof(T);
/// <summary> /// <inheritdoc />
/// Gets a value indicating which menu the group is in.
/// </summary>
public override MenuCategory ParentMenu public override MenuCategory ParentMenu
{ {
get get
@@ -90,11 +100,60 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
} }
} }
/// <summary>
/// Base class for option groups. An option group is a collection of options that are displayed together in the options menu.
/// </summary>
/// <typeparam name="T">The custom role that the group is for.</typeparam>
public abstract class AbstractRoleOptionGroup<T>() : AbstractOptionGroup<T> where T : ICustomRole
{
/// <inheritdoc />
public override Type OptionableType => typeof(T);
/// <inheritdoc />
public override MenuCategory ParentMenu => MenuCategory.Roles;
/// <inheritdoc />
public override OptionNotifConfiguration Configuration
{
get
{
var role = CustomRoleManager.CustomMiraRoles.FirstOrDefault(x => x.GetType() == OptionableType);
if (role == null)
{
return new(new Color(0.7333f, 0.7333f, 0.7333f, 1));
}
return new(role.RoleColor, role.Configuration.IconTmp);
}
}
}
/// <summary>
/// Menu categories for option groups.
/// </summary>
public enum MenuCategory public enum MenuCategory
{ {
/// <summary>
/// Determines the option group is in the game settings tab.
/// </summary>
Game, Game,
/// <summary>
/// Determines the option group is in the role settings tab.
/// </summary>
Roles, Roles,
/// <summary>
/// Determines the option group is in the modifier settings tab.
/// </summary>
Modifiers, Modifiers,
/// <summary>
/// Determines the option group is in the first custom settings tab.
/// </summary>
CustomOne, CustomOne,
CustomTwo
/// <summary>
/// Determines the option group is in the second custom settings tab.
/// </summary>
CustomTwo,
} }
@@ -5,7 +5,7 @@ using MiraAPI.GameOptions.OptionTypes;
namespace MiraAPI.GameOptions.Attributes; namespace MiraAPI.GameOptions.Attributes;
/// <summary> /// <summary>
/// Attribute for creating an enum option. /// Attribute for creating a <see cref="ModdedEnumOption"/>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? values = null) public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? values = null)
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
namespace MiraAPI.GameOptions.Attributes; namespace MiraAPI.GameOptions.Attributes;
/// <summary> /// <summary>
/// A number option attribute for the modded options system. /// Attribute for a <see cref="ModdedNumberOption"/>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public class ModdedNumberOptionAttribute( public class ModdedNumberOptionAttribute(
@@ -4,7 +4,7 @@ using System.Reflection;
namespace MiraAPI.GameOptions.Attributes; namespace MiraAPI.GameOptions.Attributes;
/// <summary> /// <summary>
/// Represents an attribute that is used to define a modded option. /// Represents an attribute that is used to define an <see cref="IModdedOption"/>.
/// </summary> /// </summary>
/// <param name="title">The option title.</param> /// <param name="title">The option title.</param>
/// <param name="roleType">Optional parameter to specify a role Type.</param> /// <param name="roleType">Optional parameter to specify a role Type.</param>
@@ -26,13 +26,13 @@ public abstract class ModdedOptionAttribute(string title, Type? roleType = null)
/// <summary> /// <summary>
/// Sets the value of the option. /// Sets the value of the option.
/// </summary> /// </summary>
/// <param name="value">The new value as an object.</param> /// <param name="value">The new value as an <see langword="object"/>.</param>
public abstract void SetValue(object value); public abstract void SetValue(object value);
/// <summary> /// <summary>
/// Gets the value of the option. /// Gets the value of the option.
/// </summary> /// </summary>
/// <returns>The value of the option as an object.</returns> /// <returns>The value of the option as an <see langword="object"/>.</returns>
public abstract object GetValue(); public abstract object GetValue();
internal abstract IModdedOption? CreateOption(object? value, PropertyInfo property); internal abstract IModdedOption? CreateOption(object? value, PropertyInfo property);
@@ -5,7 +5,7 @@ using MiraAPI.GameOptions.OptionTypes;
namespace MiraAPI.GameOptions.Attributes; namespace MiraAPI.GameOptions.Attributes;
/// <summary> /// <summary>
/// Attribute for a toggle option. /// Attribute for a <see cref="ModdedToggleOption"/>.
/// </summary> /// </summary>
/// <param name="title">The option title.</param> /// <param name="title">The option title.</param>
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
+29 -19
View File
@@ -22,22 +22,32 @@ public interface IModdedOption
string Title { get; set; } string Title { get; set; }
/// <summary> /// <summary>
/// Gets the StringName for the option, used for localization. /// Gets or sets the parent <see cref="AbstractOptionGroup"/> of the option.
/// </summary>
AbstractOptionGroup ParentGroup { get; set; }
/// <summary>
/// Gets the notification settings for the option.
/// </summary>
OptionNotifConfiguration Configuration { get; }
/// <summary>
/// Gets the <see cref="StringNames"/> for the option, used for localization.
/// </summary> /// </summary>
StringNames StringName { get; } StringNames StringName { get; }
/// <summary> /// <summary>
/// Gets or sets the MiraPlugin that created this option. /// Gets or sets the <see cref="IMiraPlugin"/> that created this option.
/// </summary> /// </summary>
IMiraPlugin? ParentMod { get; set; } IMiraPlugin? ParentMod { get; set; }
/// <summary> /// <summary>
/// Gets the game setting data for the option. /// Gets the <see cref="BaseGameSetting"/> for the option.
/// </summary> /// </summary>
BaseGameSetting Data { get; } BaseGameSetting Data { get; }
/// <summary> /// <summary>
/// Gets the OptionBehaviour object of the option. /// Gets the <see cref="global::OptionBehaviour"/> object of the option.
/// </summary> /// </summary>
OptionBehaviour? OptionBehaviour { get; } OptionBehaviour? OptionBehaviour { get; }
@@ -52,55 +62,55 @@ public interface IModdedOption
bool IncludeInPreset { get; set; } bool IncludeInPreset { get; set; }
/// <summary> /// <summary>
/// Gets or sets the ConfigDefinition for the option, used for BepInEx configuration. /// Gets or sets the <see cref="BepInEx.Configuration.ConfigDefinition"/> for the option, used for BepInEx configuration.
/// </summary> /// </summary>
ConfigDefinition? ConfigDefinition { get; set; } ConfigDefinition? ConfigDefinition { get; set; }
/// <summary> /// <summary>
/// Creates the option behaviour for the modded option. /// Creates the option behaviour for the modded option.
/// </summary> /// </summary>
/// <param name="toggleOpt">The ToggleOption template.</param> /// <param name="toggleOpt">The <see cref="ToggleOption"/> template.</param>
/// <param name="numberOpt">The NumberOption template.</param> /// <param name="numberOpt">The <see cref="NumberOption"/> template.</param>
/// <param name="stringOpt">The StringOption template.</param> /// <param name="stringOpt">The <see cref="StringOption"/> template.</param>
/// <param name="playerOpt">The PlayerOption template.</param> /// <param name="playerOpt">The <see cref="PlayerOption"/> template.</param>
/// <param name="container">>The Transform container for the option.</param> /// <param name="container">The <see cref="Transform"/> container for the option.</param>
/// <returns>>The created OptionBehaviour object.</returns> /// <returns>The created <see cref="global::OptionBehaviour"/> object.</returns>
OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container); OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container);
/// <summary> /// <summary>
/// Gets the value as a float. /// Gets the value as a <see langword="float"/>.
/// </summary> /// </summary>
/// <returns>>The value of the option as a float.</returns> /// <returns>The value of the option as a <see langword="float"/>.</returns>
float GetFloatData(); float GetFloatData();
/// <summary> /// <summary>
/// Gets the NetData for the option, used for network synchronization. /// Gets the <see cref="NetData"/> for the option, used for network synchronization.
/// </summary> /// </summary>
/// <returns>>Returns the NetData object for the option.</returns> /// <returns>Returns the <see cref="NetData"/> object for the option.</returns>
NetData GetNetData(); NetData GetNetData();
/// <summary> /// <summary>
/// Handles incoming network data for the option. /// Handles incoming network data for the option.
/// </summary> /// </summary>
/// <param name="data">>The byte array representing the network data.</param> /// <param name="data">The byte array representing the network data.</param>
void HandleNetData(byte[] data); void HandleNetData(byte[] data);
/// <summary> /// <summary>
/// Saves the option to a preset configuration file. /// Saves the option to a preset configuration file.
/// </summary> /// </summary>
/// <param name="presetConfig">The ConfigFile representing the preset configuration.</param> /// <param name="presetConfig">The <see cref="ConfigFile"/> representing the preset configuration.</param>
/// <param name="saveDefault">Indicates whether to save the default value instead of the current value.</param> /// <param name="saveDefault">Indicates whether to save the default value instead of the current value.</param>
void SaveToPreset(ConfigFile presetConfig, bool saveDefault = false); void SaveToPreset(ConfigFile presetConfig, bool saveDefault = false);
/// <summary> /// <summary>
/// Binds the option to a configuration file. /// Binds the option to a configuration file.
/// </summary> /// </summary>
/// <param name="config">The ConfigFile to bind the option to.</param> /// <param name="config">The <see cref="ConfigFile"/> to bind the option to.</param>
void Bind(ConfigFile config); void Bind(ConfigFile config);
/// <summary> /// <summary>
/// Loads the option from a preset configuration file, applying the values to the option's configuration. /// Loads the option from a preset configuration file, applying the values to the option's configuration.
/// </summary> /// </summary>
/// <param name="presetConfig">The ConfigFile representing the preset configuration.</param> /// <param name="presetConfig">The <see cref="ConfigFile"/> representing the preset configuration.</param>
void LoadFromPreset(ConfigFile presetConfig); void LoadFromPreset(ConfigFile presetConfig);
} }
@@ -13,7 +13,7 @@ namespace MiraAPI.GameOptions;
public class MiraNumberOptionComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr) public class MiraNumberOptionComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
{ {
/// <summary> /// <summary>
/// Gets or sets the modded option associated with the object. /// Gets or sets the <see cref="ModdedNumberOption"/> associated with the object.
/// </summary> /// </summary>
[HideFromIl2Cpp] [HideFromIl2Cpp]
public ModdedNumberOption NumberOption { get; set; } public ModdedNumberOption NumberOption { get; set; }
+35 -2
View File
@@ -12,11 +12,13 @@ using MiraAPI.PluginLoading;
using MiraAPI.Utilities; using MiraAPI.Utilities;
using Reactor.Networking.Rpc; using Reactor.Networking.Rpc;
using Reactor.Utilities; using Reactor.Utilities;
using TMPro;
using UnityEngine;
namespace MiraAPI.GameOptions; namespace MiraAPI.GameOptions;
/// <summary> /// <summary>
/// Handles modded options. /// Handles <see cref="IModdedOption"/>s.
/// </summary> /// </summary>
public static class ModdedOptionsManager public static class ModdedOptionsManager
{ {
@@ -30,6 +32,36 @@ public static class ModdedOptionsManager
internal static uint NextId => _nextId++; internal static uint NextId => _nextId++;
private static uint _nextId = 1; private static uint _nextId = 1;
public static void AddSettingsChangeMessage(NotificationPopper notif, StringNames key, string value, Color textColor, TMP_SpriteAsset? sprite, bool playSound = true)
{
var item = string.Empty;
var text = textColor.ToTextColor();
if (sprite != null)
{
item = TranslationController.Instance.GetString(
StringNames.LobbyChangeSettingNotification,
string.Concat(
"<sprite name=\"",
sprite.name,
"\"><font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">",
text,
TranslationController.Instance.GetString(key),
"</color></font>"),
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + value + "</font>"
);
}
else
{
item = TranslationController.Instance.GetString(
StringNames.LobbyChangeSettingNotification,
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" +
text +
TranslationController.Instance.GetString(key) + "</color></font>",
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + value + "</font>");
}
notif.SettingsChangeMessageLogic(key, item, playSound);
}
internal static bool RegisterGroup(Type type, MiraPluginInfo pluginInfo) internal static bool RegisterGroup(Type type, MiraPluginInfo pluginInfo)
{ {
if (Activator.CreateInstance(type) is not AbstractOptionGroup group) if (Activator.CreateInstance(type) is not AbstractOptionGroup group)
@@ -123,6 +155,7 @@ public static class ModdedOptionsManager
option.ConfigDefinition = new ConfigDefinition(groupName, propertyName); option.ConfigDefinition = new ConfigDefinition(groupName, propertyName);
option.ParentGroup = group;
option.ParentMod = pluginInfo.MiraPlugin; option.ParentMod = pluginInfo.MiraPlugin;
pluginInfo.InternalOptions.Add(option); pluginInfo.InternalOptions.Add(option);
ModdedOptions.Add(option.Id, option); ModdedOptions.Add(option.Id, option);
@@ -192,7 +225,7 @@ public static class ModdedOptionsManager
/// </summary> /// </summary>
/// <param name="__originalMethod">The original getter method.</param> /// <param name="__originalMethod">The original getter method.</param>
/// <param name="__result">The result of the property getter.</param> /// <param name="__result">The result of the property getter.</param>
/// <returns>False so the original getter gets skipped.</returns> /// <returns><see langword="false"/> so the original getter gets skipped.</returns>
#pragma warning disable CA1707 #pragma warning disable CA1707
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony naming convention")] [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony naming convention")]
public static bool PropertyGetterPatch(MethodBase __originalMethod, ref object __result) public static bool PropertyGetterPatch(MethodBase __originalMethod, ref object __result)
+2 -2
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.GameOptions; namespace MiraAPI.GameOptions;
/// <summary> /// <summary>
/// Singleton for option groups. /// Singleton for <see cref="AbstractOptionGroup"/>s.
/// </summary> /// </summary>
/// <typeparam name="T">The option group type.</typeparam> /// <typeparam name="T">The option group type.</typeparam>
public static class OptionGroupSingleton<T> where T : AbstractOptionGroup public static class OptionGroupSingleton<T> where T : AbstractOptionGroup
@@ -11,7 +11,7 @@ public static class OptionGroupSingleton<T> where T : AbstractOptionGroup
private static T? _instance; private static T? _instance;
/// <summary> /// <summary>
/// Gets the instance of the option group. /// Gets the instance of the <typeparamref name="T"/> group.
/// </summary> /// </summary>
#pragma warning disable CA1000 #pragma warning disable CA1000
public static T Instance => _instance ??= ModdedOptionsManager.Groups.OfType<T>().Single(); public static T Instance => _instance ??= ModdedOptionsManager.Groups.OfType<T>().Single();
@@ -0,0 +1,53 @@
using System;
using Il2CppInterop.Runtime.Attributes;
using TMPro;
using UnityEngine;
namespace MiraAPI.GameOptions;
/// <summary>
/// Used to configure the specific visuals for option notifications.
/// </summary>
public record struct OptionNotifConfiguration
{
#pragma warning disable S1133
[Obsolete("Default constructor is not supported")]
#pragma warning restore S1133
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public OptionNotifConfiguration()
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
{
throw new NotImplementedException("Default constructor is not supported.");
}
/// <summary>
/// Initializes a new instance of the <see cref="OptionNotifConfiguration"/> struct based on a group.
/// </summary>
/// <param name="group">The <see cref="AbstractOptionGroup"/> in which you are configuring.</param>
public OptionNotifConfiguration(AbstractOptionGroup group)
{
PopUpIconTmp = group.Configuration.PopUpIconTmp;
PopUpTextColor = group.Configuration.PopUpTextColor;
}
/// <summary>
/// Initializes a new instance of the <see cref="OptionNotifConfiguration"/> struct from scratch.
/// </summary>
/// <param name="color">The text <see cref="Color"/> for the configuration.</param>
/// <param name="asset">The <see cref="TMP_SpriteAsset"/> icon for the configuration.</param>
public OptionNotifConfiguration(Color color, TMP_SpriteAsset asset = null!)
{
PopUpIconTmp = asset;
PopUpTextColor = color;
}
/// <summary>
/// Gets or sets the <see cref="TMP_SpriteAsset"/> for the icon on the options pop-up.
/// </summary>
public TMP_SpriteAsset PopUpIconTmp { get; set; }
/// <summary>
/// Gets or sets the <see cref="Color"/> for the text on the options pop-up.
/// </summary>
[HideFromIl2Cpp]
public Color PopUpTextColor { get; set; }
}
@@ -11,7 +11,7 @@ using Object = UnityEngine.Object;
namespace MiraAPI.GameOptions.OptionTypes; namespace MiraAPI.GameOptions.OptionTypes;
/// <summary> /// <summary>
/// An option for selecting an enum value. /// An option for selecting an <see langword="enum"/> value.
/// </summary> /// </summary>
public class ModdedEnumOption : ModdedOption<int> public class ModdedEnumOption : ModdedOption<int>
{ {
@@ -25,8 +25,8 @@ public class ModdedEnumOption : ModdedOption<int>
/// </summary> /// </summary>
/// <param name="title">The title of the option.</param> /// <param name="title">The title of the option.</param>
/// <param name="defaultValue">The default value as an int.</param> /// <param name="defaultValue">The default value as an int.</param>
/// <param name="enumType">The Enum type.</param> /// <param name="enumType">The <see cref="Enum"/> type.</param>
/// <param name="values">An option list of string values to use in place of the enum name.</param> /// <param name="values">An option list of string values to use in place of the <see langword="enum"/> name.</param>
/// <param name="includeInPreset">Whether to include this option in the preset or not.</param> /// <param name="includeInPreset">Whether to include this option in the preset or not.</param>
public ModdedEnumOption(string title, int defaultValue, Type enumType, string[]? values = null, bool includeInPreset=true) : base(title, defaultValue, includeInPreset) public ModdedEnumOption(string title, int defaultValue, Type enumType, string[]? values = null, bool includeInPreset=true) : base(title, defaultValue, includeInPreset)
{ {
@@ -90,7 +90,13 @@ public class ModdedEnumOption : ModdedOption<int>
/// <inheritdoc /> /// <inheritdoc />
protected override void OnValueChanged(int newValue) protected override void OnValueChanged(int newValue)
{ {
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(newValue), false); ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
StringName,
Data.GetValueString(newValue),
Configuration.PopUpTextColor,
Configuration.PopUpIconTmp,
false);
if (!OptionBehaviour) if (!OptionBehaviour)
{ {
return; return;
@@ -104,13 +110,13 @@ public class ModdedEnumOption : ModdedOption<int>
} }
/// <summary> /// <summary>
/// An option for selecting an enum value. /// An option for selecting an <see langword="enum"/> value.
/// </summary> /// </summary>
/// <typeparam name="T">The enum type.</typeparam> /// <typeparam name="T">The <see cref="Enum"/> type.</typeparam>
public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
{ {
/// <summary> /// <summary>
/// Gets the string values of the enum. /// Gets the string values of the <see langword="enum"/>.
/// </summary> /// </summary>
public string[] Values { get; } public string[] Values { get; }
@@ -118,8 +124,8 @@ public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
/// Initializes a new instance of the <see cref="ModdedEnumOption{T}"/> class. /// Initializes a new instance of the <see cref="ModdedEnumOption{T}"/> class.
/// </summary> /// </summary>
/// <param name="title">The title of the option.</param> /// <param name="title">The title of the option.</param>
/// <param name="defaultValue">The default value as an int.</param> /// <param name="defaultValue">The default value as an <see langword="int"/>.</param>
/// <param name="values">An option list of string values to use in place of the enum name.</param> /// <param name="values">An option list of string values to use in place of the <see langword="enum"/> name.</param>
/// <param name="includeInPreset">Whether to include this option in the preset or not.</param> /// <param name="includeInPreset">Whether to include this option in the preset or not.</param>
public ModdedEnumOption(string title, T defaultValue, string[]? values = null, bool includeInPreset=true) : base(title, defaultValue, includeInPreset) public ModdedEnumOption(string title, T defaultValue, string[]? values = null, bool includeInPreset=true) : base(title, defaultValue, includeInPreset)
{ {
@@ -183,7 +189,13 @@ public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
/// <inheritdoc /> /// <inheritdoc />
protected override void OnValueChanged(T newValue) protected override void OnValueChanged(T newValue)
{ {
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(Convert.ToInt32(newValue, NumberFormatInfo.InvariantInfo)), false); ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
StringName,
Data.GetValueString(Convert.ToInt32(newValue, NumberFormatInfo.InvariantInfo)),
Configuration.PopUpTextColor,
Configuration.PopUpIconTmp,
false);
if (!OptionBehaviour) if (!OptionBehaviour)
{ {
return; return;
@@ -225,9 +225,12 @@ public class ModdedNumberOption : ModdedOption<float>
protected override void OnValueChanged(float newValue) protected override void OnValueChanged(float newValue)
{ {
Value = Mathf.Clamp(newValue, Min, Max); Value = Mathf.Clamp(newValue, Min, Max);
HudManager.Instance.Notifier.AddSettingsChangeMessage( ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
StringName, StringName,
Data.GetValueString(Value), Data.GetValueString(newValue),
Configuration.PopUpTextColor,
Configuration.PopUpIconTmp,
false); false);
if (OptionBehaviour is NumberOption opt) if (OptionBehaviour is NumberOption opt)
@@ -237,7 +240,7 @@ public class ModdedNumberOption : ModdedOption<float>
} }
/// <summary> /// <summary>
/// Implicitly converts the option to an int. /// Implicitly converts the option to an <see langword="int"/>.
/// </summary> /// </summary>
/// <param name="option">The option.</param> /// <param name="option">The option.</param>
/// <returns>Integer value.</returns> /// <returns>Integer value.</returns>
@@ -4,7 +4,6 @@ using MiraAPI.Networking;
using MiraAPI.PluginLoading; using MiraAPI.PluginLoading;
using Reactor.Localization.Utilities; using Reactor.Localization.Utilities;
using Reactor.Networking.Rpc; using Reactor.Networking.Rpc;
using Reactor.Utilities;
using UnityEngine; using UnityEngine;
namespace MiraAPI.GameOptions.OptionTypes; namespace MiraAPI.GameOptions.OptionTypes;
@@ -190,4 +189,10 @@ public abstract class ModdedOption<T> : IModdedOption
{ {
return option.Value; return option.Value;
} }
/// <inheritdoc />
public AbstractOptionGroup ParentGroup { get; set; }
/// <inheritdoc />
public virtual OptionNotifConfiguration Configuration => new(ParentGroup);
} }
@@ -9,7 +9,7 @@ using Object = UnityEngine.Object;
namespace MiraAPI.GameOptions.OptionTypes; namespace MiraAPI.GameOptions.OptionTypes;
/// <summary> /// <summary>
/// An option for selecting an ingame player. It returns an index of the values list, NOT A PLAYER ID. To get a player out of this, index the Values list. /// An option for selecting an ingame player. It returns an index of the values list, NOT A PLAYER ID. To get a player out of this, index the <see cref="Values"/> list.
/// </summary> /// </summary>
public class ModdedPlayerOption : ModdedOption<int> public class ModdedPlayerOption : ModdedOption<int>
{ {
@@ -91,9 +91,9 @@ public class ModdedPlayerOption : ModdedOption<int>
} }
/// <summary> /// <summary>
/// Returns a player from the value. If AllowNone is enabled and none is enabled this will return null. /// Returns a player from the value. If <see cref="AllowNone"/> is enabled and none is enabled this will return <see langword="null"/>.
/// </summary> /// </summary>
/// <returns>A player or null if chosen none.</returns> /// <returns>A player or <see langword="null"/> if chosen none.</returns>
public NetworkedPlayerInfo? GetPlayerValue() public NetworkedPlayerInfo? GetPlayerValue()
{ {
return Value < 0 ? null : Values[Value]; return Value < 0 ? null : Values[Value];
@@ -126,7 +126,13 @@ public class ModdedPlayerOption : ModdedOption<int>
/// <inheritdoc /> /// <inheritdoc />
protected override void OnValueChanged(int newValue) protected override void OnValueChanged(int newValue)
{ {
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(newValue), false); ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
StringName,
Data.GetValueString(newValue),
Configuration.PopUpTextColor,
Configuration.PopUpIconTmp,
false);
if (!OptionBehaviour) if (!OptionBehaviour)
{ {
return; return;
@@ -71,7 +71,13 @@ public class ModdedToggleOption : ModdedOption<bool>
/// <inheritdoc /> /// <inheritdoc />
protected override void OnValueChanged(bool newValue) protected override void OnValueChanged(bool newValue)
{ {
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, newValue ? "On" : "Off", false); ModdedOptionsManager.AddSettingsChangeMessage(
HudManager.Instance.Notifier,
StringName,
newValue ? "On" : "Off",
Configuration.PopUpTextColor,
Configuration.PopUpIconTmp,
false);
if (!OptionBehaviour) if (!OptionBehaviour)
{ {
return; return;
+1 -1
View File
@@ -1,7 +1,7 @@
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// The location of the custom button on the screen. /// The location of the <see cref="CustomActionButton"/> on the screen.
/// </summary> /// </summary>
public enum ButtonLocation public enum ButtonLocation
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// The uses mode for custom buttons. /// The uses mode for <see cref="CustomActionButton"/>s.
/// </summary> /// </summary>
public enum ButtonUsesMode public enum ButtonUsesMode
{ {
+30 -31
View File
@@ -7,7 +7,6 @@ using MiraAPI.LocalSettings;
using MiraAPI.Patches; using MiraAPI.Patches;
using MiraAPI.Utilities; using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets; using MiraAPI.Utilities.Assets;
using Reactor.Utilities;
using Rewired; using Rewired;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@@ -18,7 +17,7 @@ using Object = UnityEngine.Object;
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// Class for making custom action buttons. More customizable than the default Action/Ability buttons in the base game. /// Class for making custom action buttons. More customizable than the default <see cref="ActionButton"/>/<see cref="AbilityButton"/>s in the base game.
/// </summary> /// </summary>
public abstract class CustomActionButton public abstract class CustomActionButton
{ {
@@ -54,7 +53,7 @@ public abstract class CustomActionButton
public virtual string CooldownTimerFormatString => "0"; public virtual string CooldownTimerFormatString => "0";
/// <summary> /// <summary>
/// Gets a value indicating whether the button has an effect ability. By default true if <see cref="EffectDuration"/> is greater than 0. /// Gets a value indicating whether the button has an effect ability. By default <see langword="true"/> if <see cref="EffectDuration"/> is greater than 0.
/// </summary> /// </summary>
public virtual bool HasEffect => EffectDuration > 0; public virtual bool HasEffect => EffectDuration > 0;
@@ -79,17 +78,17 @@ public abstract class CustomActionButton
public virtual ButtonUsesMode UsesMode => ButtonUsesMode.PerGame; public virtual ButtonUsesMode UsesMode => ButtonUsesMode.PerGame;
/// <summary> /// <summary>
/// Gets the keybind for this button. If null, no keybind will be added. /// Gets the keybind for this button. If <see langword="null"/>, no keybind will be added.
/// </summary> /// </summary>
public virtual BaseKeybind? Keybind => null; public virtual BaseKeybind? Keybind => null;
/// <summary> /// <summary>
/// Gets the button's text outline color. /// Gets the button's text outline <see cref="Color"/>.
/// </summary> /// </summary>
public virtual Color TextOutlineColor => Color.clear; public virtual Color TextOutlineColor => Color.clear;
/// <summary> /// <summary>
/// Gets or sets the location of the button on the screen. /// Gets or sets the <see cref="ButtonLocation"/> on the screen.
/// </summary> /// </summary>
public virtual ButtonLocation Location { get; set; } = ButtonLocation.BottomLeft; public virtual ButtonLocation Location { get; set; } = ButtonLocation.BottomLeft;
@@ -119,12 +118,12 @@ public abstract class CustomActionButton
public float Timer { get; set; } public float Timer { get; set; }
/// <summary> /// <summary>
/// Gets or sets the button object in game. This is created by Mira API automatically. /// Gets or sets the <see cref="ActionButton"/> object in game. This is created by Mira API automatically.
/// </summary> /// </summary>
public ActionButton? Button { get; set; } public ActionButton? Button { get; set; }
/// <summary> /// <summary>
/// Gets the gameObject used for the keybind icon. /// Gets the <see cref="GameObject"/> used for the keybind icon.
/// </summary> /// </summary>
public GameObject? KeybindIcon { get; private set; } public GameObject? KeybindIcon { get; private set; }
@@ -316,18 +315,18 @@ public abstract class CustomActionButton
} }
/// <summary> /// <summary>
/// A utility function to change the outline color of the button's text. /// A utility function to change the outline <see cref="Color"/> of the button's text.
/// </summary> /// </summary>
/// <param name="color">The new color.</param> /// <param name="color">The new <see cref="Color"/>.</param>
public virtual void SetTextOutline(Color color) public virtual void SetTextOutline(Color color)
{ {
Button?.buttonLabelText.SetOutlineColor(color); Button?.buttonLabelText.SetOutlineColor(color);
} }
/// <summary> /// <summary>
/// A utility function to override the sprite of the button. /// A utility function to override the <see cref="UnityEngine.Sprite"/> of the button.
/// </summary> /// </summary>
/// <param name="sprite">The new sprite to override with.</param> /// <param name="sprite">The new <see cref="UnityEngine.Sprite"/> to override with.</param>
public virtual void OverrideSprite(Sprite sprite) public virtual void OverrideSprite(Sprite sprite)
{ {
if (Button != null) if (Button != null)
@@ -415,7 +414,7 @@ public abstract class CustomActionButton
} }
/// <summary> /// <summary>
/// A utility function that runs with the local PlayerControl's FixedUpdate if the button is enabled. /// A utility function that runs with the local player's <see cref="PlayerControl.FixedUpdate"/> if the button is enabled.
/// </summary> /// </summary>
/// <param name="playerControl">the local PlayerControl.</param> /// <param name="playerControl">the local PlayerControl.</param>
protected virtual void FixedUpdate(PlayerControl playerControl) protected virtual void FixedUpdate(PlayerControl playerControl)
@@ -429,10 +428,10 @@ public abstract class CustomActionButton
/// <summary> /// <summary>
/// This method determines if the button should be active or not. /// This method determines if the button should be active or not.
/// True means the button is active, false means the button is disabled. /// <see langword="true"/> means the button is active, <see langword="false"/> means the button is disabled.
/// </summary> /// </summary>
/// <param name="role">The role of the local player.</param> /// <param name="role">The <see cref="RoleBehaviour"/> of the local player.</param>
/// <returns>True if the button is enabled, false otherwise.</returns> /// <returns><see langword="true"/> if the button is enabled, <see langword="false"/> otherwise.</returns>
public abstract bool Enabled(RoleBehaviour? role); public abstract bool Enabled(RoleBehaviour? role);
/// <summary> /// <summary>
@@ -445,7 +444,7 @@ public abstract class CustomActionButton
/// <summary> /// <summary>
/// Returns a value indicating whether the effect can be ended early by the player. /// Returns a value indicating whether the effect can be ended early by the player.
/// Always false by default. /// Always <see langword="false"/> by default.
/// </summary> /// </summary>
/// <returns>Can the effect be canceled.</returns> /// <returns>Can the effect be canceled.</returns>
public virtual bool IsEffectCancellable() => false; public virtual bool IsEffectCancellable() => false;
@@ -473,12 +472,12 @@ public abstract class CustomActionButton
} }
/// <summary> /// <summary>
/// This method is called on the HudManager.SetHudActive method. It determines whether the button should be visible or not. /// This method is called on the <see cref="HudManager.SetHudActive(PlayerControl, RoleBehaviour, bool)"/> method. It determines whether the button should be visible or not.
/// The default behavior is to show the button if the <paramref name="visible"/> parameter and the <see cref="Enabled"/> method return true. /// The default behavior is to show the button if the <paramref name="visible"/> parameter and the <see cref="Enabled"/> method return <see langword="true"/>.
/// It can be overridden for custom behavior. /// It can be overridden for custom behavior.
/// </summary> /// </summary>
/// <param name="visible">Passed in from HudManager.SetHudActive, should hud be active.</param> /// <param name="visible">Passed in from <see cref="HudManager.SetHudActive(PlayerControl, RoleBehaviour, bool)"/>, should hud be active.</param>
/// <param name="role">Passed in from HudManager.SetHudActive, the current role of the player.</param> /// <param name="role">Passed in from <see cref="HudManager.SetHudActive(PlayerControl, RoleBehaviour, bool)"/>, the current role of the player.</param>
public virtual void SetActive(bool visible, RoleBehaviour role) public virtual void SetActive(bool visible, RoleBehaviour role)
{ {
Button?.ToggleVisible(visible && Enabled(role)); Button?.ToggleVisible(visible && Enabled(role));
@@ -522,7 +521,7 @@ public abstract class CustomActionButton
} }
/// <summary> /// <summary>
/// This method is called on the PlayerControl.FixedUpdate method. It is a wrapper for the <see cref="FixedUpdate"/> method. /// This method is called on the <see cref="PlayerControl.FixedUpdate"/> method. It is a wrapper for the <see cref="FixedUpdate"/> method.
/// By default, it handles the cooldown and effect timers, and sets the button to enabled or disabled. /// By default, it handles the cooldown and effect timers, and sets the button to enabled or disabled.
/// It can be overridden for custom behavior. /// It can be overridden for custom behavior.
/// </summary> /// </summary>
@@ -580,39 +579,39 @@ public abstract class CustomActionButton
} }
/// <summary> /// <summary>
/// Custom action button that has a target object. /// Custom action button that has a target <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <typeparam name="T">The type of the target object.</typeparam> /// <typeparam name="T">The type of the target object.</typeparam>
public abstract class CustomActionButton<T> : CustomActionButton where T : MonoBehaviour public abstract class CustomActionButton<T> : CustomActionButton where T : MonoBehaviour
{ {
/// <summary> /// <summary>
/// Gets or sets the target object of the button. /// Gets or sets the target <typeparamref name="T"/> of the button.
/// </summary> /// </summary>
public T? Target { get; set; } public T? Target { get; set; }
/// <summary> /// <summary>
/// Gets the distance the player must be from the target object to use the button. /// Gets the distance the player must be from the target <typeparamref name="T"/> to use the button.
/// </summary> /// </summary>
public virtual float Distance => PlayerControl.LocalPlayer.Data.Role.GetAbilityDistance(); public virtual float Distance => PlayerControl.LocalPlayer.Data.Role.GetAbilityDistance();
/// <summary> /// <summary>
/// Determines if the target object is valid. /// Determines if the target <typeparamref name="T"/> is valid.
/// </summary> /// </summary>
/// <param name="target">The target object being checked.</param> /// <param name="target">The target <typeparamref name="T"/> being checked.</param>
/// <returns>True if the target object is valid, false otherwise.</returns> /// <returns><see langword="true"/> if the target <typeparamref name="T"/> is valid, <see langword="false"/> otherwise.</returns>
public virtual bool IsTargetValid(T? target) public virtual bool IsTargetValid(T? target)
{ {
return target != null; return target != null;
} }
/// <summary> /// <summary>
/// The method used to get the target object. /// The method used to get the target <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <returns>The target object or null if it isn't found.</returns> /// <returns>The target <typeparamref name="T"/> or <see langword="null"/> if it isn't found.</returns>
public abstract T? GetTarget(); public abstract T? GetTarget();
/// <summary> /// <summary>
/// Sets the outline of the target object. /// Sets the outline of the target <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <param name="active">Should the outline be active.</param> /// <param name="active">Should the outline be active.</param>
public abstract void SetOutline(bool active); public abstract void SetOutline(bool active);
+2 -3
View File
@@ -4,17 +4,16 @@ using System.Collections.ObjectModel;
using System.Reflection; using System.Reflection;
using MiraAPI.Events.Mira; using MiraAPI.Events.Mira;
using MiraAPI.PluginLoading; using MiraAPI.PluginLoading;
using UnityEngine;
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// Custom button manager for handling custom buttons. /// Custom button manager for handling <see cref="CustomActionButton"/>s.
/// </summary> /// </summary>
public static class CustomButtonManager public static class CustomButtonManager
{ {
/// <summary> /// <summary>
/// Gets a list of all registered custom buttons. /// Gets a list of all registered custom <see cref="CustomActionButton"/>s.
/// </summary> /// </summary>
public static ReadOnlyCollection<CustomActionButton> Buttons { get; internal set; } = new([]); public static ReadOnlyCollection<CustomActionButton> Buttons { get; internal set; } = new([]);
+2 -2
View File
@@ -4,7 +4,7 @@ using System.Linq;
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// A utility class to get the instance of a custom action button. /// A utility class to get the instance of a <see cref="CustomActionButton"/>.
/// </summary> /// </summary>
/// <typeparam name="T">The type of the button you are trying to access.</typeparam> /// <typeparam name="T">The type of the button you are trying to access.</typeparam>
public static class CustomButtonSingleton<T> where T : CustomActionButton public static class CustomButtonSingleton<T> where T : CustomActionButton
@@ -12,7 +12,7 @@ public static class CustomButtonSingleton<T> where T : CustomActionButton
private static T? _instance; private static T? _instance;
/// <summary> /// <summary>
/// Gets the instance of the button. /// Gets the instance of the <typeparamref name="T"/> button.
/// </summary> /// </summary>
[SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "This is a utility class to get the instance of a custom action button.")] [SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "This is a utility class to get the instance of a custom action button.")]
public static T Instance => _instance ??= CustomButtonManager.CustomButtons.OfType<T>().Single(); public static T Instance => _instance ??= CustomButtonManager.CustomButtons.OfType<T>().Single();
+6 -6
View File
@@ -15,9 +15,9 @@ using UnityEngine.Events;
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// Custom Player Menu using the ShapeshifterPanel as a base. /// Custom Player Menu using the <see cref="ShapeshifterPanel"/> as a base.
/// </summary> /// </summary>
/// <param name="il2CppPtr">Used by Il2Cpp. Do not use constructor, this is a MonoBehaviour.</param> /// <param name="il2CppPtr">Used by Il2Cpp. Do not use constructor, this is a <see cref="MonoBehaviour"/>.</param>
[RegisterInIl2Cpp] [RegisterInIl2Cpp]
[SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Unity Convention")] [SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Unity Convention")]
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Unity Convention")] [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Unity Convention")]
@@ -34,9 +34,9 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
public List<ShapeshifterPanel> potentialVictims; public List<ShapeshifterPanel> potentialVictims;
/// <summary> /// <summary>
/// Creates a CustomPlayerMenu. /// Creates a <see cref="CustomPlayerMenu"/>.
/// </summary> /// </summary>
/// <returns>New CustomPlayerMenu object.</returns> /// <returns>New <see cref="CustomPlayerMenu"/> object.</returns>
public static CustomPlayerMenu Create() public static CustomPlayerMenu Create()
{ {
var shapeShifterRole = RoleManager.Instance.GetRole(RoleTypes.Shapeshifter); var shapeShifterRole = RoleManager.Instance.GetRole(RoleTypes.Shapeshifter);
@@ -84,7 +84,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
/// Begins/opens the custom player menu. /// Begins/opens the custom player menu.
/// </summary> /// </summary>
/// <param name="playerMatch">Function to determine if player should show in the custom menu.</param> /// <param name="playerMatch">Function to determine if player should show in the custom menu.</param>
/// <param name="onClick">Onclick action for player.</param> /// <param name="onClick"><see cref="PassiveButton.OnClick"/> action for player.</param>
[HideFromIl2Cpp] [HideFromIl2Cpp]
public void Begin(Func<PlayerControl, bool> playerMatch, Action<PlayerControl?> onClick) public void Begin(Func<PlayerControl, bool> playerMatch, Action<PlayerControl?> onClick)
{ {
@@ -96,7 +96,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
onClick(null); onClick(null);
})); }));
DestroyableSingleton<DebugAnalytics>.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType); DebugAnalytics.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
var list = PlayerControl.AllPlayerControls.ToArray().Where(playerMatch).ToList(); var list = PlayerControl.AllPlayerControls.ToArray().Where(playerMatch).ToList();
potentialVictims = []; potentialVictims = [];
var list2 = new Il2CppSystem.Collections.Generic.List<UiElement>(); var list2 = new Il2CppSystem.Collections.Generic.List<UiElement>();
+6 -4
View File
@@ -1,12 +1,11 @@
using System.Linq; using System.Linq;
using HarmonyLib; using HarmonyLib;
using Reactor.Utilities.Extensions;
using UnityEngine; using UnityEngine;
namespace MiraAPI.Hud; namespace MiraAPI.Hud;
/// <summary> /// <summary>
/// Custom action button that has multiple target objects. /// <see cref="CustomActionButton"/> that has multiple target objects.
/// </summary> /// </summary>
/// <typeparam name="T">The type of the target objects.</typeparam> /// <typeparam name="T">The type of the target objects.</typeparam>
public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBehaviour public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBehaviour
@@ -36,8 +35,11 @@ public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBe
/// <returns>The list of target objects.</returns> /// <returns>The list of target objects.</returns>
public abstract T[] GetTargets(); public abstract T[] GetTargets();
/// <inheritdoc cref="CustomActionButton{T}.SetOutline"/> /// <summary>
/// <param name="target">The target object to set the oultine.</param> /// Sets the outline of the target <typeparamref name="T"/>.
/// </summary>
/// <param name="target">The target <typeparamref name="T"/> to set the oultine.</param>
/// <param name="active">Should the outline be active.</param>
public abstract void SetOutline(T target, bool active); public abstract void SetOutline(T target, bool active);
/// <inheritdoc cref="CustomActionButton{T}.CanUse"/> /// <inheritdoc cref="CustomActionButton{T}.CanUse"/>
+1 -1
View File
@@ -14,7 +14,7 @@ public class BaseKeybind
public InputAction? RewiredInputAction { get; internal set; } public InputAction? RewiredInputAction { get; internal set; }
/// <summary> /// <summary>
/// Gets the unique identifier for this keybind. Used in Rewired. /// Gets or sets the unique identifier for this keybind. Used in Rewired.
/// </summary> /// </summary>
public string Id { get; protected set; } public string Id { get; protected set; }
+5 -6
View File
@@ -3,18 +3,17 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Attributes;
using MiraAPI.Utilities; using MiraAPI.Utilities;
using Reactor.Utilities;
using Rewired; using Rewired;
namespace MiraAPI.Keybinds; namespace MiraAPI.Keybinds;
/// <summary> /// <summary>
/// Lets you register and manage mod keybinds with conflict checks and rebinding support. /// Lets you register and manage mod <see cref="MiraKeybind"/>s with conflict checks and rebinding support.
/// </summary> /// </summary>
public static class KeybindManager public static class KeybindManager
{ {
/// <summary> /// <summary>
/// Gets a list of all registered keybinds. /// Gets a list of all registered <see cref="MiraKeybind"/>s.
/// </summary> /// </summary>
public static List<MiraKeybind> Keybinds { get; } = new(); public static List<MiraKeybind> Keybinds { get; } = new();
@@ -49,7 +48,7 @@ public static class KeybindManager
} }
/// <summary> /// <summary>
/// Returns all conflicts where keybinds use the same key. /// Returns all conflicts where <see cref="MiraKeybind"/>s use the same key.
/// </summary> /// </summary>
/// <returns>A list of pairs of keybinds that conflict.</returns> /// <returns>A list of pairs of keybinds that conflict.</returns>
public static Dictionary<KeyboardKeyCode, List<MiraKeybind>> GetConflicts() public static Dictionary<KeyboardKeyCode, List<MiraKeybind>> GetConflicts()
@@ -77,11 +76,11 @@ public static class KeybindManager
} }
/// <summary> /// <summary>
/// Returns all keybinds for a specified keycode. /// Returns all <see cref="MiraKeybind"/>s for a specified keycode.
/// </summary> /// </summary>
/// <param name="keyCode">The key to look for.</param> /// <param name="keyCode">The key to look for.</param>
/// /// <param name="exclusiveCheck">Should only exlusive keybinds be present.</param> /// /// <param name="exclusiveCheck">Should only exlusive keybinds be present.</param>
/// <returns>The list of keybinds.</returns> /// <returns>The list of <see cref="MiraKeybind"/>s.</returns>
public static MiraKeybind[] GetKeybindsForKey(KeyboardKeyCode keyCode, bool exclusiveCheck = false) public static MiraKeybind[] GetKeybindsForKey(KeyboardKeyCode keyCode, bool exclusiveCheck = false)
{ {
var all = new List<MiraKeybind>(); var all = new List<MiraKeybind>();
+5 -5
View File
@@ -14,9 +14,9 @@ public static class KeybindUtils
public static InputManager_Base? RewiredInputManager { get; internal set; } public static InputManager_Base? RewiredInputManager { get; internal set; }
/// <summary> /// <summary>
/// Returns the currently assigned keycode of a keybind. /// Returns the currently assigned keycode of a <see cref="BaseKeybind"/>.
/// </summary> /// </summary>
/// <param name="keybind">The keybind to get the keycode from.</param> /// <param name="keybind">The <see cref="BaseKeybind"/> to get the keycode from.</param>
/// <returns>The currently assigned keycode.</returns> /// <returns>The currently assigned keycode.</returns>
public static KeyboardKeyCode GetKeycodeByKeybind(BaseKeybind keybind) public static KeyboardKeyCode GetKeycodeByKeybind(BaseKeybind keybind)
{ {
@@ -29,7 +29,7 @@ public static class KeybindUtils
} }
/// <summary> /// <summary>
/// Gets the keycode for an action with ReInput. /// Gets the keycode for an action with <see cref="ReInput"/>.
/// </summary> /// </summary>
/// <param name="actionId">The action ID.</param> /// <param name="actionId">The action ID.</param>
/// <returns>The keyboard keycode.</returns> /// <returns>The keyboard keycode.</returns>
@@ -39,7 +39,7 @@ public static class KeybindUtils
} }
/// <summary> /// <summary>
/// Gets a <see cref="ActionElementMap"/> by id with ReInput. /// Gets a <see cref="ActionElementMap"/> by id with <see cref="ReInput"/>.
/// </summary> /// </summary>
/// <param name="actionId">The action ID.</param> /// <param name="actionId">The action ID.</param>
/// <returns>The keyboard keycode.</returns> /// <returns>The keyboard keycode.</returns>
@@ -65,7 +65,7 @@ public static class KeybindUtils
/// <param name="exclude">The KeyCode to skip during the search.</param> /// <param name="exclude">The KeyCode to skip during the search.</param>
/// <returns> /// <returns>
/// The first available KeyCode not currently used by any registered keybind, /// The first available KeyCode not currently used by any registered keybind,
/// or KeyCode.None if none are available. /// or <see cref="KeyboardKeyCode.None"/> if none are available.
/// </returns> /// </returns>
public static KeyboardKeyCode FindAvailableKey(KeyboardKeyCode exclude) public static KeyboardKeyCode FindAvailableKey(KeyboardKeyCode exclude)
{ {
+1 -1
View File
@@ -3,7 +3,7 @@
namespace MiraAPI.Keybinds; namespace MiraAPI.Keybinds;
/// <summary> /// <summary>
/// Class containing all default keybinds. /// Class containing all default <see cref="MiraKeybind"/>s.
/// Recommended for cross-mod compatibility. /// Recommended for cross-mod compatibility.
/// </summary> /// </summary>
[RegisterCustomKeybinds] [RegisterCustomKeybinds]
+3 -3
View File
@@ -19,8 +19,8 @@ public class MiraKeybind : BaseKeybind
public KeyboardKeyCode DefaultKey { get; } public KeyboardKeyCode DefaultKey { get; }
/// <summary> /// <summary>
/// Gets the modifier keys assigned to this keybind. /// Gets the <see cref="ModifierKey"/>s assigned to this keybind.
/// Due to Rewired limitations, there can only be 3 modifier keys. /// Due to Rewired limitations, there can only be 3 <see cref="ModifierKey"/>s.
/// </summary> /// </summary>
public ModifierKey[] ModifierKeys { get; } public ModifierKey[] ModifierKeys { get; }
@@ -36,7 +36,7 @@ public class MiraKeybind : BaseKeybind
/// </summary> /// </summary>
/// <param name="name">The name of the keybind.</param> /// <param name="name">The name of the keybind.</param>
/// <param name="defaultKeycode">The default keycode.</param> /// <param name="defaultKeycode">The default keycode.</param>
/// <param name="modifierKeys">Up to 3 optional modifier keys.</param> /// <param name="modifierKeys">Up to 3 optional <see cref="ModifierKey"/>s.</param>
/// <param name="exclusive">Is exclusive.</param> /// <param name="exclusive">Is exclusive.</param>
public MiraKeybind( public MiraKeybind(
string name, string name,
@@ -3,7 +3,7 @@
namespace MiraAPI.Keybinds; namespace MiraAPI.Keybinds;
/// <summary> /// <summary>
/// Used to mark a class for custom keybinds registration. /// Used to mark a class for <see cref="MiraKeybind"/>s registration.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomKeybindsAttribute : Attribute; public class RegisterCustomKeybindsAttribute : Attribute;
+2 -2
View File
@@ -1,4 +1,4 @@
using Rewired; using System.Globalization;
namespace MiraAPI.Keybinds; namespace MiraAPI.Keybinds;
@@ -19,6 +19,6 @@ public class VanillaKeybind : BaseKeybind
public VanillaKeybind(int id) public VanillaKeybind(int id)
{ {
RewiredInputAction = KeybindUtils.GetInputActionById(id); RewiredInputAction = KeybindUtils.GetInputActionById(id);
Id = RewiredInputAction != null ? RewiredInputAction.name : id.ToString(); Id = RewiredInputAction != null ? RewiredInputAction.name : id.ToString(CultureInfo.InvariantCulture);
} }
} }
+3 -3
View File
@@ -1,15 +1,15 @@
namespace MiraAPI.Keybinds; namespace MiraAPI.Keybinds;
/// <summary> /// <summary>
/// Singleton for getting a vanilla keybind by <see cref="ActionButton"/>. /// Singleton for getting a <see cref="VanillaKeybind"/> by <see cref="ActionButton"/>.
/// </summary> /// </summary>
/// <typeparam name="T">ActionButton type.</typeparam> /// <typeparam name="T"><see cref="AccountButton"/> type.</typeparam>
public static class VanillaKeybinding<T> where T : ActionButton public static class VanillaKeybinding<T> where T : ActionButton
{ {
private static VanillaKeybind? _instance; private static VanillaKeybind? _instance;
/// <summary> /// <summary>
/// Gets the instance of the option group. /// Gets the instance of the <see cref="VanillaKeybind"/>.
/// </summary> /// </summary>
#pragma warning disable CA1000 #pragma warning disable CA1000
public static VanillaKeybind Instance => _instance ??= KeybindManager.VanillaKeybinds[typeof(T)]; public static VanillaKeybind Instance => _instance ??= KeybindManager.VanillaKeybinds[typeof(T)];
@@ -5,9 +5,9 @@ using MiraAPI.LocalSettings.SettingTypes;
namespace MiraAPI.LocalSettings.Attributes; namespace MiraAPI.LocalSettings.Attributes;
/// <summary> /// <summary>
/// Creates an enum setting for the <see cref="ConfigEntry{T}"/>. /// Creates a <see cref="LocalEnumSetting"/> for the <see cref="ConfigEntry{T}"/>.
/// </summary> /// </summary>
/// <param name="names">Optional custom enum names.</param> /// <param name="names">Optional custom <see langword="enum"/> names.</param>
/// <inheritdoc/> /// <inheritdoc/>
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public class LocalEnumSettingAttribute( public class LocalEnumSettingAttribute(
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
namespace MiraAPI.LocalSettings.Attributes; namespace MiraAPI.LocalSettings.Attributes;
/// <summary> /// <summary>
/// Creates a number setting for the <see cref="ConfigEntry{T}"/>. /// Creates a <see cref="LocalNumberSetting"/> for the <see cref="ConfigEntry{T}"/>.
/// </summary> /// </summary>
/// <param name="min">Minimum range.</param> /// <param name="min">Minimum range.</param>
/// <param name="max">Maximum range.</param> /// <param name="max">Maximum range.</param>
@@ -15,10 +15,10 @@ public abstract class LocalSettingAttribute(
) : Attribute ) : Attribute
{ {
/// <summary> /// <summary>
/// Returns the created setting object. /// Returns the created <see cref="ILocalSetting"/> object.
/// </summary> /// </summary>
/// <param name="tab">Gets the tab where the setting is located.</param> /// <param name="tab">Gets the tab where the setting is located.</param>
/// <param name="configEntryBase">Gets the config entry the setting is attached to.</param> /// <param name="configEntryBase">Gets the config entry the setting is attached to.</param>
/// <returns>The created class.</returns> /// <returns>The created <see cref="ILocalSetting"/>.</returns>
public abstract ILocalSetting CreateSetting(Type tab, ConfigEntryBase configEntryBase); public abstract ILocalSetting CreateSetting(Type tab, ConfigEntryBase configEntryBase);
} }
@@ -1,5 +1,4 @@
using System; using System;
using BepInEx.Configuration;
namespace MiraAPI.LocalSettings.Attributes; namespace MiraAPI.LocalSettings.Attributes;
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
namespace MiraAPI.LocalSettings.Attributes; namespace MiraAPI.LocalSettings.Attributes;
/// <summary> /// <summary>
/// Creates a slider setting for the <see cref="ConfigEntry{T}"/>. /// Creates a <see cref="LocalSliderSetting"/> for the <see cref="ConfigEntry{T}"/>.
/// </summary> /// </summary>
/// <inheritdoc/> /// <inheritdoc/>
/// <param name="min">Minimum range.</param> /// <param name="min">Minimum range.</param>
@@ -5,7 +5,7 @@ using MiraAPI.LocalSettings.SettingTypes;
namespace MiraAPI.LocalSettings.Attributes; namespace MiraAPI.LocalSettings.Attributes;
/// <summary> /// <summary>
/// Creates a toggle setting for the <see cref="ConfigEntry{T}"/>. /// Creates a <see cref="LocalToggleSetting"/> for the <see cref="ConfigEntry{T}"/>.
/// </summary> /// </summary>
/// <inheritdoc/> /// <inheritdoc/>
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
+5 -5
View File
@@ -19,7 +19,7 @@ public interface ILocalSetting
string Description { get; } string Description { get; }
/// <summary> /// <summary>
/// Gets the setting's gameobject. /// Gets the setting's <see cref="GameObject"/>.
/// </summary> /// </summary>
GameObject? Setting { get; } GameObject? Setting { get; }
@@ -31,12 +31,12 @@ public interface ILocalSetting
/// <summary> /// <summary>
/// Used to create the setting. /// Used to create the setting.
/// </summary> /// </summary>
/// <param name="toggle">Toggle template.</param> /// <param name="toggle"><see cref="ToggleButtonBehaviour"/> template.</param>
/// <param name="slider">Slider template.</param> /// <param name="slider"><see cref="SlideBar"/> template.</param>
/// <param name="parent">The parent of the setting.</param> /// <param name="parent">The parent <see cref="Transform"/> of the setting.</param>
/// <param name="offset">The offset.</param> /// <param name="offset">The offset.</param>
/// <param name="order">The order.</param> /// <param name="order">The order.</param>
/// <param name="last">Whether it's the last on the row.</param> /// <param name="last">Whether it's the last on the row.</param>
/// <returns>The created setting.</returns> /// <returns>The created setting's <see cref="GameObject"/>.</returns>
GameObject? CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last); GameObject? CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
} }
+2 -3
View File
@@ -1,6 +1,5 @@
using System; using System;
using MiraAPI.Utilities; using MiraAPI.Utilities;
using Reactor.Localization.Utilities;
using Reactor.Utilities.Extensions; using Reactor.Utilities.Extensions;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@@ -10,7 +9,7 @@ using Object = UnityEngine.Object;
namespace MiraAPI.LocalSettings; namespace MiraAPI.LocalSettings;
/// <summary> /// <summary>
/// Represents a local settings button. /// Represents a <see cref="LocalSettingsTab"/> button.
/// </summary> /// </summary>
public class LocalSettingsButton(string text, Action onClick) public class LocalSettingsButton(string text, Action onClick)
{ {
@@ -25,7 +24,7 @@ public class LocalSettingsButton(string text, Action onClick)
public Action OnClick { get; set; } = onClick; public Action OnClick { get; set; } = onClick;
/// <summary> /// <summary>
/// Gets the tab instance this button belongs to. /// Gets the <see cref="LocalSettingsTab"/> instance this button belongs to.
/// </summary> /// </summary>
public LocalSettingsTab? Tab { get; internal set; } public LocalSettingsTab? Tab { get; internal set; }
@@ -2,18 +2,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP;
using MiraAPI.GameOptions;
using Reactor.Utilities;
namespace MiraAPI.LocalSettings; namespace MiraAPI.LocalSettings;
/// <summary> /// <summary>
/// Manages local settings. /// Manages <see cref="LocalSettingsTab"/>s.
/// </summary> /// </summary>
public static class LocalSettingsManager public static class LocalSettingsManager
{ {
internal static readonly Dictionary<Type, LocalSettingsTab> TypeToTab = []; internal static readonly Dictionary<Type, LocalSettingsTab> TypeToTab = [];
internal static readonly List<LocalSettingsTab> Tabs = []; internal static readonly List<LocalSettingsTab> Tabs = [];
internal static readonly List<LocalSettingsTab> AvailableTabs = [];
internal static bool RegisterTab(Type type, BasePlugin pluginInfo) internal static bool RegisterTab(Type type, BasePlugin pluginInfo)
{ {
@@ -29,6 +28,10 @@ public static class LocalSettingsManager
} }
Tabs.Add(tab); Tabs.Add(tab);
if (tab.ShouldCreateButton)
{
AvailableTabs.Add(tab);
}
TypeToTab.Add(type, tab); TypeToTab.Add(type, tab);
typeof(LocalSettingsTabSingleton<>).MakeGenericType(type) typeof(LocalSettingsTabSingleton<>).MakeGenericType(type)
+4 -4
View File
@@ -23,7 +23,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
public abstract string TabName { get; } public abstract string TabName { get; }
/// <summary> /// <summary>
/// Gets the tab appearance. /// Gets the tab's <see cref="LocalSettingTabAppearance"/>.
/// </summary> /// </summary>
public virtual LocalSettingTabAppearance TabAppearance { get; } = new(); public virtual LocalSettingTabAppearance TabAppearance { get; } = new();
@@ -38,7 +38,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
protected virtual bool ShouldCreateLabels => true; protected virtual bool ShouldCreateLabels => true;
/// <summary> /// <summary>
/// Gets the mod's config file. Automatically found in the plugin loader. /// Gets the mod's <see cref="ConfigFile"/>. Automatically found in the plugin loader.
/// </summary> /// </summary>
public ConfigFile Config { get; } = config ?? throw new ArgumentNullException(nameof(config)); public ConfigFile Config { get; } = config ?? throw new ArgumentNullException(nameof(config));
@@ -48,12 +48,12 @@ public abstract class LocalSettingsTab(ConfigFile config)
public TabGroup? TabButton { get; internal set; } public TabGroup? TabButton { get; internal set; }
/// <summary> /// <summary>
/// Gets the list of settings. /// Gets the list of <see cref="ILocalSetting"/>s.
/// </summary> /// </summary>
public List<ILocalSetting> Settings { get; } = []; public List<ILocalSetting> Settings { get; } = [];
/// <summary> /// <summary>
/// Gets the list of buttons. /// Gets the list of <see cref="LocalSettingsButton"/>s.
/// </summary> /// </summary>
public List<LocalSettingsButton> Buttons { get; } = []; public List<LocalSettingsButton> Buttons { get; } = [];
@@ -4,93 +4,93 @@ using UnityEngine;
namespace MiraAPI.LocalSettings; namespace MiraAPI.LocalSettings;
/// <summary> /// <summary>
/// Struct for modifying tab appearance. /// Struct for modifying <see cref="LocalSettingsTab"/> appearance.
/// Defines how the settings look. /// Defines how the settings look.
/// </summary> /// </summary>
public record struct LocalSettingTabAppearance() public record struct LocalSettingTabAppearance()
{ {
/// <summary> /// <summary>
/// Gets or sets main color of the tab. /// Gets or sets the main <see cref="Color"/> of the <see cref="LocalSettingsTab"/>.
/// </summary> /// </summary>
public Color TabColor { get; set; } = Color.white; public Color TabColor { get; set; } = Color.white;
/// <summary> /// <summary>
/// Gets or sets tab button icon. No icon by default. /// Gets or sets the <see cref="LocalSettingsTab"/> button icon. No icon by default.
/// </summary> /// </summary>
public LoadableAsset<Sprite>? TabIcon { get; set; } public LoadableAsset<Sprite>? TabIcon { get; set; }
/// <summary> /// <summary>
/// Gets or sets color of the tab button. /// Gets or sets the <see cref="Color"/> of the <see cref="LocalSettingsTab"/> button.
/// </summary> /// </summary>
public Color TabButtonColor { get; set; } = Color.white; public Color TabButtonColor { get; set; } = Color.white;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the icon should be hidden when tab button is hovered. /// Gets or sets a value indicating whether the icon should be hidden when the <see cref="LocalSettingsTab"/> button is hovered.
/// </summary> /// </summary>
public bool HideIconOnHover { get; set; } = true; public bool HideIconOnHover { get; set; } = true;
/// <summary> /// <summary>
/// Gets or sets hover color of the tab button. /// Gets or sets the hover <see cref="Color"/> of the <see cref="LocalSettingsTab"/> button.
/// </summary> /// </summary>
public Color TabButtonHoverColor { get; set; } = Palette.AcceptedGreen; public Color TabButtonHoverColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets active color of the tab button. /// Gets or sets the active <see cref="Color"/> of the <see cref="LocalSettingsTab"/> button.
/// </summary> /// </summary>
public Color TabButtonActiveColor { get; set; } = Palette.AcceptedGreen; public Color TabButtonActiveColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets hover color of toggles. /// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalToggleSetting"/>s.
/// </summary> /// </summary>
public Color ToggleHoverColor { get; set; } = Palette.AcceptedGreen; public Color ToggleHoverColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets active color of toggles. /// Gets or sets the active <see cref="Color"/> of <see cref="SettingTypes.LocalToggleSetting"/>s.
/// </summary> /// </summary>
public Color ToggleActiveColor { get; set; } = Palette.AcceptedGreen; public Color ToggleActiveColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets inactive color of toggles. /// Gets or sets the inactive <see cref="Color"/> of <see cref="SettingTypes.LocalToggleSetting"/>s.
/// </summary> /// </summary>
public Color ToggleInactiveColor { get; set; } = Color.red; public Color ToggleInactiveColor { get; set; } = Color.red;
/// <summary> /// <summary>
/// Gets or sets color of number buttons. /// Gets or sets the <see cref="Color"/> of <see cref="SettingTypes.LocalNumberSetting"/> buttons.
/// </summary> /// </summary>
public Color NumberColor { get; set; } = Color.white; public Color NumberColor { get; set; } = Color.white;
/// <summary> /// <summary>
/// Gets or sets hover color of number buttons. /// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalNumberSetting"/> buttons.
/// </summary> /// </summary>
public Color NumberHoverColor { get; set; } = Palette.AcceptedGreen; public Color NumberHoverColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets color of sliders. /// Gets or sets the <see cref="Color"/> of <see cref="SettingTypes.LocalSliderSetting"/>s.
/// </summary> /// </summary>
public Color SliderColor { get; set; } = Color.white; public Color SliderColor { get; set; } = Color.white;
/// <summary> /// <summary>
/// Gets or sets hover color of sliders. /// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalSliderSetting"/>s.
/// </summary> /// </summary>
public Color SliderHoverColor { get; set; } = Palette.AcceptedGreen; public Color SliderHoverColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets color of enum buttons. /// Gets or sets the <see cref="Color"/> of <see cref="SettingTypes.LocalEnumSetting"/> buttons.
/// </summary> /// </summary>
public Color EnumColor { get; set; } = Color.white; public Color EnumColor { get; set; } = Color.white;
/// <summary> /// <summary>
/// Gets or sets hover color of enum buttons. /// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalEnumSetting"/> buttons.
/// </summary> /// </summary>
public Color EnumHoverColor { get; set; } = Palette.AcceptedGreen; public Color EnumHoverColor { get; set; } = Palette.AcceptedGreen;
/// <summary> /// <summary>
/// Gets or sets color of buttons. /// Gets or sets the <see cref="Color"/> of buttons.
/// </summary> /// </summary>
public Color ButtonColor { get; set; } = Color.white; public Color ButtonColor { get; set; } = Color.white;
/// <summary> /// <summary>
/// Gets or sets hover color of buttons. /// Gets or sets the hover <see cref="Color"/> of buttons.
/// </summary> /// </summary>
public Color ButtonHoverColor { get; set; } = Palette.AcceptedGreen; public Color ButtonHoverColor { get; set; } = Palette.AcceptedGreen;
} }
@@ -3,7 +3,7 @@
namespace MiraAPI.LocalSettings; namespace MiraAPI.LocalSettings;
/// <summary> /// <summary>
/// Singleton for local settings tabs. /// Singleton for <see cref="LocalSettingsTab"/>s.
/// </summary> /// </summary>
/// <typeparam name="T">The settings tab type.</typeparam> /// <typeparam name="T">The settings tab type.</typeparam>
public static class LocalSettingsTabSingleton<T> where T : LocalSettingsTab public static class LocalSettingsTabSingleton<T> where T : LocalSettingsTab
@@ -11,7 +11,7 @@ public static class LocalSettingsTabSingleton<T> where T : LocalSettingsTab
private static T? _instance; private static T? _instance;
/// <summary> /// <summary>
/// Gets the instance of the setting tab. /// Gets the instance of the <typeparamref name="T"/> setting tab.
/// </summary> /// </summary>
#pragma warning disable CA1000 #pragma warning disable CA1000
public static T Instance => _instance ??= LocalSettingsManager.Tabs.OfType<T>().Single(); public static T Instance => _instance ??= LocalSettingsManager.Tabs.OfType<T>().Single();
@@ -11,17 +11,17 @@ using Object = UnityEngine.Object;
namespace MiraAPI.LocalSettings.SettingTypes; namespace MiraAPI.LocalSettings.SettingTypes;
/// <summary> /// <summary>
/// Local setting class for enums. /// Local setting class for <see langword="enum"/>s.
/// </summary> /// </summary>
public class LocalEnumSetting : LocalSettingBase<int> public class LocalEnumSetting : LocalSettingBase<int>
{ {
/// <summary> /// <summary>
/// Gets the enum type of the setting. /// Gets the <see cref="Enum"/> type of the setting.
/// </summary> /// </summary>
public Type EnumType { get; } public Type EnumType { get; }
/// <summary> /// <summary>
/// Gets the enum values. /// Gets the <see langword="enum"/> values.
/// </summary> /// </summary>
public string[] Values { get; } public string[] Values { get; }
@@ -29,8 +29,8 @@ public class LocalEnumSetting : LocalSettingBase<int>
/// Initializes a new instance of the <see cref="LocalEnumSetting"/> class. /// Initializes a new instance of the <see cref="LocalEnumSetting"/> class.
/// </summary> /// </summary>
/// <inheritdoc/> /// <inheritdoc/>
/// <param name="enumType">The enum type.</param> /// <param name="enumType">The <see cref="Enum"/> type.</param>
/// <param name="values">The optional values array to replace the enum names.</param> /// <param name="values">The optional values array to replace the <see langword="enum"/> names.</param>
public LocalEnumSetting( public LocalEnumSetting(
Type tab, Type tab,
ConfigEntryBase configEntry, ConfigEntryBase configEntry,
@@ -43,6 +43,12 @@ public abstract class LocalSettingBase<T> : ILocalSetting
/// <summary> /// <summary>
/// Creates an instance of the setting. /// Creates an instance of the setting.
/// </summary> /// </summary>
/// <param name="toggle">Toggle option to create.</param>
/// <param name="slider">Slider option to create.</param>
/// <param name="parent">The parent options menu.</param>
/// <param name="offset">the Y Offset for the option in the menu.</param>
/// <param name="order">The order of the option.</param>
/// <param name="last">Whether the option is the last in a row.</param>
/// <returns>The created setting.</returns> /// <returns>The created setting.</returns>
public abstract GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last); public abstract GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
@@ -56,9 +62,9 @@ public abstract class LocalSettingBase<T> : ILocalSetting
} }
/// <summary> /// <summary>
/// Gets the value of the config entry, cast to the setting type. /// Gets the value of the config entry, cast to <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <returns>The value.</returns> /// <returns>The <typeparamref name="T"/> value.</returns>
public virtual T GetValue() public virtual T GetValue()
{ {
return (T)ConfigEntry.BoxedValue; return (T)ConfigEntry.BoxedValue;
+1 -1
View File
@@ -9,7 +9,7 @@ using UnityEngine;
namespace MiraAPI; namespace MiraAPI;
/// <summary> /// <summary>
/// Mira API Config File Handler. /// Mira API <see cref="ConfigFile"/> Handler.
/// </summary> /// </summary>
public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config) public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
{ {
+2 -2
View File
@@ -17,8 +17,8 @@ public static class ModCompatibility
/// <summary> /// <summary>
/// Checks if the Submerged mod is loaded. /// Checks if the Submerged mod is loaded.
/// </summary> /// </summary>
/// <param name="submergedAssembly">Submerged mod assembly if loaded, null otherwise.</param> /// <param name="submergedAssembly">Submerged mod assembly if loaded, <see langword="null"/> otherwise.</param>
/// <returns>True if the Submerged mod is loaded, false otherwise.</returns> /// <returns><see langword="true"/> if the Submerged mod is loaded, <see langword="false"/> otherwise.</returns>
public static bool SubmergedLoaded([NotNullWhen(true)] out Assembly? submergedAssembly) public static bool SubmergedLoaded([NotNullWhen(true)] out Assembly? submergedAssembly)
{ {
var result = IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin); var result = IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin);
+5 -5
View File
@@ -1,10 +1,10 @@
namespace MiraAPI.Modifiers; namespace MiraAPI.Modifiers;
/// <summary> /// <summary>
/// Represents the assignment configuration for a game modifier. /// Represents the assignment configuration for a <see cref="Types.GameModifier"/>.
/// </summary> /// </summary>
/// <param name="DefaultAmount">The default amount of players that can have this modifier in a game.</param> /// <param name="DefaultAmount">The default amount of players that can have this <see cref="Types.GameModifier"/> in a game.</param>
/// <param name="DefaultChance">The default chance of the modifier being assigned to a player.</param> /// <param name="DefaultChance">The default chance of the <see cref="Types.GameModifier"/> being assigned to a player.</param>
/// <param name="CreateAmountOption">Whether Mira should create an amount option for the modifier.</param> /// <param name="CreateAmountOption">Whether Mira should create an amount option for the <see cref="Types.GameModifier"/>.</param>
/// <param name="CreateChanceOption">Whether Mira should create a chance option for the modifier.</param> /// <param name="CreateChanceOption">Whether Mira should create a chance option for the <see cref="Types.GameModifier"/>.</param>
public record struct AssignmentConfiguration(int DefaultAmount, int DefaultChance, bool CreateAmountOption, bool CreateChanceOption); public record struct AssignmentConfiguration(int DefaultAmount, int DefaultChance, bool CreateAmountOption, bool CreateChanceOption);
Loaded 100 of 195 files, more files were not shown because too many files have changed in this diff. Show more