Various prototypes
@ -224,3 +224,5 @@
|
||||
63520=legacy-mech-pad|block-legacy-mech-pad-medium
|
||||
63519=ground-factory|block-ground-factory-medium
|
||||
63518=legacy-unit-factory|block-legacy-unit-factory-medium
|
||||
63517=mass-conveyor|block-mass-conveyor-medium
|
||||
63516=legacy-command-center|block-legacy-command-center-medium
|
||||
|
Before Width: | Height: | Size: 705 B After Width: | Height: | Size: 707 B |
Before Width: | Height: | Size: 714 KiB After Width: | Height: | Size: 728 KiB |
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 221 KiB |
Before Width: | Height: | Size: 813 KiB After Width: | Height: | Size: 817 KiB |
@ -56,7 +56,8 @@ public class Blocks implements ContentList{
|
||||
scrapWall, scrapWallLarge, scrapWallHuge, scrapWallGigantic, thruster, //ok, these names are getting ridiculous, but at least I don't have humongous walls yet
|
||||
|
||||
//transport
|
||||
conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate, underflowGate, massDriver,
|
||||
conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate,
|
||||
underflowGate, massDriver, massConveyor,
|
||||
|
||||
//liquid
|
||||
mechanicalPump, rotaryPump, thermalPump, conduit, pulseConduit, platedConduit, liquidRouter, liquidTank, liquidJunction, bridgeConduit, phaseConduit,
|
||||
@ -975,6 +976,10 @@ public class Blocks implements ContentList{
|
||||
consumes.power(1.75f);
|
||||
}};
|
||||
|
||||
massConveyor = new MassConveyor("mass-conveyor"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 1));
|
||||
}};
|
||||
|
||||
//endregion
|
||||
//region liquid
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
image.setImageSize(editor.width(), editor.height());
|
||||
|
||||
if(!ScissorStack.pushScissors(rect.set(x, y, width, height))){
|
||||
if(!ScissorStack.push(rect.set(x, y, width, height))){
|
||||
return;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ public class MapView extends Element implements GestureListener{
|
||||
Lines.rect(x, y, width, height);
|
||||
Draw.reset();
|
||||
|
||||
ScissorStack.popScissors();
|
||||
ScissorStack.pop();
|
||||
}
|
||||
|
||||
private boolean active(){
|
||||
|
@ -844,17 +844,20 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
public void drawArrow(Block block, int x, int y, int rotation, boolean valid){
|
||||
float trns = (block.size / 2) * tilesize;
|
||||
int dx = Geometry.d4(rotation).x, dy = Geometry.d4(rotation).y;
|
||||
|
||||
Draw.color(!valid ? Pal.removeBack : Pal.accentBack);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
x * tilesize + block.offset(),
|
||||
y * tilesize + block.offset() - 1,
|
||||
x * tilesize + block.offset() + dx*trns,
|
||||
y * tilesize + block.offset() - 1 + dy*trns,
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||
|
||||
Draw.color(!valid ? Pal.remove : Pal.accent);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
x * tilesize + block.offset(),
|
||||
y * tilesize + block.offset(),
|
||||
x * tilesize + block.offset() + dx*trns,
|
||||
y * tilesize + block.offset() + dy*trns,
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ public class Bar extends Element{
|
||||
if(topWidth > Core.atlas.find("bar-top").getWidth()){
|
||||
top.draw(x, y, topWidth, height);
|
||||
}else{
|
||||
if(ScissorStack.pushScissors(scissor.set(x, y, topWidth, height))){
|
||||
if(ScissorStack.push(scissor.set(x, y, topWidth, height))){
|
||||
top.draw(x, y, Core.atlas.find("bar-top").getWidth(), height);
|
||||
ScissorStack.popScissors();
|
||||
ScissorStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,7 +542,7 @@ public class Block extends UnlockableContent{
|
||||
|
||||
while(entityType == null && Block.class.isAssignableFrom(current)){
|
||||
//first class that is subclass of Tilec
|
||||
Class<?> type = Structs.find(current.getDeclaredClasses(), Tilec.class::isAssignableFrom);
|
||||
Class<?> type = Structs.find(current.getDeclaredClasses(), t -> Tilec.class.isAssignableFrom(t) && !t.isInterface());
|
||||
if(type != null){
|
||||
//these are inner classes, so they have an implicit parameter generated
|
||||
Constructor<? extends Tilec> cons = (Constructor<? extends Tilec>)type.getDeclaredConstructor(type.getDeclaringClass());
|
||||
|
@ -1,58 +1,233 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
//TODO rename
|
||||
public class MassConveyor extends Block{
|
||||
public float moveTime = 70f;
|
||||
public TextureRegion topRegion, edgeRegion;
|
||||
|
||||
public MassConveyor(String name){
|
||||
super(name);
|
||||
|
||||
layer = Layer.overlay;
|
||||
size = 3;
|
||||
rotate = true;
|
||||
update = true;
|
||||
}
|
||||
|
||||
public class MassConveyorEntity extends TileEntity{
|
||||
public Conveyable item;
|
||||
public float progress;
|
||||
public @Nullable Tilec next;
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
topRegion = Core.atlas.find(name + "-top");
|
||||
edgeRegion = Core.atlas.find(name + "-edge");
|
||||
}
|
||||
|
||||
public class MassConveyorEntity extends TileEntity implements MassAcceptor{
|
||||
public @Nullable Payload item;
|
||||
public float progress, itemRotation;
|
||||
public @Nullable MassAcceptor next;
|
||||
public boolean blocked;
|
||||
public int step = -1, stepAccepted = -1;
|
||||
|
||||
@Override
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
||||
next = front();
|
||||
Tilec accept = nearby(Geometry.d4[rotation()].x * size, Geometry.d4[rotation()].y * size);
|
||||
//next block must be aligned and of the same size
|
||||
if(next.block().size != size || x + Geometry.d4[rotation()].x * size != next.tileX() || y + Geometry.d4[rotation()].y * size != next.tileY()){
|
||||
next = null;
|
||||
if(accept instanceof MassAcceptor && accept.block().size == size &&
|
||||
tileX() + Geometry.d4[rotation()].x * size == accept.tileX() && tileY() + Geometry.d4[rotation()].y * size == accept.tileY()){
|
||||
next = (MassAcceptor)accept;
|
||||
}
|
||||
|
||||
int ntrns = 1 + size/2;
|
||||
Tile next = tile.getNearby(Geometry.d4[rotation()].x * ntrns, Geometry.d4[rotation()].y * ntrns);
|
||||
blocked = next != null && next.solid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
progress += edelta();
|
||||
if(progress >= moveTime){
|
||||
//todo step
|
||||
progress = 0;
|
||||
progress = Time.time() % moveTime;
|
||||
|
||||
//TODO DEBUG
|
||||
if(Core.input.keyTap(KeyCode.G) && world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y) == tile){
|
||||
item = new UnitPayload(UnitTypes.dagger.create(Team.sharded));
|
||||
itemRotation = rotation() * 90;
|
||||
}
|
||||
|
||||
int curStep = curStep();
|
||||
if(curStep > step){
|
||||
if(step != -1 && stepAccepted != curStep){
|
||||
if(canMove()){
|
||||
//move forward.
|
||||
next.handleMass(item, this);
|
||||
item = null;
|
||||
}
|
||||
}
|
||||
|
||||
step = curStep;
|
||||
}
|
||||
|
||||
|
||||
//dumping item forward.
|
||||
if(fract() >= 0.5f && item != null && !blocked && next == null){
|
||||
float trnext = fract() * size * tilesize, cx = Geometry.d4[rotation()].x, cy = Geometry.d4[rotation()].y, rot = rotation() * 90;
|
||||
|
||||
item.dump(x + cx * trnext, y + cy * trnext, rotation() * 90);
|
||||
item = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
float dst = 0.8f;
|
||||
|
||||
float glow = Math.max((dst - (Math.abs(fract() - 0.5f) * 2)) / dst, 0);
|
||||
Draw.mixcol(Pal.accent, glow);
|
||||
|
||||
float trnext = fract() * size * tilesize, trprev = size * tilesize * (fract() - 1), rot = rotation() * 90;
|
||||
|
||||
TextureRegion clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trnext, 0), topRegion);
|
||||
float s = tilesize * size;
|
||||
|
||||
//next
|
||||
Tmp.v1.set((s-clipped.getWidth()*Draw.scl) + clipped.getWidth()/2f*Draw.scl - s/2f, s-clipped.getHeight()*Draw.scl + clipped.getHeight()/2f*Draw.scl - s/2f).rotate(rot);
|
||||
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot);
|
||||
|
||||
clipped = clipRegion(tile.getHitbox(Tmp.r1), tile.getHitbox(Tmp.r2).move(trprev, 0), topRegion);
|
||||
|
||||
//prev
|
||||
Tmp.v1.set(- s/2f + clipped.getWidth()/2f*Draw.scl, - s/2f + clipped.getHeight()/2f*Draw.scl).rotate(rot);
|
||||
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(!blends(i)){
|
||||
Draw.rect(edgeRegion, x, y, i * 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
public void drawLayer(){
|
||||
float fract = !blocked ? fract() : fract() > 0.5f ? 1f - fract() : fract();
|
||||
float trnext = fract * size * tilesize, cx = Geometry.d4[rotation()].x, cy = Geometry.d4[rotation()].y, rot = Mathf.slerp(itemRotation, rotation() * 90, fract);
|
||||
|
||||
if(item != null){
|
||||
Draw.color(0, 0, 0, 0.4f);
|
||||
float size = 21;
|
||||
Draw.rect("circle-shadow", x + cx * trnext, y + cy * trnext, size, size);
|
||||
Draw.color();
|
||||
|
||||
item.draw(x + cx * trnext, y + cy * trnext, rot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(){
|
||||
public boolean acceptMass(Payload item, Tilec source){
|
||||
return this.item == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMass(Payload item, Tilec source){
|
||||
this.item = item;
|
||||
this.stepAccepted = curStep();
|
||||
this.itemRotation = source.rotation() * 90;
|
||||
}
|
||||
|
||||
boolean blends(int direction){
|
||||
if(direction == rotation()){
|
||||
return !blocked;
|
||||
}else{
|
||||
Tilec accept = nearby(Geometry.d4[direction].x * size, Geometry.d4[direction].y * size);
|
||||
return accept instanceof MassAcceptor && accept.block().size == size &&
|
||||
accept.tileX() + Geometry.d4[accept.rotation()].x * size == tileX() && accept.tileY() + Geometry.d4[accept.rotation()].y * size == tileY();
|
||||
}
|
||||
}
|
||||
|
||||
boolean canMove(){
|
||||
return item != null && next != null && next.acceptMass(item, this);
|
||||
}
|
||||
|
||||
TextureRegion clipRegion(Rect bounds, Rect sprite, TextureRegion region){
|
||||
Rect over = Tmp.r3;
|
||||
|
||||
boolean overlaps = Intersector.intersectRectangles(bounds, sprite, over);
|
||||
|
||||
TextureRegion out = Tmp.tr1;
|
||||
out.set(region.getTexture());
|
||||
|
||||
if(overlaps){
|
||||
float w = region.getU2() - region.getU();
|
||||
float h = region.getV2() - region.getV();
|
||||
float x = region.getU(), y = region.getV();
|
||||
float newX = (over.x - sprite.x) / sprite.width * w + x;
|
||||
float newY = (over.y - sprite.y) / sprite.height * h + y;
|
||||
float newW = (over.width / sprite.width) * w, newH = (over.height / sprite.height) * h;
|
||||
|
||||
out.set(newX, newY, newX + newW, newY + newH);
|
||||
}else{
|
||||
out.set(0f, 0f, 0f, 0f);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
int curStep(){
|
||||
return (int)(Time.time() / moveTime);
|
||||
}
|
||||
|
||||
float fract(){
|
||||
return Interpolation.pow5.apply(progress / moveTime);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Conveyable{
|
||||
void drawConvey(float x, float y, float rotation);
|
||||
public interface MassAcceptor extends Tilec{
|
||||
boolean acceptMass(Payload item, Tilec source);
|
||||
void handleMass(Payload item, Tilec source);
|
||||
}
|
||||
|
||||
public interface Payload{
|
||||
void draw(float x, float y, float rotation);
|
||||
void dump(float x, float y, float rotation);
|
||||
}
|
||||
|
||||
public static class UnitPayload implements Payload{
|
||||
Unitc unit;
|
||||
|
||||
public UnitPayload(Unitc unit){
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(float x, float y, float rotation){
|
||||
unit.set(x, y);
|
||||
unit.rotation(rotation);
|
||||
unit.add();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(float x, float y, float rotation){
|
||||
Draw.rect(unit.type().icon(Cicon.full), x, y, rotation - 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
liquidCapacity = 30f;
|
||||
hasItems = true;
|
||||
outputsPower = consumesPower = true;
|
||||
bottomRegion = reg("-bottom");
|
||||
bottomRegion = reg("-bottom");
|
||||
plasmaRegions = new int[plasmas];
|
||||
for(int i = 0; i < plasmas; i++){
|
||||
plasmaRegions[i] = reg("-plasma-" + i);
|
||||
@ -100,8 +100,8 @@ public class ImpactReactor extends PowerGenerator{
|
||||
public void draw(){
|
||||
Draw.rect(reg(bottomRegion), x, y);
|
||||
|
||||
for(int i = 0; i < plasmas; i++){
|
||||
float r = size * tilesize - 3f + Mathf.absin(Time.time(), 2f + i * 1f, 5f - i * 0.5f);
|
||||
for(int i = 0; i < plasmas; i++){
|
||||
float r = size * tilesize - 3f + Mathf.absin(Time.time(), 2f + i * 1f, 5f - i * 0.5f);
|
||||
|
||||
Draw.color(plasma1, plasma2, (float)i / plasmas);
|
||||
Draw.alpha((0.3f + Mathf.absin(Time.time(), 2f + i * 2f, 0.3f + i * 0.05f)) * warmup);
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=0dc4ad593d0b24c48dab44fdd4f39f2fd105fb60
|
||||
archash=bc7c6ea8654fa1d476f228a62327b2fbb0085b2f
|
||||
|