Unit assembly finalizations
This commit is contained in:
@@ -3322,7 +3322,7 @@ public class Blocks{
|
||||
size = 5;
|
||||
droneType = UnitTypes.manifold;
|
||||
plans.add(new AssemblerUnitPlan(UnitTypes.vanquish, 60f * 5f, BlockStack.list(Blocks.thoriumWallLarge, 4, Blocks.duct, 2)));
|
||||
consumes.power(1f);
|
||||
consumes.power(2f);
|
||||
areaSize = 13;
|
||||
|
||||
droneType = UnitTypes.assemblyDrone;
|
||||
@@ -3330,6 +3330,7 @@ public class Blocks{
|
||||
|
||||
basicAssemblerModule = new UnitAssemblerModule("basic-assembler-module"){{
|
||||
requirements(Category.units, with(Items.graphite, 10));
|
||||
consumes.power(0.5f);
|
||||
|
||||
size = 3;
|
||||
}};
|
||||
|
||||
@@ -292,6 +292,14 @@ public class Fx{
|
||||
Lines.poly(e.x, e.y, 4, 5f + e.fin() * 12f);
|
||||
}),
|
||||
|
||||
unitAssemble = new Effect(70, e -> {
|
||||
if(!(e.data instanceof Unit unit)) return;
|
||||
|
||||
alpha(e.fout());
|
||||
mixcol(Pal.accent, e.fout());
|
||||
rect(unit.type.fullIcon, unit.x, unit.y, unit.rotation - 90);
|
||||
}).layer(Layer.flyingUnit + 5f),
|
||||
|
||||
padlaunch = new Effect(10, e -> {
|
||||
stroke(4f * e.fout());
|
||||
color(Pal.accent);
|
||||
|
||||
@@ -95,6 +95,11 @@ public class UnitAssembler extends PayloadBlock{
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, sideRegion1, topRegion};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
clipSize = Math.max(clipSize, (areaSize + size) * tilesize * 2);
|
||||
@@ -338,10 +343,10 @@ public class UnitAssembler extends PayloadBlock{
|
||||
unit.set(spawn.x + Mathf.range(0.001f), spawn.y + Mathf.range(0.001f));
|
||||
unit.rotation = 90f;
|
||||
//TODO annoying so nothing is created yet
|
||||
//unit.add();
|
||||
unit.add();
|
||||
progress = 0f;
|
||||
|
||||
Fx.spawn.at(unit);
|
||||
Fx.unitAssemble.at(unit.x, unit.y, 0f, unit);
|
||||
|
||||
blocks.clear();
|
||||
}
|
||||
@@ -383,21 +388,43 @@ public class UnitAssembler extends PayloadBlock{
|
||||
}
|
||||
|
||||
Vec2 spawn = getUnitSpawn();
|
||||
|
||||
Draw.alpha(progress);
|
||||
float sx = spawn.x, sy = spawn.y;
|
||||
|
||||
var plan = plan();
|
||||
|
||||
Draw.rect(plan.unit.fullIcon, spawn.x, spawn.y);
|
||||
Draw.draw(Layer.blockBuilding, () -> {
|
||||
Draw.color(Pal.accent, warmup);
|
||||
|
||||
Shaders.blockbuild.region = plan.unit.fullIcon;
|
||||
Shaders.blockbuild.time = Time.time;
|
||||
//margin due to units not taking up whole region
|
||||
Shaders.blockbuild.progress = Mathf.clamp(progress + 0.05f);
|
||||
|
||||
Draw.rect(plan.unit.fullIcon, sx, sy);
|
||||
Draw.flush();
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
/*
|
||||
Tmp.tr1.set(plan.unit.fullIcon);
|
||||
Tmp.tr1.setY(Tmp.tr1.getY() + plan.unit.fullIcon.height * (1f - progress));
|
||||
|
||||
//TODO what if building animation
|
||||
Draw.rect(Tmp.tr1, spawn.x, spawn.y + (Tmp.tr1.height/2f - plan.unit.fullIcon.height/2f) * Draw.scl, Tmp.tr1.width * Draw.scl, Tmp.tr1.height * Draw.scl);
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
Draw.alpha(warmup);
|
||||
Lines.lineAngleCenter(spawn.x, spawn.y - plan.unit.fullIcon.height/2f * Draw.scl + plan.unit.fullIcon.height * progress * Draw.scl, 0f, plan.unit.fullIcon.width * 0.9f * Draw.scl);*/
|
||||
|
||||
Draw.reset();
|
||||
|
||||
Draw.z(Layer.buildBeam);
|
||||
|
||||
//draw unit outline
|
||||
Draw.mixcol(Tmp.c1.set(Pal.accent).lerp(Pal.remove, invalidWarmup), 1f);
|
||||
Draw.alpha(0.8f + Mathf.absin(10f, 0.2f));
|
||||
Draw.rect(plan.unit.fullIcon, spawn.x, spawn.y);
|
||||
|
||||
Draw.alpha(warmup * Draw.getColor().a);
|
||||
//build beams do not draw when invalid
|
||||
Draw.alpha(Math.min(1f - invalidWarmup, warmup));
|
||||
|
||||
//draw build beams
|
||||
for(var unit : units){
|
||||
@@ -424,9 +451,11 @@ public class UnitAssembler extends PayloadBlock{
|
||||
|
||||
float outSize = plan.unit.hitSize + 9f;
|
||||
|
||||
//draw small square for area
|
||||
Lines.stroke(2f, Tmp.c3.set(Pal.accent).lerp(Pal.remove, invalidWarmup).a(efficiency()));
|
||||
Drawf.dashSquareBasic(spawn.x, spawn.y, outSize);
|
||||
if(invalidWarmup > 0){
|
||||
//draw small square for area
|
||||
Lines.stroke(2f, Tmp.c3.set(Pal.accent).lerp(Pal.remove, invalidWarmup).a(invalidWarmup));
|
||||
Drawf.dashSquareBasic(spawn.x, spawn.y, outSize);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package mindustry.world.blocks.units;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -14,6 +16,9 @@ import mindustry.world.meta.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitAssemblerModule extends PayloadBlock{
|
||||
public @Load("@-side1") TextureRegion sideRegion1;
|
||||
public @Load("@-side2") TextureRegion sideRegion2;
|
||||
|
||||
public int tier = 1;
|
||||
|
||||
public UnitAssemblerModule(String name){
|
||||
@@ -38,6 +43,18 @@ public class UnitAssemblerModule extends PayloadBlock{
|
||||
return getLink(team, tile.x, tile.y, rotation) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
Draw.rect(plan.rotation >= 2 ? sideRegion2 : sideRegion1, plan.drawx(), plan.drawy(), plan.rotation * 90);
|
||||
Draw.rect(topRegion, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, sideRegion1, topRegion};
|
||||
}
|
||||
|
||||
public @Nullable UnitAssemblerBuild getLink(Team team, int x, int y, int rotation){
|
||||
var results = Vars.indexer.getFlagged(team, BlockFlag.unitAssembler).<UnitAssemblerBuild>as();
|
||||
|
||||
@@ -73,6 +90,8 @@ public class UnitAssemblerModule extends PayloadBlock{
|
||||
}
|
||||
}
|
||||
|
||||
Draw.rect(rotation >= 2 ? sideRegion2 : sideRegion1, x, y, rotdeg());
|
||||
|
||||
Draw.z(Layer.blockOver);
|
||||
payRotation = rotdeg();
|
||||
drawPayload();
|
||||
@@ -109,7 +128,7 @@ public class UnitAssemblerModule extends PayloadBlock{
|
||||
findLink();
|
||||
}
|
||||
|
||||
if(moveInPayload() && link != null && link.moduleFits(block, x, y, rotation) && link.acceptPayload(this, payload)){
|
||||
if(moveInPayload() && link != null && link.moduleFits(block, x, y, rotation) && link.acceptPayload(this, payload) && consValid()){
|
||||
link.yeetPayload(payload);
|
||||
payload = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user