コード例 #1
0
ファイル: Region.cs プロジェクト: zlubars/CheepsAmongUsMods
        /// <summary>
        /// Updates the Among Us Region Object
        /// </summary>
        public void UpdateAuRegionObject()
        {
            var region = new List <ServerObject>();

            foreach (var server in ServerList)
            {
                region.Add(server.AmongUsServerObject);
            }

            AmongUsRegionObject = new RegionObject(RegionName, RegionPingIP, region.ToArray());
        }
コード例 #2
0
            public static bool Prefix(ref RegionMenu __instance)
            {
                ClearOnClickAction(__instance.ButtonPool);

                if (_firstRun)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        _defaultRegions[i] = ServerManager.DefaultRegions[i];
                    }

                    _firstRun = false;
                }

                Directory.CreateDirectory(CustomServersPlugin.userDataPath);

                if (File.Exists(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath)))
                {
                    customServers = JsonConvert.DeserializeObject <List <CustomServerInfo> >(File.ReadAllText(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath)));
                    CustomServersPlugin.Logger.LogDebug("Loaded custom servers list from file!");
                }
                else
                {
                    CustomServersPlugin.Logger.LogWarning("Custom servers list file not found!");
                }

                if (ServerManager.DefaultRegions.Count != 4 + customServers.Count || forceReloadServers)
                {
                    var regions = new RegionInfo[4 + customServers.Count];

                    regions[0] = new RegionInfo("Manage servers...", "MANAGE_SERVERS", null);

                    for (int i = 0; i < 3; i++)
                    {
                        regions[i + 1] = _defaultRegions[i];
                    }

                    for (int i = 0; i < customServers.Count; i++)
                    {
                        Il2CppReferenceArray <ServerInfo> servers = new ServerInfo[1] {
                            new ServerInfo(customServers[i].name, customServers[i].ip, (ushort)customServers[i].port)
                        };

                        regions[i + 4] = new RegionInfo(customServers[i].name, "0", servers);
                    }

                    ServerManager.DefaultRegions = regions;
                }

                return(true);
            }
コード例 #3
0
ファイル: GenericPatches.cs プロジェクト: Herysia/CrowdedMod
            public static bool Prefix(ref RegionMenu __instance)
            {
                ClearOnClickAction(__instance.ButtonPool);

                if (_firstRun)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        _defaultRegions[i] = ServerManager.DefaultRegions[i];
                    }

                    _firstRun = false;
                }

                if (ServerManager.DefaultRegions.Count != 3 + ServersParser.servers.Count)
                {
                    var regions = new RegionInfo[3 + ServersParser.servers.Count];

                    for (int i = 0; i < 3; i++)
                    {
                        regions[i] = _defaultRegions[i];
                    }
                    for (int i = 0; i < ServersParser.servers.Count; i++)
                    {
                        Il2CppReferenceArray <ServerInfo> servers = new ServerInfo[1] {
                            new ServerInfo(ServersParser.servers[i].name, ServersParser.servers[i].ip, (ushort)ServersParser.servers[i].port)
                        };

                        regions[i + 3] = new RegionInfo(ServersParser.servers[i].name, "0", servers);
                    }

                    ServerManager.DefaultRegions = regions;
                }

                return(true);
            }