/* Handle the repair behavior */
 void Update()
 {
     if (Input.GetMouseButtonDown(1) &&
         Physics.Raycast(
             m_LookTransform.position,
             m_LookTransform.forward,
             out m_Hit,
             m_InteractDistance,
             1 << 9))
     {
         // Start repairing
         m_RepairableSystem = m_Hit.transform.GetComponent <Repairable>();
         m_Repairing        = (m_RepairableSystem != null);
         animator.SetBool("Repairing", m_Repairing);
         effects.PlayBlowtorch();
     }
     else if (Input.GetMouseButton(1) && m_Repairing)
     {
         // continue repairing
         m_RepairableSystem.Repair(m_RepairSpeed * Time.deltaTime);
     }
     else if (Input.GetMouseButtonUp(1) && m_Repairing)
     {
         m_RepairableSystem = null;
         m_Repairing        = false;
         animator.SetBool("Repairing", false);
         effects.Stop();
     }
 }
Пример #2
0
        public Resupply(Actor self, Actor host, WDist closeEnough)
        {
            this.host        = Target.FromActor(host);
            this.closeEnough = closeEnough;
            allRepairsUnits  = host.TraitsImplementing <RepairsUnits>().ToArray();
            health           = self.TraitOrDefault <IHealth>();
            repairable       = self.TraitOrDefault <Repairable>();
            repairableNear   = self.TraitOrDefault <RepairableNear>();
            rearmable        = self.TraitOrDefault <Rearmable>();
            notifyResupplies = host.TraitsImplementing <INotifyResupply>().ToArray();

            var cannotRepairAtHost = health == null || health.DamageState == DamageState.Undamaged ||
                                     !allRepairsUnits.Any() ||
                                     ((repairable == null || !repairable.Info.RepairActors.Contains(host.Info.Name)) &&
                                      (repairableNear == null || !repairableNear.Info.RepairActors.Contains(host.Info.Name)));

            if (!cannotRepairAtHost)
            {
                activeResupplyTypes |= ResupplyType.Repair;
            }

            var cannotRearmAtHost = rearmable == null || !rearmable.Info.RearmActors.Contains(host.Info.Name) || rearmable.RearmableAmmoPools.All(p => p.FullAmmo());

            if (!cannotRearmAtHost)
            {
                activeResupplyTypes |= ResupplyType.Rearm;
            }
        }
Пример #3
0
        internal static void Configure(ModComponent modComponent)
        {
            ModRepairableComponent modRepairableComponent = modComponent.GetComponent <ModRepairableComponent>();

            if (modRepairableComponent == null)
            {
                return;
            }

            Repairable repairable = ModUtils.GetOrCreateComponent <Repairable>(modRepairableComponent);

            repairable.m_RepairAudio       = modRepairableComponent.Audio;
            repairable.m_DurationMinutes   = modRepairableComponent.Minutes;
            repairable.m_ConditionIncrease = modRepairableComponent.Condition;

            if (modRepairableComponent.MaterialNames.Length != modRepairableComponent.MaterialCounts.Length)
            {
                throw new ArgumentException("MaterialNames and MaterialCounts do not have the same length on gear item '" + modRepairableComponent.name + "'.");
            }

            repairable.m_RequiredGear      = ModUtils.GetItems <GearItem>(modRepairableComponent.MaterialNames, modRepairableComponent.name);
            repairable.m_RequiredGearUnits = modRepairableComponent.MaterialCounts;

            repairable.m_RepairToolChoices    = ModUtils.GetItems <ToolsItem>(modRepairableComponent.RequiredTools, modRepairableComponent.name);
            repairable.m_RequiresToolToRepair = repairable.m_RepairToolChoices.Length > 0;
        }
Пример #4
0
    private void DestroyRepariable(Repairable item)
    {
        List <PickupType> availableMats = item.GetAvailableMaterials();

        List <int> indexes = new List <int>();

        for (int i = 0; i < (availableMats.Count <= 2 ? availableMats.Count : 3); i++)
        {
            int val = Random.Range(0, availableMats.Count - 1);
            if (!indexes.Contains(val))
            {
                indexes.Add(val);
            }
            else
            {
                i--;
            }
        }

        List <RepairStage> repairStages = new List <RepairStage>();

        for (int i = 0; i < (availableMats.Count <= 2 ? availableMats.Count : 3); i++)
        {
            repairStages.Add(new RepairStage(availableMats[indexes[i]], Random.Range(1, 3), Color.black));
        }

        item.Break(repairStages);

        repairables.Remove(item);
    }
Пример #5
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (repairable != null)
     {
         repairable = null;
     }
 }
Пример #6
0
 public void instanitateTooltip(Repairable r)
 {
     foreach (int id in r.recipe.required_items)
     {
         rtp.gameObject.transform.GetChild(id).gameObject.SetActive(true);
         rtp.gameObject.transform.GetChild(id).gameObject.GetComponent <Image>().sprite = slotEmpty;
     }
 }
Пример #7
0
 public void RepairableUpdate(Repairable repairable)
 {
     if (repairable != currentRepairable)
     {
         return;
     }
     SetProgressionData();
 }
Пример #8
0
 public Repair(Actor self, Actor host, WDist closeEnough)
 {
     this.host        = Target.FromActor(host);
     this.closeEnough = closeEnough;
     allRepairsUnits  = host.TraitsImplementing <RepairsUnits>().ToArray();
     health           = self.TraitOrDefault <Health>();
     repairable       = self.TraitOrDefault <Repairable>();
 }
Пример #9
0
 protected virtual void Created(Actor self)
 {
     repairable       = self.TraitOrDefault <Repairable>();
     rearmable        = self.TraitOrDefault <Rearmable>();
     conditionManager = self.TraitOrDefault <ConditionManager>();
     speedModifiers   = self.TraitsImplementing <ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
     cachedPosition   = self.CenterPosition;
     notifyMoving     = self.TraitsImplementing <INotifyMoving>().ToArray();
 }
Пример #10
0
    private void OnTriggerEnter(Collider other)
    {
        Repairable repairable = other.GetComponent <Repairable>();

        if (repairable != null)
        {
            _repairableInView = repairable;
        }
    }
Пример #11
0
    public void OnInteract(Interactable interactable, Hand hand, Tool.ToolType toolType)
    {
        Repairable repairable = interactable.GetComponent <Repairable>();

        if (repairable != null)
        {
            repairable.RepairWithTool(toolType);
        }
    }
Пример #12
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            Repairable repairable = other.GetComponent <Repairable> ();

            if (repairable != null)
            {
                this.repairable = repairable;
            }
        }
Пример #13
0
    private void OnTriggerExit(Collider other)
    {
        Repairable repairable = other.GetComponent <Repairable>();

        if (repairable == _repairableInView)
        {
            _repairableInView = null;
        }
    }
Пример #14
0
        public void OnItemRepaired(Character character, Repairable repairable, float repairAmount)
        {
            float karmaIncrease = repairAmount * ItemRepairKarmaIncrease;

            if (repairable.HasRequiredSkills(character))
            {
                karmaIncrease *= 2.0f;
            }
            AdjustKarma(character, karmaIncrease, "Repaired item");
        }
Пример #15
0
 private void AddRepairable(Repairable item)
 {
     score    += 10;
     audioClip = item.audioClip;
     if (audioClip != null)
     {
         audioSource.Play();
     }
     repairables.Add(item);
 }
Пример #16
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        Repairable repairable = go.AddOrGet <Repairable>();

        repairable.expectedRepairTime = 52.5f;
        SolarPanel solarPanel = go.AddOrGet <SolarPanel>();

        solarPanel.powerDistributionOrder = 9;
        go.AddOrGetDef <PoweredActiveController.Def>();
    }
Пример #17
0
    public void clearTooltip(Repairable r)
    {
        //nstanitateTooltip(r);
        int iz = 0;

        foreach (int id in r.recipe.required_items)
        {
            rtp.gameObject.transform.GetChild(iz).gameObject.transform.GetChild(1).GetComponent <Image>().sprite = slotEmpty;
            iz = iz + 1;
        }
    }
Пример #18
0
    // Update is called once per frame
    void Update()
    {
        foreach (Outline o in outlines)
        {
            outlinesDict[o] = false;
        }

        RaycastHit hit;
        Ray        ray       = Camera.main.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f));
        int        layerMask = ~(1 << 8);

        repairPrompt.SetActive(false);
        damageBar.SetActive(false);

        if (Physics.Raycast(ray, out hit, 10f, layerMask))
        {
            if (hit.transform.tag == "Repairable")
            {
                Repairable r = hit.transform.gameObject.GetComponent <Repairable>();
                damageBar.SetActive(true);
                if (r.getCurrentDamage() > 0)
                {
                    repairPrompt.SetActive(true);

                    Outline o = hit.transform.GetComponent <Outline>();
                    if (!outlines.Contains(o))
                    {
                        outlines.Add(o);
                    }
                    outlinesDict[o] = true;

                    if (Input.GetKey(KeyCode.E))
                    {
                        r.repairDamage(Time.deltaTime);
                        theSoundManager.PlayRepair();
                        healthBar.localScale = new Vector3(1f - (r.getCurrentDamage() / r.getInitialDamage()), healthBar.localScale.y, healthBar.localScale.z);
                    }
                }
                else
                {
                    checkmark.SetActive(true);
                }
            }
            else
            {
                checkmark.SetActive(false);
            }
        }

        foreach (Outline o in outlines)
        {
            o.enabled = outlinesDict[o];
        }
    }
Пример #19
0
    public void populateTooltip(Repairable r)
    {
        //nstanitateTooltip(r);
        r.rd.getRecipeFromId(r.recipe_id).required_items.Sort();
        r.currentState.Sort();
        int ii = 0;

        foreach (int id in r.currentState)
        {
            rtp.gameObject.transform.GetChild(ii).gameObject.transform.GetChild(1).GetComponent <Image>().sprite = _id.getItemFromId(id).icon;
            ii = ii + 1;
        }
    }
Пример #20
0
    public void Repair(Repairable _repairable)
    {
        if (!_repairable)
        {
            return;
        }

        if (repairCoroutine != null)
        {
            StopCoroutine(repairCoroutine);
        }
        repairCoroutine = StartCoroutine(DoRepair(_repairable));
    }
Пример #21
0
 public void SetRepairItems(Repairable repairable)
 {
     currentRepairable = repairable;
     ResetItems();
     if (repairable == null)
     {
         return;
     }
     foreach (var item in repairable.repairItems)
     {
         var rep = GetRepairItem(item.resource);
         rep.weight = item.weight;
         rep.ResetItem();
     }
     SetProgressionData();
 }
Пример #22
0
 private void CheckJunctionBoxHighlights(Repairable comp1, Repairable comp2, Repairable comp3)
 {
     if (engineer_submarineJunctionBox_1.Condition > comp1.RepairThreshold && engineer_submarineJunctionBox_1.ExternalHighlight)
     {
         SetHighlight(engineer_submarineJunctionBox_1, false);
         engineer.RemoveActiveObjectiveEntity(engineer_submarineJunctionBox_1);
     }
     if (engineer_submarineJunctionBox_2.Condition > comp2.RepairThreshold && engineer_submarineJunctionBox_2.ExternalHighlight)
     {
         SetHighlight(engineer_submarineJunctionBox_2, false);
         engineer.RemoveActiveObjectiveEntity(engineer_submarineJunctionBox_2);
     }
     if (engineer_submarineJunctionBox_3.Condition > comp3.RepairThreshold && engineer_submarineJunctionBox_3.ExternalHighlight)
     {
         SetHighlight(engineer_submarineJunctionBox_3, false);
         engineer.RemoveActiveObjectiveEntity(engineer_submarineJunctionBox_3);
     }
 }
Пример #23
0
 private void CheckHighlights(Repairable comp1, Repairable comp2, Repairable comp3)
 {
     if (mechanic_ballastPump_1.Item.Condition > comp1.RepairThreshold && mechanic_ballastPump_1.Item.ExternalHighlight)
     {
         SetHighlight(mechanic_ballastPump_1.Item, false);
         mechanic.RemoveActiveObjectiveEntity(mechanic_ballastPump_1.Item);
     }
     if (mechanic_ballastPump_2.Item.Condition > comp2.RepairThreshold && mechanic_ballastPump_2.Item.ExternalHighlight)
     {
         SetHighlight(mechanic_ballastPump_2.Item, false);
         mechanic.RemoveActiveObjectiveEntity(mechanic_ballastPump_2.Item);
     }
     if (mechanic_submarineEngine.Item.Condition > comp3.RepairThreshold && mechanic_submarineEngine.Item.ExternalHighlight)
     {
         SetHighlight(mechanic_submarineEngine.Item, false);
         mechanic.RemoveActiveObjectiveEntity(mechanic_submarineEngine.Item);
     }
 }
Пример #24
0
        public Resupply(Actor self, Actor host, WDist closeEnough, bool stayOnResupplier = false)
        {
            this.host             = Target.FromActor(host);
            this.closeEnough      = closeEnough;
            this.stayOnResupplier = stayOnResupplier;
            allRepairsUnits       = host.TraitsImplementing <RepairsUnits>().ToArray();
            health                = self.TraitOrDefault <IHealth>();
            repairable            = self.TraitOrDefault <Repairable>();
            repairableNear        = self.TraitOrDefault <RepairableNear>();
            rearmable             = self.TraitOrDefault <Rearmable>();
            notifyResupplies      = host.TraitsImplementing <INotifyResupply>().ToArray();
            notifyBeingResupplied = self.TraitsImplementing <INotifyBeingResupplied>().ToArray();
            transportCallers      = self.TraitsImplementing <ICallForTransport>().ToArray();
            move            = self.Trait <IMove>();
            aircraft        = move as Aircraft;
            moveInfo        = self.Info.TraitInfo <IMoveInfo>();
            playerResources = self.Owner.PlayerActor.Trait <PlayerResources>();

            var valued = self.Info.TraitInfoOrDefault <ValuedInfo>();

            unitCost = valued != null ? valued.Cost : 0;

            var cannotRepairAtHost = health == null || health.DamageState == DamageState.Undamaged ||
                                     !allRepairsUnits.Any() ||
                                     ((repairable == null || !repairable.Info.RepairActors.Contains(host.Info.Name)) &&
                                      (repairableNear == null || !repairableNear.Info.RepairActors.Contains(host.Info.Name)));

            if (!cannotRepairAtHost)
            {
                activeResupplyTypes |= ResupplyType.Repair;

                // HACK: Reservable logic can't handle repairs, so force a take-off if resupply included repairs.
                // TODO: Make reservation logic or future docking logic properly handle this.
                wasRepaired = true;
            }

            var cannotRearmAtHost = rearmable == null || !rearmable.Info.RearmActors.Contains(host.Info.Name) || rearmable.RearmableAmmoPools.All(p => p.HasFullAmmo);

            if (!cannotRearmAtHost)
            {
                activeResupplyTypes |= ResupplyType.Rearm;
            }
        }
Пример #25
0
    private void OnTriggerEnter(Collider other)
    {
        Repairable repairable = other.GetComponent <Repairable>();

        if (repairable != null && !other.isTrigger)
        {
            colliderToPaint  = other;
            waitingCoroutine = PaintWithDelay(other, timeWaitingToPaint);
            StartCoroutine(waitingCoroutine);
            if (system1 != null)
            {
                system1.Play();
            }
            if (system2 != null)
            {
                system2.Play();
            }
        }
    }
Пример #26
0
 void Explode()
 {
     for (int x = -2; x <= 2; x++)
     {
         for (int z = -2; z <= 2; z++)
         {
             Tile tile = island.GetTileByWorldCoords(transform.position.x + x, transform.position.z + z);
             if (tile != null && tile.building != null)
             {
                 Repairable r = tile.building.GetComponent <Repairable>();
                 if (r != null)
                 {
                     r.AddHealth(Random.Range(-60, -20));
                 }
             }
         }
     }
     Instantiate(evillDead, transform.position, transform.rotation);
     Destroy(gameObject);
 }
Пример #27
0
    /**************************
     *******   REPAIR   *******
     *************************/

    private IEnumerator DoRepair(Repairable _repairable)
    {
        UIManager.I?.ActiveRepair(IsPlayerOne, new Vector2(transform.position.x, transform.position.y + 1.5f));
        UIManager.I?.SetReppairPercent(IsPlayerOne, 0);
        IsPlayable = false;

        audioSource.time = 0;
        audioSource.Play();

        bool _doRepair = true;

        OnRepairSomething += (Repairable _r) =>
        {
            if (_r == _repairable)
            {
                UIManager.I?.SetReppairPercent(IsPlayerOne, 1);
                _doRepair = false;
            }
        };

        while (_doRepair)
        {
            yield return(null);

            if (Input.GetKeyDown(IsPlayerOne ? KeyCode.Joystick1Button2 : KeyCode.Joystick2Button2) || Input.GetKeyDown(IsPlayerOne ? KeyCode.Joystick1Button1 : KeyCode.Joystick2Button1) || Input.GetKeyDown(playerInputs.IsPlayerOne ? KeyCode.Joystick1Button3 : KeyCode.Joystick2Button3) || Input.GetKeyDown(playerInputs.IsPlayerOne ? KeyCode.E : KeyCode.RightShift) || Input.GetKeyDown(playerInputs.IsPlayerOne ? KeyCode.F : KeyCode.Return))
            {
                if (_repairable.Repair(this))
                {
                    break;
                }
            }
        }

        OnRepairSomething?.Invoke(_repairable);
        audioSource.Stop();

        IsPlayable      = true;
        repairCoroutine = null;
    }
Пример #28
0
    public void TargetToAction(Transform target)
    {
        animator.SetBool("action", false);
        taskBatch = null;

        if (GeneratePathToTarget(target.position))
        {
            if (target.GetComponent <Collectable>())
            {
                Collectable          collectable = target.GetComponent <Collectable>();
                TaskCollectResources taskCollect = new TaskCollectResources(collectable);
                AddTask(taskCollect);
            }
            else if (target.name == "Charge Station")
            {
            }
            else if (target.GetComponent <Repairable>())
            {
                Repairable repairable = target.GetComponent <Repairable>();
                AddTask(new TaskRepair(repairable));
            }
        }
    }
Пример #29
0
        public override IEnumerable <object> UpdateState()
        {
            while (GameMain.Instance.LoadingScreenOpen)
            {
                yield return(null);
            }

            // Room 1
            SoundPlayer.PlayDamageSound("StructureBlunt", 10, Character.Controlled.WorldPosition);
            while (shakeTimer > 0.0f) // Wake up, shake
            {
                shakeTimer -= 0.1f;
                GameMain.GameScreen.Cam.Shake = shakeAmount;
                yield return(new WaitForSeconds(0.1f, false));
            }

            //// Remove
            //for (int i = 0; i < engineer_disconnectedJunctionBoxes.Length; i++)
            //{
            //    SetHighlight(engineer_disconnectedJunctionBoxes[i].Item, true);
            //}
            //do { CheckGhostWires(); HandleJunctionBoxWiringHighlights(); yield return null; } while (engineer_workingPump.Voltage < engineer_workingPump.MinVoltage); // Wait until connected all the way to the pump
            //CheckGhostWires();
            //// Remove

            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.WakeUp"), ChatMessageType.Radio, null);
            SetHighlight(engineer_equipmentCabinet.Item, true);

            // Room 2
            do
            {
                yield return(null);
            } while (!engineer_equipmentObjectiveSensor.MotionDetected);
            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.Equipment"), ChatMessageType.Radio, null);
            yield return(new WaitForSeconds(0.5f, false));

            TriggerTutorialSegment(0, GameMain.Config.KeyBind(InputType.Select), GameMain.Config.KeyBind(InputType.Deselect)); // Retrieve equipment
            bool firstSlotRemoved  = false;
            bool secondSlotRemoved = false;
            bool thirdSlotRemoved  = false;
            bool fourthSlotRemoved = false;

            do
            {
                if (IsSelectedItem(engineer_equipmentCabinet.Item))
                {
                    if (!firstSlotRemoved)
                    {
                        HighlightInventorySlot(engineer_equipmentCabinet.Inventory, 0, highlightColor, .5f, .5f, 0f);
                        if (engineer_equipmentCabinet.Inventory.Items[0] == null)
                        {
                            firstSlotRemoved = true;
                        }
                    }

                    if (!secondSlotRemoved)
                    {
                        HighlightInventorySlot(engineer_equipmentCabinet.Inventory, 1, highlightColor, .5f, .5f, 0f);
                        if (engineer_equipmentCabinet.Inventory.Items[1] == null)
                        {
                            secondSlotRemoved = true;
                        }
                    }

                    if (!thirdSlotRemoved)
                    {
                        HighlightInventorySlot(engineer_equipmentCabinet.Inventory, 2, highlightColor, .5f, .5f, 0f);
                        if (engineer_equipmentCabinet.Inventory.Items[2] == null)
                        {
                            thirdSlotRemoved = true;
                        }
                    }

                    if (!fourthSlotRemoved)
                    {
                        HighlightInventorySlot(engineer_equipmentCabinet.Inventory, 3, highlightColor, .5f, .5f, 0f);
                        if (engineer_equipmentCabinet.Inventory.Items[2] == null)
                        {
                            fourthSlotRemoved = true;
                        }
                    }

                    for (int i = 0; i < engineer.Inventory.slots.Length; i++)
                    {
                        if (engineer.Inventory.Items[i] == null)
                        {
                            HighlightInventorySlot(engineer.Inventory, i, highlightColor, .5f, .5f, 0f);
                        }
                    }
                }

                yield return(null);
            } while (!engineer_equipmentCabinet.Inventory.IsEmpty()); // Wait until looted
            RemoveCompletedObjective(segments[0]);
            SetHighlight(engineer_equipmentCabinet.Item, false);
            SetHighlight(engineer_reactor.Item, true);
            SetDoorAccess(engineer_firstDoor, engineer_firstDoorLight, true);

            // Room 3
            do
            {
                yield return(null);
            } while (!IsSelectedItem(engineer_reactor.Item));
            yield return(new WaitForSeconds(0.5f, false));

            TriggerTutorialSegment(1);
            do
            {
                if (IsSelectedItem(engineer_reactor.Item))
                {
                    engineer_reactor.AutoTempSlider.BarScrollValue = 1.0f;
                    if (engineer_reactor.OnOffSwitch.FlashTimer <= 0)
                    {
                        engineer_reactor.OnOffSwitch.Flash(highlightColor, 1.5f, false);
                    }
                }
                yield return(null);
            } while (engineer_reactor.OnOffSwitch.BarScroll > 0.45f);
            do
            {
                if (IsSelectedItem(engineer_reactor.Item) && engineer_reactor.Item.OwnInventory.slots != null)
                {
                    engineer_reactor.AutoTempSlider.BarScrollValue = 1.0f;
                    HighlightInventorySlot(engineer.Inventory, "fuelrod", highlightColor, 0.5f, 0.5f, 0f);

                    for (int i = 0; i < engineer_reactor.Item.OwnInventory.slots.Length; i++)
                    {
                        HighlightInventorySlot(engineer_reactor.Item.OwnInventory, i, highlightColor, 0.5f, 0.5f, 0f);
                    }
                }
                yield return(null);
            } while (engineer_reactor.AvailableFuel == 0);
            CoroutineManager.StartCoroutine(ReactorOperatedProperly());
            do
            {
                if (IsSelectedItem(engineer_reactor.Item))
                {
                    engineer_reactor.AutoTempSlider.BarScrollValue = 1.0f;
                    if (engineer_reactor.FissionRateScrollBar.FlashTimer <= 0)
                    {
                        engineer_reactor.FissionRateScrollBar.Flash(highlightColor, 1.5f);
                    }

                    if (engineer_reactor.TurbineOutputScrollBar.FlashTimer <= 0)
                    {
                        engineer_reactor.TurbineOutputScrollBar.Flash(highlightColor, 1.5f);
                    }
                }
                yield return(null);
            } while (!reactorOperatedProperly);
            yield return(new WaitForSeconds(2f, false));

            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.ReactorStable"), ChatMessageType.Radio, null);
            do
            {
                if (IsSelectedItem(engineer_reactor.Item))
                {
                    if (engineer_reactor.AutoTempSlider.FlashTimer <= 0)
                    {
                        engineer_reactor.AutoTempSlider.Flash(highlightColor, 1.5f, false, new Vector2(10, 10));
                    }
                }
                yield return(null);
            } while (!engineer_reactor.AutoTemp);

            float wait = 1.5f;

            do
            {
                yield return(new WaitForSeconds(0.1f, false));

                wait -= 0.1f;
                engineer_reactor.AutoTempSlider.BarScrollValue = 0.0f;
            } while (wait > 0.0f);
            engineer.SelectedConstruction  = null;
            engineer_reactor.CanBeSelected = false;
            RemoveCompletedObjective(segments[1]);
            SetHighlight(engineer_reactor.Item, false);
            SetHighlight(engineer_brokenJunctionBox, true);
            SetDoorAccess(engineer_secondDoor, engineer_secondDoorLight, true);

            // Room 4
            do
            {
                yield return(null);
            } while (!engineer_secondDoor.IsOpen);
            yield return(new WaitForSeconds(1f, false));

            Repairable repairableJunctionBoxComponent = engineer_brokenJunctionBox.GetComponent <Repairable>();

            TriggerTutorialSegment(2, GameMain.Config.KeyBind(InputType.Select)); // Repair the junction box
            do
            {
                if (!engineer.HasEquippedItem("screwdriver"))
                {
                    HighlightInventorySlot(engineer.Inventory, "screwdriver", highlightColor, .5f, .5f, 0f);
                }
                else if (IsSelectedItem(engineer_brokenJunctionBox) && repairableJunctionBoxComponent.CurrentFixer == null)
                {
                    if (repairableJunctionBoxComponent.RepairButton.Frame.FlashTimer <= 0)
                    {
                        repairableJunctionBoxComponent.RepairButton.Frame.Flash();
                    }
                }
                yield return(null);
            } while (!engineer_brokenJunctionBox.IsFullCondition); // Wait until repaired
            SetHighlight(engineer_brokenJunctionBox, false);
            RemoveCompletedObjective(segments[2]);
            SetDoorAccess(engineer_thirdDoor, engineer_thirdDoorLight, true);
            for (int i = 0; i < engineer_disconnectedJunctionBoxes.Length; i++)
            {
                SetHighlight(engineer_disconnectedJunctionBoxes[i].Item, true);
            }

            // Room 5
            do
            {
                yield return(null);
            } while (!engineer_thirdDoor.IsOpen);
            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.FaultyWiring"), ChatMessageType.Radio, null);
            yield return(new WaitForSeconds(2f, false));

            TriggerTutorialSegment(3, GameMain.Config.KeyBind(InputType.Use), GameMain.Config.KeyBind(InputType.Deselect)); // Connect the junction boxes
            do
            {
                CheckGhostWires(); HandleJunctionBoxWiringHighlights(); yield return(null);
            } while (engineer_workingPump.Voltage < engineer_workingPump.MinVoltage);                                                                                 // Wait until connected all the way to the pump
            CheckGhostWires();
            for (int i = 0; i < engineer_disconnectedJunctionBoxes.Length; i++)
            {
                SetHighlight(engineer_disconnectedJunctionBoxes[i].Item, false);
            }
            RemoveCompletedObjective(segments[3]);
            do
            {
                yield return(null);
            } while (engineer_workingPump.Item.CurrentHull.WaterPercentage > waterVolumeBeforeOpening);                         // Wait until drained
            wiringActive = false;
            SetDoorAccess(engineer_fourthDoor, engineer_fourthDoorLight, true);
            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.ChangeOfPlans"), ChatMessageType.Radio, null);

            // Submarine
            do
            {
                yield return(null);
            } while (!tutorial_enteredSubmarineSensor.MotionDetected);
            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.Submarine"), ChatMessageType.Radio, null);
            yield return(new WaitForSeconds(2f, false));

            TriggerTutorialSegment(4); // Repair junction box
            while (ContentRunning)
            {
                yield return(null);
            }
            SetHighlight(engineer_submarineJunctionBox_1, true);
            SetHighlight(engineer_submarineJunctionBox_2, true);
            SetHighlight(engineer_submarineJunctionBox_3, true);
            engineer.AddActiveObjectiveEntity(engineer_submarineJunctionBox_1, engineer_repairIcon, engineer_repairIconColor);
            engineer.AddActiveObjectiveEntity(engineer_submarineJunctionBox_2, engineer_repairIcon, engineer_repairIconColor);
            engineer.AddActiveObjectiveEntity(engineer_submarineJunctionBox_3, engineer_repairIcon, engineer_repairIconColor);
            // Remove highlights when each individual machine is repaired
            do
            {
                CheckJunctionBoxHighlights(); yield return(null);
            } while (!engineer_submarineJunctionBox_1.IsFullCondition || !engineer_submarineJunctionBox_2.IsFullCondition || !engineer_submarineJunctionBox_3.IsFullCondition);
            CheckJunctionBoxHighlights();
            RemoveCompletedObjective(segments[4]);
            yield return(new WaitForSeconds(2f, false));

            TriggerTutorialSegment(5); // Powerup reactor
            SetHighlight(engineer_submarineReactor.Item, true);
            engineer.AddActiveObjectiveEntity(engineer_submarineReactor.Item, engineer_reactorIcon, engineer_reactorIconColor);
            do
            {
                yield return(null);
            } while (!IsReactorPoweredUp(engineer_submarineReactor));                         // Wait until ~matches load
            engineer.RemoveActiveObjectiveEntity(engineer_submarineReactor.Item);
            SetHighlight(engineer_submarineReactor.Item, false);
            RemoveCompletedObjective(segments[5]);
            GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Engineer.Radio.Complete"), ChatMessageType.Radio, null);

            yield return(new WaitForSeconds(4f, false));

            CoroutineManager.StartCoroutine(TutorialCompleted());
        }
Пример #30
0
        public override IEnumerable <object> UpdateState()
        {
            while (GameMain.Instance.LoadingScreenOpen)
            {
                yield return(null);
            }

            // Room 1
            SoundPlayer.PlayDamageSound("StructureBlunt", 10, Character.Controlled.WorldPosition);
            while (shakeTimer > 0.0f) // Wake up, shake
            {
                shakeTimer -= 0.1f;
                GameMain.GameScreen.Cam.Shake = shakeAmount;
                yield return(new WaitForSeconds(0.1f, false));
            }
            yield return(new WaitForSeconds(2.5f, false));

            mechanic_fabricator.RemoveFabricationRecipes(new List <string>()
            {
                "extinguisher", "wrench", "weldingtool", "weldingfuel", "divingmask", "railgunshell", "nuclearshell", "uex", "harpoongun"
            });
            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.WakeUp"), ChatMessageType.Radio, null);

            yield return(new WaitForSeconds(2.5f, false));

            TriggerTutorialSegment(0, GameMain.Config.KeyBindText(InputType.Up), GameMain.Config.KeyBindText(InputType.Left), GameMain.Config.KeyBindText(InputType.Down), GameMain.Config.KeyBindText(InputType.Right), GameMain.Config.KeyBindText(InputType.Select), GameMain.Config.KeyBindText(InputType.Select)); // Open door objective
            yield return(new WaitForSeconds(0.0f, false));

            SetDoorAccess(mechanic_firstDoor, mechanic_firstDoorLight, true);
            SetHighlight(mechanic_firstDoor.Item, true);
            do
            {
                yield return(null);
            } while (!mechanic_firstDoor.IsOpen);
            SetHighlight(mechanic_firstDoor.Item, false);
            yield return(new WaitForSeconds(1.5f, false));

            RemoveCompletedObjective(segments[0]);

            // Room 2
            yield return(new WaitForSeconds(0.0f, false));

            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Equipment"), ChatMessageType.Radio, null);
            do
            {
                yield return(null);
            } while (!mechanic_equipmentObjectiveSensor.MotionDetected);
            TriggerTutorialSegment(1, GameMain.Config.KeyBindText(InputType.Select), GameMain.Config.KeyBindText(InputType.Deselect), GameMain.Config.KeyBindText(InputType.ToggleInventory)); // Equipment & inventory objective
            SetHighlight(mechanic_equipmentCabinet.Item, true);
            bool firstSlotRemoved  = false;
            bool secondSlotRemoved = false;
            bool thirdSlotRemoved  = false;

            do
            {
                if (IsSelectedItem(mechanic_equipmentCabinet.Item))
                {
                    if (!firstSlotRemoved)
                    {
                        HighlightInventorySlot(mechanic_equipmentCabinet.Inventory, 0, highlightColor, .5f, .5f, 0f);
                        if (mechanic_equipmentCabinet.Inventory.Items[0] == null)
                        {
                            firstSlotRemoved = true;
                        }
                    }

                    if (!secondSlotRemoved)
                    {
                        HighlightInventorySlot(mechanic_equipmentCabinet.Inventory, 1, highlightColor, .5f, .5f, 0f);
                        if (mechanic_equipmentCabinet.Inventory.Items[1] == null)
                        {
                            secondSlotRemoved = true;
                        }
                    }

                    if (!thirdSlotRemoved)
                    {
                        HighlightInventorySlot(mechanic_equipmentCabinet.Inventory, 2, highlightColor, .5f, .5f, 0f);
                        if (mechanic_equipmentCabinet.Inventory.Items[2] == null)
                        {
                            thirdSlotRemoved = true;
                        }
                    }

                    for (int i = 0; i < mechanic.Inventory.slots.Length; i++)
                    {
                        if (mechanic.Inventory.Items[i] == null)
                        {
                            HighlightInventorySlot(mechanic.Inventory, i, highlightColor, .5f, .5f, 0f);
                        }
                    }
                }

                yield return(null);
            } while (mechanic.Inventory.FindItemByIdentifier("divingmask") == null || mechanic.Inventory.FindItemByIdentifier("weldingtool") == null || mechanic.Inventory.FindItemByIdentifier("wrench") == null); // Wait until looted
            SetHighlight(mechanic_equipmentCabinet.Item, false);
            yield return(new WaitForSeconds(1.5f, false));

            RemoveCompletedObjective(segments[1]);
            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Breach"), ChatMessageType.Radio, null);

            // Room 3
            do
            {
                yield return(null);
            } while (!mechanic_weldingObjectiveSensor.MotionDetected);
            TriggerTutorialSegment(2, GameMain.Config.KeyBindText(InputType.Aim), GameMain.Config.KeyBindText(InputType.Shoot), GameMain.Config.KeyBindText(InputType.ToggleInventory)); // Welding objective
            do
            {
                if (!mechanic.HasEquippedItem("divingmask"))
                {
                    HighlightInventorySlot(mechanic.Inventory, "divingmask", highlightColor, .5f, .5f, 0f);
                }

                if (!mechanic.HasEquippedItem("weldingtool"))
                {
                    HighlightInventorySlot(mechanic.Inventory, "weldingtool", highlightColor, .5f, .5f, 0f);
                }
                yield return(null);
            } while (!mechanic.HasEquippedItem("divingmask") || !mechanic.HasEquippedItem("weldingtool")); // Wait until equipped
            SetDoorAccess(mechanic_secondDoor, mechanic_secondDoorLight, true);
            mechanic.AddActiveObjectiveEntity(mechanic_brokenWall_1, mechanic_weldIcon, mechanic_repairIconColor);
            do
            {
                yield return(null);
            } while (WallHasDamagedSections(mechanic_brokenWall_1));                         // Highlight until repaired
            mechanic.RemoveActiveObjectiveEntity(mechanic_brokenWall_1);
            RemoveCompletedObjective(segments[2]);
            yield return(new WaitForSeconds(1f, false));

            TriggerTutorialSegment(3, GameMain.Config.KeyBindText(InputType.Select)); // Pump objective
            SetHighlight(mechanic_workingPump.Item, true);
            do
            {
                yield return(null);

                if (IsSelectedItem(mechanic_workingPump.Item))
                {
                    if (mechanic_workingPump.PowerButton.FlashTimer <= 0)
                    {
                        mechanic_workingPump.PowerButton.Flash(uiHighlightColor, 1.5f, true);
                    }
                }
            } while (mechanic_workingPump.FlowPercentage >= 0 || !mechanic_workingPump.IsActive); // Highlight until draining
            SetHighlight(mechanic_workingPump.Item, false);
            do
            {
                yield return(null);
            } while (mechanic_brokenhull_1.WaterPercentage > waterVolumeBeforeOpening);                         // Unlock door once drained
            RemoveCompletedObjective(segments[3]);
            SetDoorAccess(mechanic_thirdDoor, mechanic_thirdDoorLight, true);
            //TriggerTutorialSegment(11, GameMain.Config.KeyBind(InputType.Select), GameMain.Config.KeyBind(InputType.Up), GameMain.Config.KeyBind(InputType.Down), GameMain.Config.KeyBind(InputType.Select)); // Ladder objective
            //do { yield return null; } while (!mechanic_ladderSensor.MotionDetected);
            //RemoveCompletedObjective(segments[11]);
            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.News"), ChatMessageType.Radio, null);
            yield return(new WaitForSeconds(1f, false));

            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Fire"), ChatMessageType.Radio, null);

            // Room 4
            do
            {
                yield return(null);
            } while (!mechanic_thirdDoor.IsOpen);
            yield return(new WaitForSeconds(1f, false));

            mechanic_fire = new DummyFireSource(new Vector2(20f, 2f), Item.ItemList.Find(i => i.HasTag("mechanic_fire")).WorldPosition);
            //do { yield return null; } while (!mechanic_craftingObjectiveSensor.MotionDetected);
            TriggerTutorialSegment(4); // Deconstruct

            SetHighlight(mechanic_craftingCabinet.Item, true);

            bool gotOxygenTank = false;
            bool gotSodium     = false;

            do
            {
                if (mechanic.SelectedConstruction == mechanic_craftingCabinet.Item)
                {
                    for (int i = 0; i < mechanic.Inventory.slots.Length; i++)
                    {
                        if (mechanic.Inventory.Items[i] == null)
                        {
                            HighlightInventorySlot(mechanic.Inventory, i, highlightColor, .5f, .5f, 0f);
                        }
                    }

                    if (mechanic.Inventory.FindItemByIdentifier("oxygentank") == null && mechanic.Inventory.FindItemByIdentifier("aluminium") == null)
                    {
                        for (int i = 0; i < mechanic_craftingCabinet.Inventory.Items.Length; i++)
                        {
                            Item item = mechanic_craftingCabinet.Inventory.Items[i];
                            if (item != null && item.prefab.Identifier == "oxygentank")
                            {
                                HighlightInventorySlot(mechanic_craftingCabinet.Inventory, i, highlightColor, .5f, .5f, 0f);
                            }
                        }
                    }

                    if (mechanic.Inventory.FindItemByIdentifier("sodium") == null)
                    {
                        for (int i = 0; i < mechanic_craftingCabinet.Inventory.Items.Length; i++)
                        {
                            Item item = mechanic_craftingCabinet.Inventory.Items[i];
                            if (item != null && item.prefab.Identifier == "sodium")
                            {
                                HighlightInventorySlot(mechanic_craftingCabinet.Inventory, i, highlightColor, .5f, .5f, 0f);
                            }
                        }
                    }
                }

                if (!gotOxygenTank && (mechanic.Inventory.FindItemByIdentifier("oxygentank") != null ||
                                       mechanic_deconstructor.InputContainer.Inventory.FindItemByIdentifier("oxygentank") != null))
                {
                    gotOxygenTank = true;
                }
                if (!gotSodium && mechanic.Inventory.FindItemByIdentifier("sodium") != null)
                {
                    gotSodium = true;
                }
                yield return(null);
            } while (!gotOxygenTank || !gotSodium); // Wait until looted

            yield return(new WaitForSeconds(1.0f, false));

            SetHighlight(mechanic_craftingCabinet.Item, false);
            SetHighlight(mechanic_deconstructor.Item, true);
            do
            {
                if (IsSelectedItem(mechanic_deconstructor.Item))
                {
                    if (mechanic_deconstructor.OutputContainer.Inventory.FindItemByIdentifier("aluminium") != null)
                    {
                        HighlightInventorySlot(mechanic_deconstructor.OutputContainer.Inventory, "aluminium", highlightColor, .5f, .5f, 0f);

                        for (int i = 0; i < mechanic.Inventory.slots.Length; i++)
                        {
                            if (mechanic.Inventory.Items[i] == null)
                            {
                                HighlightInventorySlot(mechanic.Inventory, i, highlightColor, .5f, .5f, 0f);
                            }
                        }
                    }
                    else
                    {
                        if (mechanic.Inventory.FindItemByIdentifier("oxygentank") != null && mechanic_deconstructor.InputContainer.Inventory.FindItemByIdentifier("oxygentank") == null)
                        {
                            HighlightInventorySlot(mechanic.Inventory, "oxygentank", highlightColor, .5f, .5f, 0f);

                            if (mechanic_deconstructor.InputContainer.Inventory.slots != null)
                            {
                                for (int i = 0; i < mechanic_deconstructor.InputContainer.Inventory.slots.Length; i++)
                                {
                                    HighlightInventorySlot(mechanic_deconstructor.InputContainer.Inventory, i, highlightColor, .5f, .5f, 0f);
                                }
                            }
                        }

                        if (mechanic_deconstructor.InputContainer.Inventory.FindItemByIdentifier("oxygentank") != null && !mechanic_deconstructor.IsActive)
                        {
                            if (mechanic_deconstructor.ActivateButton.FlashTimer <= 0)
                            {
                                mechanic_deconstructor.ActivateButton.Flash(highlightColor, 1.5f, false);
                            }
                        }
                    }
                }
                yield return(null);
            } while (
                mechanic.Inventory.FindItemByIdentifier("aluminium") == null &&
                mechanic_fabricator.InputContainer.Inventory.FindItemByIdentifier("aluminium") == null); // Wait until aluminium obtained

            SetHighlight(mechanic_deconstructor.Item, false);
            RemoveCompletedObjective(segments[4]);
            yield return(new WaitForSeconds(1f, false));

            TriggerTutorialSegment(5); // Fabricate
            SetHighlight(mechanic_fabricator.Item, true);
            do
            {
                if (IsSelectedItem(mechanic_fabricator.Item))
                {
                    if (mechanic_fabricator.SelectedItem?.TargetItem.Identifier != "extinguisher")
                    {
                        mechanic_fabricator.HighlightRecipe("extinguisher", highlightColor);
                    }
                    else
                    {
                        if (mechanic_fabricator.OutputContainer.Inventory.FindItemByIdentifier("extinguisher") != null)
                        {
                            HighlightInventorySlot(mechanic_fabricator.OutputContainer.Inventory, "extinguisher", highlightColor, .5f, .5f, 0f);

                            /*for (int i = 0; i < mechanic.Inventory.slots.Length; i++)
                             * {
                             *  if (mechanic.Inventory.Items[i] == null) HighlightInventorySlot(mechanic.Inventory, i, highlightColor, .5f, .5f, 0f);
                             * }*/
                        }
                        else if (mechanic_fabricator.InputContainer.Inventory.FindItemByIdentifier("aluminium") != null && mechanic_fabricator.InputContainer.Inventory.FindItemByIdentifier("sodium") != null && !mechanic_fabricator.IsActive)
                        {
                            if (mechanic_fabricator.ActivateButton.FlashTimer <= 0)
                            {
                                mechanic_fabricator.ActivateButton.Flash(highlightColor, 1.5f, false);
                            }
                        }
                        else if (mechanic.Inventory.FindItemByIdentifier("aluminium") != null || mechanic.Inventory.FindItemByIdentifier("sodium") != null)
                        {
                            HighlightInventorySlot(mechanic.Inventory, "aluminium", highlightColor, .5f, .5f, 0f);
                            HighlightInventorySlot(mechanic.Inventory, "sodium", highlightColor, .5f, .5f, 0f);

                            if (mechanic_fabricator.InputContainer.Inventory.Items[0] == null)
                            {
                                HighlightInventorySlot(mechanic_fabricator.InputContainer.Inventory, 0, highlightColor, .5f, .5f, 0f);
                            }

                            if (mechanic_fabricator.InputContainer.Inventory.Items[1] == null)
                            {
                                HighlightInventorySlot(mechanic_fabricator.InputContainer.Inventory, 1, highlightColor, .5f, .5f, 0f);
                            }
                        }
                    }
                }
                yield return(null);
            } while (mechanic.Inventory.FindItemByIdentifier("extinguisher") == null); // Wait until extinguisher is created
            RemoveCompletedObjective(segments[5]);
            SetHighlight(mechanic_fabricator.Item, false);
            SetDoorAccess(mechanic_fourthDoor, mechanic_fourthDoorLight, true);

            // Room 5
            do
            {
                yield return(null);
            } while (!mechanic_fireSensor.MotionDetected);
            TriggerTutorialSegment(6, GameMain.Config.KeyBindText(InputType.Aim), GameMain.Config.KeyBindText(InputType.Shoot)); // Using the extinguisher
            do
            {
                yield return(null);
            } while (!mechanic_fire.Removed);                         // Wait until extinguished
            yield return(new WaitForSeconds(3f, false));

            RemoveCompletedObjective(segments[6]);

            if (mechanic.HasEquippedItem("extinguisher")) // do not trigger if dropped already
            {
                TriggerTutorialSegment(7);
                do
                {
                    HighlightInventorySlot(mechanic.Inventory, "extinguisher", highlightColor, 0.5f, 0.5f, 0f);
                    yield return(null);
                } while (mechanic.HasEquippedItem("extinguisher"));
                RemoveCompletedObjective(segments[7]);
            }
            SetDoorAccess(mechanic_fifthDoor, mechanic_fifthDoorLight, true);

            // Room 6
            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Diving"), ChatMessageType.Radio, null);
            do
            {
                yield return(null);
            } while (!mechanic_divingSuitObjectiveSensor.MotionDetected);
            TriggerTutorialSegment(8); // Dangers of pressure, equip diving suit objective
            SetHighlight(mechanic_divingSuitContainer.Item, true);
            do
            {
                if (IsSelectedItem(mechanic_divingSuitContainer.Item))
                {
                    if (mechanic_divingSuitContainer.Inventory.slots != null)
                    {
                        for (int i = 0; i < mechanic_divingSuitContainer.Inventory.slots.Length; i++)
                        {
                            HighlightInventorySlot(mechanic_divingSuitContainer.Inventory, i, highlightColor, 0.5f, 0.5f, 0f);
                        }
                    }
                }
                yield return(null);
            } while (!mechanic.HasEquippedItem("divingsuit"));
            SetHighlight(mechanic_divingSuitContainer.Item, false);
            RemoveCompletedObjective(segments[8]);
            SetDoorAccess(tutorial_mechanicFinalDoor, tutorial_mechanicFinalDoorLight, true);

            // Room 7
            mechanic.AddActiveObjectiveEntity(mechanic_brokenWall_2, mechanic_weldIcon, mechanic_repairIconColor);
            do
            {
                yield return(null);
            } while (WallHasDamagedSections(mechanic_brokenWall_2));
            mechanic.RemoveActiveObjectiveEntity(mechanic_brokenWall_2);
            yield return(new WaitForSeconds(2f, false));

            TriggerTutorialSegment(9, GameMain.Config.KeyBindText(InputType.Use)); // Repairing machinery (pump)
            SetHighlight(mechanic_brokenPump.Item, true);
            mechanic_brokenPump.CanBeSelected = true;
            Repairable repairablePumpComponent = mechanic_brokenPump.Item.GetComponent <Repairable>();

            repairablePumpComponent.CanBeSelected = true;
            do
            {
                yield return(null);

                if (mechanic_brokenPump.Item.Condition < repairablePumpComponent.RepairThreshold)
                {
                    if (!mechanic.HasEquippedItem("wrench"))
                    {
                        HighlightInventorySlot(mechanic.Inventory, "wrench", highlightColor, 0.5f, 0.5f, 0f);
                    }
                    else if (IsSelectedItem(mechanic_brokenPump.Item) && repairablePumpComponent.CurrentFixer == null)
                    {
                        if (repairablePumpComponent.RepairButton.FlashTimer <= 0)
                        {
                            repairablePumpComponent.RepairButton.Flash();
                        }
                    }
                }
                else
                {
                    if (IsSelectedItem(mechanic_brokenPump.Item))
                    {
                        if (mechanic_brokenPump.PowerButton.FlashTimer <= 0)
                        {
                            mechanic_brokenPump.PowerButton.Flash(uiHighlightColor, 1.5f, true);
                        }
                    }
                }
            } while (mechanic_brokenPump.Item.Condition < repairablePumpComponent.RepairThreshold || mechanic_brokenPump.FlowPercentage >= 0 || !mechanic_brokenPump.IsActive);
            RemoveCompletedObjective(segments[9]);
            SetHighlight(mechanic_brokenPump.Item, false);
            do
            {
                yield return(null);
            } while (mechanic_brokenhull_2.WaterPercentage > waterVolumeBeforeOpening);
            SetDoorAccess(tutorial_submarineDoor, tutorial_submarineDoorLight, true);

            // Submarine
            do
            {
                yield return(null);
            } while (!tutorial_enteredSubmarineSensor.MotionDetected);
            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Submarine"), ChatMessageType.Radio, null);
            TriggerTutorialSegment(10); // Repairing ballast pumps, engine
            while (ContentRunning)
            {
                yield return(null);
            }
            mechanic.AddActiveObjectiveEntity(mechanic_ballastPump_1.Item, mechanic_repairIcon, mechanic_repairIconColor);
            mechanic.AddActiveObjectiveEntity(mechanic_ballastPump_2.Item, mechanic_repairIcon, mechanic_repairIconColor);
            mechanic.AddActiveObjectiveEntity(mechanic_submarineEngine.Item, mechanic_repairIcon, mechanic_repairIconColor);
            SetHighlight(mechanic_ballastPump_1.Item, true);
            SetHighlight(mechanic_ballastPump_2.Item, true);
            SetHighlight(mechanic_submarineEngine.Item, true);

            Repairable repairablePumpComponent1  = mechanic_ballastPump_1.Item.GetComponent <Repairable>();
            Repairable repairablePumpComponent2  = mechanic_ballastPump_2.Item.GetComponent <Repairable>();
            Repairable repairableEngineComponent = mechanic_submarineEngine.Item.GetComponent <Repairable>();

            // Remove highlights when each individual machine is repaired
            do
            {
                CheckHighlights(repairablePumpComponent1, repairablePumpComponent2, repairableEngineComponent); yield return(null);
            } while (mechanic_ballastPump_1.Item.Condition < repairablePumpComponent1.RepairThreshold || mechanic_ballastPump_2.Item.Condition < repairablePumpComponent2.RepairThreshold || mechanic_submarineEngine.Item.Condition < repairableEngineComponent.RepairThreshold);
            CheckHighlights(repairablePumpComponent1, repairablePumpComponent2, repairableEngineComponent);
            RemoveCompletedObjective(segments[10]);
            GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Complete"), ChatMessageType.Radio, null);

            // END TUTORIAL
            CoroutineManager.StartCoroutine(TutorialCompleted());
        }