Fluid handler

This commit is contained in:
2026-10-31 16:54:24 -03:00
parent 23d02c5229
commit 407ed77385
20 changed files with 602 additions and 127 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ import type {
Visual,
VisualBlock,
} from "bworld/client";
import type { Face } from "bworld/shared";
import type { Face, FluidStack } from "bworld/shared";
import {
actual_speed,
type Axis,
@@ -28,7 +28,7 @@ import {
OPPOSITE,
} from "./kinetics/connections.ts";
import { BASIN_TRAVEL, head_offset, type PressShown } from "./processing/press.ts";
import { BASIN_TANK_CAPACITY, BASIN_TANKS, type BasinTank } from "./processing/basin.ts";
import { BASIN_TANK_CAPACITY, BASIN_TANKS } from "./processing/basin.ts";
// a model reaching north turned to reach each way
const facing_turns = (model: string): Record<Face, ModelRef> => ({
@@ -244,7 +244,7 @@ function basin_visual(block: VisualBlock, instances: Instances): Visual {
for (const instance of shown) instance.delete();
shown = [];
floating = [];
const tanks = block.get_client_data<BasinTank[]>("tanks") ?? [];
const tanks = block.get_client_data<FluidStack[]>("tanks") ?? [];
const total = tanks.reduce((sum, tank) => sum + tank.amount, 0);
const full = 1 - (1 - Math.min(1, total / (BASIN_TANKS * BASIN_TANK_CAPACITY))) ** 2;
const top = total > 0 ? 2 + 12 * full : 0;