public override void TickRare() { if (this.TryGetComp <CompGasTrader>(out var gas)) { if (!gas.GasOn) { return; } float ambient = AmbientTemperature; float efficiency = Mathf.InverseLerp(120, 20, ambient); float maxEnergy = compTempControl.Props.energyPerSecond * efficiency * MAGIC_NUMBER_ALPHA; float energyUsed = GenTemperature.ControlTemperatureTempChange(Position, Map, maxEnergy, compTempControl.targetTemperature); if (Mathf.Approximately(energyUsed, 0)) { gas.GasConsumption = gas.Props.gasConsumption * compTempControl.Props.lowPowerConsumptionFactor; } else { gas.GasConsumption = gas.Props.gasConsumption; this.GetRoomGroup().Temperature += energyUsed; } } else { // TODO: why is base.TickRare() conditional? base.TickRare(); } }
private void ControlTemperature() { var temperature = roomNorth.Temperature; float energyMod; if (temperature < 20f) { energyMod = 1f; } else { energyMod = temperature > 120f ? 0f : Mathf.InverseLerp(120f, 20f, temperature); } var energyLimit = compTempControl.Props.energyPerSecond * energyMod * 4.16666651f; var hotAir = GenTemperature.ControlTemperatureTempChange(vecNorth, this.Map, energyLimit, compTempControl.targetTemperature); var hotIsHot = !Mathf.Approximately(hotAir, 0f); if (hotIsHot) { roomNorth.Temperature += hotAir; WorkingState = true; } else { WorkingState = false; } }
public override void Tick() { base.Tick(); if (this.compPowerTrader.PowerOn) { timeTillEval--; if (timeTillEval <= 0) { IntVec3 intVec3_1 = this.Position + IntVec3.North.RotatedBy(this.Rotation); IntVec3 intVec3_2 = this.Position + IntVec3.South.RotatedBy(this.Rotation); IntVec3 intVec3_3 = this.Position + (IntVec3.South.RotatedBy(this.Rotation) * 2); IntVec3 intVec3_4 = this.Position + (IntVec3.South.RotatedBy(this.Rotation) * 3); bool flag = false; if (!intVec3_4.Impassable(this.Map) && !intVec3_3.Impassable(this.Map) && !intVec3_2.Impassable(this.Map) && !intVec3_1.Impassable(this.Map)) { float temperature1 = intVec3_2.GetTemperature(this.Map); float temperature2 = intVec3_1.GetTemperature(this.Map); float num1 = temperature1 - temperature2; if ((double)temperature1 - 40.0 > (double)num1) { num1 = temperature1 - 40f; } float num2 = (float)(1.0 - (double)num1 * (1.0 / 130.0)); if ((double)num2 < 0.0) { num2 = 0.0f; } float energyLimit = (float)(((double)this.compTempControl.Props.energyPerSecond) * (double)num2 * 4.16666650772095); float a = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature); flag = !Mathf.Approximately(a, 0.0f); if (flag) { intVec3_1.GetRoomGroup(this.Map).Temperature += a; GenTemperature.PushHeat(intVec3_2, this.Map, (float)(-(double)energyLimit * 1.25)); GenTemperature.PushHeat(intVec3_3, this.Map, (float)(-(double)energyLimit * 1.25)); GenTemperature.PushHeat(intVec3_4, this.Map, (float)(-(double)energyLimit * 1.25)); } } CompProperties_Power props = this.compPowerTrader.Props; if (flag) { this.compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor; } this.compTempControl.operatingAtHighPower = flag; unfoldComponent.Target = flag ? 1.0f : 0.0f; timeTillEval = EVAL_TIME; } } else { unfoldComponent.Target = 0.0f; } }
private void ControlTemperature() { var temperature = Position.GetTemperature(); float energyMod; if (temperature < 20f) { energyMod = 1f; } else { energyMod = temperature > 120f ? 0f : Mathf.InverseLerp(120f, 20f, temperature); } var energyLimit = compTempControl.Props.energyPerSecond * energyMod * 4.16666651f; var hotAir = GenTemperature.ControlTemperatureTempChange(Position, energyLimit, compTempControl.targetTemperature); var hotIsHot = !Mathf.Approximately(hotAir, 0f); if (hotIsHot) { Position.GetRoom().Temperature += hotAir; compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption; } else { compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption * compTempControl.Props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = hotIsHot; }
public override void TickRare() { if (this.compPowerTrader.PowerOn) { float ambientTemperature = base.AmbientTemperature; float num; if (ambientTemperature < 20f) { num = 1f; } else if (ambientTemperature > 120f) { num = 0f; } else { num = Mathf.InverseLerp(120f, 20f, ambientTemperature); } float energyLimit = this.compTempControl.Props.energyPerSecond * num * 4.16666651f; float num2 = GenTemperature.ControlTemperatureTempChange(base.Position, base.Map, energyLimit, this.compTempControl.targetTemperature); bool flag = !Mathf.Approximately(num2, 0f); CompProperties_Power props = this.compPowerTrader.Props; if (flag) { this.GetRoomGroup().Temperature += num2; this.compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor; } this.compTempControl.operatingAtHighPower = flag; } }
public override void Tick() { base.TickRare(); long now = DateTime.Now.Ticks; if (now - lastTick > Settings.RepairAttachmentUpdateIntervalTicks) { //Log.Warning("Tick: [" + (int)((now - lastTick) / TimeSpan.TicksPerMillisecond) + "] milliseconds"); lastTick = DateTime.Now.Ticks; if (!this.compPowerTrader.PowerOn) { // Power is off if (beingRepaird != null) { this.StopRepairing(); } } else if (this.beingRepaird == null) { // Power is on and not repairing anything if (now - lastSearch > THIRTY_SECONDS) { lastSearch = now; this.StartRepairing(); } } else if ( this.beingRepaird != null && this.beingRepaird.HitPoints >= this.beingRepaird.MaxHitPoints) { // Power is on // Repairing something // Apparel is fully repaired this.beingRepaird.HitPoints = this.beingRepaird.MaxHitPoints; this.StopRepairing(); lastSearch = now; this.StartRepairing(); } if (this.beingRepaird != null) { this.beingRepaird.HitPoints += Settings.RepairAttachmentMendingSpeed; if (this.beingRepaird.HitPoints > this.beingRepaird.MaxHitPoints) { this.beingRepaird.HitPoints = this.beingRepaird.MaxHitPoints; } float generatedHeat = GenTemperature.ControlTemperatureTempChange( base.Position, base.Map, 10, float.MaxValue); this.GetRoom(RegionType.Set_All).Temperature += generatedHeat; this.compPowerTrader.PowerOutput = -this.compPowerTrader.Props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = LOW_POWER_COST; } } }
public override void Tick() { base.Tick(); if (!this.IsHashIntervalTick(60)) { return; } if (!compPowerTrader.PowerOn) { return; } //None changed var intVec = Position + IntVec3.South.RotatedBy(Rotation); var intVec2 = Position + IntVec3.North.RotatedBy(Rotation); var flag = false; if (!intVec2.Impassable(this.Map) && !intVec.Impassable(this.Map)) { var temperature = intVec2.GetTemperature(this.Map); var temperature2 = intVec.GetTemperature(this.Map); var num = temperature - temperature2; if (temperature - 40f > num) { num = temperature - 40f; } var num2 = 1f - num * 0.0076923077f; if (num2 < 0f) { num2 = 0f; } var num3 = compTempControl.Props.energyPerSecond * num2 * 4.16666651f; var num4 = GenTemperature.ControlTemperatureTempChange(intVec, this.Map, num3, compTempControl.targetTemperature); flag = !Mathf.Approximately(num4, 0f); if (flag) { intVec.GetRoom(this.Map).Group.Temperature += num4; GenTemperature.PushHeat(intVec2, this.Map, -num3 * 1.25f); } } if (flag) { compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption; } else { compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption * compTempControl.Props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = flag; }
public override void TickRare() { if (this.compPowerTrader.PowerOn) { IntVec3 vecNorth = base.Position + IntVec3.North.RotatedBy(base.Rotation); bool hotIsHot = false; Room roomNorth = vecNorth.GetRoom(this.Map); if (!vecNorth.Impassable(base.Map) && (roomNorth != null)) { var temperature = roomNorth.Temperature; float energyMod; if (temperature < 20f) { energyMod = 1f; } else { energyMod = temperature > 120f ? 0f : Mathf.InverseLerp(120f, 20f, temperature); } var energyLimit = compTempControl.Props.energyPerSecond * energyMod * 4.16666651f; if (temperature > this.compTempControl.targetTemperature) { energyLimit *= -1; } var hotAir = GenTemperature.ControlTemperatureTempChange(vecNorth, this.Map, energyLimit, compTempControl.targetTemperature); hotIsHot = !Mathf.Approximately(hotAir, 0f); if (hotIsHot) { vecNorth.GetRoomGroup(base.Map).Temperature += hotAir; } } CompProperties_Power props = this.compPowerTrader.Props; if (hotIsHot) { this.compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor; } this.compTempControl.operatingAtHighPower = hotIsHot; } }
public override void Tick() { if (this.IsHashIntervalTick(250)) { if (compRefuelable.HasFuel) { float ambientTemperature = base.AmbientTemperature; float num = (ambientTemperature < 20f) ? 1f : ((!(ambientTemperature > 120f)) ? Mathf.InverseLerp(120f, 20f, ambientTemperature) : 0f); float energyLimit = compTempControl.Props.energyPerSecond * num * 4.16666651f; float num2 = GenTemperature.ControlTemperatureTempChange(base.Position, base.Map, energyLimit, compTempControl.targetTemperature); bool flag = !Mathf.Approximately(num2, 0f); compTempControl.operatingAtHighPower = flag; this.GetRoomGroup().Temperature += num2; } } }
public override void TickRare() { if (!compPowerTrader.PowerOn) { return; } IntVec3 intVec = base.Position + IntVec3.South.RotatedBy(base.Rotation); IntVec3 intVec2 = base.Position + IntVec3.North.RotatedBy(base.Rotation); bool flag = false; if (!intVec2.Impassable(base.Map) && !intVec.Impassable(base.Map)) { float temperature = intVec2.GetTemperature(base.Map); float temperature2 = intVec.GetTemperature(base.Map); float num = temperature - temperature2; if (temperature - 40f > num) { num = temperature - 40f; } float num2 = 1f - num * 0.0076923077f; if (num2 < 0f) { num2 = 0f; } float num3 = compTempControl.Props.energyPerSecond * num2 * 4.16666651f; float num4 = GenTemperature.ControlTemperatureTempChange(intVec, base.Map, num3, compTempControl.targetTemperature); flag = !Mathf.Approximately(num4, 0f); if (flag) { intVec.GetRoomGroup(base.Map).Temperature += num4; GenTemperature.PushHeat(intVec2, base.Map, (0f - num3) * 1.25f); } } CompProperties_Power props = compPowerTrader.Props; if (flag) { compPowerTrader.PowerOutput = 0f - props.basePowerConsumption; } else { compPowerTrader.PowerOutput = (0f - props.basePowerConsumption) * compTempControl.Props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = flag; }
private void ControlTemperature() { //Average of exhaust ports' room temperature var tempHotAvg = activeExhausts.Sum(s => s.VecNorth.GetTemperature()) / activeExhausts.Count; //Cooler's temperature var tempCold = roomSouth.Temperature; var tempDiff = tempHotAvg - tempCold; if (tempHotAvg - tempDiff > 40.0) { tempDiff = tempHotAvg - 40f; } var num2 = 1.0 - tempDiff * (1.0 / 130.0); if (num2 < 0.0) { num2 = 0.0f; } var energyLimit = (float)(Energy * activeExhausts.Count * num2 * 4.16666650772095); var coldAir = GenTemperature.ControlTemperatureTempChange(vecSouth, energyLimit, compTempControl.targetTemperature); isWorking = !Mathf.Approximately(coldAir, 0.0f); if (!isWorking) { return; } roomSouth.Temperature += coldAir; var hotAir = (float)(-energyLimit * 1.25 / activeExhausts.Count); if (Mathf.Approximately(hotAir, 0.0f)) { return; } foreach (var current in activeExhausts) { current.PushHeat(hotAir); } }
public override void Tick() { if (!this.IsHashIntervalTick(60)) { return; } if (!compPowerTrader.PowerOn) { return; } //None changed var temperature = Position.GetTemperature(); float num; if (temperature < 20f) { num = 1f; } else if (temperature > 120f) { num = 0f; } else { num = Mathf.InverseLerp(120f, 20f, temperature); } var energyLimit = compTempControl.props.energyPerSecond * num * 4.16666651f; var num2 = GenTemperature.ControlTemperatureTempChange(Position, energyLimit, compTempControl.targetTemperature); var flag = !Mathf.Approximately(num2, 0f); if (flag) { Position.GetRoom().Temperature += num2; compPowerTrader.PowerOutput = -compPowerTrader.props.basePowerConsumption; } else { compPowerTrader.PowerOutput = -compPowerTrader.props.basePowerConsumption * compTempControl.props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = flag; }
public override void TickRare() { if (base.compPowerTrader.PowerOn) { IntVec3 intVec = base.Position + IntVec3.South.RotatedBy(base.Rotation); IntVec3 intVec2 = base.Position + IntVec3.North.RotatedBy(base.Rotation); bool flag = false; if (!intVec2.Impassable(base.Map) && !intVec.Impassable(base.Map)) { float temperature = intVec2.GetTemperature(base.Map); float temperature2 = intVec.GetTemperature(base.Map); float num = temperature - temperature2; if (temperature - 40.0 > num) { num = (float)(temperature - 40.0); } float num2 = (float)(1.0 - num * 0.0076923076994717121); if (num2 < 0.0) { num2 = 0f; } float num3 = (float)(base.compTempControl.Props.energyPerSecond * num2 * 4.1666665077209473); float num4 = GenTemperature.ControlTemperatureTempChange(intVec, base.Map, num3, base.compTempControl.targetTemperature); flag = !Mathf.Approximately(num4, 0f); if (flag) { intVec.GetRoomGroup(base.Map).Temperature += num4; GenTemperature.PushHeat(intVec2, base.Map, (float)((0.0 - num3) * 1.25)); } } CompProperties_Power props = base.compPowerTrader.Props; if (flag) { base.compPowerTrader.PowerOutput = (float)(0.0 - props.basePowerConsumption); } else { base.compPowerTrader.PowerOutput = (float)((0.0 - props.basePowerConsumption) * base.compTempControl.Props.lowPowerConsumptionFactor); } base.compTempControl.operatingAtHighPower = flag; } }
public override void TickRare() { if (this.compPowerTrader.PowerOn) { IntVec3 intVec = Position + IntVec3.South.RotatedBy(Rotation); IntVec3 intVec2 = Position + IntVec3.North.RotatedBy(Rotation); bool flag = false; if (!intVec2.Impassable() && !intVec.Impassable()) { float temperature = intVec2.GetTemperature(); float temperature2 = intVec.GetTemperature(); float num = temperature - temperature2; //if (temperature - 40f > num) //{ // num = temperature - 40f; //} float num2 = 1f - num * 0.0076923077f; if (num2 < 0f) { num2 = 0f; } float num3 = this.compTempControl.Props.energyPerSecond * num2 * 4.16666651f; float num4 = GenTemperature.ControlTemperatureTempChange(intVec, num3, this.compTempControl.targetTemperature); flag = !Mathf.Approximately(num4, 0f); if (flag) { intVec.GetRoom().Temperature += num4; GenTemperature.PushHeat(intVec2, -num3 * 1.25f); } } CompProperties_Power props = this.compPowerTrader.Props; if (flag) { this.compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor; } this.compTempControl.operatingAtHighPower = flag; } }
public override void TickLong() { if (!this.compPowerTrader.PowerOn) { // Power is off if (BeingRepaird != null) { this.StopRepairing(); } } else if (this.BeingRepaird == null) { // Power is on and not repairing anything this.StartRepairing(); } else if ( this.BeingRepaird != null && this.BeingRepaird.HitPoints == this.BeingRepaird.MaxHitPoints) { // Power is on // Repairing something // Apparel is fully repaired this.StopRepairing(); this.StartRepairing(); } if (this.BeingRepaird != null) { this.BeingRepaird.HitPoints += 1; float generatedHeat = GenTemperature.ControlTemperatureTempChange( base.Position, base.Map, 10, float.MaxValue); this.GetRoomGroup().Temperature += generatedHeat; this.compPowerTrader.PowerOutput = -this.compPowerTrader.Props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = LOW_POWER_COST; } }
public override void TickRare() { if (compPowerTrader.PowerOn) { var energyLimit = compTempControl.Props.energyPerSecond; var tempChange = GenTemperature.ControlTemperatureTempChange(Position, Map, energyLimit, compTempControl.targetTemperature); var isChangingTemp = !Mathf.Approximately(tempChange, 0f); var props = compPowerTrader.Props; if (isChangingTemp) { this.GetRoomGroup().Temperature += tempChange; compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { compPowerTrader.PowerOutput = -props.basePowerConsumption * compTempControl.Props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = isChangingTemp; } }
public override void TickRare() { if (base.compPowerTrader.PowerOn) { float ambientTemperature = base.AmbientTemperature; float num = (float)((!(ambientTemperature < 20.0)) ? ((!(ambientTemperature > 120.0)) ? Mathf.InverseLerp(120f, 20f, ambientTemperature) : 0.0) : 1.0); float energyLimit = (float)(base.compTempControl.Props.energyPerSecond * num * 4.1666665077209473); float num2 = GenTemperature.ControlTemperatureTempChange(base.Position, base.Map, energyLimit, base.compTempControl.targetTemperature); bool flag = !Mathf.Approximately(num2, 0f); CompProperties_Power props = base.compPowerTrader.Props; if (flag) { this.GetRoomGroup().Temperature += num2; base.compPowerTrader.PowerOutput = (float)(0.0 - props.basePowerConsumption); } else { base.compPowerTrader.PowerOutput = (float)((0.0 - props.basePowerConsumption) * base.compTempControl.Props.lowPowerConsumptionFactor); } base.compTempControl.operatingAtHighPower = flag; } }
public override void TickRare() { var PowerTrader = CompPowerTrader; if (PowerTrader.PowerOn) { var TempControl = CompTempControl; float temperature = Position.GetTemperature(); float num; if (temperature < 20f) { num = 1f; } else if (temperature > 120f) { num = 0f; } else { num = Mathf.InverseLerp(120f, 20f, temperature); } float energyLimit = TempControl.props.energyPerSecond * num * 4.16666651f; float num2 = GenTemperature.ControlTemperatureTempChange(Position, energyLimit, TempControl.targetTemperature); bool flag = !Mathf.Approximately(num2, 0f); if (flag) { Position.GetRoom().Temperature += num2; PowerTrader.PowerOutput = -PowerTrader.props.basePowerConsumption; } else { PowerTrader.PowerOutput = -PowerTrader.props.basePowerConsumption * PowerTrader.props.lowPowerConsumptionFactor; } TempControl.operatingAtHighPower = flag; } }
public override void TickRare() { if (this.compFlickable.SwitchIsOn) { float ambientTemperature = base.AmbientTemperature; float num; if (ambientTemperature > this.compTempControl.targetTemperature - 1f && ambientTemperature < this.compTempControl.targetTemperature + 1f) { num = 0f; } else if (ambientTemperature < this.compTempControl.targetTemperature - 1f) { if (ambientTemperature < 20f) { num = 1f; } else if (ambientTemperature > 1000f) { num = 0f; } else { num = Mathf.InverseLerp(1000f, 100f, ambientTemperature); } } else if (ambientTemperature > this.compTempControl.targetTemperature + 1f) { if (ambientTemperature < -50f) { num = -Mathf.InverseLerp(-273f, -50f, ambientTemperature); } else { num = -1f; } } else { num = 0f; } float energyLimit = this.compTempControl.prop.energyPerSecond * num * 4.16666651f; float num2 = GenTemperature.ControlTemperatureTempChange(base.Position, base.Map, energyLimit, this.compTempControl.targetTemperature); bool flag = !Mathf.Approximately(num2, 0f); if (flag) { this.energyCostPerSec = compTempControl.prop.energyCostPerSec; if (netPort.TryGetEnergy(energyCostPerSec)) { this.GetRoomGroup().Temperature += num2; powerOn = true; } else { powerOn = false; } } else { this.energyCostPerSec = compTempControl.prop.energyCostPerSec * this.compTempControl.prop.lowPowerConsumptionFactor; if (netPort.TryGetEnergy(energyCostPerSec)) { powerOn = true; } else { powerOn = false; } } this.compTempControl.operatingAtHighPower = flag; } }
/// <summary> /// Tick function for Air Vents /// Main code for chaning temperature at the Rooms. We take the Converted Temperature from the Air Network. /// </summary> public override void TickRare() { CompAirFlowConsumer.TickRare(); if (!CompAirFlowConsumer.IsOperating()) { return; } if (!CompAirFlowConsumer.IsActive()) { return; } IntVec3 intVec = Position + IntVec3.North.RotatedBy(Rotation); if (intVec.Impassable(Map)) { return; } //var insideTemp = intVec.GetTemperature(Map); //var tempDiff = outsideTemp - insideTemp; var outsideTemp = CompAirFlowConsumer.ConvertedTemperature; var tempDiff = outsideTemp - intVec.GetTemperature(Map); var magnitudeChange = Mathf.Abs(tempDiff); // Cap change at 10.0f if (magnitudeChange > 10.0f) { magnitudeChange = 10.0f; } float signChanger = 1; if (tempDiff < 0) { signChanger = -1; } var thermalFlag = 1; if (CompAirFlowConsumer.ThermalEfficiency <= 0) { thermalFlag = 0; } // Flow Efficiency is capped at 1.0f. Squaring will only keep it less than or equal to 1.0f. Smaller the number more drastic the square. var efficiencyImpact = CompAirFlowConsumer.FlowEfficiency * CompAirFlowConsumer.FlowEfficiency * thermalFlag; var smoothMagnitude = magnitudeChange * 0.25f * (CompAirFlowConsumer.Props.baseAirExhaust / 100.0f); var energyLimit = smoothMagnitude * efficiencyImpact * 4.16666651f * 12f * signChanger; var tempChange = GenTemperature.ControlTemperatureTempChange(intVec, Map, energyLimit, outsideTemp); //var flag = !Mathf.Approximately(tempChange, 0f); //if (flag) if (!Mathf.Approximately(tempChange, 0f)) { intVec.GetRoomGroup(Map).Temperature += tempChange; } }
public override void TickRare() { if (!compPowerTrader.PowerOn) { return; } IntVec3 intVec3_1 = Position + IntVec3Utility.RotatedBy(IntVec3.South, Rotation); IntVec3 intVec3_2 = Position + IntVec3Utility.RotatedBy(IntVec3.North, Rotation); bool flag = false; if (!GenGrid.Impassable(intVec3_2, Map) && !GenGrid.Impassable(intVec3_1, Map)) { float temperature1 = GridsUtility.GetTemperature(intVec3_2, Map); float temperature2 = GridsUtility.GetTemperature(intVec3_1, Map); //Check for Mode bool _cooling = true; if (m_Mode == EnumCoolerMode.Cooling) { _cooling = true; } else if (m_Mode == EnumCoolerMode.Heating) { _cooling = false; } else if (m_Mode == EnumCoolerMode.Auto) { if (temperature1 > compTempControl.targetTemperature) { //Log.Message("Auto Cooling"); _cooling = true; } else { //Log.Message("Auto Heating"); _cooling = false; } } float a; float energyLimit; float _TemperatureDifferance; float num2; if (_cooling) { //Log.Message("Cooling"); _TemperatureDifferance = temperature1 - temperature2; if (temperature1 - TemperatureDiffThreshold > _TemperatureDifferance) { _TemperatureDifferance = temperature1 - TemperatureDiffThreshold; } num2 = 1.0f - _TemperatureDifferance * EfficiencyLossPerDegreeDifference; if (num2 < 0.0f) { num2 = 0.0f; } energyLimit = (float)(compTempControl.Props.energyPerSecond * (double)num2 * UnknownConst_2); a = GenTemperature.ControlTemperatureTempChange(intVec3_1, Map, energyLimit, compTempControl.targetTemperature); flag = !Mathf.Approximately(a, 0.0f); } else { //Log.Message("Heating"); _TemperatureDifferance = temperature1 - temperature2; if (temperature1 + TemperatureDiffThreshold > _TemperatureDifferance) { _TemperatureDifferance = temperature1 + TemperatureDiffThreshold; } num2 = 1.0f - _TemperatureDifferance * EfficiencyLossPerDegreeDifference; if (num2 < 0.0f) { num2 = 0.0f; } energyLimit = (float)(compTempControl.Props.energyPerSecond * -(double)num2 * UnknownConst_2); a = GenTemperature.ControlTemperatureTempChange(intVec3_1, Map, energyLimit, compTempControl.targetTemperature); flag = !Mathf.Approximately(a, 0.0f); } if (flag) { GridsUtility.GetRoomGroup(intVec3_2, Map).Temperature -= a; GenTemperature.PushHeat(intVec3_1, Map, (float)(+(double)energyLimit * HeatOutputMultiplier)); } } CompProperties_Power props = compPowerTrader.Props; if (flag) { compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { compPowerTrader.PowerOutput = -props.basePowerConsumption * compTempControl.Props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = flag; }
// Token: 0x06000018 RID: 24 RVA: 0x0000282C File Offset: 0x00000A2C public override void TickRare() { if (!compPowerTrader.PowerOn) { return; } var props = compPowerTrader.Props; var coolercell = Position + IntVec3.South.RotatedBy(Rotation); var exhaustcell = Position + IntVec3.North.RotatedBy(Rotation); var heatercell = coolercell; var ambientTemperature = heatercell.GetTemperature(Map); var targtemp = compTempControl.targetTemperature; var powered = false; var temptolerance = 0.5f; var boost = 1f; if (UseBoost) { boost = 2f; } if (ambientTemperature < targtemp) { if (!heatercell.Impassable(Map)) { var numheat = ambientTemperature < 20f ? 1f : ambientTemperature <= 120f ? Mathf.InverseLerp(120f, 20f, ambientTemperature) : 0f; var energyLimit = compTempControl.Props.energyPerSecond * numheat * 4.16666651f * boost; var tempdelta = GenTemperature.ControlTemperatureTempChange(heatercell, Map, energyLimit, compTempControl.targetTemperature); if (!Mathf.Approximately(tempdelta, temptolerance)) { heatercell.GetRoomOrAdjacent(Map).Temperature += tempdelta; powered = true; } } } else if (!exhaustcell.Impassable(Map) && !coolercell.Impassable(Map)) { var tempexhaust = exhaustcell.GetTemperature(Map); var tempcool = coolercell.GetTemperature(Map); var tempdiff = tempexhaust - tempcool; if (tempexhaust - 40f > tempdiff) { tempdiff = tempexhaust - 40f; } var numcool = 1f - (tempdiff * 0.0076923077f); if (numcool < 0f) { numcool = 0f; } var energyLimit = -1f * compTempControl.Props.energyPerSecond * numcool * 4.16666651f * boost; var tempdelta2 = GenTemperature.ControlTemperatureTempChange(coolercell, Map, energyLimit, compTempControl.targetTemperature); if (!Mathf.Approximately(tempdelta2, temptolerance)) { coolercell.GetRoomOrAdjacent(Map).Temperature += tempdelta2; GenTemperature.PushHeat(exhaustcell, Map, (0f - energyLimit) * 1.25f); powered = true; } } if (powered) { compPowerTrader.PowerOutput = 0f - (props.basePowerConsumption * boost); } else { compPowerTrader.PowerOutput = (0f - props.basePowerConsumption) * compTempControl.Props.lowPowerConsumptionFactor; } compTempControl.operatingAtHighPower = powered; }
public override void TickRare() { if (!this.compPowerTrader.PowerOn) { return; } IntVec3 intVec3_1 = this.Position + IntVec3.South.RotatedBy(this.Rotation); IntVec3 intVec3_2 = this.Position + IntVec3.North.RotatedBy(this.Rotation); bool flag = false; if (!intVec3_2.Impassable(this.Map) && !intVec3_1.Impassable(this.Map)) { float temperature1 = GridsUtility.GetTemperature(intVec3_2, this.Map); float temperature2 = GridsUtility.GetTemperature(intVec3_1, this.Map); //Check for Mode bool _cooling = true; if (this.m_Mode == enumCoolerMode.Cooling) { _cooling = true; } else if (this.m_Mode == enumCoolerMode.Heating) { _cooling = false; } else if (this.m_Mode == enumCoolerMode.Auto) { //Log.Message("T1: " + temperature1 + "T2: " + temperature2 + "TT: " + this.compTempControl.targetTemperature); if (temperature1 > this.compTempControl.targetTemperature) { //Log.Message("Auto Cooling"); _cooling = true; } else { //Log.Message("Auto Heating"); _cooling = false; } } float a = 0.0f; float energyLimit = 0.0f; if (_cooling) { //Log.Message("Cooling"); float _TemperatureDifferance = temperature1 - temperature2; if ((double)temperature1 - 40.0 > (double)_TemperatureDifferance) { _TemperatureDifferance = temperature1 - 40f; } float num2 = (float)(1.0 - (double)_TemperatureDifferance * (1.0 / 130.0)); if ((double)num2 < 0.0) { num2 = 0.0f; } energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * (double)num2 * 4.16666650772095); a = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature); flag = !Mathf.Approximately(a, 0.0f); } else { //Log.Message("Heating"); float _TemperatureDifferance = temperature1 - temperature2; if ((double)temperature1 + 40.0 > (double)_TemperatureDifferance) { _TemperatureDifferance = temperature1 + 40f; } float num2 = (float)(1.0 - (double)_TemperatureDifferance * (1.0 / 130.0)); if ((double)num2 < 0.0) { num2 = 0.0f; } energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * -(double)num2 * 4.16666650772095); //energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * 4.16666650772095 * -1); a = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature); flag = !Mathf.Approximately(a, 0.0f); //Log.Message("TempDiff: " + _TemperatureDifferance + " num2: " + num2 + " EnergyLimit: " + energyLimit + " a: " + a); } if (flag) { GridsUtility.GetRoomGroup(intVec3_2, this.Map).Temperature -= a; GenTemperature.PushHeat(intVec3_1, this.Map, (float)(+(double)energyLimit * 1.25)); } } CompProperties_Power props = this.compPowerTrader.Props; if (flag) { this.compPowerTrader.PowerOutput = -props.basePowerConsumption; } else { this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor; } this.compTempControl.operatingAtHighPower = flag; }