static void Postfix(HudManager __instance)
        {
            if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
            {
                return;
            }

            foreach (var player in PlayerControl.AllPlayerControls)
            {
                if (player.Data.PlayerName != "Hunter")
                {
                    continue;
                }

                if (!defaultSet)
                {
                    System.Console.Write(currentColor);
                    defaultSet = true;
                    player.myRend.material.SetColor("_BackColor", colors[currentColor]);
                    player.myRend.material.SetColor("_BodyColor", colors[currentColor]);
                    newColor = colors[currentColor];
                    if (currentColor + 1 >= colors.Length)
                    {
                        currentColor = -1;
                    }
                    nextColor = colors[currentColor + 1];
                }

                newColor = VecToColor(Vector3.MoveTowards(ColorToVec(newColor), ColorToVec(nextColor), 0.02f));
                player.myRend.material.SetColor("_BackColor", newColor);
                player.myRend.material.SetColor("_BodyColor", newColor);

                if (newColor != nextColor)
                {
                    continue;
                }

                currentColor++;
                defaultSet = false;
            }

            lastQ      = Input.GetKeyUp(KeyCode.Q);
            KillButton = __instance.KillButton;
            var target = PlayerControl.LocalPlayer.FindClosestPlayer();

            if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ && __instance.UseButton.isActiveAndEnabled)
            {
                PerformKillPatch.Prefix(KillButton);
            }

            if (PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer) && __instance.UseButton.isActiveAndEnabled)
            {
                KillButton.gameObject.SetActive(true);
                KillButton.isActive = true;
                KillButton.SetCoolDown(0f, 1f);
                KillButton.renderer.sprite = Main.Assets.repairIco;
                KillButton.renderer.color  = Palette.EnabledColor;
                KillButton.renderer.material.SetFloat("_Desat", 0f);
            }

            Main.Logic.clearJokerTasks();
            if (rend != null)
            {
                rend.SetActive(false);
            }

            var sabotageActive = false;

            foreach (var task in PlayerControl.LocalPlayer.myTasks)
            {
                if (PlayerTools.sabotageTasks.Contains(task.TaskType))
                {
                    sabotageActive = true;
                }
            }
            Main.Logic.sabotageActive = sabotageActive;

            if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getImmortalPlayer().PlayerControl.Data.IsDead)
            {
                BreakShield(true);
            }
            if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getRolePlayer(Role.Medic) != null &&
                Main.Logic.getRolePlayer(Role.Medic).PlayerControl.Data.IsDead)
            {
                BreakShield(true);
            }
            if (Main.Logic.getRolePlayer(Role.Medic) == null && Main.Logic.getImmortalPlayer() != null)
            {
                BreakShield(true);
            }

            // TODO: this list could maybe find a better place?
            //       It is only meant for looping through role "name", "color" and "show" simultaneously
            var roles = new List <(Role roleName, Color roleColor, bool showRole)>()
            {
                (Role.Medic, Main.Palette.medicColor, Main.Config.showMedic),
                (Role.Officer, Main.Palette.officerColor, Main.Config.showOfficer),
                (Role.Engineer, Main.Palette.engineerColor, Main.Config.showEngineer),
                (Role.Joker, Main.Palette.jokerColor, Main.Config.showJoker),
            };

            // Color of imposters and crewmates
            foreach (var player in PlayerControl.AllPlayerControls)
            {
                player.nameText.Color = player.Data.IsImpostor && (PlayerControl.LocalPlayer.Data.IsImpostor || PlayerControl.LocalPlayer.Data.IsDead)
                    ? Color.red
                    : Color.white;
            }

            // Color of roles (always see yourself, and depending on setting, others may see the role too)
            foreach (var(roleName, roleColor, showRole) in roles)
            {
                var role = Main.Logic.getRolePlayer(roleName);
                if (role == null)
                {
                    continue;
                }
                if (PlayerControl.LocalPlayer.isPlayerRole(roleName) || showRole || PlayerControl.LocalPlayer.Data.IsDead)
                {
                    role.PlayerControl.nameText.Color = roleColor;
                }
            }

            //Color of name plates in the voting hub should be the same as in-game
            if (MeetingHud.Instance != null)
            {
                foreach (var playerVoteArea in MeetingHud.Instance.playerStates)
                {
                    if (playerVoteArea.NameText == null)
                    {
                        continue;
                    }

                    var player = PlayerTools.getPlayerById((byte)playerVoteArea.TargetPlayerId);
                    playerVoteArea.NameText.Color = player.nameText.Color;
                }
            }

            if (Main.Logic.anyPlayerImmortal())
            {
                var showShielded   = Main.Config.showProtected;
                var shieldedPlayer = Main.Logic.getImmortalPlayer().PlayerControl;
                if (showShielded == (int)ShieldOptions.Everyone)
                {
                    GiveShieldedPlayerShield(shieldedPlayer);
                }
                else if (PlayerControl.LocalPlayer.isPlayerImmortal() && (showShielded == (int)ShieldOptions.Self || showShielded == (int)ShieldOptions.SelfAndMedic))
                {
                    GiveShieldedPlayerShield(shieldedPlayer);
                }
                else if (PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) &&
                         (showShielded == (int)ShieldOptions.Medic || showShielded == (int)ShieldOptions.SelfAndMedic))
                {
                    GiveShieldedPlayerShield(shieldedPlayer);
                }
            }

            if (PlayerControl.LocalPlayer.Data.IsDead)
            {
                if (!PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer))
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.renderer.enabled = false;
                    KillButton.isActive         = false;
                    KillButton.SetTarget(null);
                    KillButton.enabled = false;
                    return;
                }
            }

            if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) &&
                __instance.UseButton.isActiveAndEnabled)
            {
                KillButton.renderer.sprite = Main.Assets.shieldIco;
                KillButton.gameObject.SetActive(true);
                KillButton.isActive = true;
                KillButton.SetCoolDown(0f, 1f);
                KillButton.SetTarget(target);
            }

            if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole(Role.Officer) &&
                __instance.UseButton.isActiveAndEnabled)
            {
                KillButton.gameObject.SetActive(true);
                KillButton.isActive = true;
                KillButton.SetCoolDown(PlayerTools.getOfficerCD(), PlayerControl.GameOptions.KillCooldown + 15.0f);
                KillButton.SetTarget(target);
            }
        }
예제 #2
0
        static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
        {
            var packetId = HKHMBLJFLMC;
            var reader   = ALMCIJKELCP;

            var setRole = new Action <string>(roleName =>
            {
                var roleId = ALMCIJKELCP.ReadByte();
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == roleId)
                    {
                        player.getModdedControl().Role = roleName;
                    }
                }
            });

            switch (packetId)
            {
            case (byte)CustomRPC.AttemptSound:
                BreakShield(false);
                break;

            case (byte)CustomRPC.FixLights:
                var switchSystem = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast <SwitchSystem>();
                switchSystem.ActualSwitches = switchSystem.ExpectedSwitches;
                break;

            case (byte)CustomRPC.SetLocalPlayers:
                localPlayers.Clear();
                localPlayer = PlayerControl.LocalPlayer;
                var localPlayerBytes = ALMCIJKELCP.ReadBytesAndSize();
                foreach (var id in localPlayerBytes)
                {
                    foreach (var player in PlayerControl.AllPlayerControls)
                    {
                        if (player.PlayerId == id)
                        {
                            localPlayers.Add(player);
                        }
                    }
                }
                break;

            case (byte)CustomRPC.ResetVaribles:
                Main.Config.SetConfigSettings();
                Main.Logic.AllModPlayerControl.Clear();
                killedPlayers.Clear();
                var crewmates = PlayerControl.AllPlayerControls.ToArray().ToList();
                foreach (var plr in crewmates)
                {
                    Main.Logic.AllModPlayerControl.Add(new ModPlayerControl
                    {
                        PlayerControl = plr, Role = "Impostor", UsedAbility = false, LastAbilityTime = null,
                        Immortal      = ShieldState.None
                    });
                }
                crewmates.RemoveAll(x => x.Data.IsImpostor);
                foreach (var plr in crewmates)
                {
                    plr.getModdedControl().Role = "Crewmate";
                }
                break;

            case (byte)CustomRPC.SetMedic:
                setRole("Medic");
                break;

            case (byte)CustomRPC.SetProtected:
                var protectedId = ALMCIJKELCP.ReadByte();
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == protectedId)
                    {
                        player.getModdedControl().Immortal = ShieldState.Intact;
                    }
                }
                break;

            case (byte)CustomRPC.SetOfficer:
                setRole("Officer");
                break;

            case (byte)CustomRPC.OfficerKill:
                var killerId = ALMCIJKELCP.ReadByte();
                var killer   = PlayerTools.getPlayerById(killerId);

                var targetId = ALMCIJKELCP.ReadByte();
                var target   = PlayerTools.getPlayerById(targetId);

                killer.MurderPlayer(target);
                if (target.isPlayerImmortal())
                {
                    BreakShield(false);
                }
                break;

            case (byte)CustomRPC.SetEngineer:
                setRole("Engineer");
                break;

            case (byte)CustomRPC.SetJoker:
                setRole("Joker");
                break;

            case (byte)CustomRPC.JokerWin:
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.isPlayerRole("Joker"))
                    {
                        continue;
                    }

                    player.RemoveInfected();
                    player.Die(DeathReason.Exile);
                    player.Data.IsDead     = true;
                    player.Data.IsImpostor = false;
                }

                var joker = Main.Logic.getRolePlayer("Joker").PlayerControl;
                joker.Revive();
                joker.Data.IsDead     = false;
                joker.Data.IsImpostor = true;
                break;
            }
        }
예제 #3
0
        static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
        {
            byte          packetId = HKHMBLJFLMC;
            MessageReader reader   = ALMCIJKELCP;

            switch (packetId)
            {
            case (byte)CustomRPC.ShieldBreak:
                if (MedicSettings.Protected != null)
                {
                    MedicSettings.Protected.myRend.material.SetColor("_VisorColor", Palette.VisorColor);
                    MedicSettings.Protected.myRend.material.SetFloat("_Outline", 0f);
                }
                MedicSettings.Protected = null;
                break;

            case (byte)CustomRPC.FixLights:
                SwitchSystem switchSystem = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast <SwitchSystem>();
                switchSystem.ActualSwitches = switchSystem.ExpectedSwitches;
                break;

            case (byte)CustomRPC.SetLocalPlayers:
                ConsoleTools.Info("Setting Local Players...");
                localPlayers.Clear();
                localPlayer = PlayerControl.LocalPlayer;
                var localPlayerBytes = ALMCIJKELCP.ReadBytesAndSize();

                foreach (byte id in localPlayerBytes)
                {
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                    {
                        if (player.PlayerId == id)
                        {
                            localPlayers.Add(player);
                        }
                    }
                }
                break;

            case (byte)RPC.SetInfected:
            {
                ConsoleTools.Info("set infected.");
                break;
            }

            case (byte)CustomRPC.ResetVaribles:
            {
                MedicSettings.ClearSettings();
                OfficerSettings.ClearSettings();
                EngineerSettings.ClearSettings();
                JokerSettings.ClearSettings();
                MedicSettings.SetConfigSettings();
                OfficerSettings.SetConfigSettings();
                EngineerSettings.SetConfigSettings();
                JokerSettings.SetConfigSettings();
                killedPlayers.Clear();
                break;
            }

            case (byte)CustomRPC.SetMedic:
            {
                ConsoleTools.Info("Medic Set Through RPC!");
                byte MedicId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == MedicId)
                    {
                        MedicSettings.Medic = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.SetProtected:
            {
                byte ProtectedId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == ProtectedId)
                    {
                        MedicSettings.Protected = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.SetOfficer:
            {
                ConsoleTools.Info("Officer Set Through RPC!");
                byte OfficerId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == OfficerId)
                    {
                        OfficerSettings.Officer = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.OfficerKill:
            {
                var           killerid = ALMCIJKELCP.ReadByte();
                var           targetid = ALMCIJKELCP.ReadByte();
                PlayerControl killer   = PlayerTools.getPlayerById(killerid);
                PlayerControl target   = PlayerTools.getPlayerById(targetid);
                killer.MurderPlayer(target);
                break;
            }

            case (byte)CustomRPC.SetEngineer:
            {
                ConsoleTools.Info("Engineer Set Through RPC!");
                byte EngineerId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == EngineerId)
                    {
                        EngineerSettings.Engineer = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.SetJoker:
            {
                ConsoleTools.Info("Joker Set Through RPC!");
                byte JokerId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == JokerId)
                    {
                        JokerSettings.Joker = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.JokerWin:
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    player.RemoveInfected();
                    player.Die(DeathReason.Exile);
                    player.Data.IsDead     = true;
                    player.Data.IsImpostor = false;
                }
                JokerSettings.Joker.Revive();
                JokerSettings.Joker.Data.IsDead     = false;
                JokerSettings.Joker.Data.IsImpostor = true;
                break;
            }
        }