public static void Postfix([HarmonyArgument(0)] Il2CppReferenceArray <GameData.PlayerInfo> playerInfos)
        {
            MessageWriter writer = GetWriter(RPC.SetLocalPlayers);

            writer.WriteBytesAndSize(AllPlayers.Select(player => player.PlayerId).ToArray());
            CloseWriter(writer);
        }
Esempio n. 2
0
        public static void Postfix(Il2CppReferenceArray <PlayerInfo> BHNEINNHPIJ)
        {
            Metamorphosis.Logger.LogDebug($"RcpSetInfected postfix start");
            InitMetamorphs();

            List <byte>          infectedIds = new List <byte>();
            List <PlayerControl> infected    = GetInfected(BHNEINNHPIJ, ref infectedIds);

            foreach (PlayerControl playerControl in infected)
            {
                Metamorph metamorph = new Metamorph(playerControl);
                Metamorphs.Add(metamorph);
                Metamorphosis.Logger.LogDebug($"RcpSetInfected postfix: {metamorph.PlayerId} added");
                if (playerControl.PlayerId == PlayerControl.LocalPlayer.PlayerId)
                {
                    Metamorphosis.Logger.LogDebug($"RcpSetInfected postfix: Metamorph is a local player {metamorph.PlayerId}");
                    Metamorph.LocalMetamorph = metamorph;
                    if (HudManagerPatch.MorphButton != null)
                    {
                        HudManagerPatch.MorphButton.StartCooldown(CustomGameOptions.MorphCooldown + 9.0f);
                        HudManagerPatch.MorphButton.EffectDuration   = CustomGameOptions.MorphDuration;
                        HudManagerPatch.MorphButton.CooldownDuration = CustomGameOptions.MorphCooldown;
                    }
                }
            }

            MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMetamorphs, Hazel.SendOption.Reliable);

            writer.WriteBytesAndSize(infectedIds.ToArray());

            writer.EndMessage();

            Metamorphosis.Logger.LogDebug("RcpSetInfected postfix");
        }
        public bool GetString(out string text, StringNames stringId, Il2CppReferenceArray <Il2CppSystem.Object> parts)
        {
            string key = Enum.GetName(typeof(StringNames), stringId);

            if (Strings.TryGetValue(key, out text))
            {
                if (parts.Length != 0)
                {
                    List <object> parameters = new List <object>();
                    foreach (Il2CppSystem.Object obj in parts)
                    {
                        Il2CppSystem.Type t = obj.GetIl2CppType();
                        //BetterLanguagesPlugin.log.LogInfo("hey :" + t.ToString());
                        if (Il2CppSystem.Type.IsIntegerType(t))
                        {
                            parameters.Add(obj.Unbox <System.Int32>());
                        }
                        else
                        {
                            parameters.Add(obj.ToString());
                        }
                    }
                    text = string.Format(text, parameters.ToArray());
                }
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public static void Postfix(Il2CppReferenceArray <GameData.Nested_1> FMAOEJEHPAO)
        {
            if (!Jester.jesterEnabled)
            {
                return;
            }

            Jester.introDone = false;

            PlayerController.InitPlayers();

            List <Player> crewmates = getCrewMates(FMAOEJEHPAO);
            var           jesterid  = new System.Random().Next(0, crewmates.Count);

            Player        jester = crewmates[jesterid];
            MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJester, Hazel.SendOption.Reliable);

            writer.Write(jester.playerdata.PlayerId);
            writer.EndMessage();
            jester.components.Add("Jester");

            Jester.localPlayers.Clear();
            Jester.localPlayer = PlayerControl.LocalPlayer;

            foreach (var player in PlayerControl.AllPlayerControls)
            {
                Jester.localPlayers.Add(player);
            }

            writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLocalPlayersJester, Hazel.SendOption.Reliable);
            writer.WriteBytesAndSize(Jester.localPlayers.Select(player => player.PlayerId).ToArray());
            writer.EndMessage();
        }
Esempio n. 5
0
            public static bool Prefix(UnityToSimulation __instance, ref MapModel map)
            {
                map.mapWideBloonSpeed = 5;

                //map.areas[0].polygon.


                for (int p = 0; p < map.paths.Count; p++)
                {
                    Il2CppReferenceArray <PointInfo> arr = new Il2CppReferenceArray <PointInfo>(map.paths[p].points.Count);
                    for (int i = 0; i < map.paths[p].points.Count; i++)
                    {
                        PointInfo pointinfo = map.paths[p].points[i];
                        var       vec       = pointinfo.point;
                        //map.paths[0].points[i]
                        pointinfo.point = new Assets.Scripts.Simulation.SMath.Vector3(vec.x + ((float)r.NextDouble() * 10), vec.y + ((float)r.NextDouble() * 10), vec.z);
                        arr[i]          = pointinfo;
                    }
                    map.paths[p].points = arr;
                }



                return(true);
            }
Esempio n. 6
0
        public static bool Prefix(Il2CppReferenceArray <GameData.PlayerInfo> JPGEIBIBJPJ)
        {
            var debugImpostors = false;

            if (debugImpostors)
            {
                var infected = new byte[] { 0, 0 };

                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.Data.PlayerName == "Impostor")
                    {
                        infected[0] = player.PlayerId;
                    }
                    if (player.Data.PlayerName == "Pretender")
                    {
                        infected[1] = player.PlayerId;
                    }
                }

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)RPC.SetInfected, Hazel.SendOption.None, -1);
                writer.WritePacked((uint)2);
                writer.WriteBytesAndSize(infected);
                AmongUsClient.Instance.FinishRpcImmediately(writer);

                PlayerControl.LocalPlayer.SetInfected(infected);

                return(false);
            }
            return(true);
        }
Esempio n. 7
0
            public static void Postfix()
            {
                GameModel gm = Game.instance.model;

                if (gm == null)
                {
                    return;
                }
                // normal roundsets
                Il2CppReferenceArray <RoundSetModel> roundSets = Game.instance.model.roundSets;
                int i = 0;

                foreach (RoundSetModel roundset in roundSets)
                {
                    //log(roundset);
                    i++;
                }
                // FBGM - freeplay bloon group model
                // freeplay stuffs
                Il2CppReferenceArray <FreeplayBloonGroupModel> e = Game.instance.model.freeplayGroups;
                int    ii   = 0;
                string path = "FBGM/";

                Directory.CreateDirectory(path);

                foreach (FreeplayBloonGroupModel fbgm in e)
                {
                    var g = fbgm.name;
                    FileIOUtil.SaveObject("FBGM2/" + g + ".json", fbgm); // I have no idea why when I remove this line emissions is empty, but when I remove everything else it just doesnt work
                    File.Create(path + g + ".json").Close();
                    File.WriteAllText(path + g + ".json", JsonUtility.ToJsonInternal(fbgm, true));
                    ii++;
                }
            }
            public static void Postfix()
            {
                List <BloonModel> goldenBloons = new List <BloonModel>();

                foreach (var item in Game.instance.model.bloons)
                {
                    if (item.baseId == "Golden")
                    {
                        goldenBloons.Add(item);
                    }
                }
                Random rand = new Random();
                Il2CppReferenceArray <RoundSetModel> roundSets = InGame.instance.bridge.Model.roundSets;

                for (int i = 0; i < roundSets.Length; i++)
                {
                    Il2CppReferenceArray <RoundModel> rounds = roundSets[i].rounds;
                    for (int j = 0; j < rounds.Length; j++)
                    {
                        int randombloon = rand.Next(0, goldenBloons.Count);
                        BloonEmissionModel goldenBloon = new BloonEmissionModel(goldenBloons[randombloon].id, 0, goldenBloons[randombloon].id);
                        Il2CppReferenceArray <BloonEmissionModel> temp = rounds[j].emissions;
                        List <BloonEmissionModel> temp2 = new List <BloonEmissionModel>();
                        foreach (var item in temp)
                        {
                            temp2.Add(item);
                        }
                        temp2.Add(goldenBloon);
                        rounds[j].emissions_ = (Il2CppReferenceArray <BloonEmissionModel>)temp2.ToArray();
                    }
                }
            }
        internal static void Prefix(HeroUpgradeDetails __instance, string heroIdToUse)
        {
            var heroSprites    = __instance.heroSprites;
            var newHeroSprites = new Il2CppReferenceArray <HeroFontMaterial>(heroSprites.Length + 1);

            for (var i = 0; i < heroSprites.Count; i++)
            {
                var heroFontMaterial = heroSprites[i];
                if (heroFontMaterial.name != heroIdToUse)
                {
                    newHeroSprites[i] = heroFontMaterial;
                }
                else
                {
                    return;
                }
            }

            var nameMaterial = newHeroSprites[0].heroNameMaterial;

            if (ModTowerHelper.ModTowerCache.TryGetValue(heroIdToUse, out var tower) && tower is ModHero modHero &&
                heroSprites.FirstOrDefault(material => material.name == modHero.NameStyle) is HeroFontMaterial materal)
            {
                nameMaterial = materal.heroNameMaterial;
            }

            newHeroSprites[heroSprites.Length] = new HeroFontMaterial
            {
                name             = heroIdToUse,
                heroNameMaterial = nameMaterial
            };

            __instance.heroSprites = newHeroSprites;
        }
Esempio n. 10
0
            public static void Postfix(PlayerControl __instance,
                                       [HarmonyArgument(0)] Il2CppReferenceArray <GameData.PlayerInfo> impostors)
            {
                var crewmates = new List <PlayerControl>();

                foreach (var pctrl in PlayerControl.AllPlayerControls)
                {
                    bool wasImpostor = false;
                    foreach (var infected in impostors)
                    {
                        if (pctrl.PlayerId == infected.PlayerId)
                        {
                            wasImpostor = true;
                            break;
                        }
                    }

                    if (!wasImpostor)
                    {
                        crewmates.Add(pctrl);
                    }
                }

                var rand   = new Random();
                var picked = crewmates[rand.Next(0, crewmates.Count)];

                Jester = picked;
                System.Console.WriteLine(
                    $"Rolled player {picked.name} {picked.PlayerId}");
                __instance.Send <SetJesterRpc>(new SetJesterRpc.Data(picked.PlayerId), true);
            }
Esempio n. 11
0
        /// <summary>
        /// Recursively get every WeaponModels this TowerModel has
        /// </summary>
        public static List <WeaponModel> GetWeapons(this TowerModel towerModel)
        {
            List <AttackModel> attackModels = towerModel.GetAttackModels();

            if (attackModels is null)
            {
                return(null);
            }

            if (!attackModels.Any())
            {
                return(new List <WeaponModel>());
            }

            List <WeaponModel> weaponModels = new List <WeaponModel>();

            foreach (AttackModel attackModel in attackModels)
            {
                Il2CppReferenceArray <WeaponModel> weapons = attackModel.weapons;
                if (weapons != null)
                {
                    weaponModels.AddRange(weapons);
                }
            }

            return(weaponModels);
        }
Esempio n. 12
0
        public void RegisterRequiredScanItem(iWardenObjectiveItem item)
        {
            var array = new Il2CppReferenceArray <iWardenObjectiveItem>(1);

            array[0] = item;

            ElevatorShaftLanding.Current.AddRequiredScanItems(array);
        }
Esempio n. 13
0
        public override void VRChat_OnUiManagerInit()
        {
            var calibrateButton = GameObject.Find("UserInterface/QuickMenu/ShortcutMenu/CalibrateButton")
                                  .GetComponent <Button>();
            var oldCalibrate = calibrateButton.onClick;

            calibrateButton.onClick = new Button.ButtonClickedEvent();
            calibrateButton.onClick.AddListener(new Action(() =>
            {
                if (IkTweaksSettings.FullBodyVrIk)
                {
                    if (IkTweaksSettings.CalibrateUseUniversal)
                    {
                        CalibrationManager.Clear();
                    }
                    else
                    {
                        CalibrationManager.Clear(VRCPlayer.field_Internal_Static_VRCPlayer_0.prop_ApiAvatar_0.id);
                    }
                }

                oldCalibrate.Invoke();
            }));

            var steamVrControllerManager = CalibrationManager.GetControllerManager();
            var puckPrefab = steamVrControllerManager.field_Public_ArrayOf_GameObject_0.First(it =>
                                                                                              it != steamVrControllerManager.field_Public_GameObject_1 && it != steamVrControllerManager.field_Public_GameObject_0);
            var newPucks = new Il2CppReferenceArray <GameObject>(5 + 6);
            var newUints = new Il2CppStructArray <uint>(5 + 6);

            for (var i = 0; i < 5; i++)
            {
                newPucks[i] = steamVrControllerManager.field_Public_ArrayOf_GameObject_0[i];
                newUints[i] = steamVrControllerManager.field_Private_ArrayOf_UInt32_0[i];
            }

            ourRandomPuck = puckPrefab;

            var trackersParent = puckPrefab.transform.parent;

            for (var i = 0; i < 6; i++)
            {
                var newPuck = Object.Instantiate(puckPrefab, trackersParent, true);
                newPuck.name = "Puck" + (i + 4);
                newPuck.GetComponent <SteamVR_TrackedObject>().field_Public_EnumNPublicSealedvaNoHmDe18DeDeDeDeDeUnique_0 = SteamVR_TrackedObject.EnumNPublicSealedvaNoHmDe18DeDeDeDeDeUnique.None;
                newPuck.SetActive(false);
                newPucks[i + 5] = newPuck;
                newUints[i + 5] = UInt32.MaxValue;
            }

            steamVrControllerManager.field_Public_ArrayOf_GameObject_0 = newPucks;
            steamVrControllerManager.field_Private_ArrayOf_UInt32_0    = newUints;

            // only one of them is the correct type, so just try all of them
            steamVrControllerManager.field_Private_Action_0.TryCast <SteamVR_Events.Action <VREvent_t> >()?.action?.Invoke(new VREvent_t());
            steamVrControllerManager.field_Private_Action_1.TryCast <SteamVR_Events.Action <VREvent_t> >()?.action?.Invoke(new VREvent_t());
            steamVrControllerManager.field_Private_Action_2.TryCast <SteamVR_Events.Action <VREvent_t> >()?.action?.Invoke(new VREvent_t());
        }
Esempio n. 14
0
        public static void Postfix(Il2CppReferenceArray <GameData.LGBOMGHJELL> BHNEINNHPIJ)
        {
            PlayerController.InitPlayers();

            CustomGameObjectManager.deleteAll();

            EndGameManagerPatch.LoveCoupleWins = false;
            List <Player> crewmates = getCrewMates(BHNEINNHPIJ);
            int           lover1idx = (byte)new System.Random().Next(0, crewmates.Count);



            int lover2idx = (byte)new System.Random().Next(0, crewmates.Count);

            if (lover1idx == lover2idx)
            {
                lover2idx = (lover2idx + 1) % crewmates.Count;
            }



            Player[] impostors = PlayerController.getImpostors();
            byte     r         = (byte)new System.Random().Next(0, 3);

            if (r == 0)
            {
                lover2idx = (byte)new System.Random().Next(0, impostors.Length);
            }

            Player lover1 = crewmates[lover1idx];
            Player lover2 = crewmates[lover2idx];

            if (r == 0)
            {
                lover2 = impostors[lover2idx];
            }



            MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCouple, Hazel.SendOption.Reliable);

            writer.Write(lover1.playerdata.PlayerId);

            writer.Write(lover2.playerdata.PlayerId);
            writer.Write(r);
            writer.EndMessage();
            lover1.components.Add(new Love(lover1, lover2));
            lover2.components.Add(new Love(lover2, lover1));
            HudManagerPatch.LoadSprites();
            var localplayer = PlayerController.getLocalPlayer();

            if (lover1 == localplayer | lover2 == localplayer)
            {
                CustomGameObjectManager.AddObject(new Heart(lover1.playerdata.nameText));
                CustomGameObjectManager.AddObject(new Heart(lover2.playerdata.nameText));
            }
        }
Esempio n. 15
0
 public static bool Prefix(StringNames LENBLADGELB, string NNLLKLDPBAI, Il2CppReferenceArray <Il2CppSystem.Object> DKBJCINDDCD, ref string __result)
 {
     if (LENBLADGELB == (StringNames)3000)
     {
         __result = BonusRolesPlugin.Name.Value;
         return(false);
     }
     return(true);
 }
Esempio n. 16
0
 public static bool Prefix(StringNames BPHOFEKLDLF, string BIHKOFGIABL, Il2CppReferenceArray <Il2CppSystem.Object> FHLKFONKJLH, ref string __result)
 {
     if (BPHOFEKLDLF == (StringNames)CustomStringNames.CustomServerName)
     {
         __result = SheriffMod.Name.Value;
         return(false);
     }
     return(true);
 }
Esempio n. 17
0
            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, ", "));
                // }
            }
 public static bool Prefix(StringNames MBPOLHMKKJC, string FFCEMBMJGIP, Il2CppReferenceArray <Il2CppSystem.Object> BPBFAAEIABN, ref string __result)
 {
     if (MBPOLHMKKJC == (StringNames)CustomStringNames.CustomServerName)
     {
         __result = SheriffMod.Name.Value;
         return(false);
     }
     return(true);
 }
Esempio n. 19
0
            public static bool Prefix(GUIContent content, GUIStyle style, Il2CppReferenceArray <GUILayoutOption> options, ref Rect __result)
            {
                GUIUtility.CheckOnGUI();
                var type = Event.current.type;

                if (type != EventType.Layout)
                {
                    if (type != EventType.Used)
                    {
                        var next = GUILayoutUtility.current.topLevel.GetNext();
                        __result = next.rect;
                    }
                    else
                    {
                        __result = GUILayoutUtility.kDummyRect;
                    }
                }
                else
                {
                    var isHeightDependantOnWidth = style.isHeightDependantOnWidth;
                    if (isHeightDependantOnWidth)
                    {
                        GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                    }
                    else
                    {
                        var constraints = new Vector2(0f, 0f);
                        if (options != null)
                        {
                            foreach (var guilayoutOption in options)
                            {
                                var type2 = guilayoutOption.type;
                                if (type2 != GUILayoutOption.Type.maxWidth)
                                {
                                    if (type2 == GUILayoutOption.Type.maxHeight)
                                    {
                                        constraints.y = guilayoutOption.value.Unbox <float>();
                                    }
                                }
                                else
                                {
                                    constraints.x = guilayoutOption.value.Unbox <float>();
                                }
                            }
                        }

                        var vector = style.CalcSizeWithConstraints(content, constraints);
                        vector.x = Mathf.Ceil(vector.x);
                        vector.y = Mathf.Ceil(vector.y);
                        GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(vector.x, vector.x, vector.y, vector.y, style));
                    }

                    __result = GUILayoutUtility.kDummyRect;
                }

                return(false);
            }
Esempio n. 20
0
 public static bool Prefix(StringNames LENBLADGELB, string NNLLKLDPBAI, Il2CppReferenceArray <Il2CppSystem.Object> DKBJCINDDCD, ref string __result)
 {
     if (LENBLADGELB == (StringNames)CustomStringNames.CustomServerName)
     {
         __result = SheriffMod.Name.Value;
         return(false);
     }
     return(true);
 }
Esempio n. 21
0
        public static bool HasItemsOfType <TSource, TCast>(this Il2CppReferenceArray <TSource> referenceArray)
            where TSource : Il2CppSystem.Object
            where TCast : Il2CppSystem.Object
        {
            try { TSource result = referenceArray.First(item => item.TryCast <TCast>() != null); }
            catch (Exception) { return(false); }

            return(true);
        }
Esempio n. 22
0
 public MapData(string name, string url, MapDifficulty difficulty, PathModel[] paths, PathSpawnerModel spawner, Il2CppReferenceArray <AreaModel> areas)
 {
     this.name       = name;
     this.url        = url;
     this.difficulty = difficulty;
     this.paths      = paths;
     this.spawner    = spawner;
     this.areas      = areas;
 }
Esempio n. 23
0
        public static void SpawnBloons(this InGame inGame, int round)
        {
            GameModel model = inGame.GetGameModel();

            int index = (round < 100) ? round - 1 : round - 100;
            Il2CppReferenceArray <BloonEmissionModel> emissions = (round < 100) ? model.GetRoundSet().rounds[index].emissions : model.freeplayGroups[index].bloonEmissions;

            InGame.instance.SpawnBloons(emissions);
        }
        public static void Postfix([HarmonyArgument(0)] Il2CppReferenceArray <GameData.PlayerInfo> infected)
        {
            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ResetVaribles, Hazel.SendOption.Reliable, -1);

            AmongUsClient.Instance.FinishRpcImmediately(writer);
            RPCProcedure.resetVariables();

            assignRoles();
        }
Esempio n. 25
0
        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);
        }
        public static void Postfix(Il2CppReferenceArray <GameData.PlayerInfo> FMAOEJEHPAO)
        {
            Rpc <ResetVariablesRpc> .Instance.Send(data : true, immediately : true);

            System.Console.WriteLine(HarmonyMain.medicSpawnChance.GetValue());
            System.Console.WriteLine(HarmonyMain.officerSpawnChance.GetValue());
            System.Console.WriteLine(HarmonyMain.engineerSpawnChance.GetValue());
            System.Console.WriteLine(HarmonyMain.jokerSpawnChance.GetValue());

            var roles = new List <(Role roleName, float spawnChance)>()
            {
                (Role.Medic, HarmonyMain.medicSpawnChance.GetValue()),
                (Role.Officer, HarmonyMain.officerSpawnChance.GetValue()),
                (Role.Engineer, HarmonyMain.engineerSpawnChance.GetValue()),
                (Role.Joker, HarmonyMain.jokerSpawnChance.GetValue()),
            };

            var crewmates = PlayerControl.AllPlayerControls
                            .ToArray()
                            .Where(x => !x.Data.IsImpostor)
                            .ToList();

            foreach (var(roleName, spawnChance) in roles)
            {
                var shouldSpawn = crewmates.Count > 0 && rng.Next(0, 100) <= spawnChance;
                if (!shouldSpawn)
                {
                    continue;
                }

                var randomCrewmateIndex = rng.Next(0, crewmates.Count);
                crewmates[randomCrewmateIndex].getModdedControl().Role = roleName;
                var playerIdForRole = crewmates[randomCrewmateIndex].PlayerId;
                crewmates.RemoveAt(randomCrewmateIndex);

                System.Console.WriteLine($"Spawning {roleName} with PlayerID = {playerIdForRole}");

                Rpc <SetRoleRpc> .Instance.Send(data : (PlayerId : playerIdForRole, Role : roleName), immediately : true);
            }

            localPlayers.Clear();
            localPlayer = PlayerControl.LocalPlayer;
            foreach (var player in PlayerControl.AllPlayerControls)
            {
                var shouldAddPlayer = !player.Data.IsImpostor && !player.isPlayerRole(Role.Joker);
                if (shouldAddPlayer)
                {
                    localPlayers.Add(player);
                }
            }
            var players = localPlayers
                          .Select(player => player.PlayerId)
                          .ToArray();

            Rpc <SetLocalPlayersRpc> .Instance.Send(data : players, immediately : true);
        }
Esempio n. 27
0
            public static void Prefix(ref Il2CppReferenceArray <GameData_PlayerInfo> JPGEIBIBJPJ)
            {
                if (!BattleRoyale.GameMode.IsSelected)
                {
                    return;
                }

                JPGEIBIBJPJ = new Il2CppReferenceArray <GameData_PlayerInfo>(
                    new GameData_PlayerInfo[] { }); // Override impostors
            }
Esempio n. 28
0
        public static void Prefix(ref Il2CppReferenceArray <GameData.PlayerInfo> JPGEIBIBJPJ)
        {
            JPGEIBIBJPJ = new Il2CppReferenceArray <GameData.PlayerInfo>(0);

            if (!Game.IsHost())
            {
                return;
            }
            TeamsController.AssignTeamsServer();
        }
Esempio n. 29
0
        public static GameObject GetInGameUI(this InGame inGame)
        {
            Scene scene = SceneManager.GetSceneByName("InGameUi");
            Il2CppReferenceArray <GameObject> rootGameObjects = scene.GetRootGameObjects();

            const int  uiIndex = 1;
            GameObject ui      = rootGameObjects[uiIndex];

            return(ui);
        }
Esempio n. 30
0
        public static void Postfix(Il2CppReferenceArray <GameData.PlayerInfo> JPGEIBIBJPJ)
        {
            AssignRoles(true);
            AssignRoles(false);

            {
                ExtraNetwork.Send(CustomRPC.ResetStartingRoles);
                EndGameCentral.ResetStartingRoles();
            }
        }