Exemple #1
0
 public static void DisableInteractiveMode()
 {
     IRCConnection.SendMessage("Interactive Mode Disabled");
     TwitchPlaySettings.data.EnableInteractiveMode = false;
     TwitchPlaySettings.WriteDataToFile();
     TwitchGame.EnableDisableInput();
 }
    private void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            InputInterceptor.EnableInput();
        }

        if (Input.GetKeyDown(debugSequence[debugSequenceIndex].ToString()))
        {
            debugSequenceIndex++;
            if (debugSequenceIndex != debugSequence.Length)
            {
                return;
            }

            TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled;
            TwitchPlaySettings.WriteDataToFile();

            debugSequenceIndex = 0;
            UserAccess.AddUser("_TPDEBUG".ToLowerInvariant(), AccessLevel.Streamer | AccessLevel.SuperUser | AccessLevel.Admin | AccessLevel.Mod);
            UserAccess.WriteAccessList();
        }
        else if (Input.anyKeyDown)
        {
            debugSequenceIndex = 0;
        }
    }
Exemple #3
0
 public static void EnableTwitchPlays()
 {
     IRCConnection.SendMessage("Twitch Plays Enabled");
     TwitchPlaySettings.data.EnableTwitchPlaysMode = true;
     TwitchPlaySettings.WriteDataToFile();
     TwitchGame.EnableDisableInput();
 }
    private void Update()
    {
        MainThreadQueue.ProcessQueue();

        if (Input.GetKey(KeyCode.Escape))
        {
            InputInterceptor.EnableInput();
            TwitchGame.ModuleCameras?.DisableCameraWall();
        }

        if (Input.GetKeyDown(DebugSequence[_debugSequenceIndex].ToString()))
        {
            _debugSequenceIndex++;
            if (_debugSequenceIndex != DebugSequence.Length)
            {
                return;
            }

            TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled;
            TwitchPlaySettings.WriteDataToFile();

            chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled);

            _debugSequenceIndex = 0;
            UserAccess.AddUser("_TPDEBUG".ToLowerInvariant(), AccessLevel.Streamer | AccessLevel.SuperUser | AccessLevel.Admin | AccessLevel.Mod);
            UserAccess.WriteAccessList();
        }
        else if (Input.anyKeyDown)
        {
            _debugSequenceIndex = 0;
        }
    }
    private void OnGUI()
    {
        if (!TwitchPlaySettings.data.TwitchPlaysDebugEnabled)
        {
            return;
        }

        GUILayout.BeginArea(new Rect(50, Screen.height - 75, (Screen.width - 50) * 0.2f, 25));
        GUILayout.BeginHorizontal();
        inputCommand = GUILayout.TextField(inputCommand, GUILayout.MinWidth(50));
        if ((GUILayout.Button("Send") || Event.current.keyCode == KeyCode.Return) && inputCommand.Length != 0)
        {
            if (inputCommand.Equals(debugSequence))
            {
                TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled;
                TwitchPlaySettings.WriteDataToFile();
                inputCommand = "";
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                return;
            }
            IRCConnection.Instance.SetDebugUsername();
            IRCConnection.Instance.SendMessage(inputCommand);
            IRCConnection.Instance.OnMessageReceived.Invoke(IRCConnection.Instance.UserNickName, IRCConnection.Instance.CurrentColor, inputCommand, false);
            inputCommand = "";
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Exemple #6
0
 private static void SetTimeModeTimeLimit(object timeLimit)
 {
     if (timeLimit is int intTimeLimit)
     {
         TwitchPlaySettings.data.TimeModeStartingTime = intTimeLimit;
         TwitchPlaySettings.WriteDataToFile();
     }
 }
Exemple #7
0
    private IEnumerator RefreshIRCBackground()
    {
        yield return(null);

        if (_imageLoadingDisabled)
        {
            yield break;
        }
        yield return(null);

        IRCText.color = TwitchPlaySettings.data.IRCManagerTextColor;
        try
        {
#pragma warning disable IDE0031 // Use null propagation
            MeshRenderer background = _newImageGameObject != null?_newImageGameObject.GetComponent <MeshRenderer>() : null;

#pragma warning restore IDE0031 // Use null propagation
            //Image loading at runtime found at https://forum.unity.com/threads/solved-apply-image-to-plane-primitive.320489/
            if (background == null || !File.Exists(TwitchPlaySettings.data.IRCManagerBackgroundImage))
            {
                _originalImageGameObject.SetActive(true);
                if (_newImageGameObject != null)
                {
                    _newImageGameObject.SetActive(false);
                }
                yield break;
            }

            _originalImageGameObject.SetActive(false);
            if (_newImageGameObject != null)
            {
                _newImageGameObject.SetActive(true);
            }

            byte[]    bytes = File.ReadAllBytes(TwitchPlaySettings.data.IRCManagerBackgroundImage);
            Texture2D tex   = new Texture2D(1, 1);
            tex.LoadImage(bytes);
            background.material.mainTexture = tex;
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "Could NOT set a custom background image due to an exception. Feature is being disabled for the rest of this session:");
            _imageLoadingDisabled = true;
            TwitchPlaySettings.WriteDataToFile();
            _originalImageGameObject.SetActive(true);
            if (_newImageGameObject != null)
            {
                _newImageGameObject.SetActive(false);
            }
        }
    }
    public IceCreamConfirm(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        _settings = new Settings();
        modInfo   = ComponentSolverFactory.GetModuleInfo(GetModuleType(), ShimData.HelpMessage + " Check the opening hours with !{0} hours.");
        KMModSettings modSettings = bombComponent.GetComponent <KMModSettings>();

        try
        {
            _settings = JsonConvert.DeserializeObject <Settings>(modSettings.Settings);
        }
        catch (Exception ex)
        {
            DebugHelper.LogException(ex, "Could not deserialize ice cream settings:");
            TwitchPlaySettings.data.ShowHours = false;
            TwitchPlaySettings.WriteDataToFile();
        }
    }
    private void SetupChatSimulator()
    {
        chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled);
        var num = MouseControls.SCREEN_BOUNDARY_PERCENT * Screen.height + 5;

        chatSimulator.transform.position = new Vector3(num, num, 0);

        var messageInput = chatSimulator.Traverse <InputField>("MessageInput");
        var sendButton   = chatSimulator.Traverse <Button>("SendButton");

        messageInput.onEndEdit.AddListener(_ =>
        {
            if (Input.GetKey(KeyCode.Return))
            {
                sendButton.onClick.Invoke();
                messageInput.ActivateInputField();
            }
        });

        sendButton.onClick.AddListener(() =>
        {
            var message = messageInput.text;
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if (message.Equals(DebugSequence))
            {
                TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled;
                TwitchPlaySettings.WriteDataToFile();

                chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled);
            }
            else
            {
                IRCConnection.SetDebugUsername();
                IRCConnection.SendMessage(message);
                IRCConnection.ReceiveMessage(IRCConnection.Instance.UserNickName, IRCConnection.Instance.CurrentColor, message);
            }

            messageInput.text = "";
        });
    }
 public static bool ToggleMode()
 {
     TwitchPlaySettings.data.LogUploaderShortUrls = !TwitchPlaySettings.data.LogUploaderShortUrls;
     TwitchPlaySettings.WriteDataToFile();
     return(TwitchPlaySettings.data.LogUploaderShortUrls);
 }
 public static void ChangeMode(bool toShort)
 {
     TwitchPlaySettings.data.LogUploaderShortUrls = toShort;
     TwitchPlaySettings.WriteDataToFile();
 }
    public IEnumerator RespondToCommand(string userNickName, string message)
    {
        DisableOnStrike      = false;
        Strike               = false;
        StrikeCount          = 0;
        _currentUserNickName = userNickName;

        FloatingHoldable.HoldStateEnum holdState = Holdable.HoldState;

        if (holdState == FloatingHoldable.HoldStateEnum.Held)
        {
        }
        else
        {
            IEnumerator holdCoroutine = HoldableCommander.Hold();
            while (holdCoroutine.MoveNext() && !Strike)
            {
                yield return(holdCoroutine.Current);
            }
        }

        IEnumerator processCommand = RespondToCommandCommon(message);

        if (processCommand == null || !processCommand.MoveNext())
        {
            DebugHelper.Log("Running RespondToCommandInternal()");
            processCommand = RespondToCommandInternal(message);
            bool cancelled  = false;
            bool parseError = false;
            bool cancelling = false;

            if (processCommand == null || !processCommand.MoveNext())
            {
                if (!Strike)
                {
                    SendToChat(null, userNickName, ref parseError);
                }
            }
            else
            {
                processIEnumerators.Push(processCommand);
                processIEnumerators.Push(FirstItem(processCommand.Current));
            }

            do
            {
                try
                {
                    bool result = false;
                    while (!result && !Strike)
                    {
                        if (processIEnumerators.Count > 0)
                        {
                            processCommand = processIEnumerators.Pop();
                            result         = processCommand.MoveNext();
                            if (result)
                            {
                                processIEnumerators.Push(processCommand);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (Strike)
                    {
                        DebugHelper.Log("A strike was caused by the command. Invocation will not continue.");
                    }
                    if (!result || Strike)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.LogException(ex, "Error Processing command due to an exception. Invocation will not continue.:");
                    break;
                }

                switch (processCommand.Current)
                {
                case IEnumerator iEnumerator:
                    if (iEnumerator != null)
                    {
                        processIEnumerators.Push(iEnumerator);
                    }
                    continue;

                case KMSelectable kmSelectable when kmSelectable != null:
                    if (heldSelectables.Contains(kmSelectable))
                    {
                        DoInteractionEnd(kmSelectable);
                        heldSelectables.Remove(kmSelectable);
                    }
                    else
                    {
                        DoInteractionStart(kmSelectable);
                        heldSelectables.Add(kmSelectable);
                    }
                    break;

                case KMSelectable[] kmSelectables:
                    foreach (KMSelectable selectable in kmSelectables)
                    {
                        if (selectable != null)
                        {
                            yield return(DoInteractionClick(selectable));

                            if (Strike)
                            {
                                break;
                            }
                        }
                        else
                        {
                            yield return(new WaitForSeconds(0.1f));
                        }
                    }
                    break;

                case Quaternion quaternion:
                    HoldableCommander.RotateByLocalQuaternion(quaternion);
                    break;

                case string currentString when !string.IsNullOrEmpty(currentString):
                    if (currentString.Equals("trycancel", StringComparison.InvariantCultureIgnoreCase) &&
                        CoroutineCanceller.ShouldCancel)
                    {
                        CoroutineCanceller.ResetCancel();
                        cancelled = true;
                    }
                    else if (currentString.ToLowerInvariant().EqualsAny("elevator music", "hold music", "waiting music"))
                    {
                        if (_musicPlayer == null)
                        {
                            _musicPlayer = MusicPlayer.StartRandomMusic();
                        }
                    }
                    else if (currentString.ToLowerInvariant().Equals("cancelled") && cancelling)
                    {
                        CancelBool?.SetValue(CommandComponent, false);
                        CoroutineCanceller.ResetCancel();
                        cancelled = true;
                    }
                    else if (currentString.StartsWith("strikemessage ", StringComparison.InvariantCultureIgnoreCase) &&
                             currentString.Substring(14).Trim() != string.Empty)
                    {
                        StrikeMessage = currentString.Substring(14);
                    }
                    else if (currentString.Equals("strike", StringComparison.InvariantCultureIgnoreCase))
                    {
                        _delegatedStrikeUserNickName = _currentUserNickName;
                    }
                    else if (currentString.Equals("multiple strikes", StringComparison.InvariantCultureIgnoreCase))
                    {
                        DisableOnStrike = true;
                    }
                    else if (currentString.ToLowerInvariant().EqualsAny("detonate", "explode") && BombMessageResponder.BombActive)
                    {
                        BombCommander BombCommander = BombMessageResponder.Instance.BombCommanders[0];
                        AwardStrikes(_currentUserNickName, BombCommander.StrikeLimit - BombCommander.StrikeCount);
                        BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(string.Empty, HoldableCommander.ID);
                        Strike = true;
                    }
                    else if (currentString.ToLowerInvariant().Equals("show front"))
                    {
                        processIEnumerators.Push(HoldableCommander.Hold(true));
                    }
                    else if (currentString.ToLowerInvariant().Equals("show back"))
                    {
                        processIEnumerators.Push(HoldableCommander.Hold(false));
                    }
                    else
                    {
                        SendToChat(currentString, userNickName, ref parseError);
                    }
                    break;

                case string[] currentStrings:
                    if (currentStrings.Length >= 1)
                    {
                        if (currentStrings[0].ToLowerInvariant().EqualsAny("detonate", "explode") && BombMessageResponder.BombActive)
                        {
                            BombCommander BombCommander = BombMessageResponder.Instance.BombCommanders[0];
                            AwardStrikes(_currentUserNickName, BombCommander.StrikeLimit - BombCommander.StrikeCount);
                            switch (currentStrings.Length)
                            {
                            case 2:
                                BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(currentStrings[1], HoldableCommander.ID);
                                break;

                            case 3:
                                BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(currentStrings[1], currentStrings[2]);
                                break;

                            default:
                                BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(string.Empty, HoldableCommander.ID);
                                break;
                            }
                            break;
                        }
                    }
                    break;

                case Dictionary <string, bool> permissions:
                    foreach (KeyValuePair <string, bool> pair in permissions)
                    {
                        if (TwitchPlaySettings.data.ModPermissions.ContainsKey(pair.Key))
                        {
                            continue;
                        }
                        TwitchPlaySettings.data.ModPermissions.Add(pair.Key, pair.Value);
                        TwitchPlaySettings.WriteDataToFile();
                    }
                    break;

                case KMMission mission:
                    MiscellaneousMessageResponder.Instance.RunMission(mission);
                    break;

                case object[] objects:
                    if (objects == null)
                    {
                        break;
                    }
                    switch (objects.Length)
                    {
                    case 3 when objects[0] is string objstr:
                        if (IsAskingPermission(objstr, userNickName, out bool permissionGranted))
                        {
                            if (permissionGranted)
                            {
                                switch (objects[1])
                                {
                                case Action actionTrue:
                                    actionTrue.Invoke();
                                    break;

                                case IEnumerator iEnumerator when iEnumerator != null:
                                    processIEnumerators.Push(iEnumerator);
                                    yield return(null);

                                    continue;
                                }
                            }
                            else
                            {
                                switch (objects[2])
                                {
                                case Action actionFalse:
                                    actionFalse.Invoke();
                                    break;

                                case string objStr2 when !string.IsNullOrEmpty(objStr2):
                                    SendToChat(objStr2, userNickName, ref parseError);
                                    break;

                                case IEnumerator iEnumerator when iEnumerator != null:
                                    processIEnumerators.Push(iEnumerator);
                                    yield return(null);

                                    continue;
                                }
                            }
                        }
                        break;
                    }
                    break;