Status effect cleanup
This commit is contained in:
@@ -28,24 +28,21 @@ public class StatusController implements Saveable{
|
||||
private float damageMultiplier;
|
||||
private float armorMultiplier;
|
||||
|
||||
public void handleApply(Unit unit, StatusEffect effect, float intensity){
|
||||
public void handleApply(Unit unit, StatusEffect effect, float duration){
|
||||
if(effect == StatusEffects.none) return; //don't apply empty effects
|
||||
|
||||
float newTime = effect.baseDuration * intensity;
|
||||
|
||||
if(statuses.size > 0){
|
||||
//check for opposite effects
|
||||
for(StatusEntry entry : statuses){
|
||||
//extend effect
|
||||
if(entry.effect == effect){
|
||||
entry.time = Math.max(entry.time, newTime);
|
||||
entry.time = Math.max(entry.time, duration);
|
||||
return;
|
||||
}else if(entry.effect.isOpposite(effect)){ //find opposite
|
||||
entry.effect.getTransition(unit, effect, entry.time, newTime, globalResult);
|
||||
}else if(entry.effect.reactsWith(effect)){ //find opposite
|
||||
entry.effect.getTransition(unit, effect, entry.time, duration, globalResult);
|
||||
entry.time = globalResult.time;
|
||||
|
||||
if(globalResult.effect != entry.effect){
|
||||
entry.effect.onTransition(unit, globalResult.effect);
|
||||
entry.effect = globalResult.effect;
|
||||
}
|
||||
|
||||
@@ -57,7 +54,7 @@ public class StatusController implements Saveable{
|
||||
|
||||
//otherwise, no opposites found, add direct effect
|
||||
StatusEntry entry = Pools.obtain(StatusEntry.class, StatusEntry::new);
|
||||
entry.set(effect, newTime);
|
||||
entry.set(effect, duration);
|
||||
statuses.add(entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
if(onLiquid){
|
||||
status.handleApply(this, floor.status, floor.statusIntensity);
|
||||
status.handleApply(this, floor.status, floor.statusDuration);
|
||||
|
||||
if(floor.damageTaken > 0f){
|
||||
damagePeriodic(floor.damageTaken);
|
||||
@@ -292,9 +292,9 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
velocity.scl(Mathf.clamp(1f - drag() * (isFlying() ? 1f : floor.dragMultiplier) * Time.delta()));
|
||||
}
|
||||
|
||||
public void applyEffect(StatusEffect effect, float intensity){
|
||||
public void applyEffect(StatusEffect effect, float duration){
|
||||
if(dead || Net.client()) return; //effects are synced and thus not applied through clients
|
||||
status.handleApply(this, effect, intensity);
|
||||
status.handleApply(this, effect, duration);
|
||||
}
|
||||
|
||||
public void damagePeriodic(float amount){
|
||||
|
||||
@@ -197,7 +197,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
|
||||
if(other instanceof Unit){
|
||||
Unit unit = (Unit) other;
|
||||
unit.velocity().add(Tmp.v3.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.mass()));
|
||||
unit.applyEffect(type.status, type.statusIntensity);
|
||||
unit.applyEffect(type.status, type.statusDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class BulletType extends Content{
|
||||
/**Status effect applied on hit.*/
|
||||
public StatusEffect status = StatusEffects.none;
|
||||
/**Intensity of applied status effect in terms of duration.*/
|
||||
public float statusIntensity = 0.5f;
|
||||
public float statusDuration = 60 * 1f;
|
||||
/**What fraction of armor is pierced, 0-1*/
|
||||
public float armorPierce = 0f;
|
||||
/**Whether to sync this bullet to clients.*/
|
||||
|
||||
@@ -25,7 +25,7 @@ public class LiquidBulletType extends BulletType{
|
||||
|
||||
lifetime = 70f;
|
||||
status = liquid.effect;
|
||||
statusIntensity = 0.5f;
|
||||
statusDuration = 90f;
|
||||
despawnEffect = Fx.none;
|
||||
hitEffect = Fx.hitLiquid;
|
||||
drag = 0.01f;
|
||||
|
||||
@@ -151,7 +151,9 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
||||
if(damage){
|
||||
entity.damage(0.4f);
|
||||
}
|
||||
Damage.damageUnits(null, tile.worldx(), tile.worldy(), tilesize, 3f, unit -> !unit.isFlying(), unit -> unit.applyEffect(StatusEffects.burning, 0.8f));
|
||||
Damage.damageUnits(null, tile.worldx(), tile.worldy(), tilesize, 3f,
|
||||
unit -> !unit.isFlying(),
|
||||
unit -> unit.applyEffect(StatusEffects.burning, 60 * 5));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
||||
unit.hitbox(rect2);
|
||||
if(!rect.overlaps(rect2)) return;
|
||||
|
||||
unit.applyEffect(liquid.effect, 0.5f);
|
||||
unit.applyEffect(liquid.effect, 60 * 2);
|
||||
|
||||
if(unit.velocity().len() > 0.1){
|
||||
Effects.effect(Fx.ripple, liquid.color, unit.x, unit.y);
|
||||
|
||||
Reference in New Issue
Block a user