mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-23 06:07:47 +07:00
"Better" build tower sprite / Assembly cleanup
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/defense/build-tower-glow.png
Normal file
BIN
core/assets-raw/sprites/blocks/defense/build-tower-glow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.5 KiB |
@ -95,10 +95,18 @@ public class Drawf{
|
||||
}
|
||||
}
|
||||
|
||||
public static void additive(TextureRegion region, Color color, float x, float y, float rotation){
|
||||
additive(region, color, x, y, rotation, Layer.blockAdditive);
|
||||
}
|
||||
|
||||
public static void additive(TextureRegion region, Color color, float x, float y, float rotation, float layer){
|
||||
additive(region, color, 1f, x, y, rotation, layer);
|
||||
}
|
||||
|
||||
public static void additive(TextureRegion region, Color color, float alpha, float x, float y, float rotation, float layer){
|
||||
float pz = Draw.z();
|
||||
Draw.z(layer);
|
||||
Draw.color(color);
|
||||
Draw.color(color, alpha * color.a);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.rect(region, x, y, rotation);
|
||||
Draw.blend();
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mindustry.world.blocks.defense;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
@ -25,11 +27,13 @@ public class BuildTurret extends BaseTurret{
|
||||
public int targetInterval = 30;
|
||||
|
||||
public @Load(value = "@-base", fallback = "block-@size") TextureRegion baseRegion;
|
||||
public @Load("@-glow") TextureRegion glowRegion;
|
||||
public float buildSpeed = 1f;
|
||||
public float buildBeamOffset = 5f;
|
||||
//created in init()
|
||||
public @Nullable UnitType unitType;
|
||||
public float elevation = -1f;
|
||||
public Color heatColor = Pal.accent.cpy().a(0.9f);
|
||||
|
||||
public BuildTurret(String name){
|
||||
super(name);
|
||||
@ -70,6 +74,7 @@ public class BuildTurret extends BaseTurret{
|
||||
public BlockUnitc unit = (BlockUnitc)unitType.create(team);
|
||||
public @Nullable Unit following;
|
||||
public @Nullable BlockPlan lastPlan;
|
||||
public float warmup;
|
||||
|
||||
{
|
||||
unit.rotation(90f);
|
||||
@ -103,6 +108,8 @@ public class BuildTurret extends BaseTurret{
|
||||
unit.buildSpeedMultiplier(efficiency() * timeScale);
|
||||
unit.speedMultiplier(efficiency() * timeScale);
|
||||
|
||||
warmup = Mathf.lerpDelta(warmup, unit.activelyBuilding() ? 1f : 0f, 0.1f);
|
||||
|
||||
if(!isControlled()){
|
||||
unit.updateBuilding(true);
|
||||
|
||||
@ -210,9 +217,18 @@ public class BuildTurret extends BaseTurret{
|
||||
Drawf.shadow(region, x - elevation, y - elevation, rotation - 90);
|
||||
Draw.rect(region, x, y, rotation - 90);
|
||||
|
||||
if(glowRegion.found()){
|
||||
Drawf.additive(glowRegion, heatColor, warmup, x, y, rotation - 90f, Layer.turretHeat);
|
||||
}
|
||||
|
||||
unit.drawBuilding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float warmup(){
|
||||
return warmup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
|
@ -26,13 +26,6 @@ import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/**
|
||||
* Steps:
|
||||
* 0. place the assembler with the rectangle indicating build area
|
||||
* 1. wait for power/consValid
|
||||
* 2. print / create the 3-5 drones for free, make sure they're tethered - build speed depends on drone active fraction
|
||||
* 3.
|
||||
* */
|
||||
public class UnitAssembler extends PayloadBlock{
|
||||
public @Load("@-side1") TextureRegion sideRegion1;
|
||||
public @Load("@-side2") TextureRegion sideRegion2;
|
||||
@ -66,7 +59,6 @@ public class UnitAssembler extends PayloadBlock{
|
||||
Tmp.r1.x += Geometry.d4x(rotation) * len;
|
||||
Tmp.r1.y += Geometry.d4y(rotation) * len;
|
||||
|
||||
//TODO better visuals here? dashLine looks bad
|
||||
Drawf.dashRect(valid ? Pal.accent : Pal.remove, Tmp.r1);
|
||||
}
|
||||
|
||||
@ -237,26 +229,8 @@ public class UnitAssembler extends PayloadBlock{
|
||||
for(var module : modules){
|
||||
Drawf.selected(module, Pal.accent);
|
||||
}
|
||||
|
||||
//TODO draw area when no power
|
||||
}
|
||||
|
||||
//is this necessary? wastes a lot of space
|
||||
/*
|
||||
@Override
|
||||
public void displayConsumption(Table table){
|
||||
super.displayConsumption(table);
|
||||
table.row();
|
||||
|
||||
table.table(t -> {
|
||||
t.left();
|
||||
for(var mod : modules){
|
||||
//TODO crosses for missing reqs?
|
||||
t.image(mod.block.uiIcon).size(iconMed).padRight(4).padTop(4);
|
||||
}
|
||||
}).fillX().row();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
super.display(table);
|
||||
@ -311,8 +285,6 @@ public class UnitAssembler extends PayloadBlock{
|
||||
droneProgress = 0f;
|
||||
}
|
||||
|
||||
//TODO units should pick up and move payloads into position
|
||||
|
||||
Vec2 spawn = getUnitSpawn();
|
||||
|
||||
if(moveInPayload() && !wasOccupied){
|
||||
@ -341,14 +313,11 @@ public class UnitAssembler extends PayloadBlock{
|
||||
warmup = Mathf.lerpDelta(warmup, efficiency(), 0.1f);
|
||||
|
||||
if((progress += edelta() * eff / plan.time) >= 1f){
|
||||
//TODO ???? should this even be part of a trigger
|
||||
consume();
|
||||
|
||||
//TODO actually just goes poof
|
||||
var unit = plan.unit.create(team);
|
||||
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();
|
||||
progress = 0f;
|
||||
|
||||
@ -359,8 +328,6 @@ public class UnitAssembler extends PayloadBlock{
|
||||
}else{
|
||||
warmup = Mathf.lerpDelta(warmup, 0f, 0.1f);
|
||||
}
|
||||
|
||||
//TODO drones need to indicate that they are in position and actually play an animation
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -387,7 +354,6 @@ public class UnitAssembler extends PayloadBlock{
|
||||
|
||||
//draw drone construction
|
||||
if(droneWarmup > 0){
|
||||
//TODO draw it - better animations?
|
||||
Draw.draw(Layer.blockOver + 0.2f, () -> {
|
||||
Drawf.construct(this, droneType.fullIcon, Pal.accent, 0f, droneProgress, droneWarmup, totalDroneProgress, 14f);
|
||||
});
|
||||
@ -411,16 +377,6 @@ public class UnitAssembler extends PayloadBlock{
|
||||
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);
|
||||
|
@ -106,7 +106,7 @@ public class UnitAssemblerModule extends PayloadBlock{
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
//TODO draw area
|
||||
//TODO draw area?
|
||||
if(link != null){
|
||||
Drawf.selected(link, Pal.accent);
|
||||
}
|
||||
|
@ -133,47 +133,6 @@ def antialias = { File file ->
|
||||
new Fi(file).writePng(out)
|
||||
}
|
||||
|
||||
def tileImage = { File file ->
|
||||
def image = new Pixmap(new Fi(file))
|
||||
|
||||
for(x in 0..image.width-1){
|
||||
for(y in 0..image.height-1){
|
||||
if(x > (image.height - 1 - y)){
|
||||
def rx = image.height - 1 - y
|
||||
def ry = x
|
||||
|
||||
image.setRaw(x, y, image.getRaw(rx, image.height - 1 - ry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def result = new Pixmap(image.width * 2, image.height * 2)
|
||||
|
||||
result.draw(image.flipX(), 0, 0)
|
||||
result.draw(image, image.width, 0)
|
||||
result.draw(image.flipX().flipY(), 0, image.height)
|
||||
result.draw(image.flipY(), image.width, image.height)
|
||||
|
||||
for(x in 0..result.width-1){
|
||||
for(y in 0..result.height-1){
|
||||
int p = result.getRaw(x, y)
|
||||
if(x <= y){
|
||||
List<Color> list = colorMap.get(p)
|
||||
int index = colorIndexMap.get(p, -1)
|
||||
|
||||
if(index != -1){
|
||||
int resultIndex = (x == y ? 1 : index == 2 ? 0 : index == 0 ? 2 : 1);
|
||||
result.setRaw(x, y, list[resultIndex].rgba())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new Fi(file).writePng(result)
|
||||
result.dispose()
|
||||
image.dispose()
|
||||
}
|
||||
|
||||
task antialiasImages(){
|
||||
doLast{
|
||||
for(def img : project.getProperty("images").split(",")){
|
||||
|
Reference in New Issue
Block a user