private void OnThermoMachineLeaveAtmosphere(EntityUid uid, GasThermoMachineComponent component, AtmosDeviceDisabledEvent args) { if (ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance)) { appearance.SetData(ThermoMachineVisuals.Enabled, false); } }
private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, AtmosDeviceUpdateEvent args) { var appearance = thermoMachine.Owner.GetComponentOrNull <AppearanceComponent>(); appearance?.SetData(ThermoMachineVisuals.Enabled, false); if (!thermoMachine.Enabled) { return; } if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)) { return; } if (!nodeContainer.TryGetNode(thermoMachine.InletName, out PipeNode? inlet)) { return; } var airHeatCapacity = _atmosphereSystem.GetHeatCapacity(inlet.Air); var combinedHeatCapacity = airHeatCapacity + thermoMachine.HeatCapacity; var oldTemperature = inlet.Air.Temperature; if (combinedHeatCapacity > 0) { appearance?.SetData(ThermoMachineVisuals.Enabled, true); var combinedEnergy = thermoMachine.HeatCapacity * thermoMachine.TargetTemperature + airHeatCapacity * inlet.Air.Temperature; inlet.Air.Temperature = combinedEnergy / combinedHeatCapacity; } // TODO ATMOS: Active power usage. }
private void OnChangeTemperature(EntityUid uid, GasThermoMachineComponent component, GasThermomachineChangeTemperatureMessage args) { component.TargetTemperature = Math.Clamp(args.Temperature, component.MinTemperature, component.MaxTemperature); DirtyUI(uid, component); }
private void OnGasThermoRefreshParts(EntityUid uid, GasThermoMachineComponent component, RefreshPartsEvent args) { // Here we evaluate the average quality of relevant machine parts. var nLasers = 0; var nBins = 0; var matterBinRating = 0; var laserRating = 0; foreach (var part in args.Parts) { switch (part.PartType) { case MachinePart.MatterBin: nBins += 1; matterBinRating += part.Rating; break; case MachinePart.Laser: nLasers += 1; laserRating += part.Rating; break; } } laserRating /= nLasers; matterBinRating /= nBins; component.HeatCapacity = 5000 * MathF.Pow(matterBinRating, 2); switch (component.Mode) { // 593.15K with stock parts. case ThermoMachineMode.Heater: component.MaxTemperature = component.BaseMaxTemperature + component.MaxTemperatureDelta * laserRating; component.MinTemperature = Atmospherics.T20C; break; // 73.15K with stock parts. case ThermoMachineMode.Freezer: component.MinTemperature = MathF.Max( component.BaseMinTemperature - component.MinTemperatureDelta * laserRating, Atmospherics.TCMB); component.MaxTemperature = Atmospherics.T20C; break; } DirtyUI(uid, component); }
private void OnGasThermoRefreshParts(EntityUid uid, GasThermoMachineComponent component, RefreshPartsEvent args) { var matterBinRating = 0; var laserRating = 0; foreach (var part in args.Parts) { switch (part.PartType) { case MachinePart.MatterBin: matterBinRating += part.Rating; break; case MachinePart.Laser: laserRating += part.Rating; break; } } component.HeatCapacity = 5000 * MathF.Pow((matterBinRating - 1), 2); switch (component.Mode) { // 573.15K with stock parts. case ThermoMachineMode.Heater: component.MaxTemperature = Atmospherics.T20C + (component.InitialMaxTemperature * laserRating); break; // 73.15K with stock parts. case ThermoMachineMode.Freezer: component.MinTemperature = MathF.Max(Atmospherics.T0C - component.InitialMinTemperature + laserRating * 15f, Atmospherics.TCMB); break; } DirtyUI(uid, component); }
private void OnToggleMessage(EntityUid uid, GasThermoMachineComponent component, GasThermomachineToggleMessage args) { component.Enabled = !component.Enabled; DirtyUI(uid, component); }