Skip to content

Commit

Permalink
Item Liquid Junction sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Jun 14, 2024
1 parent adfd892 commit 8cfbbab
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 41 additions & 1 deletion src/tranqol/world/blocks/hybrid/ItemLiquidJunction.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package tranqol.world.blocks.hybrid;

import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
Expand All @@ -15,16 +18,44 @@ public class ItemLiquidJunction extends LiquidBlock{
public float speed = 26; //frames taken for item go through this junction
public int capacity = 6;

protected TextureRegion[][] directionRegions;

public ItemLiquidJunction(String name){
super(name);

rotate = true;
//rotateDraw = false;
rotateDraw = false;
drawArrow = false;
unloadable = false;
floating = true;
noUpdateDisabled = true;
}

@Override
public void load(){
super.load();

directionRegions = new TextureRegion[2][2];
for(int j = 0; j <= 1; j++){
directionRegions[j][0] = Core.atlas.find(name + "-item" + j, name + "-item");
directionRegions[j][1] = Core.atlas.find(name + "-liquid" + j, name + "-liquid");
}
}

@Override
public void drawPlanRegion(BuildPlan plan, Eachable<BuildPlan> list){
super.drawPlanRegion(plan, list);

for(int i = 0; i < 4; i++){
Draw.rect(directionRegions[i > 1 ? 1 : 0][(plan.rotation + i) % 2], plan.drawx(), plan.drawy(), i * 90f);
}
}

@Override
public TextureRegion[] icons(){
return new TextureRegion[]{region};
}

@Override
public void setStats(){
super.setStats();
Expand All @@ -45,6 +76,15 @@ public boolean outputsItems(){
public class ItemLiquidJunctionBuild extends LiquidBuild{
public DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity);

@Override
public void draw(){
Draw.rect(region, x, y);

for(int i = 0; i < 4; i++){
Draw.rect(directionRegions[i > 1 ? 1 : 0][(rotation + i) % 2], x, y, i * 90f);
}
}

@Override
public Building getLiquidDestination(Building source, Liquid liquid){
if(!enabled || relativeSelf(source) % 2 == 0) return this;
Expand Down

0 comments on commit 8cfbbab

Please sign in to comment.