Skip to content

Commit

Permalink
Merge Liquid System Rework [PR #58]
Browse files Browse the repository at this point in the history
  • Loading branch information
stabu-dev authored Feb 3, 2025
2 parents 45c6984 + 2346a87 commit fd0126e
Show file tree
Hide file tree
Showing 45 changed files with 2,066 additions and 660 deletions.
63 changes: 45 additions & 18 deletions assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ setting.omaloon-discord-join = Join Omaloon discord server!
setting.omaloon-enable-soft-cleaner = Enable Safe Cleaner
setting.omaloon-enable-soft-cleaner.description = Cleans your campaign from not allowed content and research.

setting.omaloon-display-liquid-stats = Display custom viscosity/density
setting.omaloon-display-liquid-stats.description = [red]NEEDS RELOAD

binding.category-omaloon-editor = Editor

settings.omaloon-resethints = Reset Hints
Expand All @@ -62,13 +65,10 @@ omaloon.update.dialog.fullclean.confirm = Are you sure you want to reset your cu
requirement.omaloon-at-wave = Reach Wave {0} in {1}

## Hints
hint.omaloon-pump_positive = To create higher pressure, place \uC353[accent] mechanical pumps[] in series, adding liquid pipes between them.\nTo increase pressure faster, place \uC353[accent] mechanical pumps[] in parallel.
hint.omaloon-pump_negative = To decrease pressure faster, add more \uC353[accent]mechanical pumps[].
hint.omaloon-drill_positive_pressure = \uC351 [accent]Hammer drills[] require negative pressure to operate. Rotate the \uC353[accent] mechanical pumps[] away from the drills to create negative pressure.
hint.omaloon-press_or_shelter_negative_pressure = Some buildings require positive pressure. Rotate the \uC353[accent] mechanical pumps[] to these blocks to create positive pressure.
hint.omaloon-pump = The pumps only stop when there is a block in front of it or the front block has enough pressure.
hint.omaloon-low_pressure = Buildings will implode when it reaches -50 pressure units. To avoid this, use \uC354 [accent]Liquid Valve[], which will reduce the pressure, preventing it from reaching dangerous levels.
hint.omaloon-valve = One valve can handle up to three pumps. If you have more pumps, place more valves to avoid jamming.
hint.omaloon-air = Air is equivalent to pressure in it's density. So each fluid unit of air equals one pascal inside the Liquid Tube.
hint.omaloon-drill = Drills work with negative pressure, working faster with lower pressures.
hint.omaloon-pump_chaining = Pumps chained in series can reach a higher pressure gradient between the ends. If they're chained in parallel, they work faster.
hint.omaloon-shelter = Shelters work with positive pressure, covering a larger area at higher pressures.

## planets
planet.omaloon-omaloon.name = Omaloon
Expand Down Expand Up @@ -268,12 +268,18 @@ block.omaloon-liquid-tube.description = Moves liquids.
block.omaloon-liquid-pump.name = Mechanical Pump
block.omaloon-liquid-pump.description = Moves liquids forward.

block.omaloon-filter-pump.name = Filter
block.omaloon-filter-pump.description = Moves liquids forward. Liquid can be choosen manually

block.omaloon-liquid-junction.name = Liquid Junction
block.omaloon-liquid-junction.description = Acts as a bridge for two crossing liquid tubes.

block.omaloon-liquid-valve.name = Liquid Valve
block.omaloon-liquid-valve.description = Equalizes fluid systems pressure to -15 pressure units. Jams when the pressure decreases too fast.

block.omaloon-liquid-gauge.name = Liquid Gauge
block.omaloon-liquid-gauge.description = Displays the amount of pressure inside it.

block.omaloon-liquid-bridge.name = Liquid Bridge
block.omaloon-liquid-bridge.description = Transports liquids over terrain or buildings.

Expand Down Expand Up @@ -327,23 +333,44 @@ block.omaloon-hammer-drill.description = When placed on ore, outputs items. Effi

## stats
category.omaloon-pressure = Pressure
stat.omaloon-consumepressure = Consume Pressure
stat.omaloon-minpressure = Min Pressure
stat.omaloon-maxpressure = Max Pressure

stat.omaloon-max-speed = Max Speed
stat.omaloon-min-speed = Min Speed
stat.omaloon-outputpressure = Output Pressure

air = Air

stat.omaloon-fluid-capacity = Fluid Capacity
stat.omaloon-fluid-capacity.format = @x@x@ Blocks

stat.omaloon-density = Density
stat.omaloon-viscosity = @% (\uC357 @)

stat.omaloon-pump-strength = Pump Strength
stat.omaloon-pressure-gradient = Pressure Gradient

stat.omaloon-min-pressure = Min Pressure
stat.omaloon-max-pressure = Max Pressure

stat.omaloon-pressureflow = Speed
stat.omaloon-pressurerange = Operating Range
stat.omaloon-pressurerange.format = from \uC357 @ pressure units to \uC357 @ pressure units.
stat.omaloon-pressure-range = Operating Range
stat.omaloon-pressure-range.format = \uC357 @ to @ Pressure Units.
stat.omaloon-optimal-pressure = Optimal Pressure
stat.omaloon-optimal-pressure.format = \uC357 @ Pressure Units (@%)

## ui units
unit.omaloon-pressuresecond = pressure units / second
unit.omaloon-pressureunits = pressure units
bar.air = Air
bar.pressure-liquid = {0} (\uC357 {1}/{2})
unit.omaloon-blocks-cubed = Blocks\u00B3

unit.omaloon-density-unit = Pressure Units / Blocks\u00B3
unit.omaloon-viscosity-unit = Viscosity Units

unit.omaloon-pressure-unit = Pressure Units
unit.omaloon-pressure-second = Pressure Units / Second


bar.air = Air:
bar.pressure = Pressure:
bar.pressure-liquid = ({0}: {1} / Air: {2})
bar.hail-shield-health = Individual Shelter
omaloon-source-negative = Negative

## abilities
ability.hailshield = Individual Shelter
Expand Down
Binary file added assets/sprites/blocks/crafting/glacium-boiler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/liquids/filter-pump-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/liquids/filter-pump-filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/liquids/filter-pump-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/liquids/filter-pump.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/liquids/liquid-gauge-tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/blocks/liquids/liquid-gauge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import arc.files.Fi
import arc.util.*
import arc.util.serialization.*
import de.undercouch.gradle.tasks.download.Download
Expand Down Expand Up @@ -262,4 +263,17 @@ project(":"){
classpath(files("$rootDir/run/Mindustry.jar"))
mainClass.set("mindustry.desktop.DesktopLauncher")
}

tasks.register<DefaultTask>("install"){
dependsOn("jar")
doLast{
val folder = Fi.get(OS.getAppDataDirectoryString("Mindustry")).child("mods")
folder.mkdirs()

val input = Fi.get("$rootDir/build/libs/${project.name}Desktop.jar")
folder.child(input.name()).delete()
input.copyTo(folder)
logger.lifecycle("Copied :jar output to $folder.")
}
}
}
74 changes: 59 additions & 15 deletions src/omaloon/content/OlFx.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,70 @@ public class OlFx {
Draw.blend();
}),

pumpFront = new Effect(60f, e -> {
Draw.alpha(e.fout() / 5f);
flowOut = new Effect(60f, e -> {
Draw.color(e.color);
Draw.alpha(e.fout() / 5);
vec.trns(e.rotation, 4f).add(e.x, e.y);
randLenVectors(e.id, 3, 16f * e.fin(), e.rotation, 10f, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3f * e.fin());
Angles.randLenVectors(e.id, 3, 16 * e.fin(), e.rotation, 10, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3 * e.fin());
});
vec.trns(e.rotation, -4f).add(e.x, e.y);
Angles.randLenVectors(e.id + 2, 3, 16 * e.fin(), e.rotation + 180, 10, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3 * e.fin());
});
Draw.alpha(e.fout() / 7);
Angles.randLenVectors(e.id + 1, 3, 16 * e.fin(), e.rotation + 180, 20, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5 * e.fin(), e.fin(), vec.angleTo(vec.x + x, vec.y + y));
});
Draw.alpha(e.fout() / 7f);
randLenVectors(e.id/2, 3, 16f * e.fin(), e.rotation, 20f, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5f * e.fin(), e.fin(), vec.angleTo(vec.x + x, vec.y + y));
vec.trns(e.rotation, 4f).add(e.x, e.y);
Angles.randLenVectors(e.id + 3, 3, 16 * e.fin(), e.rotation, 20, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5 * e.fin(), e.fin(), vec.angleTo(vec.x + x, vec.y + y));
});
}),
pumpBack = new Effect(60f, e -> {
Draw.alpha(e.fin() / 5f);
vec.trns(e.rotation, 4).add(e.x, e.y);
randLenVectors(e.id, 3, 16f * e.fout(), e.rotation, 10f, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3f * e.fout());
flowIn = new Effect(60f, e -> {
Draw.color(e.color);
Draw.alpha(e.fin() / 5);
vec.trns(e.rotation, 4f).add(e.x, e.y);
Angles.randLenVectors(e.id, 3, 16 * e.fout(), e.rotation, 10, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3 * e.fout());
});
vec.trns(e.rotation, -4f).add(e.x, e.y);
Angles.randLenVectors(e.id + 2, 3, 16 * e.fout(), e.rotation + 180, 10, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3 * e.fout());
});
Draw.alpha(e.fin() / 7);
Angles.randLenVectors(e.id + 1, 3, 16 * e.fout(), e.rotation + 180, 20, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5 * e.fout(), e.fout(), vec.angleTo(vec.x + x, vec.y + y));
});
vec.trns(e.rotation, 4f).add(e.x, e.y);
Angles.randLenVectors(e.id + 3, 3, 16 * e.fout(), e.rotation, 20, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5 * e.fout(), e.fout(), vec.angleTo(vec.x + x, vec.y + y));
});
}),

pumpOut = new Effect(60f, e -> {
Draw.color(e.color);
Draw.alpha(e.fout() / 5);
vec.trns(e.rotation, 4f).add(e.x, e.y);
Angles.randLenVectors(e.id, 3, 16 * e.fin(), e.rotation, 10, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3 * e.fin());
});
Draw.alpha(e.fout() / 7);
vec.trns(e.rotation, 4f).add(e.x, e.y);
Angles.randLenVectors(e.id + 3, 3, 16 * e.fin(), e.rotation, 20, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5 * e.fin(), e.fin(), vec.angleTo(vec.x + x, vec.y + y));
});
}),
pumpIn = new Effect(60f, e -> {
Draw.color(e.color);
Draw.alpha(e.fin() / 5);
vec.trns(e.rotation, 4f).add(e.x, e.y);
Angles.randLenVectors(e.id, 3, 16 * e.fout(), e.rotation, 10, (x, y) -> {
Fill.circle(vec.x + x, vec.y + y, 3 * e.fout());
});
Draw.alpha(e.fin() / 7f);
randLenVectors(e.id/2, 3, 16f * e.fout(), e.rotation, 20f, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5f * e.fout(), e.fout(), vec.angleTo(vec.x + x, vec.y + y));
Draw.alpha(e.fin() / 7);
Angles.randLenVectors(e.id + 3, 3, 16 * e.fout(), e.rotation, 20, (x, y) -> {
Fill.rect(vec.x + x, vec.y + y, 5 * e.fout(), e.fout(), vec.angleTo(vec.x + x, vec.y + y));
});
}),

Expand Down
47 changes: 47 additions & 0 deletions src/omaloon/content/OlLiquids.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package omaloon.content;

import arc.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.game.*;
import mindustry.type.*;
import mindustry.world.meta.*;
import omaloon.type.liquid.*;
import omaloon.world.meta.*;

import static arc.graphics.Color.*;

Expand All @@ -12,6 +18,9 @@ public class OlLiquids {

end;

public static ObjectFloatMap<Liquid> densities = new ObjectFloatMap<>();
public static ObjectFloatMap<Liquid> viscosities = new ObjectFloatMap<>();

public static void load(){
glacium = new CrystalLiquid("glacium", valueOf("5e929d")){{
effect = OlStatusEffects.glacied;
Expand All @@ -36,6 +45,44 @@ public static void load(){
canStayOn.add(Liquids.water);
}};

addDensity(Liquids.water, 1000);
addViscosity(Liquids.water, 10);
addDensity(Liquids.slag, 1600);
addViscosity(Liquids.slag, 250);
addDensity(Liquids.oil, 700);
addViscosity(Liquids.oil, 50);
addDensity(Liquids.cryofluid, 200);
addViscosity(Liquids.cryofluid, 1.2f);
addDensity(glacium, 1300);
addViscosity(glacium, 13);
addDensity(tiredGlacium, 1300);
addViscosity(tiredGlacium, 13);

if (Core.settings.getBool("omaloon-display-liquid-stats", true)) Events.on(EventType.ContentInitEvent.class, e -> {
densities.each(map -> {
map.key.stats.add(OlStats.density, map.value, OlStats.densityUnit);
});
viscosities.each(map -> {
map.key.checkStats();
map.key.stats.remove(Stat.viscosity);
map.key.stats.add(Stat.viscosity, Core.bundle.get("stat.omaloon-viscosity"), map.key.viscosity * 100f ,Strings.autoFixed(map.value/60f, 2) + " " + OlStats.viscosityUnit.localized());
});
});
}

public static void addDensity(Liquid liquid, float density) {
densities.put(liquid, density);
}

public static void addViscosity(Liquid liquid, float viscosity) {
viscosities.put(liquid, viscosity);
}

public static float getDensity(@Nullable Liquid liquid) {
return densities.get(liquid, 8f);
}

public static float getViscosity(@Nullable Liquid liquid) {
return viscosities.get(liquid, 1f);
}
}
12 changes: 6 additions & 6 deletions src/omaloon/content/OlTechTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public static void load() {
});

node(hammerDrill, () -> {
node(liquidTube, () -> {
node(liquidJunction, () -> {
node(liquidBridge);
});
node(liquidPump, () -> {
node(liquidValve);
node(liquidPump, () -> {
node(liquidTube, () -> {
node(liquidJunction, () -> {
node(liquidBridge);
});
});
node(liquidGauge);
});

node(carborundumPress, with(new Research(smallShelter)), () -> {
Expand Down
47 changes: 42 additions & 5 deletions src/omaloon/content/blocks/OlCraftingBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import mindustry.content.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import omaloon.content.*;
import omaloon.world.blocks.production.*;
import omaloon.world.consumers.*;

import static mindustry.type.ItemStack.*;

public class OlCraftingBlocks {
public static Block carborundumPress, graphitePress;
public static Block carborundumPress, graphitePress, glaciumBoiler;

public static void load() {
carborundumPress = new PressureCrafter("carborundum-press") {{
Expand All @@ -26,8 +27,17 @@ public static void load() {
craftEffect = OlFx.carborundumCraft;

consumeItems(with(Items.beryllium, 1, OlItems.cobalt, 1));
consume(new ConsumePressure(6f, false));
consume(new PressureEfficiencyRange(5f, 50f, 1.6f, false));
consume(new ConsumeFluid(null, 5) {{
startRange = 5f;
endRange = 50f;
efficiencyMultiplier = 1.6f;
curve = t -> Math.min(
9f/2f * (1f - t),
9f/7f * t
);
optimalPressure = 40f;
hasOptimalPressure = true;
}});

outputItems = with(OlItems.carborundum, 1);
}};
Expand All @@ -44,10 +54,37 @@ public static void load() {

craftEffect = Fx.pulverizeMedium;
consumeItem(Items.coal, 4);
consume(new ConsumePressure(8f, false));
consume(new PressureEfficiencyRange(10f, 50f, 1.5f, false));
consume(new ConsumeFluid(null, 8f) {{
startRange = 10f;
endRange = 50f;
efficiencyMultiplier = 1.5f;
curve = t -> Math.min(
8f * (1f - t),
8f/7f * t
);
optimalPressure = 45f;
hasOptimalPressure = true;
}});

outputItem = new ItemStack(Items.graphite, 2);
}};

glaciumBoiler = new PressureCrafter("glacium-boiler") {{
requirements(Category.crafting, BuildVisibility.sandboxOnly, with());
size = 2;

useVanillaLiquids = false;
ignoreLiquidFullness = true;
dumpExtraLiquid = true;

craftTime = 120f;

consumeItem(Items.coal, 1);
consume(new ConsumeFluid(OlLiquids.glacium, 1f/60f) {{
continuous = true;
}});

outputAir = 4f/6f;
}};
}
}
Loading

0 comments on commit fd0126e

Please sign in to comment.