This commit is contained in:
Anuken
2020-05-15 19:54:04 -04:00
parent 6a0dc4c965
commit 381df23bf2
8 changed files with 99 additions and 40 deletions
@@ -4,6 +4,7 @@ import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.entities.bullet.*;
@@ -18,6 +19,7 @@ import static mindustry.Vars.*;
abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{
@Import Team team;
IntArray collided = new IntArray(6);
Object data;
BulletType type;
float damage;
@@ -42,6 +44,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override
public void remove(){
type.despawned(this);
collided.clear();
}
@Override
@@ -72,7 +75,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override
public boolean collides(Hitboxc other){
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team())
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)));
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)))
&& !(type.pierce && collided.contains(other.id())); //prevent multiple collisions
}
@MethodPriority(100)
@@ -92,7 +96,11 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
}
//must be last.
if(!type.pierce) remove();
if(!type.pierce){
remove();
}else{
collided.add(other.id());
}
}
@Override
@@ -185,6 +185,10 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
return relativeTo(tile.x, tile.y);
}
public byte relativeTo(Tilec tile){
return relativeTo(tile.tile());
}
public byte relativeTo(int cx, int cy){
return tile.absoluteRelativeTo(cx, cy);
}