@adatechnology/game-terrain 0.9.2 → 0.9.4

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/README.md CHANGED
@@ -14,6 +14,7 @@ terrain.heightAt(x, z) // what things stand on
14
14
 
15
15
  - **Profiles** (`TERRAIN_PROFILES`, replace or add through `profiles`): `lawn` (turf 5 cm, soil 1.5 m, rock), `dirt`, `sand`, `road` (asphalt 5 cm, gravel, soil), `concrete_slab` (12 cm with rebar at 3 cm), `tile_floor` (tile, mortar, slab), `wood_floor`, `stone_paving`, `mud`, `gravel_bed`, `dry_clay`, `snow`, `cobblestone`, `paver_floor`, `shallow_water`, `bedrock` (bare rock).
16
16
  - **Digging**: a blow removes `energy / specificEnergy` cubic metres (`TERRAIN_MATERIALS`, per blow type: ballistic, blunt, slash, explosive) as a bowl with the shape of the material. It takes the top stratum and spends what is left on the next. The strata end at the digging limit: **a slab is never pierced**, and a crater has a floor.
17
+ - **Pits** (`open(excavation)`): a planned pit in the ground as it stands (a shaft whose cover a blast threw off), as deep as the excavation of the layout says, no ground loss; `reset` closes it with the craters.
17
18
  - **Bars**: bare bars bend with each blow and give way at `yieldJoules`. A slab on the ground stays the floor; `suspended_slab` (`TerrainProfile.drop`) opens onto the floor below.
18
19
  - **Fine marks**: a bowl under 1.5 cells stays a mark, not a change of the height field. Blows on the same mark grow it until it is dug in.
19
20
  - **Budget** (`budget`): marks per area and in total (past it the closest two merge, then the oldest goes), thrown pieces, chunks redrawn per frame, cells checked for sliding, cells on fire.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { GroundLayout, Hit, GroundLoss, DestructibleImpl } from '@adatechnology/game-contracts';
1
+ import { GroundLayout, GroundExcavation, Hit, GroundLoss, DestructibleImpl } from '@adatechnology/game-contracts';
2
2
  export { GroundExcavation, GroundLayout, GroundZone } from '@adatechnology/game-contracts';
3
3
 
4
4
  /**
@@ -485,6 +485,11 @@ interface Terrain {
485
485
  } | null;
486
486
  /** A blow at (x, z). `energy` in joules, `direction` where it travels (it throws the pieces back along it). */
487
487
  strike(blow: TerrainBlow, spec: TerrainStrike): TerrainBlowResult;
488
+ /**
489
+ * Opens a pit in the ground as it stands now (a shaft a blast threw its cover off): the same dig as an excavation of the layout, never less deep than the ground already is there, and
490
+ * no ground loss. The layout is left alone, so the next `reset` closes it with the craters.
491
+ */
492
+ open(excavation: GroundExcavation): void;
488
493
  /** A shovelful at (x, z): takes the earth down through what a shovel digs, stops at what it does not (concrete, rock), heaps it at `dump`. */
489
494
  dig(spec: TerrainDig): TerrainDigResult;
490
495
  /** Earth thrown back from a heap into a hole: fills what was dug first, then heaps. Returns the cubic metres moved. */
@@ -326,6 +326,8 @@ var GameTerrain = (() => {
326
326
  { id: "dirt", strata: [{ material: "soil", thickness: 1.8 }, { material: "stone", thickness: 0.5 }] },
327
327
  { id: "sand", strata: [{ material: "sand", thickness: 2.5 }] },
328
328
  { id: "road", strata: [{ material: "asphalt", thickness: 0.05 }, { material: "gravel", thickness: 0.25 }, { material: "soil", thickness: 1.5 }] },
329
+ // a pavement for walking: concrete over its gravel bed over the soil, as the road's layers (a blast digs down to the pipes under it)
330
+ { id: "sidewalk", strata: [{ material: "concrete", thickness: 0.08 }, { material: "gravel", thickness: 0.22 }, { material: "soil", thickness: 1.5 }] },
329
331
  { id: "concrete_slab", strata: [{ material: "concrete", thickness: 0.12, reinforcement: { material: "steel", cover: 0.03, spacing: 0.15, resistance: 4 } }] },
330
332
  { id: "suspended_slab", drop: 3, strata: [{ material: "concrete", thickness: 0.12, reinforcement: { material: "steel", cover: 0.03, spacing: 0.15, resistance: 4 } }] },
331
333
  { id: "tile_floor", strata: [{ material: "ceramic", thickness: 8e-3 }, { material: "mortar", thickness: 0.03 }, { material: "concrete", thickness: 0.1, reinforcement: { material: "steel", cover: 0.03, spacing: 0.15, resistance: 4 } }] },
@@ -1929,6 +1931,11 @@ var GameTerrain = (() => {
1929
1931
  raycast,
1930
1932
  strike,
1931
1933
  burn,
1934
+ open(excavation) {
1935
+ excavate(excavation);
1936
+ const [ex0, ez0, ex1, ez1] = excavation.rect;
1937
+ emitDeform((ex0 + ex1) / 2, (ez0 + ez1) / 2, Math.hypot(ex1 - ex0, ez1 - ez0) / 2 + cellSize * 2);
1938
+ },
1932
1939
  dig,
1933
1940
  fill,
1934
1941
  applyHit,