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

@@ -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);
}
}
}