mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 11:39:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac2201b3ef | ||
|
|
8bf101534f | ||
|
|
479323acdd | ||
|
|
50c5899f4d | ||
|
|
fd719ae42f | ||
|
|
e050b043cb | ||
|
|
992df67e18 | ||
|
|
e78c456636 | ||
|
|
7e8d07672c | ||
|
|
67611471b8 | ||
|
|
5ddf48883c | ||
|
|
77ae01c66a | ||
|
|
ce824f05fa | ||
|
|
b5fe3c7afd | ||
|
|
df8598db4d | ||
|
|
134e229523 | ||
|
|
cc1e89fd32 | ||
|
|
8bec9efa5c | ||
|
|
41c2a2b118 | ||
|
|
7919b32023 | ||
|
|
95bf1e1448 | ||
|
|
e4adaf7ab4 | ||
|
|
4027257b55 | ||
|
|
6c32c8bed9 | ||
|
|
905cc9e335 | ||
|
|
157aa65c2d | ||
|
|
3693ee754a | ||
|
|
85431d3685 | ||
|
|
2ac6c55cf8 | ||
|
|
db69446352 |
No files matched your search
+2
-2
@@ -2,12 +2,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Reactor" Version="2.3.1" />
|
<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="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" />
|
||||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2025.9.9" 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.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
|
||||||
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
|
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" PrivateAssets="all" ExcludeAssets="runtime" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
|
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
|
||||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
|
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||||
|
|
||||||
<VersionPrefix>0.3.0</VersionPrefix>
|
<VersionPrefix>0.3.1</VersionPrefix>
|
||||||
<VersionSuffix>dev</VersionSuffix>
|
<VersionSuffix>dev</VersionSuffix>
|
||||||
|
|
||||||
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using MiraAPI.Example.GameOver;
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
|
using MiraAPI.Example.GameOver;
|
||||||
using MiraAPI.GameEnd;
|
using MiraAPI.GameEnd;
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -22,6 +23,7 @@ public class NeutralKillerRole : ImpostorRole, ICustomRole
|
|||||||
|
|
||||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
||||||
|
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
|
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
|
||||||
Color.gray,
|
Color.gray,
|
||||||
"OUTCAST",
|
"OUTCAST",
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using AmongUs.GameOptions;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2CppSystem.Collections.Generic;
|
||||||
|
using MiraAPI.Roles;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace MiraAPI.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(DetectiveNotesMinigame), nameof(DetectiveNotesMinigame.OpenBodyPopup))]
|
||||||
|
public static class DetectiveNotesMinigamePatch
|
||||||
|
{
|
||||||
|
public static void Prefix(DetectiveNotesMinigame __instance, bool active)
|
||||||
|
{
|
||||||
|
__instance.impostorTypePopup.SetActive(active);
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
ControllerManager.Instance.CloseOverlayMenu(__instance.ImpostorOverlay);
|
||||||
|
ControllerManager.Instance.SetUpSelectables(ControllerManager.Instance.CurrentUiState, __instance.ControllerSelectable[0], __instance.ControllerSelectable);
|
||||||
|
ControllerManager.Instance.SetCurrentSelected(__instance.ControllerSelectable[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (__instance.impostorButton != null)
|
||||||
|
{
|
||||||
|
ControllerManager.Instance.OpenOverlayMenu(__instance.ImpostorOverlay, null, __instance.ImpostorIconControllerSelectables[0], __instance.ImpostorIconControllerSelectables, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
__instance.impostorButton = new List<GameObject>();
|
||||||
|
int num = 0;
|
||||||
|
var allRoles = DestroyableSingleton<RoleManager>.Instance.AllRoles;
|
||||||
|
var customRoles = CustomRoleManager.CustomRoleBehaviours;
|
||||||
|
foreach (var role in allRoles)
|
||||||
|
{
|
||||||
|
if (role.TeamType != RoleTeamTypes.Impostor || role.Role == RoleTypes.ImpostorGhost || customRoles.Contains(role) )
|
||||||
|
continue;
|
||||||
|
GameObject gameObject = Object.Instantiate<GameObject>(__instance.impostorTypePrefab, __instance.impostorTypeParent);
|
||||||
|
__instance.impostorButton.Add(gameObject);
|
||||||
|
gameObject.GetComponent<DetectiveImpostorType>().Initialize(__instance, role);
|
||||||
|
num++;
|
||||||
|
__instance.ImpostorIconControllerSelectables.Add(gameObject.GetComponent<PassiveButton>());
|
||||||
|
}
|
||||||
|
ControllerManager.Instance.OpenOverlayMenu(__instance.ImpostorOverlay, null, __instance.ImpostorIconControllerSelectables[0], __instance.ImpostorIconControllerSelectables, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,18 @@ public static class HudManagerPatches
|
|||||||
gridArrange.Alignment = GridArrange.StartAlign.Right;
|
gridArrange.Alignment = GridArrange.StartAlign.Right;
|
||||||
aspectPosition.Alignment = AspectPosition.EdgeAlignments.LeftBottom;
|
aspectPosition.Alignment = AspectPosition.EdgeAlignments.LeftBottom;
|
||||||
|
|
||||||
|
var fakeButton = Object.Instantiate(__instance.AbilityButton, BottomLeft.transform);
|
||||||
|
foreach (var renderer in fakeButton.GetComponentsInChildren<Renderer>())
|
||||||
|
{
|
||||||
|
renderer.enabled = false;
|
||||||
|
}
|
||||||
|
fakeButton.buttonLabelText.Destroy();
|
||||||
|
fakeButton.cooldownTimerText.Destroy();
|
||||||
|
fakeButton.usesRemainingText.Destroy();
|
||||||
|
fakeButton.GetComponent<PassiveButton>().Destroy();
|
||||||
|
fakeButton.ToggleVisible(true);
|
||||||
|
fakeButton.Destroy();
|
||||||
|
|
||||||
foreach (var button in CustomButtonManager.CustomButtons)
|
foreach (var button in CustomButtonManager.CustomButtons)
|
||||||
{
|
{
|
||||||
var location = button.Location switch
|
var location = button.Location switch
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
using HarmonyLib;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2CppInterop.Runtime.InteropTypes;
|
||||||
using MiraAPI.Events;
|
using MiraAPI.Events;
|
||||||
using MiraAPI.Events.Vanilla.Gameplay;
|
using MiraAPI.Events.Vanilla.Gameplay;
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
|
using Reactor.Utilities;
|
||||||
|
|
||||||
namespace MiraAPI.Patches;
|
namespace MiraAPI.Patches;
|
||||||
|
|
||||||
@@ -29,14 +33,29 @@ public static class IntroCutscenePatches
|
|||||||
MiraEventManager.InvokeEvent(@event);
|
MiraEventManager.InvokeEvent(@event);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPatch]
|
||||||
[HarmonyPatch(typeof(IntroCutscene._ShowRole_d__41), nameof(IntroCutscene._ShowRole_d__41.MoveNext))]
|
public static class IntroCutsceneShowRolePatch
|
||||||
[HarmonyPriority(Priority.Last)]
|
|
||||||
public static void ShowRolePatch(IntroCutscene._ShowRole_d__41 __instance)
|
|
||||||
{
|
{
|
||||||
var realInstance = __instance.__4__this;
|
public static MethodBase TargetMethod()
|
||||||
var @event = new IntroRoleRevealEvent(realInstance);
|
{
|
||||||
MiraEventManager.InvokeEvent(@event);
|
return Helpers.GetStateMachineMoveNext<IntroCutscene>("ShowRole")!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Postfix(Il2CppObjectBase __instance)
|
||||||
|
{
|
||||||
|
var wrapper = new StateMachineWrapper<IntroCutscene>(__instance);
|
||||||
|
// run before the first yield
|
||||||
|
if (wrapper.GetState() != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var introCutscene = wrapper.Instance;
|
||||||
|
|
||||||
|
Logger<MiraApiPlugin>.Info("IntroCutscene ShowRole reached");
|
||||||
|
var @event = new IntroRoleRevealEvent(introCutscene);
|
||||||
|
MiraEventManager.InvokeEvent(@event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
@@ -66,16 +85,54 @@ public static class IntroCutscenePatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPatch]
|
||||||
[HarmonyPatch(nameof(IntroCutscene.OnDestroy))]
|
public static class IntroCutsceneDestroyPatch
|
||||||
public static void GameBeginPatch(IntroCutscene __instance)
|
|
||||||
{
|
{
|
||||||
MiraEventManager.InvokeEvent(new IntroEndEvent(__instance));
|
private static bool _usedFallback;
|
||||||
|
|
||||||
var @event = new BeforeRoundStartEvent(true);
|
public static MethodBase TargetMethod()
|
||||||
MiraEventManager.InvokeEvent(@event);
|
{
|
||||||
|
var onDestroy = AccessTools.Method(typeof(IntroCutscene), "OnDestroy");
|
||||||
|
if (onDestroy != null)
|
||||||
|
{
|
||||||
|
_usedFallback = false;
|
||||||
|
Logger<MiraApiPlugin>.Info("Using OnDestroy for IntroCutsceneDestroyPatch");
|
||||||
|
return onDestroy;
|
||||||
|
}
|
||||||
|
|
||||||
if (@event.IsCancelled) return;
|
_usedFallback = true;
|
||||||
MiraEventManager.InvokeEvent(new RoundStartEvent(true));
|
return Helpers.GetStateMachineMoveNext<IntroCutscene>("CoBegin")!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Postfix(Il2CppObjectBase __instance)
|
||||||
|
{
|
||||||
|
IntroCutscene introCutscene;
|
||||||
|
|
||||||
|
if (_usedFallback)
|
||||||
|
{
|
||||||
|
var wrapper = new StateMachineWrapper<IntroCutscene>(__instance);
|
||||||
|
// run after the final yield
|
||||||
|
if (wrapper.GetState() != -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
introCutscene = wrapper.Instance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
introCutscene = __instance.Cast<IntroCutscene>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Logger<MiraApiPlugin>.Info("IntroCutscene ended");
|
||||||
|
|
||||||
|
MiraEventManager.InvokeEvent(new IntroEndEvent(introCutscene));
|
||||||
|
|
||||||
|
var @event = new BeforeRoundStartEvent(true);
|
||||||
|
MiraEventManager.InvokeEvent(@event);
|
||||||
|
|
||||||
|
if (@event.IsCancelled) return;
|
||||||
|
MiraEventManager.InvokeEvent(new RoundStartEvent(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,10 +6,13 @@ using System.Linq;
|
|||||||
using AmongUs.Data;
|
using AmongUs.Data;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
using Reactor.Utilities;
|
using Reactor.Utilities;
|
||||||
using Reactor.Utilities.Extensions;
|
using Reactor.Utilities.Extensions;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.UI;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace MiraAPI.Patches.Menu;
|
namespace MiraAPI.Patches.Menu;
|
||||||
@@ -20,6 +23,20 @@ public static class HatsTabPatches
|
|||||||
private static SortedList<string, List<HatData>> sortedHats = [];
|
private static SortedList<string, List<HatData>> sortedHats = [];
|
||||||
private static int currentPage;
|
private static int currentPage;
|
||||||
|
|
||||||
|
private static void PreviousPage(HatsTab hatsTab)
|
||||||
|
{
|
||||||
|
currentPage--;
|
||||||
|
currentPage = currentPage < 0 ? sortedHats.Count - 1 : currentPage;
|
||||||
|
GenerateHats(hatsTab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NextPage(HatsTab hatsTab)
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
currentPage = currentPage > sortedHats.Count - 1 ? 0 : currentPage;
|
||||||
|
GenerateHats(hatsTab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(HatsTab.OnEnable))]
|
[HarmonyPatch(nameof(HatsTab.OnEnable))]
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
public static bool OnEnablePrefix(HatsTab __instance)
|
public static bool OnEnablePrefix(HatsTab __instance)
|
||||||
@@ -38,6 +55,8 @@ public static class HatsTabPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InventoryUtility.CreateNextBackButtons(__instance, PreviousPage, NextPage);
|
||||||
|
|
||||||
GenerateHats(__instance, currentPage);
|
GenerateHats(__instance, currentPage);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -45,22 +64,17 @@ public static class HatsTabPatches
|
|||||||
|
|
||||||
[HarmonyPatch(typeof(HatsTab), nameof(HatsTab.Update))]
|
[HarmonyPatch(typeof(HatsTab), nameof(HatsTab.Update))]
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
|
|
||||||
public static void UpdatePrefix(HatsTab __instance)
|
public static void UpdatePrefix(HatsTab __instance)
|
||||||
{
|
{
|
||||||
if (sortedHats.Count == 0) return;
|
if (sortedHats.Count == 0) return;
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
||||||
{
|
{
|
||||||
currentPage--;
|
PreviousPage(__instance);
|
||||||
currentPage = currentPage < 0 ? sortedHats.Count - 1 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
||||||
{
|
{
|
||||||
currentPage++;
|
NextPage(__instance);
|
||||||
currentPage = currentPage > sortedHats.Count - 1 ? 0 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,10 +98,10 @@ 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} ({currentPage + 1}/{sortedHats.Count})\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{sortedHats.Count})";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 5f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 5f;
|
||||||
text.fontSizeMin = 0f;
|
text.fontSizeMin = 0f;
|
||||||
var xLerp = __instance.XRange.Lerp(0.5f);
|
var xLerp = __instance.XRange.Lerp(0.5f);
|
||||||
var yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
var yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||||
@@ -125,9 +139,17 @@ public static class HatsTabPatches
|
|||||||
{
|
{
|
||||||
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
||||||
colorChip.gameObject.name = hat.ProductId;
|
colorChip.gameObject.name = hat.ProductId;
|
||||||
colorChip.Button.OnClick.AddListener((Action)(() => __instance.ClickEquip()));
|
if (ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard)
|
||||||
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectHat(hat)));
|
{
|
||||||
colorChip.Button.OnMouseOut.AddListener((Action)(() => __instance.SelectHat(HatManager.Instance.GetHatById(DataManager.Player.Customization.Hat))));
|
colorChip.Button.OnClick.AddListener((Action)__instance.ClickEquip);
|
||||||
|
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectHat(hat)));
|
||||||
|
colorChip.Button.OnMouseOut.AddListener((Action)(() => __instance.SelectHat(HatManager.Instance.GetHatById(DataManager.Player.Customization.Hat))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colorChip.Button.OnClick.AddListener((Action)(() => __instance.SelectHat(hat)));
|
||||||
|
}
|
||||||
|
|
||||||
colorChip.Inner.SetHat(hat, __instance.HasLocalPlayer() ? PlayerControl.LocalPlayer.Data.DefaultOutfit.ColorId : DataManager.Player.Customization.Color);
|
colorChip.Inner.SetHat(hat, __instance.HasLocalPlayer() ? PlayerControl.LocalPlayer.Data.DefaultOutfit.ColorId : DataManager.Player.Customization.Color);
|
||||||
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
||||||
colorChip.SelectionHighlight.gameObject.SetActive(false);
|
colorChip.SelectionHighlight.gameObject.SetActive(false);
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
|
namespace MiraAPI.Patches.Menu;
|
||||||
|
|
||||||
|
public static class InventoryUtility
|
||||||
|
{
|
||||||
|
public static void CreateNextBackButtons<T>(T tab, Action<T> previousPage, Action<T> nextPage) where T : InventoryTab
|
||||||
|
{
|
||||||
|
var title = tab.transform.FindChild("Text");
|
||||||
|
title.localPosition = new Vector3(.9123f, -.23f, -55);
|
||||||
|
title.GetComponent<TextMeshPro>().alignment = TextAlignmentOptions.Center;
|
||||||
|
|
||||||
|
tab.scroller.Hitbox.transform.localScale -= new Vector3(0, 0.1f, 0);
|
||||||
|
tab.scroller.Hitbox.transform.localPosition -= new Vector3(0, 0.1f, 0);
|
||||||
|
|
||||||
|
var leftButtonElement = Object.Instantiate(PlayerCustomizationMenu.Instance.BackButton.gameObject, tab.transform);
|
||||||
|
var leftSpriteRenderer = leftButtonElement.GetComponent<SpriteRenderer>();
|
||||||
|
var leftButton = leftButtonElement.GetComponent<PassiveButton>();
|
||||||
|
|
||||||
|
leftButtonElement.transform.localPosition = new Vector3(-1.1f, -0.2f, -55);
|
||||||
|
leftSpriteRenderer.sprite = MiraAssets.NextButton.LoadAsset();
|
||||||
|
leftSpriteRenderer.flipX = true;
|
||||||
|
|
||||||
|
leftButton.OnMouseOver = new UnityEvent();
|
||||||
|
leftButton.OnMouseOver.AddListener((Action)(() => leftSpriteRenderer.sprite = MiraAssets.NextButtonActive.LoadAsset()));
|
||||||
|
leftButton.OnMouseOut = new UnityEvent();
|
||||||
|
leftButton.OnMouseOut.AddListener((Action)(() => leftSpriteRenderer.sprite = MiraAssets.NextButton.LoadAsset()));
|
||||||
|
|
||||||
|
leftButton.OnClick = new Button.ButtonClickedEvent();
|
||||||
|
leftButton.OnClick.AddListener((Action)(() => previousPage(tab)));
|
||||||
|
|
||||||
|
var rightButtonElement = Object.Instantiate(leftButtonElement, tab.transform);
|
||||||
|
var rightSpriteRenderer = rightButtonElement.GetComponent<SpriteRenderer>();
|
||||||
|
var rightButton = rightButtonElement.GetComponent<PassiveButton>();
|
||||||
|
|
||||||
|
rightButtonElement.transform.localPosition = new Vector3(2.8f, -0.2f, -55);
|
||||||
|
rightSpriteRenderer.sprite = MiraAssets.NextButton.LoadAsset();
|
||||||
|
rightSpriteRenderer.flipX = false;
|
||||||
|
|
||||||
|
rightButton.OnMouseOver = new UnityEvent();
|
||||||
|
rightButton.OnMouseOver.AddListener((Action)(() => rightSpriteRenderer.sprite = MiraAssets.NextButtonActive.LoadAsset()));
|
||||||
|
rightButton.OnMouseOut = new UnityEvent();
|
||||||
|
rightButton.OnMouseOut.AddListener((Action)(() => rightSpriteRenderer.sprite = MiraAssets.NextButton.LoadAsset()));
|
||||||
|
|
||||||
|
rightButton.OnClick = new Button.ButtonClickedEvent();
|
||||||
|
rightButton.OnClick.AddListener((Action)(() => nextPage(tab)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,20 @@ public static class NameplatesTabPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreviousPage(NameplatesTab tab)
|
||||||
|
{
|
||||||
|
currentPage--;
|
||||||
|
currentPage = currentPage < 0 ? SortedNameplates.Count - 1 : currentPage;
|
||||||
|
GenerateHats(tab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NextPage(NameplatesTab tab)
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
currentPage = currentPage > SortedNameplates.Count - 1 ? 0 : currentPage;
|
||||||
|
GenerateHats(tab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(NameplatesTab.OnEnable))]
|
[HarmonyPatch(nameof(NameplatesTab.OnEnable))]
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
public static bool OnEnablePrefix(NameplatesTab __instance)
|
public static bool OnEnablePrefix(NameplatesTab __instance)
|
||||||
@@ -33,6 +47,9 @@ public static class NameplatesTabPatches
|
|||||||
__instance.plateId = HatManager.Instance.GetNamePlateById(DataManager.Player.Customization.namePlate).ProdId;
|
__instance.plateId = HatManager.Instance.GetNamePlateById(DataManager.Player.Customization.namePlate).ProdId;
|
||||||
|
|
||||||
if (!SortedNameplates.ContainsKey("Vanilla")) AddRange(DestroyableSingleton<HatManager>.Instance.GetUnlockedNamePlates().Select(x => ("Vanilla", x)));
|
if (!SortedNameplates.ContainsKey("Vanilla")) AddRange(DestroyableSingleton<HatManager>.Instance.GetUnlockedNamePlates().Select(x => ("Vanilla", x)));
|
||||||
|
|
||||||
|
InventoryUtility.CreateNextBackButtons(__instance, PreviousPage, NextPage);
|
||||||
|
|
||||||
GenerateHats(__instance, currentPage);
|
GenerateHats(__instance, currentPage);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -45,15 +62,11 @@ public static class NameplatesTabPatches
|
|||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
||||||
{
|
{
|
||||||
currentPage--;
|
PreviousPage(__instance);
|
||||||
currentPage = currentPage < 0 ? SortedNameplates.Count - 1 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
||||||
{
|
{
|
||||||
currentPage++;
|
NextPage(__instance);
|
||||||
currentPage = currentPage > SortedNameplates.Count - 1 ? 0 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,10 +86,10 @@ 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} ({currentPage + 1}/{SortedNameplates.Count})\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{SortedNameplates.Count})";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 5f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 5f;
|
||||||
text.fontSizeMin = 0f;
|
text.fontSizeMin = 0f;
|
||||||
float xLerp = __instance.XRange.Lerp(0.5f);
|
float xLerp = __instance.XRange.Lerp(0.5f);
|
||||||
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||||
@@ -99,9 +112,20 @@ public static class NameplatesTabPatches
|
|||||||
{
|
{
|
||||||
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
||||||
colorChip.gameObject.name = namePlate.ProductId;
|
colorChip.gameObject.name = namePlate.ProductId;
|
||||||
colorChip.Button.OnClick.AddListener((Action)(() => __instance.ClickEquip()));
|
|
||||||
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectNameplate(namePlate)));
|
if (ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard)
|
||||||
colorChip.Button.OnMouseOut.AddListener((Action)(() => __instance.SelectNameplate(HatManager.Instance.GetNamePlateById(DataManager.Player.Customization.NamePlate))));
|
{
|
||||||
|
colorChip.Button.OnClick.AddListener((Action)__instance.ClickEquip);
|
||||||
|
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectNameplate(namePlate)));
|
||||||
|
colorChip.Button.OnMouseOut.AddListener(
|
||||||
|
(Action)(() => __instance.SelectNameplate(
|
||||||
|
HatManager.Instance.GetNamePlateById(DataManager.Player.Customization.NamePlate))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colorChip.Button.OnClick.AddListener((Action)(() => __instance.SelectNameplate(namePlate)));
|
||||||
|
}
|
||||||
|
|
||||||
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
||||||
colorChip.ProductId = namePlate.ProdId;
|
colorChip.ProductId = namePlate.ProdId;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,20 @@ public static class SkinsTabPatches
|
|||||||
private static SortedList<string, List<SkinData>> sortedSkins = [];
|
private static SortedList<string, List<SkinData>> sortedSkins = [];
|
||||||
private static int currentPage;
|
private static int currentPage;
|
||||||
|
|
||||||
|
private static void PreviousPage(SkinsTab tab)
|
||||||
|
{
|
||||||
|
currentPage--;
|
||||||
|
currentPage = currentPage < 0 ? sortedSkins.Count - 1 : currentPage;
|
||||||
|
GenerateHats(tab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NextPage(SkinsTab tab)
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
currentPage = currentPage > sortedSkins.Count - 1 ? 0 : currentPage;
|
||||||
|
GenerateHats(tab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(SkinsTab.OnEnable))]
|
[HarmonyPatch(nameof(SkinsTab.OnEnable))]
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
public static bool OnEnablePrefix(SkinsTab __instance)
|
public static bool OnEnablePrefix(SkinsTab __instance)
|
||||||
@@ -36,6 +50,8 @@ public static class SkinsTabPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InventoryUtility.CreateNextBackButtons(__instance, PreviousPage, NextPage);
|
||||||
|
|
||||||
GenerateHats(__instance, currentPage);
|
GenerateHats(__instance, currentPage);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -48,15 +64,11 @@ public static class SkinsTabPatches
|
|||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
||||||
{
|
{
|
||||||
currentPage--;
|
PreviousPage(__instance);
|
||||||
currentPage = currentPage < 0 ? sortedSkins.Count - 1 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
||||||
{
|
{
|
||||||
currentPage++;
|
NextPage(__instance);
|
||||||
currentPage = currentPage > sortedSkins.Count - 1 ? 0 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,10 +88,10 @@ 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} ({currentPage + 1}/{sortedSkins.Count})\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{sortedSkins.Count})";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 5f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 5f;
|
||||||
text.fontSizeMin = 0f;
|
text.fontSizeMin = 0f;
|
||||||
float xLerp = __instance.XRange.Lerp(0.5f);
|
float xLerp = __instance.XRange.Lerp(0.5f);
|
||||||
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||||
@@ -102,9 +114,18 @@ public static class SkinsTabPatches
|
|||||||
{
|
{
|
||||||
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
||||||
colorChip.gameObject.name = skin.ProductId;
|
colorChip.gameObject.name = skin.ProductId;
|
||||||
colorChip.Button.OnClick.AddListener((Action)(() => __instance.ClickEquip()));
|
if (ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard)
|
||||||
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectSkin(skin)));
|
{
|
||||||
colorChip.Button.OnMouseOut.AddListener((Action)(() => __instance.SelectSkin(HatManager.Instance.GetSkinById(DataManager.Player.Customization.Skin))));
|
colorChip.Button.OnClick.AddListener((Action)__instance.ClickEquip);
|
||||||
|
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectSkin(skin)));
|
||||||
|
colorChip.Button.OnMouseOut.AddListener(
|
||||||
|
(Action)(() =>
|
||||||
|
__instance.SelectSkin(HatManager.Instance.GetSkinById(DataManager.Player.Customization.Skin))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colorChip.Button.OnClick.AddListener((Action)(() => __instance.SelectSkin(skin)));
|
||||||
|
}
|
||||||
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
||||||
colorChip.ProductId = skin.ProductId;
|
colorChip.ProductId = skin.ProductId;
|
||||||
colorChip.SelectionHighlight.gameObject.SetActive(false);
|
colorChip.SelectionHighlight.gameObject.SetActive(false);
|
||||||
|
|||||||
@@ -25,6 +25,21 @@ public static class VisorsTabPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreviousPage(VisorsTab tab)
|
||||||
|
{
|
||||||
|
currentPage--;
|
||||||
|
currentPage = currentPage < 0 ? SortedVisors.Count - 1 : currentPage;
|
||||||
|
GenerateHats(tab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NextPage(VisorsTab tab)
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
currentPage = currentPage > SortedVisors.Count - 1 ? 0 : currentPage;
|
||||||
|
GenerateHats(tab, currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(VisorsTab.OnEnable))]
|
[HarmonyPatch(nameof(VisorsTab.OnEnable))]
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
public static bool OnEnablePrefix(VisorsTab __instance)
|
public static bool OnEnablePrefix(VisorsTab __instance)
|
||||||
@@ -32,6 +47,9 @@ public static class VisorsTabPatches
|
|||||||
__instance.visorId = HatManager.Instance.GetVisorById(DataManager.Player.Customization.Visor).ProdId;
|
__instance.visorId = HatManager.Instance.GetVisorById(DataManager.Player.Customization.Visor).ProdId;
|
||||||
|
|
||||||
if (!SortedVisors.ContainsKey("Vanilla")) AddRange(DestroyableSingleton<HatManager>.Instance.GetUnlockedVisors().Select(x => ("Vanilla", x)));
|
if (!SortedVisors.ContainsKey("Vanilla")) AddRange(DestroyableSingleton<HatManager>.Instance.GetUnlockedVisors().Select(x => ("Vanilla", x)));
|
||||||
|
|
||||||
|
InventoryUtility.CreateNextBackButtons(__instance, PreviousPage, NextPage);
|
||||||
|
|
||||||
GenerateHats(__instance, currentPage);
|
GenerateHats(__instance, currentPage);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -44,15 +62,11 @@ public static class VisorsTabPatches
|
|||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow))
|
||||||
{
|
{
|
||||||
currentPage--;
|
PreviousPage(__instance);
|
||||||
currentPage = currentPage < 0 ? SortedVisors.Count - 1 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.RightArrow))
|
||||||
{
|
{
|
||||||
currentPage++;
|
NextPage(__instance);
|
||||||
currentPage = currentPage > SortedVisors.Count - 1 ? 0 : currentPage;
|
|
||||||
GenerateHats(__instance, currentPage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +86,10 @@ 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} ({currentPage + 1}/{SortedVisors.Count})\nPress Ctrl or Tab to cycle pages";
|
text.text = $"{groupName} ({currentPage + 1}/{SortedVisors.Count})";
|
||||||
text.alignment = TextAlignmentOptions.Center;
|
text.alignment = TextAlignmentOptions.Center;
|
||||||
text.fontSize = 3f;
|
text.fontSize = 5f;
|
||||||
text.fontSizeMax = 3f;
|
text.fontSizeMax = 5f;
|
||||||
text.fontSizeMin = 0f;
|
text.fontSizeMin = 0f;
|
||||||
float xLerp = __instance.XRange.Lerp(0.5f);
|
float xLerp = __instance.XRange.Lerp(0.5f);
|
||||||
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
float yLerp = __instance.YStart - hatIndex / __instance.NumPerRow * __instance.YOffset;
|
||||||
@@ -98,9 +112,20 @@ public static class VisorsTabPatches
|
|||||||
{
|
{
|
||||||
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
var colorChip = Object.Instantiate(__instance.ColorTabPrefab, __instance.scroller.Inner);
|
||||||
colorChip.gameObject.name = visor.ProductId;
|
colorChip.gameObject.name = visor.ProductId;
|
||||||
colorChip.Button.OnClick.AddListener((Action)(() => __instance.ClickEquip()));
|
|
||||||
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectVisor(visor)));
|
if (ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard)
|
||||||
colorChip.Button.OnMouseOut.AddListener((Action)(() => __instance.SelectVisor(HatManager.Instance.GetVisorById(DataManager.Player.Customization.Visor))));
|
{
|
||||||
|
colorChip.Button.OnClick.AddListener((Action)__instance.ClickEquip);
|
||||||
|
colorChip.Button.OnMouseOver.AddListener((Action)(() => __instance.SelectVisor(visor)));
|
||||||
|
colorChip.Button.OnMouseOut.AddListener(
|
||||||
|
(Action)(() =>
|
||||||
|
__instance.SelectVisor(HatManager.Instance.GetVisorById(DataManager.Player.Customization.Visor))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colorChip.Button.OnClick.AddListener((Action)(() => __instance.SelectVisor(visor)));
|
||||||
|
}
|
||||||
|
|
||||||
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
colorChip.Button.ClickMask = __instance.scroller.Hitbox;
|
||||||
colorChip.ProductId = visor.ProductId;
|
colorChip.ProductId = visor.ProductId;
|
||||||
colorChip.SelectionHighlight.gameObject.SetActive(false);
|
colorChip.SelectionHighlight.gameObject.SetActive(false);
|
||||||
|
|||||||
Binary file not shown.
@@ -12,7 +12,7 @@ public static class MiraAssets
|
|||||||
{
|
{
|
||||||
var boxTex = SpriteTools.LoadTextureFromResourcePath(
|
var boxTex = SpriteTools.LoadTextureFromResourcePath(
|
||||||
"MiraAPI.Resources.RoundedBox.png",
|
"MiraAPI.Resources.RoundedBox.png",
|
||||||
System.Reflection.Assembly.GetCallingAssembly());
|
System.Reflection.Assembly.GetExecutingAssembly());
|
||||||
var boxSprite = Sprite.Create(
|
var boxSprite = Sprite.Create(
|
||||||
boxTex,
|
boxTex,
|
||||||
new Rect(0, 0, boxTex.width, boxTex.height),
|
new Rect(0, 0, boxTex.width, boxTex.height),
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
using System;
|
using System.Collections;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using HarmonyLib;
|
||||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||||
using MiraAPI.Keybinds;
|
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
|
using Reactor.Utilities;
|
||||||
using Rewired;
|
using Rewired;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using MethodBase = System.Reflection.MethodBase;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace MiraAPI.Utilities;
|
namespace MiraAPI.Utilities;
|
||||||
@@ -38,6 +39,31 @@ public static class Helpers
|
|||||||
return keybindIcon;
|
return keybindIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodBase? GetStateMachineMoveNext<T>(string methodName)
|
||||||
|
{
|
||||||
|
var typeName = typeof(T).FullName;
|
||||||
|
var showRoleStateMachine =
|
||||||
|
typeof(T)
|
||||||
|
.GetNestedTypes()
|
||||||
|
.FirstOrDefault(x=>x.Name.Contains(methodName));
|
||||||
|
|
||||||
|
if (showRoleStateMachine == null)
|
||||||
|
{
|
||||||
|
Logger<MiraApiPlugin>.Error($"Failed to find {methodName} state machine for {typeName}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var moveNext = AccessTools.Method(showRoleStateMachine, "MoveNext");
|
||||||
|
if (moveNext == null)
|
||||||
|
{
|
||||||
|
Logger<MiraApiPlugin>.Error($"Failed to find MoveNext method for {typeName}.{methodName}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger<MiraApiPlugin>.Info($"Found {methodName}.MoveNext");
|
||||||
|
return moveNext;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a draggable scroller. Add items into the scroller.Inner transform. This does not automatically position children.
|
/// Creates a draggable scroller. Add items into the scroller.Inner transform. This does not automatically position children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2CppInterop.Runtime.InteropTypes;
|
||||||
|
|
||||||
|
namespace MiraAPI.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A wrapper for state machine objects to access their parent instance and state.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the parent class that owns the state machine.</typeparam>
|
||||||
|
public class StateMachineWrapper<T> where T : Il2CppObjectBase
|
||||||
|
{
|
||||||
|
private readonly Il2CppObjectBase _stateMachine;
|
||||||
|
private readonly PropertyInfo _thisProperty;
|
||||||
|
private readonly PropertyInfo _stateProperty;
|
||||||
|
|
||||||
|
private T? _parentInstance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the instance of the parent class that owns the state machine.
|
||||||
|
/// </summary>
|
||||||
|
public T Instance => _parentInstance ??= (T)_thisProperty.GetValue(_stateMachine)!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="StateMachineWrapper{T}"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stateMachine">The state machine instance to wrap.</param>
|
||||||
|
public StateMachineWrapper(Il2CppObjectBase stateMachine)
|
||||||
|
{
|
||||||
|
_stateMachine = stateMachine;
|
||||||
|
|
||||||
|
var type = _stateMachine.GetType();
|
||||||
|
_thisProperty = AccessTools.Property(type, "__4__this");
|
||||||
|
_stateProperty = AccessTools.Property(type, "__1__state");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current state of the state machine.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current state as an integer.</returns>
|
||||||
|
public int GetState() => (int)_stateProperty.GetValue(_stateMachine)!;
|
||||||
|
}
|
||||||
@@ -6,5 +6,6 @@
|
|||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
<add key="Reactor" value="https://nuget.reactor.gg/v3/index.json" />
|
<add key="Reactor" value="https://nuget.reactor.gg/v3/index.json" />
|
||||||
<add key="Samboy063" value="https://nuget.samboy.dev/v3/index.json" />
|
<add key="Samboy063" value="https://nuget.samboy.dev/v3/index.json" />
|
||||||
|
<add key="Local" value="packages/" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
</configuration>
|
</configuration>
|
||||||
Binary file not shown.
Reference in new issue
Block a user