diff --git a/build.gradle b/build.gradle index fb8c5d7..4bdd43a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { arcHash = "v133" packerHash = '128' mindustryVersion = "v133" - aciVersion = "daea5433ca3" + aciVersion = "9f9ed7da24" modsDirectories = []; def file = new File(rootDir, "modsDirectoies.txt"); // println "abs->"+file.getAbsolutePath(); diff --git a/core/src/gas/entities/Clouds.java b/core/src/gas/entities/Clouds.java index d7aa4ee..e131ca9 100644 --- a/core/src/gas/entities/Clouds.java +++ b/core/src/gas/entities/Clouds.java @@ -50,7 +50,7 @@ public static void deposit(Tile tile, Tile source, Gas gas, float amount,boolean p.accepting = Math.max(amount, p.accepting); if(initial && p.lastRipple <= Time.time - 40f && p.amount >= maxGas / 2f){ - Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, p.gasObject.color); +// Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, p.gasObject.color); p.lastRipple = Time.time; } }else{ diff --git a/core/src/gas/gen/GasBuilding.java b/core/src/gas/gen/GasBuilding.java index 044a28f..4c59870 100644 --- a/core/src/gas/gen/GasBuilding.java +++ b/core/src/gas/gen/GasBuilding.java @@ -1,68 +1,59 @@ package gas.gen; -import gas.type.Gas; -import gas.world.GasBlock; -import gas.entities.Clouds; -import gas.world.modules.GasConsumeModule; -import gas.world.modules.GasModule; -import arc.graphics.g2d.Draw; -import arc.graphics.g2d.Fill; -import arc.math.Mathf; -import arc.scene.ui.layout.Table; -import arc.util.Interval; -import arc.util.Time; -import mindustry.Vars; -import mindustry.audio.SoundLoop; -import mindustry.content.Fx; -import mindustry.core.World; -import mindustry.ctype.Content; -import mindustry.entities.Damage; -import mindustry.entities.Effect; -import mindustry.entities.Puddles; -import mindustry.game.Team; -import mindustry.gen.Building; -import mindustry.gen.Sounds; -import mindustry.graphics.Layer; -import mindustry.graphics.Pal; -import mindustry.logic.LAccess; -import mindustry.type.Item; -import mindustry.type.Liquid; -import mindustry.world.Block; -import mindustry.world.Tile; -import mindustry.world.blocks.ControlBlock; +import arc.graphics.g2d.*; +import arc.math.*; +import arc.scene.ui.layout.*; +import arc.util.*; +import gas.content.*; +import gas.entities.*; +import gas.type.*; +import gas.world.*; +import gas.world.modules.*; +import mindustry.*; +import mindustry.audio.*; +import mindustry.content.*; +import mindustry.core.*; +import mindustry.ctype.*; +import mindustry.entities.*; +import mindustry.game.*; +import mindustry.gen.*; +import mindustry.graphics.*; +import mindustry.logic.*; +import mindustry.type.*; +import mindustry.world.*; +import mindustry.world.blocks.*; import mindustry.world.blocks.payloads.*; -import mindustry.world.consumers.Consume; -import mindustry.world.consumers.ConsumeType; -import mindustry.world.modules.ItemModule; -import mindustry.world.modules.LiquidModule; -import mindustry.world.modules.PowerModule; +import mindustry.world.consumers.*; +import mindustry.world.modules.*; -import java.util.Iterator; +import java.util.*; import static mindustry.Vars.tilesize; -public class GasBuilding extends Building { +public class GasBuilding extends Building{ public GasModule gasses; public GasBlock block; public float smoothGas; - public void handleGas(Building source, Gas gas, float amount) { + public void handleGas(Building source, Gas gas, float amount){ gasses.add(gas, amount); } - public boolean acceptGas(Building source, Gas gas) { - return (source instanceof GasBuilding || source == null) && acceptGas((GasBuilding)source, gas); - } - public boolean acceptGas(GasBuilding source, Gas gas) { - return block.hasGasses && block.consumes.gasFilter.get(gas.id); + public boolean acceptGas(Building source, Gas gas){ + if (source instanceof GasBuilding || source == null){ + return block.hasGasses && block.consumes.gasFilter.get(gas.id); + } + return false; } + @Override - public boolean acceptItem(Building source, Item item) { + public boolean acceptItem(Building source, Item item){ return block.consumes.itemFilters.get(item.id) && items.get(item) < getMaximumAccepted(item); } + @Override - public boolean acceptLiquid(Building source, Liquid liquid) { + public boolean acceptLiquid(Building source, Liquid liquid){ return block.hasLiquids && block.consumes.liquidfilters.get(liquid.id); } @@ -71,11 +62,11 @@ public boolean acceptPayload(Building source, Payload payload){ return super.acceptPayload(source, payload); } - public double sense(LAccess sensor) { + public double sense(LAccess sensor){ double var10000; - switch(sensor) { + switch(sensor){ case x: - var10000 = World.conv(x); + var10000 = World.conv(x); break; case y: var10000 = World.conv(y); @@ -141,31 +132,33 @@ public double sense(LAccess sensor) { return var10000; } - public double sense(Content content) { - if (content instanceof Item && items != null) { + + public double sense(Content content){ + if(content instanceof Item && items != null){ return items.get((Item)content); - } else if (content instanceof Gas && gasses!=null) { - return gasses.get((Gas) content); - } else { + }else if(content instanceof Gas && gasses != null){ + return gasses.get((Gas)content); + }else{ return content instanceof Liquid && liquids != null ? (double)liquids.get((Liquid)content) : 0.0D; } } + @Override - public void onDestroyed() { + public void onDestroyed(){ float explosiveness = block.baseExplosiveness; float flammability = 0.0F; float power = 0.0F; Item item; int amount; - if (block.hasItems) { - for(Iterator var4 = Vars.content.items().iterator(); var4.hasNext(); flammability += item.flammability * (float)amount) { + if(block.hasItems){ + for(Iterator var4 = Vars.content.items().iterator(); var4.hasNext(); flammability += item.flammability * (float)amount){ item = var4.next(); amount = items.get(item); explosiveness += item.explosiveness * (float)amount; } } - if (block.hasLiquids) { + if(block.hasLiquids){ flammability += liquids.sum((liquid, amountx) -> { return liquid.flammability * amountx / 2.0F; }); @@ -174,7 +167,7 @@ public void onDestroyed() { }); } - if (block.hasGasses) { + if(block.hasGasses){ flammability += gasses.sum((gas, amountx) -> { return gas.flammability * amountx / 2.0F; }); @@ -183,17 +176,17 @@ public void onDestroyed() { }); } - if (block.consumes.hasPower() && block.consumes.getPower().buffered) { + if(block.consumes.hasPower() && block.consumes.getPower().buffered){ power += this.power.status * block.consumes.getPower().capacity; } - if (block.hasLiquids && Vars.state.rules.damageExplosions) { + if(block.hasLiquids && Vars.state.rules.damageExplosions){ liquids.each((liquid, amountx) -> { float splash = Mathf.clamp(amountx / 4.0F, 0.0F, 10.0F); - for(int i = 0; (float)i < Mathf.clamp(amountx / 5.0F, 0.0F, 30.0F); ++i) { + for(int i = 0; (float)i < Mathf.clamp(amountx / 5.0F, 0.0F, 30.0F); ++i){ Time.run((float)i / 2.0F, () -> { Tile other = Vars.world.tile(tileX() + Mathf.range(block.size / 2), tileY() + Mathf.range(block.size / 2)); - if (other != null) { + if(other != null){ Puddles.deposit(other, liquid, splash); } @@ -202,13 +195,13 @@ public void onDestroyed() { }); } - if (block.hasGasses && Vars.state.rules.damageExplosions) { + if(block.hasGasses && Vars.state.rules.damageExplosions){ gasses.each((gas, amountx) -> { float splash = Mathf.clamp(amountx / 4.0F, 0.0F, 10.0F); - for(int i = 0; (float)i < Mathf.clamp(amountx / 5.0F, 0.0F, 30.0F); ++i) { + for(int i = 0; (float)i < Mathf.clamp(amountx / 5.0F, 0.0F, 30.0F); ++i){ Time.run((float)i / 2.0F, () -> { Tile other = Vars.world.tile(tileX() + Mathf.range(block.size / 2), tileY() + Mathf.range(block.size / 2)); - if (other != null) { + if(other != null){ Clouds.deposit(other, gas, splash); } @@ -219,20 +212,22 @@ public void onDestroyed() { } Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5F, power, (float)(8 * block.size) / 2.0F, Vars.state.rules.damageExplosions); - if (!floor().solid && !floor().isLiquid) { + if(!floor().solid && !floor().isLiquid){ Effect.rubble(x, y, block.size); } } - public float efficiency() { - if (!enabled) { + + public float efficiency(){ + if(!enabled){ return 0.0F; - } else { + }else{ return power != null && block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered ? power.status : 1.0F; } } - public void drawStatus() { - if (block.enableDrawStatus && block.consumes.any()) { + + public void drawStatus(){ + if(block.enableDrawStatus && block.consumes.any()){ float multiplier = block.size > 1 ? 1 : 0.64F; float brcx = x + (block.size * tilesize / 2.0F) - (tilesize * multiplier / 2.0F); float brcy = y - (block.size * tilesize / 2.0F) + (tilesize * multiplier / 2.0F); @@ -244,43 +239,44 @@ public void drawStatus() { Draw.color(); } } - public GasModule gasses() { + + public GasModule gasses(){ return gasses; } - public void gasses(GasModule gasses) { + public void gasses(GasModule gasses){ this.gasses = gasses; } - public GasBuilding getGasDestination(Building from, Gas gas) { + public GasBuilding getGasDestination(Building from, Gas gas){ return this; } - public boolean canDumpGas(Building to, Gas gas) { + public boolean canDumpGas(Building to, Gas gas){ return true; } - public void transferGas(Building n, float amount, Gas gas) { - if (!(n instanceof GasBuilding)) return; - GasBuilding next = (GasBuilding) n; + public void transferGas(Building n, float amount, Gas gas){ + if(!(n instanceof GasBuilding)) return; + GasBuilding next = (GasBuilding)n; float flow = Math.min(next.block.gasCapacity - next.gasses.get(gas), amount); - if (next.acceptGas(this, gas)) { + if(next.acceptGas(this, gas)){ next.handleGas(this, gas, flow); gasses.remove(gas, flow); } } @Override - public void displayConsumption(Table table) { + public void displayConsumption(Table table){ table.left(); - for (Consume cons : block.consumes.all()) { - if (cons.isOptional() && cons.isBoost()) continue; + for(Consume cons : block.consumes.all()){ + if(cons.isOptional() && cons.isBoost()) continue; cons.build(this, table); } } @Override - public void displayBars(Table table) { + public void displayBars(Table table){ super.displayBars(table); } @@ -290,54 +286,55 @@ public GasBlock block(){ } @Override - public GasBuilding create(Block block, Team team) { - return create((GasBlock)block,team); + public GasBuilding create(Block block, Team team){ + return create((GasBlock)block, team); } - public GasBuilding create(GasBlock block, Team team) { - super.block=block; + public GasBuilding create(GasBlock block, Team team){ + super.block = block; this.block = block; this.team = team; - if (block.loopSound != Sounds.none) { + if(block.loopSound != Sounds.none){ sound = new SoundLoop(block.loopSound, block.loopSoundVolume); } health = block.health; maxHealth(block.health); timer(new Interval(block.timers)); cons = new GasConsumeModule(this); - if (block.hasItems) items = new ItemModule(); - if (block.hasLiquids) liquids = new LiquidModule(); - if (block.hasPower) { + if(block.hasItems) items = new ItemModule(); + if(block.hasLiquids) liquids = new LiquidModule(); + if(block.hasPower){ power = new PowerModule(); power.graph.add(this); } - if (block.hasGasses) { + if(block.hasGasses){ gasses = new GasModule(); } initialized = true; return this; } + public void dumpGas(Gas gas){ - dumpGas(gas,2f); + dumpGas(gas, 2f); } - public void dumpGas(Gas gas, float scaling) { + public void dumpGas(Gas gas, float scaling){ int dump = cdump; - if (gasses.get(gas) > 1.0E-4F) { - if (!Vars.net.client() && Vars.state.isCampaign() && team == Vars.state.rules.defaultTeam) { + if(gasses.get(gas) > 0.0001f){ + if(!Vars.net.client() && Vars.state.isCampaign() && team == Vars.state.rules.defaultTeam){ gas.unlock(); } - for (int i = 0; i < proximity.size; ++i) { + for(int i = 0; i < proximity.size; ++i){ incrementDump(proximity.size); Building o = proximity.get((i + dump) % proximity.size); - if (!(o instanceof GasBuilding)) continue; - GasBuilding other = (GasBuilding) o; + if(!(o instanceof GasBuilding)) continue; + GasBuilding other = (GasBuilding)o; other = other.getGasDestination(this, gas); - if (other != null && other.team == team && other.block.hasGasses && canDumpGas(other, gas) && other.gasses != null) { + if(other != null && other.team == team && other.block.hasGasses && canDumpGas(other, gas) && other.gasses != null){ float ofract = other.gasses.get(gas) / other.block.gasCapacity; float fract = gasses.get(gas) / block.gasCapacity; - if (ofract < fract) { + if(ofract < fract){ transferGas(other, (fract - ofract) * block.gasCapacity / scaling, gas); } } @@ -345,59 +342,60 @@ public void dumpGas(Gas gas, float scaling) { } } + @Override - public String toString() { + public String toString(){ return "GasBuilding#" + id; } - public float moveGas(Building n, Gas gas) { - if (n instanceof GasBuilding) { - GasBuilding next = (GasBuilding) n; - next = next.getGasDestination(this, gas); - if (next.team == team && next.block.hasGasses && gasses.get(gas) > 0.0F) { - float ofract = next.gasses.get(gas) / next.block.gasCapacity; - float fract = gasses.get(gas) / block.gasCapacity; - float flow = Math.min(Mathf.clamp((fract - ofract) * 1.0F) * block.gasCapacity, gasses.get(gas)); - flow = Math.min(flow, next.block.gasCapacity - next.gasses.get(gas)); - if (flow > 0.0F && ofract <= fract && next.acceptGas(this, gas)) { - next.handleGas(this, gas, flow); - gasses.remove(gas, flow); - return flow; + public float moveGas(Building n, Gas gas){ + if(!(n instanceof GasBuilding)) return 0f; + GasBuilding next = (GasBuilding)n; + next = next.getGasDestination(this, gas); + float gasAmount = gasses.get(gas); + if(next.team != team || !next.block.hasGasses || !(gasAmount > 0.0F)) return 0; + + float ofract = next.gasses.get(gas) / next.block.gasCapacity; + float fract = gasAmount / block.gasCapacity; + float flow = Math.min(Mathf.clamp((fract - ofract) * 1.0F) * block.gasCapacity, gasAmount); + flow = Math.min(flow, next.block.gasCapacity - next.gasses.get(gas)); + + if(flow > 0.0F && ofract <= fract && next.acceptGas(this, gas)){ + next.handleGas(this, gas, flow); + gasses.remove(gas, flow); + return flow; + } + if(next.gasses.currentAmount() / next.block.gasCapacity > 0.1F && fract > 0.1F){ + float fx = (x + next.x) / 2.0F; + float fy = (y + next.y) / 2.0F; + Gas other = next.gasses.current(); + if(other.flammability > 0.3F && gas.temperature > 0.7F || gas.flammability > 0.3F && other.temperature > 0.7F){ + damage(1.0F * Time.delta); + next.damage(1.0F * Time.delta); + if(Mathf.chance(0.1D * (double)Time.delta)){ + Fx.fire.at(fx, fy); } - if (next.gasses.currentAmount() / next.block.gasCapacity > 0.1F && fract > 0.1F) { - float fx = (x + next.x) / 2.0F; - float fy = (y + next.y) / 2.0F; - Gas other = next.gasses.current(); - if (other.flammability > 0.3F && gas.temperature > 0.7F || gas.flammability > 0.3F && other.temperature > 0.7F) { - damage(1.0F * Time.delta); - next.damage(1.0F * Time.delta); - if (Mathf.chance(0.1D * (double) Time.delta)) { - Fx.fire.at(fx, fy); - } - } else if (gas.temperature > 0.7F && other.temperature < 0.55F || other.temperature > 0.7F && gas.temperature < 0.55F) { - gasses.remove(gas, Math.min(gasses.get(gas), 0.7F * Time.delta)); - if (Mathf.chance((double) (0.2F * Time.delta))) { - Fx.steam.at(fx, fy); - } - } + }else if(gas.temperature > 0.7F && other.temperature < 0.55F || other.temperature > 0.7F && gas.temperature < 0.55F){ + gasses.remove(gas, Math.min(gasAmount, 0.7F * Time.delta)); + if(Mathf.chance((double)(0.2F * Time.delta))){ + Fx.steam.at(fx, fy); } } - } - return 0.0F; + return 0f; } @Override - public void updateTile() { + public void updateTile(){ } - public float moveGasForward(boolean leaks, Gas gas) { + public float moveGasForward(boolean leaks, Gas gas){ Building next = front(); Tile nextTile = tile.nearby(rotation); - if ((next instanceof GasBuilding)) { + if((next instanceof GasBuilding)){ return moveGas(next, gas); } - if (nextTile != null && leaks && !nextTile.block().solid && !nextTile.block().hasLiquids) { + if(nextTile != null && leaks && !nextTile.block().solid && !nextTile.block().hasLiquids){ float leakAmount = gasses.get(gas) / 1.5F; Clouds.deposit(nextTile, tile, gas, leakAmount); diff --git a/core/src/gas/world/GasBlock.java b/core/src/gas/world/GasBlock.java index c272669..787358b 100644 --- a/core/src/gas/world/GasBlock.java +++ b/core/src/gas/world/GasBlock.java @@ -196,14 +196,14 @@ public void setBars(){ } if(hasGasses){ Func current; - if(consumes.has(ConsumeType.liquid) && consumes.get(ConsumeType.liquid) instanceof ConsumeGas){ + if(consumes.hasGas() && consumes.getGas() instanceof ConsumeGas){ Gas gas = consumes.getGas().gas; current = entity -> gas; }else{ current = entity -> entity.gasses == null ? null : entity.gasses.current(); } - bars.add("gas", entity -> new Bar(() -> entity.gasses.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, - () -> current.get(entity).barColor(), () -> entity == null || entity.liquids == null ? 0f : entity.gasses.get(current.get(entity)) / liquidCapacity)); + bars.add("gas", entity -> new Bar(() -> entity.gasses.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.gas") : current.get(entity).localizedName, + () -> current.get(entity).barColor(), () -> entity == null || entity.gasses == null ? 0f : entity.gasses.get(current.get(entity)) / gasCapacity)); } } diff --git a/core/src/gas/world/blocks/gas/GasConduit.java b/core/src/gas/world/blocks/gas/GasConduit.java index f6a67f7..59e9cc6 100644 --- a/core/src/gas/world/blocks/gas/GasConduit.java +++ b/core/src/gas/world/blocks/gas/GasConduit.java @@ -89,6 +89,11 @@ public boolean blends(Tile tile, int rotation, int otherx, int othery, int other return otherblock.hasGasses && (otherblock.outputsGas || (lookingAt(tile, rotation, otherx, othery, otherblock))) && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock); } + @Override + public void setBars(){ + super.setBars(); + } + @Override public void handlePlacementLine(Seq plans) { if (bridgeReplacement == null) @@ -150,7 +155,7 @@ public void onProximityUpdate() { @Override public boolean acceptGas(Building source, Gas gas) { noSleep(); - return (gasses.current() == gas || gasses.currentAmount() < 0.2f) && (tile == null || (source.relativeTo(tile.x, tile.y) + 2) % 4 != rotation); + return (gasses.current() == gas || gasses.currentAmount() < 0.2f) && (tile == null||source==null || (source.relativeTo(tile.x, tile.y) + 2) % 4 != rotation); } @Override diff --git a/core/src/gas/world/blocks/sandbox/GasSource.java b/core/src/gas/world/blocks/sandbox/GasSource.java index 6d0b379..529902c 100644 --- a/core/src/gas/world/blocks/sandbox/GasSource.java +++ b/core/src/gas/world/blocks/sandbox/GasSource.java @@ -21,21 +21,19 @@ public class GasSource extends GasBlock { public GasSource(String name) { super(name); - this.hasGasses = true; - this.outputsGas=true; - this.update = true; - this.solid = true; - this.group = BlockGroup.transportation; - this.configurable = true; - this.saveConfig = true; - this.noUpdateDisabled = true; - this.displayFlow = false; - this.config(Gas.class, (t, gas) -> { - GasSourceBuild tile=(GasSourceBuild)t; + hasGasses = true; + outputsGas=true; + update = true; + solid = true; + group = BlockGroup.transportation; + configurable = true; + saveConfig = true; + noUpdateDisabled = true; + displayFlow = false; + config(Gas.class, (GasSourceBuild tile,Gas gas) -> { tile.source = gas; }); - this.configClear((t) -> { - GasSourceBuild tile=(GasSourceBuild)t; + configClear((GasSourceBuild tile) -> { tile.source = null; }); }