private void RefreshDepth()
        {
            int depth = GetDepthAvailable(gameObject, out bool waterFound);

            if (depth != previousDepth || waterFound != previousWaterFound)
            {
                if (depth <= 0)
                {
                    line.SetVisiblity(false);
                    hook?.SetVisiblity(false);
                }
                else
                {
                    line.SetVisiblity(true);
                    line.Play(lineAnim + depth, playMode);
                    hook?.SetVisiblity(true);
                }
                if (type != GuideType.Preview)
                {
                    // todo: пока выключил резервацию тайлов. тк создает неопределенное поведение,
                    // если сделать работу в разных типах комнатах для совместимости с "роом эхпандед"
                    // надо подумать
#if false
                    OccupyArea(depth);
#endif
                    if (kSelectable != null)
                    {
                        kSelectable.ToggleStatusItem(statusItemNoDepth, depth <= 0);
                        kSelectable.ToggleStatusItem(statusItemNoWater, depth > 0 && !waterFound);
                    }
                }
                previousDepth      = depth;
                previousWaterFound = waterFound;
            }
        }
    private void UpdateConnectionState(bool force_update = false)
    {
        connected = IsConnected(utilityCell);
        if (connected != previouslyConnected || force_update)
        {
            operational.SetFlag(outputConnectedFlag, connected);
            previouslyConnected = connected;
            StatusItem status_item = null;
            switch (conduitType)
            {
            case ConduitType.Liquid:
                status_item = Db.Get().BuildingStatusItems.NeedLiquidOut;
                break;

            case ConduitType.Gas:
                status_item = Db.Get().BuildingStatusItems.NeedGasOut;
                break;

            case ConduitType.Solid:
                status_item = Db.Get().BuildingStatusItems.NeedSolidOut;
                break;
            }
            hasPipeGuid = selectable.ToggleStatusItem(status_item, hasPipeGuid, !connected, this);
        }
    }
        private void OnLiquidConduitUpdate(float dt)
        {
            var flow = Game.Instance.liquidConduitFlow;

            liquidWastePipeBlocked = flow.HasConduit(liquidWasteOutputCell) && flow.GetContents(liquidWasteOutputCell).mass > 0f;
            liquidWastePipeBlockedStatusItemGuid = selectable.ToggleStatusItem(liquidWastePipeBlockedStatusItem, liquidWastePipeBlockedStatusItemGuid, liquidWastePipeBlocked);
        }
示例#4
0
    private void UpdateConduitExistsStatus()
    {
        bool       flag = RequireOutputs.IsConnected(filteredCell, portInfo.conduitType);
        StatusItem status_item;

        switch (portInfo.conduitType)
        {
        case ConduitType.Gas:
            status_item = Db.Get().BuildingStatusItems.NeedGasOut;
            break;

        case ConduitType.Liquid:
            status_item = Db.Get().BuildingStatusItems.NeedLiquidOut;
            break;

        case ConduitType.Solid:
            status_item = Db.Get().BuildingStatusItems.NeedSolidOut;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
        bool flag2 = needsConduitStatusItemGuid != Guid.Empty;

        if (flag == flag2)
        {
            needsConduitStatusItemGuid = selectable.ToggleStatusItem(status_item, needsConduitStatusItemGuid, !flag, null);
        }
    }
示例#5
0
        private void CheckRequirements(bool forceEvent)
        {
            bool connected = !conduitInput.enabled || conduitInput.IsConnected;

            if (connected != previouslyConnected)
            {
                previouslyConnected = connected;

                StatusItem statusItem = null;
                switch (conduitInput.TypeOfConduit)
                {
                case ConduitType.Liquid:
                    statusItem = Db.Get().BuildingStatusItems.NeedLiquidIn;
                    break;

                case ConduitType.Gas:
                    statusItem = Db.Get().BuildingStatusItems.NeedGasIn;
                    break;
                }

                if (statusItem != null)
                {
                    inputConnectedStatusItem = selectable.ToggleStatusItem(statusItem, inputConnectedStatusItem, !connected, new Tuple <ConduitType, Tag>(conduitInput.TypeOfConduit, conduitInput.capacityTag));
                }

                operational.SetFlag(inputConnectedFlag, connected);
            }

            bool satisfied = !conduitInput.enabled || conduitInput.IsSatisfied;

            if (previouslySatisfied != satisfied)
            {
                previouslySatisfied = satisfied;

                if (requireConduitHasMass)
                {
                    StatusItem statusItem = null;
                    switch (conduitInput.TypeOfConduit)
                    {
                    case ConduitType.Liquid:
                        statusItem = Db.Get().BuildingStatusItems.LiquidPipeEmpty;
                        break;

                    case ConduitType.Gas:
                        statusItem = Db.Get().BuildingStatusItems.GasPipeEmpty;
                        break;
                    }

                    if (statusItem != null)
                    {
                        pipesHaveMassStatusItem = selectable.ToggleStatusItem(statusItem, pipesHaveMassStatusItem, !satisfied, this);
                    }

                    operational.SetFlag(pipesHaveMassFlag, satisfied);
                }
            }

            RequirementsMet = connected &&
                              (!requireConduitHasMass || satisfied);
        }
 private void CheckDrowning(object data = null)
 {
     if (!drowned)
     {
         int cell = Grid.PosToCell(base.gameObject.transform.GetPosition());
         if (!IsCellSafe(cell))
         {
             if (!drowning)
             {
                 drowning = true;
                 Trigger(1949704522, null);
                 GetComponent <KPrefabID>().AddTag(GameTags.Creatures.Drowning, false);
             }
             if (timeToDrown <= 0f && canDrownToDeath)
             {
                 this.GetSMI <DeathMonitor.Instance>()?.Kill(Db.Get().Deaths.Drowned);
                 Trigger(-750750377, null);
                 drowned = true;
             }
         }
         else if (drowning)
         {
             drowning = false;
             GetComponent <KPrefabID>().RemoveTag(GameTags.Creatures.Drowning);
             Trigger(99949694, null);
         }
         if (livesUnderWater)
         {
             selectable.ToggleStatusItem(Db.Get().CreatureStatusItems.Saturated, drowning, this);
         }
         else
         {
             selectable.ToggleStatusItem(Db.Get().CreatureStatusItems.Drowning, drowning, this);
         }
         if ((UnityEngine.Object)effects != (UnityEngine.Object)null)
         {
             if (drowning)
             {
                 if (livesUnderWater)
                 {
                     effects.Add(saturatedEffect, false);
                 }
                 else
                 {
                     effects.Add(drowningEffect, false);
                 }
             }
             else if (livesUnderWater)
             {
                 effects.Remove(saturatedEffect);
             }
             else
             {
                 effects.Remove(drowningEffect);
             }
         }
     }
 }
示例#7
0
        private bool UpdateVentOperational()
        {
            Vent.State outputState      = GetEndPointState();
            bool       obstructedFlag   = outputState == Vent.State.Blocked;
            bool       overPressureFlag = outputState == Vent.State.OverPressure;

            obstructedStatusGuid   = selectable.ToggleStatusItem(conduitType != ConduitType.Gas ? Db.Get().BuildingStatusItems.LiquidVentObstructed : Db.Get().BuildingStatusItems.GasVentObstructed, obstructedStatusGuid, obstructedFlag, null);
            overPressureStatusGuid = selectable.ToggleStatusItem(conduitType != ConduitType.Gas ? Db.Get().BuildingStatusItems.LiquidVentOverPressure : Db.Get().BuildingStatusItems.GasVentOverPressure, overPressureStatusGuid, overPressureFlag, null);
            bool flag = !obstructedFlag && !overPressureFlag;

            operational.SetFlag(FanOutFlag, flag);
            return(flag);
        }
示例#8
0
        private void CheckRequirements(bool forceEvent)
        {
            bool connected = !conduitOutput.enabled || conduitOutput.IsConnected;

            if (connected != previouslyConnected)
            {
                previouslyConnected = connected;

                StatusItem statusItem = null;
                switch (conduitOutput.TypeOfConduit)
                {
                case ConduitType.Liquid:
                    statusItem = Db.Get().BuildingStatusItems.NeedLiquidOut;
                    break;

                case ConduitType.Gas:
                    statusItem = Db.Get().BuildingStatusItems.NeedGasOut;
                    break;
                }

                if (statusItem != null)
                {
                    outputConnectedStatusItem = selectable.ToggleStatusItem(statusItem, outputConnectedStatusItem, !connected);
                }

                operational.SetFlag(outputConnectedFlag, connected);
            }

            bool empty = !conduitOutput.enabled || conduitOutput.ConduitContents.mass <= 0;

            if (previouslyEmpty != empty)
            {
                previouslyEmpty = empty;

                if (requireConduitHasRoom)
                {
                    StatusItem statusItem = Db.Get().BuildingStatusItems.ConduitBlockedMultiples;

                    if (statusItem != null)
                    {
                        pipesHaveRoomStatusItem = selectable.ToggleStatusItem(statusItem, pipesHaveRoomStatusItem, !empty, this);
                    }

                    operational.SetFlag(pipesHaveRoomFlag, empty);
                }
            }

            RequirementsMet = connected &&
                              (!requireConduitHasRoom || empty);
        }
 public void RefreshClearableStatus()
 {
     if (isMarkedForClear)
     {
         bool flag = GlobalChoreProvider.Instance.ClearableHasDestination(pickupable);
         selectable.ToggleStatusItem(Db.Get().MiscStatusItems.PendingClear, flag, this);
         selectable.ToggleStatusItem(Db.Get().MiscStatusItems.PendingClearNoStorage, !flag, this);
     }
     else
     {
         selectable.ToggleStatusItem(Db.Get().MiscStatusItems.PendingClear, false, this);
         selectable.ToggleStatusItem(Db.Get().MiscStatusItems.PendingClearNoStorage, false, this);
     }
 }
示例#10
0
        private void OnFilterChanged(Tag tag)
        {
            if (refreshing)
            {
                return;
            }

            Element element = ElementLoader.GetElement(tag);

            if (element != null)
            {
                filteredElement = element.id;
                anim.SetSymbolTint("gasframes", element.substance.uiColour);
                anim.SetSymbolTint("liquid", element.substance.uiColour);
                anim.SetSymbolTint("liquid_top", element.substance.uiColour);

                minTemp = element.lowTemp;
                maxTemp = element.highTemp;

                Temp = Mathf.Clamp(Temp, element.lowTemp, element.highTemp);
            }

            bool invalidElement = (!tag.IsValid || tag == GameTags.Void);

            selectable.ToggleStatusItem(Db.Get().BuildingStatusItems.NoFilterElementSelected, invalidElement, null);
            operational.SetFlag(filterFlag, !invalidElement);
        }
示例#11
0
    private void RefreshStatusItem()
    {
        bool on = operational.IsOperational && hasLogicWire;

        selectable.ToggleStatusItem(infoStatusItem_Logic, on, this);
        statusDirty = false;
    }
示例#12
0
 public void MarkForEmptying()
 {
     if (chore == null)
     {
         StatusItem  statusItem = GetStatusItem();
         KSelectable component  = GetComponent <KSelectable>();
         component.ToggleStatusItem(statusItem, true, null);
         CreateWorkChore();
     }
 }
示例#13
0
    private bool UpdateOperational()
    {
        Element.State state = Element.State.Vacuum;
        switch (dispenser.conduitType)
        {
        case ConduitType.Gas:
            state = Element.State.Gas;
            break;

        case ConduitType.Liquid:
            state = Element.State.Liquid;
            break;
        }
        bool       flag        = IsPumpable(state, consumer.consumptionRadius);
        StatusItem status_item = (state != Element.State.Gas) ? Db.Get().BuildingStatusItems.NoLiquidElementToPump : Db.Get().BuildingStatusItems.NoGasElementToPump;

        selectable.ToggleStatusItem(status_item, !flag, null);
        operational.SetFlag(PumpableFlag, !storage.IsFull() && flag);
        return(flag);
    }
示例#14
0
        private void RefreshDepthAvailable()
        {
            bool waterFound;
            int  depthAvailable = GetDepthAvailable(parent, out waterFound);

            if (depthAvailable != previousDepthAvailable || waterFound != previousWaterFound)
            {
                KBatchedAnimController kBatchedAnimController = GetComponent <KBatchedAnimController>();
                if (depthAvailable == 0)
                {
                    kBatchedAnimController.enabled = false;
                }
                else
                {
                    kBatchedAnimController.enabled = true;
                    kBatchedAnimController.Offset  = new Vector3(0, -depthAvailable + 0.35f);
                    for (int i = 1; i <= MaxDepth; i++)
                    {
                        kBatchedAnimController.SetSymbolVisiblity("line" + i.ToString(), i <= depthAvailable);
                        kBatchedAnimController.SetSymbolVisiblity("lineplace" + i.ToString(), i <= depthAvailable);
                    }
                    kBatchedAnimController.sceneLayer = Grid.SceneLayer.BuildingBack;
                    kBatchedAnimController.Play(kBatchedAnimController.initialAnim, KAnim.PlayMode.Loop, 1f, 0f);
                }
                if (occupyTiles)
                {
                    OccupyArea(parent, depthAvailable);
                }
                if (!isPreview)
                {
                    KSelectable kSelectable = parent.GetComponent <KSelectable>();
                    if (kSelectable != null)
                    {
                        kSelectable.ToggleStatusItem(statusItemNoDepth, depthAvailable == 0);
                        kSelectable.ToggleStatusItem(statusItemNoWater, depthAvailable > 0 && !waterFound);
                    }
                }
                previousDepthAvailable = depthAvailable;
                previousWaterFound     = waterFound;
            }
        }
示例#15
0
        private bool UpdateOperational()
        {
            var expected_state = Element.State.Vacuum;

            switch (dispenser.conduitType)
            {
            case ConduitType.Gas:
                expected_state = Element.State.Gas;
                break;

            case ConduitType.Liquid:
                expected_state = Element.State.Liquid;
                break;
            }

            var flag = IsPumpable(expected_state, consumer.consumptionRadius);

            selectable.ToggleStatusItem(Db.Get().BuildingStatusItems.NoLiquidElementToPump, false);
            operational.SetFlag(Pump.PumpableFlag, !storage.IsFull() && flag);
            return(flag);
        }
示例#16
0
    public void EnergySim200ms(float dt)
    {
        KSelectable component = GetComponent <KSelectable>();

        if (operational.IsActive)
        {
            generator.GenerateJoules(generator.WattageRating * dt, false);
            component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.Wattage, generator);
        }
        else
        {
            generator.ResetJoules();
            component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.GeneratorOffline, null);
            if (operational.IsOperational)
            {
                CircuitManager circuitManager = Game.Instance.circuitManager;
                if (circuitManager != null)
                {
                    ushort circuitID = circuitManager.GetCircuitID(powerCell);
                    bool   flag      = circuitManager.HasBatteries(circuitID);
                    bool   flag2     = false;
                    if (!flag && circuitManager.HasConsumers(circuitID))
                    {
                        flag2 = true;
                    }
                    else if (flag)
                    {
                        if (batteryRefillPercent <= 0f && circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) <= 0f)
                        {
                            flag2 = true;
                        }
                        else if (circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) < batteryRefillPercent)
                        {
                            flag2 = true;
                        }
                    }
                    if (flag2)
                    {
                        if (chore == null && smi.GetCurrentState() == smi.sm.on)
                        {
                            chore = new WorkChore <ManualGenerator>(Db.Get().ChoreTypes.GeneratePower, this, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
                        }
                    }
                    else if (chore != null)
                    {
                        chore.Cancel("No refill needed");
                        chore = null;
                    }
                    component.ToggleStatusItem(EnergyGenerator.BatteriesSufficientlyFull, !flag2, null);
                }
            }
        }
    }
示例#17
0
        protected static void RemoveDupe(Workable instance, Chore chore, Func <Workable, bool> isEndlessWorking)
        {
            KSelectable kSelectable = instance.GetComponent <KSelectable>();

            if (isEndlessWorking(instance) && chore != null)
            {
                bool isBeingWorked = false;
                if (chore.driver != null)
                {
                    isBeingWorked = true;
                    if (!ShouldChoreBeWorked(chore))
                    {
                        chore.driver.StopChore();
                    }
                }
                kSelectable.ToggleStatusItem(requiresAttributeRange, !isBeingWorked, GetAttributeRange(chore));
            }
            else
            {
                kSelectable.ToggleStatusItem(requiresAttributeRange, false);
            }
        }
示例#18
0
    private void CleanUpVisualization()
    {
        StatusItem  statusItem = GetStatusItem();
        KSelectable component  = GetComponent <KSelectable>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.ToggleStatusItem(statusItem, false, null);
        }
        elapsedTime = -1f;
        if (chore != null)
        {
            GetComponent <Prioritizable>().RemoveRef();
        }
    }
示例#19
0
        private void UpdateHasFuelStatus()
        {
            hasFuel = elementConverter.CanConvertAtAll();

            bool statusShown = needsFuelStatusItemGuid != Guid.Empty;

            if (hasFuel != statusShown)
            {
                return;
            }

            Log.Spam($"UpdateHasFuelStatus: {hasFuel}");

            var data = new Dictionary <Tag, float>();

            foreach (var input in elementConverter.consumedElements)
            {
                data.Add(input.tag, input.massConsumptionRate);
            }

            StatusItem statusItem = Db.Get().BuildingStatusItems.MaterialsUnavailable;

            needsFuelStatusItemGuid = selectable.ToggleStatusItem(statusItem, needsFuelStatusItemGuid, !hasFuel, data);
        }
    private void OnTagsChanged(object data)
    {
        bool        flag      = base.gameObject.HasTag(GameTags.HasInvalidPorts);
        Operational component = GetComponent <Operational>();

        if ((Object)component != (Object)null)
        {
            component.SetFlag(portsNotOverlapping, !flag);
        }
        KSelectable component2 = GetComponent <KSelectable>();

        if ((Object)component2 != (Object)null)
        {
            component2.ToggleStatusItem(Db.Get().BuildingStatusItems.InvalidPortOverlap, flag, base.gameObject);
        }
    }
        private static bool Prefix(ref Valve __instance, float amount, ref ValveBase ___valveBase, ref float ___desiredFlow)
        {
            if (!CustomizeBuildingsState.StateManager.State.NoDupeValves)
            {
                return(true);
            }

            ___desiredFlow = Mathf.Clamp(amount, 0.0f, ___valveBase.MaxFlow);

            KSelectable component = __instance.GetComponent <KSelectable>();

            component.ToggleStatusItem(Db.Get().BuildingStatusItems.PumpingLiquidOrGas, ___desiredFlow >= 0.0, (object)___valveBase.AccumulatorHandle);

            __instance.UpdateFlow();
            return(false);
        }
示例#22
0
 public void UpdateValues()
 {
     if (Grid.IsValidCell(selectedCell))
     {
         Mass         = Grid.Mass[selectedCell];
         element      = Grid.Element[selectedCell];
         ElementName  = element.name;
         state        = element.state;
         tags         = element.GetMaterialCategoryTag();
         temperature  = Grid.Temperature[selectedCell];
         diseaseIdx   = Grid.DiseaseIdx[selectedCell];
         diseaseCount = Grid.DiseaseCount[selectedCell];
         mSelectable.SetName(Grid.Element[selectedCell].name);
         DetailsScreen.Instance.Trigger(-1514841199, null);
         UpdateStatusItem();
         if (element.id == SimHashes.OxyRock)
         {
             mSelectable.AddStatusItem(Db.Get().MiscStatusItems.OxyRockEmitting, this);
             if (FlowRate <= 0f)
             {
                 mSelectable.AddStatusItem(Db.Get().MiscStatusItems.OxyRockBlocked, this);
             }
             else
             {
                 mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.OxyRockBlocked, false);
             }
         }
         else
         {
             mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.OxyRockEmitting, false);
             mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.OxyRockBlocked, false);
         }
         if (Game.Instance.GetComponent <EntombedItemVisualizer>().IsEntombedItem(selectedCell))
         {
             mSelectable.AddStatusItem(Db.Get().MiscStatusItems.BuriedItem, this);
         }
         else
         {
             mSelectable.RemoveStatusItem(Db.Get().MiscStatusItems.BuriedItem, true);
         }
         bool on = IsExposedToSpace(selectedCell);
         mSelectable.ToggleStatusItem(Db.Get().MiscStatusItems.Space, on, null);
     }
 }
    private void CheckRequirements(bool forceEvent)
    {
        bool flag  = true;
        bool flag2 = false;

        if (requirePower)
        {
            bool isConnected = energy.IsConnected;
            bool isPowered   = energy.IsPowered;
            if (isConnected)
            {
                if (isConnected != wasConnected)
                {
                    wireConnectedStatusItem = selectable.RemoveStatusItem(wireConnectedStatusItem, false);
                }
                if (visualizeRequirements)
                {
                    bool on = !isPowered && ((UnityEngine.Object)button == (UnityEngine.Object)null || button.IsEnabled);
                    selectable.ToggleStatusItem(Db.Get().BuildingStatusItems.NeedPower, on, this);
                }
                flag = (flag && isPowered);
            }
            else
            {
                if (isConnected != wasConnected)
                {
                    selectable.RemoveStatusItem(Db.Get().BuildingStatusItems.NeedPower, false);
                }
                if (wireConnectedStatusItem == Guid.Empty)
                {
                    wireConnectedStatusItem = selectable.AddStatusItem(Db.Get().BuildingStatusItems.NoWireConnected, null);
                }
                flag = (flag && isConnected);
            }
            wasConnected = isConnected;
            flag2        = (flag != RequirementsMet && (UnityEngine.Object)GetComponent <Light2D>() != (UnityEngine.Object)null);
        }
        if (requireConduit && visualizeRequirements)
        {
            bool flag3 = !conduitConsumer.enabled || conduitConsumer.IsConnected;
            bool flag4 = !conduitConsumer.enabled || conduitConsumer.IsSatisfied;
            if (previouslyConnected != flag3)
            {
                previouslyConnected = flag3;
                StatusItem statusItem = null;
                switch (conduitConsumer.TypeOfConduit)
                {
                case ConduitType.Liquid:
                    statusItem = Db.Get().BuildingStatusItems.NeedLiquidIn;
                    break;

                case ConduitType.Gas:
                    statusItem = Db.Get().BuildingStatusItems.NeedGasIn;
                    break;
                }
                if (statusItem != null)
                {
                    selectable.ToggleStatusItem(statusItem, !flag3, new Tuple <ConduitType, Tag>(conduitConsumer.TypeOfConduit, conduitConsumer.capacityTag));
                }
                operational.SetFlag(inputConnectedFlag, flag3);
            }
            flag = (flag && flag3);
            if (previouslySatisfied != flag4)
            {
                previouslySatisfied = flag4;
                StatusItem statusItem2 = null;
                switch (conduitConsumer.TypeOfConduit)
                {
                case ConduitType.Liquid:
                    statusItem2 = Db.Get().BuildingStatusItems.LiquidPipeEmpty;
                    break;

                case ConduitType.Gas:
                    statusItem2 = Db.Get().BuildingStatusItems.GasPipeEmpty;
                    break;
                }
                if (requireConduitHasMass)
                {
                    if (statusItem2 != null)
                    {
                        selectable.ToggleStatusItem(statusItem2, !flag4, this);
                    }
                    operational.SetFlag(pipesHaveMass, flag4);
                }
            }
        }
        requirementsMet = flag;
        if (flag2)
        {
            Room roomOfGameObject = Game.Instance.roomProber.GetRoomOfGameObject(base.gameObject);
            if (roomOfGameObject != null)
            {
                Game.Instance.roomProber.UpdateRoom(roomOfGameObject.cavity);
            }
        }
    }
示例#24
0
 // Called when conduits are updated.
 private void OnConduitUpdate(float dt)
 {
     conduitBlockedGuid = selectable.ToggleStatusItem(Db.Get().BuildingStatusItems.
                                                      ConduitBlocked, conduitBlockedGuid, dispenser.blocked);
 }