コード例 #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, ", "));
                // }
            }