Basic kill tracking
This commit is contained in:
@@ -1194,7 +1194,7 @@ public class Blocks implements ContentList{
|
||||
rotateSpeed = 1.4f;
|
||||
attribute = Attribute.water;
|
||||
|
||||
consumes.power(0.90f);
|
||||
consumes.power(1f);
|
||||
}};
|
||||
|
||||
cultivator = new Cultivator("cultivator"){{
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package io.anuke.mindustry.entities.traits;
|
||||
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
|
||||
public interface DamageTrait{
|
||||
float damage();
|
||||
|
||||
default void killed(Entity other){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.anuke.mindustry.entities.traits;
|
||||
|
||||
public interface KillerTrait{
|
||||
void killed(Entity other);
|
||||
}
|
||||
@@ -134,6 +134,13 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killed(Entity other){
|
||||
if(owner instanceof KillerTrait){
|
||||
((KillerTrait)owner).killed(other);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorb(){
|
||||
supressCollision = true;
|
||||
|
||||
@@ -15,8 +15,12 @@ public abstract class DestructibleEntity extends SolidEntity implements HealthTr
|
||||
@Override
|
||||
public void collision(SolidTrait other, float x, float y){
|
||||
if(other instanceof DamageTrait){
|
||||
boolean wasDead = isDead();
|
||||
onHit(other);
|
||||
damage(((DamageTrait)other).damage());
|
||||
if(!wasDead && isDead()){
|
||||
((DamageTrait)other).killed(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user