This commit is contained in:
Anuken
2020-06-23 16:27:32 -04:00
parent ba78eab30a
commit fc8e1d5b6d
12 changed files with 31 additions and 40 deletions

View File

@@ -114,12 +114,16 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
if(tile == null) return false;
if(tile.collide(this) && type.collides(this, tile) && !tile.dead() && (type.collidesTeam || tile.team() != team())){
boolean remove = false;
if(tile.team() != team()){
tile.collision(this);
remove = tile.collision(this);
}
type.hitTile(this, tile);
remove();
if(remove){
type.hitTile(this, tile);
remove();
}
return true;
}

View File

@@ -1046,8 +1046,12 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
return true;
}
public void collision(Bulletc other){
/** Handle a bullet collision.
* @return whether the bullet should be removed. */
public boolean collision(Bulletc other){
damage(other.damage() * other.type().tileDamageMultiplier);
return true;
}
public void removeFromProximity(){

View File

@@ -37,7 +37,6 @@ public class AIController implements UnitController{
}
protected void targetClosest(){
//TODO optimize!
Teamc newTarget = Units.closestTarget(unit.team(), unit.x(), unit.y(), Math.max(unit.range(), unit.type().range), u -> (unit.type().targetAir && u.isFlying()) || (unit.type().targetGround && !u.isFlying()));
if(newTarget != null){
target = newTarget;

View File

@@ -2,7 +2,6 @@ package mindustry.entities.units;
import mindustry.gen.*;
//TODO rename
public interface UnitController{
void unit(Unitc unit);
Unitc unit();