Ejemplo n.º 1
0
        public void OnApplicationStart()
        {
            //Asynchronous Twitch Library
            SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
            SceneManager.sceneLoaded        += SceneManager_sceneLoaded;
            {
                Log("Creating Harmony Instance");
                harmony = HarmonyInstance.Create("com.kyle1413.BeatSaber.GamePlayModifiersPlus");
                ApplyPatches();
            }
            CheckPlugins();

            if (twitchPluginInstalled)
            {
                InitStreamCore();
            }
            ChatConfig.Load();
            ReadPrefs();
            //Delete old config if it exists
            if (File.Exists(Path.Combine(Environment.CurrentDirectory, "UserData\\GamePlayModifiersPlusChatSettings.ini")))
            {
                try
                {
                    File.Delete(Path.Combine(Environment.CurrentDirectory, "UserData\\GamePlayModifiersPlusChatSettings.ini"));
                }
                catch (Exception ex)
                {
                    Log("Could not Delete Old Config: " + ex);
                }
            }
            cooldowns = new Cooldowns();
            defColorA.SetColor(new Color(1f, 0, 0));
            defColorB.SetColor(new Color(0, .706f, 1));

            if (ModPrefs.GetInt("GameplayModifiersPlus", "GameRumbleSetting", -1, false) != -1)
            {
                Log("Rumble Key Exists");
                setDefaultRumble = true;
            }
        }
        public void CheckConfigMessage(TwitchMessage message)
        {
            string messageString = message.message.ToLower();

            if (!messageString.Contains("!configchange"))
            {
                return;
            }
            if (!(message.user.isMod && ChatConfig.allowModCommands) && !message.user.isBroadcaster)
            {
                return;
            }
            string command        = "";
            string property       = "";
            bool   isPropertyOnly = false;
            string value          = value = messageString.Split('=')[1];
            string arg1           = messageString.Split(' ', ' ')[1];
            string arg2           = messageString.Split(' ', ' ', '=')[2];

            Plugin.Log(arg1 + " " + arg2 + " " + value);
            switch (arg1)
            {
            case "da":
                command = "DA";
                break;

            case "smaller":
                command = "Smaller";
                break;

            case "larger":
                command = "Larger";
                break;

            case "random":
                command = "Random";
                break;

            case "instafail":
                command = "Instafail";
                break;

            case "invincible":
                command = "Invincible";
                break;

            case "njsrandom":
                command = "NjsRandom";
                break;

            case "noarrows":
                command = "NoArrows";
                break;

            case "funky":
                command = "Funky";
                break;

            case "rainbow":
                command = "Rainbow";
                break;

            case "pause":
                command = "Pause";
                break;

            case "bombs":
                command = "Bombs";
                break;

            case "faster":
                command = "Faster";
                break;

            case "slower":
                command = "Slower";
                break;

            case "poison":
                command = "Poison";
                break;

            case "offsetrandom":
                command = "OffsetRandom";
                break;

            case "reverse":
                command = "Reverse";
                break;

            case "mirror":
                command = "Mirror";
                break;

            default:
                isPropertyOnly = true;
                break;
            }
            if (isPropertyOnly)
            {
                switch (arg1.Split('=')[0])
                {
                case "bitspercharge":
                    property = "bitsPerCharge";
                    break;

                case "chargesforsupercharge":
                    property = "chargesForSuperCharge";
                    break;

                case "maxcharges":
                    property = "maxCharges";
                    break;

                case "chargesperlevel":
                    property = "chargesPerLevel";
                    break;

                case "allowsubs":
                    property = "allowSubs";
                    break;

                case "alloweveryone":
                    property = "allowEveryone";
                    break;

                case "commandspermessage":
                    property = "commandsPerMessage";
                    break;

                case "globalcommandcooldown":
                    property = "globalCommandCooldown";
                    break;

                case "timeforcharges":
                    property = "timeForCharges";
                    break;

                case "chargesovertime":
                    property = "chargesOverTime";
                    break;

                case "showcooldownonmessage":
                    property = "showCooldownOnMessage";
                    break;

                case "uiontop":
                    property = "uiOnTop";
                    break;

                case "resetchargeseachlevel":
                    property = "resetChargesEachLevel";
                    break;

                case "allowmodcommands":
                    property = "allowModCommands";
                    break;

                default:
                    return;
                }
                ChatConfig.ChangeConfigValue(property, value);
            }
            else
            {
                switch (arg2)
                {
                case "chargecost":
                    property = "ChargeCost";
                    break;

                case "cooldown":
                    property = "CoolDown";
                    break;

                case "globalcooldown":
                    property = "CoolDown";
                    break;

                case "duration":
                    property = "Duration";
                    break;

                case "min":
                    property = "Min";
                    break;

                case "max":
                    property = "Max";
                    break;

                case "chance":
                    property = "Chance";
                    break;

                case "multiplier":
                    property = "Multiplier";
                    break;

                default:
                    return;
                }

                ChatConfig.ChangeConfigValue(command, property, value);
            }
        }
        public void CheckInfoCommands(TwitchMessage message)
        {
            if (message.message.ToLower().Contains("!gm help"))
            {
                TwitchWebSocketClient.SendMessage("Guides: For Regular Users - http://bit.ly/1413ChatUser | For Streamers - http://bit.ly/1413Readme | For moderators also view http://bit.ly/1413Config");
            }
            if (message.message.ToLower().Contains("!currentsong"))
            {
                if (!Plugin.isValidScene)
                {
                    TwitchWebSocketClient.SendMessage("No song is currently being played.");
                }
                else
                {
                    TwitchWebSocketClient.SendMessage("Current Song: " + Plugin.levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.songName
                                                      + " - " + Plugin.levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.songSubName + " mapped by " + Plugin.levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.songAuthorName);
                }
            }

            if (message.message.ToLower().Contains("!gm chargehelp"))
            {
                if (ChatConfig.timeForCharges == 0 || ChatConfig.chargesOverTime == 0)
                {
                    TwitchWebSocketClient.SendMessage("Every " + ChatConfig.bitsPerCharge + " bits sent with a message adds a charge, which are used to activate commands! If you add super at the end of a command, it will cost " + ChatConfig.chargesForSuperCharge + " Charges but will make the effect last much longer! " + ChatConfig.chargesPerLevel + " Charges are generated every song with chat mode on.");
                }
                else
                {
                    TwitchWebSocketClient.SendMessage("Every " + ChatConfig.bitsPerCharge + " bits sent with a message adds a charge, which are used to activate commands! If you add super at the end of a command, it will cost " + ChatConfig.chargesForSuperCharge + " Charges but will make the effect last much longer! " + ChatConfig.chargesPerLevel + " Charges are generated every song with chat mode on. Every " + ChatConfig.timeForCharges + " seconds, " + ChatConfig.chargesOverTime + " are added.");
                }
            }
            if (message.message.ToLower().Contains("!gm commands"))
            {
                TwitchWebSocketClient.SendMessage("Currently supported commands | status: Currrent Status of chat integration | charges: view current charges and costs | chargehelp: Explain charge system");
            }


            if (message.message.ToLower().Contains("!gm charges"))
            {
                TwitchWebSocketClient.SendMessage("Charges: " + Plugin.charges + " | Commands Per Message: " + ChatConfig.commandsPerMessage + " | " + ChatConfig.GetChargeCostString());
            }
        }