More stuff in cooldown system test component.

This commit is contained in:
Olof Larsson 2013-04-05 09:19:13 +02:00
parent cae94f01f6
commit b7a88095d3

View File

@ -6,11 +6,14 @@ public abstract class Heatable
// ABSTRACT // ABSTRACT
// -------------------------------------------- // // -------------------------------------------- //
protected abstract HeatData getData(); public abstract HeatData getData();
protected abstract void setData(HeatData data); public abstract void setData(HeatData data);
public abstract double getHeatPerMilli();
public abstract double getHeatPerExecution();
// -------------------------------------------- // // -------------------------------------------- //
// UTIL // CUSTOM
// -------------------------------------------- // // -------------------------------------------- //
private HeatData getRecalculatedData(double heatPerMilli) private HeatData getRecalculatedData(double heatPerMilli)
@ -35,7 +38,6 @@ public abstract class Heatable
return data.getHeat(); return data.getHeat();
} }
public boolean isOverheated(double heatPerMilli) public boolean isOverheated(double heatPerMilli)
{ {
HeatData data = getRecalculatedData(heatPerMilli); HeatData data = getRecalculatedData(heatPerMilli);
@ -54,4 +56,52 @@ public abstract class Heatable
return (long) (-overheat / heatPerMilli); return (long) (-overheat / heatPerMilli);
} }
// -------------------------------------------- //
// DEFAULT
// -------------------------------------------- //
public void addHeat(double heat)
{
this.addHeat(this.getHeatPerMilli(), heat);
}
public void addHeat()
{
this.addHeat(this.getHeatPerExecution());
}
public double getHeat()
{
return this.getHeat(this.getHeatPerMilli());
}
public boolean isOverheated()
{
return this.isOverheated(this.getHeatPerMilli());
}
public double getOverheat()
{
return this.getOverheat(this.getHeatPerMilli());
}
public long getCooldownMillisLeft()
{
return this.getCooldownMillisLeft(this.getHeatPerMilli());
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static double calcHeatPerExecution(long executionCount, long periodMillis)
{
return 1D / (double)executionCount;
}
public static double calcHeatPerMilli(long executionCount, long periodMillis)
{
return - 1D / (double)periodMillis;
}
} }