mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-23 20:46:46 +00:00
Compare commits
10
Commits
commission
...
contexts
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
575f7a78a1 | ||
|
|
bf7edb30ab | ||
|
|
b4527014b7 | ||
|
|
277391ef1c | ||
|
|
6b3038f397 | ||
|
|
4e1db039a0 | ||
|
|
62bee24789 | ||
|
|
2156c80467 | ||
|
|
0ff60071c2 | ||
|
|
de2f3f0d95 |
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
namespace MiraAPI.Game;
|
||||||
|
|
||||||
|
public enum PlayerContext
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -64,6 +64,11 @@ public abstract class BaseModifier : IOptionable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool ShowInFreeplay => false;
|
public virtual bool ShowInFreeplay => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating the color that should be used for the modifier within freeplay.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Color FreeplayFileColor => Color.gray;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the modifier is unique. If 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>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace MiraAPI.Modifiers;
|
||||||
|
|
||||||
|
public enum ModifierContext
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ using System.Runtime.Serialization;
|
|||||||
using MiraAPI.Modifiers.Types;
|
using MiraAPI.Modifiers.Types;
|
||||||
using MiraAPI.PluginLoading;
|
using MiraAPI.PluginLoading;
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
|
using MiraAPI.Utilities;
|
||||||
using Reactor.Utilities;
|
using Reactor.Utilities;
|
||||||
using Reactor.Utilities.Extensions;
|
using Reactor.Utilities.Extensions;
|
||||||
using Random = System.Random;
|
using Random = System.Random;
|
||||||
@@ -125,6 +126,7 @@ public static class ModifierManager
|
|||||||
.Select(x => Activator.CreateInstance(x.Value) as GameModifier)
|
.Select(x => Activator.CreateInstance(x.Value) as GameModifier)
|
||||||
.OfType<GameModifier>()
|
.OfType<GameModifier>()
|
||||||
.Where(x => x.GetAmountPerGame() > 0 && x.GetAssignmentChance() > 0)
|
.Where(x => x.GetAmountPerGame() > 0 && x.GetAssignmentChance() > 0)
|
||||||
|
.Shuffle()
|
||||||
.OrderByDescending(x => x.Priority())
|
.OrderByDescending(x => x.Priority())
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace MiraAPI.Patches;
|
namespace MiraAPI.Patches;
|
||||||
|
|
||||||
|
#pragma warning disable SA1629
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows players to paste text into chat.
|
/// Allows players to paste text into chat.
|
||||||
/// Source: https://github.com/CallOfCreator/NewMod/blob/main/NewMod/Patches/ClipboardPatch.cs
|
/// Source: https://github.com/CallOfCreator/NewMod/blob/main/NewMod/Patches/ClipboardPatch.cs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
#pragma warning restore SA1629
|
||||||
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))]
|
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))]
|
||||||
public static class ChatControllerPatch
|
public static class ChatControllerPatch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,14 +12,16 @@ public static class CanUsePatches
|
|||||||
public static IEnumerable<MethodBase> TargetMethods()
|
public static IEnumerable<MethodBase> TargetMethods()
|
||||||
{
|
{
|
||||||
yield return AccessTools.Method(typeof(Console), nameof(Console.CanUse));
|
yield return AccessTools.Method(typeof(Console), nameof(Console.CanUse));
|
||||||
yield return AccessTools.Method(typeof(MapConsole), nameof(MapConsole.CanUse));
|
yield return AccessTools.Method(typeof(DeconControl), nameof(DeconControl.CanUse));
|
||||||
yield return AccessTools.Method(typeof(SystemConsole), nameof(SystemConsole.CanUse));
|
|
||||||
yield return AccessTools.Method(typeof(Ladder), nameof(Ladder.CanUse));
|
|
||||||
yield return AccessTools.Method(typeof(PlatformConsole), nameof(PlatformConsole.CanUse));
|
|
||||||
yield return AccessTools.Method(typeof(OpenDoorConsole), nameof(OpenDoorConsole.CanUse));
|
|
||||||
yield return AccessTools.Method(typeof(DoorConsole), nameof(DoorConsole.CanUse));
|
yield return AccessTools.Method(typeof(DoorConsole), nameof(DoorConsole.CanUse));
|
||||||
|
yield return AccessTools.Method(typeof(Ladder), nameof(Ladder.CanUse));
|
||||||
|
yield return AccessTools.Method(typeof(MapConsole), nameof(MapConsole.CanUse));
|
||||||
|
yield return AccessTools.Method(typeof(OpenDoorConsole), nameof(OpenDoorConsole.CanUse));
|
||||||
yield return AccessTools.Method(typeof(OptionsConsole), nameof(OptionsConsole.CanUse));
|
yield return AccessTools.Method(typeof(OptionsConsole), nameof(OptionsConsole.CanUse));
|
||||||
|
yield return AccessTools.Method(typeof(PlatformConsole), nameof(PlatformConsole.CanUse));
|
||||||
|
yield return AccessTools.Method(typeof(SystemConsole), nameof(SystemConsole.CanUse));
|
||||||
yield return AccessTools.Method(typeof(ZiplineConsole), nameof(ZiplineConsole.CanUse));
|
yield return AccessTools.Method(typeof(ZiplineConsole), nameof(ZiplineConsole.CanUse));
|
||||||
|
// vent is not necessary as it has its own patch
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPriority(Priority.Last)]
|
[HarmonyPriority(Priority.Last)]
|
||||||
|
|||||||
@@ -22,15 +22,4 @@ internal static class TaskAddButtonPatches
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(nameof(TaskAddButton.Role), MethodType.Setter)]
|
|
||||||
public static void RoleGetterPatch(TaskAddButton __instance)
|
|
||||||
{
|
|
||||||
if (__instance.role is ICustomRole { Team: ModdedRoleTeams.Custom } customRole)
|
|
||||||
{
|
|
||||||
__instance.FileImage.color = customRole.IntroConfiguration?.IntroTeamColor ?? Color.gray;
|
|
||||||
}
|
|
||||||
__instance.RolloverHandler.OutColor = __instance.FileImage.color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ using MiraAPI.Utilities;
|
|||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
@@ -19,7 +20,6 @@ namespace MiraAPI.Patches.Freeplay;
|
|||||||
internal static class TaskAdderPatches
|
internal static class TaskAdderPatches
|
||||||
{
|
{
|
||||||
private static Scroller _scroller = null!;
|
private static Scroller _scroller = null!;
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(TaskAdderGame.Begin))]
|
[HarmonyPatch(nameof(TaskAdderGame.Begin))]
|
||||||
public static void AddRolesFolder(TaskAdderGame __instance)
|
public static void AddRolesFolder(TaskAdderGame __instance)
|
||||||
@@ -32,6 +32,11 @@ internal static class TaskAdderPatches
|
|||||||
_scroller.allowY = true;
|
_scroller.allowY = true;
|
||||||
_scroller.Inner = inner.transform;
|
_scroller.Inner = inner.transform;
|
||||||
|
|
||||||
|
var scrollerHelper = __instance.TaskParent.gameObject.AddComponent<ManualScrollHelper>();
|
||||||
|
scrollerHelper.scroller = _scroller;
|
||||||
|
scrollerHelper.verticalAxis = RewiredConstsEnum.Action.TaskRVertical;
|
||||||
|
scrollerHelper.scrollSpeed = 10f;
|
||||||
|
|
||||||
GameObject hitbox = new("Hitbox")
|
GameObject hitbox = new("Hitbox")
|
||||||
{
|
{
|
||||||
layer = 5,
|
layer = 5,
|
||||||
@@ -295,7 +300,7 @@ internal static class TaskAdderPatches
|
|||||||
|
|
||||||
if (_scroller)
|
if (_scroller)
|
||||||
{
|
{
|
||||||
_scroller.CalculateAndSetYBounds(__instance.ActiveItems.Count, 6, 5, 1.4f);
|
_scroller.CalculateAndSetYBounds(__instance.ActiveItems.Count, 6, 4.5f, 1.65f);
|
||||||
_scroller.SetYBoundsMin(0.0f);
|
_scroller.SetYBoundsMin(0.0f);
|
||||||
_scroller.ScrollToTop();
|
_scroller.ScrollToTop();
|
||||||
}
|
}
|
||||||
@@ -332,7 +337,8 @@ internal static class TaskAdderPatches
|
|||||||
taskAddButton.SafePositionWorld = instance.SafePositionWorld;
|
taskAddButton.SafePositionWorld = instance.SafePositionWorld;
|
||||||
taskAddButton.Text.text = modifier.ModifierName;
|
taskAddButton.Text.text = modifier.ModifierName;
|
||||||
taskAddButton.Text.EnableMasking();
|
taskAddButton.Text.EnableMasking();
|
||||||
|
taskAddButton.FileImage.color = modifier.FreeplayFileColor;
|
||||||
|
taskAddButton.RolloverHandler.OutColor = modifier.FreeplayFileColor;
|
||||||
taskAddButton.Button.OnClick = new Button.ButtonClickedEvent();
|
taskAddButton.Button.OnClick = new Button.ButtonClickedEvent();
|
||||||
taskAddButton.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() =>
|
taskAddButton.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() =>
|
||||||
{
|
{
|
||||||
@@ -384,6 +390,20 @@ internal static class TaskAdderPatches
|
|||||||
|
|
||||||
instance.AddFileAsChildCustom(taskAddButton2, ref num, ref num2, ref num3);
|
instance.AddFileAsChildCustom(taskAddButton2, ref num, ref num2, ref num3);
|
||||||
taskAddButton2.Role = roleBehaviour;
|
taskAddButton2.Role = roleBehaviour;
|
||||||
|
if (roleBehaviour is ICustomRole custom)
|
||||||
|
{
|
||||||
|
var customColor = custom.IntroConfiguration?.IntroTeamColor ?? Color.gray;
|
||||||
|
if (custom.Team is ModdedRoleTeams.Crewmate)
|
||||||
|
{
|
||||||
|
customColor = Palette.CrewmateBlue;
|
||||||
|
}
|
||||||
|
else if (custom.Team is ModdedRoleTeams.Impostor)
|
||||||
|
{
|
||||||
|
customColor = Palette.ImpostorRed;
|
||||||
|
}
|
||||||
|
taskAddButton2.FileImage.color = customColor;
|
||||||
|
taskAddButton2.RolloverHandler.OutColor = customColor;
|
||||||
|
}
|
||||||
if (taskAddButton2.Button == null)
|
if (taskAddButton2.Button == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public static class HatsTabPatches
|
|||||||
text.gameObject.transform.localScale = Vector3.one;
|
text.gameObject.transform.localScale = Vector3.one;
|
||||||
text.GetComponent<TextTranslatorTMP>().Destroy();
|
text.GetComponent<TextTranslatorTMP>().Destroy();
|
||||||
text.EnableStencilMasking();
|
text.EnableStencilMasking();
|
||||||
text.text = $"{groupName}\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{sortedHats.Count})\nPress Ctrl or Tab to cycle pages";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 3f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 3f;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public static class NameplatesTabPatches
|
|||||||
text.gameObject.transform.localScale = Vector3.one;
|
text.gameObject.transform.localScale = Vector3.one;
|
||||||
text.GetComponent<TextTranslatorTMP>().Destroy();
|
text.GetComponent<TextTranslatorTMP>().Destroy();
|
||||||
text.EnableStencilMasking();
|
text.EnableStencilMasking();
|
||||||
text.text = $"{groupName}\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{SortedNameplates.Count})\nPress Ctrl or Tab to cycle pages";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 3f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 3f;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public static class SkinsTabPatches
|
|||||||
text.gameObject.transform.localScale = Vector3.one;
|
text.gameObject.transform.localScale = Vector3.one;
|
||||||
text.GetComponent<TextTranslatorTMP>().Destroy();
|
text.GetComponent<TextTranslatorTMP>().Destroy();
|
||||||
text.EnableStencilMasking();
|
text.EnableStencilMasking();
|
||||||
text.text = $"{groupName}\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{sortedSkins.Count})\nPress Ctrl or Tab to cycle pages";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 3f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 3f;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public static class VisorsTabPatches
|
|||||||
text.gameObject.transform.localScale = Vector3.one;
|
text.gameObject.transform.localScale = Vector3.one;
|
||||||
text.GetComponent<TextTranslatorTMP>().Destroy();
|
text.GetComponent<TextTranslatorTMP>().Destroy();
|
||||||
text.EnableStencilMasking();
|
text.EnableStencilMasking();
|
||||||
text.text = $"{groupName}\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{SortedVisors.Count})\nPress Ctrl or Tab to cycle pages";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 3f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 3f;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace MiraAPI.Patches;
|
namespace MiraAPI.Patches;
|
||||||
|
|
||||||
@@ -14,6 +15,8 @@ public static class ServerDropdownPatch
|
|||||||
|
|
||||||
foreach (var regionInfo in DestroyableSingleton<ServerManager>.Instance.AvailableRegions)
|
foreach (var regionInfo in DestroyableSingleton<ServerManager>.Instance.AvailableRegions)
|
||||||
{
|
{
|
||||||
|
var findingGame = SceneManager.GetActiveScene().name is "FindAGame";
|
||||||
|
|
||||||
if (DestroyableSingleton<ServerManager>.Instance.CurrentRegion.Equals(regionInfo))
|
if (DestroyableSingleton<ServerManager>.Instance.CurrentRegion.Equals(regionInfo))
|
||||||
{
|
{
|
||||||
__instance.defaultButtonSelected = __instance.firstOption;
|
__instance.defaultButtonSelected = __instance.firstOption;
|
||||||
@@ -27,6 +30,10 @@ public static class ServerDropdownPatch
|
|||||||
var region = regionInfo;
|
var region = regionInfo;
|
||||||
var serverListButton = __instance.ButtonPool.Get<ServerListButton>();
|
var serverListButton = __instance.ButtonPool.Get<ServerListButton>();
|
||||||
var x = num % 2 == 0 ? -2 : 2;
|
var x = num % 2 == 0 ? -2 : 2;
|
||||||
|
if (findingGame)
|
||||||
|
{
|
||||||
|
x += 2;
|
||||||
|
}
|
||||||
var y = -0.55f * (num / 2);
|
var y = -0.55f * (num / 2);
|
||||||
serverListButton.transform.localPosition = new Vector3(x, __instance.y_posButton + y, -1f);
|
serverListButton.transform.localPosition = new Vector3(x, __instance.y_posButton + y, -1f);
|
||||||
serverListButton.transform.localScale = Vector3.one;
|
serverListButton.transform.localScale = Vector3.one;
|
||||||
@@ -39,7 +46,7 @@ public static class ServerDropdownPatch
|
|||||||
serverListButton.Button.OnClick.AddListener((UnityAction)(() => { __instance.ChooseOption(region); }));
|
serverListButton.Button.OnClick.AddListener((UnityAction)(() => { __instance.ChooseOption(region); }));
|
||||||
__instance.controllerSelectable.Add(serverListButton.Button);
|
__instance.controllerSelectable.Add(serverListButton.Button);
|
||||||
__instance.background.transform.localPosition = new Vector3(
|
__instance.background.transform.localPosition = new Vector3(
|
||||||
0f,
|
findingGame ? 2f : 0f,
|
||||||
__instance.initialYPos + (-0.3f * (num / 2)),
|
__instance.initialYPos + (-0.3f * (num / 2)),
|
||||||
0f);
|
0f);
|
||||||
__instance.background.size = new Vector2(__instance.background.size.x, 1.2f + (0.6f * (num / 2)));
|
__instance.background.size = new Vector2(__instance.background.size.x, 1.2f + (0.6f * (num / 2)));
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
namespace MiraAPI.Roles;
|
||||||
|
|
||||||
|
public enum RoleContext
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace MiraAPI.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extensions for IEnumerable.
|
||||||
|
/// </summary>
|
||||||
|
public static class EnumerableExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Shuffle the elements of the source enumerable using a new instance of Random.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The source enumerable.</param>
|
||||||
|
/// <typeparam name="T">The type of the elements.</typeparam>
|
||||||
|
/// <returns>>The shuffled enumerable.</returns>
|
||||||
|
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
|
||||||
|
{
|
||||||
|
return source.Shuffle(new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuffle the elements of the source enumerable using the provided Random instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The source enumerable.</param>
|
||||||
|
/// <param name="rng">The Random instance to use for shuffling.</param>
|
||||||
|
/// <typeparam name="T">The type of the elements.</typeparam>
|
||||||
|
/// <returns>>The shuffled enumerable.</returns>
|
||||||
|
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random rng)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(source);
|
||||||
|
ArgumentNullException.ThrowIfNull(rng);
|
||||||
|
|
||||||
|
return source.ShuffleIterator(rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<T> ShuffleIterator<T>(this IEnumerable<T> source, Random rng)
|
||||||
|
{
|
||||||
|
var buffer = source.ToList();
|
||||||
|
for (var i = 0; i < buffer.Count; i++)
|
||||||
|
{
|
||||||
|
var j = rng.Next(i, buffer.Count);
|
||||||
|
yield return buffer[j];
|
||||||
|
|
||||||
|
buffer[j] = buffer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user