コード例 #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
            {
                if (!this.Operation.IsOperational)
                {
                    return;
                }

                if (FlowMgr.HasConduit(InputCell) && FlowMgr.HasConduit(OutputCell1) && FlowMgr.HasConduit(OutputCell2)
                    &&
                    FlowMgr.IsConduitFull(InputCell)
                    //&& FlowMgr.IsConduitEmpty(OutputCell1) && FlowMgr.IsConduitEmpty(OutputCell2)
                    )
                {
                }
                else
                {
                    return;
                }

                var inputContent = FlowMgr.GetPickupable(FlowMgr.GetContents(InputCell).pickupableHandle);
                //var inputContent = FlowMgr.RemovePickupable(InputCell);
                if (inputContent == null)
                {
                    return;
                }

                var inputContent2 = inputContent.PrimaryElement;
                if (inputContent2 == null)
                {
                    return;
                }

                var filterData    = this;
                int outputCellIdx = filterData.GetOutputRouteIdx(inputContent2.Temperature, this.OutputCell1, this.OutputCell2);

                if (outputCellIdx == OutputCell1)
                {
                    if (FlowMgr.IsConduitFull(OutputCell1))
                    {
                        return;
                    }
                    else //if (outputCellIdx == OutputCell2)
                    if (FlowMgr.IsConduitFull(OutputCell2))
                    {
                        return;
                    }
                }

                //var outputTgt = FlowMgr.GetContents(outputCellIdx);
                //if (outputTgt.pickupableHandle.IsValid())
                //    return;

                inputContent = FlowMgr.RemovePickupable(InputCell);
                FlowMgr.AddPickupable(outputCellIdx, inputContent);

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