示例#1
0
        internal void ChangeFilledRatio(float newFilledRatio, bool updateSync = false)
        {
            m_nextGasTransfer = 0f;
            float oldFilledRatio = FilledRatio;

            if (oldFilledRatio != newFilledRatio || MySession.Static.CreativeMode)
            {
                if (!MySession.Static.CreativeMode || newFilledRatio > oldFilledRatio)
                {
                    if (updateSync)
                    {
                        this.ChangeFillRatioAmount(newFilledRatio);
                    }

                    FilledRatio = newFilledRatio;
                }

                if (MySession.Static.CreativeMode)
                {
                    SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, Capacity);
                }
                else
                {
                    SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, FilledRatio * Capacity);
                }

                ResourceSink.Update();
                UpdateEmissivity();
                UdpateText();
            }
        }
示例#2
0
        void VentToRoom(float amount)
        {
            if (amount == 0f || IsDepressurizing)
            {
                return;
            }

            Debug.Assert(!IsDepressurizing, "Vent asked to vent when it is supposed to depressurize");
            Debug.Assert(amount >= 0f);

            var oxygenBlock = GetOxygenBlock();

            if (oxygenBlock.Room == null || !oxygenBlock.Room.IsPressurized)
            {
                return;
            }

            oxygenBlock.Room.OxygenAmount += amount;
            if (oxygenBlock.Room.OxygenLevel(CubeGrid.GridSize) > 1f)
            {
                oxygenBlock.Room.OxygenAmount = oxygenBlock.Room.MaxOxygen(CubeGrid.GridSize);
            }

            SourceComp.SetRemainingCapacityByType(m_oxygenGasId, (float)oxygenBlock.Room.OxygenAmount);

            m_nextGasTransfer = 0;

            if (amount > 0)
            {
                m_producedSinceLastUpdate = true;
            }
        }
示例#3
0
        public override void UpdateAfterSimulation100()
        {
            base.UpdateAfterSimulation100();

            if (Sync.IsServer && IsWorking)
            {
                UpdateActions();
            }

            if (m_playVentEffect == false)
            {
                if (m_effect != null)
                {
                    m_effect.Stop();
                    m_effect = null;
                }
            }

            m_isProducing             = m_producedSinceLastUpdate;
            m_producedSinceLastUpdate = false;
            m_playVentEffect          = false;
            var block = GetOxygenBlock();

            int sourceUpdateFrames = (MySession.Static.GameplayFrameCounter - m_lastOutputUpdateTime);
            int sinkUpdateFrames   = (MySession.Static.GameplayFrameCounter - m_lastInputUpdateTime);

            m_lastOutputUpdateTime = MySession.Static.GameplayFrameCounter;
            m_lastInputUpdateTime  = MySession.Static.GameplayFrameCounter;

            float gasInput      = GasInputPerUpdate * sinkUpdateFrames;
            float gasOutput     = GasOutputPerUpdate * sourceUpdateFrames;
            float totalTransfer = gasInput - gasOutput + m_nextGasTransfer;

            if (totalTransfer != 0f)
            {
                Transfer(totalTransfer);
            }

            SourceComp.SetRemainingCapacityByType(m_oxygenGasId, (float)(block.Room != null && block.Room.IsPressurized ? block.Room.OxygenAmount : (MyOxygenProviderSystem.GetOxygenInPoint(WorldMatrix.Translation) != 0 ? BlockDefinition.VentilationCapacityPerSecond * 100 : 0f)));

            ResourceSink.Update();

            UpdateTexts();
            UpdateEmissivity();

            if (MyFakes.ENABLE_OXYGEN_SOUNDS)
            {
                UpdateSound();
            }
        }
示例#4
0
        void DrainFromRoom(float amount)
        {
            if (amount == 0f || !IsDepressurizing)
            {
                return;
            }

            Debug.Assert(IsDepressurizing, "Vent asked to depressurize when it is supposed to pressurize");
            Debug.Assert(amount >= 0f);

            var   oxygenBlock  = GetOxygenBlock();
            float oxygenInRoom = oxygenBlock.Room == null ? 0f : (float)oxygenBlock.Room.OxygenAmount;

            if (oxygenBlock.Room == null)
            {
                return;
            }

            if (oxygenBlock.Room.IsPressurized)
            {
                SourceComp.SetRemainingCapacityByType(m_oxygenGasId, oxygenInRoom);
                oxygenBlock.Room.OxygenAmount -= amount;
                if (oxygenBlock.Room.OxygenAmount < 0f)
                {
                    oxygenBlock.Room.OxygenAmount = 0f;
                }
            }
            //Take from environment
            else
            {
                float oxygenInEnvironment = MyOxygenProviderSystem.GetOxygenInPoint(WorldMatrix.Translation) != 0 ? BlockDefinition.VentilationCapacityPerSecond * 100 : 0f;
                SourceComp.SetRemainingCapacityByType(m_oxygenGasId, oxygenInEnvironment);
                m_producedSinceLastUpdate = true;
            }
            if (amount > 0)//some oxygen were vented
            {
                m_producedSinceLastUpdate = true;
                if (amount > 1)//enough oxygen were vented for sound and effects
                {
                    m_playVentEffect = true;
                    if (m_effect == null)//create air vent effect
                    {
                        CreateEffect();
                    }
                }
            }

            m_nextGasTransfer = 0f;
        }
示例#5
0
        void RemainingCapacityChanged()
        {
            var before = IsWorking;

            SourceComp.SetRemainingCapacityByType(MyResourceDistributorComponent.ElectricityId, m_remainingPowerCapacity);
            UpdateMaxOutputAndEmissivity();

            if (!before && IsWorking)
            {
                OnStartWorking();
            }
            else if (before && !IsWorking)
            {
                OnStopWorking();
            }
        }
示例#6
0
        public override void UpdateAfterSimulation100()
        {
            base.UpdateAfterSimulation100();

            if (m_producedSinceLastUpdate)
            {
                if (m_effect == null)
                {
                    CreateEffect();
                }
            }
            else
            {
                if (m_effect != null)
                {
                    m_effect.Stop();
                    m_effect = null;
                }
            }

            if (MyFakes.ENABLE_OXYGEN_SOUNDS)
            {
                UpdateSound();
            }

            m_isProducing             = m_producedSinceLastUpdate;
            m_producedSinceLastUpdate = false;
            var block = GetOxygenBlock();

            int sourceUpdateFrames = (m_updateCounter - m_lastOutputUpdateTime);
            int sinkUpdateFrames   = (m_updateCounter - m_lastInputUpdateTime);

            float gasInput      = GasInputPerUpdate * sinkUpdateFrames;
            float gasOutput     = GasOutputPerUpdate * sourceUpdateFrames;
            float totalTransfer = gasInput - gasOutput + m_nextGasTransfer;

            Transfer(totalTransfer);

            SourceComp.SetRemainingCapacityByType(m_oxygenGasId, (float)(block.Room != null ? block.Room.OxygenAmount : 0));

            m_updateCounter        = 0;
            m_lastOutputUpdateTime = m_updateCounter;
            m_lastInputUpdateTime  = m_updateCounter;
            ResourceSink.Update();

            UdpateTexts();
        }
示例#7
0
        internal void ChangeFilledRatio(float newFilledRatio, bool updateSync = false)
        {
            m_nextGasTransfer = 0f;
            float oldFilledRatio = FilledRatio;

            if (oldFilledRatio != newFilledRatio)
            {
                if (updateSync)
                {
                    SyncObject.ChangeFillRatioAmount(newFilledRatio);
                }
                FilledRatio = newFilledRatio;
                SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, FilledRatio * Capacity);
                ResourceSink.Update();
                UpdateEmissivity();
                UdpateText();
            }
        }
示例#8
0
        void VentToRoom(float amount)
        {
            if (amount == 0f || IsDepressurizing)
            {
                return;
            }

            Debug.Assert(!IsDepressurizing, "Vent asked to vent when it is supposed to depressurize");
            Debug.Assert(amount >= 0f);

            var oxygenBlock = GetOxygenBlock();

            if (oxygenBlock.Room == null || !oxygenBlock.Room.IsPressurized)
            {
                return;
            }

            oxygenBlock.Room.OxygenAmount += amount;
            if (oxygenBlock.Room.OxygenLevel(CubeGrid.GridSize) > 1f)
            {
                oxygenBlock.Room.OxygenAmount = oxygenBlock.Room.MaxOxygen(CubeGrid.GridSize);
            }

            SourceComp.SetRemainingCapacityByType(m_oxygenGasId, (float)oxygenBlock.Room.OxygenAmount);

            m_nextGasTransfer = 0;

            if (amount > 0)//some oxygen were vented
            {
                m_producedSinceLastUpdate = true;
                if (amount > 1)//enough oxygen were vented for sound and effects
                {
                    m_playVentEffect = true;
                    if (m_effect == null)//create air vent effect
                    {
                        CreateEffect();
                    }
                }
            }
        }
示例#9
0
        void DrainFromRoom(float amount)
        {
            if (amount == 0f || !IsDepressurizing)
            {
                return;
            }

            Debug.Assert(IsDepressurizing, "Vent asked to depressurize when it is supposed to pressurize");
            Debug.Assert(amount >= 0f);

            var   oxygenBlock  = GetOxygenBlock();
            float oxygenInRoom = oxygenBlock.Room == null ? 0f : (float)oxygenBlock.Room.OxygenAmount;

            SourceComp.SetRemainingCapacityByType(m_oxygenGasId, oxygenInRoom);
            if (oxygenBlock.Room == null)
            {
                return;
            }

            if (oxygenBlock.Room.IsPressurized)
            {
                oxygenBlock.Room.OxygenAmount -= amount;
                if (oxygenBlock.Room.OxygenAmount < 0f)
                {
                    oxygenBlock.Room.OxygenAmount = 0f;
                }

                if (amount > 0)
                {
                    m_producedSinceLastUpdate = true;
                }
            }
            else
            {
                //Take from environment, nothing to do
                m_producedSinceLastUpdate = true;
            }

            m_nextGasTransfer = 0f;
        }
示例#10
0
        void ComponentStack_IsFunctionalChanged()
        {
            SourceComp.Enabled = CanStore;
            ResourceSink.Update();
            FilledRatio = 0;

            if (MySession.Static.CreativeMode)
            {
                SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, Capacity);
            }
            else
            {
                SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, FilledRatio * Capacity);
            }

            // ResourceDistributor could be null if the grid is falling apart for whatever reason (collisions, explosions, etc)
            if (CubeGrid != null && CubeGrid.GridSystems != null && CubeGrid.GridSystems.ResourceDistributor != null)
            {
                CubeGrid.GridSystems.ResourceDistributor.ConveyorSystem_OnPoweredChanged(); // Hotfix TODO
            }
            UdpateText();
        }
示例#11
0
        internal void ChangeFilledRatio(float newFilledRatio, bool updateSync = false)
        {
            float oldFilledRatio = FilledRatio;

            if (oldFilledRatio != newFilledRatio || MySession.Static.CreativeMode)
            {
                if (!MySession.Static.CreativeMode)
                {
                    if (updateSync)
                    {
                        this.ChangeFillRatioAmount(newFilledRatio);
                        return;
                    }

                    FilledRatio = newFilledRatio;
                }
                else
                {
                    //AB: In creative we allways have 50% filled so we can recieve and send gas
                    FilledRatio = 0.5f;
                }

                if (MySession.Static.CreativeMode && newFilledRatio > oldFilledRatio)
                {
                    SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, Capacity);
                }
                else
                {
                    SourceComp.SetRemainingCapacityByType(BlockDefinition.StoredGasId, FilledRatio * Capacity);
                }

                ResourceSink.Update();
                UpdateEmissivity();
                UpdateText();
            }
        }