コード例 #1
0
    public static void IsWorkSpotClear(string type, Vector3 pos)
    {
        World world;
        Tile  t;

        if (ModUtils.GetCurrentWorld(out world) && ModUtils.GetTileAt(pos, out t))
        {
            if (world.FurnitureManager.IsWorkSpotClear(type, t))
            {
                DevConsole.Log("Work spot is clear!", "green");
            }
            else
            {
                DevConsole.LogWarning("Work spot isn't clear!");
            }
        }
    }
コード例 #2
0
        private static void ProcessLevel(string path, LevelLocation location)
        {
            Main.SpecialCode = "Loading Level " + path != null ? path : "null";
            if (!path.EndsWith(".lev"))
            {
                return;
            }
            path = path.Replace('\\', '/');
            LevelData levelData = DuckFile.LoadLevel(path);

            levelData.SetPath(path);
            path = path.Substring(0, path.Length - 4);
            path.Substring(path.IndexOf("/levels/") + 8);
            bool flag1 = true;

            if (levelData.modData.workshopIDs.Count != 0)
            {
                foreach (ulong workshopId in levelData.modData.workshopIDs)
                {
                    bool flag2 = false;
                    foreach (Mod accessibleMod in (IEnumerable <Mod>)ModLoader.accessibleMods)
                    {
                        if (accessibleMod.configuration != null && (long)accessibleMod.configuration.workshopID == (long)workshopId)
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        flag1 = false;
                        break;
                    }
                }
            }
            if (flag1 && !levelData.modData.hasLocalMods)
            {
                RandomLevelDownloader._readyLevels.Add(levelData);
                DevConsole.Log(DCSection.Steam, "Downloaded random level " + RandomLevelDownloader._readyLevels.Count.ToString() + "/" + RandomLevelDownloader.numToHaveReady.ToString());
            }
            else
            {
                DevConsole.Log(DCSection.Steam, "Downloaded level had mods, and was ignored!");
            }
        }
コード例 #3
0
        public static void CreateProject(string projectPath, string name)
        {
            if (!Directory.Exists(projectPath))
            {
                DevConsole.Log(LogType.Error, $"Path for project not found. {projectPath}");
                return;
            }

            projectPath = projectPath + "/" + name;
            Directory.CreateDirectory(projectPath);

            ProjectData newProject = new ProjectData(name, "0.0.1");
            string      json       = JsonSerializer.Serialize(newProject);

            File.WriteAllText(projectPath + "/" + projectFileName, json);

            ValidateProjectFolders(projectPath);
        }
コード例 #4
0
 public void ChangeState(MatchmakingState s, float wait = 0.0f)
 {
     if (s == MatchmakingState.Waiting)
     {
         return;
     }
     DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|CHANGE STATE " + s.ToString(), Color.White);
     if ((double)wait == 0.0)
     {
         this.OnStateChange(s);
     }
     else
     {
         UIMatchmakingBox._state = MatchmakingState.Waiting;
         this._pendingState      = s;
         this._stateWait         = wait;
     }
 }
コード例 #5
0
        void resetReskin(Profile pro)
        {
            Reskin skin;

            if (!ActiveReskins.TryGetValue(pro, out skin))
            {
                return;
            }
            ActiveReskins.Remove(pro);

            pro.persona.sprite.texture.Dispose();
            pro.persona.armSprite.texture.Dispose();
            pro.persona.arrowSprite.texture.Dispose();
            pro.persona.featherSprite.texture.Dispose();
            pro.persona.quackSprite.texture.Dispose();
            pro.persona.skipSprite.texture.Dispose();
            pro.persona.controlledSprite.texture.Dispose();
            pro.persona.fingerPositionSprite.texture.Dispose();

            var personas = (Persona.all as List <DuckPersona>);
            int index    = personas.FindIndex(persona => persona == pro.persona || persona.color == pro.persona.color);

            DevConsole.Log("reset skin: " + pro.name + ", with persona index: " + index, Color.Green);

            try
            {
                personas[index] = pro.persona = new DuckPersona(pro.persona.color);
            }
            catch
            {
                DevConsole.Log("invalid index! Could not correct persona because duckgame messed up persona indexes earlier.", Color.Red);
            }

            if (pro.duck == null)
            {
                return;
            }
            pro.duck.InitProfile();
            foreach (var component in skin.Components)
            {
                component.OnSkinReset(pro.duck);
            }
        }
コード例 #6
0
ファイル: EntygineEditorApp.cs プロジェクト: luxgile/Entygine
        private static void LoadEditor()
        {
            imgui = new EntyImGui(mainWindow.Size.X, mainWindow.Size.Y);
            var style = ImGui.GetStyle();

            style.WindowRounding   = 0;
            style.AntiAliasedLines = true;

            mainEditorDrawer.AttachDrawer(new MainMenuBarDrawer());
            mainEditorDrawer.AttachDrawer(new AssetsWindow());
            mainEditorDrawer.AttachDrawer(new ClientWindow());
            mainEditorDrawer.AttachDrawer(new ConsoleWindow());
            mainEditorDrawer.AttachDrawer(new WorldWindow());
            mainEditorDrawer.AttachDrawer(new DetailsWindow());

            EntygineApp.LoadEngine();

            DevConsole.Log(LogType.Info, "Editor started succesfully.");
        }
コード例 #7
0
        public static void ValidateProjectFolders(string projectPath)
        {
            if (!Directory.Exists(projectPath))
            {
                DevConsole.Log(LogType.Error, "Project path doesn't exists");
                return;
            }

            if (!File.Exists(projectPath + "/" + projectFileName))
            {
                DevConsole.Log(LogType.Error, "No project was found on path");
                return;
            }

            if (!Directory.Exists(projectPath + "/" + assetFolder))
            {
                Directory.CreateDirectory(projectPath + "/" + assetFolder);
            }
        }
コード例 #8
0
ファイル: Mod.cs プロジェクト: jogood/Kill-counter-mod
        // This function is run after all mods are loaded.
        protected override void OnPostInitialize()
        {
            base.OnPostInitialize();
            Network.Initialize();

            void thread()
            {
                while (!(Level.current is TeamSelect2)) // This prevent crash
                {
                    Thread.Sleep(1000);
                }
                DevConsole.Log(DCSection.Mod, "--KillCounter 2.2.1.1--", -1);
                File.WriteAllText("stateLog.txt", "\n");
                stateMachine = new StateMachine();
                killCounter  = new KillCounter(stateMachine);
            }

            new Thread(thread).Start();
        }
コード例 #9
0
ファイル: Framebuffer.cs プロジェクト: luxgile/Entygine
        public void AddDepthBuffer(bool multisampling)
        {
            if (depthBuffer != -1)
            {
                DevConsole.Log(LogType.Error, "Framebuffer already has depth buffer");
                return;
            }

            multisampledDepth = multisampling;
            TextureTarget textureTarget = multisampling ? TextureTarget.Texture2DMultisample : TextureTarget.Texture2D;

            depthBuffer = Ogl.GenTexture($"{name} - Depth");

            Ogl.BindTexture(textureTarget, depthBuffer);

            if (multisampling)
            {
                Ogl.TexImage2DMultisample(TextureTargetMultisample.Texture2DMultisample, 4, PixelInternalFormat.DepthComponent, Size.x, Size.y, true);
            }
            else
            {
                Ogl.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent, Size.x, Size.y, 0, PixelFormat.DepthComponent, PixelType.Float, null);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureMinFilter, TextureMinFilter.Nearest);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureMagFilter, TextureMagFilter.Nearest);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureWrapS, TextureWrapMode.ClampToBorder);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureWrapT, TextureWrapMode.ClampToBorder);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureBorderColor, new float[] { 1, 1, 1, 1 });
            }


            Ogl.BindFramebuffer(FramebufferTarget.Framebuffer, handle);
            Ogl.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, textureTarget, depthBuffer, 0);

            var error = Ogl.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

            if (error != FramebufferErrorCode.FramebufferComplete)
            {
                DevConsole.Log(LogType.Warning, error);
            }

            Ogl.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
コード例 #10
0
    public static void NewCharacter(Vector3 pos, string name = "")
    {
        World world;
        Tile  t;

        if (ModUtils.GetCurrentWorld(out world) && ModUtils.GetTileAt(pos, out t))
        {
            Character character = world.CharacterManager.Create(t);

            if (character != null)
            {
                if (name != string.Empty)
                {
                    character.name = name;
                }

                DevConsole.Log("Say hello to: " + character.GetName());
            }
        }
    }
コード例 #11
0
ファイル: statsMod.cs プロジェクト: 3yggy/DuckStats-client
        protected override void OnPreInitialize()
        {
            base.OnPreInitialize();

            AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args)
            {
                if (args.Name.Contains("0Harmony, Version="))
                {
                    Assembly A = null;
                    foreach (Assembly a in (typeof(ModLoader).GetField("_modAssemblies", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as Dictionary <Assembly, Mod>).Keys)
                    {
                        if (a.GetName().Name == @"0Harmony")
                        {
                            A = a;
                            break;
                        }
                    }
                    if (A == null)
                    {
                        A = Assembly.LoadFrom(this.configuration.directory + @"\0Harmony.dll");
                        (typeof(ModLoader).GetField("_modAssemblies", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as Dictionary <Assembly, Mod>).Add(A, new DisabledMod());
                        DevConsole.Log("ziggy puedes provido el harmony lib!", Color.Green);
                    }
                    if (A != null)
                    {
                        return(A);
                    }
                }
                else if (args.Name.Contains("Newtonsoft.Json, Version="))
                {
                    Assembly A = Assembly.LoadFrom(this.configuration.directory + @"\Newtonsoft.Json.dll");
                    if (A != null)
                    {
                        DevConsole.Log("yo resolvo un newtonsoft", Color.Green);
                        return(A);
                    }
                }
                DevConsole.Log(args.Name, Color.Brown);
                return(null);
            };
        }
コード例 #12
0
ファイル: Framebuffer.cs プロジェクト: luxgile/Entygine
        public void AddColorBuffer(bool multisampling)
        {
            if (colorBuffer != -1)
            {
                DevConsole.Log(LogType.Error, "Framebuffer already has color buffer");
                return;
            }

            multisampledColor = multisampling;
            TextureTarget textureTarget = multisampling ? TextureTarget.Texture2DMultisample : TextureTarget.Texture2D;

            colorBuffer = Ogl.GenTexture($"{name} - Color");

            Ogl.BindTexture(textureTarget, colorBuffer);
            if (multisampling)
            {
                Ogl.TexImage2DMultisample(TextureTargetMultisample.Texture2DMultisample, 4, PixelInternalFormat.Rgb, Size.x, Size.y, true);
            }
            else
            {
                Ogl.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, Size.x, Size.y, 0, PixelFormat.Rgb, PixelType.UnsignedByte, null);

                Ogl.TexParameter(textureTarget, TextureParameterName.TextureMinFilter, TextureMinFilter.Linear);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureMagFilter, TextureMagFilter.Linear);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureWrapS, TextureWrapMode.Repeat);
                Ogl.TexParameter(textureTarget, TextureParameterName.TextureWrapT, TextureWrapMode.Repeat);
            }


            Ogl.BindFramebuffer(FramebufferTarget.Framebuffer, handle);
            Ogl.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, textureTarget, colorBuffer, 0);

            var error = Ogl.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

            if (error != FramebufferErrorCode.FramebufferComplete)
            {
                DevConsole.Log(LogType.Warning, error);
            }

            Ogl.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
コード例 #13
0
        public static void SetFontSize(int size = 14)
        {
            if (size < 10)
            {
                DevConsole.LogError("Font size would be too small");
            }
            else if (size > 20)
            {
                DevConsole.LogError("Font size would be too big");
            }
            else
            {
                Text textObj = DevConsole.TextObject();
                if (textObj != null)
                {
                    textObj.fontSize = size;
                }

                DevConsole.Log("Change successful :D", "green");
            }
        }
コード例 #14
0
        private void OnStateChange(MatchmakingState s)
        {
            UIMatchmakingBox._state = s;
            this._stateWait         = 0.0f;
            switch (UIMatchmakingBox._state)
            {
            case MatchmakingState.Searching:
                Steam.SearchForLobby((User)null);
                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Searching for lobbies.", Color.White);
                break;

            case MatchmakingState.Disconnect:
                Network.Disconnect();
                break;

            case MatchmakingState.Connecting:
                this._tryConnectTimeout = 9f + Rando.Float(2f);
                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Attempting connection to server.", Color.White);
                break;
            }
        }
コード例 #15
0
        public static void OnDataRecieved(NetworkConnection connection, byte index, BitBuffer data, short session, bool last)
        {
            if (!ActiveSessions.ContainsKey(connection))
            {
                ActiveSessions.Add(connection, new DataTransferSession(session, index, data, last));

                DevConsole.Log("Starting new TransferSession" + session, Color.Green);

                return;
            }

            var TransferSession = ActiveSessions[connection];

            if (TransferSession.id != session)
            {
                TransferSession.Reset(session);
            }

            TransferSession.RecieveData(index, data, last);

            if (!TransferSession.finished)
            {
                return;
            }


            DevConsole.Log("recieved last dataslice", Color.Green);

            ActiveSessions.Remove(connection);

            byte[] bytes = decompress(TransferSession.GetData());
            onMessageCompleted(connection, new DataTransferArgs()
            {
                data = bytes.Skip(1).ToArray(), dataType = dataTypes[bytes[0]], profile = connection.profile
            });
        }
コード例 #16
0
 public void OnUserStatusChange(User who, SteamLobbyUserStatusFlags flags, User responsible)
 {
     if ((flags & SteamLobbyUserStatusFlags.Entered) != (SteamLobbyUserStatusFlags)0)
     {
         DevConsole.Log(DCSection.Steam, "|DGGREEN|" + who.name + " has joined the Steam lobby.");
         if (Network.isServer && DuckNetwork.localConnection.status == ConnectionStatus.Connected)
         {
             this.AttemptConnection((object)who);
         }
     }
     else if ((flags & SteamLobbyUserStatusFlags.Left) != (SteamLobbyUserStatusFlags)0)
     {
         DevConsole.Log(DCSection.Steam, "|DGRED|" + who.name + " has left the Steam lobby.");
     }
     else if ((flags & SteamLobbyUserStatusFlags.Disconnected) != (SteamLobbyUserStatusFlags)0)
     {
         DevConsole.Log(DCSection.Steam, "|DGRED|" + who.name + " has disconnected from the Steam lobby.");
     }
     if ((flags & SteamLobbyUserStatusFlags.Kicked) == (SteamLobbyUserStatusFlags)0)
     {
         return;
     }
     DevConsole.Log(DCSection.Steam, "|DGYELLOW|" + responsible.name + " kicked " + who.name + ".");
 }
コード例 #17
0
        public static void Help(string tag = "")
        {
            DevConsole.Log("-- Help --", "green");

            string text = string.Empty;

            CommandBase[] consoleCommands = DevConsole.CommandArray(tag);

            for (int i = 0; i < consoleCommands.Length; i++)
            {
                text += "\n<color=orange>" + consoleCommands[i].Title + "</color>" + DevConsole.GetParameters(consoleCommands[i]) + (consoleCommands[i].Description == null ? string.Empty : " <color=green>// " + consoleCommands[i].Description + "</color>");
            }

            DevConsole.Log(text);

            DevConsole.Log("\n<color=orange>Note:</color> If the function has no parameters you <color=red> don't</color> need to use the parameter modifier.");
            DevConsole.Log("<color=orange>Note:</color> You <color=red>don't</color> need to use the trailing parameter modifier either");
            DevConsole.Log("You can use constants to replace common parameters (they are case insensitive but require ' ' around them):");
            DevConsole.Log("- 'Center' (or 'Centre') is the position of the center/centre of the map.");
            DevConsole.Log("- 'MousePos' is the position of the mouse");
            DevConsole.Log("- 'TimeScale' is the current time scale");
            DevConsole.Log("- 'Pi' is 3.141...");
            DevConsole.Log("- 'E' is 2.718...");
        }
コード例 #18
0
ファイル: DuckEvents.cs プロジェクト: eim64/DuckGameReskins
        public static void Update()
        {
            foreach (var profile in reskinMod.ActiveReskins.Keys)
            {
                if (!Infos.ContainsKey(profile))
                {
                    Infos.Add(profile, new DuckInfo(profile.duck));
                    DevConsole.Log("added profile!", Color.Green);
                    return;
                }

                var info = Infos[profile];
                info.UpdateInfo(profile.duck);

                if (info.exists && !info.pexists)
                {
                    OnDuckSpawn(profile, new EventArgs());
                }
                if (info.quack && !info.pquack)
                {
                    OnDuckQuack(profile, new EventArgs());
                }
            }
        }
コード例 #19
0
 /// <summary>
 /// To prevent C# Modding side of commands from getting lost
 /// </summary>
 public static void SetTimeStamp(bool on)
 {
     CommandSettings.ShowTimeStamp = on;
     DevConsole.Log("Change successful :D", "green");
 }
コード例 #20
0
 public static void DoBuildHelp()
 {
     DevConsole.Log("Does build mode using the furniture/floor/whatever type provided at position pos");
     DevConsole.Log("The options for build mode are: FLOOR = 0, ROOMBEHAVIOUR= 1, FURNITURE= 2, UTILITY = 3, and DECONSTRUCT= 4");
 }
コード例 #21
0
 public void OnConnectionFailed(User who) => DevConsole.Log(DCSection.Steam, "|DGRED|Connection with " + who.name + " has failed!");
コード例 #22
0
        public override void Update()
        {
            this._scroll += 0.1f;
            if ((double)this._scroll > 9.0)
            {
                this._scroll = 0.0f;
            }
            this._dots += 0.01f;
            if ((double)this._dots > 1.0)
            {
                this._dots = 0.0f;
            }
            if (this.open)
            {
                foreach (BlacklistServer failedAttempt in this._failedAttempts)
                {
                    failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer());
                }
                if (this._signalCrossLocal.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseLocal)
                    {
                        this._signalCrossLocal.SetAnimation("flicker");
                        UIMatchmakingBox.pulseLocal = false;
                    }
                }
                else if (this._signalCrossLocal.finished)
                {
                    this._signalCrossLocal.SetAnimation("idle");
                }
                if (this._signalCrossNetwork.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseNetwork)
                    {
                        this._signalCrossNetwork.SetAnimation("flicker");
                        UIMatchmakingBox.pulseNetwork = false;
                    }
                }
                else if (this._signalCrossNetwork.finished)
                {
                    this._signalCrossNetwork.SetAnimation("idle");
                }
                if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting)
                {
                    this.ChangeState(MatchmakingState.Connecting);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White);
                }
                if (DuckNetwork.status == DuckNetStatus.Connected)
                {
                    if (this._tryHostingLobby != null)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new TeamSelect2();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White);
                        return;
                    }
                    if (Level.current is TeamSelect2)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new ConnectingScreen();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White);
                        return;
                    }
                    Network.Disconnect();
                    this.ChangeState(MatchmakingState.SearchForLobbies);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White);
                    return;
                }
                switch (UIMatchmakingBox._state)
                {
                case MatchmakingState.ConnectToMoon:
                    Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                    Steam.SearchForLobby((User)null);
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.ConnectingToMoon);
                    break;

                case MatchmakingState.ConnectingToMoon:
                    if (Steam.lobbySearchComplete)
                    {
                        if (this.searchTryIndex == 0)
                        {
                            this._totalInGameLobbies = Steam.lobbiesFound;
                            if (this._totalInGameLobbies < 0)
                            {
                                this._totalInGameLobbies = 0;
                            }
                            ++this.searchTryIndex;
                            Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                            Steam.SearchForLobby((User)null);
                            break;
                        }
                        UIMatchmakingBox.pulseNetwork = true;
                        this._totalLobbiesFound       = Steam.lobbiesFound;
                        List <User> users = Steam.GetSearchLobbyAtIndex(0).users;
                        this._newStatusList.Add("|DGGREEN|Connected to Moon!");
                        this._newStatusList.Add("");
                        this._newStatusList.Add("|DGYELLOW|Searching for companions.");
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        break;
                    }
                    break;

                case MatchmakingState.SearchForLobbies:
                    if (this._triesSinceSearch == 3)
                    {
                        Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                        Steam.SearchForLobby((User)null);
                        this.ChangeState(MatchmakingState.CheckingTotalGames);
                        return;
                    }
                    if (this._tries > 0 && this._tryHostingLobby == null)
                    {
                        DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public);
                        this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby;
                        if (!this.triedHostingAlready)
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching even harder.");
                        }
                        else
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching.");
                        }
                        this.triedHostingAlready = true;
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White);
                        this._tryHostingWait = 5f + Rando.Float(2f);
                    }
                    foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                    {
                        if (matchSetting.value is int)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue);
                            }
                        }
                        if (matchSetting.value is bool)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
                    {
                        if (onlineSetting.value is int)
                        {
                            if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue);
                            }
                        }
                        if (onlineSetting.value is bool)
                        {
                            if (onlineSetting.id == "modifiers")
                            {
                                if (onlineSetting.filtered)
                                {
                                    Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal);
                                }
                            }
                            else if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal);
                    if (!Steam.waitingForGlobalStats)
                    {
                        this._globalKills = (long)Steam.GetDailyGlobalStat("kills");
                    }
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.Searching);
                    ++this._triesSinceSearch;
                    ++this._tries;
                    break;

                case MatchmakingState.CheckingTotalGames:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalInGameLobbies = Steam.lobbiesFound;
                        if (this._totalInGameLobbies < 0)
                        {
                            this._totalInGameLobbies = 0;
                        }
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        this._triesSinceSearch = 0;
                        break;
                    }
                    break;

                case MatchmakingState.Searching:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalLobbiesFound = Steam.lobbiesFound;
                        if (this._tryHostingLobby != null)
                        {
                            --this._totalLobbiesFound;
                        }
                        List <Lobby> lobbyList = new List <Lobby>();
                        DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White);
                        for (int index1 = 0; index1 < 2; ++index1)
                        {
                            int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound;
                            for (int index2 = 0; index2 < num1; ++index2)
                            {
                                Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2);
                                if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id)
                                {
                                    if (index2 == Steam.lobbiesFound - 1)
                                    {
                                        this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0));
                                    }
                                    if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0)
                                    {
                                        lobbyList.Add(lobby);
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White);
                                    }
                                    else if (this.IsBlacklisted(lobby.id))
                                    {
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White);
                                    }
                                    else
                                    {
                                        if (this._tryHostingLobby != null)
                                        {
                                            int num2 = -1;
                                            try
                                            {
                                                string lobbyData = lobby.GetLobbyData("randomID");
                                                if (lobbyData != "")
                                                {
                                                    num2 = Convert.ToInt32(lobbyData);
                                                }
                                            }
                                            catch
                                            {
                                            }
                                            if (num2 == -1)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White);
                                                num2 = Rando.Int(2147483646);
                                            }
                                            if (num2 >= this._tryHostingLobby.randomID)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White);
                                            }
                                            else
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White);
                                                NCSteam.UpdateRandomID(this._tryHostingLobby);
                                                continue;
                                            }
                                        }
                                        this._tryConnectLobby = lobby;
                                        if (lobby.owner != null)
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + ".");
                                        }
                                        else
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join server.");
                                        }
                                        this.ChangeState(MatchmakingState.Disconnect);
                                        break;
                                    }
                                }
                            }
                        }
                        if (this._tryConnectLobby == null)
                        {
                            DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White);
                            this.ChangeState(MatchmakingState.SearchForLobbies, 3f);
                            break;
                        }
                        break;
                    }
                    break;

                case MatchmakingState.Waiting:
                    this._stateWait -= Maths.IncFrameTimer();
                    if ((double)this._stateWait <= 0.0)
                    {
                        this._stateWait = 0.0f;
                        this.OnStateChange(this._pendingState);
                        break;
                    }
                    break;

                default:
                    int state = (int)UIMatchmakingBox._state;
                    break;
                }
                if (Input.Pressed("QUACK"))
                {
                    this._quit = true;
                    this.ChangeState(MatchmakingState.Disconnect);
                }
            }
            if (this._newStatusList.Count > 0)
            {
                this._newStatusWait -= 0.1f;
                if ((double)this._newStatusWait <= 0.0)
                {
                    this._newStatusWait = 1f;
                    while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0)
                    {
                        this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1);
                    }
                    this._statusList.Add(this._newStatusList[0]);
                    if (this._statusList.Count > 7)
                    {
                        this._statusList.RemoveAt(0);
                    }
                    this._newStatusList.RemoveAt(0);
                }
            }
            base.Update();
        }
コード例 #23
0
 public static void Status()
 {
     DevConsole.Log("Developer Mode is " + (CommandSettings.DeveloperModeToggle ? "on" : "off"), "yellow");
     DevConsole.Log("Time is " + (TimeManager.Instance.IsPaused ? "paused" : TimeManager.Instance.TimeScale + "x"), "yellow");
 }
コード例 #24
0
 public static void FinishMacro(string file)
 {
     file = ModUtils.HandlePath(file);
     DevConsole.FinishMacro(file);
     DevConsole.Log("Finished Macro saved at: " + file);
 }
コード例 #25
0
 public static void Status()
 {
     // Purely a placeholder, add more content as required.
     DevConsole.Log("Developer Mode is " + (SettingsKeyHolder.DeveloperMode ? "on" : "off"), "yellow");
     DevConsole.Log("Time is " + (TimeManager.Instance.IsPaused ? "paused" : TimeManager.Instance.TimeScale + "x"), "yellow");
 }
コード例 #26
0
 /// <summary>
 /// To prevent C# Modding side of commands from getting lost
 /// </summary>
 public static void SetTimeStamp(bool on)
 {
     SettingsKeyHolder.TimeStamps = on;
     DevConsole.Log("Change successful :D", "green");
 }
コード例 #27
0
 public void OnSessionEnded(DuckNetErrorInfo error)
 {
     if (!this.open)
     {
         return;
     }
     if (UIMatchmakingBox._state == MatchmakingState.Disconnect)
     {
         if (this._tryHostingLobby != null)
         {
             this._tries = 0;
         }
         this._tryHostingLobby = (Lobby)null;
         if (this._quit)
         {
             HUD.CloseAllCorners();
             this.Close();
             this._openOnClose.Open();
         }
         else if (this._tryConnectLobby != null)
         {
             DuckNetwork.Join(this._tryConnectLobby.id.ToString());
             this.ChangeState(MatchmakingState.Connecting);
         }
         else
         {
             this.ChangeState(MatchmakingState.SearchForLobbies);
         }
     }
     else
     {
         if (error != null)
         {
             if (error.error == DuckNetError.VersionMismatch)
             {
                 if (error.tooNew)
                 {
                     this._newStatusList.Add("|DGRED|Their version was older.");
                 }
                 else
                 {
                     this._newStatusList.Add("|DGRED|Their version was newer.");
                 }
                 if (this._tryConnectLobby != null)
                 {
                     this._permenantBlacklist.Add(new BlacklistServer()
                     {
                         lobby    = this._tryConnectLobby.id,
                         cooldown = 15f
                     });
                 }
             }
             else if (error.error == DuckNetError.FullServer)
             {
                 this._newStatusList.Add("|DGRED|Failed (FULL SERVER)");
             }
             else if (error.error == DuckNetError.ConnectionTimeout)
             {
                 this._newStatusList.Add("|DGRED|Failed (TIMEOUT)");
             }
             else if (error.error == DuckNetError.GameInProgress)
             {
                 this._newStatusList.Add("|DGRED|Failed (IN PROGRESS)");
             }
             else
             {
                 this._newStatusList.Add("|DGRED|Unknown connection error.");
                 if (this._tryConnectLobby != null)
                 {
                     this._permenantBlacklist.Add(new BlacklistServer()
                     {
                         lobby    = this._tryConnectLobby.id,
                         cooldown = 15f
                     });
                 }
             }
         }
         else
         {
             this._newStatusList.Add("|DGRED|Connection timeout.");
             if (this._tryConnectLobby != null)
             {
                 this._permenantBlacklist.Add(new BlacklistServer()
                 {
                     lobby    = this._tryConnectLobby.id,
                     cooldown = 15f
                 });
             }
         }
         if (this._tryConnectLobby != null)
         {
             this._failedAttempts.Add(new BlacklistServer()
             {
                 lobby    = this._tryConnectLobby.id,
                 cooldown = 15f
             });
         }
         DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Connection failure, continuing search.", Color.White);
         this._tryConnectLobby = (Lobby)null;
         this.ChangeState(MatchmakingState.SearchForLobbies);
     }
 }
コード例 #28
0
 public static void ChangeCameraPosition(Vector3 newPos, string logThis)
 {
     Camera.main.transform.position = newPos;
     DevConsole.Log(logThis, "green");
 }
コード例 #29
0
 public static void StartMacro()
 {
     DevConsole.Log("Starting Macro!");
     DevConsole.StartMacro();
 }
コード例 #30
0
 public static void AllTags()
 {
     DevConsole.Log("All the tags: ", "green");
     DevConsole.Log(string.Join(", ", DevConsole.CommandArray().SelectMany(x => x.Tags).Select(x => x.Trim()).Distinct().ToArray()));
 }