generated from Anuken/MindustryJavaModTemplate
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/biotech/world/blocks/production/BoostableDrill.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |