Fixed invalid healing effects

This commit is contained in:
Anuken
2021-06-08 09:14:54 -04:00
parent a7de30ba53
commit 8962992ef9
4 changed files with 37 additions and 22 deletions

View File

@@ -49,7 +49,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
transient float healTime;
private transient float resupplyTime = Mathf.random(10f);
private transient boolean wasPlayer;
private transient float lastHealth;
private transient boolean wasHealed;
public void moveAt(Vec2 vector){
moveAt(vector, type.accel);
@@ -320,16 +320,23 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
type.landed(self());
}
@Override
public void heal(float amount){
if(health < maxHealth && amount > 0){
wasHealed = true;
}
}
@Override
public void update(){
type.update(self());
if(health > lastHealth && lastHealth > 0 && healTime <= -1f){
if(wasHealed && healTime <= -1f){
healTime = 1f;
}
healTime -= Time.delta / 20f;
lastHealth = health;
wasHealed = false;
//check if environment is unsupported
if(!type.supportsEnv(state.rules.environment) && !dead){