Skip to content

Commit 4006083

Browse files
Merge pull request #9 from MyDragonBreath/dev
v0.0.5
2 parents e5939d3 + 4764c34 commit 4006083

File tree

7 files changed

+121
-1
lines changed

7 files changed

+121
-1
lines changed

MCI/MCIPlugin.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
11
using BepInEx;
22
using BepInEx.Unity.IL2CPP;
33
using HarmonyLib;
4+
using System;
5+
using UnityEngine.SceneManagement;
46

57
namespace MCI
68
{
79
[BepInAutoPlugin("dragonbreath.au.mci", "MCI", VersionString)]
810
[BepInProcess("Among Us.exe")]
911
public partial class MCIPlugin : BasePlugin
1012
{
11-
public const string VersionString = "0.0.4";
13+
public const string VersionString = "0.0.5";
1214
public static System.Version vVersion = new(VersionString);
1315
public Harmony Harmony { get; } = new(Id);
1416
public override void Load()
1517
{
1618
Harmony.PatchAll();
1719
UpdateChecker.checkForUpdate();
20+
21+
SceneManager.add_sceneLoaded((Action<Scene, LoadSceneMode>)((scene, _) =>
22+
{
23+
if (scene.name == "MainMenu")
24+
{
25+
ModManager.Instance.ShowModStamp();
26+
}
27+
}));
28+
}
29+
30+
31+
public static bool Persistence = true;
32+
33+
}
34+
35+
36+
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
37+
public static class CountdownPatch
38+
{
39+
public static void Prefix(GameStartManager __instance)
40+
{
41+
__instance.countDownTimer = 0;
1842
}
1943
}
2044
}

MCI/Patches/AirshipSpawn.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using HarmonyLib;
2+
using System;
3+
4+
namespace MCI.Patches
5+
{
6+
[HarmonyPatch]
7+
8+
public sealed class AirshipSpawn
9+
{
10+
[HarmonyPatch(typeof(SpawnInMinigame), nameof(SpawnInMinigame.Begin))]
11+
[HarmonyPostfix]
12+
13+
public static void Postfix(SpawnInMinigame __instance)
14+
{
15+
foreach (var player in PlayerControl.AllPlayerControls)
16+
{
17+
if (!player.Data.PlayerName.Contains("Robot")) continue;
18+
var rand = new Random().Next(0, __instance.Locations.Count);
19+
player.gameObject.SetActive(true);
20+
player.NetTransform.RpcSnapTo(__instance.Locations[rand].Location);
21+
}
22+
}
23+
}
24+
}

MCI/Patches/KeyboardJoystick.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ public static void Postfix()
3131
controllingFigure = Mathf.Clamp(controllingFigure, 0, PlayerControl.AllPlayerControls.Count - 1);
3232
InstanceControl.SwitchTo((byte)controllingFigure);
3333
}
34+
35+
if (Input.GetKeyDown(KeyCode.F6))
36+
{
37+
MCIPlugin.Persistence = !MCIPlugin.Persistence;
38+
}
39+
40+
if (Input.GetKeyDown(KeyCode.F11))
41+
{
42+
Utils.RemoveAllPlayers();
43+
}
3444
}
3545
}
3646
}

MCI/Patches/OnLobbyStart.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using HarmonyLib;
2+
3+
namespace MCI.Patches
4+
{
5+
[HarmonyPatch]
6+
7+
public sealed class OnLobbyStart
8+
{
9+
[HarmonyPatch(typeof(LobbyBehaviour), nameof(LobbyBehaviour.Start))]
10+
[HarmonyPostfix]
11+
12+
public static void Postfix()
13+
{
14+
if (MCIPlugin.Persistence && InstanceControl.clients.Count != 0)
15+
{
16+
int count = InstanceControl.clients.Count;
17+
InstanceControl.clients.Clear();
18+
InstanceControl.PlayerIdClientId.Clear();
19+
for (int i = 0; i < count; i++)
20+
{
21+
Utils.CreatePlayerInstance("Robot");
22+
}
23+
}
24+
}
25+
}
26+
}

MCI/Patches/PingTracker.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public static void Postfix(PingTracker __instance)
1515
position.AdjustPosition();
1616
__instance.text.text +=
1717
"\n<color=#ff6700FF>MCI v" + MCIPlugin.VersionString + "</color>";
18+
__instance.text.text += (MCIPlugin.Persistence) ?
19+
" <color=#00ff00FF>[✓]</color>": " <color=#ff0000FF>[X]</color>";
1820
if (UpdateChecker.needsUpdate) __instance.text.text += " - <color=#ff0000FF>UPDATE AVAILABLE</color>";
1921
__instance.text.text +=
2022
"\n by MyDragonBreath, whichTwix";

MCI/Utils.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using InnerNet;
2+
using System.Linq;
23
using UnityEngine;
34

45
namespace MCI
@@ -49,6 +50,27 @@ public static PlayerControl PlayerById(byte id)
4950
}
5051
return null;
5152
}
53+
54+
55+
56+
57+
58+
59+
60+
public static void RemovePlayer(byte id)
61+
{
62+
int clientId = InstanceControl.clients.FirstOrDefault(x => x.Value.Character.PlayerId == id).Key;
63+
ClientData outputData;
64+
InstanceControl.clients.Remove(clientId, out outputData);
65+
InstanceControl.PlayerIdClientId.Remove(id);
66+
AmongUsClient.Instance.RemovePlayer(clientId, DisconnectReasons.ExitGame);
67+
AmongUsClient.Instance.allClients.Remove(outputData);
68+
}
69+
70+
public static void RemoveAllPlayers()
71+
{
72+
foreach (byte playerId in InstanceControl.PlayerIdClientId.Keys) RemovePlayer(playerId);
73+
}
5274
}
5375
}
5476

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ It can also be buggy with different mods differently depending on how they inter
66
Think of this as more like a ease-of-access utility then a standlone testing environment.
77

88
Whilst in lobby press f5 to add players,
9+
press f6 to toggle between keeping or losing bots between games,
910
and in game press f9 to move up or f10 to move down through the id list.
11+
You can press f11 to remove all bots.
1012

1113
i've left it openended for any future features but i dont think i can see myself regularly maintaning this beyond bug fixes,
1214
but your welcome to pr and contribute
@@ -21,13 +23,23 @@ Relies on Bepinex
2123

2224
| Among Us Version | Download |
2325
|----------|-------------|
26+
| v2023.2.28 | [v0.0.5](https://github.com/MyDragonBreath/AmongUs.MultiClientInstancing/releases/tag/v0.0.5)
2427
| v2022.12.14 | [v0.0.4](https://github.com/MyDragonBreath/AmongUs.MultiClientInstancing/releases/tag/v0.0.4)
2528
| v2022.6.21 & v2022.7.12 | [v0.0.2](https://github.com/MyDragonBreath/AmongUs.MultiClientInstancing/releases/tag/v0.0.2)
2629
| v2022.6.21 & v2022.7.12 | [v0.0.1](https://github.com/MyDragonBreath/AmongUs.MultiClientInstancing/releases/tag/v0.0.1)
2730

2831
<details>
2932
<summary> Changelog </summary>
3033
<details>
34+
<summary> v0.0.5 </summary>
35+
<ul>
36+
<li> Robot presistence </li>
37+
<li> Player removal keybind </li>
38+
<li> Countdown timer removed </li>
39+
<li> Fix Airship Spawning </li>
40+
</ul>
41+
</details>
42+
<details>
3143
<summary> v0.0.4 </summary>
3244
<ul>
3345
<li> Updated to latest version, fixed bugs </li>

0 commit comments

Comments
 (0)