コード例 #1
0
ファイル: Jester.cs プロジェクト: ottomated/AmongUsJester
            public static void Prefix([HarmonyArgument(1)] MessageReader writer, [HarmonyArgument(0)] int callId)
            {
                switch ((CustomRpcMessage)callId)
                {
                case CustomRpcMessage.SetCustomRoles:     // Set Custom Roles
                    CustomRoles.Clear();
                    var giveRole = writer.ReadBoolean();
                    if (!giveRole)
                    {
                        return;
                    }
                    var playerId = writer.ReadByte();
                    var player   = GameData.Instance.GetPlayerById(playerId).CBEJMNMADDB;
                    CustomRoles.Add(player.PlayerId, true);

                    if (CustomRoles.ContainsKey(PlayerControl.LocalPlayer.PlayerId))
                    {
                        var role = CustomRoles[PlayerControl.LocalPlayer.PlayerId];
                        if (role)
                        {
                            PlayerControl.LocalPlayer.nameText.Color = JesterRole.Color;
                        }
                    }

                    return;
                }
            }
コード例 #2
0
ファイル: Jester.cs プロジェクト: ottomated/AmongUsJester
            public static void Postfix(PlayerControl __instance,
                                       [HarmonyArgument(0)] Il2CppReferenceArray <GameData.Nested_1> infected)
            {
                var playersToGiveRoles = new List <GameData.Nested_1>();

                foreach (var p in GameData.Instance.AllPlayers)
                {
                    if (infected.All(imposter => imposter.FMAAJCIEMEH != p.FMAAJCIEMEH))
                    {
                        playersToGiveRoles.Add(p);
                    }
                }

                var giveRole = false;;

                switch (GameOptionsPatches.JesterMode)
                {
                case GameOptionsPatches.JesterModes.Always:
                    giveRole = true;
                    break;

                case GameOptionsPatches.JesterModes.Maybe:
                    if (HashRandom.Method_1(10000) % 2 == 0)
                    {
                        giveRole = true;
                    }
                    break;
                }

                var messageWriter = AmongUsClient.Instance.StartRpc(__instance.NetId,
                                                                    (byte)CustomRpcMessage.SetCustomRoles, SendOption.Reliable);

                CustomRoles.Clear();

                messageWriter.Write(giveRole);
                if (giveRole)
                {
                    int index = HashRandom.Method_1(playersToGiveRoles.Count);
                    CustomRoles.Add(playersToGiveRoles[index].ACBLKMFEPKC, true);
                    messageWriter.Write(playersToGiveRoles[index].ACBLKMFEPKC);
                    if (CustomRoles.ContainsKey(PlayerControl.LocalPlayer.PlayerId))
                    {
                        var role = CustomRoles[PlayerControl.LocalPlayer.PlayerId];
                        if (role)
                        {
                            __instance.nameText.Color = JesterRole.Color;
                        }
                    }
                }

                messageWriter.EndMessage();

                // foreach (var (key, value) in CustomRoles)
                // {
                //     System.Console.WriteLine(key + ": " + value.Join(null, ", "));
                // }
            }
コード例 #3
0
ファイル: Jester.cs プロジェクト: ottomated/AmongUsJester
 public static void Postfix([HarmonyArgument(0)] GameData.Nested_1 player, ref PlayerVoteArea __result)
 {
     if (player.IBJBIALCEKB.AmOwner && CustomRoles.ContainsKey(player.FMAAJCIEMEH))
     {
         var role = CustomRoles[PlayerControl.LocalPlayer.PlayerId];
         if (role)
         {
             __result.NameText.Color = JesterRole.Color;
         }
     }
 }
コード例 #4
0
ファイル: Jester.cs プロジェクト: ottomated/AmongUsJester
 public static void Postfix(IntroCutscene __instance)
 {
     if (CustomRoles.ContainsKey(PlayerControl.LocalPlayer.PlayerId))
     {
         var role = CustomRoles[PlayerControl.LocalPlayer.PlayerId];
         if (role)
         {
             __instance.ImpostorText.Text = JesterRole.ImpostorText;
             __instance.Title.Text        = JesterRole.Name;
             __instance.Title.Color       = JesterRole.Color;
             __instance.BackgroundBar.material.SetColor(Color, JesterRole.Color);
         }
     }
 }