Topic on Talk:Beer

Jump to navigation Jump to search
Line 3: Line 3:
 
As for the second part, it does seem to do as you say. Tick up at a rate defined by the difference between actual temperature and the safe temperature, and then ruin when it gets to 100% (1)  
 
As for the second part, it does seem to do as you say. Tick up at a rate defined by the difference between actual temperature and the safe temperature, and then ruin when it gets to 100% (1)  
  
 +
<code>
 
private void DoTicks(int ticks)
 
private void DoTicks(int ticks)
 
 
{
 
{
 
+
    if (!this.Ruined)
if (!this.Ruined)
+
    {
 
+
        float ambientTemperature = this.parent.AmbientTemperature;
{
+
        if (ambientTemperature > this.Props.maxSafeTemperature)
 
+
        {
float ambientTemperature = this.parent.AmbientTemperature;
+
            this.ruinedPercent += (ambientTemperature - this.Props.maxSafeTemperature) * this.Props.progressPerDegreePerTick * (float)ticks;
 
+
        }
if (ambientTemperature > this.Props.maxSafeTemperature)
+
        else if (ambientTemperature < this.Props.minSafeTemperature)
 
+
        {
{
+
            this.ruinedPercent -= (ambientTemperature - this.Props.minSafeTemperature) * this.Props.progressPerDegreePerTick * (float)ticks;
 
+
        }
this.ruinedPercent += (ambientTemperature - this.Props.maxSafeTemperature) * this.Props.progressPerDegreePerTick * (float)ticks;
+
        if (this.ruinedPercent >= 1f)
 
+
        {
}
+
            this.ruinedPercent = 1f;
 
+
            this.parent.BroadcastCompSignal("RuinedByTemperature");
else if (ambientTemperature < this.Props.minSafeTemperature)
+
            return;
 
+
        }
{
+
        if (this.ruinedPercent < 0f)
 
+
        {
this.ruinedPercent -= (ambientTemperature - this.Props.minSafeTemperature) * this.Props.progressPerDegreePerTick * (float)ticks;
+
            this.ruinedPercent = 0f;
 
+
        }
}
+
    }
 
 
if (this.ruinedPercent >= 1f)
 
 
 
{
 
 
 
this.ruinedPercent = 1f;
 
 
 
this.parent.BroadcastCompSignal("RuinedByTemperature");
 
 
 
return;
 
 
 
}
 
 
 
if (this.ruinedPercent < 0f)
 
 
 
{
 
 
 
this.ruinedPercent = 0f;
 
 
 
}
 
 
 
}
 
 
 
 
}
 
}
 +
</code>