WIP point laser turret

This commit is contained in:
Anuken
2022-06-23 20:57:22 -04:00
parent ac47d22ea1
commit be61b45d08
18 changed files with 202 additions and 61 deletions
+33
View File
@@ -298,6 +298,39 @@ public class Damage{
units.each(cons);
}
/**
* Damages entities on a point.
* Only enemies of the specified team are damaged.
*/
public static void collidePoint(Bullet hitter, Team team, Effect effect, float x, float y){
if(hitter.type.collidesGround){
Building build = world.build(World.toTile(x), World.toTile(y));
if(build != null && hitter.damage > 0){
float health = build.health;
if(build.team != team && build.collide(hitter)){
build.collision(hitter);
hitter.type.hit(hitter, x, y);
}
//try to heal the tile
if(hitter.type.testCollision(hitter, build)){
hitter.type.hitTile(hitter, build, x, y, health, false);
}
}
}
Units.nearbyEnemies(team, rect.setCentered(x, y, 1f), u -> {
if(u.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround) && u.hittable()){
effect.at(x, y);
u.collision(hitter, x, y);
hitter.collision(u, x, y);
}
});
}
/**
* Casts forward in a line.
* @return the first encountered object.