Added self-destruct bullet property
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -14,6 +14,11 @@ public interface HealthTrait{
|
||||
|
||||
void setDead(boolean dead);
|
||||
|
||||
default void kill(){
|
||||
health(-1);
|
||||
damage(1);
|
||||
}
|
||||
|
||||
default void onHit(SolidTrait entity){
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user