Esempio n. 1
0
        static void Prefix(UnityEngine.Object obj)
        {
            if (ExileController.Instance == null || obj != ExileController.Instance.gameObject)
            {
                return;
            }
            if (!SpecialRoleIsAssigned <Maniac>(out var maniacKvp))
            {
                return;
            }
            if (ExileController.Instance.exiled?.PlayerId != maniacKvp.Key)
            {
                return;
            }

            WriteImmediately(RPC.ManiacWin);

            Maniac maniac = maniacKvp.Value;

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                if (player == maniac.player)
                {
                    continue;
                }
                player.RemoveInfected();
                player.Die(DeathReason.Exile);
                player.Data.IsDead     = true;
                player.Data.IsImpostor = false;
            }
            maniac.player.Revive();
            maniac.player.Data.IsDead     = false;
            maniac.player.Data.IsImpostor = true;
        }
        public static void Postfix(Il2CppReferenceArray <GameData.PlayerInfo> JPGEIBIBJPJ)
        {
            List <Role> assignedRoles = AssignedSpecialRoles.Values.ToList();

            foreach (Role r in assignedRoles)
            {
                r.ClearSettings();
            }
            ResetValues();

            WriteImmediately(RPC.ResetVariables);

            List <PlayerControl> crewmates = PlayerControl.AllPlayerControls.ToArray().ToList();

            crewmates.RemoveAll(x => x.Data.IsImpostor);

            Doctor.SetRole(crewmates);
            Detective.SetRole(crewmates);
            Engineer.SetRole(crewmates);
            Maniac.SetRole(crewmates);
            Seer.SetRole(crewmates);
            Tracker.SetRole(crewmates);
            Nocturnal.SetRole(crewmates);
            Pathfinder.SetRole(crewmates);

            List <PlayerControl> impostors = PlayerControl.AllPlayerControls.ToArray().ToList();

            impostors.RemoveAll(x => !x.Data.IsImpostor);

            Ninja.SetRole(impostors);

            Crew.Clear();
            localPlayer = PlayerControl.LocalPlayer;

            bool   maniacExists   = SpecialRoleIsAssigned <Maniac>(out var maniacKvp);
            Maniac maniacInstance = maniacKvp.Value;

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                if (player.Data.IsImpostor)
                {
                    continue;
                }
                if (maniacExists && maniacInstance.player.PlayerId == player.PlayerId)
                {
                    continue;
                }

                Crew.Add(player);
            }

            MessageWriter writer = GetWriter(RPC.SetLocalPlayers);

            writer.WriteBytesAndSize(Crew.Select(player => player.PlayerId).ToArray());
            CloseWriter(writer);
        }
Esempio n. 3
0
        static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
        {
            MessageReader reader = ALMCIJKELCP;
            
            switch (HKHMBLJFLMC /*Packet ID*/)
            {
                // ---------------------- Set special roles ----------------------
                case (byte) RPC.SetRole:
                    byte roleId = reader.ReadByte();
                    byte playerId = reader.ReadByte();
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                        if (player.PlayerId == playerId)
                            switch (roleId)
                            {
                                case var value when value == Detective.RoleID:
                                    AddSpecialRole(new Detective(player));
                                    break;
                                
                                case var value when value == Doctor.RoleID:
                                    AddSpecialRole(new Doctor(player));
                                    break;
                                
                                case var value when value == Engineer.RoleID:
                                    AddSpecialRole(new Engineer(player));
                                    break;
                                
                                case var value when value == Maniac.RoleID:
                                    AddSpecialRole(new Maniac(player));
                                    break;
                                
                                case var value when value == Seer.RoleID:
                                    AddSpecialRole(new Seer(player));
                                    break;

                                case var value when value == Tracker.RoleID:
                                    AddSpecialRole(new Tracker(player));
                                    break;
                                
                                case var value when value == Ninja.RoleID:
                                    AddSpecialRole(new Ninja(player));
                                    break;

                                case var value when value == Nocturnal.RoleID:
                                    AddSpecialRole(new Nocturnal(player));
                                    break;

                                case var value when value == Pathfinder.RoleID:
                                    AddSpecialRole(new Pathfinder(player));
                                    break;
                            }
                    break;
                // -------------- Happenings related to special roles --------------
                
                case (byte)RPC.SetProtected:
                    byte protectedId = reader.ReadByte();
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                        if (player.PlayerId == protectedId)
                            GetSpecialRole<Doctor>().protectedPlayer = player;
                    break;
                case (byte)RPC.ShieldBreak:
                    Doctor doctor = GetSpecialRole<Doctor>();
                    PlayerControl protectedPlayer = doctor.protectedPlayer;
                    if (protectedPlayer != null)
                    {
                        protectedPlayer.myRend.material.SetColor("_VisorColor", Palette.VisorColor);
                        protectedPlayer.myRend.material.SetFloat("_Outline", 0f);
                    }    
                    doctor.protectedPlayer = null;
                    break;
                case (byte) RPC.AttemptShield:
                    Doctor doctorShieldAttempt = GetSpecialRole<Doctor>();
                    if (doctorShieldAttempt.player != null)
                    {
                        doctorShieldAttempt.AttemptKillShielded();
                    }
                    break;
                case (byte) RPC.DetectiveKill:
                    var killerid = reader.ReadByte();
                    var targetid = reader.ReadByte();
                    PlayerControl killer = PlayerTools.GetPlayerById(killerid);
                    PlayerControl target = PlayerTools.GetPlayerById(targetid);
                    killer.MurderPlayer(target);
                    break;
                case (byte)RPC.ManiacWin:
                    Maniac maniac = GetSpecialRole<Maniac>();
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                    {
                        if (player == maniac.player) continue;
                        player.RemoveInfected();
                        player.Die(DeathReason.Exile);
                        player.Data.IsDead = true;
                        player.Data.IsImpostor = false;
                    }

                    maniac.player.Revive();
                    maniac.player.Data.IsDead = false;
                    maniac.player.Data.IsImpostor = true;
                    break;
                case (byte) RPC.NinjaDoubleKill:
                    var ninjaId = reader.ReadByte();
                    var doubleKillId = reader.ReadByte();
                    PlayerControl ninjaDoubleKill = PlayerTools.GetPlayerById(ninjaId);
                    PlayerControl targetDoubleKill = PlayerTools.GetPlayerById(doubleKillId);
                    ninjaDoubleKill.MurderPlayer(targetDoubleKill);
                    break;
                case (byte)RPC.SetTrackerMark:
                    Tracker tracker1 = GetSpecialRole<Tracker>();
                    SystemTypes system = (SystemTypes) reader.ReadInt32();
                    tracker1.markedSystem = system;
                    break;
                case (byte)RPC.TrapSuccessful:
                    if (TryGetSpecialRole(PlayerControl.LocalPlayer.PlayerId, out Tracker tracker2))
                    {
                        byte roomId = reader.ReadByte();
                        tracker2.TrapSuccessful((SystemTypes) roomId);
                    }
                    break;

                // --------------------------- Other ---------------------------

                case (byte)RPC.FixLights:
                    SwitchSystem switchSystem = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast<SwitchSystem>();
                    switchSystem.ActualSwitches = switchSystem.ExpectedSwitches;
                    break;
                case (byte)RPC.SetLocalPlayers:
                    Crew.Clear();
                    localPlayer = PlayerControl.LocalPlayer;
                    var localPlayerBytes = reader.ReadBytesAndSize();

                    foreach (byte id in localPlayerBytes)
                        foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                            if (player.PlayerId == id)
                                Crew.Add(player);
                    break;
                case (byte) RPC.SetInfected:
                    break;
                case (byte) RPC.ResetVariables:
                    List<Role> assignedRoles = AssignedSpecialRoles.Values.ToList();
                    foreach (Role r in assignedRoles)
                    {
                        r.ClearSettings();
                    }
                    ResetValues();
                    break;
            }
        }