Carbide, surge conveyors

This commit is contained in:
Anuken
2021-11-05 16:41:08 -04:00
parent 57ef7c823e
commit 6b3dfa6036
21 changed files with 92 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
package mindustry.content;
import arc.graphics.*;
import arc.math.*;
import arc.struct.*;
import mindustry.*;
import mindustry.ctype.*;
@@ -60,6 +59,7 @@ public class Blocks implements ContentList{
//crafting
siliconSmelter, siliconCrucible, siliconArcFurnace, kiln, graphitePress, plastaniumCompressor, multiPress, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
melter, separator, disassembler, sporePress, pulverizer, incinerator, coalCentrifuge,
carbideCrucible,
cellSynthesisChamber,
//sandbox
@@ -75,6 +75,7 @@ public class Blocks implements ContentList{
conveyor, titaniumConveyor, plastaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router,
overflowGate, underflowGate, massDriver,
duct, ductRouter, ductBridge,
surgeConveyor,
//liquid
mechanicalPump, rotaryPump, thermalPump, conduit, pulseConduit, platedConduit, liquidRouter, liquidContainer, liquidTank, liquidJunction, bridgeConduit, phaseConduit,
@@ -939,6 +940,22 @@ public class Blocks implements ContentList{
consumes.power(0.50f);
}};
carbideCrucible = new GenericCrafter("carbide-crucible"){{
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
craftEffect = Fx.smeltsmoke;
outputItem = new ItemStack(Items.carbide, 1);
craftTime = 30f;
size = 2;
hasPower = hasItems = true;
drawer = new DrawSmelter(Color.valueOf("ffc099"));
ambientSound = Sounds.smelter;
ambientSoundVolume = 0.07f;
//TODO use heat!
consumes.items(with(Items.tungsten, 1, Items.graphite, 2));
consumes.power(2f);
}};
cellSynthesisChamber = new LiquidConverter("cell-synthesis-chamber"){{
//TODO booster mechanics?
requirements(Category.crafting, with(Items.thorium, 100, Items.phaseFabric, 120, Items.titanium, 150, Items.surgeAlloy, 70));
@@ -1277,20 +1294,35 @@ public class Blocks implements ContentList{
//special transport blocks
duct = new Duct("duct"){{
requirements(Category.distribution, BuildVisibility.debugOnly, with(Items.graphite, 5));
requirements(Category.distribution, with(Items.graphite, 5));
speed = 4f;
}};
ductRouter = new DuctRouter("duct-router"){{
requirements(Category.distribution, BuildVisibility.debugOnly, with(Items.graphite, 10));
requirements(Category.distribution, with(Items.graphite, 10));
speed = 4f;
}};
ductBridge = new DuctBridge("duct-bridge"){{
requirements(Category.distribution, BuildVisibility.debugOnly, with(Items.graphite, 20));
requirements(Category.distribution, with(Items.graphite, 20));
speed = 4f;
}};
surgeConveyor = new StackConveyor("surge-conveyor"){{
requirements(Category.distribution, with(Items.surgeAlloy, 3, Items.graphite, 5));
health = 90;
//TODO different base speed/item capacity?
speed = 5f / 60f;
itemCapacity = 10;
outputRouter = false;
hasPower = true;
consumesPower = true;
conductivePower = true;
baseEfficiency = 1f;
consumes.power(1f / 60f);
}};
//endregion
//region liquid

View File

@@ -111,9 +111,7 @@ public class Items implements ContentList{
cost = 1.2f;
}};
//TODO carbide impl
carbide = new Item("carbide", Color.valueOf("768a9a")){{
carbide = new Item("carbide", Color.valueOf("89769a")){{
cost = 1.3f;
}};
}

View File

@@ -845,7 +845,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
for(Building other : proximity){
if(other != null && other.power != null
&& other.team == team
&& !(block.consumesPower && other.block.consumesPower && !block.outputsPower && !other.block.outputsPower)
&& !(block.consumesPower && other.block.consumesPower && !block.outputsPower && !other.block.outputsPower && !block.conductivePower && !other.block.conductivePower)
&& conductsTo(other) && other.conductsTo(self()) && !power.links.contains(other.pos())){
out.add(other);
}

View File

@@ -26,6 +26,9 @@ public class Layer{
//base block layer - most blocks go here
block = 30,
//informal layer used for additive blending overlay, grouped together to reduce draw calls
blockAdditive = 31,
//things drawn over blocks (intermediate layer)
blockOver = 35,

View File

@@ -47,6 +47,7 @@ public class Block extends UnlockableContent{
public boolean outputsLiquid = false;
public boolean consumesPower = true;
public boolean outputsPower = false;
public boolean conductivePower = false;
public boolean outputsPayload = false;
public boolean acceptsPayload = false;
public boolean acceptsItems = false;

View File

@@ -189,7 +189,8 @@ public interface Autotiler{
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| ((!otherblock.rotatedOutput(otherx, othery) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || (otherblock.rotatedOutput(otherx, othery) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) ||
(otherblock.rotatedOutput(otherx, othery) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));
}
/** @return whether this other block is *not* looking at this one. */

View File

@@ -1,5 +1,6 @@
package mindustry.world.blocks.distribution;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.struct.*;
@@ -25,9 +26,15 @@ public class StackConveyor extends Block implements Autotiler{
public @Load(value = "@-#", length = 3) TextureRegion[] regions;
public @Load("@-edge") TextureRegion edgeRegion;
public @Load("@-stack") TextureRegion stackRegion;
/** requires power to work properly */
public @Load(value = "@-glow") TextureRegion glowRegion;
public float glowAlpha = 1f;
public Color glowColor = Pal.redLight;
public float baseEfficiency = 1f;
public float speed = 0f;
public boolean splitOut = true;
public boolean outputRouter = true;
/** (minimum) amount of loading docks needed to fill a line. */
public float recharge = 2f;
public Effect loadEffect = Fx.plasticburn;
@@ -61,7 +68,7 @@ public class StackConveyor extends Block implements Autotiler{
int state = b.state;
if(state == stateLoad){ //standard conveyor mode
return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock);
}else if(state == stateUnload){ //router mode
}else if(state == stateUnload && !outputRouter){ //router mode
return otherblock.acceptsItems &&
(!otherblock.noSideBlend || lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock)) &&
(notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) ||
@@ -105,6 +112,7 @@ public class StackConveyor extends Block implements Autotiler{
public int link = -1;
public float cooldown;
public Item lastItem;
public float glow;
boolean proxUpdating = false;
@@ -124,6 +132,17 @@ public class StackConveyor extends Block implements Autotiler{
Tile from = world.tile(link);
//TODO do not draw for certain configurations?
if(glowRegion.found() && glow > 0f){
Draw.z(Layer.blockAdditive);
Draw.color(glowColor, glowAlpha * glow);
Draw.blend(Blending.additive);
Draw.rect(glowRegion, x, y, rotation * 90);
Draw.blend();
Draw.color();
Draw.z(Layer.block - 0.1f);
}
if(link == -1 || from == null || lastItem == null) return;
int fromRot = from.build == null ? rotation : from.build.rotation;
@@ -139,6 +158,10 @@ public class StackConveyor extends Block implements Autotiler{
if((fromRot%4) == 3 && (rotation%4) == 0) a = -1 * 90;
if((fromRot%4) == 0 && (rotation%4) == 3) a = 4 * 90;
if(glowRegion.found()){
Draw.z(Layer.blockAdditive + 0.01f);
}
//stack
Draw.rect(stackRegion, Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interp.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
@@ -169,13 +192,14 @@ public class StackConveyor extends Block implements Autotiler{
int[] bits = buildBlending(tile, rotation, null, true);
if(bits[0] == 0 && blends(tile, rotation, 0) && !blends(tile, rotation, 2)) state = stateLoad; // a 0 that faces into a conveyor with none behind it
if(bits[0] == 0 && !blends(tile, rotation, 0) && blends(tile, rotation, 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
if(outputRouter && bits[0] == 0 && !blends(tile, rotation, 0) && blends(tile, rotation, 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
if(!outputRouter && !(front() instanceof StackConveyorBuild)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
if(!headless){
blendprox = 0;
for(int i = 0; i < 4; i++){
if(blends(tile, rotation, i)){
if(blends(tile, rotation, i) && (state != stateUnload || outputRouter || i == 0 || nearby(Mathf.mod(rotation - i, 4)) instanceof StackConveyorBuild)){
blendprox |= (1 << i);
}
}
@@ -210,7 +234,7 @@ public class StackConveyor extends Block implements Autotiler{
@Override
public float efficiency(){
return 1f;
return baseEfficiency + (power == null ? 0f : power.status);
}
@Override
@@ -229,12 +253,21 @@ public class StackConveyor extends Block implements Autotiler{
lastItem = items.first();
}
if(power != null) glow = Mathf.lerpDelta(glow, power.status, 0.6f);
//do not continue if disabled, will still allow one to be reeled in to prevent visual stacking
if(!enabled) return;
if(state == stateUnload){ //unload
while(lastItem != null && (!splitOut ? moveForward(lastItem) : dump(lastItem))){
if(items.empty()) poofOut();
while(lastItem != null && (!outputRouter ? moveForward(lastItem) : dump(lastItem))){
if(!outputRouter){
items.remove(lastItem, 1);
}
if(items.empty()){
poofOut();
lastItem = null;
}
}
}else{ //transfer
if(state != stateLoad || (items.total() >= getMaximumAccepted(lastItem))){

View File

@@ -7,6 +7,7 @@ import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.graphics.*;
public class BurstDrill extends Drill{
public float shake = 2f;
@@ -104,8 +105,6 @@ public class BurstDrill extends Drill{
Draw.color();
}
float z = Draw.z();
float fract = smoothProgress;
int arrows = 3;
Draw.color(arrowColor);
@@ -116,13 +115,13 @@ public class BurstDrill extends Drill{
Tmp.v1.trns(i * 90 + 45, j * arrowSpacing);
//TODO maybe just use arrow alpha and that drawn on the base?
Draw.z(z);
Draw.z(Layer.block);
Draw.color(baseArrowColor, arrowColor, a);
Draw.rect(arrowRegion, x + Tmp.v1.x, y + Tmp.v1.y, i * 90);
Draw.color(arrowColor);
Draw.z(z + 0.001f);
Draw.z(Layer.blockAdditive);
Draw.blend(Blending.additive);
Draw.alpha(Mathf.pow(a, 10f));
Draw.rect(arrowBlurRegion, x + Tmp.v1.x, y + Tmp.v1.y, i * 90);