Пример #1
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 Sim200ms(float dt)
 {
     operational.SetFlag(canExhaust, !vent.IsBlocked);
     if (!operational.IsOperational)
     {
         if (isAnimating)
         {
             isAnimating       = false;
             recentlyExhausted = false;
             Trigger(-793429877, null);
         }
     }
     else
     {
         UpdateEmission();
         elapsedSwitchTime -= dt;
         if (elapsedSwitchTime <= 0f)
         {
             elapsedSwitchTime = 1f;
             if (recentlyExhausted != isAnimating)
             {
                 isAnimating = recentlyExhausted;
                 Trigger(-793429877, null);
             }
             recentlyExhausted = false;
         }
     }
 }
Пример #3
0
    private void TestTemperature(bool force)
    {
        bool flag = false;

        if (primaryElement.Temperature < minimumTemperature)
        {
            flag = false;
        }
        else
        {
            flag = true;
            for (int i = 0; i < building.PlacementCells.Length; i++)
            {
                int   i2   = building.PlacementCells[i];
                float num  = Grid.Temperature[i2];
                float num2 = Grid.Mass[i2];
                if ((num != 0f || num2 != 0f) && num < minimumTemperature)
                {
                    flag = false;
                    break;
                }
            }
        }
        if (!flag)
        {
            lastOffTime = Time.time;
        }
        if ((flag != isWarm && !flag) || (flag != isWarm && flag && Time.time > lastOffTime + 5f) || force)
        {
            isWarm = flag;
            operational.SetFlag(warmEnoughFlag, isWarm);
            GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.TooCold, !isWarm, this);
        }
    }
Пример #4
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);
        }
Пример #5
0
    protected override void OnCompleteWork(Worker worker)
    {
        Operational component = GetComponent <Operational>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetFlag(repairedFlag, true);
        }
    }
Пример #6
0
    protected override void OnStartWork(Worker worker)
    {
        base.OnStartWork(worker);
        Operational component = GetComponent <Operational>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetFlag(repairedFlag, false);
        }
        timeSpentRepairing = 0f;
    }
Пример #7
0
 private void CheckConnectionStatus()
 {
     if (CircuitID == 65535)
     {
         if (HasWire)
         {
             SetStatusItem(Db.Get().BuildingStatusItems.NoPowerConsumers);
             operational.SetFlag(generatorConnectedFlag, true);
         }
         else
         {
             SetStatusItem(Db.Get().BuildingStatusItems.NoWireConnected);
             operational.SetFlag(generatorConnectedFlag, false);
         }
     }
     else
     {
         SetStatusItem(null);
         operational.SetFlag(generatorConnectedFlag, true);
     }
 }
Пример #8
0
 private void UpdateSolidState(bool is_solid, ref Data data)
 {
     if (data.solid != is_solid)
     {
         data.solid = is_solid;
         Operational component = data.go.GetComponent <Operational>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null)
         {
             component.SetFlag(solidFoundation, is_solid);
         }
         data.go.GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.MissingFoundation, !is_solid, this);
     }
 }
    private void OnFilterChanged()
    {
        if (this.onFilterChanged != null)
        {
            this.onFilterChanged(selectedTag);
        }
        Operational component = GetComponent <Operational>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetFlag(filterSelected, selectedTag.IsValid);
        }
    }
 public override void InitializeStates(out BaseState default_state)
 {
     base.serializable = true;
     default_state     = healthy;
     healthy.DefaultState(healthy.imperfect).EventTransition(GameHashes.BuildingReceivedDamage, damaged, (SMInstance smi) => smi.master.HitPoints <= 0);
     healthy.imperfect.Enter(delegate(SMInstance smi)
     {
         smi.ShowProgressBar(true);
     }).DefaultState(healthy.imperfect.playEffect).EventTransition(GameHashes.BuildingPartiallyRepaired, healthy.perfect, (SMInstance smi) => smi.master.HitPoints == smi.master.building.Def.HitPoints)
     .EventHandler(GameHashes.BuildingPartiallyRepaired, delegate(SMInstance smi)
     {
         smi.UpdateMeter();
     })
     .ToggleStatusItem((SMInstance smi) => (smi.master.damageSourceInfo.statusItemID == null) ? null : Db.Get().BuildingStatusItems.Get(smi.master.damageSourceInfo.statusItemID), null)
     .Exit(delegate(SMInstance smi)
     {
         smi.ShowProgressBar(false);
     });
     healthy.imperfect.playEffect.Transition(healthy.imperfect.waiting, (SMInstance smi) => true, UpdateRate.SIM_200ms);
     healthy.imperfect.waiting.ScheduleGoTo((SMInstance smi) => UnityEngine.Random.Range(15f, 30f), healthy.imperfect.playEffect);
     healthy.perfect.EventTransition(GameHashes.BuildingReceivedDamage, healthy.imperfect, (SMInstance smi) => smi.master.HitPoints < smi.master.building.Def.HitPoints);
     damaged.Enter(delegate(SMInstance smi)
     {
         Operational component2 = smi.GetComponent <Operational>();
         if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
         {
             component2.SetFlag(healthyFlag, false);
         }
         smi.ShowProgressBar(true);
         smi.master.Trigger(774203113, smi.master);
         smi.SetCrackOverlayValue(1f);
     }).ToggleNotification((SMInstance smi) => smi.CreateBrokenMachineNotification()).ToggleStatusItem(Db.Get().BuildingStatusItems.Broken, (object)null)
     .ToggleFX((SMInstance smi) => smi.InstantiateDamageFX())
     .EventTransition(GameHashes.BuildingPartiallyRepaired, healthy.perfect, (SMInstance smi) => smi.master.HitPoints == smi.master.building.Def.HitPoints)
     .EventHandler(GameHashes.BuildingPartiallyRepaired, delegate(SMInstance smi)
     {
         smi.UpdateMeter();
     })
     .Exit(delegate(SMInstance smi)
     {
         Operational component = smi.GetComponent <Operational>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null)
         {
             component.SetFlag(healthyFlag, true);
         }
         smi.ShowProgressBar(false);
         smi.SetCrackOverlayValue(0f);
     });
 }
    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);
        }
    }
Пример #12
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);
    }
Пример #13
0
 private void ConduitUpdate(float dt)
 {
     operational.SetFlag(outputConduitFlag, IsConnected);
     if (operational.IsOperational || alwaysDispense)
     {
         PrimaryElement primaryElement = FindSuitableElement();
         if ((Object)primaryElement != (Object)null)
         {
             primaryElement.KeepZeroMassObject = true;
             ConduitFlow conduitManager = GetConduitManager();
             float       num            = conduitManager.AddElement(utilityCell, primaryElement.ElementID, primaryElement.Mass, primaryElement.Temperature, primaryElement.DiseaseIdx, primaryElement.DiseaseCount);
             if (num > 0f)
             {
                 float num2 = num / primaryElement.Mass;
                 int   num3 = (int)(num2 * (float)primaryElement.DiseaseCount);
                 primaryElement.ModifyDiseaseCount(-num3, "ConduitDispenser.ConduitUpdate");
                 primaryElement.Mass -= num;
                 Trigger(-1697596308, primaryElement.gameObject);
             }
         }
     }
 }