From 24546938b6d72611c5b50d3c2ef9af627c9f4f9c Mon Sep 17 00:00:00 2001
From: AmongUsModdingDev <137340286+AmongUsDev@users.noreply.github.com>
Date: Mon, 26 Jun 2023 11:59:01 +0100
Subject: [PATCH 1/3] Update README.md
---
README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 855dbab..1fe101b 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
-# PeasAPI
+# PeasAPI-R
API for making Among Us mods
+Reactivited
+
+__**Soon for the latest version of among us**__
*This mod is not affiliated with Among Us or Innersloth LLC, and the content contained therein is not endorsed or otherwise sponsored by Innersloth LLC. Portions of the materials contained herein are property of Innersloth LLC. © Innersloth LLC.*
From 6e053c8808c0110227cb2d842299447b0338cb2d Mon Sep 17 00:00:00 2001
From: AmongUsModdingDev <137340286+AmongUsDev@users.noreply.github.com>
Date: Tue, 27 Jun 2023 14:26:07 +0000
Subject: [PATCH 2/3] Bring to AU 2023.6.13
---
.../RegisterCustomGameModeAttribute.cs | 7 +-
.../Components/RegisterCustomRoleAttribute.cs | 7 +-
PeasAPI/CustomButtons/CustomButton.cs | 16 +-
PeasAPI/CustomEndReason/CustomEndReason.cs | 4 +-
PeasAPI/CustomEndReason/EndReasonManager.cs | 18 +-
PeasAPI/CustomRpc/RpcCustomCheckColor.cs | 4 +-
PeasAPI/CustomRpc/RpcCustomEndReason.cs | 6 +-
PeasAPI/CustomRpc/RpcInitializeRoles.cs | 8 +-
PeasAPI/CustomRpc/RpcResetRoles.cs | 5 +-
PeasAPI/CustomRpc/RpcSetColor.cs | 5 +-
PeasAPI/CustomRpc/RpcSetRole.cs | 5 +-
PeasAPI/CustomRpc/RpcSetVanillaRole.cs | 5 +-
PeasAPI/CustomRpc/RpcShowMessage.cs | 4 +-
PeasAPI/CustomRpc/RpcUpdateSetting.cs | 4 +-
PeasAPI/Data.cs | 19 +-
PeasAPI/{ => Extension}/Extensions.cs | 34 ++--
PeasAPI/Extension/HatParentExtension.cs | 20 ++
PeasAPI/GameModes/GameMode.cs | 3 +-
PeasAPI/GameModes/Patches.cs | 30 ++-
PeasAPI/Managers/CustomColorManager.cs | 23 ++-
PeasAPI/Managers/CustomHatManager.cs | 6 +-
PeasAPI/Managers/PlayerMenuManager.cs | 10 +-
PeasAPI/Managers/TextMessageManager.cs | 9 +-
PeasAPI/Managers/UpdateManager.cs | 3 +-
.../Managers/UpdateTools/UpdateListener.cs | 11 +-
PeasAPI/Managers/WatermarkManager.cs | 23 +--
PeasAPI/Options/CustomNumberOption.cs | 6 +-
PeasAPI/Options/CustomOptionButton.cs | 6 +-
PeasAPI/Options/CustomOptionHeader.cs | 6 +-
PeasAPI/Options/CustomRoleOption.cs | 18 +-
PeasAPI/Options/CustomStringOption.cs | 10 +-
PeasAPI/Options/CustomToggleOption.cs | 14 +-
PeasAPI/Options/Patches.cs | 177 +++++++++++-------
PeasAPI/Patches.cs | 11 +-
PeasAPI/PeasAPI.cs | 19 +-
PeasAPI/PeasAPI.csproj | 19 +-
PeasAPI/Roles/AssignRoleOnDeath.cs | 22 +++
PeasAPI/Roles/BaseRole.cs | 31 +--
PeasAPI/Roles/Patches.cs | 93 ++++-----
PeasAPI/Roles/RoleManager.cs | 21 ++-
PeasAPI/Utility.cs | 45 ++++-
PeasAPI/nuget.config | 1 +
README.md | 8 +-
43 files changed, 446 insertions(+), 350 deletions(-)
rename PeasAPI/{ => Extension}/Extensions.cs (88%)
create mode 100644 PeasAPI/Extension/HatParentExtension.cs
create mode 100644 PeasAPI/Roles/AssignRoleOnDeath.cs
diff --git a/PeasAPI/Components/RegisterCustomGameModeAttribute.cs b/PeasAPI/Components/RegisterCustomGameModeAttribute.cs
index 6ab7acb..ac38eae 100644
--- a/PeasAPI/Components/RegisterCustomGameModeAttribute.cs
+++ b/PeasAPI/Components/RegisterCustomGameModeAttribute.cs
@@ -1,6 +1,6 @@
using System;
using System.Reflection;
-using BepInEx.IL2CPP;
+using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using PeasAPI.GameModes;
using Reactor;
@@ -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);
}
}
}
\ No newline at end of file
diff --git a/PeasAPI/Components/RegisterCustomRoleAttribute.cs b/PeasAPI/Components/RegisterCustomRoleAttribute.cs
index 97e8cf7..d5477d3 100644
--- a/PeasAPI/Components/RegisterCustomRoleAttribute.cs
+++ b/PeasAPI/Components/RegisterCustomRoleAttribute.cs
@@ -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
{
@@ -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);
}
}
}
\ No newline at end of file
diff --git a/PeasAPI/CustomButtons/CustomButton.cs b/PeasAPI/CustomButtons/CustomButton.cs
index 9c9c6e7..2b8d195 100644
--- a/PeasAPI/CustomButtons/CustomButton.cs
+++ b/PeasAPI/CustomButtons/CustomButton.cs
@@ -5,6 +5,7 @@
using UnityEngine;
using Action = System.Action;
using Object = UnityEngine.Object;
+using AmongUs.GameOptions;
namespace PeasAPI.CustomButtons
{
@@ -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;
@@ -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;
@@ -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,
diff --git a/PeasAPI/CustomEndReason/CustomEndReason.cs b/PeasAPI/CustomEndReason/CustomEndReason.cs
index a21edd1..adc88d8 100644
--- a/PeasAPI/CustomEndReason/CustomEndReason.cs
+++ b/PeasAPI/CustomEndReason/CustomEndReason.cs
@@ -2,7 +2,7 @@
using Hazel;
using PeasAPI.CustomRpc;
using PeasAPI.Roles;
-using Reactor.Networking;
+using Reactor.Networking.Rpc;
using UnityEngine;
namespace PeasAPI.CustomEndReason
@@ -12,7 +12,7 @@ public class CustomEndReason
///
/// Ends the game with the specified values
///
- public CustomEndReason(Color color, string victoryText, string defeatText, string stinger, List winners)
+ internal CustomEndReason(Color color, string victoryText, string defeatText, string stinger, List winners)
{
Rpc.Instance.Send(new RpcCustomEndReason.Data(color, victoryText, defeatText, stinger, winners));
}
diff --git a/PeasAPI/CustomEndReason/EndReasonManager.cs b/PeasAPI/CustomEndReason/EndReasonManager.cs
index 5a935f1..a4eae11 100644
--- a/PeasAPI/CustomEndReason/EndReasonManager.cs
+++ b/PeasAPI/CustomEndReason/EndReasonManager.cs
@@ -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)
@@ -82,9 +83,9 @@ 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
{
@@ -92,11 +93,11 @@ public static bool Prefix(EndGameManager __instance)
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);
@@ -105,6 +106,7 @@ public static bool Prefix(EndGameManager __instance)
}
}
+
[HarmonyPatch(typeof(EndGameManager), nameof(EndGameManager.Start))]
private class AdjustEndScreenPatch
{
diff --git a/PeasAPI/CustomRpc/RpcCustomCheckColor.cs b/PeasAPI/CustomRpc/RpcCustomCheckColor.cs
index 4cde6dc..a67d5f1 100644
--- a/PeasAPI/CustomRpc/RpcCustomCheckColor.cs
+++ b/PeasAPI/CustomRpc/RpcCustomCheckColor.cs
@@ -1,6 +1,6 @@
using Hazel;
-using Reactor;
-using Reactor.Networking;
+using Reactor.Networking.Rpc;
+using Reactor.Networking.Attributes;
namespace PeasAPI.CustomRpc
{
diff --git a/PeasAPI/CustomRpc/RpcCustomEndReason.cs b/PeasAPI/CustomRpc/RpcCustomEndReason.cs
index 98841f1..d1745d4 100644
--- a/PeasAPI/CustomRpc/RpcCustomEndReason.cs
+++ b/PeasAPI/CustomRpc/RpcCustomEndReason.cs
@@ -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
@@ -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);
}
}
}
\ No newline at end of file
diff --git a/PeasAPI/CustomRpc/RpcInitializeRoles.cs b/PeasAPI/CustomRpc/RpcInitializeRoles.cs
index a95001e..6e10ef7 100644
--- a/PeasAPI/CustomRpc/RpcInitializeRoles.cs
+++ b/PeasAPI/CustomRpc/RpcInitializeRoles.cs
@@ -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
{
@@ -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();
diff --git a/PeasAPI/CustomRpc/RpcResetRoles.cs b/PeasAPI/CustomRpc/RpcResetRoles.cs
index 9df2f3f..571288e 100644
--- a/PeasAPI/CustomRpc/RpcResetRoles.cs
+++ b/PeasAPI/CustomRpc/RpcResetRoles.cs
@@ -1,6 +1,7 @@
using PeasAPI.Roles;
-using Reactor;
-using Reactor.Networking;
+using Reactor.Networking.Rpc;
+using Reactor.Networking.Attributes;
+
namespace PeasAPI.CustomRpc
{
diff --git a/PeasAPI/CustomRpc/RpcSetColor.cs b/PeasAPI/CustomRpc/RpcSetColor.cs
index 47bc526..aaa8e10 100644
--- a/PeasAPI/CustomRpc/RpcSetColor.cs
+++ b/PeasAPI/CustomRpc/RpcSetColor.cs
@@ -1,6 +1,7 @@
using Hazel;
-using Reactor;
-using Reactor.Networking;
+using Reactor.Networking.Rpc;
+using Reactor.Networking.Attributes;
+
namespace PeasAPI.CustomRpc
{
diff --git a/PeasAPI/CustomRpc/RpcSetRole.cs b/PeasAPI/CustomRpc/RpcSetRole.cs
index fb46441..d1fff89 100644
--- a/PeasAPI/CustomRpc/RpcSetRole.cs
+++ b/PeasAPI/CustomRpc/RpcSetRole.cs
@@ -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
{
diff --git a/PeasAPI/CustomRpc/RpcSetVanillaRole.cs b/PeasAPI/CustomRpc/RpcSetVanillaRole.cs
index 3abbd68..fe44c75 100644
--- a/PeasAPI/CustomRpc/RpcSetVanillaRole.cs
+++ b/PeasAPI/CustomRpc/RpcSetVanillaRole.cs
@@ -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
{
diff --git a/PeasAPI/CustomRpc/RpcShowMessage.cs b/PeasAPI/CustomRpc/RpcShowMessage.cs
index 59b785b..85a3923 100644
--- a/PeasAPI/CustomRpc/RpcShowMessage.cs
+++ b/PeasAPI/CustomRpc/RpcShowMessage.cs
@@ -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
{
diff --git a/PeasAPI/CustomRpc/RpcUpdateSetting.cs b/PeasAPI/CustomRpc/RpcUpdateSetting.cs
index 513dc9b..c9becb8 100644
--- a/PeasAPI/CustomRpc/RpcUpdateSetting.cs
+++ b/PeasAPI/CustomRpc/RpcUpdateSetting.cs
@@ -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
{
diff --git a/PeasAPI/Data.cs b/PeasAPI/Data.cs
index 1331e56..8f8f60b 100644
--- a/PeasAPI/Data.cs
+++ b/PeasAPI/Data.cs
@@ -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
{
@@ -34,6 +35,9 @@ public CustomIntroScreen(bool overrideTeam = false, string team = null, string t
RoleColor = roleColor.GetValueOrDefault();
}
}
+
+
+ /*
public readonly struct Hat
{
@@ -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
{
@@ -68,8 +73,9 @@ public HatData CreateHat()
ImageConversion.LoadImage(tex, data, false);
var newHat = ScriptableObject.CreateInstance();
- newHat.hatViewData.viewData = ScriptableObject.CreateInstance();
- newHat.hatViewData.viewData.MainImage = newHat.hatViewData.viewData.LeftMainImage = Sprite.Create(
+ var b = __instance.GetViewData();
+ b.GetViewData() = ScriptableObject.CreateInstance();
+ 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),
@@ -96,6 +102,7 @@ public HatData CreateHat()
PeasAPI.Logger.LogError($"Error while creating a hat: {e}");
}
+
return null;
}
}
@@ -118,6 +125,7 @@ public Visor(string name, string imagePath, Assembly assembly, Vector2 chipOffse
ClimbImage = climbImage;
FloorImage = floorImage;
}
+
public VisorData CreateVisor()
{
@@ -129,7 +137,7 @@ public VisorData CreateVisor()
ImageConversion.LoadImage(tex, data, false);
var newVisor = ScriptableObject.CreateInstance();
- newVisor.viewData.viewData = ScriptableObject.CreateInstance();
+ newVisor.CreateAddressableAsset().GetAsset(). = ScriptableObject.CreateInstance();
newVisor.viewData.viewData.IdleFrame = newVisor.viewData.viewData.LeftIdleFrame = Sprite.Create(
tex,
new Rect(0, 0, tex.width, tex.height),
@@ -156,5 +164,6 @@ public VisorData CreateVisor()
return null;
}
}
+ */
}
}
\ No newline at end of file
diff --git a/PeasAPI/Extensions.cs b/PeasAPI/Extension/Extensions.cs
similarity index 88%
rename from PeasAPI/Extensions.cs
rename to PeasAPI/Extension/Extensions.cs
index 761240b..68fd009 100644
--- a/PeasAPI/Extensions.cs
+++ b/PeasAPI/Extension/Extensions.cs
@@ -1,18 +1,16 @@
using System.Linq;
-using HarmonyLib;
using PeasAPI.CustomRpc;
using PeasAPI.Options;
using PeasAPI.Roles;
-using Reactor.Extensions;
-using Reactor.Networking;
-using Reactor.Networking.MethodRpc;
-using UnhollowerBaseLib;
+using Reactor.Utilities.Extensions;
+using Reactor.Networking.Extensions;
+using Reactor.Networking.Rpc;
using UnityEngine;
-using Object = Il2CppSystem.Object;
+using AmongUs.GameOptions;
namespace PeasAPI
{
- public static class Extensions
+ public static class Extension
{
///
/// Gets a from it's id
@@ -39,12 +37,12 @@ public static void ToggleOutline(this PlayerControl player, bool active, Color c
{
if (active)
{
- player.MyRend.material.SetFloat("_Outline", 1f);
- player.MyRend.material.SetColor("_OutlineColor", color);
+ player.myRend().material.SetFloat("_Outline", 1f);
+ player.myRend().material.SetColor("_OutlineColor", color);
return;
}
- player.MyRend.material.SetFloat("_Outline", 0f);
+ player.myRend().material.SetFloat("_Outline", 0f);
}
public static Color SetAlpha(this Color original, float alpha)
@@ -160,8 +158,8 @@ public static void SetRole(this PlayerControl player, BaseRole? role)
HudManager.Instance.KillButton.gameObject.SetActive(isImpostor && !isDead);
HudManager.Instance.ImpostorVentButton.gameObject.SetActive(isImpostor && !isDead);
- player.nameText.color = isImpostor ? Palette.ImpostorRed : Color.white;
- player.nameText.text = player.name;
+ player.nameText().color = isImpostor ? Palette.ImpostorRed : Color.white;
+ player.nameText().text = player.name;
}
}
@@ -177,7 +175,7 @@ public static void SetVanillaRole(this PlayerControl player, RoleTypes role)
HudManager.Instance.MapButton.gameObject.SetActive(true);
HudManager.Instance.ReportButton.gameObject.SetActive(true);
HudManager.Instance.UseButton.gameObject.SetActive(true);
- PlayerControl.LocalPlayer.RemainingEmergencies = PlayerControl.GameOptions.NumEmergencyMeetings;
+ PlayerControl.LocalPlayer.RemainingEmergencies = GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings;
RoleManager.Instance.SetRole(player, role);
player.Data.Role.SpawnTaskHeader(player);
if (!DestroyableSingleton.InstanceExists)
@@ -188,11 +186,11 @@ public static void SetVanillaRole(this PlayerControl player, RoleTypes role)
{
if (pc.Data.Role.TeamType == PlayerControl.LocalPlayer.Data.Role.TeamType)
{
- pc.nameText.color = pc.Data.Role.NameColor;
+ pc.nameText().color = pc.Data.Role.NameColor;
}
else
{
- pc.nameText.color = Palette.White;
+ pc.nameText().color = Palette.White;
}
});
}
@@ -348,6 +346,12 @@ public static Vector3 SetZ(this Transform transform, float z)
transform.position = vector;
return vector;
}
+
+ public static TMPro.TextMeshPro nameText(this PlayerControl p) => p.cosmetics.nameText;
+
+ public static TMPro.TextMeshPro NameText(this PoolablePlayer p) => p.cosmetics.nameText;
+
+ public static UnityEngine.SpriteRenderer myRend(this PlayerControl p) => p.cosmetics.currentBodySprite.BodySprite;
#endregion
}
}
\ No newline at end of file
diff --git a/PeasAPI/Extension/HatParentExtension.cs b/PeasAPI/Extension/HatParentExtension.cs
new file mode 100644
index 0000000..fd06942
--- /dev/null
+++ b/PeasAPI/Extension/HatParentExtension.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+namespace PeasAPI.Extensions;
+
+public static class HatParentExtensions
+{
+ public static Dictionary HatViewDataRegistry = new();
+ public static HatViewData GetViewData(this HatParent parent)
+ {
+ if (!parent || !parent.Hat) return null;
+ return HatViewDataRegistry.TryGetValue(parent.Hat.ProductId, out var asset) ? asset : parent.hatDataAsset?.GetAsset();
+ }
+
+ public static bool IsModdedHat(this HatParent parent)
+ {
+ if (!parent || !parent.Hat) return false;
+ return HatViewDataRegistry.ContainsKey(parent.Hat.ProductId);
+ }
+}
\ No newline at end of file
diff --git a/PeasAPI/GameModes/GameMode.cs b/PeasAPI/GameModes/GameMode.cs
index ced0ca2..9074c04 100644
--- a/PeasAPI/GameModes/GameMode.cs
+++ b/PeasAPI/GameModes/GameMode.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
-using BepInEx.IL2CPP;
+using BepInEx.Unity.IL2CPP;
+using AmongUs.GameOptions;
namespace PeasAPI.GameModes
{
diff --git a/PeasAPI/GameModes/Patches.cs b/PeasAPI/GameModes/Patches.cs
index 3f34ec8..e8458fc 100644
--- a/PeasAPI/GameModes/Patches.cs
+++ b/PeasAPI/GameModes/Patches.cs
@@ -2,14 +2,17 @@
using System.Linq;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
-using Reactor;
+using AmongUs.GameOptions;
using UnityEngine;
+using Reactor.Localization.Utilities;
namespace PeasAPI.GameModes
{
[HarmonyPatch]
public static class Patches
{
+ public static MapBehaviour map;
+
[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.Start))]
class ShipStatusStartPatch
{
@@ -23,10 +26,10 @@ public static void Prefix(ShipStatus __instance)
}
}
- [HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.RpcEndGame))]
+ [HarmonyPatch(typeof(GameManager), nameof(GameManager.RpcEndGame))]
class ShipStatusRpcEndGamePatch
{
- public static bool Prefix(ShipStatus __instance, [HarmonyArgument(0)] GameOverReason reason)
+ public static bool Prefix(GameManager __instance, [HarmonyArgument(0)] GameOverReason reason)
{
foreach (var mode in GameModeManager.Modes)
{
@@ -125,22 +128,19 @@ public static bool Prefix(SabotageButton __instance)
{
if (mode.Enabled)
{
- HudManager.Instance.ShowMap((Action) (map =>
- {
foreach (MapRoom mapRoom in map.infectedOverlay.rooms.ToArray())
{
mapRoom.gameObject.SetActive(mode.AllowSabotage(mapRoom.room));
}
map.ShowSabotageMap();
- }));
+ };
- return false;
}
+ return false;
}
+ return true;
}
-
- return true;
}
}
@@ -155,13 +155,12 @@ public static void Prefix(MapBehaviour __instance)
{
if (mode.Enabled)
{
- HudManager.Instance.ShowMap((Action) (map =>
{
- foreach (MapRoom mapRoom in map.infectedOverlay.rooms.ToArray())
+ foreach (MapRoom mapRoom in __instance.infectedOverlay.rooms.ToArray())
{
mapRoom.gameObject.SetActive(mode.AllowSabotage(mapRoom.room));
}
- }));
+ };
}
}
}
@@ -183,10 +182,10 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] GameDat
}
}
- [HarmonyPatch(typeof(PlayerControl._CoSetTasks_d__112), nameof(PlayerControl._CoSetTasks_d__112.MoveNext))]
+ [HarmonyPatch(typeof(PlayerControl._CoSetTasks_d__114), nameof(PlayerControl._CoSetTasks_d__114.MoveNext))]
public static class PlayerControlSetTasks
{
- public static void Postfix(PlayerControl._CoSetTasks_d__112 __instance)
+ public static void Postfix(PlayerControl._CoSetTasks_d__114 __instance)
{
if (__instance == null)
return;
@@ -210,7 +209,6 @@ public static void Postfix(PlayerControl._CoSetTasks_d__112 __instance)
}
}
}
- }
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowTeam))]
[HarmonyPostfix]
@@ -292,7 +290,7 @@ public static void RoleTeamPatch(IntroCutscene __instance, [HarmonyArgument(0)]
[HarmonyPostfix]
static void SetupGameModeSetting(AmongUsClient __instance)
{
- GameModeManager.GameModeOption.Values = GameModeManager.Modes.ConvertAll(mode => mode.Name).Prepend("None").ToList().ConvertAll(mode => (StringNames) CustomStringName.Register(mode));
+ GameModeManager.GameModeOption.Values = GameModeManager.Modes.ConvertAll(mode => mode.Name).Prepend("None").ToList().ConvertAll(mode => (StringNames) CustomStringName.CreateAndRegister(mode));
}
}
}
\ No newline at end of file
diff --git a/PeasAPI/Managers/CustomColorManager.cs b/PeasAPI/Managers/CustomColorManager.cs
index cdbcd36..2a0c8c5 100644
--- a/PeasAPI/Managers/CustomColorManager.cs
+++ b/PeasAPI/Managers/CustomColorManager.cs
@@ -1,3 +1,4 @@
+/*
using System;
using System.Collections.Generic;
using System.Linq;
@@ -5,12 +6,13 @@
using HarmonyLib;
using InnerNet;
using PeasAPI.CustomRpc;
-using Reactor;
-using Reactor.Extensions;
-using Reactor.Networking;
-using UnhollowerBaseLib;
+using Reactor.Utilities;
+using Reactor.Utilities.Extensions;
+using Reactor.Localization.Utilities;
+using Il2CppInterop.Runtime.InteropTypes.Arrays;
using UnityEngine;
using Object = UnityEngine.Object;
+using AmongUs.Data.Legacy;
namespace PeasAPI.Managers
{
@@ -61,7 +63,7 @@ public AUColor(Color body, Color shadow, string name)
{
Body = body;
Shadow = shadow;
- Name = CustomStringName.Register(name);
+ Name = CustomStringName.CreateAndRegister(name);
}
}
@@ -138,7 +140,7 @@ private static void OnEnablePostfix(PlayerTab __instance)
[HarmonyPatch(nameof(PlayerTab.SelectColor))]
private static void SelectColor(PlayerTab __instance, int colorId)
{
- __instance.PlayerPreview.HatSlot.SetHat(SaveManager.LastHat, colorId);
+ __instance.PlayerPreview.SetHat(LegacySaveManager.LastHat, colorId);
}
}
@@ -169,7 +171,7 @@ private static bool RpcSetColor(byte bodyColor, PlayerControl __instance)
Rpc.Instance.Send(new RpcSetColor.Data(__instance, bodyColor));
return false;
- }*/
+ }
// It does the same as the original one
// But needed because it sends vanilla RPC for some reason
@@ -197,12 +199,12 @@ bool ColorIsOccupied(GameData.PlayerInfo p)
}
// Prevent custom color from being saved inside SaveManager
- [HarmonyPatch(typeof(SaveManager), nameof(SaveManager.BodyColor))]
- private static class SaveManagerPatch
+ [HarmonyPatch(typeof(LegacySaveManager), nameof(LegacySaveManager.BodyColor))]
+ private static class LegacySaveManagerPatch
{
private const byte MAXColor = 17;
private static ConfigEntry Data => PeasAPI.ConfigFile
- .Bind("CustomSaveManager", "Player Color ID", (byte) SaveManager.colorConfig);
+ .Bind("CustomSaveManager", "Player Color ID", (byte) LegacySaveManager.colorConfig);
[HarmonyPrefix]
[HarmonyPatch(MethodType.Getter)]
@@ -233,3 +235,4 @@ private static bool SetterPatch(byte value)
}
}
}
+*/
\ No newline at end of file
diff --git a/PeasAPI/Managers/CustomHatManager.cs b/PeasAPI/Managers/CustomHatManager.cs
index e6a46d4..c0d3170 100644
--- a/PeasAPI/Managers/CustomHatManager.cs
+++ b/PeasAPI/Managers/CustomHatManager.cs
@@ -1,4 +1,5 @@
-using System;
+/*
+using System;
using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
@@ -56,4 +57,5 @@ public static void Prefix(HatManager __instance)
__instance.allVisors.ToArray().ToList().Sort((h1, h2) => String.Compare(h2.ProductId, h1.ProductId, StringComparison.Ordinal));
}
}
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file
diff --git a/PeasAPI/Managers/PlayerMenuManager.cs b/PeasAPI/Managers/PlayerMenuManager.cs
index eaf3623..47483a5 100644
--- a/PeasAPI/Managers/PlayerMenuManager.cs
+++ b/PeasAPI/Managers/PlayerMenuManager.cs
@@ -3,8 +3,8 @@
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
-using Newtonsoft.Json.Utilities;
-using Reactor;
+using System.Text.Json;
+using Reactor.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
@@ -112,7 +112,7 @@ private static void CloseMenu()
Instance.DespawnOnDestroy = false;
ConsoleJoystick.SetMode_Task();
Camera.main.GetComponent().Locked = false;
- DestroyableSingleton.Instance.SetHudActive(true);
+ // DestroyableSingleton.Instance.SetHudActive(false);
ControllerManager.Instance.ResetAll();
Object.Destroy(Instance.gameObject);
IsMenuOpen = false;
@@ -121,7 +121,7 @@ private static void CloseMenu()
[HarmonyPatch]
internal static class Patches
{
- [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CoStartMeeting))]
+ [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.StartMeeting))]
[HarmonyPrefix]
public static void OnMeetingStartPatch(PlayerControl __instance)
{
@@ -139,7 +139,7 @@ public static void MeetingHudOnStartPatch(MeetingHud __instance)
{
HudManager.Instance.Chat.SetPosition(null);
HudManager.Instance.Chat.SetVisible(false);
- __instance.discussionTimer = 20;
+ __instance.discussionTimer = 21;
}
}
diff --git a/PeasAPI/Managers/TextMessageManager.cs b/PeasAPI/Managers/TextMessageManager.cs
index fe3992d..bb2897e 100644
--- a/PeasAPI/Managers/TextMessageManager.cs
+++ b/PeasAPI/Managers/TextMessageManager.cs
@@ -1,10 +1,11 @@
using System.Collections;
using System.Collections.Generic;
-using BepInEx.IL2CPP.Utils.Collections;
+using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using PeasAPI.CustomRpc;
-using Reactor.Extensions;
-using Reactor.Networking;
+using Reactor.Utilities.Extensions;
+using Reactor.Utilities;
+using Reactor.Networking.Rpc;
using TMPro;
using UnityEngine;
@@ -16,7 +17,7 @@ public static class TextMessageManager
public static void ShowMessage(string message, float duration)
{
- Reactor.Coroutines.Start(CoShowText(message, duration));
+ Coroutines.Start(CoShowText(message, duration));
}
public static void RpcShowMessage(string message, float duration, List targets)
diff --git a/PeasAPI/Managers/UpdateManager.cs b/PeasAPI/Managers/UpdateManager.cs
index ef01d58..41561d9 100644
--- a/PeasAPI/Managers/UpdateManager.cs
+++ b/PeasAPI/Managers/UpdateManager.cs
@@ -5,8 +5,7 @@
using System.Text;
using PeasAPI.Enums;
using PeasAPI.Managers.UpdateTools;
-using Reactor;
-using Reactor.Extensions;
+using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;
using Object = UnityEngine.Object;
diff --git a/PeasAPI/Managers/UpdateTools/UpdateListener.cs b/PeasAPI/Managers/UpdateTools/UpdateListener.cs
index 636d2bf..c5b362c 100644
--- a/PeasAPI/Managers/UpdateTools/UpdateListener.cs
+++ b/PeasAPI/Managers/UpdateTools/UpdateListener.cs
@@ -6,7 +6,7 @@
using System.Net.Http;
using System.Reflection;
using System.Text.Json;
-using BepInEx.IL2CPP;
+using BepInEx.Unity.IL2CPP;
using PeasAPI.Enums;
using Reactor;
using UnityEngine;
@@ -68,11 +68,14 @@ public virtual void Initialize()
return;
var result = httpResponseMessage.Content.ReadAsStringAsync().Result;
FromJsonElement(JsonDocument.Parse(result).RootElement);
- }
- catch (Exception ex)
+ } catch (Exception e)
{
- PeasAPI.Logger.LogError($"An error occured while initializing {Name}: \n{ex.Message}");
+
}
+ // catch (Exception ex)
+ // {
+ // PeasAPI.Logger.LogError($"An error occured while initializing {Name}: \n{ex.Message}");
+ // }
}
public abstract void FromJsonElement(JsonElement json);
diff --git a/PeasAPI/Managers/WatermarkManager.cs b/PeasAPI/Managers/WatermarkManager.cs
index db3e7bc..42e74f5 100644
--- a/PeasAPI/Managers/WatermarkManager.cs
+++ b/PeasAPI/Managers/WatermarkManager.cs
@@ -1,9 +1,7 @@
using System.Collections.Generic;
-using BepInEx;
using HarmonyLib;
-using Reactor;
-using UnhollowerRuntimeLib;
using UnityEngine;
+using Il2CppInterop.Runtime;
namespace PeasAPI.Managers
{
@@ -46,8 +44,8 @@ public Watermark(string versionText, string pingText,
public static readonly Vector2 defaultVersionTextOffset = new (0f, -0.2f);
public static readonly Vector2 defaultPingTextOffset = new Vector2(0f, 0f);
- public static Watermark PeasApiWatermark = new Watermark($"\nPeasAPI {PeasAPI.Version} by Peasplayer\nReactor v{ReactorPlugin.Version}\nBepInEx v{Paths.BepInExVersion}",
- "\nPeasAPI", new Vector2(), new Vector2());
+ public static Watermark PeasApiWatermark = new Watermark($"\nPeasAPI-R v 1.8.4-dev1 by Peasplayer\nContinued by JeanAU",
+ "\nPeasAPI-R", new Vector2(), new Vector2());
public static void AddWatermark(string versionText, string pingText,
Vector2 versionTextOffset = new Vector2(), Vector2 pingTextOffset = new Vector2())
@@ -60,18 +58,7 @@ public static void AddWatermark(string versionText, string pingText,
public static class VersionShowerStartPatch
{
static void Postfix(VersionShower __instance)
- {
- foreach (var watermark in Watermarks)
- {
- __instance.transform.position += watermark.VersionTextOffset;
-
- if (watermark.VersionText != null)
- __instance.text.text += watermark.VersionText;
-
- foreach (var gameObject in Object.FindObjectsOfTypeAll(Il2CppType.Of()))
- if (gameObject.name.Contains("ReactorVersion"))
- Object.Destroy(gameObject);
- }
+ {
if (PeasAPI.ShamelessPlug)
{
@@ -85,7 +72,7 @@ static void Postfix(VersionShower __instance)
Object.Destroy(gameObject);
}
- __instance.transform.position = new Vector3(-5.2333f, 2.85f, 0f) - new Vector3(0f, 0.2875f / 2 * (__instance.text.text.Split('\n').Length - 1));
+ __instance.transform.position = new Vector3(-1.2287f * + 10.9f, -0.57f, 4.5f) - new Vector3(0f, 0.2875f / 2 * (__instance.text.text.Split('\n').Length - 1));
}
}
diff --git a/PeasAPI/Options/CustomNumberOption.cs b/PeasAPI/Options/CustomNumberOption.cs
index ff3be6f..d689c14 100644
--- a/PeasAPI/Options/CustomNumberOption.cs
+++ b/PeasAPI/Options/CustomNumberOption.cs
@@ -2,8 +2,8 @@
using System.Reflection;
using BepInEx.Configuration;
using PeasAPI.CustomRpc;
-using Reactor;
-using Reactor.Networking;
+using Reactor.Localization.Utilities;
+using Reactor.Networking.Rpc;
using Object = UnityEngine.Object;
namespace PeasAPI.Options
@@ -72,7 +72,7 @@ internal OptionBehaviour CreateOption(NumberOption numberOptionPrefab)
Object.Instantiate(numberOptionPrefab, numberOptionPrefab.transform.parent);
numberOption.TitleText.text = Title;
- numberOption.Title = CustomStringName.Register(Title);
+ numberOption.Title = CustomStringName.CreateAndRegister(Title);
numberOption.Value = Value;
numberOption.ValidRange = new FloatRange(MinValue, MaxValue);
numberOption.Increment = Increment;
diff --git a/PeasAPI/Options/CustomOptionButton.cs b/PeasAPI/Options/CustomOptionButton.cs
index 7dbec0a..aa4b6c3 100644
--- a/PeasAPI/Options/CustomOptionButton.cs
+++ b/PeasAPI/Options/CustomOptionButton.cs
@@ -1,5 +1,5 @@
using System;
-using Reactor;
+using Reactor.Localization.Utilities;
using Object = UnityEngine.Object;
namespace PeasAPI.Options
@@ -72,7 +72,7 @@ internal OptionBehaviour CreateOption(ToggleOption toggleOptionPrefab, StringOpt
Option = toggleOption;
toggleOption.TitleText.text = Title;
- toggleOption.Title = CustomStringName.Register(Title);
+ toggleOption.Title = CustomStringName.CreateAndRegister(Title);
toggleOption.CheckMark.enabled = false;
toggleOption.transform.FindChild("CheckBox").gameObject.SetActive(false);
@@ -91,7 +91,7 @@ internal OptionBehaviour CreateOption(ToggleOption toggleOptionPrefab, StringOpt
Option = toggleOption;
toggleOption.TitleText.text = Title;
- toggleOption.Title = CustomStringName.Register(Title);
+ toggleOption.Title = CustomStringName.CreateAndRegister(Title);
toggleOption.Value = 0;
toggleOption.transform.FindChild("Value_TMP").gameObject.SetActive(false);
diff --git a/PeasAPI/Options/CustomOptionHeader.cs b/PeasAPI/Options/CustomOptionHeader.cs
index 4870aed..63ba1bb 100644
--- a/PeasAPI/Options/CustomOptionHeader.cs
+++ b/PeasAPI/Options/CustomOptionHeader.cs
@@ -1,5 +1,5 @@
-using Reactor;
-using Reactor.Extensions;
+using Reactor.Localization.Utilities;
+using Reactor.Utilities.Extensions;
using UnityEngine;
namespace PeasAPI.Options
@@ -17,7 +17,7 @@ internal OptionBehaviour CreateOption(ToggleOption toggleOptionPrefab)
Object.Instantiate(toggleOptionPrefab, toggleOptionPrefab.transform.parent);
header.TitleText.text = Title;
- header.Title = CustomStringName.Register(Title);
+ header.Title = CustomStringName.CreateAndRegister(Title);
var checkBox = header.transform.FindChild("CheckBox")?.gameObject;
if (checkBox) checkBox.Destroy();
diff --git a/PeasAPI/Options/CustomRoleOption.cs b/PeasAPI/Options/CustomRoleOption.cs
index 4d16721..50165dd 100644
--- a/PeasAPI/Options/CustomRoleOption.cs
+++ b/PeasAPI/Options/CustomRoleOption.cs
@@ -2,16 +2,18 @@
using System.Linq;
using HarmonyLib;
using PeasAPI.Roles;
-using Reactor;
-using Reactor.Extensions;
+using Reactor.Localization.Utilities;
+using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;
using Object = UnityEngine.Object;
+using AmongUs.GameOptions;
namespace PeasAPI.Options
{
public class CustomRoleOption : CustomOption
{
+ public static RoleOptionsData optionsData;
public BaseRole Role;
public int Count;
@@ -72,12 +74,12 @@ internal OptionBehaviour CreateOption(RoleOptionSetting roleOptionPrefab)
var newSetting = Object.Instantiate(roleOptionPrefab, roleOptionPrefab.transform.parent);
newSetting.name = Role.Name;
newSetting.Role = Role.RoleBehaviour;
- newSetting.SetRole(PlayerControl.GameOptions.RoleOptions);
+ newSetting.SetRole(GameOptionsManager.Instance.currentNormalGameOptions.RoleOptions);
- if (!PlayerControl.GameOptions.RoleOptions.roleRates.ContainsKey(Role.RoleBehaviour.Role))
- PlayerControl.GameOptions.RoleOptions.roleRates[Role.RoleBehaviour.Role] =
- new RoleOptionsData.RoleRate();
- var rates = PlayerControl.GameOptions.RoleOptions.roleRates[Role.RoleBehaviour.Role];
+ if (!optionsData.roleRates.ContainsKey(Role.RoleBehaviour.Role))
+ optionsData.roleRates[Role.RoleBehaviour.Role] =
+ new AmongUs.GameOptions.RoleRate();
+ var rates = optionsData.roleRates[Role.RoleBehaviour.Role];
Count = rates.MaxCount;
Chance = rates.Chance;
@@ -120,7 +122,7 @@ internal AdvancedRoleSettingsButton CreateOptionObjects(GameObject roleTabTempla
break;
}
- optionBehaviour.Title = CustomStringName.Register(advancedOption.Title);
+ optionBehaviour.Title = CustomStringName.CreateAndRegister(advancedOption.Title);
optionBehaviour.name = advancedOption.Title;
var optionTransform = optionBehaviour.transform;
diff --git a/PeasAPI/Options/CustomStringOption.cs b/PeasAPI/Options/CustomStringOption.cs
index 286a0e4..7fa133b 100644
--- a/PeasAPI/Options/CustomStringOption.cs
+++ b/PeasAPI/Options/CustomStringOption.cs
@@ -2,10 +2,10 @@
using BepInEx.Configuration;
using System.Collections.Generic;
using System.Reflection;
-using BepInEx.IL2CPP;
+using BepInEx.Unity.IL2CPP;
using PeasAPI.CustomRpc;
-using Reactor;
-using Reactor.Networking;
+using Reactor.Localization.Utilities;
+using Reactor.Networking.Rpc;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -81,7 +81,7 @@ internal OptionBehaviour CreateOption(StringOption stringOptionPrefab)
Object.Instantiate(stringOptionPrefab, stringOptionPrefab.transform.parent);
stringOption.TitleText.text = Title;
- stringOption.Title = CustomStringName.Register(Title);
+ stringOption.Title = CustomStringName.CreateAndRegister(Title);
stringOption.Value = Value;
stringOption.ValueText.text = StringValue;
stringOption.Values = Values.ToArray();
@@ -109,7 +109,7 @@ public CustomStringOption(string id, string title, params string[] values) : bas
Value = _configEntry?.Value ?? 0;
Values = new List();
foreach (var value in values)
- Values.Add((StringNames)CustomStringName.Register(value));
+ Values.Add((StringNames)CustomStringName.CreateAndRegister(value));
HudFormat = "{0}: {1}";
OptionManager.CustomOptions.Add(this);
diff --git a/PeasAPI/Options/CustomToggleOption.cs b/PeasAPI/Options/CustomToggleOption.cs
index 43f93e0..989685a 100644
--- a/PeasAPI/Options/CustomToggleOption.cs
+++ b/PeasAPI/Options/CustomToggleOption.cs
@@ -3,10 +3,10 @@
using System.Reflection;
using BepInEx.Configuration;
using PeasAPI.CustomRpc;
-using Reactor;
-using Reactor.Networking;
+using Reactor.Localization.Utilities;
+using Reactor.Networking.Rpc;
using UnityEngine;
-using Object = System.Object;
+using Object = UnityEngine.Object;
namespace PeasAPI.Options
{
@@ -85,7 +85,7 @@ internal OptionBehaviour CreateOption(ToggleOption toggleOptionPrefab, StringOpt
Option = toggleOption;
toggleOption.TitleText.text = Title;
- toggleOption.Title = CustomStringName.Register(Title);
+ toggleOption.Title = CustomStringName.CreateAndRegister(Title);
toggleOption.CheckMark.enabled = Value;
toggleOption.OnValueChanged = new Action(behaviour =>
@@ -103,12 +103,12 @@ internal OptionBehaviour CreateOption(ToggleOption toggleOptionPrefab, StringOpt
Option = toggleOption;
toggleOption.TitleText.text = Title;
- toggleOption.Title = CustomStringName.Register(Title);
+ toggleOption.Title = CustomStringName.CreateAndRegister(Title);
toggleOption.Value = Value ? 0 : 1;
var values = new List();
- values.Add(CustomStringName.Register("On"));
- values.Add(CustomStringName.Register("Off"));
+ values.Add(CustomStringName.CreateAndRegister("On"));
+ values.Add(CustomStringName.CreateAndRegister("Off"));
toggleOption.Values = values.ToArray();
toggleOption.OnValueChanged = new Action(behaviour =>
diff --git a/PeasAPI/Options/Patches.cs b/PeasAPI/Options/Patches.cs
index deaa875..603f278 100644
--- a/PeasAPI/Options/Patches.cs
+++ b/PeasAPI/Options/Patches.cs
@@ -4,22 +4,27 @@
using Il2CppSystem.Text;
using InnerNet;
using PeasAPI.CustomRpc;
-using Reactor.Extensions;
-using Reactor.Networking;
+using Reactor.Utilities.Extensions;
+using Reactor.Networking.Rpc;
using UnityEngine;
using Object = UnityEngine.Object;
+using AmongUs.GameOptions;
+using System.Collections.Generic;
+using System.Reflection;
namespace PeasAPI.Options
{
[HarmonyPatch]
public static class Patches
{
+
private static float AllOptionSize = 6.73f;
private static float LowestOption = -7.85f;
private static float OptionSize = 0.5f;
private static float HudTextSize = 1.4f;
private static Scroller OptionsScroller;
+ private static RoleOptionsData optionsData;
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Start))]
[HarmonyPostfix]
@@ -132,7 +137,7 @@ public static void RoleOptionValueChangedPatch(RolesSettingsMenu __instance, [Ha
switch (custom)
{
case CustomRoleOption option:
- var rates = PlayerControl.GameOptions.RoleOptions.roleRates[option.Role.RoleBehaviour.Role];
+ var rates = optionsData.roleRates[option.Role.RoleBehaviour.Role];
option.SetValue(rates.MaxCount, rates.Chance);
break;
case CustomNumberOption option:
@@ -203,80 +208,107 @@ private static void SwitchSettingsPagesPatch(KeyboardJoystick __instance)
if (Input.GetKeyDown(KeyCode.RightShift))
OnModdedPage = !OnModdedPage;
}
+
+ internal static void RenderOption(CustomOption option, StringBuilder builder, string prefix = "")
+ {
+ switch (option)
+ {
+ case CustomToggleOption _option:
+ builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title, _option.Value ? "On" : "Off") + Utility.StringColor.Reset);
+ break;
+ case CustomNumberOption _option:
+ builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title, _option.Value, _option.SuffixType switch
+ {
+ NumberSuffixes.None => "",
+ NumberSuffixes.Multiplier => "x",
+ NumberSuffixes.Seconds => "s",
+ _ => ""
+ }) + Utility.StringColor.Reset);
+ break;
+ case CustomStringOption _option:
+ builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title, _option.StringValue) + Utility.StringColor.Reset);
+ break;
+ case CustomOptionHeader _option:
+ builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title) + Utility.StringColor.Reset);
+ break;
+
+ }
+ }
- [HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.ToHudString))]
- [HarmonyPrefix]
+ [HarmonyPatch(typeof(IGameOptionsExtensions), nameof(IGameOptionsExtensions.ToHudString))]
+ private static class GameOptionsDataPatch
+ {
+ public static IEnumerable TargetMethods()
+ {
+ return typeof(GameOptionsData).GetMethods(typeof(string), typeof(int));
+ }
private static bool AddInformationPatch(GameOptionsData __instance)
{
if (OnModdedPage)
{
- __instance.settings.Length = 0;
- __instance.settings.AppendLine("Press RightShift to switch to the vanilla settings");
- __instance.settings.AppendLine();
+ var builder = new StringBuilder();
+ builder.Length = 0;
+ builder.AppendLine("Press RightShift to switch to the vanilla settings");
+ builder.AppendLine();
+
- __instance.settings.AppendLine("Roles:");
+ builder.AppendLine("Roles:");
foreach (var option in OptionManager.CustomRoleOptions)
{
- __instance.settings.AppendLine(String.Format(option.HudFormat, $"{option.Role.Color.ToTextColor()}{option.Role.Name}{Utility.StringColor.Reset}",
+ builder.AppendLine(String.Format(option.HudFormat, $"{option.Role.Color.ToTextColor()}{option.Role.Name}{Utility.StringColor.Reset}",
__instance.RoleOptions.GetNumPerGame(option.Role.RoleBehaviour.Role),
__instance.RoleOptions.GetChancePerGame(option.Role.RoleBehaviour.Role)));
- option.AdvancedOptions.Where(_option => _option.HudVisible).Do(_option => RenderOption(_option, __instance.settings, option.AdvancedOptionPrefix) );
+ option.AdvancedOptions.Where(_option => _option.HudVisible).Do(_option => RenderOption(_option, builder, option.AdvancedOptionPrefix) );
}
- OptionManager.HudVisibleOptions.Where(option => !option.IsFromPeasAPI && !option.AdvancedRoleOption).Do(option => RenderOption(option, __instance.settings) );
+ OptionManager.HudVisibleOptions.Where(option => !option.IsFromPeasAPI && !option.AdvancedRoleOption).Do(option => RenderOption(option, builder) );
return false;
}
return true;
}
- [HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.ToHudString))]
- [HarmonyPostfix]
+ [HarmonyPatch(typeof(IGameOptionsExtensions), nameof(IGameOptionsExtensions.ToHudString))]
+ private static class GameOptionsDataPatch1
+ {
+ public static IEnumerable TargetMethods()
+ {
+ return typeof(GameOptionsData).GetMethods(typeof(string), typeof(int));
+ }
private static void GameOptionsDataToHudStringPatch(GameOptionsData __instance, ref string __result)
{
if (!OnModdedPage)
{
- var text = __instance.settings.ToString();
- __instance.settings.Clear();
- __instance.settings.AppendLine("Press RightShift to switch to the modded settings");
- __instance.settings.AppendLine();
- __instance.settings.AppendLine(text);
+
+ var builder = new StringBuilder();
+ var text = builder.ToString();
+ builder.Clear();
+ builder.AppendLine("Press RightShift to switch to the modded settings");
+ builder.AppendLine();
+ builder.AppendLine(text);
- OptionManager.HudVisibleOptions.Where(option => option.IsFromPeasAPI).Do(option => RenderOption(option, __instance.settings) );
+ OptionManager.HudVisibleOptions.Where(option => option.IsFromPeasAPI).Do(option => RenderOption(option, builder) );
}
-
- __result = __instance.settings.ToString();
+
+ var builder1 = new StringBuilder();
+ __result = builder1.ToString();
}
- internal static void RenderOption(CustomOption option, StringBuilder builder, string prefix = "")
- {
- switch (option)
- {
- case CustomToggleOption _option:
- builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title, _option.Value ? "On" : "Off") + Utility.StringColor.Reset);
- break;
- case CustomNumberOption _option:
- builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title, _option.Value, _option.SuffixType switch
- {
- NumberSuffixes.None => "",
- NumberSuffixes.Multiplier => "x",
- NumberSuffixes.Seconds => "s",
- _ => ""
- }) + Utility.StringColor.Reset);
- break;
- case CustomStringOption _option:
- builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title, _option.StringValue) + Utility.StringColor.Reset);
- break;
- case CustomOptionHeader _option:
- builder.AppendLine(prefix + String.Format(_option.HudFormat, _option.Title) + Utility.StringColor.Reset);
- break;
- }
- }
+
+
+ private static Scroller Scroller;
+
+
+ private const float
+ MinX = -5.233334F /*-5.3F*/,
+ OriginalY = 2.9F,
+ MinY = 3F; // Differs to cause excess options to appear cut off to encourage scrolling
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
[HarmonyPostfix]
private static void HudManagerUpdatePatch(HudManager __instance)
{
+
if (__instance.GameSettings == null)
return;
@@ -288,29 +320,30 @@ private static void HudManagerUpdatePatch(HudManager __instance)
var bottomLeft = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)) - Camera.main.transform.localPosition;
- OptionsScroller.ContentYBounds = new FloatRange(-bottomLeft.y, Mathf.Max(-bottomLeft.y, __instance.GameSettings.renderedHeight - -bottomLeft.y + 0.02F));
+ Scroller.ContentYBounds = new FloatRange(-bottomLeft.y, Mathf.Max(-bottomLeft.y, __instance.GameSettings.renderedHeight - -bottomLeft.y + 0.02F));
}
- //THIS BIT IS SKIDDED FROM ESSENTIALS: https://github.com/DorCoMaNdO/Reactor-Essentials
- private static void CreateScroller(HudManager hudManager)
- {
- if (OptionsScroller != null) return;
-
- OptionsScroller = new GameObject("OptionsScroller").AddComponent();
- OptionsScroller.transform.SetParent(hudManager.GameSettings.transform.parent);
- OptionsScroller.gameObject.layer = 5;
-
- OptionsScroller.transform.localScale = Vector3.one;
- OptionsScroller.allowX = false;
- OptionsScroller.allowY = true;
- OptionsScroller.active = true;
- OptionsScroller.velocity = new Vector2(0, 0);
- OptionsScroller.ContentYBounds = new FloatRange(0, 0);
- OptionsScroller.enabled = true;
-
- OptionsScroller.Inner = hudManager.GameSettings.transform;
- hudManager.GameSettings.transform.SetParent(OptionsScroller.transform);
- }
+ //THIS BIT IS SKIDDED FROM TOU: https://github.com/eDonners124/TownOfUsR
+ private static void CreateScroller(HudManager __instance)
+ {
+ if (Scroller != null) return;
+
+ Scroller = new GameObject("SettingsScroller").AddComponent();
+ Scroller.transform.SetParent(__instance.GameSettings.transform.parent);
+ Scroller.gameObject.layer = 5;
+
+ Scroller.transform.localScale = Vector3.one;
+ Scroller.allowX = false;
+ Scroller.allowY = true;
+ Scroller.active = true;
+ Scroller.velocity = new Vector2(0, 0);
+ Scroller.ScrollbarYBounds = new FloatRange(0, 0);
+ Scroller.ContentXBounds = new FloatRange(MinX, MinX);
+ Scroller.enabled = true;
+
+ Scroller.Inner = __instance.GameSettings.transform;
+ __instance.GameSettings.transform.SetParent(Scroller.transform);
+ }
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameJoined))]
[HarmonyPostfix]
@@ -321,10 +354,10 @@ private static void RoleOptionInitialisePatch(AmongUsClient __instance)
foreach (var option in OptionManager.CustomRoleOptions)
{
- if (!PlayerControl.GameOptions.RoleOptions.roleRates.ContainsKey(option.Role.RoleBehaviour.Role))
- PlayerControl.GameOptions.RoleOptions.roleRates[option.Role.RoleBehaviour.Role] =
- new RoleOptionsData.RoleRate();
- var rates = PlayerControl.GameOptions.RoleOptions.roleRates[option.Role.RoleBehaviour.Role];
+ if (!optionsData.roleRates.ContainsKey(option.Role.RoleBehaviour.Role))
+ optionsData.roleRates[option.Role.RoleBehaviour.Role] =
+ new AmongUs.GameOptions.RoleRate();
+ var rates = optionsData.roleRates[option.Role.RoleBehaviour.Role];
option.Count = rates.MaxCount;
option.Chance = rates.Chance;
}
@@ -355,4 +388,6 @@ private static void AmongUsClientOnPlayerJoinedPatch(AmongUsClient __instance,
}
}
}
+}
+ }
}
\ No newline at end of file
diff --git a/PeasAPI/Patches.cs b/PeasAPI/Patches.cs
index 30042d3..98e5948 100644
--- a/PeasAPI/Patches.cs
+++ b/PeasAPI/Patches.cs
@@ -5,16 +5,7 @@ namespace PeasAPI
{
[HarmonyPatch]
public static class Patches
- {
- [HarmonyPatch(typeof(VersionShower), nameof(VersionShower.Start))]
- [HarmonyPostfix]
- public static void ChangeZOfAccountTabPatch()
- {
- var tab = AccountManager.Instance.accountTab;
- tab.transform.SetZ(1f);
- tab.GetComponent().computedClosedPosition = tab.GetComponent().computedClosedPosition.SetZ(1);
- }
-
+ {
[HarmonyPatch(typeof(AccountManager), nameof(AccountManager.RandomizeName))]
[HarmonyPrefix]
public static bool RemoveRandomNamePatch()
diff --git a/PeasAPI/PeasAPI.cs b/PeasAPI/PeasAPI.cs
index f1882e1..4033bdb 100644
--- a/PeasAPI/PeasAPI.cs
+++ b/PeasAPI/PeasAPI.cs
@@ -1,6 +1,6 @@
using BepInEx;
using BepInEx.Configuration;
-using BepInEx.IL2CPP;
+using BepInEx.Unity.IL2CPP;
using BepInEx.Logging;
using HarmonyLib;
using InnerNet;
@@ -14,14 +14,11 @@
namespace PeasAPI
{
- [HarmonyPatch]
- [BepInPlugin(Id, "PeasAPI", Version)]
+ [BepInAutoPlugin]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
- public class PeasAPI : BasePlugin
+ public partial class PeasAPI : BasePlugin
{
- public const string Id = "tk.peasplayer.amongus.api";
- public const string Version = "1.8.3";
public Harmony Harmony { get; } = new Harmony(Id);
@@ -47,14 +44,15 @@ public static bool GameStarted
{
return GameData.Instance && ShipStatus.Instance && AmongUsClient.Instance &&
(AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started ||
- AmongUsClient.Instance.GameMode == global::GameModes.FreePlay);
+ AmongUsClient.Instance.NetworkMode == global::NetworkModes.FreePlay &&
+ AmongUsClient.Instance.NetworkMode == NetworkModes.LocalGame);
}
}
///
/// If you set this to false please provide credit! I mean this stuff is free and open-source so a little credit would be nice :)
///
- public static bool ShamelessPlug = true;
+ public static bool ShamelessPlug = false;
public static CustomToggleOption ShowRolesOfDead;
@@ -67,11 +65,11 @@ public override void Load()
if (useCustomServer.Value)
{
CustomServerManager.RegisterServer(ConfigFile.Bind("CustomServer", "Name", "CustomServer").Value,
- ConfigFile.Bind("CustomServer", "Ipv4 or Hostname", "au.peasplayer.tk").Value,
+ ConfigFile.Bind("CustomServer", "Ipv4 or Hostname", "127.0.0.1").Value,
ConfigFile.Bind("CustomServer", "Port", (ushort)22023).Value);
}
- UpdateManager.RegisterGitHubUpdateListener("Peasplayer", "PeasAPI");
+ UpdateManager.RegisterGitHubUpdateListener("AmongUsDev", "PeasAPI-R");
RegisterCustomRoleAttribute.Load();
RegisterCustomGameModeAttribute.Load();
@@ -89,6 +87,7 @@ public static void PatchToTestSomeStuff(KeyboardJoystick __instance)
{
if (Input.GetKeyDown(KeyCode.F))
{
+ Debug.Log("Something is coming in the future");
}
}
}
diff --git a/PeasAPI/PeasAPI.csproj b/PeasAPI/PeasAPI.csproj
index 92acbe8..720c2fa 100644
--- a/PeasAPI/PeasAPI.csproj
+++ b/PeasAPI/PeasAPI.csproj
@@ -1,15 +1,15 @@
- netstandard2.1
- 1.8.3
+ net6.0
+ 1.8.4
release
API for making Among Us mods
Peasplayer
latest
Steam
- 2022.3.29
- 2022.3.29
+ 2023.6.13
+ 2023.6.13
PeasAPI-Icon.png
git
@@ -22,13 +22,16 @@
-
-
-
+
+
+
+
-
+
+
+
diff --git a/PeasAPI/Roles/AssignRoleOnDeath.cs b/PeasAPI/Roles/AssignRoleOnDeath.cs
new file mode 100644
index 0000000..6e041ec
--- /dev/null
+++ b/PeasAPI/Roles/AssignRoleOnDeath.cs
@@ -0,0 +1,22 @@
+/*
+using AmongUs.GameOptions;
+using HarmonyLib;
+
+namespace PeasAPI;
+
+[HarmonyPatch(typeof(RoleManager), nameof(RoleManager.AssignRoleOnDeath))]
+public class AssignRoleOnDeathPatch
+{
+ public static bool Prefix(RoleManager __instance, [HarmonyArgument(0)] PlayerControl player)
+ {
+ return false;
+ }
+
+
+ public static void Postfix(RoleManager __instance, [HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] bool specialRolesAllowed)
+ {
+ player.RpcSetRole(player.Get().IsImpostor() ? RoleTypes.ImpostorGhost : RoleTypes.CrewmateGhost);
+ VentLogger.Debug($"Dead Player {player.name} => {player.Data.Role.Role}");
+ }
+}
+*/
\ No newline at end of file
diff --git a/PeasAPI/Roles/BaseRole.cs b/PeasAPI/Roles/BaseRole.cs
index 3e9212e..a718aee 100644
--- a/PeasAPI/Roles/BaseRole.cs
+++ b/PeasAPI/Roles/BaseRole.cs
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using BepInEx.IL2CPP;
+using BepInEx.Unity.IL2CPP;
using PeasAPI.Managers;
using PeasAPI.Options;
using UnityEngine;
+using AmongUs.GameOptions;
namespace PeasAPI.Roles
{
@@ -28,7 +29,7 @@ public abstract class BaseRole
public abstract string LongDescription { get; }
- public virtual Sprite Icon { get; } = Utility.CreateSprite("PeasAPI.Placeholder.png");
+ public virtual Sprite Icon { get; } = Utility.LoadSprite("PeasAPI.Placeholder.png", 90f);
///
/// The description of the Role at the task list
@@ -76,7 +77,7 @@ public abstract class BaseRole
public virtual Type[] GameModeWhitelist { get; } = Array.Empty();
- public virtual float KillDistance { get; set; } = GameOptionsData.KillDistances[Mathf.Clamp(PlayerControl.GameOptions.KillDistance, 0, 2)];
+ public virtual float KillDistance { get; set; } = GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)];
///
/// If a member of the role should be able to kill that player / in general
@@ -126,13 +127,15 @@ public virtual bool _IsRoleVisible(PlayerControl playerWithRole, PlayerControl p
default: throw new NotImplementedException("Unknown Visibility");
}
}
-
+
+ /*
+ // Disable this feature because i very hard ):
///
/// This method calculates the nearest player to kill for a member of this role
///
- public virtual PlayerControl FindClosestTarget(PlayerControl from, bool protecting)
+ public virtual RoleBehaviour FindClosestTarget(PlayerControl from)
{
- PlayerControl result = null;
+ RoleBehaviour result = null;
float num = KillDistance;
if (!ShipStatus.Instance)
{
@@ -141,9 +144,11 @@ public virtual PlayerControl FindClosestTarget(PlayerControl from, bool protecti
Vector2 truePosition = from.GetTruePosition();
foreach (var playerInfo in GameData.Instance.AllPlayers)
{
- if (!playerInfo.Disconnected && playerInfo.PlayerId != from.PlayerId && !playerInfo.IsDead && (from.GetRole().CanKill(playerInfo.Object) || protecting) && !playerInfo.Object.inVent)
+ if (!playerInfo.Disconnected && playerInfo.PlayerId != from.PlayerId && !playerInfo.IsDead && (from.GetRole().CanKill(playerInfo.Object)) && !playerInfo.Object.inVent)
{
- PlayerControl @object = playerInfo.Object;
+ foreach (var playerInfo1 in GameData.Instance.AllPlayers)
+ {
+ RoleBehaviour @object = playerInfo1.Object;
if (@object && @object.Collider.enabled)
{
Vector2 vector = @object.GetTruePosition() - truePosition;
@@ -156,8 +161,10 @@ public virtual PlayerControl FindClosestTarget(PlayerControl from, bool protecti
}
}
}
+ }
return result;
}
+ */
public virtual bool ShouldGameEnd(GameOverReason reason) => true;
@@ -186,8 +193,8 @@ internal void _OnUpdate()
continue;
if (playerControl.IsRole(this) && _IsRoleVisible(playerControl, PlayerControl.LocalPlayer))
{
- playerControl.nameText.color = this.Color;
- playerControl.nameText.text = $"{player.GetPlayer().name}\n{Name}";
+ playerControl.nameText().color = this.Color;
+ playerControl.nameText().text = $"{player.GetPlayer().name}\n{Name}";
}
}
@@ -215,8 +222,8 @@ internal void _OnMeetingUpdate(MeetingHud __instance)
continue;
if (playerControl.IsRole(this) && _IsRoleVisible(playerControl, PlayerControl.LocalPlayer))
{
- playerControl.nameText.color = this.Color;
- playerControl.nameText.text = $"{player.GetPlayer().name}\n{Name}";
+ playerControl.nameText().color = this.Color;
+ playerControl.nameText().text = $"{player.GetPlayer().name}\n{Name}";
}
}
diff --git a/PeasAPI/Roles/Patches.cs b/PeasAPI/Roles/Patches.cs
index 67f7062..b3bfb18 100644
--- a/PeasAPI/Roles/Patches.cs
+++ b/PeasAPI/Roles/Patches.cs
@@ -4,16 +4,21 @@
using Il2CppSystem.Collections.Generic;
using PeasAPI.CustomButtons;
using PeasAPI.CustomRpc;
-using Reactor.Networking;
-using UnhollowerBaseLib;
+using Reactor.Networking.Rpc;
+using Il2CppInterop.Runtime.InteropTypes.Arrays;
using UnityEngine;
using Object = Il2CppSystem.Object;
+using AmongUs.GameOptions;
namespace PeasAPI.Roles
{
+
[HarmonyPatch]
public static class Patches
{
+ public static RoleBehaviour roleBehaviour;
+ public static MapBehaviour map;
+
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameEnd))]
[HarmonyPrefix]
public static void OnGameEndPatch(AmongUsClient __instance)
@@ -37,31 +42,9 @@ public static void InitializeRolesPatch()
Rpc.Instance.Send();
}
- [HarmonyPatch(typeof(global::RoleManager), nameof(global::RoleManager.AssignRolesFromList))]
- [HarmonyPrefix]
- public static bool ChangeImpostors(global::RoleManager __instance,
- [HarmonyArgument(0)] List players, [HarmonyArgument(1)] int teamMax,
- [HarmonyArgument(2)] List roleList, [HarmonyArgument(3)] ref int rolesAssigned)
- {
- while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
- {
- int index = HashRandom.FastNext(roleList.Count);
- RoleTypes roleType = roleList.ToArray()[index];
- roleList.RemoveAt(index);
- int index2 = global::RoleManager.IsImpostorRole(roleType) && RoleManager.HostMod.IsImpostor
- ? 0
- : HashRandom.FastNext(players.Count);
- players.ToArray()[index2].Object.RpcSetRole(roleType);
- players.RemoveAt(index2);
- rolesAssigned++;
- }
-
- return false;
- }
-
- [HarmonyPatch(typeof(IntroCutscene._ShowRole_d__24), nameof(IntroCutscene._ShowRole_d__24.MoveNext))]
+ [HarmonyPatch(typeof(IntroCutscene._ShowRole_d__39), nameof(IntroCutscene._ShowRole_d__39.MoveNext))]
[HarmonyPostfix]
- public static void RoleTextPatch(IntroCutscene._ShowRole_d__24 __instance)
+ public static void RoleTextPatch(IntroCutscene._ShowRole_d__39 __instance)
{
if (PlayerControl.LocalPlayer.GetRole() != null)
{
@@ -205,7 +188,7 @@ public static void Postfix(PlayerControl __instance)
{
if (!__instance.Data.Role.IsImpostor)
__instance.SetKillTimer(__instance.killTimer - Time.fixedDeltaTime);
- PlayerControl target = __instance.FindClosestTarget(false);
+ PlayerControl target = roleBehaviour.FindClosestTarget();
HudManager.Instance.KillButton.SetTarget(target);
}
else
@@ -303,10 +286,10 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] float t
{
if (__instance.GetRole() != null && __instance.GetRole().CanKill() || __instance.Data.Role.CanUseKillButton)
{
- if (PlayerControl.GameOptions.KillCooldown <= 0f)
+ if (GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown <= 0f)
return false;
- __instance.killTimer = Mathf.Clamp(time, 0f, PlayerControl.GameOptions.KillCooldown);
- DestroyableSingleton.Instance.KillButton.SetCoolDown(__instance.killTimer, PlayerControl.GameOptions.KillCooldown);
+ __instance.killTimer = Mathf.Clamp(time, 0f, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown);
+ DestroyableSingleton.Instance.KillButton.SetCoolDown(__instance.killTimer, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown);
}
return false;
}
@@ -328,22 +311,24 @@ public static void OnPlayerExiledPatch(PlayerControl __instance)
RoleManager.Roles.Do(r => r.OnExiled(__instance));
}
- [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CoStartMeeting))]
+ [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.StartMeeting))]
[HarmonyPrefix]
public static void OnMeetingStart(MeetingHud __instance)
{
RoleManager.Roles.Do(r => r.OnMeetingStart(__instance));
}
- [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FindClosestTarget))]
- public static class PlayerControlFindClosestTargetPatch
+ // very hard to fix this issue idk why
+ /* [HarmonyPatch(typeof(RoleBehaviour), nameof(RoleBehaviour.FindClosestTarget))]
+ public static class RoleBehaviourFindClosestTargetPatch
{
- public static bool Prefix(PlayerControl __instance, out PlayerControl __result,
+ public static bool Prefix(RoleBehaviour __instance, out RoleBehaviour __result,
[HarmonyArgument(0)] bool protecting)
{
- if (__instance.GetRole() != null)
+ var player = PlayerControl.LocalPlayer;
+ if (player.GetRole() != null)
{
- __result = __instance.GetRole().FindClosestTarget(__instance, protecting);
+ __result = player.GetRole().RoleBehaviour.FindClosestTarget();
return false;
}
@@ -351,11 +336,12 @@ public static bool Prefix(PlayerControl __instance, out PlayerControl __result,
return true;
}
}
+ */
- [HarmonyPatch(typeof(PlayerControl._CoSetTasks_d__112), nameof(PlayerControl._CoSetTasks_d__112.MoveNext))]
+ [HarmonyPatch(typeof(PlayerControl._CoSetTasks_d__114), nameof(PlayerControl._CoSetTasks_d__114.MoveNext))]
public static class PlayerControlSetTasks
{
- public static void Postfix(PlayerControl._CoSetTasks_d__112 __instance)
+ public static void Postfix(PlayerControl._CoSetTasks_d__114 __instance)
{
if (__instance == null)
return;
@@ -390,6 +376,8 @@ public static void Postfix(PlayerControl._CoSetTasks_d__112 __instance)
}
}
+
+
[HarmonyPatch(typeof(SabotageButton), nameof(SabotageButton.DoClick))]
public static class UseButtonManagerDoClickPatch
{
@@ -401,9 +389,8 @@ public static bool Prefix(SabotageButton __instance)
if (role == null)
return true;
-
- HudManager.Instance.ShowMap((Action)(map =>
- {
+
+
foreach (MapRoom mapRoom in map.infectedOverlay.rooms.ToArray()
.Where(room => !role.CanSabotage(room.room)))
{
@@ -411,12 +398,11 @@ public static bool Prefix(SabotageButton __instance)
}
map.ShowSabotageMap();
- }));
+ };
return false;
}
- return true;
}
}
@@ -428,23 +414,21 @@ public static bool Prefix(MapBehaviour __instance)
if (PeasAPI.GameStarted)
{
var role = PlayerControl.LocalPlayer.GetRole();
+ var map = new MapBehaviour();
if (role == null)
return true;
-
- HudManager.Instance.ShowMap((Action) (map =>
- {
+
foreach (MapRoom mapRoom in map.infectedOverlay.rooms.ToArray())
{
mapRoom.gameObject.SetActive(role.CanSabotage(mapRoom.room));
}
- }));
+
//return false;
}
-
- return true;
- }
+ return false;
+ }
}
[HarmonyPatch(typeof(Vent), nameof(Vent.CanUse))]
@@ -473,11 +457,10 @@ public static void Postfix(Vent __instance, [HarmonyArgument(1)] ref bool canUse
Constants.ShipOnlyMask, false));
}
}
- }
- [HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.RpcEndGame))]
+ [HarmonyPatch(typeof(GameManager), nameof(GameManager.Instance.RpcEndGame))]
[HarmonyPrefix]
- private static bool ShouldGameEndPatch(ShipStatus __instance, [HarmonyArgument(0)] GameOverReason endReason)
+ private static bool ShouldGameEndPatch(GameManager __instance, [HarmonyArgument(0)] GameOverReason endReason)
{
return RoleManager.Roles.Count(r => r.Members.Count != 0 && !r.ShouldGameEnd(endReason)) == 0;
}
@@ -520,7 +503,7 @@ private static bool DoTasksCountPatch(GameData __instance)
__instance.CompletedTasks = 0;
foreach (var playerInfo in __instance.AllPlayers)
{
- if (!playerInfo.Disconnected && playerInfo.Tasks != null && playerInfo.Object && (PlayerControl.GameOptions.GhostsDoTasks || !playerInfo.IsDead) && playerInfo.Role && playerInfo.Role.TasksCountTowardProgress && (playerInfo.GetRole() == null || playerInfo.GetRole().HasToDoTasks))
+ if (!playerInfo.Disconnected && playerInfo.Tasks != null && playerInfo.Object && (GameOptionsManager.Instance.currentNormalGameOptions.GhostsDoTasks || !playerInfo.IsDead) && playerInfo.Role && playerInfo.Role.TasksCountTowardProgress && (playerInfo.GetRole() == null || playerInfo.GetRole().HasToDoTasks))
{
foreach (var task in playerInfo.Tasks)
{
@@ -535,7 +518,7 @@ private static bool DoTasksCountPatch(GameData __instance)
/*for (int i = 0; i < __instance.AllPlayers.Count; i++)
{
GameData.PlayerInfo playerInfo = __instance.AllPlayers[i];
- if (!playerInfo.Disconnected && playerInfo.Tasks != null && playerInfo.Object && (PlayerControl.GameOptions.GhostsDoTasks || !playerInfo.IsDead) && playerInfo.Role && playerInfo.Role.TasksCountTowardProgress)
+ if (!playerInfo.Disconnected && playerInfo.Tasks != null && playerInfo.Object && (GameOptionsManager.Instance.currentNormalGameOptions.GhostsDoTasks || !playerInfo.IsDead) && playerInfo.Role && playerInfo.Role.TasksCountTowardProgress)
{
for (int j = 0; j < playerInfo.Tasks.Count; j++)
{
diff --git a/PeasAPI/Roles/RoleManager.cs b/PeasAPI/Roles/RoleManager.cs
index 63cee14..0e0b3c1 100644
--- a/PeasAPI/Roles/RoleManager.cs
+++ b/PeasAPI/Roles/RoleManager.cs
@@ -2,11 +2,13 @@
using System.Linq;
using HarmonyLib;
using PeasAPI.CustomRpc;
-using Reactor;
-using Reactor.Extensions;
-using Reactor.Networking;
+using Reactor.Localization.Utilities;
+using Reactor.Utilities.Extensions;
+using Reactor.Networking.Rpc;
+using AmongUs.GameOptions;
using UnityEngine;
+
namespace PeasAPI.Roles
{
public static class RoleManager
@@ -18,6 +20,7 @@ public static class RoleManager
public static List Roles = new List();
public static int GetRoleId() => Roles.Count;
+
public static void RegisterRole(BaseRole role) => Roles.Add(role);
@@ -33,15 +36,15 @@ internal static RoleBehaviour ToRoleBehaviour(BaseRole baseRole)
var role = roleObject.AddComponent();
- role.StringName = CustomStringName.Register(baseRole.Name);
- role.BlurbName = CustomStringName.Register(baseRole.Description);
- role.BlurbNameLong = CustomStringName.Register(baseRole.LongDescription);
- role.BlurbNameMed = CustomStringName.Register(baseRole.Name);
+ role.StringName = CustomStringName.CreateAndRegister(baseRole.Name);
+ role.BlurbName = CustomStringName.CreateAndRegister(baseRole.Description);
+ role.BlurbNameLong = CustomStringName.CreateAndRegister(baseRole.LongDescription);
+ role.BlurbNameMed = CustomStringName.CreateAndRegister(baseRole.Name);
role.Role = (RoleTypes) (6 + baseRole.Id);
var abilityButtonSettings = ScriptableObject.CreateInstance();
abilityButtonSettings.Image = baseRole.Icon;
- abilityButtonSettings.Text = CustomStringName.Register(baseRole.Name);
+ abilityButtonSettings.Text = CustomStringName.CreateAndRegister(baseRole.Name);
role.Ability = abilityButtonSettings;
role.TeamType = baseRole.Team switch
@@ -57,7 +60,7 @@ internal static RoleBehaviour ToRoleBehaviour(BaseRole baseRole)
role.CanVent = baseRole.CanVent;
role.CanUseKillButton = baseRole.CanKill();
- PlayerControl.GameOptions.RoleOptions.SetRoleRate(role.Role, 0, 0);
+ GameOptionsManager.Instance.currentNormalGameOptions.RoleOptions.SetRoleRate(role.Role, 0, 0);
global::RoleManager.Instance.AllRoles.AddItem(role);
diff --git a/PeasAPI/Utility.cs b/PeasAPI/Utility.cs
index ee9a8af..cb205aa 100644
--- a/PeasAPI/Utility.cs
+++ b/PeasAPI/Utility.cs
@@ -2,24 +2,49 @@
using System.IO;
using System.Linq;
using System.Reflection;
-using Reactor.Extensions;
using UnityEngine;
namespace PeasAPI
{
public static class Utility
{
- public static Sprite CreateSprite(string image, float pixelsPerUnit = 128f)
+ public static Dictionary CachedSprites = new();
+
+ public static Sprite LoadSprite(string path, float pixelsPerUnit = 1f)
+ {
+ try
+ {
+ if (CachedSprites.TryGetValue(path + pixelsPerUnit, out var sprite)) return sprite;
+ Texture2D texture = LoadTextureFromResources(path);
+ sprite = Sprite.Create(texture, new(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), pixelsPerUnit);
+ sprite.hideFlags |= HideFlags.HideAndDontSave | HideFlags.DontSaveInEditor;
+ return CachedSprites[path + pixelsPerUnit] = sprite;
+ }
+ catch
{
- Texture2D tex = GUIExtensions.CreateEmptyTexture();
- Stream myStream = Assembly.GetCallingAssembly().GetManifestResourceStream(image);
- byte[] data = myStream.ReadFully();
- ImageConversion.LoadImage(tex, data, false);
- var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f),
- pixelsPerUnit);
- sprite.DontDestroy();
- return sprite;
+ PeasAPI.Logger.LogError($"An error was occured when loading the follow path {path}");
}
+ return null;
+ }
+ public static Texture2D LoadTextureFromResources(string path)
+ {
+ try
+ {
+ var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
+ var texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
+ using MemoryStream ms = new();
+ stream.CopyTo(ms);
+ ImageConversion.LoadImage(texture, ms.ToArray(), false);
+ return texture;
+ }
+ catch
+ {
+ PeasAPI.Logger.LogError($"An error was occured when loading the follow path {path}");
+
+ }
+ return null;
+ }
+
public static List GetAllPlayers()
{
diff --git a/PeasAPI/nuget.config b/PeasAPI/nuget.config
index 9a4ac66..1a0de73 100644
--- a/PeasAPI/nuget.config
+++ b/PeasAPI/nuget.config
@@ -3,5 +3,6 @@
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 1fe101b..8e9eae4 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,12 @@
# PeasAPI-R
API for making Among Us mods
-Reactivited
+Reactivited for __**2023.6.13__**
-__**Soon for the latest version of among us**__
+## Note : I don't know if work or not just try creating role
+
+if there any issue make sure [report](https://github.com/AmongUsDev/PeasAPI-R/issue);
+
+if you wante change something please open an [pull-request](https://github.com/AmongUsDev/PeasAPI-R/pulls)
*This mod is not affiliated with Among Us or Innersloth LLC, and the content contained therein is not endorsed or otherwise sponsored by Innersloth LLC. Portions of the materials contained herein are property of Innersloth LLC. © Innersloth LLC.*
From e6c8474ea893a9f9c873df79fea6cb03db53ef53 Mon Sep 17 00:00:00 2001
From: AmongUsModdingDev <137340286+AmongUsDev@users.noreply.github.com>
Date: Tue, 27 Jun 2023 15:29:19 +0100
Subject: [PATCH 3/3] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8e9eae4..143b1ad 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Reactivited for __**2023.6.13__**
## Note : I don't know if work or not just try creating role
-if there any issue make sure [report](https://github.com/AmongUsDev/PeasAPI-R/issue);
+if there any issue make sure [report](https://github.com/AmongUsDev/PeasAPI-R/issues);
if you wante change something please open an [pull-request](https://github.com/AmongUsDev/PeasAPI-R/pulls)