Unit assembly finalizations

This commit is contained in:
Anuken
2021-12-19 20:31:00 -05:00
parent 59550f58ee
commit 430fe2fd0a
12 changed files with 75 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -18,11 +18,13 @@ bool id(vec2 coords, vec4 base){
} }
bool cont(vec2 T, vec2 v){ bool cont(vec2 T, vec2 v){
const float step = 3.0; const float step = 3.5;
vec4 base = texture2D(u_texture, T); vec4 base = texture2D(u_texture, T);
return base.a > 0.1 && return base.a > 0.1 &&
(id(T + vec2(0, step) * v, base) || id(T + vec2(0, -step) * v, base) || (id(T + vec2(0, step) * v, base) || id(T + vec2(0, -step) * v, base) ||
id(T + vec2(step, 0) * v, base) || id(T + vec2(-step, 0) * v, base)); id(T + vec2(step, 0) * v, base) || id(T + vec2(-step, 0) * v, base) ||
id(T + vec2(step, step) * v, base) || id(T + vec2(step, -step) * v, base) ||
id(T + vec2(-step, -step) * v, base) || id(T + vec2(-step, step) * v, base));
} }
void main(){ void main(){
@@ -42,7 +44,7 @@ void main(){
gl_FragColor = v_color; gl_FragColor = v_color;
}else if(dst > (1.0-u_progress) * (center.x)){ }else if(dst > (1.0-u_progress) * (center.x)){
gl_FragColor = color; gl_FragColor = color;
}else if((dst + 1.0 > (1.0-u_progress) * (center.x)) && color.a > 0.1){ }else if((dst + 2.0 > (1.0-u_progress) * (center.x)) && color.a > 0.1){
gl_FragColor = v_color; gl_FragColor = v_color;
}else{ }else{
gl_FragColor = vec4(0.0); gl_FragColor = vec4(0.0);

View File

@@ -3322,7 +3322,7 @@ public class Blocks{
size = 5; size = 5;
droneType = UnitTypes.manifold; droneType = UnitTypes.manifold;
plans.add(new AssemblerUnitPlan(UnitTypes.vanquish, 60f * 5f, BlockStack.list(Blocks.thoriumWallLarge, 4, Blocks.duct, 2))); plans.add(new AssemblerUnitPlan(UnitTypes.vanquish, 60f * 5f, BlockStack.list(Blocks.thoriumWallLarge, 4, Blocks.duct, 2)));
consumes.power(1f); consumes.power(2f);
areaSize = 13; areaSize = 13;
droneType = UnitTypes.assemblyDrone; droneType = UnitTypes.assemblyDrone;
@@ -3330,6 +3330,7 @@ public class Blocks{
basicAssemblerModule = new UnitAssemblerModule("basic-assembler-module"){{ basicAssemblerModule = new UnitAssemblerModule("basic-assembler-module"){{
requirements(Category.units, with(Items.graphite, 10)); requirements(Category.units, with(Items.graphite, 10));
consumes.power(0.5f);
size = 3; size = 3;
}}; }};

View File

@@ -292,6 +292,14 @@ public class Fx{
Lines.poly(e.x, e.y, 4, 5f + e.fin() * 12f); 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 -> { padlaunch = new Effect(10, e -> {
stroke(4f * e.fout()); stroke(4f * e.fout());
color(Pal.accent); color(Pal.accent);

View File

@@ -95,6 +95,11 @@ public class UnitAssembler extends PayloadBlock{
Draw.rect(topRegion, plan.drawx(), plan.drawy()); Draw.rect(topRegion, plan.drawx(), plan.drawy());
} }
@Override
public TextureRegion[] icons(){
return new TextureRegion[]{region, sideRegion1, topRegion};
}
@Override @Override
public void init(){ public void init(){
clipSize = Math.max(clipSize, (areaSize + size) * tilesize * 2); 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.set(spawn.x + Mathf.range(0.001f), spawn.y + Mathf.range(0.001f));
unit.rotation = 90f; unit.rotation = 90f;
//TODO annoying so nothing is created yet //TODO annoying so nothing is created yet
//unit.add(); unit.add();
progress = 0f; progress = 0f;
Fx.spawn.at(unit); Fx.unitAssemble.at(unit.x, unit.y, 0f, unit);
blocks.clear(); blocks.clear();
} }
@@ -383,21 +388,43 @@ public class UnitAssembler extends PayloadBlock{
} }
Vec2 spawn = getUnitSpawn(); Vec2 spawn = getUnitSpawn();
float sx = spawn.x, sy = spawn.y;
Draw.alpha(progress);
var plan = plan(); 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.z(Layer.buildBeam);
//draw unit outline //draw unit outline
Draw.mixcol(Tmp.c1.set(Pal.accent).lerp(Pal.remove, invalidWarmup), 1f); 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.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 //draw build beams
for(var unit : units){ for(var unit : units){
@@ -424,9 +451,11 @@ public class UnitAssembler extends PayloadBlock{
float outSize = plan.unit.hitSize + 9f; float outSize = plan.unit.hitSize + 9f;
//draw small square for area if(invalidWarmup > 0){
Lines.stroke(2f, Tmp.c3.set(Pal.accent).lerp(Pal.remove, invalidWarmup).a(efficiency())); //draw small square for area
Drawf.dashSquareBasic(spawn.x, spawn.y, outSize); Lines.stroke(2f, Tmp.c3.set(Pal.accent).lerp(Pal.remove, invalidWarmup).a(invalidWarmup));
Drawf.dashSquareBasic(spawn.x, spawn.y, outSize);
}
Draw.reset(); Draw.reset();
} }

View File

@@ -3,6 +3,8 @@ package mindustry.world.blocks.units;
import arc.graphics.g2d.*; import arc.graphics.g2d.*;
import arc.util.*; import arc.util.*;
import mindustry.*; import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.entities.units.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
@@ -14,6 +16,9 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class UnitAssemblerModule extends PayloadBlock{ public class UnitAssemblerModule extends PayloadBlock{
public @Load("@-side1") TextureRegion sideRegion1;
public @Load("@-side2") TextureRegion sideRegion2;
public int tier = 1; public int tier = 1;
public UnitAssemblerModule(String name){ public UnitAssemblerModule(String name){
@@ -38,6 +43,18 @@ public class UnitAssemblerModule extends PayloadBlock{
return getLink(team, tile.x, tile.y, rotation) != null; 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){ public @Nullable UnitAssemblerBuild getLink(Team team, int x, int y, int rotation){
var results = Vars.indexer.getFlagged(team, BlockFlag.unitAssembler).<UnitAssemblerBuild>as(); 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); Draw.z(Layer.blockOver);
payRotation = rotdeg(); payRotation = rotdeg();
drawPayload(); drawPayload();
@@ -109,7 +128,7 @@ public class UnitAssemblerModule extends PayloadBlock{
findLink(); 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); link.yeetPayload(payload);
payload = null; payload = null;
} }

View File

@@ -24,4 +24,4 @@ android.useAndroidX=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=15f2f63a9f archash=309d2fc02d