Mostly-complete cliff crusher implementation
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/drills/cliff-crusher-top.png
Normal file
BIN
core/assets-raw/sprites/blocks/drills/cliff-crusher-top.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 354 B |
BIN
core/assets-raw/sprites/blocks/drills/cliff-crusher.png
Normal file
BIN
core/assets-raw/sprites/blocks/drills/cliff-crusher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -393,3 +393,4 @@
|
||||
63340=carbon-boulder|block-carbon-boulder-ui
|
||||
63339=carbon-stone|block-carbon-stone-ui
|
||||
63338=payload-deconstructor|block-payload-deconstructor-ui
|
||||
63337=cliff-crusher|block-cliff-crusher-ui
|
||||
|
||||
Binary file not shown.
@@ -395,6 +395,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
duneWall = new StaticWall("dune-wall"){{
|
||||
basalt.asFloor().wall = darksandWater.asFloor().wall = darksandTaintedWater.asFloor().wall = this;
|
||||
attributes.set(Attribute.silicate, 2f);
|
||||
}};
|
||||
|
||||
regolithWall = new StaticWall("regolith-wall"){{
|
||||
@@ -411,6 +412,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
carbonWall = new StaticWall("carbon-wall"){{
|
||||
carbonStone.asFloor().wall = this;
|
||||
attributes.set(Attribute.silicate, 0.7f);
|
||||
}};
|
||||
|
||||
ferricStoneWall = new StaticWall("ferric-stone-wall"){{
|
||||
@@ -429,6 +431,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
sandWall = new StaticWall("sand-wall"){{
|
||||
sandWater.asFloor().wall = water.asFloor().wall = deepwater.asFloor().wall = this;
|
||||
attributes.set(Attribute.silicate, 2f);
|
||||
}};
|
||||
|
||||
saltWall = new StaticWall("salt-wall");
|
||||
@@ -1515,8 +1518,9 @@ public class Blocks implements ContentList{
|
||||
|
||||
cliffCrusher = new WallCrafter("cliff-crusher"){{
|
||||
requirements(Category.production, with(Items.copper, 10));
|
||||
consumes.power(0.2f);
|
||||
consumes.power(0.9f);
|
||||
|
||||
drillTime = 110f;
|
||||
size = 2;
|
||||
attribute = Attribute.silicate;
|
||||
output = Items.sand;
|
||||
|
||||
@@ -1689,6 +1689,13 @@ public class Fx{
|
||||
Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8);
|
||||
}),
|
||||
|
||||
mineWallSmall = new Effect(50, e -> {
|
||||
color(e.color, Color.darkGray, e.fin());
|
||||
randLenVectors(e.id, 2, e.fin() * 6f, (x, y) -> {
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() + 0.5f);
|
||||
});
|
||||
}),
|
||||
|
||||
mineSmall = new Effect(30, e -> {
|
||||
color(e.color, Color.lightGray, e.fin());
|
||||
randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> {
|
||||
|
||||
@@ -12,19 +12,27 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class WallCrafter extends Block{
|
||||
static int idx = 0;
|
||||
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
public @Load("@-rotator-bottom") TextureRegion rotatorBottomRegion;
|
||||
public @Load("@-rotator") TextureRegion rotatorRegion;
|
||||
|
||||
/** Time to produce one item at 100% efficiency. */
|
||||
public float drillTime = 200f;
|
||||
public float drillTime = 150f;
|
||||
/** Effect randomly played while drilling. */
|
||||
public Effect updateEffect = Fx.mineSmall;
|
||||
public Effect updateEffect = Fx.mineWallSmall;
|
||||
public float updateEffectChance = 0.02f;
|
||||
public float rotateSpeed = 2f;
|
||||
/** Attribute to check for wall output. */
|
||||
public Attribute attribute = Attribute.silicate;
|
||||
|
||||
@@ -44,6 +52,9 @@ public class WallCrafter extends Block{
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("drillspeed", (WallCrafterBuild e) ->
|
||||
new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(e.lastEfficiency * 60 / drillTime, 2)), () -> Pal.ammo, () -> e.warmup));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,16 +88,16 @@ public class WallCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
float eff = getEfficiency(x, y, rotation, null);
|
||||
float eff = getEfficiency(x, y, rotation, null, null);
|
||||
|
||||
drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / drillTime * eff, 2), x, y, valid);
|
||||
}
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
return getEfficiency(tile.x, tile.y, rotation, null) > 0;
|
||||
return getEfficiency(tile.x, tile.y, rotation, null, null) > 0;
|
||||
}
|
||||
|
||||
float getEfficiency(int tx, int ty, int rotation, @Nullable Cons<Tile> ctile){
|
||||
float getEfficiency(int tx, int ty, int rotation, @Nullable Cons<Tile> ctile, @Nullable Intc2 cpos){
|
||||
float eff = 0f;
|
||||
int cornerX = tx - (size-1)/2, cornerY = ty - (size-1)/2, s = size;
|
||||
|
||||
@@ -112,6 +123,10 @@ public class WallCrafter extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
if(cpos != null){
|
||||
cpos.get(rx, ry);
|
||||
}
|
||||
|
||||
Tile other = world.tile(rx, ry);
|
||||
if(other != null && other.solid()){
|
||||
float at = other.block().attributes.get(attribute);
|
||||
@@ -125,8 +140,7 @@ public class WallCrafter extends Block{
|
||||
}
|
||||
|
||||
public class WallCrafterBuild extends Building{
|
||||
public float time;
|
||||
public float warmup;
|
||||
public float time, warmup, totalTime, lastEfficiency;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
@@ -139,20 +153,24 @@ public class WallCrafter extends Block{
|
||||
|
||||
float eff = getEfficiency(tile.x, tile.y, rotation, dest -> {
|
||||
//TODO make not chance based?
|
||||
if(cons && Mathf.chanceDelta(0.05 * warmup)){
|
||||
if(cons && Mathf.chanceDelta(updateEffectChance * warmup)){
|
||||
updateEffect.at(
|
||||
dest.worldx() + Mathf.range(3f) - dx,
|
||||
dest.worldy() + Mathf.range(3f) - dy,
|
||||
output.color
|
||||
dest.worldx() + Mathf.range(3f) - dx * tilesize,
|
||||
dest.worldy() + Mathf.range(3f) - dy * tilesize,
|
||||
Tmp.c1.set(dest.block().mapColor).mul(1f)
|
||||
);
|
||||
}
|
||||
});
|
||||
}, null);
|
||||
|
||||
lastEfficiency = eff * timeScale * efficiency();
|
||||
|
||||
if(cons && (time += edelta() * eff) >= drillTime){
|
||||
items.add(output, 1);
|
||||
time %= drillTime;
|
||||
}
|
||||
|
||||
totalTime += edelta() * warmup;
|
||||
|
||||
if(timer(timerDump, dumpTime)){
|
||||
dump();
|
||||
}
|
||||
@@ -168,6 +186,17 @@ public class WallCrafter extends Block{
|
||||
//TODO draw spinner drill thingies
|
||||
Draw.rect(block.region, x, y);
|
||||
Draw.rect(topRegion, x, y, rotdeg());
|
||||
float ds = 0.6f, dx = Geometry.d4x(rotation) * ds, dy = Geometry.d4y(rotation) * ds;
|
||||
|
||||
int bs = (rotation == 0 || rotation == 3) ? 1 : -1;
|
||||
idx = 0;
|
||||
getEfficiency(tile.x, tile.y, rotation, null, (cx, cy) -> {
|
||||
int sign = idx++ >= size/2 && size % 2 == 0 ? -1 : 1;
|
||||
float vx = (cx - dx) * tilesize, vy = (cy - dy) * tilesize;
|
||||
Draw.z(Layer.blockOver);
|
||||
Draw.rect(rotatorBottomRegion, vx, vy, totalTime * rotateSpeed * sign * bs);
|
||||
Draw.rect(rotatorRegion, vx, vy);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user