Skip to content

Commit

Permalink
Update to v4.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gendelo3 committed Aug 19, 2023
1 parent cdb5ed5 commit 2bd94e2
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 68 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2023.07.12s| v4.3.4| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v4.3.4/TheOtherRoles.zip)
| 2023.07.12s| v4.3.3| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v4.3.3/TheOtherRoles.zip)
| 2023.03.28s| v4.3.2| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v4.3.2/TheOtherRoles.zip)
<details>
Expand Down Expand Up @@ -124,6 +125,13 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 4.3.4**
- Updated BepInEx dependency to 671
- Fixed compatibility to Submerged (not thouroughly tested)
- Fixed a bug where the death reason of a guessed shifter was incorrectly displayed as "shifted xy"
- Make it possible to disable the Mod-Updater (see [details](#gcerror) ), to circumvent a crash at startup with a GC-Error
- Fixed the hats in freeplay partially

**Version 4.3.3**
- Updated to Among Us version 2023.07.12
- Fixed an issue where the swap icon of a swapper guesser would be in front of the witch icon on a spelled player
Expand Down Expand Up @@ -2071,6 +2079,10 @@ Each Hunter action or finished Crew task will lower the timer by a configurable
| Enable Sabotages | -
| Time The Hunter Needs To Wait | -

## GCERROR
If the error message "Fatal Error in GC - Collecting from unknown thread" stops you from playing the game, you can now disable the mod-updater, which causes this error.
In order to do this, create a file called `noupdater.txt` in your modded Among Us folder.

# License
TheOtherRolesAU/TheOtherRoles is licensed under the

Expand Down
4 changes: 3 additions & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "4.3.3";
public const string VersionString = "4.3.4";
public static uint betaDays = 0; // amount of days for the build to be usable (0 for infinite!)

public static Version Version = Version.Parse(VersionString);
Expand Down Expand Up @@ -125,6 +125,8 @@ public override void Load() {
SubmergedCompatibility.Initialize();
AddComponent<ModUpdateBehaviour>();
Modules.MainMenuPatch.addSceneChangeCallbacks();

TheOtherRolesPlugin.Logger.LogInfo("Loading TOR completed!");
}
public static Sprite GetModStamp() {
if (ModStamp) return ModStamp;
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Modules/BepInExUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace TheOtherRoles.Modules;

public class BepInExUpdater : MonoBehaviour
{
public const string RequiredBepInExVersion = "6.0.0-be.670+42a6727370c2b9356fc043ea601410540a8b4042";
public const string BepInExDownloadURL = "https://builds.bepinex.dev/projects/bepinex_be/670/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.670%2B42a6727.zip";
public const string RequiredBepInExVersion = "6.0.0-be.671+9caf61dca07043beae57b0771f6a5283aa02436b";
public const string BepInExDownloadURL = "https://builds.bepinex.dev/projects/bepinex_be/671/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.671%2B9caf61d.zip";
public static bool UpdateRequired => Paths.BepInExVersion.ToString() != RequiredBepInExVersion;

public void Awake()
Expand Down
62 changes: 58 additions & 4 deletions TheOtherRoles/Modules/CustomHats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static HatData CreateHatBehaviour(CustomHat ch, bool fromDisk = false, b
} else {
CustomHatRegistry.Add(hat.name, extend);
}
CustomHatViewDatas.Add(hat.name, viewdata);
CustomHatViewDatas.TryAdd(hat.name, viewdata);
var assetRef = new AssetReference(viewdata.Pointer);

hat.ViewDataRef = assetRef;
Expand Down Expand Up @@ -256,6 +256,7 @@ private static void Postfix(PlayerPhysics __instance) {
[HarmonyPatch]
private static class FreeplayHatTestingPatches
{
[HarmonyPriority(Priority.High)]
[HarmonyPatch(typeof(HatParent), nameof(HatParent.SetHat), typeof(int))]
private static class HatParentSetHatPatchColor {
static void Prefix(HatParent __instance) {
Expand Down Expand Up @@ -295,7 +296,7 @@ static bool Prefix(HatParent __instance, HatData hat, int color)
if (hats.Count > 0)
{
__instance.Hat = CreateHatBehaviour(hats[0], true, true);
__instance.hatDataAsset = __instance.Hat.CreateAddressableAsset();
__instance.Hat.CreateAddressableAsset();
}
}
catch (System.Exception e)
Expand All @@ -314,7 +315,7 @@ static bool Prefix(HatParent __instance, HatData hat, int color)
[HarmonyPatch(typeof(HatParent), nameof(HatParent.SetHat), typeof(int))]
public class SetHatPatch {
public static bool Prefix(HatParent __instance, int color) {
if (!CustomHatRegistry.ContainsKey(__instance.Hat.name)) return true;
if (!CustomHatViewDatas.ContainsKey(__instance.Hat.name)) return true;
__instance.hatDataAsset = null;
__instance.PopulateFromHatViewData();
__instance.SetMaterialColor(color);
Expand Down Expand Up @@ -385,6 +386,47 @@ public static bool Prefix(HatParent __instance) {
}
}

[HarmonyPatch(typeof(HatParent), nameof(HatParent.LateUpdate))]
public static class HatParentLateUpdatePatch {
public static bool Prefix(HatParent __instance) {
return false;
if (__instance.Parent) {
HatViewData hatViewData;
try {
hatViewData = __instance.hatDataAsset.GetAsset();
return true;
} catch {
try {
hatViewData = CustomHatViewDatas[__instance.Hat.name];
} catch {
return false;
}
}
if (__instance.Hat && hatViewData != null) {
if (__instance.FrontLayer.sprite != hatViewData.ClimbImage && __instance.FrontLayer.sprite != hatViewData.FloorImage) {
if ((__instance.Hat.InFront || hatViewData.BackImage) && hatViewData.LeftMainImage) {
__instance.FrontLayer.sprite = (__instance.Parent.flipX ? hatViewData.LeftMainImage : hatViewData.MainImage);
}
if (hatViewData.BackImage && hatViewData.LeftBackImage) {
__instance.BackLayer.sprite = (__instance.Parent.flipX ? hatViewData.LeftBackImage : hatViewData.BackImage);
return false;
}
if (!hatViewData.BackImage && !__instance.Hat.InFront && hatViewData.LeftMainImage) {
__instance.BackLayer.sprite = (__instance.Parent.flipX ? hatViewData.LeftMainImage : hatViewData.MainImage);
return false;
}
} else if (__instance.FrontLayer.sprite == hatViewData.ClimbImage || __instance.FrontLayer.sprite == hatViewData.LeftClimbImage) {
SpriteAnimNodeSync spriteAnimNodeSync = __instance.SpriteSyncNode ?? __instance.GetComponent<SpriteAnimNodeSync>();
if (spriteAnimNodeSync) {
spriteAnimNodeSync.NodeId = 0;
}
}
}
}
return false;
}
}

[HarmonyPatch(typeof(HatParent), nameof(HatParent.SetFloorAnim))]
public class HatParentSetFloorAnimPatch {
public static bool Prefix(HatParent __instance) {
Expand All @@ -404,7 +446,7 @@ public static bool Prefix(HatParent __instance) {
public class HatParentSetIdleAnimPatch {
public static bool Prefix(HatParent __instance, int colorId) {
if (!__instance.Hat) return false;
if (!CustomHatRegistry.ContainsKey(__instance.Hat.name))
if (!CustomHatViewDatas.ContainsKey(__instance.Hat.name))
return true;
HatViewData hatViewData = CustomHatViewDatas[__instance.Hat.name];
__instance.hatDataAsset = null;
Expand Down Expand Up @@ -480,6 +522,18 @@ public static bool Prefix(HatParent __instance) {
}
}

[HarmonyPatch(typeof(CosmeticsCache), nameof(CosmeticsCache.GetHat))]
public class CosmeticsCacheGetHatPatch {
public static bool Prefix(string id, ref HatViewData __result) {
TheOtherRolesPlugin.Logger.LogMessage($"trying to load hat {id} from cosmetics cache");
if (CustomHatViewDatas.ContainsKey(id)) {
__result = CustomHatViewDatas[id];
return false;
}
return true;
}
}

[HarmonyPatch(typeof(HatsTab), nameof(HatsTab.OnEnable))]
public class HatsTabOnEnablePatch {
public static string innerslothPackageName = "Innersloth Hats";
Expand Down
9 changes: 5 additions & 4 deletions TheOtherRoles/Modules/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class UpdateData
public string TimeString;
public JObject Request;
public Version Version => Version.Parse(Tag);

public UpdateData(JObject data)
{
Tag = data["tag_name"]?.ToString().TrimStart('v');
Expand Down Expand Up @@ -199,6 +199,9 @@ public IEnumerator CoShowAnnouncement(string announcement, bool show=true, strin
[HideFromIl2Cpp]
public static IEnumerator CoCheckUpdates()
{
// Since running the update check task causes a crash for some users, allow the user to disable the updater by creating a file called noupdater.txt
// in their Among Us folder (root)
if (Il2CppSystem.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + "\\noupdater.txt")) yield break;
var torUpdateCheck = Task.Run(() => Instance.GetGithubUpdate("Eisbison", "TheOtherRoles"));
while (!torUpdateCheck.IsCompleted) yield return null;
if (torUpdateCheck.Result != null && torUpdateCheck.Result.IsNewer(Version.Parse(TheOtherRolesPlugin.VersionString)))
Expand All @@ -212,7 +215,7 @@ public static IEnumerator CoCheckUpdates()
if (submergedUpdateCheck.Result != null && (!SubmergedCompatibility.Loaded || submergedUpdateCheck.Result.IsNewer(SubmergedCompatibility.Version)))
{
Instance.SubmergedUpdate = submergedUpdateCheck.Result;
if (Instance.SubmergedUpdate.Tag.Equals("2022.10.26")) Instance.SubmergedUpdate = null;
if (Instance.SubmergedUpdate.Tag.Equals("2022.10.26") || IL2CPPChainloader.Instance.Plugins.TryGetValue("com.DigiWorm.LevelImposter", out PluginInfo _)) Instance.SubmergedUpdate = null;
}
}
Instance.OnSceneLoaded(SceneManager.GetActiveScene(), LoadSceneMode.Single);
Expand All @@ -223,10 +226,8 @@ public async Task<UpdateData> GetGithubUpdate(string owner, string repo)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("User-Agent", "TheOtherRoles Updater");

try {
var req = await client.GetAsync($"https://api.github.com/repos/{owner}/{repo}/releases/latest", HttpCompletionOption.ResponseContentRead);

if (!req.IsSuccessStatusCode) return null;

var dataString = await req.Content.ReadAsStringAsync();
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/RoleAssignmentPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void Postfix(ref int __result) {
__result = Mathf.Clamp(GameOptionsManager.Instance.CurrentGameOptions.NumImpostors, 1, 3);
}
}
}
}

[HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.Validate))]
class GameOptionsDataValidatePatch {
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public static void shifterShift(byte targetId) {
Shifter.clearAndReload();

// Suicide (exile) when impostor or impostor variants
if (player.Data.Role.IsImpostor || Helpers.isNeutral(player)) {
if ((player.Data.Role.IsImpostor || Helpers.isNeutral(player)) && !oldShifter.Data.IsDead) {
oldShifter.Exiled();
GameHistory.overrideDeathReasonAndKiller(oldShifter, DeadPlayer.CustomDeathReason.Shift, player);
if (oldShifter == Lawyer.target && AmongUsClient.Instance.AmHost && Lawyer.lawyer != null) {
Expand Down
6 changes: 4 additions & 2 deletions TheOtherRoles/SoundEffectsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace TheOtherRoles
public static class SoundEffectsManager

{
private static Dictionary<string, AudioClip> soundEffects;
private static Dictionary<string, AudioClip> soundEffects = new();

public static void Load()
{
Expand Down Expand Up @@ -69,7 +69,9 @@ public static void playAtPosition(string path, Vector2 position, float maxDurati
}

public static void stop(string path) {
if (Constants.ShouldPlaySfx()) SoundManager.Instance.StopSound(get(path));
var soundToStop = get(path);
if (soundToStop != null)
if (Constants.ShouldPlaySfx()) SoundManager.Instance.StopSound(soundToStop);
}

public static void stopAll() {
Expand Down
33 changes: 11 additions & 22 deletions TheOtherRoles/SubmergedCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ public static class Classes

public static bool IsSubmerged { get; private set; }

public static bool DisableO2MaskCheckForEmergency
{
set
{
if (!Loaded) return;
DisableO2MaskCheckField.SetValue(null, value);
}
}

public static void SetupMap(ShipStatus map)
{
Expand All @@ -59,17 +51,14 @@ public static void SetupMap(ShipStatus map)
}

private static Type SubmarineStatusType;
private static MethodInfo CalculateLightRadiusMethod;

private static Type TaskIsEmergencyPatchType;
private static FieldInfo DisableO2MaskCheckField;
private static MethodInfo CalculateLightRadiusMethod;

private static MethodInfo RpcRequestChangeFloorMethod;
private static Type FloorHandlerType;
private static MethodInfo GetFloorHandlerMethod;

private static Type Vent_MoveToVent_PatchType;
private static FieldInfo InTransitionField;
private static Type VentPatchDataType;
private static PropertyInfo InTransitionField;

private static Type CustomTaskTypesType;
private static FieldInfo RetrieveOxigenMaskField;
Expand Down Expand Up @@ -132,25 +121,25 @@ public static void Initialize()

InjectedTypes = (Dictionary<string, Type>) AccessTools.PropertyGetter(Types.FirstOrDefault(t => t.Name == "ComponentExtensions"), "RegisteredTypes")
.Invoke(null, Array.Empty<object>());

SubmarineStatusType = Types.First(t => t.Name == "SubmarineStatus");
CalculateLightRadiusMethod = AccessTools.Method(SubmarineStatusType, "CalculateLightRadius");

TaskIsEmergencyPatchType = Types.First(t => t.Name == "PlayerTask_TaskIsEmergency_Patch");
DisableO2MaskCheckField = AccessTools.Field(TaskIsEmergencyPatchType, "DisableO2MaskCheck");

FloorHandlerType = Types.First(t => t.Name == "FloorHandler");
GetFloorHandlerMethod = AccessTools.Method(FloorHandlerType, "GetFloorHandler", new Type[] {typeof(PlayerControl)});
RpcRequestChangeFloorMethod = AccessTools.Method(FloorHandlerType, "RpcRequestChangeFloor");

Vent_MoveToVent_PatchType = Types.First(t => t.Name == "Vent_MoveToVent_Patch");
InTransitionField = AccessTools.Field(Vent_MoveToVent_PatchType, "InTransition");
VentPatchDataType = Types.First(t => t.Name == "VentPatchData");

InTransitionField = AccessTools.Property(VentPatchDataType, "InTransition");

CustomTaskTypesType = Types.First(t => t.Name == "CustomTaskTypes");
RetrieveOxigenMaskField = AccessTools.Field(CustomTaskTypesType, "RetrieveOxygenMask");
RetrieveOxygenMask = (TaskTypes)RetrieveOxigenMaskField.GetValue(null);
var RetrieveOxigenMaskTaskTypeField = AccessTools.Field(CustomTaskTypesType, "taskType");
object OxygenMaskCustomTaskType = RetrieveOxigenMaskField.GetValue(null);
RetrieveOxygenMask = (TaskTypes)RetrieveOxigenMaskTaskTypeField.GetValue(OxygenMaskCustomTaskType);

SubmarineOxygenSystemType = Types.First(t => t.Name == "SubmarineOxygenSystem" && t.Namespace == "Submerged.Systems.CustomSystems.Oxygen");
SubmarineOxygenSystemType = Types.First(t => t.Name == "SubmarineOxygenSystem" && t.Namespace == "Submerged.Systems.Oxygen");
SubmarineOxygenSystemInstanceField = AccessTools.PropertyGetter(SubmarineOxygenSystemType, "Instance");
RepairDamageMethod = AccessTools.Method(SubmarineOxygenSystemType, "RepairDamage");
}
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/TheOtherRoles.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>4.3.3</Version>
<Version>4.3.4</Version>
<Description>TheOtherRoles</Description>
<Authors>Eisbison</Authors>
<LangVersion>latest</LangVersion>
Expand All @@ -16,9 +16,9 @@

<ItemGroup>
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2023.7.11" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.670" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.671" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" />
<PackageReference Include="Reactor" Version="2.2.0-ci.235" />
<PackageReference Include="Reactor" Version="2.2.0" />
</ItemGroup>

<Target Name="Date" BeforeTargets="BeforeBuild"> <!--Will make the compile time available s.t. we can let betas expire-->
Expand Down
Loading

0 comments on commit 2bd94e2

Please sign in to comment.