try to fix an issue with sanity/insanity interactions
This commit is contained in:
@@ -58,18 +58,17 @@ public class SanityCapability implements ISanity {
|
||||
}
|
||||
|
||||
public void setBonusMaxSanity(float bonusMaxSanity) {
|
||||
float oldMax = getMaxSanity();
|
||||
this.bonusMaxSanity = Math.max(0f, bonusMaxSanity);
|
||||
float newMax = getMaxSanity();
|
||||
if (oldMax > 0) {
|
||||
float pct = sanity / oldMax;
|
||||
sanity = pct * newMax;
|
||||
}
|
||||
setSanity(sanity);
|
||||
setInsanity(insanity);
|
||||
clampToMax();
|
||||
}
|
||||
|
||||
public float getBonusMaxSanity() {
|
||||
return bonusMaxSanity;
|
||||
}
|
||||
|
||||
private void clampToMax() {
|
||||
float max = getMaxSanity();
|
||||
this.sanity = Math.max(0, Math.min(max, this.sanity));
|
||||
this.insanity = Math.max(0, Math.min(max, this.insanity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,17 +47,11 @@ public class TempoCapability implements ITempo {
|
||||
}
|
||||
|
||||
public void setBonusMaxTempo(float bonusMaxTempo) {
|
||||
int oldMax = getMaxTempo();
|
||||
this.bonusMaxTempo = Math.max(0f, bonusMaxTempo);
|
||||
int newMax = getMaxTempo();
|
||||
if (oldMax > 0) {
|
||||
float pct = (float) tempo / (float) oldMax;
|
||||
tempo = Math.round(pct * newMax);
|
||||
}
|
||||
setTempo(tempo);
|
||||
setTempo(this.tempo);
|
||||
}
|
||||
|
||||
public float getBonusMaxTempo() {
|
||||
return bonusMaxTempo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user