Esempio n. 1
0
    public void ChangeBomb(TwitchBomb bomb)
    {
        DebugHelper.Log("Switching bomb");
        if (_currentBomb != null)
        {
            _currentBomb.CanvasGroup.alpha = 0;
        }
        if (bomb != null)
        {
            bomb.CanvasGroup.alpha = 1;
        }

        _currentBomb = bomb;
        UpdateHeader();
        UpdateStrikes();
        UpdateSolves();
        UpdateConfidence();

        int needies = _currentBomb.Bomb.BombComponents.Count(bombComponent => bombComponent.GetComponent <NeedyComponent>() != null);

        NeediesPrefab.gameObject.SetActive(needies > 0);
        NeediesPrefab.text = needies.ToString();

        if (TwitchPlaySettings.data.EnableEdgeworkCameras)
        {
            SetupEdgeworkCameras();
        }
    }
Esempio n. 2
0
    public static void ChangeStrikeParameter(TwitchBomb bomb, string user, bool isWhisper, [Group(1)] bool negative, [Group(2)] bool direct, [Group(3)] bool isStrikes, [Group(4)] int amount)
    {
        void setParameter(string thing1, string thing2, int originalAmount, Func <int, int> set)
        {
            // Don’t go below 0 strikes because Simon Says is unsolvable then.
            var newAmount = set(Math.Max(0, direct ? amount : negative ? originalAmount - amount : originalAmount + amount));

            if (direct)
            {
                IRCConnection.SendMessage(string.Format("{2} set to {0} {1}.", newAmount, newAmount != 1 ? "strikes" : "strike", thing1), user, !isWhisper);
            }
            else
            {
                var difference = Math.Abs(newAmount - originalAmount);
                IRCConnection.SendMessage(string.Format(newAmount >= originalAmount ? "Added {0} {1} to the {2}." : "Subtracted {0} {1} from the {2}.", difference, difference != 1 ? "strikes" : "strike", thing2), user, !isWhisper);
            }
        }

        if (isStrikes)
        {
            setParameter("Strike count", "bomb", bomb.StrikeCount, am => bomb.StrikeCount = am);
        }
        else            // strike limit
        {
            setParameter("Strike limit", "strike limit", bomb.StrikeLimit, am => bomb.StrikeLimit = am);
        }

        TwitchGame.ModuleCameras.UpdateStrikes();
    }
Esempio n. 3
0
 public static void Pause(TwitchBomb bomb)
 {
     if (bomb.Bomb.GetTimer().IsUpdating)
     {
         bomb.Bomb.GetTimer().StopTimer();
     }
 }
Esempio n. 4
0
    public void CreateComponentHandlesForBomb(TwitchBomb bomb)
    {
        foreach (var component in bomb.Bomb.BombComponents)
        {
            var    componentType = component.ComponentType;
            string moduleName;

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (componentType)
            {
            case ComponentTypeEnum.Empty:
            case ComponentTypeEnum.Timer:
                continue;

            default:
                moduleName = component.GetModuleDisplayName();
                break;
            }

            TwitchModule module = Instantiate(twitchModulePrefab, component.transform, false);
            module.Bomb          = bomb;
            module.BombComponent = component;
            module.BombID        = _currentBomb == -1 ? -1 : Bombs.Count - 1;

            module.transform.SetParent(component.transform.parent, true);
            module.BasePosition = module.transform.localPosition;

            Modules.Add(module);
        }
    }
Esempio n. 5
0
 public static void Unpause(TwitchBomb bomb)
 {
     if (!bomb.Bomb.GetTimer().IsUpdating)
     {
         bomb.Bomb.GetTimer().StartTimer();
     }
 }
Esempio n. 6
0
    private TwitchBomb CreateBombHandleForBomb(Bomb bomb, int id)
    {
        TwitchBomb twitchBomb = Instantiate(twitchBombPrefab);

        twitchBomb.Bomb              = bomb;
        twitchBomb.BombID            = id;
        twitchBomb.BombTimeStamp     = DateTime.Now;
        twitchBomb.BombStartingTimer = bomb.GetTimer().TimeRemaining;
        return(twitchBomb);
    }
Esempio n. 7
0
    public static void Clear(bool clearGlobal = false)
    {
        if (Bomb == null && !clearGlobal)
        {
            return;
        }

        Bomb = null;
        Voters.Clear();
        ResetTimer();
    }
Esempio n. 8
0
 public static IEnumerator Edgework(TwitchBomb bomb, [Group(1)] string edge, string user, bool isWhisper)
 {
     if (TwitchPlaySettings.data.EnableEdgeworkCommand || TwitchPlaySettings.data.AnarchyMode)
     {
         return(bomb.ShowEdgework(edge));
     }
     else
     {
         IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombEdgework, bomb.EdgeworkText.text), user, !isWhisper);
         return(null);
     }
 }
Esempio n. 9
0
    public static void ChangeTimer(TwitchBomb bomb, string user, bool isWhisper, [Group(1)] bool negative, [Group(2)] bool direct, [Group(3)] string amount)
    {
        float time         = 0;
        float originalTime = bomb.Bomb.GetTimer().TimeRemaining;
        var   timeLengths  = new Dictionary <string, float>()
        {
            { "ms", 0.001f },
            { "s", 1 },
            { "m", 60 },
            { "h", 3600 },
            { "d", 86400 },
            { "w", 604800 },
            { "y", 31536000 },
        };

        foreach (string part in amount.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
        {
            bool valid = false;
            foreach (string unit in timeLengths.Keys)
            {
                if (!part.EndsWith(unit, StringComparison.InvariantCultureIgnoreCase) || !float.TryParse(part.Substring(0, part.Length - unit.Length), out float length))
                {
                    continue;
                }
                time += length * timeLengths[unit];
                valid = true;
                break;
            }

            if (!valid)
            {
                IRCConnection.SendMessage(@"I don’t understand “{0}”.", user, !isWhisper, part);
                return;
            }
        }

        time = (float)Math.Round((decimal)time, 2, MidpointRounding.AwayFromZero);
        if (!direct && Math.Abs(time) < 0.01f)
        {
            return;
        }

        bomb.CurrentTimer = direct ? time : negative ? bomb.CurrentTimer - time : bomb.CurrentTimer + time;

        // If the time requested was negative, we need to flip the message.
        bool negativeTime = time < 0 ? !negative : negative;

        IRCConnection.SendMessage(direct
                        ? $"Set the bomb's timer to {Math.Abs(time < 0 ? 0 : time).FormatTime()}."
                        : $"{(negativeTime ? "Subtracted" : "Added")} {Math.Abs(time).FormatTime()} {(negativeTime ? "from" : "to")} the timer.", user, !isWhisper);
    }
Esempio n. 10
0
    public void ChangeBomb(TwitchBomb bomb)
    {
        DebugHelper.Log("Switching bomb");
        _currentBomb = bomb;
        UpdateHeader();
        UpdateStrikes();
        UpdateSolves();
        UpdateConfidence();

        int needies = _currentBomb.Bomb.BombComponents.Count(bombComponent => bombComponent.GetComponent <NeedyComponent>() != null);

        NeediesPrefab.gameObject.SetActive(needies > 0);
        NeediesPrefab.text = needies.ToString();
    }
Esempio n. 11
0
    public void CreateComponentHandlesForBomb(TwitchBomb bomb)
    {
        string[] keyModules =
        {
            "SouvenirModule",       "MemoryV2", "TurnTheKey", "TurnTheKeyAdvanced", "theSwan", "HexiEvilFMN", "taxReturns", "timeKeeper", "cookieJars",
            "DividedSquaresModule", "forgetThis"
        };

        foreach (var component in bomb.Bomb.BombComponents)
        {
            var    componentType = component.ComponentType;
            bool   keyModule     = false;
            string moduleName;

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (componentType)
            {
            case ComponentTypeEnum.Empty:
            case ComponentTypeEnum.Timer:
                continue;

            case ComponentTypeEnum.NeedyCapacitor:
            case ComponentTypeEnum.NeedyKnob:
            case ComponentTypeEnum.NeedyVentGas:
            case ComponentTypeEnum.NeedyMod:
                moduleName = component.GetModuleDisplayName();
                keyModule  = true;
                break;

            case ComponentTypeEnum.Mod:
                keyModule = keyModules.Contains(component.GetComponent <KMBombModule>().ModuleType);
                goto default;

            default:
                moduleName = component.GetModuleDisplayName();
                break;
            }

            TwitchModule module = Instantiate(twitchModulePrefab, component.transform, false);
            module.Bomb          = bomb;
            module.BombComponent = component;
            module.BombID        = _currentBomb == -1 ? -1 : Bombs.Count - 1;
            module.IsKey         = keyModule;

            module.transform.SetParent(component.transform.parent, true);
            module.BasePosition = module.transform.localPosition;

            Modules.Add(module);
        }
    }
Esempio n. 12
0
    protected void InitializeBomb(Bomb bomb, bool reuseTwitchBomb = false)
    {
        if (!reuseTwitchBomb)
        {
            TwitchGame.Instance.SetBomb(bomb, BombCount);
            return;
        }

        TwitchBomb tb = TwitchGame.Instance.Bombs[0];

        tb.Bomb              = bomb;
        tb.BombTimeStamp     = DateTime.Now;
        tb.BombStartingTimer = bomb.GetTimer().TimeRemaining;
        TwitchGame.Instance.CreateComponentHandlesForBomb(tb);
        TwitchGame.Instance.InitializeModuleCodes();
    }
Esempio n. 13
0
 private void ToggleEmergencyLights(bool on, TwitchBomb handle)
 {
     if (_emergencyLightsState == on)
     {
         return;
     }
     _emergencyLightsState = on;
     if (!on)
     {
         handle.StopCoroutine(_emergencyLightsRoutine);
         _emergencyLightsRoutine = null;
         _roomLight.GetComponent <Light>().color = new Color(0.5f, 0.5f, 0.5f);
     }
     else
     {
         _emergencyLightsRoutine = (IEnumerator)_redLightsMethod.Invoke(_room, null);
         handle.StartCoroutine(_emergencyLightsRoutine);
     }
 }
Esempio n. 14
0
    public static void Status(TwitchBomb bomb, string user, bool isWhisper)
    {
        int currentReward = TwitchPlaySettings.GetRewardBonus();

        if (OtherModes.TimeModeOn)
        {
            IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombStatusTimeMode, bomb.GetFullFormattedTime, bomb.GetFullStartingTime,
                                                    OtherModes.GetAdjustedMultiplier(), bomb.BombSolvedModules, bomb.BombSolvableModules, currentReward), user, !isWhisper);
        }
        else if (OtherModes.VSModeOn)
        {
            IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombStatusVsMode, bomb.GetFullFormattedTime,
                                                    bomb.GetFullStartingTime, OtherModes.goodHealth, OtherModes.evilHealth, currentReward), user, !isWhisper);
        }
        else
        {
            IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombStatus, bomb.GetFullFormattedTime, bomb.GetFullStartingTime,
                                                    bomb.StrikeCount, bomb.StrikeLimit, bomb.BombSolvedModules, bomb.BombSolvableModules, currentReward), user, !isWhisper);
        }
    }
Esempio n. 15
0
    public void CreateComponentHandlesForBomb(TwitchBomb bomb)
    {
        foreach (var component in bomb.Bomb.BombComponents)
        {
            if (component.ComponentType.EqualsAny(ComponentTypeEnum.Empty, ComponentTypeEnum.Timer))
            {
                continue;
            }

            TwitchModule module = Instantiate(twitchModulePrefab, component.transform, false);
            module.Bomb          = bomb;
            module.BombComponent = component;
            module.BombID        = _currentBomb == -1 ? -1 : Bombs.Count - 1;

            module.transform.SetParent(component.transform.parent, true);
            module.BasePosition = module.transform.localPosition;

            Modules.Add(module);
        }
    }
Esempio n. 16
0
    public static void StartVote(TwitchBomb TPBomb, string user, VoteTypes act)
    {
        if (!TwitchPlaySettings.data.EnableVoting)
        {
            IRCConnection.SendMessage("Voting is disabled");
            return;
        }

        if (Active)
        {
            IRCConnection.SendMessage("A voting is already in progress!");
            return;
        }

        Clear();
        Bomb       = TPBomb;
        ActionType = act;
        Voters.Add(user, true);
        Countdown.Enabled = true;

        IRCConnection.SendMessage($"Voting has started by {user} to \"{voteNames[act]}\"! Enter with '!vote VoteYea ' or '!vote VoteNay '");
    }
Esempio n. 17
0
    public static IEnumerator Explode(TwitchBomb bomb, string user, bool isWhisper)
    {
        if (!OtherModes.TrainingModeOn)
        {
            IRCConnection.SendMessage("Training mode is not on.", user, false, user);
            return(null);
        }

        if (isWhisper)
        {
            IRCConnection.SendMessage("Sorry {0}, you can't end Training mode in a whisper.", user, false, user);
            return(null);
        }

        Leaderboard.Instance.GetRank(user, out var entry);
        if (!UserAccess.HasAccess(user, AccessLevel.Defuser, true) && entry != null && entry.SolveScore < TwitchPlaySettings.data.MinScoreForNewbomb)
        {
            IRCConnection.SendMessage("Sorry, you don't have enough points to end Training mode.");
            return(null);
        }

        return(bomb.DelayBombExplosionCoroutine());
    }
Esempio n. 18
0
    public override IEnumerator ReportBombStatus()
    {
        IEnumerator baseIEnumerator = base.ReportBombStatus();

        while (baseIEnumerator.MoveNext())
        {
            yield return(baseIEnumerator.Current);
        }
        TwitchBomb     bombHandle     = TwitchGame.Instance.Bombs[0];
        TimerComponent timerComponent = bombHandle.Bomb.GetTimer();

        yield return(new WaitUntil(() => timerComponent.IsActive));

        TwitchGame.Instance.OnLightsChange(true);

        _elevatorRoom.PacingActions.RemoveAll(action => action.EventType == PaceEvent.OneMinuteLeft);
        while (!bombHandle.Bomb.HasDetonated)
        {
            if (Input.GetKey(KeyCode.Escape))
            {
                IEnumerator bombDrop = bombHandle.LetGoBomb();
                while (bombDrop.MoveNext())
                {
                    yield return(bombDrop.Current);
                }
            }

            if (bombHandle.Bomb.IsSolved())
            {
                yield break;
            }
            ToggleEmergencyLights(SceneManager.Instance.GameplayState.Mission.PacingEventsEnabled &&
                                  bombHandle.CurrentTimer < 60f && !bombHandle.Bomb.IsSolved() && !OtherModes.ZenModeOn);
            yield return(null);
        }
    }
Esempio n. 19
0
 public static IEnumerator Drop(TwitchBomb bomb) => bomb.LetGoBomb();
Esempio n. 20
0
 public static IEnumerator Explode(TwitchBomb bomb) => bomb.DelayBombExplosionCoroutine();
Esempio n. 21
0
    public static IEnumerator Tilt(TwitchModule module, object yield, string direction)
    {
        float easeCubic(float t)
        {
            return(3 * t * t - 2 * t * t * t);
        }

        Dictionary <string[], int> directionNames = new Dictionary <string[], int>()
        {
            { new[] { "up", "u", "top", "t" }, 0 },
            { new[] { "upright", "rightup", "ur", "ru", "topright", "righttop", "tr", "rt" }, 45 },
            { new[] { "right", "r" }, 90 },
            { new[] { "downright", "rightdown", "dr", "rd", "bottomright", "rightbottom", "br", "rb" }, 135 },
            { new[] { "down", "d", "bottom", "b" }, 180 },
            { new[] { "downleft", "leftdown", "dl", "ld", "bottomleft", "leftbottom", "bl", "lb" }, 255 },
            { new[] { "left", "l" }, 270 },
            { new[] { "upleft", "leftup", "ul", "lu", "topleft", "lefttop", "tl", "lt" }, 315 },
        };

        var targetRotation = 180;

        if (!string.IsNullOrEmpty(direction))
        {
            var nameAngle = directionNames.Where(pair => pair.Key.Contains(direction)).Select(pair => pair.Value);
            if (nameAngle.Any())
            {
                targetRotation = nameAngle.First();
            }
            else if (int.TryParse(direction, out int directionAngle))
            {
                targetRotation = directionAngle;
            }
            else
            {
                yield break;
            }
        }

        IEnumerator focusCoroutine = module.Bomb.Focus(module.Selectable, module.FocusDistance, module.FrontFace, false);

        while (focusCoroutine.MoveNext())
        {
            yield return(focusCoroutine.Current);
        }

        yield return(new WaitForSeconds(0.5f));

        var targetAngle = Quaternion.Euler(new Vector3(-Mathf.Cos(targetRotation * Mathf.Deg2Rad), 0, Mathf.Sin(targetRotation * Mathf.Deg2Rad)) * (module.FrontFace ? 60 : -60));

        foreach (float alpha in 1f.TimedAnimation())
        {
            var lerp     = Quaternion.Lerp(Quaternion.identity, targetAngle, easeCubic(alpha));
            var bombLerp = module.FrontFace ? lerp : Quaternion.Euler(Vector3.Scale(lerp.eulerAngles, new Vector3(1, 1, -1)));
            module.Bomb.RotateByLocalQuaternion(bombLerp);
            TwitchBomb.RotateCameraByLocalQuaternion(module.BombComponent.gameObject, lerp);
            yield return(null);
        }

        yield return(yield is float delay ? new WaitForSecondsWithCancel(delay, false, module.Solver) : yield);

        if (CoroutineCanceller.ShouldCancel)
        {
            var angle     = Quaternion.identity;
            var bombAngle = module.FrontFace ? angle : Quaternion.Euler(Vector3.Scale(angle.eulerAngles, new Vector3(1, 1, -1)));
            module.Bomb.RotateByLocalQuaternion(bombAngle);
            TwitchBomb.RotateCameraByLocalQuaternion(module.BombComponent.gameObject, angle);
            module.StartCoroutine(module.Bomb.Defocus(module.Selectable, module.FrontFace, false));
            yield break;
        }

        foreach (float alpha in 1f.TimedAnimation())
        {
            var lerp     = Quaternion.Lerp(targetAngle, Quaternion.identity, easeCubic(alpha));
            var bombLerp = module.FrontFace ? lerp : Quaternion.Euler(Vector3.Scale(lerp.eulerAngles, new Vector3(1, 1, -1)));
            module.Bomb.RotateByLocalQuaternion(bombLerp);
            TwitchBomb.RotateCameraByLocalQuaternion(module.BombComponent.gameObject, lerp);
            yield return(null);
        }

        IEnumerator defocusCoroutine = module.Bomb.Defocus(module.Selectable, module.FrontFace, false);

        while (defocusCoroutine.MoveNext())
        {
            yield return(defocusCoroutine.Current);
        }

        yield return(new WaitForSeconds(0.5f));
    }
Esempio n. 22
0
 public static void Timestamp(TwitchBomb bomb, string user, bool isWhisper) => IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombTimeStamp, bomb.BombTimeStamp), user, !isWhisper);
Esempio n. 23
0
 public static void Time(TwitchBomb bomb, string user, bool isWhisper) => IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombTimeRemaining, bomb.GetFullFormattedTime, bomb.GetFullStartingTime), user, !isWhisper);
Esempio n. 24
0
 public static IEnumerator EdgeworkElevator(TwitchBomb bomb, [Group(1)] string edge, string user, bool isWhisper) => Edgework(bomb, edge, user, isWhisper);
 public static void VoteStart(TwitchBomb bomb, string user, [Group(1)] bool Detonation) => Votes.StartVote(bomb, user, Detonation ? VoteTypes.Detonation : 0);
Esempio n. 26
0
 public static IEnumerator TurnBomb(TwitchBomb bomb) => bomb.TurnBomb();
Esempio n. 27
0
    private void AwardStrikes(string userNickName, int strikeCount)
    {
        TwitchBomb bomb          = TwitchGame.Instance.Bombs[0];
        int        strikePenalty = -5;

        strikePenalty = TwitchPlaySettings.data.EnableRewardMultipleStrikes ? (strikeCount * strikePenalty) : (Math.Min(strikePenalty, strikeCount * strikePenalty));

        IRCConnection.SendMessageFormat(TwitchPlaySettings.data.AwardHoldableStrike,
                                        ID,
                                        strikeCount == 1 ? "a" : strikeCount.ToString(),
                                        strikeCount == 1 ? "" : "s",
                                        strikePenalty,
                                        userNickName,
                                        string.IsNullOrEmpty(StrikeMessage) ? "" : " caused by " + StrikeMessage);
        if (strikeCount <= 0)
        {
            return;
        }

        string recordMessageTone = $"Holdable ID: {ID} | Player: {userNickName} | Strike";

        TwitchPlaySettings.AppendToSolveStrikeLog(recordMessageTone, TwitchPlaySettings.data.EnableRewardMultipleStrikes ? strikeCount : 1);

        int originalReward = TwitchPlaySettings.GetRewardBonus();
        int currentReward  = Convert.ToInt32(originalReward * (1 - (1 - TwitchPlaySettings.data.AwardDropMultiplierOnStrike) * OtherModes.ScoreMultiplier));

        TwitchPlaySettings.AddRewardBonus(currentReward - originalReward);
        if (currentReward != originalReward)
        {
            IRCConnection.SendMessage($"Reward {(currentReward > 0 ? "reduced" : "increased")} to {currentReward} points.");
        }
        if (OtherModes.TimeModeOn)
        {
            bool   multiDropped = OtherModes.DropMultiplier();
            float  multiplier   = OtherModes.GetMultiplier();
            string tempMessage  = multiDropped
                                ? "Multiplier reduced to " + Math.Round(multiplier, 1) + " and time"
                                : $"Multiplier set at {TwitchPlaySettings.data.TimeModeMinMultiplier}, cannot be further reduced.  Time";
            if (bomb.CurrentTimer < (TwitchPlaySettings.data.TimeModeMinimumTimeLost / TwitchPlaySettings.data.TimeModeTimerStrikePenalty))
            {
                bomb.Bomb.GetTimer().TimeRemaining = bomb.CurrentTimer - TwitchPlaySettings.data.TimeModeMinimumTimeLost;
                tempMessage += $" reduced by {TwitchPlaySettings.data.TimeModeMinimumTimeLost} seconds.";
            }
            else
            {
                float  timeReducer = bomb.CurrentTimer * TwitchPlaySettings.data.TimeModeTimerStrikePenalty;
                double easyText    = Math.Round(timeReducer, 1);
                bomb.Bomb.GetTimer().TimeRemaining = bomb.CurrentTimer - timeReducer;
                tempMessage += $" reduced by {Math.Round(TwitchPlaySettings.data.TimeModeTimerStrikePenalty * 100, 1)}%. ({easyText} seconds)";
            }
            IRCConnection.SendMessage(tempMessage);
            bomb.StrikeCount = 0;
            if (TwitchGame.ModuleCameras != null)
            {
                TwitchGame.ModuleCameras.UpdateStrikes();
            }
        }

        Leaderboard.Instance?.AddScore(userNickName, strikePenalty);
        Leaderboard.Instance?.AddStrike(userNickName, strikeCount);
        StrikeMessage = string.Empty;
    }
Esempio n. 28
0
 public static IEnumerator Hold(TwitchBomb bomb) => bomb.HoldBomb();
Esempio n. 29
0
    public override IEnumerator ReportBombStatus()
    {
        if (_gameroom.GetType() == _factoryStaticModeType)
        {
            IEnumerator baseIEnumerator = base.ReportBombStatus();
            while (baseIEnumerator.MoveNext())
            {
                yield return(baseIEnumerator.Current);
            }
            yield break;
        }
        InitializeOnLightsOn = false;

        TwitchBomb bombHandle = TwitchGame.Instance.Bombs[0];

        bombHandle.BombName = _infiniteMode ? "Infinite bombs incoming" : $"{BombCount} bombs incoming";

        yield return(new WaitUntil(() => GetBomb != null || bombHandle.Bomb.HasDetonated));

        if (bombHandle.Bomb.HasDetonated && !_zenMode)
        {
            yield break;
        }

        float currentBombTimer = bombHandle.CurrentTimer + 5;
        int   currentBombID    = 1;

        while (GetBomb != null)
        {
            Object currentBomb = GetBomb;

            TimerComponent timerComponent = bombHandle.Bomb.GetTimer();
            yield return(new WaitUntil(() => timerComponent.IsActive));

            if (Math.Abs(currentBombTimer - bombHandle.CurrentTimer) > 1f)
            {
                yield return(null);

                InitializeGameModes(true);
            }

            bool enableCameraWall = OtherModes.TrainingModeOn && IRCConnection.Instance.State == IRCConnectionState.Connected && TwitchPlaySettings.data.EnableFactoryTrainingModeCameraWall;
            if (enableCameraWall != TwitchGame.ModuleCameras.CameraWallEnabled)
            {
                if (enableCameraWall)
                {
                    TwitchGame.ModuleCameras.EnableCameraWall();
                }
                else
                {
                    TwitchGame.ModuleCameras.DisableCameraWall();
                }
            }
            bombHandle.BombName = $"Bomb {currentBombID} of {(_infiniteMode ? "∞" : BombCount.ToString())}";
            IRCConnection.SendMessage($"Bomb {currentBombID++} of {(_infiniteMode ? "∞" : BombCount.ToString())} is now live.");

            if (TwitchPlaySettings.data.EnableAutomaticEdgework)
            {
                bombHandle.FillEdgework();
            }
            else
            {
                bombHandle.EdgeworkText.text = TwitchPlaySettings.data.BlankBombEdgework;
            }
            if (OtherModes.Unexplodable)
            {
                bombHandle.StrikeLimit += bombHandle.StrikeCount;
            }

            IEnumerator bombHold = bombHandle.HoldBomb();
            while (bombHold.MoveNext())
            {
                yield return(bombHold.Current);
            }

            Bomb bomb1 = (Bomb)_internalBombProperty.GetValue(currentBomb, null);
            yield return(new WaitUntil(() =>
            {
                bool result = bomb1.HasDetonated || bomb1.IsSolved() || !TwitchGame.BombActive;
                if (!result || OtherModes.TimeModeOn)
                {
                    currentBombTimer = bomb1.GetTimer().TimeRemaining;
                }
                return result;
            }));

            if (!TwitchGame.BombActive)
            {
                yield break;
            }

            IRCConnection.SendMessage(TwitchGame.Instance.GetBombResult(false));
            TwitchPlaySettings.SetRetryReward();

            foreach (TwitchModule handle in TwitchGame.Instance.Modules)
            {
                //If the camera is still attached to the bomb component when the bomb gets destroyed, then THAT camera is destroyed as wel.
                TwitchGame.ModuleCameras.UnviewModule(handle);
            }

            if (TwitchPlaySettings.data.EnableFactoryAutomaticNextBomb)
            {
                bombHold = bombHandle.LetGoBomb();
                while (bombHold.MoveNext())
                {
                    yield return(bombHold.Current);
                }
                yield return(new WaitForSeconds(1.0f));

                //If for some reason we are somehow still holding the bomb, then the Let go did not register.
                //Try again exactly one more time.
                if (currentBomb == GetBomb)
                {
                    bombHold = bombHandle.HoldBomb();
                    while (bombHold.MoveNext())
                    {
                        yield return(bombHold.Current);
                    }
                    yield return(new WaitForSeconds(0.10f));

                    bombHold = bombHandle.LetGoBomb();
                    while (bombHold.MoveNext())
                    {
                        yield return(bombHold.Current);
                    }
                }
            }

            //If we are still holding the bomb, wait for it to actually be put down manually, or by a Twitch plays Drop bomb command.
            while (currentBomb == GetBomb)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            bombHandle.StartCoroutine(DestroyBomb(currentBomb));

            if (GetBomb == null)
            {
                continue;
            }
            Bomb bomb = (Bomb)_internalBombProperty.GetValue(GetBomb, null);
            InitializeBomb(bomb, true);
        }
    }
Esempio n. 30
0
 public static IEnumerator Throw(TwitchBomb bomb, [Group(1)] int?strength = 5)
 {
     yield return(HoldableCommands.Throw(bomb.Bomb.GetComponent <FloatingHoldable>(), strength));
 }