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(); } }
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; } }
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(); } }
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; }
void RemainingCapacityChanged() { var before = IsWorking; SourceComp.SetRemainingCapacityByType(MyResourceDistributorComponent.ElectricityId, m_remainingPowerCapacity); UpdateMaxOutputAndEmissivity(); if (!before && IsWorking) { OnStartWorking(); } else if (before && !IsWorking) { OnStopWorking(); } }
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(); }
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(); } }
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(); } } } }
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; }
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(); }
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(); } }