示例#1
0
        public static bool Prefix(float dt, ValveBase __instance, float ___currentFlow, int ___outputCell, int ___inputCell, HandleVector <int> .Handle ___flowAccumulator)
        {
            ConduitFlow flowManager = Conduit.GetFlowManager(__instance.conduitType);

            if (!flowManager.HasConduit(___inputCell) || !flowManager.HasConduit(___outputCell))
            {
                __instance.UpdateAnim();
            }
            else
            {
                ConduitFlow.ConduitContents input_content  = flowManager.GetConduit(___inputCell).GetContents(flowManager);
                ConduitFlow.ConduitContents output_content = flowManager.GetConduit(___outputCell).GetContents(flowManager);

                float mass_input  = Mathf.Min(input_content.mass, ___currentFlow * dt);
                float mass_output = output_content.mass;

                float mass_limit = Mathf.Max(___currentFlow - mass_output, 0);  // mass on output cannot exceed flow setting
                mass_input = Mathf.Min(mass_input, mass_limit);                 // set new input mass

                if (mass_input > 0f)
                {
                    float disease_percent = mass_input / input_content.mass;
                    int   disease_count   = (int)(disease_percent * input_content.diseaseCount);
                    float mass_moved      = flowManager.AddElement(___outputCell, input_content.element, mass_input, input_content.temperature, input_content.diseaseIdx, disease_count);
                    Game.Instance.accumulators.Accumulate(___flowAccumulator, mass_moved);
                    if (mass_moved > 0f)
                    {
                        flowManager.RemoveElement(___inputCell, mass_moved);
                    }
                }
                __instance.UpdateAnim();
            }

            return(false);
        }
            public static bool Prefix(ConduitConsumer __instance, ConduitFlow conduit_mgr, int ___utilityCell)
            {
                // if we don't have the component, do nothing special
                if (__instance.gameObject.GetComponent <InfiniteStorage>() == null)
                {
                    return(true);
                }

                var contents = conduit_mgr.GetContents(___utilityCell);

                var storage = __instance.gameObject.GetComponent <Storage>();

                if (storage == null)
                {
                    return(true);
                }

                var filterable = __instance.gameObject.GetComponent <TreeFilterable>();

                if (filterable == null)
                {
                    return(true);
                }

                // If it doesn't contain the tag, return false, don't consume
                var tag = ElementLoader.FindElementByHash(contents.element).tag;
                var ret = filterable.AcceptedTags.Contains(tag);

                return(ret);
            }
    private void ConduitUpdate(float dt)
    {
        ConduitFlow flowManager = Conduit.GetFlowManager(portInfo.conduitType);

        if (flowManager.HasConduit(inputCell))
        {
            ConduitFlow.ConduitContents contents = flowManager.GetContents(inputCell);
            if (!(contents.mass <= 0f))
            {
                int cell = outputCell;
                ConduitFlow.ConduitContents contents2 = flowManager.GetContents(cell);
                if (contents2.mass > 0f)
                {
                    cell      = secondaryOutput.Cell;
                    contents2 = flowManager.GetContents(cell);
                }
                if (contents2.mass <= 0f)
                {
                    float num = flowManager.AddElement(cell, contents.element, contents.mass, contents.temperature, contents.diseaseIdx, contents.diseaseCount);
                    if (num > 0f)
                    {
                        flowManager.RemoveElement(inputCell, num);
                    }
                }
            }
        }
    }
示例#4
0
        protected override void ConduitUpdate(float dt)
        {
            this.currentValue = 0;

            // spawn code should never toggle as it crashes on load
            if (dt < 0)
            {
                return;
            }

            int         cell        = Grid.PosToCell(this);
            ConduitFlow flowManager = Conduit.GetFlowManager(this.conduitType);

            if (flowManager.HasConduit(cell))
            {
                if (flowManager != null)
                {
                    var conduit  = flowManager.GetConduit(cell);
                    var lastFlow = conduit.GetLastFlowInfo(flowManager);
                    if (lastFlow.direction != ConduitFlow.FlowDirections.None)
                    {
                        this.currentValue = (lastFlow.contents.mass) * 1000;
                    }
                }
            }



            if (this.activateAboveThreshold)
            {
                // Empty is always false
                if (this.currentValue <= 0f)
                {
                    if (base.IsSwitchedOn)
                    {
                        this.Toggle();
                    }
                    return;
                }

                // Full is always true
                if (this.currentValue >= this.max)
                {
                    if (!base.IsSwitchedOn)
                    {
                        this.Toggle();
                    }
                    return;
                }

                if ((this.currentValue > this.threshold && !base.IsSwitchedOn) || (this.currentValue <= this.threshold && base.IsSwitchedOn))
                {
                    this.Toggle();
                }
            }
            else if ((this.currentValue > this.threshold && base.IsSwitchedOn) || (this.currentValue <= this.threshold && !base.IsSwitchedOn))
            {
                this.Toggle();
            }
        }
    private float GetContainedMass()
    {
        int         cell        = Grid.PosToCell(this);
        ConduitFlow flowManager = Conduit.GetFlowManager(conduitType);

        return(flowManager.GetContents(cell).mass);
    }
示例#6
0
 protected override void UpdateVisualState(bool force = false)
 {
     if (wasOn != switchedOn || force)
     {
         wasOn = switchedOn;
         if (switchedOn)
         {
             animController.Play(ConduitSensor.ON_ANIMS, KAnim.PlayMode.Loop);
             int         cell        = Grid.PosToCell(this);
             ConduitFlow flowManager = Conduit.GetFlowManager(conduitType);
             ConduitFlow.ConduitContents contents = flowManager.GetContents(cell);
             Color32 c = Color.white;
             if (contents.diseaseIdx != 255)
             {
                 Disease disease = Db.Get().Diseases[contents.diseaseIdx];
                 c = disease.overlayColour;
             }
             animController.SetSymbolTint(TINT_SYMBOL, c);
         }
         else
         {
             animController.Play(ConduitSensor.OFF_ANIMS, KAnim.PlayMode.Once);
         }
     }
 }
示例#7
0
    public unsafe void Sim200ms(float dt)
    {
        IntPtr value = ConduitTemperatureManager_Update(dt, (IntPtr)(void *)Game.Instance.simData.buildingTemperatures);
        ConduitTemperatureUpdateData *ptr = (ConduitTemperatureUpdateData *)(void *)value;
        int numEntries = ptr->numEntries;

        if (numEntries > 0)
        {
            Marshal.Copy((IntPtr)(void *)ptr->temperatures, temperatures, 0, numEntries);
        }
        for (int i = 0; i < ptr->numFrozenHandles; i++)
        {
            int         h           = ptr->frozenHandles[i];
            int         handleIndex = Sim.GetHandleIndex(h);
            ConduitInfo conduitInfo = this.conduitInfo[handleIndex];
            ConduitFlow flowManager = Conduit.GetFlowManager(conduitInfo.type);
            flowManager.FreezeConduitContents(conduitInfo.idx);
        }
        for (int j = 0; j < ptr->numMeltedHandles; j++)
        {
            int         h2           = ptr->meltedHandles[j];
            int         handleIndex2 = Sim.GetHandleIndex(h2);
            ConduitInfo conduitInfo2 = this.conduitInfo[handleIndex2];
            ConduitFlow flowManager2 = Conduit.GetFlowManager(conduitInfo2.type);
            flowManager2.MeltConduitContents(conduitInfo2.idx);
        }
    }
示例#8
0
        public static float GetMaxCapacityWithObject(int cell, ConduitType type, out GameObject obj, bool isBridge = false)
        {
            if (type != ConduitType.Gas && type != ConduitType.Liquid)
            {
                throw new System.ArgumentException($"[Pressurized] Invalid Conduit Type given to IntegrationHelper.GetMaxCapacityAt(): {type.ToString()}  Type must be ConduitType.Gas or ConduitType.Liquid.", "type");
            }
            ConduitFlow manager     = Conduit.GetFlowManager(type);
            Pressurized pressurized = GetPressurizedAt(cell, type, isBridge);

            if (pressurized == null)
            {
                obj = null;
            }
            else
            {
                obj = pressurized.gameObject;
            }
            if (Pressurized.IsDefault(pressurized))
            {
                return(manager.MaxMass());
            }
            else
            {
                return(pressurized.Info.IncreaseMultiplier * manager.MaxMass());
            }
        }
示例#9
0
 protected virtual void ConduitUpdate(float dt)
 {
     if (!SkipSetOperational)
     {
         this.operational.SetFlag(PortConduitDispenserBase.outputConduitFlag, this.IsConnected);
     }
     if (this.operational.IsOperational || this.alwaysDispense)
     {
         PrimaryElement primaryElement = this.FindSuitableElement();
         if (primaryElement != null)
         {
             primaryElement.KeepZeroMassObject = true;
             ConduitFlow conduitManager = this.GetConduitManager();
             float       num            = conduitManager.AddElement(this.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, "CustomConduitDispenser.ConduitUpdate");
                 primaryElement.Mass -= num;
                 base.Trigger(-1697596308, primaryElement.gameObject);
             }
         }
     }
 }
        public bool CanConvertAtAll()
        {
            float             filterAmt = 0;
            float             liquidAmt = 0;
            List <GameObject> items     = this.storage.items;
            PrimaryElement    elem      = null;

            foreach (GameObject item in items)
            {
                elem = item.GetComponent <PrimaryElement>();
                if (elem.ElementID == SimHashes.BleachStone)
                {
                    filterAmt += elem.Mass;
                }
                else if (elem.Element.IsLiquid /*&& elem.DiseaseIdx != Byte.MaxValue*/)
                {
                    liquidAmt += elem.Mass;
                }
            }
            if (filterAmt <= 0.1f || liquidAmt <= 0.1f)
            {
                return(false);                                        // non-zero to prevent constant activity
            }
            ConduitFlow flowManager = Conduit.GetFlowManager(ConduitType.Liquid);

            return(flowManager.HasConduit(outCell));
        }
    protected override void OnCleanUp()
    {
        ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;

        liquidConduitFlow.onConduitsRebuilt -= OnConduitsRebuilt;
        Components.Toilets.Remove(this);
        base.OnCleanUp();
    }
 private void ConduitUpdate(float dt)
 {
     if (this.isConsuming)
     {
         ConduitFlow conduitManager = this.GetConduitManager();
         this.Consume(dt, conduitManager);
     }
 }
示例#13
0
 public static float MaxMass(this ConduitFlow manager)
 {
     if (manager == null)
     {
         throw new System.ArgumentNullException("manager");
     }
     return((float)maxMass.GetValue(manager));
 }
 private void ConduitUpdate(float dt)
 {
     if (isConsuming)
     {
         ConduitFlow conduitManager = GetConduitManager();
         Consume(dt, conduitManager);
     }
 }
    private void OnConduitUpdate(float dt)
    {
        ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;
        bool        flag = liquidConduitFlow.GetContents(outputCell).mass > 0f;

        smi.sm.outputBlocked.Set(flag, smi);
        operational.SetFlag(coolantOutputPipeEmpty, !flag);
    }
示例#16
0
            internal static void Postfix(ConduitFlowVisualizer __instance, int cell, ConduitFlow ___flowManager, bool ___showContents, ref Color32 __result)
            {
                Pressurized pressure = Integration.GetPressurizedAt(cell, (ConduitType)conduitType.GetValue(___flowManager));

                if (!Pressurized.IsDefault(pressure))
                {
                    __result = ___showContents ? pressure.Info.FlowOverlayTint : pressure.Info.FlowTint;
                }
            }
 private void OnConduitUpdate(float dt)
 {
     if (GetSMI() != null)
     {
         ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;
         bool        value             = liquidConduitFlow.GetContents(outputCell).mass > 0f && base.smi.HasContaminatedMass();
         base.smi.sm.outputBlocked.Set(value, base.smi);
     }
 }
示例#18
0
        public static float GetMaxCapacityAt(int cell, ConduitType type, bool isBridge = false)
        {
            if (type != ConduitType.Gas && type != ConduitType.Liquid)
            {
                throw new System.ArgumentException($"[Pressurized] Invalid Conduit Type given to IntegrationHelper.GetMaxCapacityAt(): {type.ToString()}  Type must be ConduitType.Gas or ConduitType.Liquid.", "type");
            }
            ConduitFlow manager = Conduit.GetFlowManager(type);

            return(Pressurized.GetMaxCapacity(GetPressurizedAt(cell, type, isBridge)));
        }
    protected override void OnCleanUp()
    {
        IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(this.portInfo.conduitType);

        networkManager.RemoveFromNetworks(this.sInputCell, this.itemSInput, true);
        ConduitFlow flowManager = Conduit.GetFlowManager(this.portInfo.conduitType);

        flowManager.RemoveConduitUpdater(this.OnConduitTick);
        base.OnCleanUp();
    }
 public ConduitFlowVisualizer(ConduitFlow flow_manager, Game.ConduitVisInfo vis_info, string overlay_sound, Tuning tuning)
 {
     flowManager    = flow_manager;
     visInfo        = vis_info;
     overlaySound   = overlay_sound;
     this.tuning    = tuning;
     movingBallMesh = new ConduitFlowMesh();
     staticBallMesh = new ConduitFlowMesh();
     RenderMeshTask.Ball.InitializeResources();
 }
示例#21
0
    private void UpdateState(float dt)
    {
        bool value = consumer.IsSatisfied;

        envTemp   = 0f;
        cellCount = 0;
        if ((UnityEngine.Object)occupyArea != (UnityEngine.Object)null && (UnityEngine.Object)base.gameObject != (UnityEngine.Object)null)
        {
            occupyArea.TestArea(Grid.PosToCell(base.gameObject), this, UpdateStateCb);
            envTemp /= (float)cellCount;
        }
        lastEnvTemp = envTemp;
        List <GameObject> items = storage.items;

        for (int i = 0; i < items.Count; i++)
        {
            PrimaryElement component = items[i].GetComponent <PrimaryElement>();
            if (component.Mass > 0f && (!isLiquidConditioner || !component.Element.IsGas) && (isLiquidConditioner || !component.Element.IsLiquid))
            {
                value       = true;
                lastGasTemp = component.Temperature;
                float num = component.Temperature + temperatureDelta;
                if (num < 1f)
                {
                    num        = 1f;
                    lowTempLag = Mathf.Min(lowTempLag + dt / 5f, 1f);
                }
                else
                {
                    lowTempLag = Mathf.Min(lowTempLag - dt / 5f, 0f);
                }
                ConduitFlow conduitFlow = (!isLiquidConditioner) ? Game.Instance.gasConduitFlow : Game.Instance.liquidConduitFlow;
                float       num2        = conduitFlow.AddElement(cooledAirOutputCell, component.ElementID, component.Mass, num, component.DiseaseIdx, component.DiseaseCount);
                component.KeepZeroMassObject = true;
                float num3 = num2 / component.Mass;
                int   num4 = (int)((float)component.DiseaseCount * num3);
                component.Mass -= num2;
                component.ModifyDiseaseCount(-num4, "AirConditioner.UpdateState");
                float num5       = num - component.Temperature;
                float num6       = num5 * component.Element.specificHeatCapacity * num2;
                float display_dt = (!(lastSampleTime > 0f)) ? 1f : (Time.time - lastSampleTime);
                lastSampleTime = Time.time;
                GameComps.StructureTemperatures.ProduceEnergy(structureTemperature, 0f - num6, BUILDING.STATUSITEMS.OPERATINGENERGY.PIPECONTENTS_TRANSFER, display_dt);
                break;
            }
        }
        if (Time.time - lastSampleTime > 2f)
        {
            GameComps.StructureTemperatures.ProduceEnergy(structureTemperature, 0f, BUILDING.STATUSITEMS.OPERATINGENERGY.PIPECONTENTS_TRANSFER, Time.time - lastSampleTime);
            lastSampleTime = Time.time;
        }
        operational.SetActive(value, false);
        UpdateStatus();
    }
示例#22
0
    private void UpdateConduitBlockedStatus()
    {
        ConduitFlow flowManager             = Conduit.GetFlowManager(portInfo.conduitType);
        bool        flag                    = flowManager.IsConduitEmpty(filteredCell);
        StatusItem  conduitBlockedMultiples = Db.Get().BuildingStatusItems.ConduitBlockedMultiples;
        bool        flag2                   = conduitBlockedStatusItemGuid != Guid.Empty;

        if (flag == flag2)
        {
            conduitBlockedStatusItemGuid = selectable.ToggleStatusItem(conduitBlockedMultiples, conduitBlockedStatusItemGuid, !flag, null);
        }
    }
示例#23
0
        public static float GetMaxCapacity(Pressurized pressure)
        {
            ConduitFlow manager = Conduit.GetFlowManager(pressure.ConduitType);

            if (IsDefault(pressure))
            {
                return(manager.MaxMass());
            }
            else
            {
                return(pressure.Info.IncreaseMultiplier * manager.MaxMass());
            }
        }
示例#24
0
        private void ForceRebuild()
        {
            //Rebuild the conduit flow network, so that conduit contents transfer no heat.
            ConduitFlow manager = conduit.GetFlowManager();

            if (manager == null)
            {
                Debug.LogError($"[Pressurized] Could not retrieve the conduit flow manager for conduit type: {ConduitType}");
                return;
            }
            //Without forcing the rebuild, the conduit system will not know that this conduit is now made out of insulation. Rebuilds normally occur when conduits are built/destroyed
            manager.ForceRebuildNetworks();
        }
示例#25
0
        private bool SetContents(int cell, ConduitType conduitType, Element element, float mass, float temperature, byte diseaseIdx, int diseaseCount)
        {
            if (conduitType == ConduitType.Solid)
            {
                var conduitFlow = Game.Instance.solidConduitFlow;
                if (!conduitFlow.HasConduit(cell))
                {
                    return(false);
                }

                mass = Mathf.Clamp(mass, 0, MAX_SOLID_MASS);
                var res = element.substance.SpawnResource(Vector3.zero, mass, temperature, diseaseIdx, diseaseCount);
                var pc  = res.GetComponent <Pickupable>();
                var p   = conduitFlow.RemovePickupable(cell);
                if (p != null)
                {
                    DestroyPickupable(p);
                }

                conduitFlow.SetContents(cell, pc);
                updateSolidFlowVisualization = true;
            }
            else
            {
                ConduitFlow conduitFlow = conduitType == ConduitType.Liqud
                    ? Game.Instance.liquidConduitFlow
                    : Game.Instance.gasConduitFlow;

                if (!conduitFlow.HasConduit(cell))
                {
                    return(false);
                }

                var maxMass = conduitType == ConduitType.Liqud ? MAX_LIQUID_MASS : MAX_GAS_MASS;
                mass = Mathf.Clamp(mass, 0, maxMass);

                var contents = new ConduitFlow.ConduitContents(element.id, mass, temperature, diseaseIdx, diseaseCount);
                conduitFlow.SetContents(cell, contents);

                if (conduitType == ConduitType.Liqud)
                {
                    updateLiquidFlowVisualization = true;
                }
                else
                {
                    updateGasFlowVisualization = true;
                }
            }

            return(true);
        }
示例#26
0
    protected override void OnCleanUp()
    {
        IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType);

        networkManager.RemoveFromNetworks(filteredCell, itemFilter, true);
        ConduitFlow flowManager = Conduit.GetFlowManager(portInfo.conduitType);

        flowManager.RemoveConduitUpdater(OnConduitTick);
        if (partitionerEntry.IsValid() && (UnityEngine.Object)GameScenePartitioner.Instance != (UnityEngine.Object)null)
        {
            GameScenePartitioner.Instance.Free(ref partitionerEntry);
        }
        base.OnCleanUp();
    }
示例#27
0
    private void OnConduitTick(float dt)
    {
        bool value = false;

        if (this.operational.IsOperational)
        {
            ConduitFlow gasFlow = Conduit.GetFlowManager(this.portInfo.conduitType);

            ConduitFlow.ConduitContents contentsI1 = gasFlow.GetContents(this.inputCell1);
            ConduitFlow.ConduitContents contentsI2 = gasFlow.GetContents(this.inputCell2);

            //Debug.Log("contentsI1.mass: " + contentsI1.mass);
            //Debug.Log("contentsI2.mass: " + contentsI2.mass);

            //int num = (contents.element != this.filteredElem) ? this.outputCell : this.filteredCell;
            ConduitFlow.ConduitContents contentsO = gasFlow.GetContents(this.outputCell);

            if (contentsI1.element != SimHashes.Hydrogen || contentsI2.element != SimHashes.Oxygen)
            {
                base.Trigger((int)GameHashes.DoBuildingDamage, new BuildingHP.DamageSourceInfo
                {
                    damage    = 1,
                    source    = STRINGS.BUILDINGS.DAMAGESOURCES.BAD_INPUT_ELEMENT,
                    popString = STRINGS.UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.WRONG_ELEMENT
                });
                gasFlow.RemoveElement(this.inputCell1, 0.111999989f);
                gasFlow.RemoveElement(this.inputCell2, 0.888f);
            }
            else
            {
                if (contentsI1.mass > 0.111999989f &&
                    contentsI2.mass > 0.888f &&
                    contentsO.mass <= 0f)
                {
                    value = true;
                    //float num2 = flowManager.AddElement(num, contents.element, contents.mass, contents.temperature, contents.diseaseIdx, contents.diseaseCount);
                    float outputTemperature = contentsI1.temperature * 0.111999989f + contentsI2.temperature * 0.888f;
                    //Debug.Log("outputTemperature: " + outputTemperature);
                    ConduitFlow liquidFlow = Conduit.GetFlowManager(ConduitType.Liquid);
                    float       num2       = liquidFlow.AddElement(this.outputCell, SimHashes.Water, 1f, outputTemperature, contentsI1.diseaseIdx, 0);
                    if (num2 > 0f)
                    {
                        gasFlow.RemoveElement(this.inputCell1, 0.111999989f);
                        gasFlow.RemoveElement(this.inputCell2, 0.888f);
                    }
                }
            }
        }
        this.operational.SetActive(value, false);
    }
示例#28
0
        private void UpdateConduitFlow(ConduitFlow conduitFlow)
        {
            var conduitType = Traverse.Create(conduitFlow).Field("conduitType").GetValue <ConduitType>();
            //Log.Spam($"Begin UpdateConduitFlow {conduitType}");

            var networks = Traverse.Create(conduitFlow).Field("networks").GetValue <IEnumerable>();

            foreach (var network in networks)
            {
                var cells = Traverse.Create(network).Field("cells").GetValue <List <int> >();

                UpdateConduitNetwork(conduitFlow, conduitType, cells);
            }

            //Log.Spam($"End UpdateConduitFlow {conduitType}");
        }
示例#29
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        inputCell  = building.GetUtilityInputCell();
        outputCell = building.GetUtilityOutputCell();
        int        cell          = Grid.PosToCell(base.transform.GetPosition());
        CellOffset rotatedOffset = building.GetRotatedOffset(portInfo.offset);

        filteredCell = Grid.OffsetCell(cell, rotatedOffset);
        IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType);

        itemFilter = new FlowUtilityNetwork.NetworkItem(portInfo.conduitType, Endpoint.Source, filteredCell, base.gameObject);
        networkManager.AddToNetworks(filteredCell, itemFilter, true);
        GetComponent <ConduitConsumer>().isConsuming = false;
        OnFilterChanged(filterable.SelectedTag);
        filterable.onFilterChanged += OnFilterChanged;
        ConduitFlow flowManager = Conduit.GetFlowManager(portInfo.conduitType);

        flowManager.AddConduitUpdater(OnConduitTick, ConduitFlowPriority.Default);
        GetComponent <KSelectable>().SetStatusItem(Db.Get().StatusItemCategories.Main, filterStatusItem, this);
        UpdateConduitExistsStatus();
        UpdateConduitBlockedStatus();
        ScenePartitionerLayer scenePartitionerLayer = null;

        switch (portInfo.conduitType)
        {
        case ConduitType.Gas:
            scenePartitionerLayer = GameScenePartitioner.Instance.gasConduitsLayer;
            break;

        case ConduitType.Liquid:
            scenePartitionerLayer = GameScenePartitioner.Instance.liquidConduitsLayer;
            break;

        case ConduitType.Solid:
            scenePartitionerLayer = GameScenePartitioner.Instance.solidConduitsLayer;
            break;
        }
        if (scenePartitionerLayer != null)
        {
            partitionerEntry = GameScenePartitioner.Instance.Add("ElementFilterConduitExists", base.gameObject, filteredCell, scenePartitionerLayer, delegate
            {
                UpdateConduitExistsStatus();
            });
        }
    }
示例#30
0
        protected override void ConduitUpdate(float dt)
        {
            int         cell        = Grid.PosToCell(this);
            ConduitFlow flowManager = Conduit.GetFlowManager(this.conduitType);

            this.currentValue = flowManager.GetContents(cell).mass * 1000;

            // spawn code should never toggle as it crashes on load
            if (dt < 0)
            {
                return;
            }

            if (this.activateAboveThreshold)
            {
                // Empty is always false
                if (this.currentValue <= 0f)
                {
                    if (base.IsSwitchedOn)
                    {
                        this.Toggle();
                    }
                    return;
                }

                // Full is always true
                if (this.currentValue >= this.max)
                {
                    if (!base.IsSwitchedOn)
                    {
                        this.Toggle();
                    }
                    return;
                }

                if ((this.currentValue > this.threshold && !base.IsSwitchedOn) || (this.currentValue <= this.threshold && base.IsSwitchedOn))
                {
                    this.Toggle();
                }
            }
            else if ((this.currentValue > this.threshold && base.IsSwitchedOn) || (this.currentValue <= this.threshold && !base.IsSwitchedOn))
            {
                this.Toggle();
            }
        }