Skip to content
Open
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
7 changes: 2 additions & 5 deletions PeasAPI/Components/RegisterCustomGameModeAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Reflection;
using BepInEx.IL2CPP;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using PeasAPI.GameModes;
using Reactor;
Expand Down Expand Up @@ -38,10 +38,7 @@ public static void Register(Assembly assembly, BasePlugin plugin)

public static void Load()
{
ChainloaderHooks.PluginLoad += plugin =>
{
Register(plugin.GetType().Assembly, plugin);
};
IL2CPPChainloader.Instance.PluginLoad += (_, assembly, plugin) => Register(assembly, plugin);
}
}
}
7 changes: 3 additions & 4 deletions PeasAPI/Components/RegisterCustomRoleAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Reflection;
using BepInEx.IL2CPP;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using PeasAPI.Roles;
using Reactor;

namespace PeasAPI.Components
{
Expand Down Expand Up @@ -34,12 +33,12 @@ public static void Register(Assembly assembly, BasePlugin plugin)

Activator.CreateInstance(type, plugin);
}
}
}
}

public static void Load()
{
ChainloaderHooks.PluginLoad += plugin => Register(plugin.GetType().Assembly, plugin);
IL2CPPChainloader.Instance.PluginLoad += (_, assembly, plugin) => Register(assembly, plugin);
}
}
}
16 changes: 4 additions & 12 deletions PeasAPI/CustomButtons/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using UnityEngine;
using Action = System.Action;
using Object = UnityEngine.Object;
using AmongUs.GameOptions;

namespace PeasAPI.CustomButtons
{
Expand Down Expand Up @@ -319,7 +320,7 @@ public PlayerControl FindClosestPlayer()
{
var from = PlayerControl.LocalPlayer;
PlayerControl result = null;
float num = GameOptionsData.KillDistances[Mathf.Clamp(PlayerControl.GameOptions.KillDistance, 0, 2)];
float num = GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)];
if (!ShipStatus.Instance)
{
return null;
Expand Down Expand Up @@ -355,8 +356,8 @@ public GameObject FindClosestObject()
var from = PlayerControl.LocalPlayer;
GameObject result1 = null;
GameObject result2 = null;
float num1 = GameOptionsData.KillDistances[Mathf.Clamp(PlayerControl.GameOptions.KillDistance, 0, 2)];
float num2 = GameOptionsData.KillDistances[Mathf.Clamp(PlayerControl.GameOptions.KillDistance, 0, 2)];
float num1 = GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)];
float num2 = GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)];
if (!ShipStatus.Instance)
{
return null;
Expand Down Expand Up @@ -430,15 +431,6 @@ public static void Prefix(HudManager __instance)
}
}

[HarmonyPatch(typeof(HudManager), nameof(HudManager.SetHudActive))]
internal static class HudManagerSetHudActivePatch
{
public static void Prefix(HudManager __instance, [HarmonyArgument(0)] bool isActive)
{
HudActive = isActive;
}
}

public enum TargetType
{
None,
Expand Down
4 changes: 2 additions & 2 deletions PeasAPI/CustomEndReason/CustomEndReason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Hazel;
using PeasAPI.CustomRpc;
using PeasAPI.Roles;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using UnityEngine;

namespace PeasAPI.CustomEndReason
Expand All @@ -12,7 +12,7 @@ public class CustomEndReason
/// <summary>
/// Ends the game with the specified values
/// </summary>
public CustomEndReason(Color color, string victoryText, string defeatText, string stinger, List<GameData.PlayerInfo> winners)
internal CustomEndReason(Color color, string victoryText, string defeatText, string stinger, List<GameData.PlayerInfo> winners)
{
Rpc<RpcCustomEndReason>.Instance.Send(new RpcCustomEndReason.Data(color, victoryText, defeatText, stinger, winners));
}
Expand Down
18 changes: 10 additions & 8 deletions PeasAPI/CustomEndReason/EndReasonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static void Reset()
[HarmonyPatch(typeof(EndGameManager), nameof(EndGameManager.SetEverythingUp))]
private class SetEverythingUpPatch
{
public static PlayerControl player1;
private static readonly Color GhostColor = new(1f, 1f, 1f, 0.5f);

public static bool Prefix(EndGameManager __instance)
Expand Down Expand Up @@ -82,21 +83,21 @@ public static bool Prefix(EndGameManager __instance)
transform.localScale = scaleVec;
if (winner.IsDead)
{
player.BodySprites.ToArray()[0].BodySprite.sprite = __instance.GhostSprite;
player.SetDeadFlipX(i % 2 == 1);
player.HatSlot.color = GhostColor;
player.cosmetics.currentBodySprite.BodySprite.sprite = __instance.GhostSprite;
player.SetDeadFlipX(i % 2 == 0);
player.cosmetics.SetHatColor(GhostColor);
}
else
{
player.SetFlipX(i % 2 == 0);
player.SetSkin(winner.SkinId, winner.ColorId);
}

PlayerControl.SetPlayerMaterialColors(winner.ColorId, player.CurrentBodySprite.BodySprite);
player.HatSlot.SetHat(winner.HatId, winner.ColorId);
PlayerControl.SetPetImage(winner.PetId, winner.ColorId, player.PetSlot);
player.NameText.text = winner.PlayerName;
player.NameText.transform.SetLocalZ(-15f);
PlayerMaterial.SetColors(winner.ColorId, player.cosmetics.currentBodySprite.BodySprite);
player.cosmetics.SetHat(winner.HatId, winner.ColorId);
// PlayerControl.SetPetImage(winner.PetId, winner.ColorId, player.cosmetics.CurrentPet);
player.NameText().text = winner.PlayerName;
player.NameText().transform.SetLocalZ(-15f);
}

SoundManager.Instance.PlaySound(__instance.DisconnectStinger, false, 1f);
Expand All @@ -105,6 +106,7 @@ public static bool Prefix(EndGameManager __instance)
}
}


[HarmonyPatch(typeof(EndGameManager), nameof(EndGameManager.Start))]
private class AdjustEndScreenPatch
{
Expand Down
4 changes: 2 additions & 2 deletions PeasAPI/CustomRpc/RpcCustomCheckColor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Hazel;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;

namespace PeasAPI.CustomRpc
{
Expand Down
6 changes: 3 additions & 3 deletions PeasAPI/CustomRpc/RpcCustomEndReason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Linq;
using Hazel;
using PeasAPI.CustomEndReason;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;
using UnityEngine;

namespace PeasAPI.CustomRpc
Expand Down Expand Up @@ -88,7 +88,7 @@ public override void Handle(PlayerControl innerNetObject, Data data)
EndReasonManager.Stinger = data.Stinger;

if (AmongUsClient.Instance.AmHost)
ShipStatus.RpcEndGame(EndReasonManager.CustomGameOverReason, false);
GameManager.Instance.RpcEndGame(EndReasonManager.CustomGameOverReason, false);
}
}
}
8 changes: 4 additions & 4 deletions PeasAPI/CustomRpc/RpcInitializeRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using PeasAPI.CustomEndReason;
using PeasAPI.GameModes;
using PeasAPI.Roles;
using Reactor;
using Reactor.Extensions;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;
using Reactor.Utilities.Extensions;

namespace PeasAPI.CustomRpc
{
Expand All @@ -27,7 +27,7 @@ public override void Handle(PlayerControl innerNetObject)

EndReasonManager.Reset();

if (AmongUsClient.Instance.GameMode != global::GameModes.FreePlay)
if (AmongUsClient.Instance.NetworkMode != global::NetworkModes.FreePlay)
{
var rolesForPlayers = new List<BaseRole>();

Expand Down
5 changes: 3 additions & 2 deletions PeasAPI/CustomRpc/RpcResetRoles.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using PeasAPI.Roles;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;


namespace PeasAPI.CustomRpc
{
Expand Down
5 changes: 3 additions & 2 deletions PeasAPI/CustomRpc/RpcSetColor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Hazel;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;


namespace PeasAPI.CustomRpc
{
Expand Down
5 changes: 3 additions & 2 deletions PeasAPI/CustomRpc/RpcSetRole.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Hazel;
using PeasAPI.Roles;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;


namespace PeasAPI.CustomRpc
{
Expand Down
5 changes: 3 additions & 2 deletions PeasAPI/CustomRpc/RpcSetVanillaRole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Hazel;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;
using AmongUs.GameOptions;

namespace PeasAPI.CustomRpc
{
Expand Down
4 changes: 2 additions & 2 deletions PeasAPI/CustomRpc/RpcShowMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using HarmonyLib;
using Hazel;
using PeasAPI.Managers;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;

namespace PeasAPI.CustomRpc
{
Expand Down
4 changes: 2 additions & 2 deletions PeasAPI/CustomRpc/RpcUpdateSetting.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Hazel;
using PeasAPI.Options;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Rpc;
using Reactor.Networking.Attributes;

namespace PeasAPI.CustomRpc
{
Expand Down
19 changes: 14 additions & 5 deletions PeasAPI/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Reactor.Extensions;
using Reactor.Utilities.Extensions;
using UnityEngine;
using PeasAPI.Extensions;

namespace PeasAPI
{
Expand Down Expand Up @@ -34,6 +35,9 @@ public CustomIntroScreen(bool overrideTeam = false, string team = null, string t
RoleColor = roleColor.GetValueOrDefault();
}
}


/*

public readonly struct Hat
{
Expand All @@ -58,7 +62,8 @@ public Hat(string name, string imagePath, Assembly assembly, bool inFront, bool
FloorImage = floorImage;
}

public HatData CreateHat()
// very hard so maybe waiting TOU to update and get the code
public HatData CreateHat(HatParent __instance)
{
try
{
Expand All @@ -68,8 +73,9 @@ public HatData CreateHat()
ImageConversion.LoadImage(tex, data, false);

var newHat = ScriptableObject.CreateInstance<HatData>();
newHat.hatViewData.viewData = ScriptableObject.CreateInstance<HatViewData>();
newHat.hatViewData.viewData.MainImage = newHat.hatViewData.viewData.LeftMainImage = Sprite.Create(
var b = __instance.GetViewData();
b.GetViewData() = ScriptableObject.CreateInstance<HatViewData>();
newHat.CreateAddressableAsset().GetAsset().MainImage = newHat.CreateAddressableAsset().GetAsset().LeftMainImage = Sprite.Create(
tex,
new Rect(0, 0, tex.width, tex.height),
new Vector2(0.53f, 0.575f),
Expand All @@ -96,6 +102,7 @@ public HatData CreateHat()
PeasAPI.Logger.LogError($"Error while creating a hat: {e}");
}


return null;
}
}
Expand All @@ -118,6 +125,7 @@ public Visor(string name, string imagePath, Assembly assembly, Vector2 chipOffse
ClimbImage = climbImage;
FloorImage = floorImage;
}


public VisorData CreateVisor()
{
Expand All @@ -129,7 +137,7 @@ public VisorData CreateVisor()
ImageConversion.LoadImage(tex, data, false);

var newVisor = ScriptableObject.CreateInstance<VisorData>();
newVisor.viewData.viewData = ScriptableObject.CreateInstance<VisorViewData>();
newVisor.CreateAddressableAsset().GetAsset(). = ScriptableObject.CreateInstance<VisorViewData>();
newVisor.viewData.viewData.IdleFrame = newVisor.viewData.viewData.LeftIdleFrame = Sprite.Create(
tex,
new Rect(0, 0, tex.width, tex.height),
Expand All @@ -156,5 +164,6 @@ public VisorData CreateVisor()
return null;
}
}
*/
}
}
Loading