Skip to content

Commit

Permalink
[Module] Add drawer support to ModuleableBlock + (WIP) module tags fi…
Browse files Browse the repository at this point in the history
…lter
  • Loading branch information
JojoFR1 committed Jul 20, 2024
1 parent 46d8962 commit 72cfc7c
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions src/aeyama/world/block/ModuleableBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.*;
import aeyama.world.block.module.ModuleBlock.*;
import mindustry.world.draw.*;

import aeyama.world.block.ModuleBlock.*;

import static mindustry.Vars.tilesize;

public class ModuleableBlock extends Block {
/** The amount of available module slots to the player. */
public int moduleSlots;
/** Filter the modules this block accept. */
public Seq<String> tags = new Seq<String>();
private TextureRegion moduleSlotTexture;

public DrawBlock drawer = new DrawDefault();

public ModuleableBlock(String name, int moduleSlots) {
super(name);

Expand Down Expand Up @@ -49,12 +55,13 @@ public void init() {
public void load() {
super.load();

drawer.load(this);
moduleSlotTexture = Core.atlas.find("aeyama-module-slot");
}

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

drawModuleSlots(plan.getX(), plan.getY(), plan.block.size, plan.rotation);
}
Expand Down Expand Up @@ -95,14 +102,24 @@ public void drawModuleSlots(float x, float y, int size, int rotation) {
}
}

@Override
protected TextureRegion[] icons() {
return drawer.finalIcons(this);
}

@Override
public void getRegionsToOutline(Seq<TextureRegion> out) {
drawer.getRegionsToOutline(this, out);
}

public class ModuleableBuild extends Building {
public Seq<Building> modules = new Seq<Building>();
public Seq<ModuleBuild> modules = new Seq<ModuleBuild>();

@Override
public void onProximityUpdate() {
proximity.each(this::isModule, t -> {
((ModuleBuild)t).linkedBuild = this;
modules.add(t);
proximity.each(this::isModule, module -> {
((ModuleBuild)module).linkedBuild = this;
modules.add((ModuleBuild)module);
});

super.onProximityUpdate();
Expand All @@ -119,10 +136,16 @@ public boolean isModule(Building build, Building tile) {

@Override
public void draw() {
super.draw();
drawer.draw(this);

drawModuleSlots(this.x, this.y, this.block.size, rotation);
}

@Override
public void drawLight() {
super.drawLight();
drawer.drawLight(this);
}

@Override
public void drawSelect() {
Expand Down

0 comments on commit 72cfc7c

Please sign in to comment.