mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
HideFromIl2Cpp and slight modification to TimedModifier to use new HudString method
This commit is contained in:
1 parent
8178967fd8
commit
126df24a23
6 files changed
+46
-10
No files matched your search
@@ -1,5 +1,8 @@
|
|||||||
using MiraAPI.Modifiers;
|
using Il2CppSystem;
|
||||||
|
using MiraAPI.Example.Roles;
|
||||||
|
using MiraAPI.Modifiers;
|
||||||
using MiraAPI.Modifiers.Types;
|
using MiraAPI.Modifiers.Types;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MiraAPI.Example.Modifiers.Freezer;
|
namespace MiraAPI.Example.Modifiers.Freezer;
|
||||||
|
|
||||||
@@ -20,6 +23,16 @@ public class FreezeModifier : TimedModifier
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void FixedUpdate()
|
||||||
|
{
|
||||||
|
base.FixedUpdate();
|
||||||
|
|
||||||
|
if (Player?.AmOwner == true || PlayerControl.LocalPlayer.Data.Role is FreezerRole)
|
||||||
|
{
|
||||||
|
Player?.cosmetics.SetOutline(true, new Nullable<Color>(Palette.LightBlue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnTimerComplete()
|
public override void OnTimerComplete()
|
||||||
{
|
{
|
||||||
if (Player?.AmOwner == true)
|
if (Player?.AmOwner == true)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using MiraAPI.Roles;
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
|
using MiraAPI.Roles;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ public class FreezerRole : ImpostorRole, ICustomRole
|
|||||||
public string RoleDescription => RoleLongDescription;
|
public string RoleDescription => RoleLongDescription;
|
||||||
public Color RoleColor => Palette.Blue;
|
public Color RoleColor => Palette.Blue;
|
||||||
public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
|
public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
|
public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
|
||||||
public int MaxPlayers => 2;
|
public int MaxPlayers => 2;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using MiraAPI.Roles;
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
|
using MiraAPI.Roles;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -12,5 +13,6 @@ public class TeleporterRole : CrewmateRole, ICustomRole
|
|||||||
public string RoleDescription => RoleLongDescription;
|
public string RoleDescription => RoleLongDescription;
|
||||||
public Color RoleColor => new Color32(221, 176, 152, 255);
|
public Color RoleColor => new Color32(221, 176, 152, 255);
|
||||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
|
public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Collections.Immutable;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
using MiraAPI.Modifiers.Types;
|
using MiraAPI.Modifiers.Types;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
using Reactor.Utilities;
|
using Reactor.Utilities;
|
||||||
@@ -22,8 +23,10 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the active modifiers on the player.
|
/// Gets the active modifiers on the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public ImmutableList<BaseModifier> ActiveModifiers => Modifiers.ToImmutableList();
|
public ImmutableList<BaseModifier> ActiveModifiers => Modifiers.ToImmutableList();
|
||||||
|
|
||||||
|
[HideFromIl2Cpp]
|
||||||
private List<BaseModifier> Modifiers { get; set; } = [];
|
private List<BaseModifier> Modifiers { get; set; } = [];
|
||||||
|
|
||||||
private PlayerControl? _player;
|
private PlayerControl? _player;
|
||||||
@@ -115,10 +118,6 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
foreach (var mod in baseModifiers)
|
foreach (var mod in baseModifiers)
|
||||||
{
|
{
|
||||||
stringBuild.Append(CultureInfo.InvariantCulture, $"\n{mod.GetHudString()}");
|
stringBuild.Append(CultureInfo.InvariantCulture, $"\n{mod.GetHudString()}");
|
||||||
if (mod is TimedModifier timer)
|
|
||||||
{
|
|
||||||
stringBuild.Append(CultureInfo.InvariantCulture, $" <size=70%>({Math.Round(timer.Duration - timer.TimeRemaining, 0)}s/{timer.Duration}s)</size>");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_modifierText!.text = $"<b><size=130%>Modifiers:</b></size>{stringBuild}";
|
_modifierText!.text = $"<b><size=130%>Modifiers:</b></size>{stringBuild}";
|
||||||
}
|
}
|
||||||
@@ -132,6 +131,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// Removes a modifier from the player.
|
/// Removes a modifier from the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">The modifier type.</param>
|
/// <param name="type">The modifier type.</param>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public void RemoveModifier(Type type)
|
public void RemoveModifier(Type type)
|
||||||
{
|
{
|
||||||
var modifier = Modifiers.Find(x => x.GetType() == type);
|
var modifier = Modifiers.Find(x => x.GetType() == type);
|
||||||
@@ -149,6 +149,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// Removes a modifier from the player.
|
/// Removes a modifier from the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The modifier type.</typeparam>
|
/// <typeparam name="T">The modifier type.</typeparam>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public void RemoveModifier<T>() where T : BaseModifier
|
public void RemoveModifier<T>() where T : BaseModifier
|
||||||
{
|
{
|
||||||
RemoveModifier(typeof(T));
|
RemoveModifier(typeof(T));
|
||||||
@@ -158,6 +159,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// Removes a modifier from the player.
|
/// Removes a modifier from the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="modifierId">The modifier ID.</param>
|
/// <param name="modifierId">The modifier ID.</param>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public void RemoveModifier(uint modifierId)
|
public void RemoveModifier(uint modifierId)
|
||||||
{
|
{
|
||||||
var modifier = Modifiers.Find(x => x.ModifierId == modifierId);
|
var modifier = Modifiers.Find(x => x.ModifierId == modifierId);
|
||||||
@@ -175,6 +177,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// Removes a modifier from the player.
|
/// Removes a modifier from the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="modifier">The modifier object.</param>
|
/// <param name="modifier">The modifier object.</param>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public void RemoveModifier(BaseModifier modifier)
|
public void RemoveModifier(BaseModifier modifier)
|
||||||
{
|
{
|
||||||
if (!Modifiers.Contains(modifier))
|
if (!Modifiers.Contains(modifier))
|
||||||
@@ -191,6 +194,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="modifier">The modifier to add.</param>
|
/// <param name="modifier">The modifier to add.</param>
|
||||||
/// <returns>The modifier that was added.</returns>
|
/// <returns>The modifier that was added.</returns>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public BaseModifier? AddModifier(BaseModifier modifier)
|
public BaseModifier? AddModifier(BaseModifier modifier)
|
||||||
{
|
{
|
||||||
if (Modifiers.Contains(modifier))
|
if (Modifiers.Contains(modifier))
|
||||||
@@ -218,6 +222,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">The modifier type.</param>
|
/// <param name="type">The modifier type.</param>
|
||||||
/// <returns>The modifier that was added.</returns>
|
/// <returns>The modifier that was added.</returns>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public BaseModifier? AddModifier(Type type)
|
public BaseModifier? AddModifier(Type type)
|
||||||
{
|
{
|
||||||
var modifierId = ModifierManager.GetModifierId(type);
|
var modifierId = ModifierManager.GetModifierId(type);
|
||||||
@@ -249,6 +254,7 @@ public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The Type of the modifier.</typeparam>
|
/// <typeparam name="T">The Type of the modifier.</typeparam>
|
||||||
/// <returns>The new modifier.</returns>
|
/// <returns>The new modifier.</returns>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public T? AddModifier<T>() where T : BaseModifier
|
public T? AddModifier<T>() where T : BaseModifier
|
||||||
{
|
{
|
||||||
return AddModifier(typeof(T)) as T;
|
return AddModifier(typeof(T)) as T;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using MiraAPI.Utilities;
|
using System;
|
||||||
|
using MiraAPI.Utilities;
|
||||||
using Reactor.Utilities;
|
using Reactor.Utilities;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -39,6 +40,15 @@ public abstract class TimedModifier : BaseModifier
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float TimeRemaining { get; protected set; }
|
public float TimeRemaining { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the HUD information for Timed Modifier, including the time remaining.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A string with the hud information + timer.</returns>
|
||||||
|
public override string GetHudString()
|
||||||
|
{
|
||||||
|
return base.GetHudString() + $" <size=70%>({Math.Round(Duration - TimeRemaining, 0)}s/{Duration}s)</size>";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The FixedUpdate method for timed modifiers. Automatically handles the timer logic.
|
/// The FixedUpdate method for timed modifiers. Automatically handles the timer logic.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
using AmongUs.GameOptions;
|
using System.Text;
|
||||||
|
using AmongUs.GameOptions;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
using MiraAPI.Modifiers;
|
using MiraAPI.Modifiers;
|
||||||
using MiraAPI.PluginLoading;
|
using MiraAPI.PluginLoading;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MiraAPI.Roles;
|
namespace MiraAPI.Roles;
|
||||||
@@ -47,11 +48,13 @@ public interface ICustomRole
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Sprite used for the Role Options menu screenshot.
|
/// Gets the Sprite used for the Role Options menu screenshot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
LoadableAsset<Sprite> OptionsScreenshot => MiraAssets.Empty;
|
LoadableAsset<Sprite> OptionsScreenshot => MiraAssets.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Sprite used for the Role Icon.
|
/// Gets the Sprite used for the Role Icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
LoadableAsset<Sprite> Icon => MiraAssets.Empty;
|
LoadableAsset<Sprite> Icon => MiraAssets.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in new issue
Block a user