Skip to content

Commit 66a79d7

Browse files
authored
Merge pull request #6 from linmeideli/dev
Dev will release for a while
2 parents a1d990d + b4c3be0 commit 66a79d7

179 files changed

Lines changed: 39641 additions & 26939 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1587 additions & 6 deletions
Large diffs are not rendered by default.

Strings.xlsx

66 KB
Binary file not shown.

TheOtherRoles/Buttons.cs

Lines changed: 3074 additions & 2253 deletions
Large diffs are not rendered by default.
Lines changed: 64 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,76 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Epic.OnlineServices.Presence;
72
using HarmonyLib;
8-
using TheOtherRoles.Utilities;
3+
using Hazel;
94
using TMPro;
105
using UnityEngine;
11-
using static UnityEngine.UI.Button;
126
using UnityEngine.Events;
13-
using Hazel;
7+
using static UnityEngine.UI.Button;
148

15-
namespace TheOtherRoles.CustomGameModes {
16-
[HarmonyPatch]
17-
class GameModePatches {
18-
/*
19-
Creates a button in the info pane in the lobby to cycle through the game modes of TOR.
20-
*/
21-
[HarmonyPatch(typeof(LobbyInfoPane), nameof(LobbyInfoPane.Update))]
22-
class LobbyInfoPanePatch {
9+
namespace TheOtherRoles.CustomGameModes;
2310

24-
private static GameObject gameModeButton = null;
25-
public static void Postfix(LobbyInfoPane __instance) {
26-
if (gameModeButton != null|| !AmongUsClient.Instance.AmHost) { return; }
11+
[HarmonyPatch]
12+
internal class GameModePatches
13+
{
14+
/*
15+
Creates a button in the info pane in the lobby to cycle through the game modes of TOR.
16+
*/
17+
[HarmonyPatch(typeof(LobbyInfoPane), nameof(LobbyInfoPane.Update))]
18+
private class LobbyInfoPanePatch
19+
{
20+
private static GameObject gameModeButton;
2721

28-
var template = GameObject.Find("PRIVATE BUTTON");
29-
var GameModeText = GameObject.Find("GameModeText");
30-
if (template == null || GameModeText== null) { return; }
31-
gameModeButton = GameObject.Instantiate(template, template.transform.parent); //, GameModeText.transform);
32-
gameModeButton.transform.localPosition = template.transform.localPosition + new Vector3(0f, 0.65f, -2f);
33-
gameModeButton.name = "TOR GameModeButton";
22+
public static void Postfix(LobbyInfoPane __instance)
23+
{
24+
if (gameModeButton != null || !AmongUsClient.Instance.AmHost) return;
3425

35-
var pButton = gameModeButton.GetComponent<PassiveButton>();
36-
pButton.buttonText.text = GameModeText.GetComponent<TextMeshPro>().text;
37-
pButton.OnClick.RemoveAllListeners();
38-
pButton.OnClick = new ButtonClickedEvent();
39-
__instance.StartCoroutine(Effects.Lerp(0.1f, new Action<float>(p => { pButton.buttonText.text = Helpers.cs(Color.yellow, GameModeText.GetComponent<TextMeshPro>().text); })));
40-
gameModeButton.transform.GetChild(1).GetComponent<SpriteRenderer>().color = new Color(0.1f, 0.1f, 0.1f);
41-
gameModeButton.transform.GetChild(2).GetComponent<SpriteRenderer>().color = new Color(0f, 0f, 0f);
42-
pButton.OnClick.AddListener((Action)(() =>
43-
{
44-
TORMapOptions.gameMode = (CustomGamemodes)((int)(TORMapOptions.gameMode + 1) % Enum.GetNames(typeof(CustomGamemodes)).Length);
45-
__instance.StartCoroutine(Effects.Lerp(0.1f, new Action<float>(p => { pButton.buttonText.text = Helpers.cs(Color.yellow, GameModeText.GetComponent<TextMeshPro>().text); })));
46-
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
47-
writer.Write((byte)TORMapOptions.gameMode);
48-
AmongUsClient.Instance.FinishRpcImmediately(writer);
49-
RPCProcedure.shareGamemode((byte)TORMapOptions.gameMode);
50-
}));
51-
pButton.OnMouseOut = new UnityEvent();
52-
pButton.OnMouseOver = new UnityEvent();
53-
pButton.OnMouseOver.AddListener((Action)(() => {
54-
gameModeButton.transform.GetChild(1).gameObject.SetActive(true);
55-
gameModeButton.transform.GetChild(2).gameObject.SetActive(false);
56-
}));
57-
pButton.OnMouseOut.AddListener((Action)(() => {
58-
gameModeButton.transform.GetChild(1).gameObject.SetActive(false);
59-
gameModeButton.transform.GetChild(2).gameObject.SetActive(true);
60-
}));
26+
var template = GameObject.Find("PRIVATE BUTTON");
27+
var GameModeText = GameObject.Find("GameModeText");
28+
if (template == null || GameModeText == null) return;
29+
gameModeButton = GameObject.Instantiate(template, template.transform.parent); //, GameModeText.transform);
30+
gameModeButton.transform.localPosition = template.transform.localPosition + new Vector3(0f, 0.65f, -2f);
31+
gameModeButton.name = "TOR GameModeButton";
6132

62-
}
33+
var pButton = gameModeButton.GetComponent<PassiveButton>();
34+
pButton.buttonText.text = GameModeText.GetComponent<TextMeshPro>().text;
35+
pButton.OnClick.RemoveAllListeners();
36+
pButton.OnClick = new ButtonClickedEvent();
37+
__instance.StartCoroutine(Effects.Lerp(0.1f,
38+
new Action<float>(p =>
39+
{
40+
pButton.buttonText.text =
41+
Helpers.cs(Color.yellow, GameModeText.GetComponent<TextMeshPro>().text);
42+
})));
43+
gameModeButton.transform.GetChild(1).GetComponent<SpriteRenderer>().color = new Color(0.1f, 0.1f, 0.1f);
44+
gameModeButton.transform.GetChild(2).GetComponent<SpriteRenderer>().color = new Color(0f, 0f, 0f);
45+
pButton.OnClick.AddListener((Action)(() =>
46+
{
47+
TORMapOptions.gameMode =
48+
(CustomGamemodes)((int)(TORMapOptions.gameMode + 1) %
49+
Enum.GetNames(typeof(CustomGamemodes)).Length);
50+
__instance.StartCoroutine(Effects.Lerp(0.1f,
51+
new Action<float>(p =>
52+
{
53+
pButton.buttonText.text =
54+
Helpers.cs(Color.yellow, GameModeText.GetComponent<TextMeshPro>().text);
55+
})));
56+
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
57+
(byte)CustomRPC.ShareGamemode, SendOption.Reliable);
58+
writer.Write((byte)TORMapOptions.gameMode);
59+
AmongUsClient.Instance.FinishRpcImmediately(writer);
60+
RPCProcedure.shareGamemode((byte)TORMapOptions.gameMode);
61+
}));
62+
pButton.OnMouseOut = new UnityEvent();
63+
pButton.OnMouseOver = new UnityEvent();
64+
pButton.OnMouseOver.AddListener((Action)(() =>
65+
{
66+
gameModeButton.transform.GetChild(1).gameObject.SetActive(true);
67+
gameModeButton.transform.GetChild(2).gameObject.SetActive(false);
68+
}));
69+
pButton.OnMouseOut.AddListener((Action)(() =>
70+
{
71+
gameModeButton.transform.GetChild(1).gameObject.SetActive(false);
72+
gameModeButton.transform.GetChild(2).gameObject.SetActive(true);
73+
}));
6374
}
6475
}
65-
}
76+
}
Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,50 @@
11
using System.Collections.Generic;
22
using UnityEngine;
33

4-
namespace TheOtherRoles.CustomGameModes {
5-
class GuesserGM { // Guesser Gamemode
6-
public static List<GuesserGM> guessers = new List<GuesserGM>();
7-
public static Color color = new Color32(255, 255, 0, byte.MaxValue);
8-
9-
public PlayerControl guesser = null;
10-
public int shots = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeNumberOfShots.getFloat());
11-
public int tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
12-
public GuesserGM(PlayerControl player) {
13-
guesser = player;
14-
guessers.Add(this);
15-
}
16-
17-
public static int remainingShots(byte playerId, bool shoot = false) {
18-
19-
var g = guessers.FindLast(x => x.guesser.PlayerId == playerId);
20-
if (g == null) return 0;
21-
if (shoot) g.shots--;
22-
return g.shots;
23-
}
24-
25-
public static void clear(byte playerId) {
26-
var g = guessers.FindLast(x => x.guesser.PlayerId == playerId);
27-
if (g == null) return;
28-
g.guesser = null;
29-
g.shots = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeNumberOfShots.getFloat());
30-
g.tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
31-
32-
guessers.Remove(g);
33-
}
34-
35-
public static void clearAndReload() {
36-
guessers = new List<GuesserGM>();
37-
}
38-
39-
public static bool isGuesser(byte playerId) {
40-
return guessers.FindAll(x => x.guesser.PlayerId == playerId).Count > 0;
41-
}
4+
namespace TheOtherRoles.CustomGameModes;
5+
6+
internal class GuesserGM
7+
{
8+
// Guesser Gamemode
9+
public static List<GuesserGM> guessers = new();
10+
public static Color color = new Color32(255, 255, 0, byte.MaxValue);
11+
12+
public PlayerControl guesser;
13+
public int shots = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeNumberOfShots.getFloat());
14+
public int tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
15+
16+
public GuesserGM(PlayerControl player)
17+
{
18+
guesser = player;
19+
guessers.Add(this);
20+
}
21+
22+
public static int remainingShots(byte playerId, bool shoot = false)
23+
{
24+
var g = guessers.FindLast(x => x.guesser.PlayerId == playerId);
25+
if (g == null) return 0;
26+
if (shoot) g.shots--;
27+
return g.shots;
28+
}
29+
30+
public static void clear(byte playerId)
31+
{
32+
var g = guessers.FindLast(x => x.guesser.PlayerId == playerId);
33+
if (g == null) return;
34+
g.guesser = null;
35+
g.shots = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeNumberOfShots.getFloat());
36+
g.tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
37+
38+
guessers.Remove(g);
39+
}
40+
41+
public static void clearAndReload()
42+
{
43+
guessers = new List<GuesserGM>();
44+
}
45+
46+
public static bool isGuesser(byte playerId)
47+
{
48+
return guessers.FindAll(x => x.guesser.PlayerId == playerId).Count > 0;
4249
}
4350
}

0 commit comments

Comments
 (0)