Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
fix(Glitch): re-initialize the mimic menu
Browse files Browse the repository at this point in the history
  • Loading branch information
NotSugden committed Jul 24, 2021
1 parent 9aa9b74 commit 63c3de6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 8 additions & 12 deletions source/Patches/Roles/Glitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ private void UnMimic()

private void ChooseMimic(PlayerControl player)
{
MimicList.SetVisible(false);
MimicList.Toggle();
MimicList.gameObject.Destroy();
MimicList = null;

AbilityManager.EnableButtons();

if (player == null) return;

TownOfUs.LogMessage($"Chosen Morph: {player.name}");

var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
(byte)CustomRPC.SetMimic, SendOption.Reliable, -1);
writer.Write(Player.PlayerId);
Expand Down Expand Up @@ -191,10 +192,13 @@ ChatBubble NextBubble(int index, PlayerControl player)
emptyBubble.NameText.gameObject.SetActive(false);
AddButton(emptyBubble);

var exitBubble = NextBubble(idx, localPlayer);
var exitBubble = NextBubble(idx++, localPlayer);
exitBubble.Player.gameObject.SetActive(false);
exitBubble.NameText.gameObject.SetActive(false);

while(idx < items.childCount)
items.GetChild(idx++).gameObject.SetActive(false);

AddButton(exitBubble)
.AddListener((System.Action)(() => ChooseMimic(null)));
MimicButton.KillButton.SetCoolDown(
Expand All @@ -206,15 +210,7 @@ ChatBubble NextBubble(int index, PlayerControl player)
public void MimicCallback()
{
AbilityManager.DisableButtons();
if (MimicList == null)
{
InitalizeList();
}
else
{
MimicList.SetVisible(true);
MimicList.Toggle();
}
InitalizeList();

Player.NetTransform.Halt();

Expand Down
2 changes: 1 addition & 1 deletion source/Patches/RpcHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static void GenEachRole(List<GameData.PlayerInfo> infected)
{
Role.LobbyBehaviour_Start.Postfix();
PlayerControl.LocalPlayer.Data.IsImpostor = true;
var role = typeof(Miner);
var role = typeof(Glitch);
Role.Gen<Role>(
role, PlayerControl.LocalPlayer, Enum.Parse<CustomRPC>($"Set{role.Name}")
);
Expand Down

0 comments on commit 63c3de6

Please sign in to comment.