@adatechnology/game-fluids 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.global.js +24 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -559,6 +559,8 @@ interface FilmDropState {
|
|
|
559
559
|
interface FilmWeather {
|
|
560
560
|
/** 0..1. While it rains drying stops and the film spreads 1.5 times faster. */
|
|
561
561
|
rain: number;
|
|
562
|
+
/** Multiplies how fast the film dries (default 1): hot weather above 1. */
|
|
563
|
+
drying?: number;
|
|
562
564
|
}
|
|
563
565
|
interface FilmOptions {
|
|
564
566
|
layout: FilmLayout;
|
|
@@ -598,6 +600,8 @@ interface Film {
|
|
|
598
600
|
update(input: FilmAdvanceInput): void;
|
|
599
601
|
setWeather(weather: Partial<FilmWeather>): void;
|
|
600
602
|
weather(): FilmWeather;
|
|
603
|
+
/** Rain washes the fresh film away: clears the cells that are less than `maxDryness` dry (default 0.5, the visor's L13494). Returns how many cells it cleared. */
|
|
604
|
+
wash(maxDryness?: number): number;
|
|
601
605
|
/** Empties the film, drops, drip, sources and drags. The ring cursor and the leftover step time stay, as in the pages. */
|
|
602
606
|
clear(): void;
|
|
603
607
|
/** Number of cells above the visible thickness (0.035 mm). */
|
package/dist/index.global.js
CHANGED
|
@@ -2575,7 +2575,7 @@ var GameFluids = (() => {
|
|
|
2575
2575
|
if (lastRow < 0) return;
|
|
2576
2576
|
const profile = profileOf();
|
|
2577
2577
|
const rainScale = 1 - options.weather().rain;
|
|
2578
|
-
const seconds = dryingSeconds * rainScale;
|
|
2578
|
+
const seconds = dryingSeconds * rainScale * (options.weather().drying ?? 1);
|
|
2579
2579
|
for (let row = firstRow; row <= lastRow; row++) {
|
|
2580
2580
|
const offset = row * width;
|
|
2581
2581
|
for (let column = firstColumn; column <= lastColumn; column++) {
|
|
@@ -2703,6 +2703,7 @@ var GameFluids = (() => {
|
|
|
2703
2703
|
// src/film/film.ts
|
|
2704
2704
|
var DEFAULT_STEP_RATE = 180;
|
|
2705
2705
|
var DEFAULT_MAX_STEPS = 6;
|
|
2706
|
+
var WASH_BELOW_DRYNESS = 0.5;
|
|
2706
2707
|
function createFilm(options) {
|
|
2707
2708
|
const { layout, random } = options;
|
|
2708
2709
|
const cellCount = layout.width * layout.height;
|
|
@@ -2713,7 +2714,7 @@ var GameFluids = (() => {
|
|
|
2713
2714
|
dryness: new Float32Array(cellCount),
|
|
2714
2715
|
dampness: new Float32Array(cellCount)
|
|
2715
2716
|
};
|
|
2716
|
-
let weatherState = { rain: 0 };
|
|
2717
|
+
let weatherState = { rain: 0, drying: 1 };
|
|
2717
2718
|
let currentProfile = options.profile;
|
|
2718
2719
|
const context = { field, random, profile: () => currentProfile };
|
|
2719
2720
|
const drops = createDropPool(layout, context);
|
|
@@ -2751,9 +2752,29 @@ var GameFluids = (() => {
|
|
|
2751
2752
|
simulator.advance({ dt, dryingSeconds });
|
|
2752
2753
|
},
|
|
2753
2754
|
setWeather(weather) {
|
|
2754
|
-
weatherState = {
|
|
2755
|
+
weatherState = {
|
|
2756
|
+
rain: Math.min(1, Math.max(0, weather.rain ?? weatherState.rain)),
|
|
2757
|
+
drying: Math.max(0, weather.drying ?? weatherState.drying ?? 1)
|
|
2758
|
+
};
|
|
2755
2759
|
},
|
|
2756
2760
|
weather: () => ({ ...weatherState }),
|
|
2761
|
+
wash(maxDryness = WASH_BELOW_DRYNESS) {
|
|
2762
|
+
simulator.refreshBounds();
|
|
2763
|
+
const { firstRow, lastRow, firstColumn, lastColumn } = simulator.bounds;
|
|
2764
|
+
let cleared = 0;
|
|
2765
|
+
for (let row = firstRow; row <= lastRow; row++) {
|
|
2766
|
+
for (let column = firstColumn; column <= lastColumn; column++) {
|
|
2767
|
+
const index = row * layout.width + column;
|
|
2768
|
+
if (field.thickness[index] > 0 && field.dryness[index] < maxDryness) {
|
|
2769
|
+
field.thickness[index] = 0;
|
|
2770
|
+
field.dryness[index] = 0;
|
|
2771
|
+
field.dampness[index] = 0;
|
|
2772
|
+
cleared++;
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
return cleared;
|
|
2777
|
+
},
|
|
2757
2778
|
clear() {
|
|
2758
2779
|
field.thickness.fill(0);
|
|
2759
2780
|
field.dryness.fill(0);
|