Fixed unit assembler overlap

This commit is contained in:
Anuken
2022-01-21 11:53:59 -05:00
parent a121c4d042
commit 025dac226c
2 changed files with 22 additions and 6 deletions

View File

@@ -1453,7 +1453,7 @@ public class UnitTypes{
engineSize = 7.8f;
rotateShooting = false;
hitSize = 66f;
payloadCapacity = (5.3f * 5.3f) * tilePayload;
payloadCapacity = (5.5f * 5.5f) * tilePayload;
buildSpeed = 4f;
drawShields = false;
commandLimit = 6;

View File

@@ -14,6 +14,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
@@ -46,20 +47,35 @@ public class UnitAssembler extends PayloadBlock{
flags = EnumSet.of(BlockFlag.unitAssembler);
}
public Rect getRect(Rect rect, float x, float y, int rotation){
rect.setCentered(x, y, areaSize * tilesize);
float len = tilesize * (areaSize + size)/2f;
rect.x += Geometry.d4x(rotation) * len;
rect.y += Geometry.d4y(rotation) * len;
return rect;
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
super.drawPlace(x, y, rotation, valid);
x *= tilesize;
y *= tilesize;
x += offset;
y += offset;
Tmp.r1.setCentered(x, y, areaSize * tilesize);
float len = tilesize * (areaSize + size)/2f;
Rect rect = getRect(Tmp.r1, x, y, rotation);
Tmp.r1.x += Geometry.d4x(rotation) * len;
Tmp.r1.y += Geometry.d4y(rotation) * len;
Drawf.dashRect(valid ? Pal.accent : Pal.remove, rect);
}
Drawf.dashRect(valid ? Pal.accent : Pal.remove, Tmp.r1);
@Override
public boolean canPlaceOn(Tile tile, Team team, int rotation){
//overlapping construction areas not allowed.
Rect rect = getRect(Tmp.r1, tile.worldx() + offset, tile.worldy() + offset, rotation).grow(0.1f);
return !indexer.getFlagged(team, BlockFlag.unitAssembler).contains(b -> getRect(Tmp.r2, b.x, b.y, b.rotation).overlaps(rect));
}
@Override