mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac2201b3ef | ||
|
|
992df67e18 | ||
|
|
67611471b8 | ||
|
|
5ddf48883c | ||
|
|
df8598db4d | ||
|
|
134e229523 | ||
|
|
cc1e89fd32 | ||
|
|
8bec9efa5c | ||
|
|
41c2a2b118 | ||
|
|
7919b32023 | ||
|
|
95bf1e1448 | ||
|
|
e4adaf7ab4 | ||
|
|
4027257b55 | ||
|
|
6c32c8bed9 | ||
|
|
905cc9e335 | ||
|
|
157aa65c2d | ||
|
|
3693ee754a | ||
|
|
85431d3685 | ||
|
|
2ac6c55cf8 | ||
|
|
db69446352 |
No files matched your search
+3
-3
@@ -1,13 +1,13 @@
|
||||
<Project>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Reactor" Version="2.5.0-ci.371" />
|
||||
<PackageReference Include="Reactor" Version="2.3.1" />
|
||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" />
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2026.3.31" PrivateAssets="all" />
|
||||
<PackageReference Include="AmongUs.GameLibs.Android" Version="2025.9.9" 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" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
|
||||
</Target>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
|
||||
<VersionPrefix>0.4.1</VersionPrefix>
|
||||
<VersionPrefix>0.3.1</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
|
||||
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
||||
@@ -42,4 +42,4 @@
|
||||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\stylecop.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
@@ -18,7 +17,7 @@ public static class ExampleEventHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// You can register event handlers with the MiraEventManager class
|
||||
// You can register event handlers with the MiraEventManager class.
|
||||
var handle = MiraEventManager.RegisterEventHandler<BeforeMurderEvent>(@event =>
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.Source.Data.PlayerName} is about to kill {@event.Target.Data.PlayerName}");
|
||||
@@ -38,21 +37,6 @@ public static class ExampleEventHandlers
|
||||
MiraEventManager.UnregisterEventHandler(handle);
|
||||
}
|
||||
|
||||
// If you want to check vanilla buttons, use something like this!
|
||||
[RegisterEvent]
|
||||
public static void VanillaButtonClickHandler(VanillaButtonClickEvent @event)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.Button.buttonLabelText.text} is being used!");
|
||||
if (@event.PlayerTarget != null)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{@event.PlayerTarget.Data.PlayerName} is being targeted!");
|
||||
}
|
||||
else if (@event.VentTarget != null)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"Vent with id {@event.VentTarget.Id.ToString(CultureInfo.InvariantCulture)} is being targeted!");
|
||||
}
|
||||
}
|
||||
|
||||
// If you want to add extra votes to a player, do something like this.
|
||||
[RegisterEvent]
|
||||
public static void StartMeetingEvent(StartMeetingEvent _)
|
||||
|
||||
@@ -5,12 +5,12 @@ using HarmonyLib;
|
||||
namespace MiraAPI.Colors;
|
||||
|
||||
/// <summary>
|
||||
/// Used to register and track <see cref="CustomColor"/>s.
|
||||
/// Used to register and track custom colors.
|
||||
/// </summary>
|
||||
public static class PaletteManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all registered <see cref="CustomColor"/>s.
|
||||
/// Gets all registered custom colors.
|
||||
/// </summary>
|
||||
public static CustomColor[] RegisteredColors => [.. CustomColors];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.Colors;
|
||||
|
||||
/// <summary>
|
||||
/// Used to mark a class for <see cref="CustomColor"/> registration.
|
||||
/// Used to mark a class for custom colors registration.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RegisterCustomColorsAttribute : Attribute;
|
||||
@@ -3,20 +3,20 @@
|
||||
namespace MiraAPI.Events.Mira;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// Invoked when a Mira Button click is cancelled. Do not use for vanilla buttons.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
|
||||
/// <typeparam name="T">The Mira Button type.</typeparam>
|
||||
public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActionButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
|
||||
/// Gets Mira Button whose click was cancelled.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MiraButtonCancelledEvent{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
|
||||
/// <param name="button">The Mira Button whose click was cancelled.</param>
|
||||
public MiraButtonCancelledEvent(T button)
|
||||
{
|
||||
Button = button;
|
||||
@@ -24,19 +24,19 @@ public sealed class MiraButtonCancelledEvent<T> : MiraEvent where T : CustomActi
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// Invoked when a Mira Button click is cancelled. Do not use for vanilla buttons.
|
||||
/// </summary>
|
||||
public sealed class MiraButtonCancelledEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> whose click was cancelled.
|
||||
/// Gets Mira Button whose click was cancelled.
|
||||
/// </summary>
|
||||
public CustomActionButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MiraButtonCancelledEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
|
||||
/// <param name="button">The Mira Button whose click was cancelled.</param>
|
||||
public MiraButtonCancelledEvent(CustomActionButton button)
|
||||
{
|
||||
Button = button;
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
namespace MiraAPI.Events.Mira;
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// Button click event for Mira Buttons only. Do not use for vanilla buttons.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
|
||||
/// <typeparam name="T">The Mira Button type.</typeparam>
|
||||
public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : CustomActionButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> that was clicked.
|
||||
/// Gets Mira Button that was clicked.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the generic <see cref="MiraButtonClickEvent"/> that is invoked before this button-specific event.
|
||||
/// Gets the generic click event that is invoked before this button-specific event.
|
||||
/// </summary>
|
||||
public MiraButtonClickEvent GenericClickEvent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MiraButtonClickEvent{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
|
||||
/// <param name="genericClickEvent">The generic <see cref="MiraButtonClickEvent"/> invoked before button-specific events.</param>
|
||||
/// <param name="button">The Mira Button that was clicked.</param>
|
||||
/// <param name="genericClickEvent">The generic click event invoked before button-specific events.</param>
|
||||
public MiraButtonClickEvent(T button, MiraButtonClickEvent genericClickEvent)
|
||||
{
|
||||
GenericClickEvent = genericClickEvent;
|
||||
@@ -31,19 +31,19 @@ public sealed class MiraButtonClickEvent<T> : MiraCancelableEvent where T : Cust
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
|
||||
/// Button click event for Mira Buttons only. Do not use for vanilla buttons.
|
||||
/// </summary>
|
||||
public sealed class MiraButtonClickEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CustomActionButton"/> that was clicked.
|
||||
/// Gets Mira Button that was clicked.
|
||||
/// </summary>
|
||||
public CustomActionButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MiraButtonClickEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
|
||||
/// <param name="button">The Mira Button that was clicked.</param>
|
||||
public MiraButtonClickEvent(CustomActionButton button)
|
||||
{
|
||||
Button = button;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Event handle to use when unregistering a <see cref="MiraEvent"/>.
|
||||
/// Event handle to use when unregistering an event.
|
||||
/// </summary>
|
||||
public class MiraEventHandle
|
||||
{
|
||||
|
||||
@@ -13,11 +13,11 @@ public static class MiraEventManager
|
||||
private static readonly Dictionary<Type, List<MiraEventWrapper>> EventWrappers = [];
|
||||
|
||||
/// <summary>
|
||||
/// Invoke a <see cref="MiraEvent"/>.
|
||||
/// Invoke an event.
|
||||
/// </summary>
|
||||
/// <param name="eventInstance">The <typeparamref name="T"/> instance.</param>
|
||||
/// <param name="eventInstance">The event instance.</param>
|
||||
/// <typeparam name="T">Type of Event.</typeparam>
|
||||
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
||||
/// <returns>If there was an event handler invoked for this event, return true. Otherwise, return false.</returns>
|
||||
public static bool InvokeEvent<T>(T eventInstance) where T : MiraEvent
|
||||
{
|
||||
EventWrappers.TryGetValue(typeof(T), out var handlers);
|
||||
@@ -34,7 +34,7 @@ public static class MiraEventManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error($"Error invoking event handler for {typeof(T).Name}: {ex.ToString()}");
|
||||
Logger<MiraApiPlugin>.Error($"Error invoking event handler for {typeof(T).Name}: {ex.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ public static class MiraEventManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoke a <see cref="MiraEvent"/> and use a specific type to find the handlers.
|
||||
/// Invoke an event and use a specific type to find the handlers.
|
||||
/// </summary>
|
||||
/// <param name="eventInstance">The <see cref="MiraEvent"/> instance.</param>
|
||||
/// <param name="eventInstance">The event instance.</param>
|
||||
/// <param name="type">The type to use for handler lookup.</param>
|
||||
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
||||
/// <returns>If there was an event handler invoked for this event, return true. Otherwise, return false.</returns>
|
||||
public static bool InvokeEvent(MiraEvent eventInstance, Type type)
|
||||
{
|
||||
EventWrappers.TryGetValue(type, out var handlers);
|
||||
@@ -63,7 +63,7 @@ public static class MiraEventManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error($"Error invoking event handler for {type.Name}: {ex.ToString()}");
|
||||
Logger<MiraApiPlugin>.Error($"Error invoking event handler for {type.Name}: {ex.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +71,12 @@ public static class MiraEventManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a <see cref="MiraEvent"/> handler.
|
||||
/// Register an event.
|
||||
/// </summary>
|
||||
/// <param name="type">The type of <see cref="MiraEvent"/> event.</param>
|
||||
/// <param name="methodInfo">The <see cref="MethodInfo"/> of the event handler.</param>
|
||||
/// <param name="type">The type of event.</param>
|
||||
/// <param name="methodInfo">The MethodInfo of the event handler.</param>
|
||||
/// <param name="priority">The priority of the event handler. Lower values are called first.</param>
|
||||
/// <returns>A <see cref="MiraEventHandle"/> to use when unregistering the event.</returns>
|
||||
/// <returns>An event handle to use when unregistering the event.</returns>
|
||||
public static MiraEventHandle RegisterEventHandler(Type type, MethodInfo methodInfo, int priority = 0)
|
||||
{
|
||||
if (!type.IsSubclassOf(typeof(MiraEvent)))
|
||||
@@ -102,12 +102,12 @@ public static class MiraEventManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a <typeparamref name="T"/> handler.
|
||||
/// Register an event.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <typeparam name="T">Type of <see cref="MiraEvent"/> event.</typeparam>
|
||||
/// <returns>A <see cref="MiraEventHandle"/> to use when unregistering the event.</returns>
|
||||
/// <typeparam name="T">Type of event.</typeparam>
|
||||
/// <returns>An event handle to use when unregistering the event.</returns>
|
||||
public static MiraEventHandle RegisterEventHandler<T>(Action<T> handler, int priority = 0) where T : MiraEvent
|
||||
{
|
||||
EventWrappers.TryAdd(typeof(T), []);
|
||||
@@ -127,10 +127,10 @@ public static class MiraEventManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregister a <see cref="MiraEvent"/> handler using the <see cref="MiraEventHandle"/>.
|
||||
/// Unregister an event using the event handle.
|
||||
/// </summary>
|
||||
/// <param name="eventHandle">A handle to the event.</param>
|
||||
/// <returns><see langword="true"/> if the event was unregistered successfully, <see langword="false"/> otherwise.</returns>
|
||||
/// <returns>True if the event was unregistered successfully, false otherwise.</returns>
|
||||
public static bool UnregisterEventHandler(MiraEventHandle eventHandle)
|
||||
{
|
||||
if (!EventWrappers.TryGetValue(eventHandle.EventType, out var handlers))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for <see cref="MiraEvent"/> handlers.
|
||||
/// Wrapper for event handlers.
|
||||
/// </summary>
|
||||
public class MiraEventWrapper
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Register a <see cref="MiraEvent"/> handler.
|
||||
/// Register an event.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class RegisterEventAttribute : Attribute
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
public class AfterMurderEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that killed the <see cref="Target"/>.
|
||||
/// Gets the player that killed the target.
|
||||
/// </summary>
|
||||
public PlayerControl Source { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that was killed.
|
||||
/// Gets the player that was killed.
|
||||
/// </summary>
|
||||
public PlayerControl Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Target"/>'s <see cref="global::DeadBody"/>, if it exists.
|
||||
/// Gets the player's body, if it exists.
|
||||
/// </summary>
|
||||
public DeadBody? DeadBody { get; }
|
||||
|
||||
@@ -24,8 +24,8 @@ public class AfterMurderEvent : MiraEvent
|
||||
/// Initializes a new instance of the <see cref="AfterMurderEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="source">The killer.</param>
|
||||
/// <param name="target">The killed <see cref="PlayerControl"/>.</param>
|
||||
/// <param name="deadBody">The <paramref name="target"/>'s <see cref="global::DeadBody"/>, if it exists.</param>
|
||||
/// <param name="target">The killed player.</param>
|
||||
/// <param name="deadBody">The player's vody, if it exists.</param>
|
||||
public AfterMurderEvent(PlayerControl source, PlayerControl target, DeadBody? deadBody)
|
||||
{
|
||||
Source = source;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked before <see cref="GameManager.RpcEndGame"/> is called, allowing cancellation of the game end entirely.
|
||||
/// Invoked before RpcEndGame is called, allowing cancellation of the game end entirely.
|
||||
/// </summary>
|
||||
public class BeforeGameEndEvent : MiraCancelableEvent
|
||||
{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using MiraAPI.Networking;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked before a player is murdered. This event is cancelable.
|
||||
@@ -8,42 +6,23 @@ namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
public sealed class BeforeMurderEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is killing the <see cref="Target"/>.
|
||||
/// Gets the player that is killing the target.
|
||||
/// </summary>
|
||||
public PlayerControl Source { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is being killed.
|
||||
/// Gets the player that is being killed.
|
||||
/// </summary>
|
||||
public PlayerControl Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the murder was meant to be done in a meeting, via an enum.
|
||||
/// </summary>
|
||||
public MeetingCheck InMeeting { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</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>
|
||||
public BeforeMurderEvent(PlayerControl source, PlayerControl target, MeetingCheck inMeeting)
|
||||
{
|
||||
Source = source;
|
||||
Target = target;
|
||||
InMeeting = inMeeting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BeforeMurderEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="source">The <see cref="PlayerControl"/> that is killing the <paramref name="target"/>.</param>
|
||||
/// <param name="target">The <see cref="PlayerControl"/> that is being killed.</param>
|
||||
/// <param name="source">The player that is killing the target.</param>
|
||||
/// <param name="target">The player that is being killed.</param>
|
||||
public BeforeMurderEvent(PlayerControl source, PlayerControl target)
|
||||
{
|
||||
Source = source;
|
||||
Target = target;
|
||||
InMeeting = MeetingCheck.Ignore;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// Event invoked on IntroCutscene.OnDestroy and ExileController.WrapUp to determine if it should run the round event or not.
|
||||
/// </summary>
|
||||
public class BeforeRoundStartEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
|
||||
/// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController.
|
||||
/// </summary>
|
||||
public bool TriggeredByIntro { get; }
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
public class GameEndEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::EndGameManager"/> instance.
|
||||
/// Gets the instance of the EndGameManager.
|
||||
/// </summary>
|
||||
public EndGameManager EndGameManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameEndEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="manager">The <see cref="global::EndGameManager"/> instance.</param>
|
||||
/// <param name="manager">The instance of the EndGameManager.</param>
|
||||
public GameEndEvent(EndGameManager manager)
|
||||
{
|
||||
EndGameManager = manager;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
public class IntroBeginEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// Gets the instance of the IntroCutscene.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
public class IntroEndEvent(IntroCutscene introCutscene) : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// Gets the instance of the IntroCutscene.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; } = introCutscene;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
public class IntroRoleRevealEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::IntroCutscene"/> instance.
|
||||
/// Gets the instance of the IntroCutscene.
|
||||
/// </summary>
|
||||
public IntroCutscene IntroCutscene { get; }
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Start Round event, invoked on <see cref="IntroCutscene.OnDestroy"/> and <see cref="ExileController.WrapUp"/>
|
||||
/// if the <see cref="BeforeRoundStartEvent"/> isn't cancelled.
|
||||
/// Start Round event, invoked on IntroCutscene.OnDestroy and ExileController.WrapUp if the event isn't cancelled.
|
||||
/// </summary>
|
||||
public class RoundStartEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the event was triggered by the <see cref="IntroCutscene"/> or <see cref="ExileController"/>.
|
||||
/// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController.
|
||||
/// </summary>
|
||||
public bool TriggeredByIntro { get; }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
public class SetRoleEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> whose role was changed.
|
||||
/// Gets the player whos role was changed.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
using MiraAPI.Hud;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a Vanilla <see cref="AbilityButton"/> click is cancelled. Do not use for <see cref="CustomActionButton"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The vanilla <see cref="AbilityButton"/> type.</typeparam>
|
||||
public sealed class VanillaButtonCancelledEvent<T> : MiraEvent where T : AbilityButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The vanilla <see cref="AbilityButton"/> whose click was cancelled.</param>
|
||||
public VanillaButtonCancelledEvent(T button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a Vanilla <see cref="AbilityButton"/> click is cancelled. Do not use for <see cref="CustomActionButton"/>s.
|
||||
/// </summary>
|
||||
public sealed class VanillaButtonCancelledEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Vanilla <see cref="AbilityButton"/> whose click was cancelled.
|
||||
/// </summary>
|
||||
public AbilityButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonCancelledEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The vanilla <see cref="AbilityButton"/> whose click was cancelled.</param>
|
||||
public VanillaButtonCancelledEvent(AbilityButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using MiraAPI.Hud;
|
||||
|
||||
namespace MiraAPI.Events.Vanilla.Gameplay;
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for Vanilla <see cref="AbilityButton"/>s only. Do not use for <see cref="CustomActionButton"/>s.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The vanilla <see cref="AbilityButton"/> type.</typeparam>
|
||||
public sealed class VanillaButtonClickEvent<T> : MiraCancelableEvent where T : AbilityButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public T Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the generic <see cref="VanillaButtonClickEvent"/> that is invoked before this button-specific event.
|
||||
/// </summary>
|
||||
public VanillaButtonClickEvent GenericClickEvent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The vanilla <see cref="AbilityButton"/> that was clicked.</param>
|
||||
/// <param name="genericClickEvent">The generic <see cref="VanillaButtonClickEvent"/> invoked before button-specific events.</param>
|
||||
public VanillaButtonClickEvent(T button, VanillaButtonClickEvent genericClickEvent)
|
||||
{
|
||||
GenericClickEvent = genericClickEvent;
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for Vanilla <see cref="AbilityButton"/> only. Do not use for <see cref="CustomActionButton"/>s.
|
||||
/// </summary>
|
||||
public sealed class VanillaButtonClickEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public AbilityButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target <see cref="PlayerControl"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public PlayerControl? PlayerTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target <see cref="Vent"/>, if any, of the Vanilla <see cref="AbilityButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public Vent? VentTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VanillaButtonClickEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The Vanilla <see cref="AbilityButton"/> that was clicked.</param>
|
||||
/// <param name="playerTarget">The <see cref="PlayerControl"/> 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)
|
||||
{
|
||||
Button = button;
|
||||
PlayerTarget = playerTarget;
|
||||
VentTarget = ventTarget;
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
public class PlayerOpenSabotageEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MapBehaviour"/>.
|
||||
/// Gets the MapBehaviour.
|
||||
/// </summary>
|
||||
public MapBehaviour MapBehaviour { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerOpenSabotageEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mapBehaviour">The <see cref="global::MapBehaviour"/>.</param>
|
||||
/// <param name="mapBehaviour">The MapBehaviour.</param>
|
||||
public PlayerOpenSabotageEvent(MapBehaviour mapBehaviour)
|
||||
{
|
||||
MapBehaviour = mapBehaviour;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace MiraAPI.Events.Vanilla.Map;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="MiraCancelableEvent"/> that is invoked before a system is updated. Usually used for sabotage events.
|
||||
/// Cancelable event that is invoked before a system is updated. Usually used for sabotage events.
|
||||
/// </summary>
|
||||
public class UpdateSystemEvent : MiraCancelableEvent
|
||||
{
|
||||
@@ -11,7 +11,7 @@ public class UpdateSystemEvent : MiraCancelableEvent
|
||||
public SystemTypes SystemType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is updating the system.
|
||||
/// Gets the player that is updating the system.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
@@ -21,10 +21,10 @@ public class UpdateSystemEvent : MiraCancelableEvent
|
||||
public byte Amount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class.
|
||||
/// Initializes a new instance of the <see cref="UpdateSystemEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="systemType">The <see cref="SystemTypes"/> being updated.</param>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> that is updating the system.</param>
|
||||
/// <param name="systemType">The SystemType being updated.</param>
|
||||
/// <param name="player">The player that is updating the system.</param>
|
||||
/// <param name="amount">Amount to update System to.</param>
|
||||
public UpdateSystemEvent(SystemTypes systemType, PlayerControl player, byte amount)
|
||||
{
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
public class EjectionEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::ExileController"/> instance.
|
||||
/// Gets the instance of the ExileController.
|
||||
/// </summary>
|
||||
public ExileController ExileController { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EjectionEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="controller">The <see cref="global::ExileController"/> instance.</param>
|
||||
/// <param name="controller">The exile controller.</param>
|
||||
public EjectionEvent(ExileController controller)
|
||||
{
|
||||
ExileController = controller;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
public class EndMeetingEvent(MeetingHud meetingHud) : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// Gets the MeetingHud instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a body is reported.
|
||||
/// This is invoked in <see cref="PlayerControl.CmdReportDeadBody(NetworkedPlayerInfo)"/>.
|
||||
/// This is invoked in CmdReportBody.
|
||||
/// </summary>
|
||||
public class ReportBodyEvent : MiraCancelableEvent
|
||||
{
|
||||
@@ -12,12 +12,12 @@ public class ReportBodyEvent : MiraCancelableEvent
|
||||
public PlayerControl Reporter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player that is being reported. Will be <see langword="null"/> for emergency meeting.
|
||||
/// Gets the player that is being reported. Will be null for emergency meeting.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo? Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DeadBody"/> that is being reported. Will be <see langword="null"/> for emergency meeting.
|
||||
/// Gets the body that is being reported. Will be null for emergency meeting.
|
||||
/// </summary>
|
||||
public DeadBody? Body { get; }
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ReportBodyEvent : MiraCancelableEvent
|
||||
/// </summary>
|
||||
/// <param name="reporter">The player who reported the body.</param>
|
||||
/// <param name="target">The player being reported.</param>
|
||||
/// <param name="body">The <see cref="DeadBody"/> being reported.</param>
|
||||
/// <param name="body">The body being reported.</param>
|
||||
public ReportBodyEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body)
|
||||
{
|
||||
Reporter = reporter;
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
public class StartMeetingEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// Gets the MeetingHud instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StartMeetingEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
|
||||
/// <param name="meetingHud">The MeetingHud instance.</param>
|
||||
public StartMeetingEvent(MeetingHud meetingHud)
|
||||
{
|
||||
MeetingHud = meetingHud;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
public class AfterVoteEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
|
||||
/// Gets the instance of the voter's vote data.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; }
|
||||
|
||||
@@ -20,7 +20,7 @@ public class AfterVoteEvent : MiraEvent
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AfterVoteEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The <see cref="PlayerVoteArea"/> that was voted on.</param>
|
||||
/// <param name="playerVoteArea">The player vote area that was voted on.</param>
|
||||
/// <param name="voter">The player who voted.</param>
|
||||
public AfterVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
public class BeforeVoteEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteArea"/>.
|
||||
/// Gets the instance of the voter's vote data.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea { get; }
|
||||
|
||||
@@ -20,7 +20,7 @@ public class BeforeVoteEvent : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BeforeVoteEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The <see cref="PlayerVoteArea"/> that was voted on.</param>
|
||||
/// <param name="playerVoteArea">The player vote area that was voted on.</param>
|
||||
/// <param name="voter">The player who voted.</param>
|
||||
public BeforeVoteEvent(PlayerVoteArea playerVoteArea, PlayerControl voter)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CheckForEndVotingEvent : MiraCancelableEvent
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CheckForEndVotingEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="isVotingComplete"><see langword="true"/> if voting is complete, <see langword="false"/> otherwise.</param>
|
||||
/// <param name="isVotingComplete">>True if voting is complete, false otherwise.</param>
|
||||
public CheckForEndVotingEvent(bool isVotingComplete)
|
||||
{
|
||||
IsVotingComplete = isVotingComplete;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DummyVoteEvent : MiraCancelableEvent
|
||||
public DummyBehaviour Dummy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the dummy's <see cref="PlayerVoteData"/>.
|
||||
/// Gets the instance of the dummy's vote data.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; }
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
/// <summary>
|
||||
/// 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 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.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class HandleVoteEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
/// Gets the instance of the voter's vote data.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; }
|
||||
|
||||
@@ -30,14 +30,14 @@ public class HandleVoteEvent : MiraCancelableEvent
|
||||
public bool PreventVote { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
|
||||
/// Gets the player info of the target.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo TargetPlayerInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HandleVoteEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
|
||||
/// <param name="playerVoteData">The voter's data.</param>
|
||||
/// <param name="targetId">The target's playerId.</param>
|
||||
public HandleVoteEvent(PlayerVoteData playerVoteData, byte targetId)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
public class MeetingSelectEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the voter's <see cref="PlayerVoteData"/>.
|
||||
/// Gets the instance of the voter's vote data.
|
||||
/// </summary>
|
||||
public PlayerVoteData VoteData { get; }
|
||||
|
||||
@@ -18,7 +18,7 @@ public class MeetingSelectEvent : MiraEvent
|
||||
public int TargetId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetworkedPlayerInfo"/> of the target.
|
||||
/// Gets the player info of the target.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo TargetPlayerInfo { get; }
|
||||
|
||||
@@ -30,9 +30,9 @@ public class MeetingSelectEvent : MiraEvent
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MeetingSelectEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteData">The voter's <see cref="PlayerVoteData"/>.</param>
|
||||
/// <param name="playerVoteData">The voter's data.</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)
|
||||
{
|
||||
VoteData = playerVoteData;
|
||||
|
||||
@@ -4,20 +4,20 @@ using MiraAPI.Voting;
|
||||
namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
|
||||
/// <summary>
|
||||
/// Called in <see cref="VotingUtils.HandlePopulateResults"/>.
|
||||
/// Called in VotingUtils.HandlePopulateResults.
|
||||
/// Cancelling is NOT advised but if you do plan on cancelling, please ensure you account for displaying ALL player's votes.
|
||||
/// </summary>
|
||||
public class PopulateResultsEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of networked <see cref="CustomVote"/>s.
|
||||
/// Gets a list of networked votes.
|
||||
/// </summary>
|
||||
public List<CustomVote> Votes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PopulateResultsEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="votes">The list of <see cref="CustomVote"/>s.</param>
|
||||
/// <param name="votes">The list of votes.</param>
|
||||
public PopulateResultsEvent(List<CustomVote> votes)
|
||||
{
|
||||
Votes = votes;
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="ProcessVotesEvent"/> class.
|
||||
/// </remarks>
|
||||
/// <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 <see langword="null"/> if no player is to be exiled.</param>
|
||||
/// <param name="votes">>The list of votes that are being processed.</param>
|
||||
/// <param name="exiledPlayer">The player to be exiled. Will be null if no player is to be exiled.</param>
|
||||
public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exiledPlayer = null) : MiraEvent
|
||||
{
|
||||
private readonly List<CustomVote> _originalVotes = [.. votes];
|
||||
@@ -29,12 +29,12 @@ public class ProcessVotesEvent(List<CustomVote> votes, NetworkedPlayerInfo? exil
|
||||
public bool VotesModified => !Votes.SequenceEqual(_originalVotes);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="CustomVote"/>s that are being processed.
|
||||
/// Gets the list of votes that are being processed.
|
||||
/// </summary>
|
||||
public List<CustomVote> Votes { get; } = votes;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the player to be exiled. Will be <see langword="null"/> if no player is to be exiled.
|
||||
/// Gets or sets the player to be exiled. Will be null if no player is to be exiled.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo? ExiledPlayer
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
/// <summary>
|
||||
/// The event that is invoked when the voting phase of a meeting is complete.
|
||||
/// </summary>
|
||||
/// <param name="meetingHud">The <see cref="global::MeetingHud"/> instance.</param>
|
||||
/// <param name="meetingHud">The MeetingHud instance.</param>
|
||||
public class VotingCompleteEvent(MeetingHud meetingHud) : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::MeetingHud"/> instance.
|
||||
/// Gets the MeetingHud instance.
|
||||
/// </summary>
|
||||
public MeetingHud MeetingHud { get; } = meetingHud;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
namespace MiraAPI.Events.Vanilla.Player;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a player completes a task within Hide and Seek. Non-cancelable.
|
||||
/// </summary>
|
||||
public class CompleteHnsTaskEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerControl"/>.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="PlayerTask"/> that the player completed.
|
||||
/// </summary>
|
||||
public PlayerTask Task { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="HideAndSeekManager"/> attached to the game.
|
||||
/// </summary>
|
||||
public HideAndSeekManager HnsManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CompleteHnsTaskEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="hnsManager">The <see cref="HideAndSeekManager"/> currently active.</param>
|
||||
/// <param name="player">The player who completed the task.</param>
|
||||
/// <param name="task">The task that the player completed.</param>
|
||||
public CompleteHnsTaskEvent(HideAndSeekManager hnsManager, PlayerControl player, PlayerTask task)
|
||||
{
|
||||
HnsManager = hnsManager;
|
||||
Player = player;
|
||||
Task = task;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class PlayerDeathEvent : MiraEvent
|
||||
public DeathReason DeathReason { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::DeadBody"/> associated with the player, if any.
|
||||
/// Gets the dead body associated with the player, if any.
|
||||
/// </summary>
|
||||
public DeadBody? DeadBody { get; }
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PlayerDeathEvent : MiraEvent
|
||||
/// </summary>
|
||||
/// <param name="player">The player who died.</param>
|
||||
/// <param name="reason">The reason the player died.</param>
|
||||
/// <param name="deadBody">The player's <see cref="global::DeadBody"/>, if it exists.</param>
|
||||
/// <param name="deadBody">The player's body, if it exists.</param>
|
||||
public PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody? deadBody)
|
||||
{
|
||||
Player = player;
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
public class EnterVentEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is entering the <see cref="Vent"/>.
|
||||
/// Gets the player that is entering the vent.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is entering.
|
||||
/// Gets the vent that the player is entering.
|
||||
/// </summary>
|
||||
public Vent? Vent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnterVentEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> that is entering the <paramref name="vent"/>.</param>
|
||||
/// <param name="vent">The <see cref="global::Vent"/> being entered.</param>
|
||||
/// <param name="player">The player that is entering the vent.</param>
|
||||
/// <param name="vent">The vent being entered.</param>
|
||||
public EnterVentEvent(PlayerControl player, Vent? vent)
|
||||
{
|
||||
Player = player;
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
public class ExitVentEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that is exiting the <see cref="Vent"/>.
|
||||
/// Gets the player that is exiting the vent.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::Vent"/> that the <see cref="Player"/> is exiting.
|
||||
/// Gets the vent that the player is exiting.
|
||||
/// </summary>
|
||||
public Vent? Vent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExitVentEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> who is exiting the <paramref name="vent"/>.</param>
|
||||
/// <param name="vent">The <see cref="global::Vent"/> being exited from.</param>
|
||||
/// <param name="player">The player who is exiting the vent.</param>
|
||||
/// <param name="vent">The vent being exited from.</param>
|
||||
public ExitVentEvent(PlayerControl player, Vent? vent)
|
||||
{
|
||||
Player = player;
|
||||
|
||||
@@ -8,7 +8,7 @@ public class PlayerCanUseEvent : PlayerUseEvent
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerCanUseEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="usable">The <see cref="IUsable"/>.</param>
|
||||
/// <param name="usable">The IUsable.</param>
|
||||
public PlayerCanUseEvent(IUsable usable) : base(usable)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,19 +11,19 @@ public class PlayerUseEvent : MiraCancelableEvent
|
||||
public IUsable Usable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>.
|
||||
/// Gets a value indicating whether the IUsable is a <see cref="Console"/>, <see cref="MapConsole"/>, or <see cref="SystemConsole"/>.
|
||||
/// </summary>
|
||||
public bool IsPrimaryConsole { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="Usable"/> is a <see cref="Vent"/>.
|
||||
/// Gets a value indicating whether the IUsable is a <see cref="Vent"/>.
|
||||
/// </summary>
|
||||
public bool IsVent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlayerUseEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="usable">The <see cref="IUsable"/>.</param>
|
||||
/// <param name="usable">The IUsable.</param>
|
||||
public PlayerUseEvent(IUsable usable)
|
||||
{
|
||||
Usable = usable;
|
||||
|
||||
@@ -10,44 +10,44 @@ namespace MiraAPI.GameEnd;
|
||||
public abstract class CustomGameOver
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current <see cref="CustomGameOver"/>.
|
||||
/// Gets the current CustomGameOver.
|
||||
/// </summary>
|
||||
public static CustomGameOver? Instance { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Verifies if the condition for this <see cref="CustomGameOver"/> is met.
|
||||
/// Verifies if the condition for this CustomGameOver is met.
|
||||
/// </summary>
|
||||
/// <param name="playerControl">The <see cref="PlayerControl"/> that requested the Game Over.</param>
|
||||
/// <param name="playerControl">The PlayerControl that requested the Game Over.</param>
|
||||
/// <param name="winners">The collection of winners.</param>
|
||||
/// <returns><see langword="true"/> if the condition is met, otherwise <see langword="false"/>.</returns>
|
||||
/// <returns>True if the condition is met, otherwise false.</returns>
|
||||
public virtual bool VerifyCondition(PlayerControl playerControl, NetworkedPlayerInfo[] winners)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs before the base game calls <see cref="EndGameManager.SetEverythingUp"/>.
|
||||
/// Runs before the base game calls EndGameManager.SetEverythingUp.
|
||||
/// </summary>
|
||||
/// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
|
||||
/// <returns>Return <see langword="true"/> to use the run the original method, return <see langword="false"/> to skip it.</returns>
|
||||
/// <param name="endGameManager">The EndGameManager instance.</param>
|
||||
/// <returns>Return True to use the run the original method, return False to skip it.</returns>
|
||||
public virtual bool BeforeEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs after the base game calls <see cref="EndGameManager.SetEverythingUp"/>.
|
||||
/// Runs after the base game calls EndGameManager.SetEverythingUp.
|
||||
/// </summary>
|
||||
/// <param name="endGameManager">The <see cref="EndGameManager"/> instance.</param>
|
||||
/// <param name="endGameManager">The EndGameManager instance.</param>
|
||||
public virtual void AfterEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="global::GameOverReason"/> associated with this <see cref ="CustomGameOver"/>.
|
||||
/// Get the GameOverReason associated with this CustomGameOver.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the custom game over.</typeparam>
|
||||
/// <returns>The <see cref="global::GameOverReason"/> associated with the custom game over.</returns>
|
||||
/// <returns>The GameOverReason associated with the custom game over.</returns>
|
||||
public static GameOverReason GameOverReason<T>() where T : CustomGameOver
|
||||
{
|
||||
return (GameOverReason)GameOverManager.GetGameOverId<T>();
|
||||
@@ -67,10 +67,10 @@ public abstract class CustomGameOver
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly convert a <see cref="CustomGameOver"/> to a <see cref="global::GameOverReason"/>.
|
||||
/// Implicitly convert a CustomGameOver to a GameOverReason.
|
||||
/// </summary>
|
||||
/// <param name="gameOver">The <see cref="CustomGameOver"/> instance.</param>
|
||||
/// <returns>The <see cref="global::GameOverReason"/> associated with the CustomGameOver.</returns>
|
||||
/// <param name="gameOver">The CustomGameOver instance.</param>
|
||||
/// <returns>The GameOverReason associated with the CustomGameOver.</returns>
|
||||
public static implicit operator GameOverReason(CustomGameOver gameOver)
|
||||
{
|
||||
return (GameOverReason)GameOverManager.GetGameOverId(gameOver.GetType());
|
||||
|
||||
@@ -6,7 +6,7 @@ using Reactor.Utilities;
|
||||
namespace MiraAPI.GameEnd;
|
||||
|
||||
/// <summary>
|
||||
/// Manage <see cref="CustomGameOver"/>s.
|
||||
/// Manage custom game overs.
|
||||
/// </summary>
|
||||
public static class GameOverManager
|
||||
{
|
||||
@@ -16,11 +16,11 @@ public static class GameOverManager
|
||||
private static int _nextId = Enum.GetNames<GameOverReason>().Length;
|
||||
|
||||
/// <summary>
|
||||
/// Register a <see cref="CustomGameOver"/>.
|
||||
/// Register a custom game over.
|
||||
/// </summary>
|
||||
/// <param name="gameOverType">Type of the <see cref="CustomGameOver"/>.</param>
|
||||
/// <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><see langword="true"/> if the game over was registered successfully, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="gameOverType">Type of the custom game over.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when the type is not a subclass of CustomGameOver, is abstract, or does not have a parameterless constructor.</exception>
|
||||
/// <returns>>True if the game over was registered successfully, false otherwise.</returns>
|
||||
public static bool RegisterGameOver(Type gameOverType)
|
||||
{
|
||||
if (!typeof(CustomGameOver).IsAssignableFrom(gameOverType))
|
||||
@@ -30,13 +30,13 @@ public static class GameOverManager
|
||||
|
||||
if (gameOverType.IsAbstract)
|
||||
{
|
||||
Error("The type must not be abstract.");
|
||||
Logger<MiraApiPlugin>.Error("The type must not be abstract.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gameOverType.GetConstructor(Type.EmptyTypes) == null)
|
||||
{
|
||||
Error("The type must have a parameterless constructor.");
|
||||
Logger<MiraApiPlugin>.Error("The type must have a parameterless constructor.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ public static class GameOverManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of a <see cref="CustomGameOver"/>.
|
||||
/// Create an instance of a custom game over.
|
||||
/// </summary>
|
||||
/// <param name="id">ID of the <see cref="CustomGameOver"/>.</param>
|
||||
/// <param name="customGameOver">The created instance of the <see cref="CustomGameOver"/>.</param>
|
||||
/// <returns>An instance of the <see cref="CustomGameOver"/>.</returns>
|
||||
/// <param name="id">ID of the custom game over.</param>
|
||||
/// <param name="customGameOver">The created instance of the custom game over.</param>
|
||||
/// <returns>An instance of the custom game over.</returns>
|
||||
public static bool TryGetGameOver(int id, [NotNullWhen(true)] out CustomGameOver? customGameOver)
|
||||
{
|
||||
if (GameOverTypes.TryGetValue(id, out var gameOverType))
|
||||
@@ -65,20 +65,20 @@ public static class GameOverManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the ID of a <see cref="CustomGameOver"/>.
|
||||
/// Get the ID of a custom game over.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the <see cref="CustomGameOver"/>.</typeparam>
|
||||
/// <returns>The ID of the <see cref="CustomGameOver"/>.</returns>
|
||||
/// <typeparam name="T">Type of the custom game over.</typeparam>
|
||||
/// <returns>The ID of the custom game over.</returns>
|
||||
public static int GetGameOverId<T>() where T : CustomGameOver
|
||||
{
|
||||
return GetGameOverId(typeof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the ID of a <see cref="CustomGameOver"/>.
|
||||
/// Get the ID of a custom game over.
|
||||
/// </summary>
|
||||
/// <param name="gameOverType">Type of the <see cref="CustomGameOver"/>.</param>
|
||||
/// <returns>The ID of the <see cref="CustomGameOver"/>.</returns>
|
||||
/// <param name="gameOverType">Type of the custom game over.</param>
|
||||
/// <returns>The ID of the custom game over.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown when the type is not registered.</exception>
|
||||
public static int GetGameOverId(Type gameOverType)
|
||||
{
|
||||
|
||||
@@ -23,24 +23,24 @@ public abstract class CustomGameMode
|
||||
public abstract int Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when <see cref="IntroCutscene"/> is destroyed.
|
||||
/// Called when Intro Cutscene is destroyed.
|
||||
/// </summary>
|
||||
public virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on <see cref="HudManager.Start"/>.
|
||||
/// Called on HudManager.Start().
|
||||
/// </summary>
|
||||
/// <param name="instance">Instance of <see cref="HudManager"/>.</param>
|
||||
/// <param name="instance">Instance of HudManager.</param>
|
||||
public virtual void HudStart(HudManager instance)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every frame on <see cref="HudManager.Update"/>.
|
||||
/// Called every frame on HudManager.Update().
|
||||
/// </summary>
|
||||
/// <param name="instance">Instance of <see cref="HudManager"/>.</param>
|
||||
/// <param name="instance">Instance of HudManager.</param>
|
||||
public virtual void HudUpdate(HudManager instance)
|
||||
{
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public abstract class CustomGameMode
|
||||
/// <summary>
|
||||
/// Called when a player is killed.
|
||||
/// </summary>
|
||||
/// <param name="player"><see cref="PlayerControl"/> that was killed.</param>
|
||||
/// <param name="player">PlayerControl that was killed.</param>
|
||||
public virtual void OnDeath(PlayerControl player)
|
||||
{
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public abstract class CustomGameMode
|
||||
/// Calculate Game End logic.
|
||||
/// </summary>
|
||||
/// <param name="runOriginal">Should original game end logic be used.</param>
|
||||
/// <param name="instance">Instance of <see cref="LogicGameFlowNormal"/>.</param>
|
||||
/// <param name="instance">Instance of LogicGameFlowNormal.</param>
|
||||
public virtual void CheckGameEnd(out bool runOriginal, LogicGameFlowNormal instance)
|
||||
{
|
||||
runOriginal = true;
|
||||
@@ -67,7 +67,7 @@ public abstract class CustomGameMode
|
||||
/// Custom role assignment.
|
||||
/// </summary>
|
||||
/// <param name="runOriginal">Should original role assignment be used.</param>
|
||||
/// <param name="instance">Instance of <see cref="LogicRoleSelection"/>.</param>
|
||||
/// <param name="instance">Instance of LogicRoleSelection.</param>
|
||||
public virtual void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance)
|
||||
{
|
||||
runOriginal = true;
|
||||
@@ -78,7 +78,7 @@ public abstract class CustomGameMode
|
||||
/// </summary>
|
||||
/// <param name="runOriginal">Should the original murder logic be used.</param>
|
||||
/// <param name="result">Result of custom murder logic.</param>
|
||||
/// <param name="target">Target <see cref="PlayerControl"/> for murder.</param>
|
||||
/// <param name="target">Target player for murder.</param>
|
||||
public virtual void CanKill(out bool runOriginal, out bool result, PlayerControl target)
|
||||
{
|
||||
result = false;
|
||||
@@ -88,60 +88,60 @@ public abstract class CustomGameMode
|
||||
/// <summary>
|
||||
/// Should Roles Settings be available when this gamemode is selected.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if Role Settings are enabled in this game mode.</returns>
|
||||
/// <returns>True if Role Settings are enabled in this game mode.</returns>
|
||||
public virtual bool AreRoleSettingsEnabled() => true;
|
||||
|
||||
/// <summary>
|
||||
/// Should Game Settings be available when this gamemode is selected.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if Game Settings are enabled in this mode.</returns>
|
||||
/// <returns>True if Game Settings are enabled in this mode.</returns>
|
||||
public virtual bool AreGameSettingsEnabled() => true;
|
||||
|
||||
/// <summary>
|
||||
/// Custom winner selection.
|
||||
/// </summary>
|
||||
/// <returns>List of winners or <see langword="null"/>.</returns>
|
||||
/// <returns>List of winners or null.</returns>
|
||||
public virtual List<NetworkedPlayerInfo>? CalculateWinners() => null;
|
||||
|
||||
/// <summary>
|
||||
/// Show gamemode in <see cref="IntroCutscene"/>.
|
||||
/// Show gamemode in Intro Cutscene.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if the game mode should be shown in the intro cutscene.</returns>
|
||||
/// <returns>True if the game mode should be shown in the intro cutscene.</returns>
|
||||
public virtual bool ShowGameModeIntroCutscene() => false;
|
||||
|
||||
/// <summary>
|
||||
/// Can Admin be used in this gamemode.
|
||||
/// </summary>
|
||||
/// <param name="console">Admin Console.</param>
|
||||
/// <returns><see langword="true"/> if Admin console is enabled.</returns>
|
||||
/// <returns>True if Admin console is enabled.</returns>
|
||||
public virtual bool CanUseMapConsole(MapConsole console) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Can a <see cref="DeadBody"/> be reported in this gamemode.
|
||||
/// Can a body be reported in this gamemode.
|
||||
/// </summary>
|
||||
/// <param name="body">Target <see cref="DeadBody"/> for reporting.</param>
|
||||
/// <returns><see langword="true"/> if <see cref="DeadBody"/>s can be reported.</returns>
|
||||
/// <param name="body">Target body for reporting.</param>
|
||||
/// <returns>True if dead bodies can be reported.</returns>
|
||||
public virtual bool CanReport(DeadBody body) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Can <see cref="SystemConsole"/>s be used in this gamemode.
|
||||
/// Can system consoles be used in this gamemode.
|
||||
/// </summary>
|
||||
/// <param name="console">System Console.</param>
|
||||
/// <returns><see langword="true"/> if <see cref="SystemConsole"/>s are enabled in this mode.</returns>
|
||||
/// <returns>True if system consoles are enabled in this mode.</returns>
|
||||
public virtual bool CanUseSystemConsole(SystemConsole console) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Can tasks be interacted with in this gamemode.
|
||||
/// </summary>
|
||||
/// <param name="console">Task console.</param>
|
||||
/// <returns><see langword="true"/> if tasks are enabled in this mode.</returns>
|
||||
/// <returns>True if tasks are enabled in this mode.</returns>
|
||||
public virtual bool CanUseTasks(Console console) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Should the sabotage map be used when attempting to open sabotage overlay.
|
||||
/// </summary>
|
||||
/// <param name="map"><see cref="MapBehaviour"/> object.</param>
|
||||
/// <returns><see langword="true"/> if the sabotage map should be shown.</returns>
|
||||
/// <param name="map">MapBehaviour object.</param>
|
||||
/// <returns>True if the sabotage map should be shown.</returns>
|
||||
public virtual bool ShouldShowSabotageMap(MapBehaviour map) => true;
|
||||
|
||||
/// <summary>
|
||||
@@ -149,6 +149,6 @@ public abstract class CustomGameMode
|
||||
/// </summary>
|
||||
/// <param name="vent">Target vent.</param>
|
||||
/// <param name="playerInfo">Player attempting to vent.</param>
|
||||
/// <returns><see langword="true"/> if venting is enabled in this mode.</returns>
|
||||
/// <returns>True if venting is enabled in this mode.</returns>
|
||||
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
|
||||
}
|
||||
@@ -6,12 +6,12 @@ using Reactor.Utilities;
|
||||
namespace MiraAPI.GameModes;
|
||||
|
||||
/// <summary>
|
||||
/// Manages <see cref="CustomGameMode"/>s.
|
||||
/// Manages custom gamemodes.
|
||||
/// </summary>
|
||||
public static class CustomGameModeManager
|
||||
{
|
||||
/// <summary>
|
||||
/// List of registered <see cref="CustomGameMode"/>.
|
||||
/// List of registered gamemodes.
|
||||
/// </summary>
|
||||
internal static readonly Dictionary<int, CustomGameMode> GameModes = [];
|
||||
|
||||
@@ -21,14 +21,14 @@ public static class CustomGameModeManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current <see cref="CustomGameMode"/>.
|
||||
/// Gets the current gamemode.
|
||||
/// </summary>
|
||||
public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode();
|
||||
|
||||
/// <summary>
|
||||
/// Set current <see cref="CustomGameMode"/>.
|
||||
/// Set current gamemode.
|
||||
/// </summary>
|
||||
/// <param name="id"><see cref="CustomGameMode"/> ID.</param>
|
||||
/// <param name="id">gamemode ID.</param>
|
||||
public static void SetGameMode(int id)
|
||||
{
|
||||
if (GameModes.TryGetValue(id, out var gameMode))
|
||||
@@ -37,18 +37,18 @@ public static class CustomGameModeManager
|
||||
return;
|
||||
}
|
||||
|
||||
Error($"No gamemode with id {id} found!");
|
||||
Logger<MiraApiPlugin>.Error($"No gamemode with id {id} found!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register <see cref="CustomGameMode"/> from type.
|
||||
/// Register gamemode from type.
|
||||
/// </summary>
|
||||
/// <param name="gameModeType">Type of <see cref="CustomGameMode"/>, should inherit from <see cref="CustomGameMode"/>.</param>
|
||||
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="CustomGameMode"/>.</param>
|
||||
internal static void RegisterGameMode(Type gameModeType)
|
||||
{
|
||||
if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType))
|
||||
{
|
||||
Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
|
||||
Logger<MiraApiPlugin>.Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ public static class CustomGameModeManager
|
||||
|
||||
if (modeObj is not CustomGameMode gameMode)
|
||||
{
|
||||
Error($"Failed to create instance of {gameModeType.Name}");
|
||||
Logger<MiraApiPlugin>.Error($"Failed to create instance of {gameModeType.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameModes.Any(x => x.Key == gameMode.Id))
|
||||
{
|
||||
Error($"ID for gamemode {gameMode.Name} already exists!");
|
||||
Logger<MiraApiPlugin>.Error($"ID for gamemode {gameMode.Name} already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using MiraAPI.Modifiers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.GameOptions;
|
||||
@@ -32,29 +31,21 @@ public abstract class AbstractOptionGroup
|
||||
/// Gets a value indicating whether the group should be shown in the modifiers menu.
|
||||
/// </summary>
|
||||
// TODO: make this not a boolean
|
||||
#pragma warning disable S1133
|
||||
[Obsolete("Use ParentMenu instead.")]
|
||||
#pragma warning restore S1133
|
||||
public virtual bool ShowInModifiersMenu => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating which menu the group is in.
|
||||
/// </summary>
|
||||
public virtual MenuCategory ParentMenu => MenuCategory.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the function that determines whether the group should be visible or not.
|
||||
/// </summary>
|
||||
public virtual Func<bool> GroupVisible => () => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the group <see cref="Color"/>. This is used to color the group in the options menu.
|
||||
/// Gets the group color. This is used to color the group in the options menu.
|
||||
/// </summary>
|
||||
public virtual Color GroupColor => MiraApiPlugin.DefaultHeaderColor;
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see langword="uint"/> value.
|
||||
/// Zero is the highest priority, and the default value is the max uint value.
|
||||
/// </summary>
|
||||
public virtual uint GroupPriority => uint.MaxValue;
|
||||
|
||||
@@ -71,55 +62,4 @@ public abstract class AbstractOptionGroup<T> : AbstractOptionGroup where T : IOp
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override Type OptionableType => typeof(T);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating which menu the group is in.
|
||||
/// </summary>
|
||||
public override MenuCategory ParentMenu
|
||||
{
|
||||
get
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (type == typeof(BaseModifier))
|
||||
{
|
||||
return MenuCategory.Modifiers;
|
||||
}
|
||||
else if (type == typeof(RoleBehaviour))
|
||||
{
|
||||
return MenuCategory.Roles;
|
||||
}
|
||||
return MenuCategory.Game;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Menu categories for option groups.
|
||||
/// </summary>
|
||||
public enum MenuCategory
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines the option group is in the game settings tab.
|
||||
/// </summary>
|
||||
Game,
|
||||
|
||||
/// <summary>
|
||||
/// Determines the option group is in the role settings tab.
|
||||
/// </summary>
|
||||
Roles,
|
||||
|
||||
/// <summary>
|
||||
/// Determines the option group is in the modifier settings tab.
|
||||
/// </summary>
|
||||
Modifiers,
|
||||
|
||||
/// <summary>
|
||||
/// Determines the option group is in the first custom settings tab.
|
||||
/// </summary>
|
||||
CustomOne,
|
||||
|
||||
/// <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;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for creating a <see cref="ModdedEnumOption"/>.
|
||||
/// Attribute for creating an enum option.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? values = null)
|
||||
|
||||
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for a <see cref="ModdedNumberOption"/>.
|
||||
/// A number option attribute for the modded options system.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ModdedNumberOptionAttribute(
|
||||
@@ -21,15 +21,7 @@ public class ModdedNumberOptionAttribute(
|
||||
{
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
return new ModdedNumberOption(
|
||||
Title,
|
||||
(float)(value ?? min + increment),
|
||||
min,
|
||||
max,
|
||||
increment,
|
||||
suffixType,
|
||||
formatString,
|
||||
zeroInfinity);
|
||||
return new ModdedNumberOption(Title, (float)(value ?? min+increment), min, max, increment, suffixType, formatString, zeroInfinity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Reflection;
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an attribute that is used to define an <see cref="IModdedOption"/>.
|
||||
/// Represents an attribute that is used to define a modded option.
|
||||
/// </summary>
|
||||
/// <param name="title">The option title.</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>
|
||||
/// Sets the value of the option.
|
||||
/// </summary>
|
||||
/// <param name="value">The new value as an <see langword="object"/>.</param>
|
||||
/// <param name="value">The new value as an object.</param>
|
||||
public abstract void SetValue(object value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the option.
|
||||
/// </summary>
|
||||
/// <returns>The value of the option as an <see langword="object"/>.</returns>
|
||||
/// <returns>The value of the option as an object.</returns>
|
||||
public abstract object GetValue();
|
||||
|
||||
internal abstract IModdedOption? CreateOption(object? value, PropertyInfo property);
|
||||
|
||||
@@ -5,7 +5,7 @@ using MiraAPI.GameOptions.OptionTypes;
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for a <see cref="ModdedToggleOption"/>.
|
||||
/// Attribute for a toggle option.
|
||||
/// </summary>
|
||||
/// <param name="title">The option title.</param>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
|
||||
@@ -17,27 +17,27 @@ public interface IModdedOption
|
||||
uint Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the option.
|
||||
/// Gets the title of the option.
|
||||
/// </summary>
|
||||
string Title { get; set; }
|
||||
string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="StringNames"/> for the option, used for localization.
|
||||
/// Gets the StringName for the option, used for localization.
|
||||
/// </summary>
|
||||
StringNames StringName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IMiraPlugin"/> that created this option.
|
||||
/// Gets or sets the MiraPlugin that created this option.
|
||||
/// </summary>
|
||||
IMiraPlugin? ParentMod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="BaseGameSetting"/> for the option.
|
||||
/// Gets the game setting data for the option.
|
||||
/// </summary>
|
||||
BaseGameSetting Data { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="global::OptionBehaviour"/> object of the option.
|
||||
/// Gets the OptionBehaviour object of the option.
|
||||
/// </summary>
|
||||
OptionBehaviour? OptionBehaviour { get; }
|
||||
|
||||
@@ -52,55 +52,55 @@ public interface IModdedOption
|
||||
bool IncludeInPreset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="BepInEx.Configuration.ConfigDefinition"/> for the option, used for BepInEx configuration.
|
||||
/// Gets or sets the ConfigDefinition for the option, used for BepInEx configuration.
|
||||
/// </summary>
|
||||
ConfigDefinition? ConfigDefinition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates the option behaviour for the modded option.
|
||||
/// </summary>
|
||||
/// <param name="toggleOpt">The <see cref="ToggleOption"/> template.</param>
|
||||
/// <param name="numberOpt">The <see cref="NumberOption"/> template.</param>
|
||||
/// <param name="stringOpt">The <see cref="StringOption"/> template.</param>
|
||||
/// <param name="playerOpt">The <see cref="PlayerOption"/> template.</param>
|
||||
/// <param name="container">The <see cref="Transform"/> container for the option.</param>
|
||||
/// <returns>The created <see cref="global::OptionBehaviour"/> object.</returns>
|
||||
/// <param name="toggleOpt">The ToggleOption template.</param>
|
||||
/// <param name="numberOpt">The NumberOption template.</param>
|
||||
/// <param name="stringOpt">The StringOption template.</param>
|
||||
/// <param name="playerOpt">The PlayerOption template.</param>
|
||||
/// <param name="container">>The Transform container for the option.</param>
|
||||
/// <returns>>The created OptionBehaviour object.</returns>
|
||||
OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value as a <see langword="float"/>.
|
||||
/// Gets the value as a float.
|
||||
/// </summary>
|
||||
/// <returns>The value of the option as a <see langword="float"/>.</returns>
|
||||
/// <returns>>The value of the option as a float.</returns>
|
||||
float GetFloatData();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NetData"/> for the option, used for network synchronization.
|
||||
/// Gets the NetData for the option, used for network synchronization.
|
||||
/// </summary>
|
||||
/// <returns>Returns the <see cref="NetData"/> object for the option.</returns>
|
||||
/// <returns>>Returns the NetData object for the option.</returns>
|
||||
NetData GetNetData();
|
||||
|
||||
/// <summary>
|
||||
/// Handles incoming network data for the option.
|
||||
/// </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);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the option to a preset configuration file.
|
||||
/// </summary>
|
||||
/// <param name="presetConfig">The <see cref="ConfigFile"/> representing the preset configuration.</param>
|
||||
/// <param name="presetConfig">The ConfigFile representing the preset configuration.</param>
|
||||
/// <param name="saveDefault">Indicates whether to save the default value instead of the current value.</param>
|
||||
void SaveToPreset(ConfigFile presetConfig, bool saveDefault = false);
|
||||
|
||||
/// <summary>
|
||||
/// Binds the option to a configuration file.
|
||||
/// </summary>
|
||||
/// <param name="config">The <see cref="ConfigFile"/> to bind the option to.</param>
|
||||
/// <param name="config">The ConfigFile to bind the option to.</param>
|
||||
void Bind(ConfigFile config);
|
||||
|
||||
/// <summary>
|
||||
/// Loads the option from a preset configuration file, applying the values to the option's configuration.
|
||||
/// </summary>
|
||||
/// <param name="presetConfig">The <see cref="ConfigFile"/> representing the preset configuration.</param>
|
||||
/// <param name="presetConfig">The ConfigFile representing the preset configuration.</param>
|
||||
void LoadFromPreset(ConfigFile presetConfig);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.GameOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Component added onto options generated via MiraAPI. This allows developers to hook patches onto options in general, without using a list.
|
||||
/// </summary>
|
||||
[RegisterInIl2Cpp]
|
||||
public class MiraNumberOptionComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="ModdedNumberOption"/> associated with the object.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public ModdedNumberOption NumberOption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default increment.
|
||||
/// </summary>
|
||||
public float DefaultIncrement { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether holding shift will split the increment in half.
|
||||
/// </summary>
|
||||
public bool ShiftIncrementToggle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating what Zero displays.
|
||||
/// </summary>
|
||||
public string ZeroValue { get; set; } = "#";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating what Negative One displays.
|
||||
/// </summary>
|
||||
public string NegativeValue { get; set; } = "#";
|
||||
}
|
||||
@@ -16,7 +16,7 @@ using Reactor.Utilities;
|
||||
namespace MiraAPI.GameOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Handles <see cref="IModdedOption"/>s.
|
||||
/// Handles modded options.
|
||||
/// </summary>
|
||||
public static class ModdedOptionsManager
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public static class ModdedOptionsManager
|
||||
|
||||
if (TypeToGroup.ContainsKey(type))
|
||||
{
|
||||
Error($"Group {type.Name} already exists.");
|
||||
Logger<MiraApiPlugin>.Error($"Group {type.Name} already exists.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ public static class ModdedOptionsManager
|
||||
{
|
||||
if (!TypeToGroup.TryGetValue(type, out var group))
|
||||
{
|
||||
Error($"Failed to get group for {type.Name}");
|
||||
Logger<MiraApiPlugin>.Error($"Failed to get group for {type.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (property.GetValue(group) is not IModdedOption option)
|
||||
{
|
||||
Error($"Failed to get option for {property.Name}");
|
||||
Logger<MiraApiPlugin>.Error($"Failed to get option for {property.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,13 +81,13 @@ public static class ModdedOptionsManager
|
||||
{
|
||||
if (OptionAttributes.ContainsKey(property))
|
||||
{
|
||||
Error($"Property {property.Name} already has an attribute registered.");
|
||||
Logger<MiraApiPlugin>.Error($"Property {property.Name} already has an attribute registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TypeToGroup.TryGetValue(type, out var group))
|
||||
{
|
||||
Error($"Failed to get group for {type.Name}");
|
||||
Logger<MiraApiPlugin>.Error($"Failed to get group for {type.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public static class ModdedOptionsManager
|
||||
|
||||
if (option == null)
|
||||
{
|
||||
Error($"Failed to get option for {property.Name}");
|
||||
Logger<MiraApiPlugin>.Error($"Failed to get option for {property.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public static class ModdedOptionsManager
|
||||
/// </summary>
|
||||
/// <param name="__originalMethod">The original getter method.</param>
|
||||
/// <param name="__result">The result of the property getter.</param>
|
||||
/// <returns><see langword="false"/> so the original getter gets skipped.</returns>
|
||||
/// <returns>False so the original getter gets skipped.</returns>
|
||||
#pragma warning disable CA1707
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony naming convention")]
|
||||
public static bool PropertyGetterPatch(MethodBase __originalMethod, ref object __result)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.GameOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton for <see cref="AbstractOptionGroup"/>s.
|
||||
/// Singleton for option groups.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The option group type.</typeparam>
|
||||
public static class OptionGroupSingleton<T> where T : AbstractOptionGroup
|
||||
@@ -11,7 +11,7 @@ public static class OptionGroupSingleton<T> where T : AbstractOptionGroup
|
||||
private static T? _instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <typeparamref name="T"/> group.
|
||||
/// Gets the instance of the option group.
|
||||
/// </summary>
|
||||
#pragma warning disable CA1000
|
||||
public static T Instance => _instance ??= ModdedOptionsManager.Groups.OfType<T>().Single();
|
||||
|
||||
@@ -11,7 +11,7 @@ using Object = UnityEngine.Object;
|
||||
namespace MiraAPI.GameOptions.OptionTypes;
|
||||
|
||||
/// <summary>
|
||||
/// An option for selecting an <see langword="enum"/> value.
|
||||
/// An option for selecting an enum value.
|
||||
/// </summary>
|
||||
public class ModdedEnumOption : ModdedOption<int>
|
||||
{
|
||||
@@ -25,8 +25,8 @@ public class ModdedEnumOption : ModdedOption<int>
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the option.</param>
|
||||
/// <param name="defaultValue">The default value as an int.</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 <see langword="enum"/> name.</param>
|
||||
/// <param name="enumType">The Enum type.</param>
|
||||
/// <param name="values">An option list of string values to use in place of the enum name.</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)
|
||||
{
|
||||
@@ -47,8 +47,6 @@ public class ModdedEnumOption : ModdedOption<int>
|
||||
public override OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container)
|
||||
{
|
||||
var stringOption = Object.Instantiate(stringOpt, container);
|
||||
stringOption.name =
|
||||
$"{ParentMod!.OptionsTitleText}.EnumOption.{TranslationController.Instance.GetString(StringName)}";
|
||||
|
||||
stringOption.SetUpFromData(Data, 20);
|
||||
stringOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
@@ -104,13 +102,13 @@ public class ModdedEnumOption : ModdedOption<int>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An option for selecting an <see langword="enum"/> value.
|
||||
/// An option for selecting an enum value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="Enum"/> type.</typeparam>
|
||||
/// <typeparam name="T">The enum type.</typeparam>
|
||||
public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the string values of the <see langword="enum"/>.
|
||||
/// Gets the string values of the enum.
|
||||
/// </summary>
|
||||
public string[] Values { get; }
|
||||
|
||||
@@ -118,8 +116,8 @@ public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
|
||||
/// Initializes a new instance of the <see cref="ModdedEnumOption{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the option.</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 <see langword="enum"/> name.</param>
|
||||
/// <param name="defaultValue">The default value as an int.</param>
|
||||
/// <param name="values">An option list of string values to use in place of the enum name.</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)
|
||||
{
|
||||
@@ -140,8 +138,6 @@ public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
|
||||
public override OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container)
|
||||
{
|
||||
var stringOption = Object.Instantiate(stringOpt, container);
|
||||
stringOption.name =
|
||||
$"{ParentMod!.OptionsTitleText}.EnumOption.{TranslationController.Instance.GetString(StringName)}";
|
||||
|
||||
stringOption.SetUpFromData(Data, 20);
|
||||
stringOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
|
||||
@@ -32,82 +32,10 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating what zero appears as.
|
||||
/// </summary>
|
||||
public string ZeroWordValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating what a negative one appears as.
|
||||
/// </summary>
|
||||
public string NegativeWordValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether zero is infinity.
|
||||
/// </summary>
|
||||
public bool ZeroInfinity => ZeroWordValue == "∞";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether holding shift will divide the increment.
|
||||
/// </summary>
|
||||
public bool ShiftIncrement { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModdedNumberOption"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the option.</param>
|
||||
/// <param name="defaultValue">The default value as a float.</param>
|
||||
/// <param name="min">The minimum value.</param>
|
||||
/// <param name="max">The maximum value.</param>
|
||||
/// <param name="increment">The increment.</param>
|
||||
/// <param name="suffixType">The suffix type.</param>
|
||||
/// <param name="formatString">Optional format string for the option screen.</param>
|
||||
/// <param name="zeroBehavior">Determines what is shown for zero. Options: ∞, #, or a word value (such as Off).</param>
|
||||
/// <param name="negativeBehavior">Determines what is shown for negative 1. Options: ∞, #, or a word value (such as Off).</param>
|
||||
/// <param name="halfIncrements">Whether increments can be split in half.</param>
|
||||
/// <param name="includeInPreset">Whether to include this option in the preset or not.</param>
|
||||
public ModdedNumberOption(
|
||||
string title,
|
||||
float defaultValue,
|
||||
float min,
|
||||
float max,
|
||||
float increment,
|
||||
string zeroBehavior,
|
||||
string negativeBehavior,
|
||||
MiraNumberSuffixes suffixType,
|
||||
string? formatString = null,
|
||||
bool halfIncrements = false,
|
||||
bool includeInPreset = true) : base(title, defaultValue, includeInPreset)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
Increment = increment;
|
||||
SuffixType = suffixType;
|
||||
ZeroWordValue = zeroBehavior;
|
||||
NegativeWordValue = negativeBehavior;
|
||||
ShiftIncrement = halfIncrements;
|
||||
|
||||
Value = Mathf.Clamp(defaultValue, min, max);
|
||||
|
||||
Data = ScriptableObject.CreateInstance<FloatGameSetting>();
|
||||
|
||||
var data = (FloatGameSetting)Data;
|
||||
data.Type = global::OptionTypes.Float;
|
||||
data.Title = StringName;
|
||||
data.Value = Value;
|
||||
data.Increment = Increment;
|
||||
data.ValidRange = new FloatRange(Min, Max);
|
||||
data.FormatString = formatString ??
|
||||
(defaultValue.IsInteger() &&
|
||||
Increment.IsInteger() &&
|
||||
Value.IsInteger() &&
|
||||
Min.IsInteger() &&
|
||||
Max.IsInteger() ? "0" : "0.0");
|
||||
|
||||
data.ZeroIsInfinity = ZeroInfinity;
|
||||
data.SuffixType = (NumberSuffixes)SuffixType;
|
||||
data.OptionName = FloatOptionNames.Invalid;
|
||||
}
|
||||
public bool ZeroInfinity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModdedNumberOption"/> class.
|
||||
@@ -136,9 +64,7 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
Max = max;
|
||||
Increment = increment;
|
||||
SuffixType = suffixType;
|
||||
ZeroWordValue = zeroInfinity ? "∞" : "#";
|
||||
NegativeWordValue = "#";
|
||||
ShiftIncrement = increment != 1f;
|
||||
ZeroInfinity = zeroInfinity;
|
||||
|
||||
Value = Mathf.Clamp(defaultValue, min, max);
|
||||
|
||||
@@ -171,14 +97,6 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
Transform container)
|
||||
{
|
||||
var numberOption = Object.Instantiate(numberOpt, Vector3.zero, Quaternion.identity, container);
|
||||
numberOption.name =
|
||||
$"{ParentMod!.OptionsTitleText}.NumberOption.{TranslationController.Instance.GetString(StringName)}";
|
||||
var optionComponent = numberOption.gameObject.AddComponent<MiraNumberOptionComponent>();
|
||||
optionComponent.NumberOption = this;
|
||||
optionComponent.DefaultIncrement = Increment;
|
||||
optionComponent.ShiftIncrementToggle = ShiftIncrement;
|
||||
optionComponent.NegativeValue = NegativeWordValue;
|
||||
optionComponent.ZeroValue = ZeroWordValue;
|
||||
|
||||
numberOption.SetUpFromData(Data, 20);
|
||||
numberOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
@@ -237,7 +155,7 @@ public class ModdedNumberOption : ModdedOption<float>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts the option to an <see langword="int"/>.
|
||||
/// Implicitly converts the option to an int.
|
||||
/// </summary>
|
||||
/// <param name="option">The option.</param>
|
||||
/// <returns>Integer value.</returns>
|
||||
|
||||
@@ -21,7 +21,7 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
public uint Id { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Title { get; set; }
|
||||
public string Title { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public StringNames StringName { get; }
|
||||
@@ -125,7 +125,7 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
{
|
||||
if (ConfigDefinition is null)
|
||||
{
|
||||
Error($"Attempted to save {Title} to preset, but ConfigDefinition is null.");
|
||||
Logger<MiraApiPlugin>.Error($"Attempted to save {Title} to preset, but ConfigDefinition is null.");
|
||||
return;
|
||||
}
|
||||
Bind(presetConfig);
|
||||
@@ -147,7 +147,7 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
}
|
||||
else
|
||||
{
|
||||
Error($"Attempted to load {Title} from preset, but ConfigDefinition is not found in preset.");
|
||||
Logger<MiraApiPlugin>.Error($"Attempted to load {Title} from preset, but ConfigDefinition is not found in preset.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ using Object = UnityEngine.Object;
|
||||
namespace MiraAPI.GameOptions.OptionTypes;
|
||||
|
||||
/// <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 <see cref="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 Values list.
|
||||
/// </summary>
|
||||
public class ModdedPlayerOption : ModdedOption<int>
|
||||
{
|
||||
@@ -55,8 +55,6 @@ public class ModdedPlayerOption : ModdedOption<int>
|
||||
Transform container)
|
||||
{
|
||||
var playerOption = Object.Instantiate(playerOpt, container);
|
||||
playerOption.name =
|
||||
$"{ParentMod!.OptionsTitleText}.PlayerOption.{TranslationController.Instance.GetString(StringName)}";
|
||||
|
||||
var filteredList = GetFilteredPlayers();
|
||||
Values = filteredList.ToIl2CppList();
|
||||
@@ -91,9 +89,9 @@ public class ModdedPlayerOption : ModdedOption<int>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a player from the value. If <see cref="AllowNone"/> is enabled and none is enabled this will return <see langword="null"/>.
|
||||
/// Returns a player from the value. If AllowNone is enabled and none is enabled this will return null.
|
||||
/// </summary>
|
||||
/// <returns>A player or <see langword="null"/> if chosen none.</returns>
|
||||
/// <returns>A player or null if chosen none.</returns>
|
||||
public NetworkedPlayerInfo? GetPlayerValue()
|
||||
{
|
||||
return Value < 0 ? null : Values[Value];
|
||||
|
||||
@@ -29,8 +29,6 @@ public class ModdedToggleOption : ModdedOption<bool>
|
||||
public override OptionBehaviour CreateOption(ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container)
|
||||
{
|
||||
var toggleOption = Object.Instantiate(toggleOpt, Vector3.zero, Quaternion.identity, container);
|
||||
toggleOption.name =
|
||||
$"{ParentMod!.OptionsTitleText}.ToggleOption.{TranslationController.Instance.GetString(StringName)}";
|
||||
|
||||
toggleOption.SetUpFromData(Data, 20);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// The location of the <see cref="CustomActionButton"/> on the screen.
|
||||
/// The location of the custom button on the screen.
|
||||
/// </summary>
|
||||
public enum ButtonLocation
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// The uses mode for <see cref="CustomActionButton"/>s.
|
||||
/// The uses mode for custom buttons.
|
||||
/// </summary>
|
||||
public enum ButtonUsesMode
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ using Object = UnityEngine.Object;
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// Class for making custom action buttons. More customizable than the default <see cref="ActionButton"/>/<see cref="AbilityButton"/>s in the base game.
|
||||
/// Class for making custom action buttons. More customizable than the default Action/Ability buttons in the base game.
|
||||
/// </summary>
|
||||
public abstract class CustomActionButton
|
||||
{
|
||||
@@ -54,7 +54,7 @@ public abstract class CustomActionButton
|
||||
public virtual string CooldownTimerFormatString => "0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the button has an effect ability. By default <see langword="true"/> if <see cref="EffectDuration"/> is greater than 0.
|
||||
/// Gets a value indicating whether the button has an effect ability. By default true if <see cref="EffectDuration"/> is greater than 0.
|
||||
/// </summary>
|
||||
public virtual bool HasEffect => EffectDuration > 0;
|
||||
|
||||
@@ -64,14 +64,9 @@ public abstract class CustomActionButton
|
||||
public virtual float EffectDuration => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the button has limited uses.
|
||||
/// Gets the maximum amount of uses the button has. If the button has infinite uses, set to 0.
|
||||
/// </summary>
|
||||
public bool LimitedUses => ZeroIsInfinite ? MaxUses > 0 : MaxUses >= 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum number of uses the button has. If the button has infinite uses, set to 0 or -1 based on what value that ZeroIsInfinite is set to.
|
||||
/// </summary>
|
||||
public virtual int MaxUses => ZeroIsInfinite ? 0 : -1;
|
||||
public virtual int MaxUses => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value indicating uses mode.
|
||||
@@ -79,24 +74,24 @@ public abstract class CustomActionButton
|
||||
public virtual ButtonUsesMode UsesMode => ButtonUsesMode.PerGame;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the keybind for this button. If <see langword="null"/>, no keybind will be added.
|
||||
/// Gets the keybind for this button. If null, no keybind will be added.
|
||||
/// </summary>
|
||||
public virtual BaseKeybind? Keybind => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the button's text outline <see cref="Color"/>.
|
||||
/// Gets the button's text outline color.
|
||||
/// </summary>
|
||||
public virtual Color TextOutlineColor => Color.clear;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="ButtonLocation"/> on the screen.
|
||||
/// Gets or sets the location of the button on the screen.
|
||||
/// </summary>
|
||||
public virtual ButtonLocation Location { get; set; } = ButtonLocation.BottomLeft;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether limited uses are determined via zero or a negative number of uses.
|
||||
/// Gets a value indicating whether the button has limited uses.
|
||||
/// </summary>
|
||||
public virtual bool ZeroIsInfinite { get; set; } = true;
|
||||
public bool LimitedUses => MaxUses > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the effect is currently active, if there is one.
|
||||
@@ -119,12 +114,12 @@ public abstract class CustomActionButton
|
||||
public float Timer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="ActionButton"/> object in game. This is created by Mira API automatically.
|
||||
/// Gets or sets the button object in game. This is created by Mira API automatically.
|
||||
/// </summary>
|
||||
public ActionButton? Button { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GameObject"/> used for the keybind icon.
|
||||
/// Gets the gameObject used for the keybind icon.
|
||||
/// </summary>
|
||||
public GameObject? KeybindIcon { get; private set; }
|
||||
|
||||
@@ -211,39 +206,7 @@ public abstract class CustomActionButton
|
||||
{
|
||||
if (Enabled(PlayerControl.LocalPlayer.Data.Role))
|
||||
{
|
||||
// Invoke the generic button click event.
|
||||
var genericEvent = new MiraButtonClickEvent(this);
|
||||
MiraEventManager.InvokeEvent(genericEvent);
|
||||
if (genericEvent.IsCancelled)
|
||||
{
|
||||
MiraEventManager.InvokeEvent(new MiraButtonCancelledEvent(this));
|
||||
}
|
||||
|
||||
// Invoke the button click event for specific button.
|
||||
var eventType = CustomButtonManager.ButtonEventTypes[GetType()];
|
||||
var @event = (MiraCancelableEvent)Activator.CreateInstance(eventType, this, genericEvent)!;
|
||||
var specificInvoked = MiraEventManager.InvokeEvent(@event, eventType);
|
||||
if (@event.IsCancelled)
|
||||
{
|
||||
var cancelEventType = CustomButtonManager.ButtonCancelledEventTypes[GetType()];
|
||||
var cancelEvent = (MiraEvent)Activator.CreateInstance(cancelEventType, this)!;
|
||||
MiraEventManager.InvokeEvent(cancelEvent, cancelEventType);
|
||||
}
|
||||
|
||||
if (specificInvoked)
|
||||
{
|
||||
if (!@event.IsCancelled)
|
||||
{
|
||||
ClickHandler();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!genericEvent.IsCancelled)
|
||||
{
|
||||
ClickHandler();
|
||||
}
|
||||
}
|
||||
ClickHandler();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -251,10 +214,9 @@ public abstract class CustomActionButton
|
||||
Helpers.CreateKeybindIcon(
|
||||
Button.gameObject,
|
||||
Keybind.CurrentKey,
|
||||
new Vector3(0.4f, 0.45f, -9f)
|
||||
new Vector3(MaxUses <= 0 ? -0.4f : 0.4f, 0.45f, -9f)
|
||||
);
|
||||
KeybindText = KeybindIcon.transform.GetChild(0).GetComponent<TextMeshPro>();
|
||||
HudManagerPatches.ModdedKeybindIcons.Add(KeybindText);
|
||||
Button.usesRemainingSprite.transform.localPosition = new(-0.341f, 0.45f, -0.1f);
|
||||
}
|
||||
}
|
||||
@@ -271,7 +233,7 @@ public abstract class CustomActionButton
|
||||
return;
|
||||
}
|
||||
|
||||
Location = location;
|
||||
this.Location = location;
|
||||
|
||||
if (!moveButton)
|
||||
{
|
||||
@@ -316,18 +278,18 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function to change the outline <see cref="Color"/> of the button's text.
|
||||
/// A utility function to change the outline color of the button's text.
|
||||
/// </summary>
|
||||
/// <param name="color">The new <see cref="Color"/>.</param>
|
||||
/// <param name="color">The new color.</param>
|
||||
public virtual void SetTextOutline(Color color)
|
||||
{
|
||||
Button?.buttonLabelText.SetOutlineColor(color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function to override the <see cref="UnityEngine.Sprite"/> of the button.
|
||||
/// A utility function to override the sprite of the button.
|
||||
/// </summary>
|
||||
/// <param name="sprite">The new <see cref="UnityEngine.Sprite"/> to override with.</param>
|
||||
/// <param name="sprite">The new sprite to override with.</param>
|
||||
public virtual void OverrideSprite(Sprite sprite)
|
||||
{
|
||||
if (Button != null)
|
||||
@@ -415,7 +377,7 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function that runs with the local player's <see cref="PlayerControl.FixedUpdate"/> if the button is enabled.
|
||||
/// A utility function that runs with the local PlayerControl's FixedUpdate if the button is enabled.
|
||||
/// </summary>
|
||||
/// <param name="playerControl">the local PlayerControl.</param>
|
||||
protected virtual void FixedUpdate(PlayerControl playerControl)
|
||||
@@ -429,10 +391,10 @@ public abstract class CustomActionButton
|
||||
|
||||
/// <summary>
|
||||
/// This method determines if the button should be active or not.
|
||||
/// <see langword="true"/> means the button is active, <see langword="false"/> means the button is disabled.
|
||||
/// True means the button is active, false means the button is disabled.
|
||||
/// </summary>
|
||||
/// <param name="role">The <see cref="RoleBehaviour"/> of the local player.</param>
|
||||
/// <returns><see langword="true"/> if the button is enabled, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="role">The role of the local player.</param>
|
||||
/// <returns>True if the button is enabled, false otherwise.</returns>
|
||||
public abstract bool Enabled(RoleBehaviour? role);
|
||||
|
||||
/// <summary>
|
||||
@@ -445,7 +407,7 @@ public abstract class CustomActionButton
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the effect can be ended early by the player.
|
||||
/// Always <see langword="false"/> by default.
|
||||
/// Always false by default.
|
||||
/// </summary>
|
||||
/// <returns>Can the effect be canceled.</returns>
|
||||
public virtual bool IsEffectCancellable() => false;
|
||||
@@ -473,12 +435,12 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see langword="true"/>.
|
||||
/// This method is called on the HudManager.SetHudActive 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.
|
||||
/// It can be overridden for custom behavior.
|
||||
/// </summary>
|
||||
/// <param name="visible">Passed in from <see cref="HudManager.SetHudActive(PlayerControl, RoleBehaviour, bool)"/>, should hud be active.</param>
|
||||
/// <param name="role">Passed in from <see cref="HudManager.SetHudActive(PlayerControl, RoleBehaviour, bool)"/>, the current role of the player.</param>
|
||||
/// <param name="visible">Passed in from HudManager.SetHudActive, should hud be active.</param>
|
||||
/// <param name="role">Passed in from HudManager.SetHudActive, the current role of the player.</param>
|
||||
public virtual void SetActive(bool visible, RoleBehaviour role)
|
||||
{
|
||||
Button?.ToggleVisible(visible && Enabled(role));
|
||||
@@ -522,7 +484,7 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called on the <see cref="PlayerControl.FixedUpdate"/> method. It is a wrapper for the <see cref="FixedUpdate"/> method.
|
||||
/// This method is called on the 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.
|
||||
/// It can be overridden for custom behavior.
|
||||
/// </summary>
|
||||
@@ -532,7 +494,7 @@ public abstract class CustomActionButton
|
||||
if (Keybind != null && KeybindText != null)
|
||||
{
|
||||
KeybindText.text = Keybind.CurrentKey.ToString();
|
||||
KeybindIcon?.SetActive(ActiveInputManager.currentControlType is ActiveInputManager.InputType.Keyboard &&
|
||||
KeybindIcon?.SetActive(ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard &&
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.ShowKeybinds.Value &&
|
||||
Keybind.CurrentKey != KeyboardKeyCode.None);
|
||||
}
|
||||
@@ -580,39 +542,39 @@ public abstract class CustomActionButton
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom action button that has a target <typeparamref name="T"/>.
|
||||
/// Custom action button that has a target object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the target object.</typeparam>
|
||||
public abstract class CustomActionButton<T> : CustomActionButton where T : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the target <typeparamref name="T"/> of the button.
|
||||
/// Gets or sets the target object of the button.
|
||||
/// </summary>
|
||||
public T? Target { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the distance the player must be from the target <typeparamref name="T"/> to use the button.
|
||||
/// Gets the distance the player must be from the target object to use the button.
|
||||
/// </summary>
|
||||
public virtual float Distance => PlayerControl.LocalPlayer.Data.Role.GetAbilityDistance();
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the target <typeparamref name="T"/> is valid.
|
||||
/// Determines if the target object is valid.
|
||||
/// </summary>
|
||||
/// <param name="target">The target <typeparamref name="T"/> being checked.</param>
|
||||
/// <returns><see langword="true"/> if the target <typeparamref name="T"/> is valid, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="target">The target object being checked.</param>
|
||||
/// <returns>True if the target object is valid, false otherwise.</returns>
|
||||
public virtual bool IsTargetValid(T? target)
|
||||
{
|
||||
return target != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method used to get the target <typeparamref name="T"/>.
|
||||
/// The method used to get the target object.
|
||||
/// </summary>
|
||||
/// <returns>The target <typeparamref name="T"/> or <see langword="null"/> if it isn't found.</returns>
|
||||
/// <returns>The target object or null if it isn't found.</returns>
|
||||
public abstract T? GetTarget();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the outline of the target <typeparamref name="T"/>.
|
||||
/// Sets the outline of the target object.
|
||||
/// </summary>
|
||||
/// <param name="active">Should the outline be active.</param>
|
||||
public abstract void SetOutline(bool active);
|
||||
|
||||
@@ -9,12 +9,12 @@ using UnityEngine;
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// Custom button manager for handling <see cref="CustomActionButton"/>s.
|
||||
/// Custom button manager for handling custom buttons.
|
||||
/// </summary>
|
||||
public static class CustomButtonManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of all registered custom <see cref="CustomActionButton"/>s.
|
||||
/// Gets a list of all registered custom buttons.
|
||||
/// </summary>
|
||||
public static ReadOnlyCollection<CustomActionButton> Buttons { get; internal set; } = new([]);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// A utility class to get the instance of a <see cref="CustomActionButton"/>.
|
||||
/// A utility class to get the instance of a custom action button.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the button you are trying to access.</typeparam>
|
||||
public static class CustomButtonSingleton<T> where T : CustomActionButton
|
||||
@@ -12,7 +12,7 @@ public static class CustomButtonSingleton<T> where T : CustomActionButton
|
||||
private static T? _instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <typeparamref name="T"/> button.
|
||||
/// Gets the instance of the button.
|
||||
/// </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.")]
|
||||
public static T Instance => _instance ??= CustomButtonManager.CustomButtons.OfType<T>().Single();
|
||||
|
||||
@@ -15,9 +15,9 @@ using UnityEngine.Events;
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// Custom Player Menu using the <see cref="ShapeshifterPanel"/> as a base.
|
||||
/// Custom Player Menu using the ShapeshifterPanel as a base.
|
||||
/// </summary>
|
||||
/// <param name="il2CppPtr">Used by Il2Cpp. Do not use constructor, this is a <see cref="MonoBehaviour"/>.</param>
|
||||
/// <param name="il2CppPtr">Used by Il2Cpp. Do not use constructor, this is a MonoBehaviour.</param>
|
||||
[RegisterInIl2Cpp]
|
||||
[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")]
|
||||
@@ -34,9 +34,9 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
|
||||
public List<ShapeshifterPanel> potentialVictims;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="CustomPlayerMenu"/>.
|
||||
/// Creates a CustomPlayerMenu.
|
||||
/// </summary>
|
||||
/// <returns>New <see cref="CustomPlayerMenu"/> object.</returns>
|
||||
/// <returns>New CustomPlayerMenu object.</returns>
|
||||
public static CustomPlayerMenu Create()
|
||||
{
|
||||
var shapeShifterRole = RoleManager.Instance.GetRole(RoleTypes.Shapeshifter);
|
||||
@@ -84,7 +84,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
|
||||
/// Begins/opens the custom player menu.
|
||||
/// </summary>
|
||||
/// <param name="playerMatch">Function to determine if player should show in the custom menu.</param>
|
||||
/// <param name="onClick"><see cref="PassiveButton.OnClick"/> action for player.</param>
|
||||
/// <param name="onClick">Onclick action for player.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void Begin(Func<PlayerControl, bool> playerMatch, Action<PlayerControl?> onClick)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
|
||||
onClick(null);
|
||||
}));
|
||||
|
||||
DebugAnalytics.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
|
||||
DestroyableSingleton<DebugAnalytics>.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
|
||||
var list = PlayerControl.AllPlayerControls.ToArray().Where(playerMatch).ToList();
|
||||
potentialVictims = [];
|
||||
var list2 = new Il2CppSystem.Collections.Generic.List<UiElement>();
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
namespace MiraAPI.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CustomActionButton"/> that has multiple target objects.
|
||||
/// Custom action button that has multiple target objects.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the target objects.</typeparam>
|
||||
public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBehaviour
|
||||
@@ -36,11 +36,8 @@ public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBe
|
||||
/// <returns>The list of target objects.</returns>
|
||||
public abstract T[] GetTargets();
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <inheritdoc cref="CustomActionButton{T}.SetOutline"/>
|
||||
/// <param name="target">The target object to set the oultine.</param>
|
||||
public abstract void SetOutline(T target, bool active);
|
||||
|
||||
/// <inheritdoc cref="CustomActionButton{T}.CanUse"/>
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BaseKeybind
|
||||
public InputAction? RewiredInputAction { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier for this keybind. Used in Rewired.
|
||||
/// Gets the unique identifier for this keybind. Used in Rewired.
|
||||
/// </summary>
|
||||
public string Id { get; protected set; }
|
||||
|
||||
@@ -69,4 +69,4 @@ public class BaseKeybind
|
||||
{
|
||||
Handler -= action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,12 @@ using Rewired;
|
||||
namespace MiraAPI.Keybinds;
|
||||
|
||||
/// <summary>
|
||||
/// Lets you register and manage mod <see cref="MiraKeybind"/>s with conflict checks and rebinding support.
|
||||
/// Lets you register and manage mod keybinds with conflict checks and rebinding support.
|
||||
/// </summary>
|
||||
public static class KeybindManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of all registered <see cref="MiraKeybind"/>s.
|
||||
/// Gets a list of all registered keybinds.
|
||||
/// </summary>
|
||||
public static List<MiraKeybind> Keybinds { get; } = new();
|
||||
|
||||
@@ -26,11 +26,11 @@ public static class KeybindManager
|
||||
try
|
||||
{
|
||||
var instance = KeybindUtils.RewiredInputManager!;
|
||||
foreach (var keybind in Keybinds)
|
||||
foreach (var keybind in KeybindManager.Keybinds)
|
||||
{
|
||||
if (instance.userData.actions.ToArray().Any(x => x.name == keybind.Id))
|
||||
{
|
||||
Warning($"Keybind of id {keybind.Id} already exists. Skipping it");
|
||||
Logger<MiraApiPlugin>.Warning($"Keybind of id {keybind.Id} already exists. Skipping it");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ public static class KeybindManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while registering keybinds in Rewired: {e}");
|
||||
Logger<MiraApiPlugin>.Error($"Error while registering keybinds in Rewired: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all conflicts where <see cref="MiraKeybind"/>s use the same key.
|
||||
/// Returns all conflicts where keybinds use the same key.
|
||||
/// </summary>
|
||||
/// <returns>A list of pairs of keybinds that conflict.</returns>
|
||||
public static Dictionary<KeyboardKeyCode, List<MiraKeybind>> GetConflicts()
|
||||
@@ -77,11 +77,11 @@ public static class KeybindManager
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all <see cref="MiraKeybind"/>s for a specified keycode.
|
||||
/// Returns all keybinds for a specified keycode.
|
||||
/// </summary>
|
||||
/// <param name="keyCode">The key to look for.</param>
|
||||
/// /// <param name="exclusiveCheck">Should only exlusive keybinds be present.</param>
|
||||
/// <returns>The list of <see cref="MiraKeybind"/>s.</returns>
|
||||
/// <returns>The list of keybinds.</returns>
|
||||
public static MiraKeybind[] GetKeybindsForKey(KeyboardKeyCode keyCode, bool exclusiveCheck = false)
|
||||
{
|
||||
var all = new List<MiraKeybind>();
|
||||
|
||||
@@ -14,9 +14,9 @@ public static class KeybindUtils
|
||||
public static InputManager_Base? RewiredInputManager { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the currently assigned keycode of a <see cref="BaseKeybind"/>.
|
||||
/// Returns the currently assigned keycode of a keybind.
|
||||
/// </summary>
|
||||
/// <param name="keybind">The <see cref="BaseKeybind"/> to get the keycode from.</param>
|
||||
/// <param name="keybind">The keybind to get the keycode from.</param>
|
||||
/// <returns>The currently assigned keycode.</returns>
|
||||
public static KeyboardKeyCode GetKeycodeByKeybind(BaseKeybind keybind)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public static class KeybindUtils
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the keycode for an action with <see cref="ReInput"/>.
|
||||
/// Gets the keycode for an action with ReInput.
|
||||
/// </summary>
|
||||
/// <param name="actionId">The action ID.</param>
|
||||
/// <returns>The keyboard keycode.</returns>
|
||||
@@ -39,7 +39,7 @@ public static class KeybindUtils
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ActionElementMap"/> by id with <see cref="ReInput"/>.
|
||||
/// Gets a <see cref="ActionElementMap"/> by id with ReInput.
|
||||
/// </summary>
|
||||
/// <param name="actionId">The action ID.</param>
|
||||
/// <returns>The keyboard keycode.</returns>
|
||||
@@ -65,7 +65,7 @@ public static class KeybindUtils
|
||||
/// <param name="exclude">The KeyCode to skip during the search.</param>
|
||||
/// <returns>
|
||||
/// The first available KeyCode not currently used by any registered keybind,
|
||||
/// or <see cref="KeyboardKeyCode.None"/> if none are available.
|
||||
/// or KeyCode.None if none are available.
|
||||
/// </returns>
|
||||
public static KeyboardKeyCode FindAvailableKey(KeyboardKeyCode exclude)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.Keybinds;
|
||||
|
||||
/// <summary>
|
||||
/// Class containing all default <see cref="MiraKeybind"/>s.
|
||||
/// Class containing all default keybinds.
|
||||
/// Recommended for cross-mod compatibility.
|
||||
/// </summary>
|
||||
[RegisterCustomKeybinds]
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MiraAPI.Keybinds;
|
||||
public class MiraKeybind : BaseKeybind
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets name of the keybind.
|
||||
/// Gets name of the keybind
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
@@ -19,8 +19,8 @@ public class MiraKeybind : BaseKeybind
|
||||
public KeyboardKeyCode DefaultKey { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ModifierKey"/>s assigned to this keybind.
|
||||
/// Due to Rewired limitations, there can only be 3 <see cref="ModifierKey"/>s.
|
||||
/// Gets the modifier keys assigned to this keybind.
|
||||
/// Due to Rewired limitations, there can only be 3 modifier keys.
|
||||
/// </summary>
|
||||
public ModifierKey[] ModifierKeys { get; }
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MiraKeybind : BaseKeybind
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the keybind.</param>
|
||||
/// <param name="defaultKeycode">The default keycode.</param>
|
||||
/// <param name="modifierKeys">Up to 3 optional <see cref="ModifierKey"/>s.</param>
|
||||
/// <param name="modifierKeys">Up to 3 optional modifier keys.</param>
|
||||
/// <param name="exclusive">Is exclusive.</param>
|
||||
public MiraKeybind(
|
||||
string name,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.Keybinds;
|
||||
|
||||
/// <summary>
|
||||
/// Used to mark a class for <see cref="MiraKeybind"/>s registration.
|
||||
/// Used to mark a class for custom keybinds registration.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RegisterCustomKeybindsAttribute : Attribute;
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Globalization;
|
||||
using Rewired;
|
||||
using Rewired;
|
||||
|
||||
namespace MiraAPI.Keybinds;
|
||||
|
||||
@@ -20,6 +19,6 @@ public class VanillaKeybind : BaseKeybind
|
||||
public VanillaKeybind(int id)
|
||||
{
|
||||
RewiredInputAction = KeybindUtils.GetInputActionById(id);
|
||||
Id = RewiredInputAction != null ? RewiredInputAction.name : id.ToString(CultureInfo.InvariantCulture);
|
||||
Id = RewiredInputAction?.name;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
namespace MiraAPI.Keybinds;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton for getting a <see cref="VanillaKeybind"/> by <see cref="ActionButton"/>.
|
||||
/// Singleton for getting a vanilla keybind by <see cref="ActionButton"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"><see cref="AccountButton"/> type.</typeparam>
|
||||
/// <typeparam name="T">ActionButton type.</typeparam>
|
||||
public static class VanillaKeybinding<T> where T : ActionButton
|
||||
{
|
||||
private static VanillaKeybind? _instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="VanillaKeybind"/>.
|
||||
/// Gets the instance of the option group.
|
||||
/// </summary>
|
||||
#pragma warning disable CA1000
|
||||
public static VanillaKeybind Instance => _instance ??= KeybindManager.VanillaKeybinds[typeof(T)];
|
||||
|
||||
@@ -5,9 +5,9 @@ using MiraAPI.LocalSettings.SettingTypes;
|
||||
namespace MiraAPI.LocalSettings.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="LocalEnumSetting"/> for the <see cref="ConfigEntry{T}"/>.
|
||||
/// Creates an enum setting for the <see cref="ConfigEntry{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="names">Optional custom <see langword="enum"/> names.</param>
|
||||
/// <param name="names">Optional custom enum names.</param>
|
||||
/// <inheritdoc/>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class LocalEnumSettingAttribute(
|
||||
|
||||
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
|
||||
namespace MiraAPI.LocalSettings.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="LocalNumberSetting"/> for the <see cref="ConfigEntry{T}"/>.
|
||||
/// Creates a number setting for the <see cref="ConfigEntry{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="min">Minimum range.</param>
|
||||
/// <param name="max">Maximum range.</param>
|
||||
|
||||
@@ -15,10 +15,10 @@ public abstract class LocalSettingAttribute(
|
||||
) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the created <see cref="ILocalSetting"/> object.
|
||||
/// Returns the created setting object.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <returns>The created <see cref="ILocalSetting"/>.</returns>
|
||||
/// <returns>The created class.</returns>
|
||||
public abstract ILocalSetting CreateSetting(Type tab, ConfigEntryBase configEntryBase);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using MiraAPI.Utilities;
|
||||
namespace MiraAPI.LocalSettings.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="LocalSliderSetting"/> for the <see cref="ConfigEntry{T}"/>.
|
||||
/// Creates a slider setting for the <see cref="ConfigEntry{T}"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
/// <param name="min">Minimum range.</param>
|
||||
|
||||
@@ -5,7 +5,7 @@ using MiraAPI.LocalSettings.SettingTypes;
|
||||
namespace MiraAPI.LocalSettings.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="LocalToggleSetting"/> for the <see cref="ConfigEntry{T}"/>.
|
||||
/// Creates a toggle setting for the <see cref="ConfigEntry{T}"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface ILocalSetting
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the setting's <see cref="GameObject"/>.
|
||||
/// Gets the setting's gameobject.
|
||||
/// </summary>
|
||||
GameObject? Setting { get; }
|
||||
|
||||
@@ -31,12 +31,12 @@ public interface ILocalSetting
|
||||
/// <summary>
|
||||
/// Used to create the setting.
|
||||
/// </summary>
|
||||
/// <param name="toggle"><see cref="ToggleButtonBehaviour"/> template.</param>
|
||||
/// <param name="slider"><see cref="SlideBar"/> template.</param>
|
||||
/// <param name="parent">The parent <see cref="Transform"/> of the setting.</param>
|
||||
/// <param name="toggle">Toggle template.</param>
|
||||
/// <param name="slider">Slider template.</param>
|
||||
/// <param name="parent">The parent of the setting.</param>
|
||||
/// <param name="offset">The offset.</param>
|
||||
/// <param name="order">The order.</param>
|
||||
/// <param name="last">Whether it's the last on the row.</param>
|
||||
/// <returns>The created setting's <see cref="GameObject"/>.</returns>
|
||||
/// <returns>The created setting.</returns>
|
||||
GameObject? CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using Object = UnityEngine.Object;
|
||||
namespace MiraAPI.LocalSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a <see cref="LocalSettingsTab"/> button.
|
||||
/// Represents a local settings button.
|
||||
/// </summary>
|
||||
public class LocalSettingsButton(string text, Action onClick)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
public Action OnClick { get; set; } = onClick;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="LocalSettingsTab"/> instance this button belongs to.
|
||||
/// Gets the tab instance this button belongs to.
|
||||
/// </summary>
|
||||
public LocalSettingsTab? Tab { get; internal set; }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using Reactor.Utilities;
|
||||
namespace MiraAPI.LocalSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Manages <see cref="LocalSettingsTab"/>s.
|
||||
/// Manages local settings.
|
||||
/// </summary>
|
||||
public static class LocalSettingsManager
|
||||
{
|
||||
@@ -24,7 +24,7 @@ public static class LocalSettingsManager
|
||||
|
||||
if (TypeToTab.ContainsKey(type))
|
||||
{
|
||||
Error($"Local settings tab {type.Name} already exists.");
|
||||
Logger<MiraApiPlugin>.Error($"Local settings tab {type.Name} already exists.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
public abstract string TabName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tab's <see cref="LocalSettingTabAppearance"/>.
|
||||
/// Gets the tab appearance.
|
||||
/// </summary>
|
||||
public virtual LocalSettingTabAppearance TabAppearance { get; } = new();
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
protected virtual bool ShouldCreateLabels => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mod's <see cref="ConfigFile"/>. Automatically found in the plugin loader.
|
||||
/// Gets the mod's config file. Automatically found in the plugin loader.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="ILocalSetting"/>s.
|
||||
/// Gets the list of settings.
|
||||
/// </summary>
|
||||
public List<ILocalSetting> Settings { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="LocalSettingsButton"/>s.
|
||||
/// Gets the list of buttons.
|
||||
/// </summary>
|
||||
public List<LocalSettingsButton> Buttons { get; } = [];
|
||||
|
||||
|
||||
@@ -4,93 +4,93 @@ using UnityEngine;
|
||||
namespace MiraAPI.LocalSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Struct for modifying <see cref="LocalSettingsTab"/> appearance.
|
||||
/// Struct for modifying tab appearance.
|
||||
/// Defines how the settings look.
|
||||
/// </summary>
|
||||
public record struct LocalSettingTabAppearance()
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the main <see cref="Color"/> of the <see cref="LocalSettingsTab"/>.
|
||||
/// Gets or sets main color of the tab.
|
||||
/// </summary>
|
||||
public Color TabColor { get; set; } = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="LocalSettingsTab"/> button icon. No icon by default.
|
||||
/// Gets or sets tab button icon. No icon by default.
|
||||
/// </summary>
|
||||
public LoadableAsset<Sprite>? TabIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Color"/> of the <see cref="LocalSettingsTab"/> button.
|
||||
/// Gets or sets color of the tab button.
|
||||
/// </summary>
|
||||
public Color TabButtonColor { get; set; } = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the icon should be hidden when the <see cref="LocalSettingsTab"/> button is hovered.
|
||||
/// Gets or sets a value indicating whether the icon should be hidden when tab button is hovered.
|
||||
/// </summary>
|
||||
public bool HideIconOnHover { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hover <see cref="Color"/> of the <see cref="LocalSettingsTab"/> button.
|
||||
/// Gets or sets hover color of the tab button.
|
||||
/// </summary>
|
||||
public Color TabButtonHoverColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the active <see cref="Color"/> of the <see cref="LocalSettingsTab"/> button.
|
||||
/// Gets or sets active color of the tab button.
|
||||
/// </summary>
|
||||
public Color TabButtonActiveColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalToggleSetting"/>s.
|
||||
/// Gets or sets hover color of toggles.
|
||||
/// </summary>
|
||||
public Color ToggleHoverColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the active <see cref="Color"/> of <see cref="SettingTypes.LocalToggleSetting"/>s.
|
||||
/// Gets or sets active color of toggles.
|
||||
/// </summary>
|
||||
public Color ToggleActiveColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the inactive <see cref="Color"/> of <see cref="SettingTypes.LocalToggleSetting"/>s.
|
||||
/// Gets or sets inactive color of toggles.
|
||||
/// </summary>
|
||||
public Color ToggleInactiveColor { get; set; } = Color.red;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Color"/> of <see cref="SettingTypes.LocalNumberSetting"/> buttons.
|
||||
/// Gets or sets color of number buttons.
|
||||
/// </summary>
|
||||
public Color NumberColor { get; set; } = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalNumberSetting"/> buttons.
|
||||
/// Gets or sets hover color of number buttons.
|
||||
/// </summary>
|
||||
public Color NumberHoverColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Color"/> of <see cref="SettingTypes.LocalSliderSetting"/>s.
|
||||
/// Gets or sets color of sliders.
|
||||
/// </summary>
|
||||
public Color SliderColor { get; set; } = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalSliderSetting"/>s.
|
||||
/// Gets or sets hover color of sliders.
|
||||
/// </summary>
|
||||
public Color SliderHoverColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Color"/> of <see cref="SettingTypes.LocalEnumSetting"/> buttons.
|
||||
/// Gets or sets color of enum buttons.
|
||||
/// </summary>
|
||||
public Color EnumColor { get; set; } = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hover <see cref="Color"/> of <see cref="SettingTypes.LocalEnumSetting"/> buttons.
|
||||
/// Gets or sets hover color of enum buttons.
|
||||
/// </summary>
|
||||
public Color EnumHoverColor { get; set; } = Palette.AcceptedGreen;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Color"/> of buttons.
|
||||
/// Gets or sets color of buttons.
|
||||
/// </summary>
|
||||
public Color ButtonColor { get; set; } = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hover <see cref="Color"/> of buttons.
|
||||
/// Gets or sets hover color of buttons.
|
||||
/// </summary>
|
||||
public Color ButtonHoverColor { get; set; } = Palette.AcceptedGreen;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace MiraAPI.LocalSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton for <see cref="LocalSettingsTab"/>s.
|
||||
/// Singleton for local settings tabs.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The settings tab type.</typeparam>
|
||||
public static class LocalSettingsTabSingleton<T> where T : LocalSettingsTab
|
||||
@@ -11,7 +11,7 @@ public static class LocalSettingsTabSingleton<T> where T : LocalSettingsTab
|
||||
private static T? _instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <typeparamref name="T"/> setting tab.
|
||||
/// Gets the instance of the setting tab.
|
||||
/// </summary>
|
||||
#pragma warning disable CA1000
|
||||
public static T Instance => _instance ??= LocalSettingsManager.Tabs.OfType<T>().Single();
|
||||
|
||||
@@ -11,17 +11,17 @@ using Object = UnityEngine.Object;
|
||||
namespace MiraAPI.LocalSettings.SettingTypes;
|
||||
|
||||
/// <summary>
|
||||
/// Local setting class for <see langword="enum"/>s.
|
||||
/// Local setting class for enums.
|
||||
/// </summary>
|
||||
public class LocalEnumSetting : LocalSettingBase<int>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Enum"/> type of the setting.
|
||||
/// Gets the enum type of the setting.
|
||||
/// </summary>
|
||||
public Type EnumType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see langword="enum"/> values.
|
||||
/// Gets the enum values.
|
||||
/// </summary>
|
||||
public string[] Values { get; }
|
||||
|
||||
@@ -29,8 +29,8 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
/// Initializes a new instance of the <see cref="LocalEnumSetting"/> class.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
/// <param name="enumType">The <see cref="Enum"/> type.</param>
|
||||
/// <param name="values">The optional values array to replace the <see langword="enum"/> names.</param>
|
||||
/// <param name="enumType">The enum type.</param>
|
||||
/// <param name="values">The optional values array to replace the enum names.</param>
|
||||
public LocalEnumSetting(
|
||||
Type tab,
|
||||
ConfigEntryBase configEntry,
|
||||
|
||||
@@ -43,12 +43,6 @@ public abstract class LocalSettingBase<T> : ILocalSetting
|
||||
/// <summary>
|
||||
/// Creates an instance of the setting.
|
||||
/// </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>
|
||||
public abstract GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
|
||||
|
||||
@@ -62,9 +56,9 @@ public abstract class LocalSettingBase<T> : ILocalSetting
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the config entry, cast to <typeparamref name="T"/>.
|
||||
/// Gets the value of the config entry, cast to the setting type.
|
||||
/// </summary>
|
||||
/// <returns>The <typeparamref name="T"/> value.</returns>
|
||||
/// <returns>The value.</returns>
|
||||
public virtual T GetValue()
|
||||
{
|
||||
return (T)ConfigEntry.BoxedValue;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
global using static Reactor.Utilities.Logger<MiraAPI.MiraApiPlugin>;
|
||||
using System;
|
||||
using BepInEx;
|
||||
using BepInEx;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
@@ -22,11 +20,6 @@ namespace MiraAPI;
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
public partial class MiraApiPlugin : BasePlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current device is running Starlight (on mobile).
|
||||
/// </summary>
|
||||
public static bool IsMobile => Constants.GetPlatformType() is Platforms.Android or Platforms.IPhone;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the branding Mira API color.
|
||||
/// </summary>
|
||||
@@ -37,11 +30,6 @@ public partial class MiraApiPlugin : BasePlugin
|
||||
/// </summary>
|
||||
public static Color DefaultHeaderColor { get; } = new Color32(77, 77, 77, 255);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current build is a development build or not. This mostly avoids confusion for users asking why the mod appears red.
|
||||
/// </summary>
|
||||
public static bool IsDevBuild => Version.Contains("ci", StringComparison.OrdinalIgnoreCase) || Version.Contains("dev", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static MiraPluginManager? PluginManager { get; set; }
|
||||
internal Harmony Harmony { get; } = new(Id);
|
||||
|
||||
@@ -50,7 +38,7 @@ public partial class MiraApiPlugin : BasePlugin
|
||||
{
|
||||
Harmony.PatchAll();
|
||||
|
||||
ReactorCredits.Register("Mira API", Version, IsDevBuild, ReactorCredits.AlwaysShow);
|
||||
ReactorCredits.Register("Mira API", Version, true, ReactorCredits.AlwaysShow);
|
||||
|
||||
PluginManager = new MiraPluginManager();
|
||||
PluginManager.Initialize();
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.Patches;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI;
|
||||
|
||||
/// <summary>
|
||||
/// Mira API <see cref="ConfigFile"/> Handler.
|
||||
/// Mira API Config File Handler
|
||||
/// </summary>
|
||||
public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
@@ -24,78 +21,20 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
HideIconOnHover = false,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value stored for scaling buttons properly.
|
||||
/// </summary>
|
||||
public static float OldButtonScaleFactor { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Open()
|
||||
{
|
||||
base.Open();
|
||||
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnOptionChanged(ConfigEntryBase configEntry)
|
||||
{
|
||||
base.OnOptionChanged(configEntry);
|
||||
if (configEntry == ButtonUIFactorSlider)
|
||||
{
|
||||
if (HudManager.InstanceExists)
|
||||
{
|
||||
HudManagerPatches.ResizeUI(1f / OldButtonScaleFactor);
|
||||
HudManagerPatches.ResizeUI(ButtonUIFactorSlider.Value);
|
||||
}
|
||||
OldButtonScaleFactor = ButtonUIFactorSlider.Value;
|
||||
}
|
||||
else if (configEntry == SetFpsSlider)
|
||||
{
|
||||
Application.targetFrameRate = (int)SetFpsSlider.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Visuals/UI", "Show Modifiers HUD on Left Side", false);
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Displays", "Show Modifiers HUD on Left Side", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show keybinds on buttons.
|
||||
/// Gets whether to show keybinds in the control mapper.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Visuals/UI", "Show Keybinds on Buttons", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.5f, max: 1.5f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> ButtonUIFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Button Scale Factor", 0.75f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fps specified by the player.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 60f, max: 240f, suffixType: MiraNumberSuffixes.None, formatString: "0", displayValue: true, roundValue: true)]
|
||||
public ConfigEntry<float> SetFpsSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Max FPS", 120f);
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Keybinds", "Show Keybinds in Control Mapper", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to apply cosmetic changes to the TaskAdder.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> PrettyTaskAdder { get; private set; } = config.Bind("Freeplay", "Pretty Task Laptop", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show the red flash from sabotages.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageFlashes { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Flashes", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to enable the sabotage sound effects or not.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageBlares { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Blare", true);
|
||||
}
|
||||
@@ -17,8 +17,8 @@ public static class ModCompatibility
|
||||
/// <summary>
|
||||
/// Checks if the Submerged mod is loaded.
|
||||
/// </summary>
|
||||
/// <param name="submergedAssembly">Submerged mod assembly if loaded, <see langword="null"/> otherwise.</param>
|
||||
/// <returns><see langword="true"/> if the Submerged mod is loaded, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="submergedAssembly">Submerged mod assembly if loaded, null otherwise.</param>
|
||||
/// <returns>True if the Submerged mod is loaded, false otherwise.</returns>
|
||||
public static bool SubmergedLoaded([NotNullWhen(true)] out Assembly? submergedAssembly)
|
||||
{
|
||||
var result = IL2CPPChainloader.Instance.Plugins.TryGetValue(SubmergedId, out var plugin);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
namespace MiraAPI.Modifiers;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the assignment configuration for a <see cref="Types.GameModifier"/>.
|
||||
/// Represents the assignment configuration for a game modifier.
|
||||
/// </summary>
|
||||
/// <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 <see cref="Types.GameModifier"/> being assigned to a player.</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 <see cref="Types.GameModifier"/>.</param>
|
||||
/// <param name="DefaultAmount">The default amount of players that can have this modifier in a game.</param>
|
||||
/// <param name="DefaultChance">The default chance of the modifier being assigned to a player.</param>
|
||||
/// <param name="CreateAmountOption">Whether Mira should create an amount option for the modifier.</param>
|
||||
/// <param name="CreateChanceOption">Whether Mira should create a chance option for the modifier.</param>
|
||||
public record struct AssignmentConfiguration(int DefaultAmount, int DefaultChance, bool CreateAmountOption, bool CreateChanceOption);
|
||||
@@ -12,12 +12,12 @@ namespace MiraAPI.Modifiers;
|
||||
public abstract class BaseModifier : IOptionable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PlayerControl"/> that the modifier is attached to.
|
||||
/// Gets the player that the modifier is attached to.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; internal set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Modifiers.ModifierComponent"/> that the modifier is attached to.
|
||||
/// Gets the modifier component that the modifier is attached to.
|
||||
/// </summary>
|
||||
public ModifierComponent? ModifierComponent { get; internal set; }
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class BaseModifier : IOptionable
|
||||
public abstract string ModifierName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the modifier icon. Useless if <see cref="HideOnUi"/> is <see langword="true"/>.
|
||||
/// Gets the modifier icon. Useless if HideOnUi is true.
|
||||
/// </summary>
|
||||
public virtual LoadableAsset<Sprite>? ModifierIcon => null;
|
||||
|
||||
@@ -65,17 +65,17 @@ public abstract class BaseModifier : IOptionable
|
||||
public virtual bool ShowInFreeplay => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the <see cref="Color"/> that should be used for the modifier within freeplay.
|
||||
/// Gets a value indicating the color that should be used for the modifier within freeplay.
|
||||
/// </summary>
|
||||
public virtual Color FreeplayFileColor => Color.gray;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the modifier is unique. If <see langword="true"/>, the player can only have one instance of this modifier.
|
||||
/// Gets a value indicating whether the modifier is unique. If true, the player can only have one instance of this modifier.
|
||||
/// </summary>
|
||||
public virtual bool Unique => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HUD description for this modifier. Does nothing if <see cref="HideOnUi"/> is <see langword="true"/>. Required to be visible on UI.
|
||||
/// Gets the HUD description for this modifier. Does nothing if <see cref="HideOnUi"/> is true. Required to be visible on UI.
|
||||
/// </summary>
|
||||
/// <returns>The description string for the HUD.</returns>
|
||||
public virtual string GetDescription() => string.Empty;
|
||||
@@ -95,14 +95,14 @@ public abstract class BaseModifier : IOptionable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the modifier is updated. Attached to <see cref="ModifierComponent"/>'s <see cref="ModifierComponent.Update"/> method.
|
||||
/// Called when the modifier is updated. Attached to the ModifierComponent's Update method.
|
||||
/// </summary>
|
||||
public virtual void Update()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the modifier is updated. Attached to <see cref="ModifierComponent"/>'s <see cref="ModifierComponent.FixedUpdate"/> method.
|
||||
/// Called when the modifier is updated. Attached to the ModifierComponent's FixedUpdate method.
|
||||
/// </summary>
|
||||
public virtual void FixedUpdate()
|
||||
{
|
||||
@@ -126,6 +126,6 @@ public abstract class BaseModifier : IOptionable
|
||||
/// <summary>
|
||||
/// Determines whether the player can vent.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if the player can vent, <see langword="false"/> otherwise. <see langword="null"/> for no effect.</returns>
|
||||
/// <returns>True if the player can vent, false otherwise. Null for no effect.</returns>
|
||||
public virtual bool? CanVent() => null;
|
||||
}
|
||||
@@ -15,13 +15,13 @@ using UnityEngine;
|
||||
namespace MiraAPI.Modifiers;
|
||||
|
||||
/// <summary>
|
||||
/// The component for handling <see cref="BaseModifier"/>s.
|
||||
/// The component for handling modifiers.
|
||||
/// </summary>
|
||||
[RegisterInIl2Cpp]
|
||||
public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the active <see cref="BaseModifier"/>s on the player.
|
||||
/// Gets the active modifiers on the player.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public ImmutableList<BaseModifier> ActiveModifiers { get; private set; } = ImmutableList<BaseModifier>.Empty;
|
||||
@@ -47,7 +47,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
_player = GetComponent<PlayerControl>();
|
||||
if (_player == null)
|
||||
{
|
||||
Error("ModifierComponent could not find PlayerControl on the same GameObject.");
|
||||
Logger<MiraApiPlugin>.Error("ModifierComponent could not find PlayerControl on the same GameObject.");
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while deactivating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Logger<MiraApiPlugin>.Error($"Error while deactivating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
}
|
||||
|
||||
Modifiers.Remove(modifier);
|
||||
@@ -95,7 +95,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while activating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Logger<MiraApiPlugin>.Error($"Error while activating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
}
|
||||
|
||||
if (modifier is TimedModifier { AutoStart: true } timer)
|
||||
@@ -122,7 +122,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Logger<MiraApiPlugin>.Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while updating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Logger<MiraApiPlugin>.Error($"Error while updating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,11 +165,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <typeparamref name="T"/>.
|
||||
/// Gets a collection of modifiers by type.
|
||||
/// </summary>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/> by.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>e.</typeparam>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <typeparamref name="T"/>s.</returns>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
/// <returns>A collection of modifiers.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public IEnumerable<T> GetModifiers<T>(Func<T, bool>? predicate=null) where T : BaseModifier
|
||||
{
|
||||
@@ -177,11 +177,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="BaseModifier"/>s by type.
|
||||
/// Gets a collection of modifiers by type.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="BaseModifier"/>s.</returns>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>A collection of modifiers.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public IEnumerable<BaseModifier> GetModifiers(Type type, Func<BaseModifier, bool>? predicate=null)
|
||||
{
|
||||
@@ -189,11 +189,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="BaseModifier"/>s by type ID.
|
||||
/// Gets a collection of modifiers by type ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/>'s type ID.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="BaseModifier"/>s.</returns>
|
||||
/// <param name="id">The modifier's type ID.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>A collection of modifiers.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public IEnumerable<BaseModifier> GetModifiers(uint id, Func<BaseModifier, bool>? predicate=null)
|
||||
{
|
||||
@@ -204,12 +204,12 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <typeparamref name="T"/>.
|
||||
/// Tries to get a modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="modifier">The <typeparamref name="T"/> or <see langword="null"/>.</param>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/> by.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <returns><see langword="true"/> if the <typeparamref name="T"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool TryGetModifier<T>([NotNullWhen(true)] out T? modifier, Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
@@ -218,12 +218,12 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <see cref="BaseModifier"/> by its type.
|
||||
/// Tries to get a modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> or <see langword="null"/>.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool TryGetModifier(Type type, [NotNullWhen(true)] out BaseModifier? modifier, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
@@ -232,12 +232,12 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <see cref="BaseModifier"/> by its type ID.
|
||||
/// Tries to get a modifier by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/>'s type ID.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> or <see langword="null"/>.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="id">The modifier type ID.</param>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool TryGetModifier(uint id, [NotNullWhen(true)] out BaseModifier? modifier, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
@@ -246,11 +246,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <see cref="BaseModifier"/> by its unique ID.
|
||||
/// Tries to get a modifier by its unique ID.
|
||||
/// </summary>
|
||||
/// <param name="modifierGuid">The <see cref="BaseModifier"/>'s unique ID.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> or <see langword="null"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="modifierGuid">The modifier unique ID.</param>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool TryGetModifier(Guid modifierGuid, [NotNullWhen(true)] out BaseModifier? modifier)
|
||||
{
|
||||
@@ -259,11 +259,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <typeparamref name="T"/>.
|
||||
/// Gets a modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/> by.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <returns>The <typeparamref name="T"/> if it is found, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
/// <returns>The Modifier if it is found, null otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public T? GetModifier<T>(Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
@@ -271,11 +271,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="BaseModifier"/> by its type.
|
||||
/// Gets a modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if it is found, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>The Modifier if it is found, null otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? GetModifier(Type type, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
@@ -283,11 +283,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="BaseModifier"/> by its type ID.
|
||||
/// Gets a modifier by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/> ID.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if it is found, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="id">The modifier ID.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>The Modifier if it is found, null otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? GetModifier(uint id, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
@@ -298,10 +298,10 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="BaseModifier"/> by unique ID.
|
||||
/// Gets a modifier by unique ID.
|
||||
/// </summary>
|
||||
/// <param name="modifierGuid">The <see cref="BaseModifier"/>'s unique ID.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if it is found, or <see langword="null"/>.</returns>
|
||||
/// <param name="modifierGuid">The modifier's unique ID.</param>
|
||||
/// <returns>The modifier if it is found, or null.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? GetModifier(Guid modifierGuid)
|
||||
{
|
||||
@@ -309,10 +309,10 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a <typeparamref name="T"/> from the player.
|
||||
/// Removes a modifier from the player.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="BaseModifier"/> type.</typeparam>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/> by.</param>
|
||||
/// <typeparam name="T">The modifier type.</typeparam>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void RemoveModifier<T>(Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
@@ -320,10 +320,10 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a <see cref="BaseModifier"/> from the player.
|
||||
/// Removes a modifier from the player.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void RemoveModifier(Type type, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
@@ -336,7 +336,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
var modifier = modifiers.FirstOrDefault();
|
||||
if (modifier is null)
|
||||
{
|
||||
Error($"Cannot remove modifier {type.Name} because it is not active.");
|
||||
Logger<MiraApiPlugin>.Error($"Cannot remove modifier {type.Name} because it is not active.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -344,15 +344,15 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a <see cref="BaseModifier"/> from the player.
|
||||
/// Removes a modifier from the player.
|
||||
/// </summary>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> object.</param>
|
||||
/// <param name="modifier">The modifier object.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void RemoveModifier(BaseModifier modifier)
|
||||
{
|
||||
if (!ActiveModifiers.Contains(modifier))
|
||||
{
|
||||
Error($"Cannot remove modifier {modifier.ModifierName} because it is not active on this player.");
|
||||
Logger<MiraApiPlugin>.Error($"Cannot remove modifier {modifier.ModifierName} because it is not active on this player.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,10 +360,10 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a <see cref="BaseModifier"/> from the player.
|
||||
/// Removes a modifier from the player.
|
||||
/// </summary>
|
||||
/// <param name="typeId">The <see cref="BaseModifier"/>'s type ID.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <param name="typeId">The modifier's type ID.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void RemoveModifier(uint typeId, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
@@ -373,16 +373,16 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a <see cref="BaseModifier"/> from the player.
|
||||
/// Removes a modifier from the player.
|
||||
/// </summary>
|
||||
/// <param name="uniqueId">The <see cref="BaseModifier"/>'s unique ID.</param>
|
||||
/// <param name="uniqueId">The modifier's unique ID.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void RemoveModifier(Guid uniqueId)
|
||||
{
|
||||
var modifier = GetModifier(uniqueId);
|
||||
if (modifier == null)
|
||||
{
|
||||
Error($"Cannot remove modifier with unique id {uniqueId} because it is not active.");
|
||||
Logger<MiraApiPlugin>.Error($"Cannot remove modifier with unique id {uniqueId} because it is not active.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -390,11 +390,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <typeparamref name="T"/> to the player.
|
||||
/// Adds a modifier to the player.
|
||||
/// </summary>
|
||||
/// <param name="args">The arguments to initialize the <typeparamref name="T"/> with.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <returns>The new <typeparamref name="T"/>.</returns>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <typeparam name="T">The Type of the modifier.</typeparam>
|
||||
/// <returns>The new modifier.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public T? AddModifier<T>(params object[] args) where T : BaseModifier
|
||||
{
|
||||
@@ -402,29 +402,29 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="BaseModifier"/> to the player.
|
||||
/// Adds a modifier to the player.
|
||||
/// </summary>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> to add.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> that was added.</returns>
|
||||
/// <param name="modifier">The modifier to add.</param>
|
||||
/// <returns>The modifier that was added.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? AddModifier(BaseModifier modifier)
|
||||
{
|
||||
// TODO: Make a proper synchronization system.
|
||||
if (LobbyBehaviour.Instance)
|
||||
{
|
||||
Warning($"Modifiers added in the lobby won't sync to new players!");
|
||||
Logger<MiraApiPlugin>.Warning($"Modifiers added in the lobby won't sync to new players!");
|
||||
}
|
||||
|
||||
var id = modifier.TypeId;
|
||||
if (modifier.Unique && ActiveModifiers.Find(x => x.TypeId == id) != null)
|
||||
{
|
||||
Error($"Player already has modifier with id {id}!");
|
||||
Logger<MiraApiPlugin>.Error($"Player already has modifier with id {id}!");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ActiveModifiers.Contains(modifier))
|
||||
{
|
||||
Error($"Player already has this modifier!");
|
||||
Logger<MiraApiPlugin>.Error($"Player already has this modifier!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -439,11 +439,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="BaseModifier"/> to the player.
|
||||
/// Adds a modifier to the player.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="args">The arguments to initialize the <see cref="BaseModifier"/> with.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> that was added.</returns>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <returns>The modifier that was added.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? AddModifier(Type type, params object[] args)
|
||||
{
|
||||
@@ -465,11 +465,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="BaseModifier"/> to the player.
|
||||
/// Adds a modifier to the player.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="args">The arguments to initialize the <see cref="BaseModifier"/> with.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if it was created, or <see langword="null"/> if it failed.</returns>
|
||||
/// <param name="id">The ID of the modifier.</param>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <returns>The modifier if it was created, or null if it failed.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? AddModifier(uint id, params object[] args)
|
||||
{
|
||||
@@ -480,11 +480,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <typeparamref name="T"/>.
|
||||
/// Checks if a player has an active modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/>.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <returns><see langword="true"/> if the <typeparamref name="T"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="predicate">The predicate to check the modifier.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
/// <returns>True if the Modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier<T>(Func<T, bool>? predicate=null) where T : BaseModifier
|
||||
{
|
||||
@@ -492,11 +492,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <see cref="BaseModifier"/> by its type.
|
||||
/// Checks if a player has an active modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="predicate">The predicate to check the modifier.</param>
|
||||
/// <returns>True if the Modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier(Type type, Func<BaseModifier, bool>? predicate=null)
|
||||
{
|
||||
@@ -504,11 +504,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <see cref="BaseModifier"/> by its type ID.
|
||||
/// Checks if a player has an active modifier by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/>'s type ID.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="id">The modifier's type ID.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier.</param>
|
||||
/// <returns>True if the modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier(uint id, Func<BaseModifier, bool>? predicate=null)
|
||||
{
|
||||
@@ -519,10 +519,10 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <see cref="BaseModifier"/> by its unique ID.
|
||||
/// Checks if a player has an active modifier by its unique ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/>'s guid.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="id">The modifier's guid.</param>
|
||||
/// <returns>True if the modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier(Guid id)
|
||||
{
|
||||
@@ -530,12 +530,12 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <typeparamref name="T"/>.
|
||||
/// Checks if a player has an active modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="checkInactive">Whether to check inactive <typeparamref name="T"/>s (those pending to be added).</param>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/>.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <returns><see langword="true"/> if the <typeparamref name="T"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="checkInactive">Whether to check inactive modifiers (those pending to be added).</param>
|
||||
/// <param name="predicate">The predicate to check the modifier.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
/// <returns>True if the Modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier<T>(bool checkInactive, Func<T, bool>? predicate=null) where T : BaseModifier
|
||||
{
|
||||
@@ -544,12 +544,12 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <see cref="BaseModifier"/> by its type.
|
||||
/// Checks if a player has an active modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="checkInactive">Whether to check inactive <see cref="BaseModifier"/>s (those pending to be added).</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="checkInactive">Whether to check inactive modifiers (those pending to be added).</param>
|
||||
/// <param name="predicate">The predicate to check the modifier.</param>
|
||||
/// <returns>True if the Modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier(Type type, bool checkInactive, Func<BaseModifier, bool>? predicate=null)
|
||||
{
|
||||
@@ -558,12 +558,12 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <see cref="BaseModifier"/> by its type ID.
|
||||
/// Checks if a player has an active modifier by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/>'s type ID.</param>
|
||||
/// <param name="checkInactive">Whether to check inactive <see cref="BaseModifier"/>s (those pending to be added).</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="id">The modifier's type ID.</param>
|
||||
/// <param name="checkInactive">Whether to check inactive modifiers (those pending to be added).</param>
|
||||
/// <param name="predicate">The predicate to check the modifier.</param>
|
||||
/// <returns>True if the modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier(uint id, bool checkInactive, Func<BaseModifier, bool>? predicate=null)
|
||||
{
|
||||
@@ -574,11 +574,11 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player has an active <see cref="BaseModifier"/> by its unique ID.
|
||||
/// Checks if a player has an active modifier by its unique ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="BaseModifier"/>'s guid.</param>
|
||||
/// <param name="checkInactive">Whether to check inactive <see cref="BaseModifier"/>s (those pending to be added).</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> is present, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="id">The modifier's guid.</param>
|
||||
/// <param name="checkInactive">Whether to check inactive modifiers (those pending to be added).</param>
|
||||
/// <returns>True if the modifier is present, false otherwise.</returns>
|
||||
[HideFromIl2Cpp]
|
||||
public bool HasModifier(Guid id, bool checkInactive)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -16,13 +15,13 @@ using UnityEngine.UI;
|
||||
namespace MiraAPI.Modifiers.ModifierDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// The code used to display <see cref="BaseModifier"/>s.
|
||||
/// The code used to display Mira modifiers.
|
||||
/// </summary>
|
||||
[RegisterInIl2Cpp]
|
||||
public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of the <see cref="ModifierDisplayComponent"/>.
|
||||
/// Gets the instance of the Modifier Display.
|
||||
/// </summary>
|
||||
public static ModifierDisplayComponent? Instance { get; private set; }
|
||||
|
||||
@@ -42,7 +41,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
private readonly Dictionary<BaseModifier, ModifierUiComponent> _modifiers = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlyDictionary{TKey, TValue}"/> of the created <see cref="ModifierUiComponent"/>s.
|
||||
/// Gets a read only dictionary of the created modifier UI components.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public ReadOnlyDictionary<BaseModifier, ModifierUiComponent> Modifiers => new(_modifiers);
|
||||
@@ -109,7 +108,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to refresh the modifiers UI. Useful if you hide modifiers UIs based on options.
|
||||
/// Use this to refresh the modifiers UI. Useful if you hide modifiers uis based on options.
|
||||
/// </summary>
|
||||
public void RefreshModifiers()
|
||||
{
|
||||
@@ -138,7 +137,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
internal void DestroyComponent(ModifierUiComponent component)
|
||||
{
|
||||
_modifiers.Remove(component.Modifier!);
|
||||
component.gameObject.DeepDestroy();
|
||||
component.gameObject.DestroyImmediate();
|
||||
RefreshModifiers();
|
||||
}
|
||||
|
||||
@@ -208,7 +207,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
continue;
|
||||
}
|
||||
|
||||
mod.Value.gameObject.DeepDestroy();
|
||||
mod.Value.gameObject.Destroy();
|
||||
_modifiers.Remove(mod.Key);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ using UnityEngine;
|
||||
namespace MiraAPI.Modifiers.ModifierDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// The code placed on every <see cref="BaseModifier"/> HUD object. Used to handle updating.
|
||||
/// The code placed on every Modifier HUD object. Used to handle updating.
|
||||
/// </summary>
|
||||
[RegisterInIl2Cpp]
|
||||
public class ModifierUiComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="BaseModifier"/> which this component is for.
|
||||
/// Gets the modifier which this component is for.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public BaseModifier? Modifier { get; internal set; }
|
||||
|
||||
@@ -10,21 +10,21 @@ using Reactor.Utilities;
|
||||
namespace MiraAPI.Modifiers;
|
||||
|
||||
/// <summary>
|
||||
/// Extensions for <see cref="BaseModifier"/>s.
|
||||
/// Extensions for modifiers.
|
||||
/// </summary>
|
||||
public static class ModifierExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Dictionary{TKey, TValue}"/> to cache <see cref="ModifierComponent"/>s.
|
||||
/// Gets the dictionary to cache ModifierComponents.
|
||||
/// </summary>
|
||||
public static Dictionary<PlayerControl, ModifierComponent> ModifierComponents { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to add a <see cref="BaseModifier"/> to a <see cref="PlayerControl"/>.
|
||||
/// Remote Procedure Call to add a modifier to a player.
|
||||
/// </summary>
|
||||
/// <param name="target">The <see cref="PlayerControl"/> to add the <see cref="BaseModifier"/> to.</param>
|
||||
/// <param name="typeId">The <see cref="BaseModifier"/> type ID.</param>
|
||||
/// <param name="args">The arguments to initialize the <see cref="BaseModifier"/> with.</param>
|
||||
/// <param name="target">The player to add the modifier to.</param>
|
||||
/// <param name="typeId">The modifier type ID.</param>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
public static void RpcAddModifier(this PlayerControl target, uint typeId, params object[] args)
|
||||
{
|
||||
_ = ModifierManager.GetModifierType(typeId) ?? throw new InvalidOperationException(
|
||||
@@ -34,11 +34,11 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to add a <see cref="BaseModifier"/> to a <see cref="PlayerControl"/>.
|
||||
/// Remote Procedure Call to add a modifier to a player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> to add the <see cref="BaseModifier"/> to.</param>
|
||||
/// <param name="type">The type of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="args">The arguments to initialize the <see cref="BaseModifier"/> with.</param>
|
||||
/// <param name="player">The player to add the modifier to.</param>
|
||||
/// <param name="type">The type of the modifier.</param>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
public static void RpcAddModifier(this PlayerControl player, Type type, params object[] args)
|
||||
{
|
||||
var id = ModifierManager.GetModifierTypeId(type) ?? throw new InvalidOperationException(
|
||||
@@ -48,21 +48,21 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to add a <typeparamref name="T"/> to a <see cref="PlayerControl"/>.
|
||||
/// Remote Procedure Call to add a modifier to a player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> to add the <typeparamref name="T"/> to.</param>
|
||||
/// <param name="args">The arguments to initialize the <typeparamref name="T"/> with.</param>
|
||||
/// <typeparam name="T">The <see cref="BaseModifier"/> Type.</typeparam>
|
||||
/// <param name="player">The player to add the modifier to.</param>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <typeparam name="T">The modifier Type.</typeparam>
|
||||
public static void RpcAddModifier<T>(this PlayerControl player, params object[] args) where T : BaseModifier
|
||||
{
|
||||
player.RpcAddModifier(typeof(T), args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to remove a <see cref="BaseModifier"/> from a <see cref="PlayerControl"/>.
|
||||
/// Remote Procedure Call to remove a modifier from a player.
|
||||
/// </summary>
|
||||
/// <param name="target">The <see cref="PlayerControl"/> to remove the <see cref="BaseModifier"/> from.</param>
|
||||
/// <param name="uniqueId">The unique ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="target">The player to remove the modifier from.</param>
|
||||
/// <param name="uniqueId">The unique ID of the modifier.</param>
|
||||
[MethodRpc((uint)MiraRpc.RemoveModifier)]
|
||||
public static void RpcRemoveModifier(this PlayerControl target, Guid uniqueId)
|
||||
{
|
||||
@@ -70,11 +70,11 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to remove a <see cref="BaseModifier"/> from a <see cref="PlayerControl"/> by type ID.
|
||||
/// Remote Procedure Call to remove a modifier from a player by type ID.
|
||||
/// </summary>
|
||||
/// <param name="target">The <see cref="PlayerControl"/> to remove the <see cref="BaseModifier"/> from.</param>
|
||||
/// <param name="typeId">The type ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <param name="target">The player to remove the modifier from.</param>
|
||||
/// <param name="typeId">The type ID of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
public static void RpcRemoveModifier(
|
||||
this PlayerControl target,
|
||||
uint typeId,
|
||||
@@ -83,7 +83,7 @@ public static class ModifierExtensions
|
||||
var modifier = target.GetModifier(typeId, predicate);
|
||||
if (modifier is null)
|
||||
{
|
||||
Error($"Player {target.PlayerId} does not have modifier with type ID {typeId}.");
|
||||
Logger<MiraApiPlugin>.Error($"Player {target.PlayerId} does not have modifier with type ID {typeId}.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to remove a <see cref="BaseModifier"/> from a <see cref="PlayerControl"/>.
|
||||
/// Remote Procedure Call to remove a modifier from a player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> to remove the <see cref="BaseModifier"/> from.</param>
|
||||
/// <param name="type">The type of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <param name="player">The player to remove the modifier from.</param>
|
||||
/// <param name="type">The type of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
public static void RpcRemoveModifier(
|
||||
this PlayerControl player,
|
||||
Type type,
|
||||
@@ -108,11 +108,11 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remote Procedure Call to remove a <typeparamref name="T"/> from a <see cref="PlayerControl"/>.
|
||||
/// Remote Procedure Call to remove a modifier from a player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> to remove the <typeparamref name="T"/> from.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <typeparamref name="T"/>s.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <param name="player">The player to remove the modifier from.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
public static void RpcRemoveModifier<T>(this PlayerControl player, Func<BaseModifier, bool>? predicate = null)
|
||||
where T : BaseModifier
|
||||
{
|
||||
@@ -120,10 +120,10 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ModifierComponent"/> for a <see cref="PlayerControl"/>.
|
||||
/// Gets the ModifierComponent for a player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> object.</param>
|
||||
/// <returns>A <see cref="ModifierComponent"/> if there is one, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl object.</param>
|
||||
/// <returns>A ModifierComponent if there is one, null otherwise.</returns>
|
||||
public static ModifierComponent GetModifierComponent(this PlayerControl player)
|
||||
{
|
||||
if (ModifierComponents.TryGetValue(player, out var component))
|
||||
@@ -142,36 +142,36 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PlayerControl"/> has a specific <typeparamref name="T"/>.
|
||||
/// Checks if the player has a specific modifier.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="PlayerControl"/> has the <typeparamref name="T"/>, <see langword="false"/> otherwise.</returns>
|
||||
/// <typeparam name="T">The type of the modifier.</typeparam>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>True if the player has the modifier, false otherwise.</returns>
|
||||
public static bool HasModifier<T>(this PlayerControl player, Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
return player.GetModifierComponent().HasModifier(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PlayerControl"/> has a specific <see cref="BaseModifier"/> by type.
|
||||
/// Checks if the player has a specific modifier by type.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="type">The type of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="PlayerControl"/> has the <see cref="BaseModifier"/>, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>True if the player has the modifier, false otherwise.</returns>
|
||||
public static bool HasModifier(this PlayerControl player, Type type, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
return player.GetModifierComponent().HasModifier(type, predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PlayerControl"/> has a specific <see cref="BaseModifier"/> by type ID.
|
||||
/// Checks if the player has a specific modifier by type ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="typeId">The type ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="PlayerControl"/> has the <see cref="BaseModifier"/>, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="typeId">The type ID of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>True if the player has the modifier, false otherwise.</returns>
|
||||
public static bool HasModifier(
|
||||
this PlayerControl player,
|
||||
uint typeId,
|
||||
@@ -181,20 +181,20 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PlayerControl"/> has a specific modifier by its GUID.
|
||||
/// Checks if the player has a specific modifier by its GUID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="uniqueId">The unique ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="PlayerControl"/> has the <see cref="BaseModifier"/>, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="uniqueId">The unique ID of the modifier.</param>
|
||||
/// <returns>True if the player has the modifier, false otherwise.</returns>
|
||||
public static bool HasModifier(this PlayerControl player, Guid uniqueId)
|
||||
{
|
||||
return player.GetModifierComponent().HasModifier(uniqueId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all <see cref="BaseModifier"/>s from the <see cref="PlayerControl"/>.
|
||||
/// Clears all modifiers from a player.
|
||||
/// </summary>
|
||||
/// <param name="plr">The player you want to clear <see cref="BaseModifier"/>s for.</param>
|
||||
/// <param name="plr">The player you want to clear modifiers for.</param>
|
||||
public static void ClearModifiers(this PlayerControl plr)
|
||||
{
|
||||
foreach (var mod in plr.GetModifierComponent().ActiveModifiers)
|
||||
@@ -204,9 +204,9 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all <see cref="BaseModifier"/>s from the <see cref="PlayerControl"/>.
|
||||
/// Clears all modifiers from a player.
|
||||
/// </summary>
|
||||
/// <param name="plr">The player you want to clear <see cref="BaseModifier"/>s for.</param>
|
||||
/// <param name="plr">The player you want to clear modifiers for.</param>
|
||||
public static void RpcClearModifiers(this PlayerControl plr)
|
||||
{
|
||||
foreach (var mod in plr.GetModifierComponent().ActiveModifiers)
|
||||
@@ -216,75 +216,75 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <typeparamref name="T"/>.
|
||||
/// Tries to get a modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="modifier">The <typeparamref name="T"/> or <see langword="null"/>.</param>
|
||||
/// <param name="predicate">The predicate to check the <typeparamref name="T"/> by.</param>
|
||||
/// <typeparam name="T">The Type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <returns><see langword="true"/> if the <typeparamref name="T"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <typeparam name="T">The Type of the Modifier.</typeparam>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
public static bool TryGetModifier<T>(this PlayerControl player, [NotNullWhen(true)] out T? modifier, Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
return player.GetModifierComponent().TryGetModifier(out modifier, predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <see cref="BaseModifier"/> by its type.
|
||||
/// Tries to get a modifier by its type.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="type">The modifier type.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> or <see langword="null"/>.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
public static bool TryGetModifier(this PlayerControl player, Type type, [NotNullWhen(true)] out BaseModifier? modifier, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
return player.GetModifierComponent().TryGetModifier(type, out modifier, predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <see cref="BaseModifier"/> by its type ID.
|
||||
/// Tries to get a modifier by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="id">The <see cref="BaseModifier"/> type ID.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> or <see langword="null"/>.</param>
|
||||
/// <param name="predicate">The predicate to check the <see cref="BaseModifier"/> by.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="id">The modifier type ID.</param>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <param name="predicate">The predicate to check the modifier by.</param>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
public static bool TryGetModifier(this PlayerControl player, uint id, [NotNullWhen(true)] out BaseModifier? modifier, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
return player.GetModifierComponent().TryGetModifier(id, out modifier, predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a <see cref="BaseModifier"/> by its unique ID.
|
||||
/// Tries to get a modifier by its unique ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="modifierGuid">The <see cref="BaseModifier"/> unique ID.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> or <see langword="null"/>.</param>
|
||||
/// <returns><see langword="true"/> if the <see cref="BaseModifier"/> was found, <see langword="false"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="modifierGuid">The modifier unique ID.</param>
|
||||
/// <param name="modifier">The modifier or null.</param>
|
||||
/// <returns>True if the modifier was found, false otherwise.</returns>
|
||||
public static bool TryGetModifier(this PlayerControl player, Guid modifierGuid, [NotNullWhen(true)] out BaseModifier? modifier)
|
||||
{
|
||||
return player.GetModifierComponent().TryGetModifier(modifierGuid, out modifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific <typeparamref name="T"/> from the <see cref="PlayerControl"/>.
|
||||
/// Gets a specific modifier from the player.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <typeparamref name="T"/>s.</param>
|
||||
/// <returns>The <typeparamref name="T"/> if found, <see langword="null"/> otherwise.</returns>
|
||||
/// <typeparam name="T">The type of the modifier.</typeparam>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>The modifier if found, null otherwise.</returns>
|
||||
public static T? GetModifier<T>(this PlayerControl player, Func<T, bool>? predicate = null) where T : BaseModifier
|
||||
{
|
||||
return player.GetModifierComponent().GetModifier(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/> by type.
|
||||
/// Gets a specific modifier from the player by type.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="type">The type of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if found, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>The modifier if found, null otherwise.</returns>
|
||||
public static BaseModifier? GetModifier(
|
||||
this PlayerControl player,
|
||||
Type type,
|
||||
@@ -294,12 +294,12 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/> by its type ID.
|
||||
/// Gets a specific modifier from the player by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="typeId">The type ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if found, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="typeId">The type ID of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>The modifier if found, null otherwise.</returns>
|
||||
public static BaseModifier? GetModifier(
|
||||
this PlayerControl player,
|
||||
uint typeId,
|
||||
@@ -309,11 +309,11 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/> by its GUID.
|
||||
/// Gets a specific modifier from the player by its GUID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="uniqueId">The GUID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <returns>The <see cref="BaseModifier"/> if found, <see langword="null"/> otherwise.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="uniqueId">The GUID of the modifier.</param>
|
||||
/// <returns>The modifier if found, null otherwise.</returns>
|
||||
public static BaseModifier? GetModifier(
|
||||
this PlayerControl player,
|
||||
Guid uniqueId)
|
||||
@@ -322,12 +322,12 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all <typeparamref name="T"/>s from the <see cref="PlayerControl"/>.
|
||||
/// Gets all modifiers of a specific type from the player.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <typeparamref name="T"/>s.</typeparam>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <typeparamref name="T"/>s.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <typeparamref name="T"/>s.</returns>
|
||||
/// <typeparam name="T">The type of the modifiers.</typeparam>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>A collection of modifiers.</returns>
|
||||
public static IEnumerable<T> GetModifiers<T>(this PlayerControl player, Func<T, bool>? predicate = null)
|
||||
where T : BaseModifier
|
||||
{
|
||||
@@ -335,12 +335,12 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all <see cref="BaseModifier"/>s of a specific type from the <see cref="PlayerControl"/>.
|
||||
/// Gets all modifiers of a specific type from the player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="type">The type of the modifiers.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="BaseModifier"/>s.</returns>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>A collection of modifiers.</returns>
|
||||
public static IEnumerable<BaseModifier> GetModifiers(
|
||||
this PlayerControl player,
|
||||
Type type,
|
||||
@@ -350,12 +350,12 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all <see cref="BaseModifier"/>s of a specific type from the <see cref="PlayerControl"/> by type ID.
|
||||
/// Gets all modifiers of a specific type from the player by type ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="typeId">The type ID of the <see cref="BaseModifier"/>s.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="BaseModifier"/>s.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="typeId">The type ID of the modifiers.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
/// <returns>A collection of modifiers.</returns>
|
||||
public static IEnumerable<BaseModifier> GetModifiers(
|
||||
this PlayerControl player,
|
||||
uint typeId,
|
||||
@@ -365,21 +365,21 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/>.
|
||||
/// Removes a specific modifier from the player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> to remove.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="modifier">The modifier to remove.</param>
|
||||
public static void RemoveModifier(this PlayerControl player, BaseModifier modifier)
|
||||
{
|
||||
player.GetModifierComponent().RemoveModifier(modifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <typeparamref name="T"/> from the <see cref="PlayerControl"/>.
|
||||
/// Removes a specific modifier from the player.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <typeparam name="T">The type of the modifier.</typeparam>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
public static void RemoveModifier<T>(this PlayerControl player, Func<T, bool>? predicate = null)
|
||||
where T : BaseModifier
|
||||
{
|
||||
@@ -387,22 +387,22 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/> by type.
|
||||
/// Removes a specific modifier from the player by type.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="type">The type of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
public static void RemoveModifier(this PlayerControl player, Type type, Func<BaseModifier, bool>? predicate = null)
|
||||
{
|
||||
player.GetModifierComponent().RemoveModifier(type, predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/> by its type ID.
|
||||
/// Removes a specific modifier from the player by its type ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="typeId">The type ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the <see cref="BaseModifier"/>s.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="typeId">The type ID of the modifier.</param>
|
||||
/// <param name="predicate">Optional predicate to filter the modifiers.</param>
|
||||
public static void RemoveModifier(
|
||||
this PlayerControl player,
|
||||
uint typeId,
|
||||
@@ -412,10 +412,10 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref="BaseModifier"/> from the <see cref="PlayerControl"/> by its GUID.
|
||||
/// Removes a specific modifier from the player by its GUID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="uniqueId">The GUID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="uniqueId">The GUID of the modifier.</param>
|
||||
public static void RemoveModifier(
|
||||
this PlayerControl player,
|
||||
Guid uniqueId)
|
||||
@@ -424,47 +424,47 @@ public static class ModifierExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a specific <typeparamref name="T"/> to the <see cref="PlayerControl"/>.
|
||||
/// Adds a specific modifier to the player.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the <see cref="BaseModifier"/>.</typeparam>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="args">The arguments to initialize the <typeparamref name="T"/> with.</param>
|
||||
/// <returns>The added <typeparamref name="T"/>.</returns>
|
||||
/// <typeparam name="T">The type of the modifier.</typeparam>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <returns>The added modifier.</returns>
|
||||
public static T? AddModifier<T>(this PlayerControl player, params object[] args) where T : BaseModifier
|
||||
{
|
||||
return player.GetModifierComponent().AddModifier<T>(args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a specific <see cref="BaseModifier"/> to the <see cref="PlayerControl"/>.
|
||||
/// Adds a specific modifier to the player.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="modifier">The <see cref="BaseModifier"/> to add.</param>
|
||||
/// <returns>The added <see cref="BaseModifier"/>.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="modifier">The modifier to add.</param>
|
||||
/// <returns>The added modifier.</returns>
|
||||
public static BaseModifier? AddModifier(this PlayerControl player, BaseModifier modifier)
|
||||
{
|
||||
return player.GetModifierComponent().AddModifier(modifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a specific <see cref="BaseModifier"/> to the <see cref="PlayerControl"/> by type.
|
||||
/// Adds a specific modifier to the player by type.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="type">The type of the modifier.</param>
|
||||
/// <param name="args">The arguments to initialize the <see cref="BaseModifier"/> with.</param>
|
||||
/// <returns>The added <see cref="BaseModifier"/>.</returns>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <returns>The added modifier.</returns>
|
||||
public static BaseModifier? AddModifier(this PlayerControl player, Type type, params object[] args)
|
||||
{
|
||||
return player.GetModifierComponent().AddModifier(type, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a specific <see cref="BaseModifier"/> to the <see cref="PlayerControl"/> by type ID.
|
||||
/// Adds a specific modifier to the player by type ID.
|
||||
/// </summary>
|
||||
/// <param name="player">The <see cref="PlayerControl"/> instance.</param>
|
||||
/// <param name="typeId">The type ID of the <see cref="BaseModifier"/>.</param>
|
||||
/// <param name="args">The arguments to initialize the <see cref="BaseModifier"/> with.</param>
|
||||
/// <returns>The added <see cref="BaseModifier"/>.</returns>
|
||||
/// <param name="player">The PlayerControl instance.</param>
|
||||
/// <param name="typeId">The type ID of the modifier.</param>
|
||||
/// <param name="args">The arguments to initialize the modifier constructor with.</param>
|
||||
/// <returns>The added modifier.</returns>
|
||||
public static BaseModifier? AddModifier(this PlayerControl player, uint typeId, params object[] args)
|
||||
{
|
||||
return player.GetModifierComponent().AddModifier(typeId, args);
|
||||
|
||||
@@ -8,7 +8,7 @@ using MiraAPI.Utilities;
|
||||
namespace MiraAPI.Modifiers;
|
||||
|
||||
/// <summary>
|
||||
/// Factory for creating instances of a <see cref="BaseModifier"/>. More efficient than using reflection.
|
||||
/// Factory for creating instances of a modifier. More efficient than using reflection.
|
||||
/// </summary>
|
||||
public static class ModifierFactory
|
||||
{
|
||||
@@ -39,11 +39,11 @@ public static class ModifierFactory
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="BaseModifier"/> with the specified type and arguments.
|
||||
/// Creates a modifier with the specified type and arguments.
|
||||
/// </summary>
|
||||
/// <param name="type">Modifier type.</param>
|
||||
/// <param name="args">Arguments.</param>
|
||||
/// <returns>An instance of the <see cref="BaseModifier"/>.</returns>
|
||||
/// <returns>An instance of the modifier.</returns>
|
||||
public static BaseModifier CreateInstance(Type type, params object[] args)
|
||||
{
|
||||
var argTypes = args.Select(arg => arg.GetType()).ToArray();
|
||||
@@ -60,9 +60,9 @@ public static class ModifierFactory
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Factory for creating instances of <typeparamref name="T"/>. More efficient than using reflection.
|
||||
/// Factory for creating instances of a modifier. More efficient than using reflection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="BaseModifier"/> type.</typeparam>
|
||||
/// <typeparam name="T">The modifier type.</typeparam>
|
||||
public static class ModifierFactory<T> where T : BaseModifier
|
||||
{
|
||||
private static readonly Func<object[], T> Constructor = CreateConstructor();
|
||||
@@ -92,10 +92,10 @@ public static class ModifierFactory<T> where T : BaseModifier
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of <typeparamref name="T"/>.
|
||||
/// Creates an instance of the modifier.
|
||||
/// </summary>
|
||||
/// <param name="args">Parameters for the constructor.</param>
|
||||
/// <returns>An instance of <typeparamref name="T"/>.</returns>
|
||||
/// <returns>An instance of the modifier.</returns>
|
||||
[SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "This is a factory class.")]
|
||||
public static T CreateInstance(params object[] args)
|
||||
{
|
||||
|
||||
Loaded 100 of 197 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user