Better spore trees

This commit is contained in:
Anuken
2020-08-14 22:21:47 -04:00
parent 91e5fa5409
commit 98844d752c
24 changed files with 2872 additions and 2824 deletions

View File

@@ -1905,7 +1905,7 @@ public class Blocks implements ContentList{
}};
logicProcessor = new LogicBlock("logic-processor"){{
requirements(Category.logic, with(Items.copper, 200, Items.lead, 120, Items.silicon, 110, Items.metaglass, 60));
requirements(Category.logic, with(Items.lead, 320, Items.silicon, 140, Items.graphite, 80, Items.thorium, 70));
instructionsPerTick = 5;

View File

@@ -66,32 +66,6 @@ public class LCanvas extends Table{
}
}
private void drawGrid(){
Draw.color(backgroundCol);
Fill.crect(x, y, width, height);
Draw.color(gridCol);
float spacing = Scl.scl(50f);
int xbars = (int)(width / spacing) + 2, ybars = (int)(width / spacing) + 2;
float ox = offset.x % spacing, oy = offset.y % spacing;
Lines.stroke(Scl.scl(3f));
for(int i = 0; i < xbars; i++){
float cx = x + width/2f + (i - xbars/2) * spacing + ox;
Lines.line(cx, y, cx, y + height);
}
for(int i = 0; i < ybars; i++){
float cy = y + height/2f + (i - ybars/2) * spacing + oy;
Lines.line(0, cy, x + width, cy);
}
Draw.reset();
}
void add(LStatement statement){
statements.addChild(new StatementElem(statement));
}

View File

@@ -1,12 +1,17 @@
package mindustry.world.blocks.environment;
import arc.graphics.g2d.Draw;
import arc.graphics.g2d.*;
import arc.math.Mathf;
import arc.math.geom.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.graphics.Layer;
import mindustry.world.Block;
import mindustry.world.Tile;
public class TreeBlock extends Block{
public @Load("@-shadow") TextureRegion shadow;
public float shadowOffset = -3f;
public TreeBlock(String name){
super(name);
@@ -16,7 +21,27 @@ public class TreeBlock extends Block{
@Override
public void drawBase(Tile tile){
float x = tile.worldx(), y = tile.worldy();
float rot = Mathf.randomSeed(tile.pos(), 0, 4) * 90 + Mathf.sin(Time.time() + x, 50f, 0.5f) + Mathf.sin(Time.time() - y, 65f, 0.9f) + Mathf.sin(Time.time() + y - x, 85f, 0.9f);
float w = region.getWidth() * Draw.scl, h = region.getHeight() * Draw.scl;
float scl = 30f, mag = 0.2f;
if(shadow.found()){
Draw.z(Layer.power - 1);
Draw.rect(shadow, tile.worldx() + shadowOffset, tile.worldy() + shadowOffset, rot);
}
Draw.z(Layer.power + 1);
Draw.rect(region, tile.worldx(), tile.worldy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);
Draw.rectv(region, x, y, w, h, rot, vec -> {
vec.add(
Mathf.sin(vec.y*3 + Time.time(), scl, mag) + Mathf.sin(vec.x*3 - Time.time(), 70, 0.8f),
Mathf.cos(vec.x*3 + Time.time() + 8, scl + 6f, mag * 1.1f) + Mathf.sin(vec.y*3 - Time.time(), 50, 0.2f)
);
});
}
void tweak(Vec2 vec){
}
}

View File

@@ -65,6 +65,9 @@ public class LogicBlock extends Block{
static String getLinkName(Block block){
String name = block.name;
if(block.minfo.mod != null){
name = name.substring(block.minfo.mod.name.length() + 1);
}
if(name.contains("-")){
String[] split = name.split("-");
//filter out 'large' at the end of block names
@@ -74,9 +77,6 @@ public class LogicBlock extends Block{
name = split[split.length - 1];
}
}
if(block.minfo.mod != null){
name = name.substring(block.minfo.mod.name.length() + 1);
}
return name;
}

View File

@@ -1,6 +1,7 @@
package mindustry.world.blocks.logic;
import arc.graphics.g2d.*;
import arc.util.io.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
import mindustry.logic.*;
@@ -14,21 +15,20 @@ public class SwitchBlock extends Block{
configurable = true;
update = true;
config(Boolean.class, (SwitchBuild entity, Boolean b) -> entity.on = b);
config(Boolean.class, (SwitchBuild entity, Boolean b) -> entity.enabled = b);
}
public class SwitchBuild extends Building{
public boolean on;
@Override
public double sense(LAccess sensor){
if(sensor == LAccess.enabled) return on ? 1 : 0;
if(sensor == LAccess.enabled) return enabled ? 1 : 0;
return super.sense(sensor);
}
@Override
public boolean configTapped(){
configure(!on);
configure(!enabled);
Sounds.click.at(this);
return false;
}
@@ -37,9 +37,30 @@ public class SwitchBlock extends Block{
public void draw(){
super.draw();
if(on){
if(enabled){
Draw.rect(onRegion, x, y);
}
}
@Override
public byte version(){
return 1;
}
@Override
public void readAll(Reads read, byte revision){
super.readAll(read, revision);
if(revision == 1){
enabled = read.bool();
}
}
@Override
public void write(Writes write){
super.write(write);
write.bool(enabled);
}
}
}