Skip to content

Commit

Permalink
:3
Browse files Browse the repository at this point in the history
  • Loading branch information
xjamiex committed Oct 17, 2024
1 parent 959df08 commit 8d2bf97
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/biotech/content/BioBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import biotech.world.blocks.enviroment.BiologicalStaticSpawner;
import biotech.world.blocks.enviroment.TallTreeBlock;
import biotech.world.blocks.power.PowerConduit;
import biotech.world.blocks.production.BoostableDrill;
import biotech.world.blocks.production.DrillBooster;
import mindustry.content.Fx;
import mindustry.content.Items;
import mindustry.entities.bullet.*;
import mindustry.entities.effect.ParticleEffect;
import mindustry.entities.effect.WaveEffect;
Expand Down Expand Up @@ -47,7 +50,7 @@ public class BioBlocks {
magnesiumConveyor, splitter, conveyorOverpass,

//drill
bioDrill, boneCrusher, bioPiercer,
bioDrill, boneCrusher, bioPiercer, drillBooster,

//env
flesh, rottenFlesh, decayedFlesh, scarredFlesh,
Expand Down Expand Up @@ -155,7 +158,7 @@ public static void load() {
//endregion

//drills
bioDrill = new Drill("bio-drill"){{
bioDrill = new BoostableDrill("bio-drill"){{
researchCost = with(BioItems.magnesium, 60);
requirements(Category.production, with(BioItems.magnesium, 40, BioItems.calciticFragment, 35));
tier = 1;
Expand Down Expand Up @@ -220,6 +223,12 @@ public static void load() {
ambientSound = Sounds.drill;
ambientSoundVolume = 0.04f;
}};

drillBooster = new DrillBooster("drill-booster"){{
requirements(production, with(BioItems.carbonicTissue, 1));
health = 1500;
size = 2;
}};
//endregion

//environment
Expand Down
107 changes: 107 additions & 0 deletions src/biotech/world/blocks/production/BoostableDrill.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package biotech.world.blocks.production;

import arc.Core;
import arc.graphics.Color;
import arc.graphics.g2d.Draw;
import arc.math.Mathf;
import mindustry.game.Team;
import mindustry.type.Item;
import mindustry.world.Tile;
import mindustry.world.blocks.environment.OreBlock;
import mindustry.world.blocks.production.Drill;

import static mindustry.Vars.*;

public class BoostableDrill extends Drill {

public BoostableDrill(String name) {
super(name);
}

@Override
public boolean canPlaceOn(Tile tile, Team team, int rotation){
return true;
}

@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
super.drawPlace(x, y, rotation, valid);

Tile tile = world.tile(x, y);
if(tile == null) return;

countOre(tile);

if(returnItem != null){
float width = drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / getDrillTime(returnItem) * returnCount, 2), x, y, valid);
float dx = x * tilesize + offset - width/2f - 4f, dy = y * tilesize + offset + size * tilesize / 2f + 5, s = iconSmall / 4f;
Draw.mixcol(Color.darkGray, 1f);
Draw.rect(returnItem.fullIcon, dx, dy - 1, s, s);
Draw.reset();
Draw.rect(returnItem.fullIcon, dx, dy, s, s);

if(drawMineItem){
Draw.color(returnItem.color);
Draw.rect(itemRegion, tile.worldx() + offset, tile.worldy() + offset);
Draw.color();
}
}else{
Tile to = tile.getLinkedTilesAs(this, tempTiles).find(t -> t.drop() != null && (t.drop().hardness > tier || t.drop() == blockedItem));
Item item = to == null ? null : to.drop();
if(item != null){
drawPlaceText(Core.bundle.get("bar.drilltierreq"), x, y, valid);
}
}
}

@Override
public boolean canMine(Tile tile) {
if(tile == null || tile.block().isStatic()) return false;
Item drops = tile.drop();
return drops != null && drops.hardness <= tier && drops != blockedItem;
}

public class boostableDrillBuild extends DrillBuild {

public int boostedTier = 1;

@Override
public void updateTile(){
if(boostedTier < tier) return;
if(timer(timerDump, dumpTime)){
dump(dominantItem != null && items.has(dominantItem) ? dominantItem : null);
}

if(dominantItem == null){
return;
}

timeDrilled += warmup * delta();

float delay = getDrillTime(dominantItem);

if(items.total() < itemCapacity && dominantItems > 0 && efficiency > 0){
float speed = Mathf.lerp(1f, liquidBoostIntensity, optionalEfficiency) * efficiency;

lastDrillSpeed = (speed * dominantItems * warmup) / delay;
warmup = Mathf.approachDelta(warmup, speed, warmupSpeed);
progress += delta() * dominantItems * speed * warmup;

if(Mathf.chanceDelta(updateEffectChance * warmup))
updateEffect.at(x + Mathf.range(size * 2f), y + Mathf.range(size * 2f));
}else{
lastDrillSpeed = 0f;
warmup = Mathf.approachDelta(warmup, 0f, warmupSpeed);
return;
}

if(dominantItems > 0 && progress >= delay && items.total() < itemCapacity){
offload(dominantItem);

progress %= delay;

if(wasVisible && Mathf.chanceDelta(updateEffectChance * warmup)) drillEffect.at(x + Mathf.range(drillEffectRnd), y + Mathf.range(drillEffectRnd), dominantItem.color);
}
}
}
}
66 changes: 66 additions & 0 deletions src/biotech/world/blocks/production/DrillBooster.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package biotech.world.blocks.production;

import arc.struct.EnumSet;
import mindustry.gen.Building;
import mindustry.world.Block;
import mindustry.world.Tile;
import mindustry.world.meta.BlockFlag;
import mindustry.world.meta.Env;

import static mindustry.Vars.world;

public class DrillBooster extends Block {
public DrillBooster(String name) {
super(name);
rotate = true;
update = true;
solid = true;

envEnabled |= Env.space;
flags = EnumSet.of(BlockFlag.drill);
}

float boostDrill(int tx, int ty, int rotation){
float eff = 0f;
int cornerX = tx - (size-1)/2, cornerY = ty - (size-1)/2, s = size;

for(int i = 0; i < size; i++){
int rx = 0, ry = 0;

switch(rotation){
case 0 -> {
rx = cornerX + s;
ry = cornerY + i;
}
case 1 -> {
rx = cornerX + i;
ry = cornerY + s;
}
case 2 -> {
rx = cornerX - 1;
ry = cornerY + i;
}
case 3 -> {
rx = cornerX + i;
ry = cornerY - 1;
}
}

Tile other = world.tile(rx, ry);
if(other != null && other.solid()){
if(other.block() instanceof BoostableDrill){
((BoostableDrill.boostableDrillBuild) other.build).boostedTier = 2;
}
}
}
return eff;
}

public class DrillBoosterBuild extends Building{
@Override
public void updateTile() {
super.updateTile();
boostDrill(tile.x, tile.y, rotation);
}
}
}

0 comments on commit 8d2bf97

Please sign in to comment.