Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tugaru1975 authored Apr 9, 2022
1 parent 32d47e5 commit b0ee517
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 31 deletions.
13 changes: 12 additions & 1 deletion TownOfPlus/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public static PlayerControl playerById(byte id)

public static PlayerControl GetNamePlayer(string name)
{
PlayerControl player = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data.PlayerName.Equals(name));
PlayerControl player;
if (name == SaveManager.PlayerName) player = PlayerControl.LocalPlayer;
else player = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data.PlayerName.Equals(name));
return player;
}

Expand All @@ -109,6 +111,15 @@ public static Color GetPlayerColor(PlayerControl p)
}
}
}
public static string GetColorHEX(InnerNet.ClientData Client)
{
return ColorToHex(Palette.PlayerColors[Client.ColorId]);
}
public static string ColorToHex(Color32 color)
{
string hex = color.r.ToString("X2") + color.g.ToString("X2") + color.b.ToString("X2") + color.a.ToString("X2");
return hex;
}
}
class Timer
{
Expand Down
2 changes: 1 addition & 1 deletion TownOfPlus/ModSetting/LobbyTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void Prefix(GameStartManager __instance)
public static void Postfix(GameStartManager __instance)
{
// Lobby timer
if (!AmongUsClient.Instance.AmHost || !GameData.Instance) return;
if (!AmongUsClient.Instance.AmHost || !GameData.Instance || AmongUsClient.Instance.GameMode == GameModes.LocalGame) return;
if (update) currentText = __instance.PlayerCounter.text;
if (main.LobbyTimer.Value) __instance.PlayerCounter.text = currentText;
timer = Mathf.Max(0f, timer -= Time.deltaTime);
Expand Down
6 changes: 3 additions & 3 deletions TownOfPlus/ModSetting/ModSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public static class ModOptionSetting
new SelectionBehaviour("コード隠し", () => main.HideLobbyCodes.Value = !main.HideLobbyCodes.Value, main.HideLobbyCodes.Value),
new SelectionBehaviour("<color=#00bfff>ロビータイマー</color>", () => main.LobbyTimer.Value = !main.LobbyTimer.Value, main.LobbyTimer.Value),
new SelectionBehaviour("<color=#00bfff>ランダムマップ</color>", () => main.RandomMaps.Value = !main.RandomMaps.Value, main.RandomMaps.Value),
new SelectionBehaviour("<color=#FF0000>虹色の帽子</color>", () => main.RainbowHat.Value = !main.RainbowHat.Value, main.RainbowHat.Value),
new SelectionBehaviour("<color=#FF0000>虹色のバイザー</color>", () => main.RainbowVisor.Value = !main.RainbowVisor.Value, main.RainbowVisor.Value),
new SelectionBehaviour("虹色の帽子", () => main.RainbowHat.Value = !main.RainbowHat.Value, main.RainbowHat.Value),
new SelectionBehaviour("虹色のバイザー", () => main.RainbowVisor.Value = !main.RainbowVisor.Value, main.RainbowVisor.Value),
new SelectionBehaviour("虹色の名前", () => main.RainbowName.Value = !main.RainbowName.Value, main.RainbowName.Value),
new SelectionBehaviour("半透明の名前", () => main.TranslucentName.Value = !main.TranslucentName.Value, main.TranslucentName.Value),
new SelectionBehaviour("名前のアウトライン", () => main.NameOutline.Value = !main.NameOutline.Value, main.NameOutline.Value),
Expand All @@ -29,7 +29,7 @@ public static class ModOptionSetting
new SelectionBehaviour("<color=#FF0000>偽のレベル</color>", () => main.FakeLevel.Value = !main.FakeLevel.Value, main.FakeLevel.Value),
new SelectionBehaviour("ネームプレート非表示", () => main.HideNameplates.Value = !main.HideNameplates.Value, main.HideNameplates.Value),
new SelectionBehaviour("拡大縮小機能", () => main.Zoom.Value = !main.Zoom.Value, main.Zoom.Value),
new SelectionBehaviour("<color=#00bfff>PC以外を追い出す</color>", () => main.OPkick.Value = !main.OPkick.Value, main.OPkick.Value),
new SelectionBehaviour("<color=#00bfff>特定の機種を追い出す</color>", () => main.OPkick.Value = !main.OPkick.Value, main.OPkick.Value),
new SelectionBehaviour("<color=#00bfff>参加者にチャットを送る</color>", () => main.SendJoinPlayer.Value = !main.SendJoinPlayer.Value, main.SendJoinPlayer.Value),
new SelectionBehaviour("<color=#00bfff>二段の名前</color>", () => main.DoubleName.Value = !main.DoubleName.Value, main.DoubleName.Value),
new SelectionBehaviour("<color=#00bfff>ゲーム中の名前</color>", () => main.ChangeGameName.Value = !main.ChangeGameName.Value, main.ChangeGameName.Value),
Expand Down
11 changes: 9 additions & 2 deletions TownOfPlus/ModSetting/OtherPlatformKick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ public static void Postfix(GameStartManager __instance)
{
if (AmongUsClient.Instance.AmHost && main.OPkick.Value)
{
var args = main.SetOPkick.Value.Split(',');
foreach (InnerNet.ClientData p in AmongUsClient.Instance.allClients)
{
if (p.PlatformData.Platform != Platforms.StandaloneEpicPC && p.PlatformData.Platform != Platforms.StandaloneSteamPC)
if (p.Id == AmongUsClient.Instance.ClientId) continue;
for (int i = 0; i < args.Length - 1; i++)
{
AmongUsClient.Instance.KickPlayer(p.Id, false);
if (p.PlatformData.Platform == (Platforms)Enum.ToObject(typeof(Platforms), int.Parse(args[i])))
{
AmongUsClient.Instance.KickPlayer(p.Id, false);
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{(Platforms)Enum.ToObject(typeof(Platforms), int.Parse(args[i]))}");
break;
}
}
}
}
Expand Down
93 changes: 82 additions & 11 deletions TownOfPlus/Patches/ChatPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static class Delete
public static void Prefix(ChatController __instance)
{
if (!HudManager.Instance.Chat.IsOpen) return;
if (SaveManager.chatModeType != 1) return;
if (!main.ChatCommand.Value) return;
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Backspace))
{
Expand All @@ -35,6 +36,7 @@ public static class UndoAndRedo
public static void Prefix(ChatController __instance)
{
if (!HudManager.Instance.Chat.IsOpen) return;
if (SaveManager.chatModeType != 1) return;
if (!main.ChatCommand.Value) return;
if (__instance.TextArea.text != Text)
{
Expand Down Expand Up @@ -76,6 +78,7 @@ public static class CopyAndCut
public static void Prefix(ChatController __instance)
{
if (!HudManager.Instance.Chat.IsOpen) return;
if (SaveManager.chatModeType != 1) return;
if (!main.ChatCommand.Value) return;
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.X))
{
Expand All @@ -97,6 +100,7 @@ public static class Paste
public static void Prefix(ChatController __instance)
{
if (!HudManager.Instance.Chat.IsOpen) return;
if (SaveManager.chatModeType != 1) return;
if (!main.ChatCommand.Value) return;
if (Input.GetKeyDown(KeyCode.V) && Input.GetKey(KeyCode.LeftControl))
{
Expand Down Expand Up @@ -150,6 +154,7 @@ class ChatCommand
public static void Prefix(ChatController __instance)
{
if (!main.ChatCommand.Value) return;
if (SaveManager.chatModeType != 1) return;
text = __instance.TextArea.text;
SendChat.Addchat(__instance);
}
Expand Down Expand Up @@ -214,6 +219,10 @@ public static void Prefix(ChatController __instance)
{
CommandList.Add(("/TranslucentName", ""));
}
if (main.OPkick.Value && AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started && AmongUsClient.Instance.AmHost && AmongUsClient.Instance.GameMode != GameModes.FreePlay)
{
CommandList.Add(("/OPkick", ""));
}
if (CommandList == null) return;
var ChatText = __instance.TextArea.text;
if (Input.GetKeyDown(KeyCode.Tab) && ChatText.Substring(0, 1) == "/")
Expand All @@ -239,7 +248,8 @@ public static void Prefix(ChatController __instance)
{
foreach (PlayerControl p in PlayerControl.AllPlayerControls)
{
ChatCommand.Add(List.Command0 + " " + p.name);
if (p == PlayerControl.LocalPlayer) ChatCommand.Add(List.Command0 + " " + SaveManager.PlayerName);
else ChatCommand.Add(List.Command0 + " " + p.Data.PlayerName);
}
}
if (List.Command1 == "MapName")
Expand Down Expand Up @@ -270,6 +280,7 @@ class SendChat
public static int LobbyLimit = 15;
public static int LevelLimit = 100;
public static int TranslucentName = 100;
public static int OPkick = 10;
public static bool Addchat(ChatController __instance)
{
var canceled = false;
Expand Down Expand Up @@ -350,6 +361,10 @@ public static bool Addchat(ChatController __instance)
{
AddChat += ("\n/TranslucentName(TN) [数値] : 名前の透明度を変更します");
}
if (main.OPkick.Value && AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started && AmongUsClient.Instance.AmHost && AmongUsClient.Instance.GameMode != GameModes.FreePlay)
{
AddChat += ("\n/OPkick [数(1~10)] : 追い出すプレイヤーの機種を変更します。");
}
if (AddChat == "===コマンド一覧===") AddChat += ("\n実行可能なコマンドはありません");
break;

Expand Down Expand Up @@ -620,6 +635,43 @@ public static bool Addchat(ChatController __instance)
SetText = args[0];
break;

case "/opkick":
if (!(main.OPkick.Value && AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started && AmongUsClient.Instance.AmHost && AmongUsClient.Instance.GameMode != GameModes.FreePlay)) break;
if (args.Length < 3)
{
SendOPkick(__instance);
break;
}
if (Int32.TryParse(args[1], out OPkick))
{
OPkick = Math.Clamp(OPkick, 1, 10);
if (main.SetOPkick.Value.Contains($"{OPkick},"))
{
main.SetOPkick.Value = main.SetOPkick.Value.Replace($"{OPkick},","");
}
else
{
main.SetOPkick.Value += $"{OPkick},";
}
SendOPkick(__instance);
break;
}
AddChat = ("/OPkick [数(1~10)] : 追い出すプレイヤーの機種を変更します。\n" +
"===機種コマンド一覧===\n" +
"機種名 [数値]\n" +
"EpicPC [1]\n" +
"SteamPC [2]\n" +
"Mac [3]\n" +
"Win10 [4]\n" +
"Itch [5]\n" +
"IPhone [6]\n" +
"Android [7]\n" +
"Switch [8]\n" +
"Xbox [9]\n" +
"Playstation [10]\n");
SetText = args[0];
break;

case "/top":
case "/townofplus":
System.Diagnostics.Process.Start("https://github.com/tugaru1975/TownOfPlus");
Expand Down Expand Up @@ -666,12 +718,22 @@ public static bool Addchat(ChatController __instance)
public static void RandomMap(ChatController __instance)
{
__instance.AddChat(PlayerControl.LocalPlayer,
($"マップ名 : 設定\n" +
($"===有効マップ一覧===" +
$"マップ名 : 設定\n" +
$"TheSkeld : {(main.AddTheSkeld.Value ? "ON" : "OFF")}\n" +
$"MIRAHQ : {(main.AddMIRAHQ.Value ? "ON" : "OFF")}\n" +
$"Polus : {(main.AddPolus.Value ? "ON" : "OFF")}\n" +
$"AirShip : {(main.AddAirShip.Value ? "ON" : "OFF")}"));
}
public static void SendOPkick(ChatController __instance)
{
var text = ($"===Kickする機種一覧===\n");
for (int i = 1; i <= Enum.GetNames(typeof(Platforms)).Length - 1; i++)
{
text += $"{Enum.ToObject(typeof(Platforms), i)}".Replace("Standalone", "") + $" : {(main.SetOPkick.Value.Contains($"{i},") ? "ON" : "OFF")}\n";
}
__instance.AddChat(PlayerControl.LocalPlayer, text);
}
}
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public static class PlayerSpectate
Expand All @@ -680,32 +742,41 @@ public static class PlayerSpectate
public static PlayerControl player;
public static void Postfix(HudManager __instance)
{
if (PlayerSpectatePlayer != null && PlayerSpectatePlayer != player)
if (MeetingHud.Instance != null) PlayerSpectatePlayer = null;
if (PlayerSpectatePlayer != null)
{
player = PlayerSpectatePlayer;
if (PlayerSpectatePlayer != player)
{
player = PlayerSpectatePlayer;
flag = false;
}
PlayerControl.LocalPlayer.transform.position = PlayerSpectatePlayer.transform.position;
if (!flag)
{
PlayerSpectatePlayer.gameObject.SetActive(true);
Reset();
foreach (PlayerControl p in PlayerControl.AllPlayerControls)
{
if(p.Data.IsDead && p != PlayerSpectatePlayer) p.gameObject.SetActive(false);
if (p.Data.IsDead && p != PlayerSpectatePlayer) p.gameObject.SetActive(false);
}
}
if (MeetingHud.Instance != null) PlayerSpectatePlayer = null;
flag = true;
}
else
{
if (flag)
{
flag = false;
foreach (PlayerControl p in PlayerControl.AllPlayerControls)
{
if (p.Data.IsDead) p.gameObject.SetActive(true);
}
Reset();
}
}
}
public static void Reset()
{
foreach (PlayerControl p in PlayerControl.AllPlayerControls)
{
p.gameObject.SetActive(true);
}
}
}
}

Expand Down
24 changes: 16 additions & 8 deletions TownOfPlus/Patches/CustomOverlays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public static bool initializeOverlays()
infoOverlayRules.enableWordWrapping = false;
infoOverlayRules.alignment = TMPro.TextAlignmentOptions.TopLeft;
infoOverlayRules.transform.position = Vector3.zero;
infoOverlayRules.transform.localPosition = new Vector3(-1.25f, 0.45f, -910f);
infoOverlayRules.transform.localScale = Vector3.one * 1.5f;
infoOverlayRules.transform.localPosition = new Vector3(-1.5f, 0.8f, -910f);
infoOverlayRules.transform.localScale = Vector3.one * 1.25f;
infoOverlayRules.color = Palette.White;
infoOverlayRules.enabled = false;
}
Expand All @@ -125,7 +125,7 @@ public static bool initializeOverlays()
infoOverlayPlayer.enableWordWrapping = false;
infoOverlayPlayer.alignment = TMPro.TextAlignmentOptions.TopLeft;
infoOverlayPlayer.transform.position = Vector3.zero;
infoOverlayPlayer.transform.localPosition = infoOverlayRules.transform.localPosition + new Vector3(2.5f, 0.5f, 0.0f);
infoOverlayPlayer.transform.localPosition = infoOverlayRules.transform.localPosition + new Vector3(2.5f, 0f, 0.0f);
infoOverlayPlayer.transform.localScale = Vector3.one * 1.25f;
infoOverlayPlayer.color = Palette.White;
infoOverlayPlayer.enabled = false;
Expand Down Expand Up @@ -163,7 +163,7 @@ public static void showInfoOverlay()
infoUnderlay.enabled = true;

GameOptionsData o = PlayerControl.GameOptions;
List<string> gameOptions = o.ToString().Split("\n", StringSplitOptions.RemoveEmptyEntries).ToList().GetRange(2, 17);
List<string> gameOptions = o.ToString().Split("\n", StringSplitOptions.RemoveEmptyEntries).ToList().GetRange(2, 21);
infoOverlayRules.text = string.Join("\n", gameOptions);
infoOverlayRules.enabled = true;
string PlayerText = "<size=1.5>===プレイヤー一覧===</size>";
Expand All @@ -172,12 +172,20 @@ public static void showInfoOverlay()
if (Client == null) continue;
var Platform = $"{Client.PlatformData.Platform}";
var TOP = "";
if (playerVersions.ContainsKey(Client.Id))
if (playerVersions.ContainsKey(Client.Id) || Client.Id == AmongUsClient.Instance.ClientId)
{
PlayerVersion PV = playerVersions[Client.Id];
TOP = $"<size=0.75>(TOP v{PV.version})</size>";
if (Client.Id == AmongUsClient.Instance.ClientId)
{
TOP = $"<size=0.75>(TOP v{main.Version})</size>";
}
else
{
PlayerVersion PV = playerVersions[Client.Id];
TOP = $"<size=0.75>(TOP v{PV.version})</size>";
}

}
PlayerText += $"\n{TOP}{Client.PlayerName.Replace("\n","")} : {Platform.Replace("Standalone", "")}";
PlayerText += $"\n<color=#{Helpers.GetColorHEX(Client)}>■</color>{TOP}{(Client.Id == AmongUsClient.Instance.ClientId ? SaveManager.PlayerName : Client.PlayerName.Replace("\n",""))} : {Platform.Replace("Standalone", "")}";
}

infoOverlayPlayer.text = PlayerText;
Expand Down
Loading

0 comments on commit b0ee517

Please # to comment.