Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion EmotesMod/EmotesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace EmotesMod;

[BepInAutoPlugin("EmotesMod", "Emotes Mod", "1.1.2")]
[BepInAutoPlugin("EmotesMod", "Emotes Mod", "1.2.0")]
[BepInProcess("Among Us.exe")]
[ReactorModFlags(ModFlags.RequireOnAllClients)]
[BepInDependency(ReactorPlugin.Id)]
Expand All @@ -23,6 +23,7 @@ public partial class EmotesPlugin : BasePlugin
public override void Load()
{
ClassInjector.RegisterTypeInIl2Cpp<Emote>();
ClassInjector.RegisterTypeInIl2Cpp<EmoteWheel>();
ClassInjector.RegisterTypeInIl2Cpp<EmoteWheelItem>();
ClassInjector.RegisterTypeInIl2Cpp<EmoteBehaviour>();
ClassInjector.RegisterTypeInIl2Cpp<EmoteWheel>();
Expand Down
6 changes: 3 additions & 3 deletions EmotesMod/Modules/Components/EmoteBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public void PlayEmote()

public IEnumerator CoHandleIdleEmote(bool loop)
{
if (pc.amOwner) HudManagerPatches.EmoteCanvas.transform.GetChild(1).gameObject.SetActive(true);
if (pc.AmOwner) HudManagerPatches.EmoteCanvas.transform.GetChild(1).gameObject.SetActive(true);
pc.cosmetics.gameObject.SetActive(false);
if (loop)
{
Vector2 originalPos = pc.GetTruePosition();
while (originalPos == pc.GetTruePosition())
while (currentEmote && originalPos == pc.GetTruePosition())
{
pc.MyPhysics.Animations.Animator.Play(currentEmote.anim.Value);
yield return new WaitForSeconds(currentEmote.anim.Value.length);
Expand All @@ -40,7 +40,7 @@ public IEnumerator CoHandleIdleEmote(bool loop)
pc.cosmetics.gameObject.SetActive(true);
currentEmote = null!;
pc.MyPhysics.Animations.PlayIdleAnimation();
HudManagerPatches.EmoteCanvas.transform.GetChild(1).gameObject.SetActive(false);
if (pc.AmOwner) HudManagerPatches.EmoteCanvas.transform.GetChild(1).gameObject.SetActive(false);
yield break;
}

Expand Down
65 changes: 37 additions & 28 deletions EmotesMod/Patches/HudManagerPatches.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using EmotesMod.Modules.Components;
using HarmonyLib;
using Rewired;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Object = UnityEngine.Object;

Expand All @@ -12,63 +10,74 @@ namespace EmotesMod.Patches;
[HarmonyPatch]
public class HudManagerPatches
{
public static GameObject EmoteCanvas;

private static GameObject _emoteCanvas;

public static GameObject EmoteCanvas
{
get
{
if (_emoteCanvas.IsDestroyedOrNull()) LazyInstantiateHud();

return _emoteCanvas;
}
}

[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
[HarmonyPostfix]
public static void HudManager_Update_Postfix(HudManager __instance)
{
if (EmoteCanvas == null) return;

if (/*ReInput.players.GetPlayer(0).GetButtonDown(InputPatches.OpenEmoteWheelBind.id)*/ Input.GetKeyDown(KeyCode.E) && Input.GetKey(KeyCode.LeftControl) && PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead)
if ( /*ReInput.players.GetPlayer(0).GetButtonDown(InputPatches.OpenEmoteWheelBind.id)*/
Input.GetKeyDown(KeyCode.E) && Input.GetKey(KeyCode.LeftControl) && PlayerControl.LocalPlayer &&
!PlayerControl.LocalPlayer.Data.IsDead)
{
var wheel = EmoteCanvas.transform.GetChild(0).gameObject;
wheel.SetActive(!wheel.activeSelf);
}

if (/*ReInput.players.GetPlayer(0).GetButtonDown(InputPatches.StopEmotingBind.id)*/ Input.GetKeyDown(KeyCode.X)&& PlayerControl.LocalPlayer.GetComponent<EmoteBehaviour>().currentEmote)
{
if ( /*ReInput.players.GetPlayer(0).GetButtonDown(InputPatches.StopEmotingBind.id)*/
Input.GetKeyDown(KeyCode.X) && PlayerControl.LocalPlayer.GetComponent<EmoteBehaviour>().currentEmote)
PlayerControl.LocalPlayer.RpcStopEmote();
}
}

[HarmonyPatch(typeof(HudManager), nameof(HudManager.Start))]
[HarmonyPostfix]
public static void HudManager_Start_Postfix(HudManager __instance)
{
EmoteCanvas = Object.Instantiate(Assets.EmoteCanvas);
EmoteCanvas.transform.GetChild(0).gameObject.SetActive(false);
EmoteCanvas.transform.GetChild(1).gameObject.SetActive(false);
EmoteCanvas.transform.GetChild(1).GetChild(1).GetComponent<Button>().onClick.AddListener(new Action(() =>
{
PlayerControl.LocalPlayer.RpcStopEmote();
EmoteCanvas.transform.GetChild(1).gameObject.SetActive(false);
}));

if (OperatingSystem.IsAndroid())
{
CreateButtonAndroid();
}
else
__instance.Chat.AddChatWarning(
"<size=150%>Thanks for downloading Emotes Mod!</size>\nTo open the emote wheel, press Control + E!");
}

private static void LazyInstantiateHud()
{
if (!_emoteCanvas.IsDestroyedOrNull()) return;

_emoteCanvas = Object.Instantiate(Assets.EmoteCanvas);
_emoteCanvas.transform.GetChild(0).gameObject.SetActive(false);
_emoteCanvas.transform.GetChild(1).gameObject.SetActive(false);
_emoteCanvas.transform.GetChild(1).GetChild(1).GetComponent<Button>().onClick.AddListener(new Action(() =>
{
__instance.Chat.AddChatWarning("<size=150%>Thanks for downloading Emotes Mod!</size>\nTo open the emote wheel, press Control + E!");
}
PlayerControl.LocalPlayer.RpcStopEmote();
_emoteCanvas.transform.GetChild(1).gameObject.SetActive(false);
}));
}

public static void CreateButtonAndroid()
private static void CreateButtonAndroid()
{
var button = UnityEngine.Object
var button = Object
.Instantiate(HudManager.Instance.SettingsButton, HudManager.Instance.SettingsButton.transform.parent)
.GetComponent<PassiveButton>();
button.gameObject.name = "EmoteButton";
button.OnClick = new();
button.OnClick = new Button.ButtonClickedEvent();
button.OnClick.AddListener(new Action(() =>
{
var wheel = EmoteCanvas.transform.GetChild(0).gameObject;
wheel.SetActive(!wheel.activeSelf);
}));
button.activeSprites.GetComponent<SpriteRenderer>().sprite = Assets.EmoteButtonHover;
button.inactiveSprites.GetComponent<SpriteRenderer>().sprite = Assets.EmoteButton;
button.GetComponent<AspectPosition>().DistanceFromEdge = new(4.75f, 0.505f, -400f);
button.GetComponent<AspectPosition>().DistanceFromEdge = new Vector3(4.75f, 0.505f, -400f);
}
}
7 changes: 2 additions & 5 deletions EmotesMod/Patches/PlayerControlPatches.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Linq;
using EmotesMod.Modules.Components;
using HarmonyLib;
using Rewired;
using UnityEngine;

namespace EmotesMod.Patches;

Expand All @@ -16,7 +13,7 @@ public static void PlayerControl_Awake_Postfix(PlayerControl __instance)
__instance.gameObject.AddComponent<EmoteBehaviour>().pc = __instance;
__instance.MyPhysics.Animations.glowAnimator.gameObject.SetActive(false);
}

[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.HandleAnimation))]
[HarmonyPrefix]
public static bool PlayerPhysics_Awake_Prefix(PlayerPhysics __instance)
Expand All @@ -31,7 +28,7 @@ public static bool PlayerPhysics_Awake_Prefix(PlayerPhysics __instance)

return true;
}

[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.Die))]
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.OnGameEnd))]
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.OnGameStart))]
Expand Down
Binary file removed EmotesMod/Resources/emotes-android.bundle
Binary file not shown.
Binary file modified EmotesMod/Resources/emotes-win.bundle
Binary file not shown.
Loading