Skip to content

Commit

Permalink
tree shadows (I'm sorry) (Anuken#8966)
Browse files Browse the repository at this point in the history
* Update TreeBlock.java

* hgmjjjjjjjjjjjjjjjjjjjjjkhvgcfxchjk

* ig
  • Loading branch information
stacktrace-error authored Aug 21, 2023
1 parent 490b281 commit d60d3d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/mindustry/world/blocks/environment/TreeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import mindustry.world.*;

public class TreeBlock extends Block{
public @Load("@-shadow") TextureRegion shadow;
public float shadowOffset = -4f;
public @Load("@-shadow") TextureRegion shadow;

public TreeBlock(String name){
super(name);
solid = true;
clipSize = 90;
customShadow = true;
}

@Override
Expand All @@ -26,9 +27,11 @@ public void drawBase(Tile tile){
w = region.width * region.scl(), h = region.height * region.scl(),
scl = 30f, mag = 0.2f;

if(shadow.found()){
TextureRegion shad = variants == 0 ? customShadowRegion : variantShadowRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantShadowRegions.length - 1))];

if(shad.found()){
Draw.z(Layer.power - 1);
Draw.rect(shadow, tile.worldx() + shadowOffset, tile.worldy() + shadowOffset, rot);
Draw.rect(shad, tile.worldx() + shadowOffset, tile.worldy() + shadowOffset, rot);
}

TextureRegion reg = variants == 0 ? region : variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))];
Expand All @@ -39,4 +42,7 @@ public void drawBase(Tile tile){
Mathf.cos(vec.x*3 + Time.time + 8, scl + 6f, mag * 1.1f) + Mathf.sin(vec.y*3 - Time.time, 50, 0.2f)
));
}

@Override
public void drawShadow(Tile tile){}
}

0 comments on commit d60d3d7

Please sign in to comment.