Skip to content

Commit

Permalink
Clear Code
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Oct 25, 2024
1 parent ad2de16 commit 8eb09d6
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 27 deletions.
3 changes: 1 addition & 2 deletions TheOtherRoles/Buttons/CustomButton.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using TheOtherRoles.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Object = UnityEngine.Object;
using static TheOtherRoles.Buttons.HudManagerStartPatch;
using Object = UnityEngine.Object;

namespace TheOtherRoles.Buttons;

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Modules/LateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void Update(float deltaTime)
}

[HarmonyPatch(typeof(ModManager), nameof(ModManager.LateUpdate))]
class ModManagerLateUpdatePatch
internal class ModManagerLateUpdatePatch
{
public static void Prefix(ModManager __instance)
{
Expand Down
9 changes: 0 additions & 9 deletions TheOtherRoles/Modules/ModTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,4 @@ internal static string Translate(this string key)
{
return getString(key);
}
}

[HarmonyPatch(typeof(LanguageSetter), nameof(LanguageSetter.SetLanguage))]
class SetLanguagePatch
{
static void Postfix()
{
//ClientOptionsPatch.updateTranslations();
}
}
4 changes: 2 additions & 2 deletions TheOtherRoles/Modules/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
public IEnumerator CoShowAnnouncement(string announcement, bool show = true, string shortTitle = "TOUE Update", string title = "", string date = "")
{
var mgr = FindObjectOfType<MainMenuManager>(true);
var popUpTemplate = UnityEngine.Object.FindObjectOfType<AnnouncementPopUp>(true);
var popUpTemplate = FindObjectOfType<AnnouncementPopUp>(true);
if (popUpTemplate == null)
{
Error("couldnt show credits, popUp is null");
yield return null;
}
var popUp = UnityEngine.Object.Instantiate(popUpTemplate);
var popUp = Instantiate(popUpTemplate);

popUp.gameObject.SetActive(true);

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/ExileControllerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class ExileControllerBeginPatch
{
public static GameData.PlayerInfo lastExiled;
public static TextMeshPro confirmImpostorSecondText;
static bool IsSec;
private static bool IsSec;
public static bool Prefix(ExileController __instance, [HarmonyArgument(0)] ref GameData.PlayerInfo exiled, [HarmonyArgument(1)] bool tie)
{
lastExiled = exiled;
Expand Down
5 changes: 3 additions & 2 deletions TheOtherRoles/Patches/LobbyRoleList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public static void roleInfosOnclick(string team, RoleTeam teamId)
count++;
}
}
static void AddInfoCard(RoleInfo roleInfo)

private static void AddInfoCard(RoleInfo roleInfo)
{
string roleSettingDescription = roleInfo.FullDescription != "" ? roleInfo.FullDescription : roleInfo.ShortDescription;
string coloredHelp = cs(Color.white, roleSettingDescription);
Expand Down Expand Up @@ -216,7 +217,7 @@ static void AddInfoCard(RoleInfo roleInfo)
}

[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.Start))]
class GameStartPatch
internal class GameStartPatch
{
public static void Prefix(ShipStatus __instance)
{
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/MeetingHudPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private static bool Prefix(MeetingHud __instance)
{
if (playerVoteArea.VotedFor != Balancer.targetplayerright.PlayerId && playerVoteArea.VotedFor != Balancer.targetplayerleft.PlayerId)
{
playerVoteArea.VotedFor = Helpers.GetRandom([Balancer.targetplayerright.PlayerId, Balancer.targetplayerleft.PlayerId]);
playerVoteArea.VotedFor = Helpers.GetRandom((byte[])([Balancer.targetplayerright.PlayerId, Balancer.targetplayerleft.PlayerId]));
}
}

Expand Down
8 changes: 4 additions & 4 deletions TheOtherRoles/Patches/TaskCountPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

namespace TheOtherRoles.Patches;

class TaskCount
internal class TaskCount
{
public static bool WireTaskIsRandom => CustomOptionHolder.WireTaskIsRandomOption.getBool();
public static int WireTaskNum => CustomOptionHolder.WireTaskNumOption.GetInt();

[HarmonyPatch(typeof(NormalPlayerTask), nameof(NormalPlayerTask.Initialize))]
class NormalPlayerTaskInitializePatch
private class NormalPlayerTaskInitializePatch
{
static void Postfix(NormalPlayerTask __instance)
private static void Postfix(NormalPlayerTask __instance)
{
if (__instance.TaskType != TaskTypes.FixWiring || !WireTaskIsRandom) return;
List<Console> orgList = MapUtilities.CachedShipStatus.AllConsoles.Where((Console t) => t.TaskTypes.Contains(__instance.TaskType)).ToList();
Expand All @@ -28,7 +28,7 @@ static void Postfix(NormalPlayerTask __instance)
{
if (list.Count == 0)
list = new List<Console>(orgList);
int index = GetRandomIndex(list);
int index = GetRandom(list);
__instance.Data[i] = (byte)list[index].ConsoleId;
list.RemoveAt(index);
}
Expand Down
13 changes: 10 additions & 3 deletions TheOtherRoles/Roles/Crewmate/Balancer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,14 @@ private static void BalancerOnClick(int Index, MeetingHud __instance)
if (currentTarget == null)
{
currentTarget = Target;
__instance.playerStates.ForEach(x => { if (x.TargetPlayerId == currentTarget.PlayerId && x.transform.FindChild("BalancerButton") != null) x.transform.FindChild("BalancerButton").gameObject.SetActive(false); });
__instance.playerStates.ForEach(x =>
{
if (x.TargetPlayerId == currentTarget.PlayerId && x.transform.FindChild("BalancerButton") != null)
x.transform.FindChild("BalancerButton").gameObject.SetActive(false);
});
return;
}
IsAbilityUsed--;
if (balancer.IsDead()) return;
var writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
(byte)CustomRPC.BalancerBalance, SendOption.Reliable);
Expand All @@ -404,8 +409,10 @@ private static void BalancerOnClick(int Index, MeetingHud __instance)
writer.Write(Target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.balancerBalance(PlayerControl.LocalPlayer.PlayerId, currentTarget.PlayerId, Target.PlayerId);
IsAbilityUsed--;
__instance.playerStates.ForEach(x => { if (x.transform.FindChild("BalancerButton") != null) Object.Destroy(x.transform.FindChild("BalancerButton").gameObject); });
__instance.playerStates.ForEach(x =>
{
if (x.transform.FindChild("BalancerButton") != null) Object.Destroy(x.transform.FindChild("BalancerButton").gameObject);
});
}

private static void Event(MeetingHud __instance)
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Roles/Crewmate/Prosecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static void Prefix(GameObject obj)

[HarmonyPatch(typeof(ExileController), nameof(ExileController.Begin))]
[HarmonyPriority(Priority.First)]
class ExileControllerPatch
internal class ExileControllerPatch
{
public static ExileController lastExiled;
public static void Prefix(ExileController __instance)
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Roles/Guesser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static int remainingShots(byte playerId, bool shoot = false)
public static int Page;
public static byte guesserCurrentTarget;

static void guesserSelectRole(RoleTeam Role, bool SetPage = true)
private static void guesserSelectRole(RoleTeam Role, bool SetPage = true)
{
currentTeamType = Role;
if (SetPage) Page = 1;
Expand Down

0 comments on commit 8eb09d6

Please sign in to comment.