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
|
63340=carbon-boulder|block-carbon-boulder-ui
|
||||||
63339=carbon-stone|block-carbon-stone-ui
|
63339=carbon-stone|block-carbon-stone-ui
|
||||||
63338=payload-deconstructor|block-payload-deconstructor-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"){{
|
duneWall = new StaticWall("dune-wall"){{
|
||||||
basalt.asFloor().wall = darksandWater.asFloor().wall = darksandTaintedWater.asFloor().wall = this;
|
basalt.asFloor().wall = darksandWater.asFloor().wall = darksandTaintedWater.asFloor().wall = this;
|
||||||
|
attributes.set(Attribute.silicate, 2f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
regolithWall = new StaticWall("regolith-wall"){{
|
regolithWall = new StaticWall("regolith-wall"){{
|
||||||
@@ -411,6 +412,7 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
carbonWall = new StaticWall("carbon-wall"){{
|
carbonWall = new StaticWall("carbon-wall"){{
|
||||||
carbonStone.asFloor().wall = this;
|
carbonStone.asFloor().wall = this;
|
||||||
|
attributes.set(Attribute.silicate, 0.7f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
ferricStoneWall = new StaticWall("ferric-stone-wall"){{
|
ferricStoneWall = new StaticWall("ferric-stone-wall"){{
|
||||||
@@ -429,6 +431,7 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
sandWall = new StaticWall("sand-wall"){{
|
sandWall = new StaticWall("sand-wall"){{
|
||||||
sandWater.asFloor().wall = water.asFloor().wall = deepwater.asFloor().wall = this;
|
sandWater.asFloor().wall = water.asFloor().wall = deepwater.asFloor().wall = this;
|
||||||
|
attributes.set(Attribute.silicate, 2f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
saltWall = new StaticWall("salt-wall");
|
saltWall = new StaticWall("salt-wall");
|
||||||
@@ -1515,8 +1518,9 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
cliffCrusher = new WallCrafter("cliff-crusher"){{
|
cliffCrusher = new WallCrafter("cliff-crusher"){{
|
||||||
requirements(Category.production, with(Items.copper, 10));
|
requirements(Category.production, with(Items.copper, 10));
|
||||||
consumes.power(0.2f);
|
consumes.power(0.9f);
|
||||||
|
|
||||||
|
drillTime = 110f;
|
||||||
size = 2;
|
size = 2;
|
||||||
attribute = Attribute.silicate;
|
attribute = Attribute.silicate;
|
||||||
output = Items.sand;
|
output = Items.sand;
|
||||||
|
|||||||
@@ -1689,6 +1689,13 @@ public class Fx{
|
|||||||
Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8);
|
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 -> {
|
mineSmall = new Effect(30, e -> {
|
||||||
color(e.color, Color.lightGray, e.fin());
|
color(e.color, Color.lightGray, e.fin());
|
||||||
randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> {
|
randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> {
|
||||||
|
|||||||
@@ -12,19 +12,27 @@ import mindustry.entities.*;
|
|||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class WallCrafter extends Block{
|
public class WallCrafter extends Block{
|
||||||
|
static int idx = 0;
|
||||||
|
|
||||||
public @Load("@-top") TextureRegion topRegion;
|
public @Load("@-top") TextureRegion topRegion;
|
||||||
|
public @Load("@-rotator-bottom") TextureRegion rotatorBottomRegion;
|
||||||
|
public @Load("@-rotator") TextureRegion rotatorRegion;
|
||||||
|
|
||||||
/** Time to produce one item at 100% efficiency. */
|
/** Time to produce one item at 100% efficiency. */
|
||||||
public float drillTime = 200f;
|
public float drillTime = 150f;
|
||||||
/** Effect randomly played while drilling. */
|
/** 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. */
|
/** Attribute to check for wall output. */
|
||||||
public Attribute attribute = Attribute.silicate;
|
public Attribute attribute = Attribute.silicate;
|
||||||
|
|
||||||
@@ -44,6 +52,9 @@ public class WallCrafter extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
super.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
|
@Override
|
||||||
@@ -77,16 +88,16 @@ public class WallCrafter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
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);
|
drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / drillTime * eff, 2), x, y, valid);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
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;
|
float eff = 0f;
|
||||||
int cornerX = tx - (size-1)/2, cornerY = ty - (size-1)/2, s = size;
|
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);
|
Tile other = world.tile(rx, ry);
|
||||||
if(other != null && other.solid()){
|
if(other != null && other.solid()){
|
||||||
float at = other.block().attributes.get(attribute);
|
float at = other.block().attributes.get(attribute);
|
||||||
@@ -125,8 +140,7 @@ public class WallCrafter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class WallCrafterBuild extends Building{
|
public class WallCrafterBuild extends Building{
|
||||||
public float time;
|
public float time, warmup, totalTime, lastEfficiency;
|
||||||
public float warmup;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
@@ -139,20 +153,24 @@ public class WallCrafter extends Block{
|
|||||||
|
|
||||||
float eff = getEfficiency(tile.x, tile.y, rotation, dest -> {
|
float eff = getEfficiency(tile.x, tile.y, rotation, dest -> {
|
||||||
//TODO make not chance based?
|
//TODO make not chance based?
|
||||||
if(cons && Mathf.chanceDelta(0.05 * warmup)){
|
if(cons && Mathf.chanceDelta(updateEffectChance * warmup)){
|
||||||
updateEffect.at(
|
updateEffect.at(
|
||||||
dest.worldx() + Mathf.range(3f) - dx,
|
dest.worldx() + Mathf.range(3f) - dx * tilesize,
|
||||||
dest.worldy() + Mathf.range(3f) - dy,
|
dest.worldy() + Mathf.range(3f) - dy * tilesize,
|
||||||
output.color
|
Tmp.c1.set(dest.block().mapColor).mul(1f)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}, null);
|
||||||
|
|
||||||
|
lastEfficiency = eff * timeScale * efficiency();
|
||||||
|
|
||||||
if(cons && (time += edelta() * eff) >= drillTime){
|
if(cons && (time += edelta() * eff) >= drillTime){
|
||||||
items.add(output, 1);
|
items.add(output, 1);
|
||||||
time %= drillTime;
|
time %= drillTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalTime += edelta() * warmup;
|
||||||
|
|
||||||
if(timer(timerDump, dumpTime)){
|
if(timer(timerDump, dumpTime)){
|
||||||
dump();
|
dump();
|
||||||
}
|
}
|
||||||
@@ -168,6 +186,17 @@ public class WallCrafter extends Block{
|
|||||||
//TODO draw spinner drill thingies
|
//TODO draw spinner drill thingies
|
||||||
Draw.rect(block.region, x, y);
|
Draw.rect(block.region, x, y);
|
||||||
Draw.rect(topRegion, x, y, rotdeg());
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ def transformColors = { List<List<String>> list ->
|
|||||||
//d4816b
|
//d4816b
|
||||||
transformColors([["a387ea", "8a73c6", "5c5e9f"], ["6e7080", "989aa4", "b0bac0"], ["bc5452", "ea8878", "feb380"],
|
transformColors([["a387ea", "8a73c6", "5c5e9f"], ["6e7080", "989aa4", "b0bac0"], ["bc5452", "ea8878", "feb380"],
|
||||||
["de9458", "f8c266", "ffe18f"], ["feb380", "ea8878", "bc5452"], ["d4816b", "eab678", "ffd37f"],
|
["de9458", "f8c266", "ffe18f"], ["feb380", "ea8878", "bc5452"], ["d4816b", "eab678", "ffd37f"],
|
||||||
["ffffff", "dcc6c6", "9d7f7f"], ["df7646", "b23a4d", "752249"], ["3c3837", "515151", "646567"]])
|
["ffffff", "dcc6c6", "9d7f7f"], ["df7646", "b23a4d", "752249"], ["3c3837", "515151", "646567"],
|
||||||
|
["5757c1", "6f80e8", "88a4ff"], ["8f665b", "b28768", "c9a58f"]])
|
||||||
|
|
||||||
def antialias = { File file ->
|
def antialias = { File file ->
|
||||||
if(!doAntialias) return
|
if(!doAntialias) return
|
||||||
|
|||||||
Reference in New Issue
Block a user