mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-15 15:20:57 -08:00
Closes Anuken/Mindustry-Suggestions/issues/4780 (dumping neoplasm from tanks)
This commit is contained in:
parent
afc2e15c51
commit
b189bfdf44
5 changed files with 27 additions and 2 deletions
|
|
@ -54,7 +54,7 @@ public class Liquids{
|
|||
capPuddles = false;
|
||||
spreadTarget = Liquids.water;
|
||||
moveThroughBlocks = true;
|
||||
incinerable = true;
|
||||
incinerable = false;
|
||||
blockReactive = false;
|
||||
canStayOn.addAll(water, oil, cryofluid);
|
||||
|
||||
|
|
|
|||
|
|
@ -1344,6 +1344,15 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||
return block.itemCapacity;
|
||||
}
|
||||
|
||||
/** Called when a block begins (not finishes!) deconstruction. The building is still present at this point. */
|
||||
public void onDeconstructed(@Nullable Unit builder){
|
||||
//deposit non-incinerable liquid on ground
|
||||
if(liquids != null && liquids.currentAmount() > 0 && (!liquids.current().incinerable || block.deconstructDropAllLiquid)){
|
||||
float perCell = liquids.currentAmount() / (block.size * block.size) * 2f;
|
||||
tile.getLinkedTiles(other -> Puddles.deposit(other, liquids.current(), perCell));
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when the block is destroyed. The tile is still intact at this stage. */
|
||||
public void onDestroyed(){
|
||||
float explosiveness = block.baseExplosiveness;
|
||||
|
|
|
|||
|
|
@ -154,6 +154,8 @@ public class Block extends UnlockableContent implements Senseable{
|
|||
public boolean updateInUnits = true;
|
||||
/** if true, this block updates in payloads in units regardless of the experimental game rule */
|
||||
public boolean alwaysUpdateInUnits = false;
|
||||
/** if false, only incinerable liquids are dropped when deconstructing; otherwise, all liquids are dropped. */
|
||||
public boolean deconstructDropAllLiquid = false;
|
||||
/** Whether to use this block's color in the minimap. Only used for overlays. */
|
||||
public boolean useColor = true;
|
||||
/** item that drops from this block, used for drills */
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ public class Build{
|
|||
Block sub = ConstructBlock.get(previous.size);
|
||||
|
||||
Seq<Building> prevBuild = new Seq<>(1);
|
||||
if(tile.build != null) prevBuild.add(tile.build);
|
||||
if(tile.build != null){
|
||||
prevBuild.add(tile.build);
|
||||
tile.build.onDeconstructed(unit);
|
||||
}
|
||||
|
||||
tile.setBlock(sub, team, rotation);
|
||||
var build = (ConstructBuild)tile.build;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import arc.math.*;
|
|||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
|
|
@ -140,6 +141,16 @@ public class PayloadDeconstructor extends PayloadBlock{
|
|||
float shift = edelta() * deconstructSpeed / deconstructing.buildTime();
|
||||
float realShift = Math.min(shift, 1f - progress);
|
||||
|
||||
//if began deconstruction...
|
||||
if(progress == 0f && shift > 0f && deconstructing instanceof BuildPayload pay){
|
||||
var build = pay.build;
|
||||
//dump liquid on floor (does not respect block configuration with respect to dumping liquids on floor)
|
||||
if(build.liquids != null && build.liquids.currentAmount() > 0){
|
||||
float perCell = build.liquids.currentAmount() / (block.size * block.size) * 2f;
|
||||
tile.getLinkedTiles(other -> Puddles.deposit(other, build.liquids.current(), perCell));
|
||||
}
|
||||
}
|
||||
|
||||
progress += shift;
|
||||
time += edelta();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue