Added self-destruct bullet property

This commit is contained in:
Anuken
2020-01-19 10:43:38 -05:00
parent 87b4c37d82
commit b1df52e0c8
5 changed files with 20 additions and 26 deletions

View File

@@ -39,6 +39,8 @@ public abstract class BulletType extends Content{
public float reloadMultiplier = 1f;
/** Recoil from shooter entities. */
public float recoil;
/** Whether to kill the shooter when this is shot. For suicide bombers. */
public boolean killShooter;
public float splashDamage = 0f;
/** Knockback in velocity. */
@@ -146,6 +148,9 @@ public abstract class BulletType extends Content{
}
public void init(Bullet b){
if(killShooter && b.getOwner() instanceof HealthTrait){
((HealthTrait)b.getOwner()).kill();
}
}
public void update(Bullet b){

View File

@@ -14,6 +14,11 @@ public interface HealthTrait{
void setDead(boolean dead);
default void kill(){
health(-1);
damage(1);
}
default void onHit(SolidTrait entity){
}

View File

@@ -185,11 +185,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
y = Mathf.clamp(y, 0, world.height() * tilesize - tilesize);
}
public void kill(){
health = -1;
damage(1);
}
public boolean isImmune(StatusEffect effect){
return false;
}