コード例 #1
0
ファイル: ValveProcessBase.cs プロジェクト: kelmen/ONI-Mods
        protected virtual void OnConduitUpdate(float data)
        {
            if (!FlowMgr.HasConduit(this.InputCell) || !FlowMgr.HasConduit(this.OutputCell))
            {
            }
            else
            {
                ConduitFlow.Conduit         conduit  = FlowMgr.GetConduit(this.InputCell);
                ConduitFlow.ConduitContents contents = conduit.GetContents(FlowMgr);
                float massSrc = Mathf.Min(contents.mass, this.DesiredFlow);
                if (massSrc > 0)
                {
                    int disease_count = (int)((massSrc / contents.mass) * contents.diseaseCount);
                    var massMoved     = FlowMgr.AddElement(this.OutputCell, contents.element, massSrc, contents.temperature, contents.diseaseIdx, disease_count);
                    MassMoved += massMoved;
                    if (massMoved > 0)
                    {
                        FlowMgr.RemoveElement(this.InputCell, massMoved);

                        DesiredFlow -= massMoved;
                    }
                }
            }

            this.UpdateAnim();
        }
コード例 #2
0
        void OnConduitUpdate(float data)
        {
            try
            {
                bool setActive = false;
                this.UpdateConduitBlockedStatus();

                if (this.Operation.IsOperational)
                {
                    var inputContent = FlowMgr.GetContents(InputCell);
                    if ((inputContent.mass > 0) && (inputContent.element != SimHashes.Vacuum))
                    {
                        var filterData    = this;
                        int outputCellIdx = filterData.GetOutputRouteIdx(inputContent.temperature, this.OutputCell1, this.OutputCell2);

                        if (FlowMgr.IsConduitEmpty(outputCellIdx))
                        {
                            var outputContent = FlowMgr.GetContents(outputCellIdx);

                            /// ConduitFlow.AddElement() included these (similar) chks:
                            ///     (outputContent.mass >= this.ConduitMassMax)
                            ///     (!inputContent.element.Equals(outputContent.element))
                            ///

                            float elementMoved = FlowMgr.AddElement(outputCellIdx
                                                                    , inputContent.element, inputContent.mass, inputContent.temperature, inputContent.diseaseIdx, inputContent.diseaseCount);

                            if (elementMoved > 0)
                            {
                                FlowMgr.RemoveElement(this.InputCell, elementMoved);
                            }
                        }
                        //else
                        //{
                        //    /// partial transfer not catered in (core) ElementFilter.OnConduitTick, don't break core design.
                        //}
                    }
                }

                this.Operation.SetActive(setActive, false);
            }
            catch (Exception ex)
            {
                KelmenUtils.Log("TemperatureFilterProcess.OnConduitUpdate", ex);
                throw ex;
            }
        }