use of io.anuke.mindustry.world.blocks.types.defense.ShieldBlock in project Mindustry by Anuken.
the class Shield method update.
@Override
public void update() {
float alpha = 0.1f;
Interpolation interp = Interpolation.fade;
if (active) {
uptime = interp.apply(uptime, 1f, alpha * Timers.delta());
} else {
uptime = interp.apply(uptime, 0f, alpha * Timers.delta());
if (uptime <= 0.05f)
remove();
}
uptime = Mathf.clamp(uptime);
if (!(tile.block() instanceof ShieldBlock)) {
remove();
return;
}
ShieldBlock block = (ShieldBlock) tile.block();
Entities.getNearby(bulletGroup, x, y, block.shieldRadius * 2 * uptime + 10, entity -> {
BulletEntity bullet = (BulletEntity) entity;
if ((bullet.owner instanceof Enemy || hitPlayers)) {
float dst = entity.distanceTo(this);
if (dst < drawRadius() / 2f) {
((ShieldBlock) tile.block()).handleBullet(tile, bullet);
}
}
});
}
Aggregations