Better build beam visuals
This commit is contained in:
@@ -145,8 +145,9 @@ public class ConstructBlock extends Block{
|
||||
* If a non-recipe block is being deconstructed, this is the block that is being deconstructed.
|
||||
*/
|
||||
public Block previous;
|
||||
public Object lastConfig;
|
||||
public boolean wasConstructing;
|
||||
public @Nullable Object lastConfig;
|
||||
public boolean wasConstructing, activeDeconstruct;
|
||||
public float constructColor;
|
||||
|
||||
@Nullable
|
||||
public Unit lastBuilder;
|
||||
@@ -176,7 +177,7 @@ public class ConstructBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void tapped(){
|
||||
//if the target is constructible, begin constructing
|
||||
//if the target is constructable, begin constructing
|
||||
if(cblock != null){
|
||||
if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){
|
||||
control.input.isBuilding = true;
|
||||
@@ -194,6 +195,12 @@ public class ConstructBlock extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
constructColor = Mathf.lerpDelta(constructColor, activeDeconstruct ? 1f : 0f, 0.2f);
|
||||
activeDeconstruct = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(!(previous == null || cblock == null || previous == cblock) && Core.atlas.isFound(previous.icon(Cicon.full))){
|
||||
@@ -201,7 +208,7 @@ public class ConstructBlock extends Block{
|
||||
}
|
||||
|
||||
Draw.draw(Layer.blockBuilding, () -> {
|
||||
Shaders.blockbuild.color = Pal.accent;
|
||||
Draw.color(Pal.accent, Pal.remove, constructColor);
|
||||
|
||||
Block target = cblock == null ? previous : cblock;
|
||||
|
||||
@@ -214,11 +221,14 @@ public class ConstructBlock extends Block{
|
||||
Draw.flush();
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
}
|
||||
|
||||
public void construct(Unit builder, @Nullable Building core, float amount, Object config){
|
||||
wasConstructing = true;
|
||||
activeDeconstruct = false;
|
||||
if(cblock == null){
|
||||
kill();
|
||||
return;
|
||||
@@ -254,6 +264,7 @@ public class ConstructBlock extends Block{
|
||||
|
||||
public void deconstruct(Unit builder, @Nullable Building core, float amount){
|
||||
wasConstructing = false;
|
||||
activeDeconstruct = true;
|
||||
float deconstructMultiplier = state.rules.deconstructRefundMultiplier;
|
||||
|
||||
if(builder.isPlayer()){
|
||||
@@ -333,7 +344,8 @@ public class ConstructBlock extends Block{
|
||||
}
|
||||
|
||||
public void setConstruct(Block previous, Block block){
|
||||
wasConstructing = true;
|
||||
this.constructColor = 0f;
|
||||
this.wasConstructing = true;
|
||||
this.cblock = block;
|
||||
this.previous = previous;
|
||||
this.accumulator = new float[block.requirements.length];
|
||||
@@ -343,7 +355,9 @@ public class ConstructBlock extends Block{
|
||||
|
||||
public void setDeconstruct(Block previous){
|
||||
if(previous == null) return;
|
||||
wasConstructing = false;
|
||||
|
||||
this.constructColor = 1f;
|
||||
this.wasConstructing = false;
|
||||
this.previous = previous;
|
||||
this.progress = 1f;
|
||||
if(previous.buildCost >= 0.01f){
|
||||
|
||||
@@ -201,7 +201,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
if(cooldown > 0f) return;
|
||||
|
||||
// get current item
|
||||
if(lastItem == null){
|
||||
if(lastItem == null || !items.has(lastItem)){
|
||||
lastItem = items.first();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user