WallCrafter progress
This commit is contained in:
@@ -81,7 +81,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
//production
|
||||
mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, waterExtractor, oilExtractor, cultivator,
|
||||
beamDrill,
|
||||
cliffCrusher, beamDrill,
|
||||
|
||||
//storage
|
||||
coreShard, coreFoundation, coreNucleus, vault, container, unloader,
|
||||
@@ -377,7 +377,9 @@ public class Blocks implements ContentList{
|
||||
wall = sporeWall;
|
||||
}};
|
||||
|
||||
stoneWall = new StaticWall("stone-wall");
|
||||
stoneWall = new StaticWall("stone-wall"){{
|
||||
attributes.set(Attribute.silicate, 1f);
|
||||
}};
|
||||
|
||||
sporeWall = new StaticWall("spore-wall");
|
||||
|
||||
@@ -413,10 +415,12 @@ public class Blocks implements ContentList{
|
||||
|
||||
ferricStoneWall = new StaticWall("ferric-stone-wall"){{
|
||||
ferricStone.asFloor().wall = this;
|
||||
attributes.set(Attribute.silicate, 0.5f);
|
||||
}};
|
||||
|
||||
beryllicStoneWall = new StaticWall("beryllic-stone-wall"){{
|
||||
beryllicStone.asFloor().wall = this;
|
||||
attributes.set(Attribute.silicate, 1.2f);
|
||||
}};
|
||||
|
||||
redIceWall = new StaticWall("red-ice-wall"){{
|
||||
@@ -1509,8 +1513,17 @@ public class Blocks implements ContentList{
|
||||
consumes.liquid(Liquids.water, 0.15f);
|
||||
}};
|
||||
|
||||
cliffCrusher = new WallCrafter("cliff-crusher"){{
|
||||
requirements(Category.production, with(Items.copper, 10));
|
||||
consumes.power(0.2f);
|
||||
|
||||
size = 2;
|
||||
attribute = Attribute.silicate;
|
||||
output = Items.sand;
|
||||
}};
|
||||
|
||||
beamDrill = new BeamDrill("beam-drill"){{
|
||||
requirements(Category.production, with(Items.copper, 150));
|
||||
requirements(Category.production, with(Items.copper, 10));
|
||||
consumes.power(0.2f);
|
||||
tier = 4;
|
||||
size = 2;
|
||||
|
||||
@@ -367,7 +367,7 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Returns whether or not this block can be place on the specified */
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ public class Build{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!type.canPlaceOn(tile, team)){
|
||||
if(!type.canPlaceOn(tile, team, rotation)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
//make sure there's heat at this location
|
||||
return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > 0.01f;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
if(isMultiblock()){
|
||||
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
|
||||
if(canMine(other)){
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Pump extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
if(isMultiblock()){
|
||||
Liquid last = null;
|
||||
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SolidPump extends Pump{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
float sum = tile.getLinkedTilesAs(this, tempTiles).sumf(t -> canPump(t) ? baseEfficiency + (attribute != null ? t.floor().attributes.get(attribute) : 0f) : 0f);
|
||||
return sum > 0.00001f;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.world.blocks.production;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
@@ -9,6 +10,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -24,7 +26,7 @@ public class WallCrafter extends Block{
|
||||
/** Effect randomly played while drilling. */
|
||||
public Effect updateEffect = Fx.mineSmall;
|
||||
/** Attribute to check for wall output. */
|
||||
public Attribute attribute = Attribute.oil; //TODO silicates
|
||||
public Attribute attribute = Attribute.silicate;
|
||||
|
||||
public Item output = Items.sand;
|
||||
|
||||
@@ -35,11 +37,23 @@ public class WallCrafter extends Block{
|
||||
rotate = true;
|
||||
update = true;
|
||||
solid = true;
|
||||
drawArrow = false;
|
||||
|
||||
envEnabled |= Env.space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.output, output);
|
||||
stats.add(Stat.tiles, StatValues.blocks(attribute, floating, 1f, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean outputsItems(){
|
||||
return true;
|
||||
@@ -63,42 +77,57 @@ public class WallCrafter extends Block{
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
float eff = getEfficiency(x, y, rotation, 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;
|
||||
}
|
||||
|
||||
float getEfficiency(int tx, int ty, int rotation, @Nullable Cons<Tile> ctile){
|
||||
float eff = 0f;
|
||||
int cornerX = tx - (size-1)/2, cornerY = ty - (size-1)/2, s = size;
|
||||
|
||||
for(int i = 0; i < size; i++){
|
||||
getLaserPos(x, y, rotation, Tmp.p1);
|
||||
int rx = Tmp.p1.x, ry = Tmp.p1.y;
|
||||
int rx = 0, ry = 0;
|
||||
|
||||
switch(rotation){
|
||||
case 0 -> {
|
||||
rx = cornerX + s;
|
||||
ry = cornerY + i;
|
||||
}
|
||||
case 1 -> {
|
||||
rx = cornerX + i;
|
||||
ry = cornerY + s;
|
||||
}
|
||||
case 2 -> {
|
||||
rx = cornerX - 1;
|
||||
ry = cornerY + i;
|
||||
}
|
||||
case 3 -> {
|
||||
rx = cornerX + i;
|
||||
ry = cornerY - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Tile other = world.tile(rx, ry);
|
||||
if(other != null && other.solid()){
|
||||
eff += other.block().attributes.get(attribute);
|
||||
float at = other.block().attributes.get(attribute);
|
||||
eff += at;
|
||||
if(at > 0 && ctile != null){
|
||||
ctile.get(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / drillTime * eff, 2), x, y, valid);
|
||||
|
||||
}
|
||||
|
||||
void getLaserPos(int tx, int ty, int rotation, Point2 out){
|
||||
int cornerX = tx - (size-1)/2, cornerY = ty - (size-1)/2, s = size;
|
||||
switch(rotation){
|
||||
case 0 -> out.set(cornerX + s, cornerY + 1);
|
||||
case 1 -> out.set(cornerX + 1, cornerY + s);
|
||||
case 2 -> out.set(cornerX - 1, cornerY + 1);
|
||||
case 3 -> out.set(cornerX + 1, cornerY - 1);
|
||||
}
|
||||
return eff;
|
||||
}
|
||||
|
||||
public class WallCrafterBuild extends Building{
|
||||
public float time;
|
||||
public float warmup;
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
|
||||
//TODO efficiency
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
@@ -106,30 +135,21 @@ public class WallCrafter extends Block{
|
||||
boolean cons = shouldConsume();
|
||||
|
||||
warmup = Mathf.lerpDelta(warmup, Mathf.num(consValid()), 0.1f);
|
||||
float eff = 0f;
|
||||
float dx = Geometry.d4x(rotation) * 0.5f, dy = Geometry.d4y(rotation) * 0.5f;
|
||||
|
||||
//update facing tiles
|
||||
for(int p = 0; p < size; p++){
|
||||
getLaserPos(tile.x, tile.y, rotation, Tmp.p1);
|
||||
|
||||
int rx = Tmp.p1.x, ry = Tmp.p1.y;
|
||||
Tile dest = world.tile(rx, ry);
|
||||
if(dest != null && dest.solid()){
|
||||
eff += dest.block().attributes.get(attribute);
|
||||
|
||||
//TODO make not chance based?
|
||||
if(cons && dest.block().attributes.get(attribute) > 0f && Mathf.chanceDelta(0.05 * warmup)){
|
||||
updateEffect.at(dest.worldx() + Mathf.range(3f), dest.worldy() + Mathf.range(3f));
|
||||
}
|
||||
float eff = getEfficiency(tile.x, tile.y, rotation, dest -> {
|
||||
//TODO make not chance based?
|
||||
if(cons && Mathf.chanceDelta(0.05 * warmup)){
|
||||
updateEffect.at(
|
||||
dest.worldx() + Mathf.range(3f) - dx,
|
||||
dest.worldy() + Mathf.range(3f) - dy,
|
||||
output.color
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
time += edelta();
|
||||
|
||||
if(time >= drillTime){
|
||||
|
||||
if(cons && (time += edelta() * eff) >= drillTime){
|
||||
items.add(output, 1);
|
||||
time %= drillTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
if(tile == null) return false;
|
||||
CoreBuild core = team.core();
|
||||
//must have all requirements
|
||||
@@ -168,7 +168,7 @@ public class CoreBlock extends StorageBlock{
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
if(world.tile(x, y) == null) return;
|
||||
|
||||
if(!canPlaceOn(world.tile(x, y), player.team())){
|
||||
if(!canPlaceOn(world.tile(x, y), player.team(), rotation)){
|
||||
|
||||
drawPlaceText(Core.bundle.get(
|
||||
(player.team().core() != null && player.team().core().items.has(requirements, state.rules.buildCostMultiplier)) || state.rules.infiniteResources ?
|
||||
|
||||
@@ -17,7 +17,9 @@ public class Attribute{
|
||||
/** Oil content. Used for oil extractor yield. */
|
||||
oil = add("oil"),
|
||||
/** Light coverage. Negative values decrease solar panel efficiency. */
|
||||
light = add("light");
|
||||
light = add("light"),
|
||||
/** Silicate content. Used for sand extraction. */
|
||||
silicate = add("silicate");
|
||||
|
||||
public final int id;
|
||||
public final String name;
|
||||
|
||||
@@ -112,14 +112,18 @@ public class StatValues{
|
||||
};
|
||||
}
|
||||
|
||||
public static StatValue floorEfficiency(Floor floor, float multiplier, boolean startZero){
|
||||
public static StatValue blockEfficiency(Block floor, float multiplier, boolean startZero){
|
||||
return table -> table.stack(
|
||||
new Image(floor.uiIcon).setScaling(Scaling.fit),
|
||||
new Table(t -> t.top().right().add((multiplier < 0 ? "[scarlet]" : startZero ? "[accent]" : "[accent]+") + (int)((multiplier) * 100) + "%").style(Styles.outlineLabel))
|
||||
);
|
||||
}
|
||||
|
||||
public static StatValue floors(Attribute attr, boolean floating, float scale, boolean startZero){
|
||||
public static StatValue blocks(Attribute attr, boolean floating, float scale, boolean startZero){
|
||||
return blocks(attr, floating, scale, startZero, true);
|
||||
}
|
||||
|
||||
public static StatValue blocks(Attribute attr, boolean floating, float scale, boolean startZero, boolean checkFloors){
|
||||
return table -> table.table(c -> {
|
||||
Runnable[] rebuild = {null};
|
||||
Map[] lastMap = {null};
|
||||
@@ -130,14 +134,14 @@ public class StatValues{
|
||||
|
||||
if(state.isGame()){
|
||||
var blocks = Vars.content.blocks()
|
||||
.select(block -> block instanceof Floor f && indexer.isBlockPresent(block) && f.attributes.get(attr) != 0 && !(f.isLiquid && !floating))
|
||||
.select(block -> (!checkFloors || block instanceof Floor) && indexer.isBlockPresent(block) && block.attributes.get(attr) != 0 && !((block instanceof Floor f && f.isLiquid) && !floating))
|
||||
.<Floor>as().with(s -> s.sort(f -> f.attributes.get(attr)));
|
||||
|
||||
if(blocks.any()){
|
||||
int i = 0;
|
||||
for(var block : blocks){
|
||||
|
||||
floorEfficiency(block, block.attributes.get(attr) * scale, startZero).display(c);
|
||||
blockEfficiency(block, block.attributes.get(attr) * scale, startZero).display(c);
|
||||
if(++i % 5 == 0){
|
||||
c.row();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Stats{
|
||||
}
|
||||
|
||||
public void add(Stat stat, Attribute attr, boolean floating, float scale, boolean startZero){
|
||||
add(stat, StatValues.floors(attr, floating, scale, startZero));
|
||||
add(stat, StatValues.blocks(attr, floating, scale, startZero));
|
||||
}
|
||||
|
||||
/** Adds a single string value with this stat. */
|
||||
|
||||
Reference in New Issue
Block a user