Search in sources :

Example 1 with TileEntity

use of io.anuke.mindustry.entities.TileEntity in project Mindustry by Anuken.

the class Omnidrill method update.

@Override
public void update(Tile tile) {
    TileEntity entity = tile.entity;
    if (tile.floor().drops != null && entity.timer.get(timerDrill, 60 * time)) {
        offloadNear(tile, tile.floor().drops.item);
        Effects.effect(drillEffect, tile.worldx(), tile.worldy());
    }
    if (entity.timer.get(timerDump, 30)) {
        tryDump(tile);
    }
}
Also used : TileEntity(io.anuke.mindustry.entities.TileEntity)

Example 2 with TileEntity

use of io.anuke.mindustry.entities.TileEntity in project Mindustry by Anuken.

the class Drill method update.

@Override
public void update(Tile tile) {
    TileEntity entity = tile.entity;
    if ((tile.floor() == resource || (resource.drops.equals(tile.floor().drops))) && entity.timer.get(timerDrill, 60 * time) && tile.entity.getItem(result) < capacity) {
        offloadNear(tile, result);
        Effects.effect(drillEffect, tile.worldx(), tile.worldy());
    }
    if (entity.timer.get(timerDump, 30)) {
        tryDump(tile);
    }
}
Also used : TileEntity(io.anuke.mindustry.entities.TileEntity)

Example 3 with TileEntity

use of io.anuke.mindustry.entities.TileEntity in project Mindustry by Anuken.

the class World method findTileTarget.

public TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged) {
    Entity closest = null;
    float dst = 0;
    int rad = (int) (range / tilesize) + 1;
    int tilex = Mathf.scl2(x, tilesize);
    int tiley = Mathf.scl2(y, tilesize);
    for (int rx = -rad; rx <= rad; rx++) {
        for (int ry = -rad; ry <= rad; ry++) {
            Tile other = tile(rx + tilex, ry + tiley);
            if (other != null && other.getLinked() != null) {
                other = other.getLinked();
            }
            if (other == null || other.entity == null || (tile != null && other.entity == tile.entity))
                continue;
            TileEntity e = other.entity;
            if (damaged && e.health >= e.tile.block().health)
                continue;
            float ndst = Vector2.dst(x, y, e.x, e.y);
            if (ndst < range && (closest == null || ndst < dst)) {
                dst = ndst;
                closest = e;
            }
        }
    }
    return (TileEntity) closest;
}
Also used : TileEntity(io.anuke.mindustry.entities.TileEntity) Entity(io.anuke.ucore.entities.Entity) TileEntity(io.anuke.mindustry.entities.TileEntity) SpawnPoint(io.anuke.mindustry.game.SpawnPoint)

Example 4 with TileEntity

use of io.anuke.mindustry.entities.TileEntity in project Mindustry by Anuken.

the class BlastType method behavior.

@Override
public void behavior(Enemy enemy) {
    float range = 10f;
    float ox = 0, oy = 0;
    if (enemy.target instanceof TileEntity) {
        TileEntity e = (TileEntity) enemy.target;
        range = (e.tile.block().width * tilesize) / 2f + 8f;
        ox = e.tile.block().getPlaceOffset().x;
        oy = e.tile.block().getPlaceOffset().y;
    }
    if (enemy.target != null && enemy.target.distanceTo(enemy.x - ox, enemy.y - oy) < range) {
        explode(enemy);
    }
}
Also used : TileEntity(io.anuke.mindustry.entities.TileEntity)

Example 5 with TileEntity

use of io.anuke.mindustry.entities.TileEntity in project Mindustry by Anuken.

the class RepairTurret method drawLayer2.

@Override
public void drawLayer2(Tile tile) {
    PowerTurretEntity entity = tile.entity();
    TileEntity target = entity.blockTarget;
    if (entity.power >= powerUsed && target != null && Angles.angleDist(entity.angleTo(target), entity.rotation) < 10) {
        Tile targetTile = target.tile;
        float len = 4f;
        float x = tile.drawx() + Angles.trnsx(entity.rotation, len), y = tile.drawy() + Angles.trnsy(entity.rotation, len);
        float x2 = targetTile.drawx(), y2 = targetTile.drawy();
        Draw.color(Hue.rgb(138, 244, 138, (MathUtils.sin(Timers.time()) + 1f) / 14f));
        Draw.alpha(0.3f);
        Lines.stroke(4f);
        Lines.line(x, y, x2, y2);
        Lines.stroke(2f);
        Draw.rect("circle", x2, y2, 7f, 7f);
        Draw.alpha(1f);
        Lines.stroke(2f);
        Lines.line(x, y, x2, y2);
        Lines.stroke(1f);
        Draw.rect("circle", x2, y2, 5f, 5f);
        Draw.reset();
    }
}
Also used : TileEntity(io.anuke.mindustry.entities.TileEntity) Tile(io.anuke.mindustry.world.Tile)

Aggregations

TileEntity (io.anuke.mindustry.entities.TileEntity)5 SpawnPoint (io.anuke.mindustry.game.SpawnPoint)1 Tile (io.anuke.mindustry.world.Tile)1 Entity (io.anuke.ucore.entities.Entity)1