@v12-engine/engine 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/dist/abilities/buffs.d.ts +83 -0
- package/dist/abilities/castTold.d.ts +12 -0
- package/dist/abilities/charges.d.ts +28 -0
- package/dist/abilities/dispel.d.ts +9 -0
- package/dist/abilities/effectFields.d.ts +10 -0
- package/dist/abilities/effects/buff.d.ts +8 -0
- package/dist/abilities/effects/core.d.ts +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -0
- package/dist/abilities/effects/missile.d.ts +1 -0
- package/dist/abilities/effects/moves.d.ts +11 -0
- package/dist/abilities/effects/passives.d.ts +15 -0
- package/dist/abilities/effects/sight.d.ts +4 -0
- package/dist/abilities/effects/spawn.d.ts +2 -0
- package/dist/abilities/effects/timed.d.ts +4 -0
- package/dist/abilities/effects/trade.d.ts +1 -0
- package/dist/abilities/effects.d.ts +122 -0
- package/dist/abilities/land.d.ts +21 -0
- package/dist/abilities/scaled.d.ts +21 -0
- package/dist/abilities/text.d.ts +113 -0
- package/dist/ai/area.d.ts +53 -0
- package/dist/ai/brain.d.ts +528 -0
- package/dist/ai/budget.d.ts +67 -0
- package/dist/ai/checks.d.ts +115 -0
- package/dist/ai/computer.d.ts +166 -0
- package/dist/ai/defence.d.ts +108 -0
- package/dist/ai/define.d.ts +21 -0
- package/dist/ai/economy.d.ts +129 -0
- package/dist/ai/geometry.d.ts +35 -0
- package/dist/ai/goals.d.ts +360 -0
- package/dist/ai/index.d.ts +38 -0
- package/dist/ai/knowledge.d.ts +418 -0
- package/dist/ai/lanes.d.ts +232 -0
- package/dist/ai/melee/build.d.ts +61 -0
- package/dist/ai/melee/goals.d.ts +299 -0
- package/dist/ai/melee/heroes.d.ts +27 -0
- package/dist/ai/melee/index.d.ts +14 -0
- package/dist/ai/melee/production.d.ts +8 -0
- package/dist/ai/melee/surrender.d.ts +24 -0
- package/dist/ai/micro.d.ts +278 -0
- package/dist/ai/mission.d.ts +195 -0
- package/dist/ai/missionRules.d.ts +18 -0
- package/dist/ai/module.d.ts +116 -0
- package/dist/ai/options.d.ts +61 -0
- package/dist/ai/plans/build.d.ts +280 -0
- package/dist/ai/plans/placement.d.ts +82 -0
- package/dist/ai/plans/plans.d.ts +105 -0
- package/dist/ai/plans/production.d.ts +210 -0
- package/dist/ai/plans/purse.d.ts +73 -0
- package/dist/ai/plans/tech.d.ts +37 -0
- package/dist/ai/profiles.d.ts +204 -0
- package/dist/ai/reach.d.ts +4 -0
- package/dist/ai/report.d.ts +203 -0
- package/dist/ai/roles.d.ts +133 -0
- package/dist/ai/rules.d.ts +288 -0
- package/dist/ai/scouting.d.ts +98 -0
- package/dist/ai/settings.d.ts +73 -0
- package/dist/ai/squads.d.ts +429 -0
- package/dist/ai/strength.d.ts +167 -0
- package/dist/ai/task.d.ts +118 -0
- package/dist/ai/tasks/attack.d.ts +7 -0
- package/dist/ai/tasks/capture.d.ts +21 -0
- package/dist/ai/tasks/creep.d.ts +16 -0
- package/dist/ai/tasks/defend.d.ts +29 -0
- package/dist/ai/tasks/drop.d.ts +34 -0
- package/dist/ai/tasks/escort.d.ts +16 -0
- package/dist/ai/tasks/gather.d.ts +23 -0
- package/dist/ai/tasks/harass.d.ts +7 -0
- package/dist/ai/tasks/hold.d.ts +20 -0
- package/dist/ai/tasks/index.d.ts +32 -0
- package/dist/ai/tasks/move.d.ts +19 -0
- package/dist/ai/tasks/patrol.d.ts +8 -0
- package/dist/ai/tasks/retreat.d.ts +20 -0
- package/dist/ai/tasks/scout.d.ts +29 -0
- package/dist/ai/tasks/shared.d.ts +74 -0
- package/dist/ai/team.d.ts +155 -0
- package/dist/ai/threat.d.ts +91 -0
- package/dist/ai/view.d.ts +366 -0
- package/dist/ai/waves.d.ts +126 -0
- package/dist/ai.js +6239 -0
- package/dist/ai.js.map +1 -0
- package/dist/aiTesting.d.ts +179 -0
- package/dist/areas.d.ts +149 -0
- package/dist/attacks.d.ts +66 -0
- package/dist/attributes.d.ts +66 -0
- package/dist/brain-BvVdUhX8.js +7659 -0
- package/dist/brain-BvVdUhX8.js.map +1 -0
- package/dist/builds-C6LfgvEU.js +460 -0
- package/dist/builds-C6LfgvEU.js.map +1 -0
- package/dist/bytes.d.ts +6 -0
- package/dist/camps.d.ts +95 -0
- package/dist/capture.d.ts +131 -0
- package/dist/cellLayers.d.ts +75 -0
- package/dist/cinematics.d.ts +194 -0
- package/dist/clock.d.ts +32 -0
- package/dist/commands.d.ts +235 -0
- package/dist/components.d.ts +184 -0
- package/dist/computers.d.ts +108 -0
- package/dist/concealment.d.ts +61 -0
- package/dist/coreComponents-syuh2fPG.js +5149 -0
- package/dist/coreComponents-syuh2fPG.js.map +1 -0
- package/dist/coreComponents.d.ts +1 -0
- package/dist/dashing.d.ts +8 -0
- package/dist/debug.d.ts +36 -0
- package/dist/debug.js +3 -0
- package/dist/debugCommands-CzjrSm66.js +14739 -0
- package/dist/debugCommands-CzjrSm66.js.map +1 -0
- package/dist/debugCommands.d.ts +213 -0
- package/dist/debugging.d.ts +10 -0
- package/dist/definitions.d.ts +43 -0
- package/dist/defs.d.ts +1162 -0
- package/dist/denying.d.ts +81 -0
- package/dist/destructibles.d.ts +27 -0
- package/dist/determinism-BCymQwiE.js +518 -0
- package/dist/determinism-BCymQwiE.js.map +1 -0
- package/dist/determinism.d.ts +121 -0
- package/dist/dialog.d.ts +94 -0
- package/dist/effectRefs.d.ts +16 -0
- package/dist/effects.d.ts +80 -0
- package/dist/endings.d.ts +22 -0
- package/dist/engagement.d.ts +108 -0
- package/dist/engineEvents.d.ts +710 -0
- package/dist/entity.d.ts +409 -0
- package/dist/entityIndex.d.ts +50 -0
- package/dist/errors.d.ts +85 -0
- package/dist/events.d.ts +97 -0
- package/dist/exactMath.d.ts +63 -0
- package/dist/features.d.ts +10 -0
- package/dist/fields.d.ts +114 -0
- package/dist/fixture.d.ts +17 -0
- package/dist/fog.d.ts +110 -0
- package/dist/formation.d.ts +111 -0
- package/dist/friendlyFire.d.ts +26 -0
- package/dist/game-DiJEN-Ks.js +5800 -0
- package/dist/game-DiJEN-Ks.js.map +1 -0
- package/dist/game.d.ts +501 -0
- package/dist/gameData.d.ts +325 -0
- package/dist/gameFiles.d.ts +26 -0
- package/dist/gates.d.ts +28 -0
- package/dist/generate.d.ts +403 -0
- package/dist/generateWorker.d.ts +39 -0
- package/dist/grid.d.ts +53 -0
- package/dist/ground.d.ts +127 -0
- package/dist/groundSpeed.d.ts +22 -0
- package/dist/hero.d.ts +177 -0
- package/dist/home.d.ts +14 -0
- package/dist/hooks.d.ts +780 -0
- package/dist/hotReload.d.ts +76 -0
- package/dist/ids.d.ts +26 -0
- package/dist/index.d.ts +227 -0
- package/dist/index.js +4701 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect-D9dWHmZ0.js +491 -0
- package/dist/inspect-D9dWHmZ0.js.map +1 -0
- package/dist/inspect.d.ts +176 -0
- package/dist/inventory.d.ts +18 -0
- package/dist/items.d.ts +91 -0
- package/dist/lanes.d.ts +213 -0
- package/dist/life.d.ts +53 -0
- package/dist/local-Dkovq42k.js +1379 -0
- package/dist/local-Dkovq42k.js.map +1 -0
- package/dist/log.d.ts +140 -0
- package/dist/manaBurn.d.ts +39 -0
- package/dist/map/file.d.ts +114 -0
- package/dist/map/images.d.ts +18 -0
- package/dist/map/look.d.ts +47 -0
- package/dist/map/pathProfile.d.ts +13 -0
- package/dist/map/resize.d.ts +54 -0
- package/dist/map/schema.d.ts +10 -0
- package/dist/map/terrain.d.ts +32 -0
- package/dist/map/types.d.ts +613 -0
- package/dist/map.d.ts +7 -0
- package/dist/mapCheck/cells.d.ts +19 -0
- package/dist/mapCheck/rule.d.ts +30 -0
- package/dist/mapCheck/rules/names.d.ts +3 -0
- package/dist/mapCheck/rules/objects.d.ts +3 -0
- package/dist/mapCheck/rules/paths.d.ts +3 -0
- package/dist/mapCheck/rules/players.d.ts +3 -0
- package/dist/mapCheck/rules/races.d.ts +3 -0
- package/dist/mapCheck/rules/random.d.ts +3 -0
- package/dist/mapCheck/rules/regions.d.ts +3 -0
- package/dist/mapCheck/rules/targets.d.ts +3 -0
- package/dist/mapCheck/rules/walking.d.ts +3 -0
- package/dist/mapCheck.d.ts +23 -0
- package/dist/mapFields.d.ts +364 -0
- package/dist/mapFile.d.ts +23 -0
- package/dist/mapMeasure.d.ts +95 -0
- package/dist/mapMerge.d.ts +19 -0
- package/dist/mapObjectives.d.ts +82 -0
- package/dist/mapObjects.d.ts +1 -0
- package/dist/math.d.ts +44 -0
- package/dist/messages.d.ts +150 -0
- package/dist/missionRules-C-bGxm0Q.js +523 -0
- package/dist/missionRules-C-bGxm0Q.js.map +1 -0
- package/dist/missionRules.d.ts +179 -0
- package/dist/mods.d.ts +146 -0
- package/dist/names.d.ts +93 -0
- package/dist/navigation/agentParams.d.ts +4 -0
- package/dist/navigation/air.d.ts +89 -0
- package/dist/navigation/builds.d.ts +140 -0
- package/dist/navigation/groundAreas.d.ts +23 -0
- package/dist/navigation/navigation.d.ts +127 -0
- package/dist/navigation/recast.d.ts +214 -0
- package/dist/navigation/sidePaths.d.ts +69 -0
- package/dist/navigation/sized.d.ts +1 -0
- package/dist/navigation-worker.js +11 -0
- package/dist/navigation-worker.js.map +1 -0
- package/dist/nearest.d.ts +8 -0
- package/dist/noise.d.ts +12 -0
- package/dist/objectives.d.ts +93 -0
- package/dist/orders/basic.d.ts +96 -0
- package/dist/orders/build.d.ts +91 -0
- package/dist/orders/cast.d.ts +105 -0
- package/dist/orders/facts.d.ts +14 -0
- package/dist/orders/harvest.d.ts +94 -0
- package/dist/orders/idle.d.ts +7 -0
- package/dist/orders/items.d.ts +14 -0
- package/dist/orders/queue.d.ts +24 -0
- package/dist/pack.schema.json +6621 -0
- package/dist/packs/director/index.d.ts +81 -0
- package/dist/packs/heroes/campaign.d.ts +137 -0
- package/dist/packs/heroes/carry.d.ts +59 -0
- package/dist/packs/heroes/commands.d.ts +6 -0
- package/dist/packs/heroes/hire.d.ts +9 -0
- package/dist/packs/heroes/index.d.ts +12 -0
- package/dist/packs/heroes/making.d.ts +16 -0
- package/dist/packs/heroes/respawn.d.ts +42 -0
- package/dist/packs/moba/index.d.ts +34 -0
- package/dist/packs/pack.d.ts +84 -0
- package/dist/packs-g5thvmGn.js +3199 -0
- package/dist/packs-g5thvmGn.js.map +1 -0
- package/dist/packs.d.ts +84 -0
- package/dist/paths.d.ts +51 -0
- package/dist/plain.d.ts +17 -0
- package/dist/player.d.ts +117 -0
- package/dist/portals.d.ts +66 -0
- package/dist/prefabs.d.ts +139 -0
- package/dist/presetBuildings.d.ts +52 -0
- package/dist/presetGround.d.ts +22 -0
- package/dist/profiles-B3NS9jwk.js +335 -0
- package/dist/profiles-B3NS9jwk.js.map +1 -0
- package/dist/races.d.ts +136 -0
- package/dist/randomGroups.d.ts +2 -0
- package/dist/registry.d.ts +464 -0
- package/dist/remains.d.ts +119 -0
- package/dist/replication.d.ts +103 -0
- package/dist/rng.d.ts +17 -0
- package/dist/rules.d.ts +395 -0
- package/dist/rulesCheck.d.ts +37 -0
- package/dist/runes.d.ts +41 -0
- package/dist/save.d.ts +277 -0
- package/dist/scenario.d.ts +56 -0
- package/dist/scheduler.d.ts +67 -0
- package/dist/score.d.ts +306 -0
- package/dist/sequences.d.ts +132 -0
- package/dist/server/doorman.d.ts +21 -0
- package/dist/server/gameServer.d.ts +346 -0
- package/dist/server/index.d.ts +24 -0
- package/dist/server/lobby.d.ts +1 -0
- package/dist/server/log.d.ts +13 -0
- package/dist/server/match.d.ts +24 -0
- package/dist/server/mode.d.ts +168 -0
- package/dist/server/navigation-worker.d.ts +1 -0
- package/dist/server/navigation.d.ts +11 -0
- package/dist/server/ops.d.ts +78 -0
- package/dist/server/packs.d.ts +15 -0
- package/dist/server/ratings.d.ts +62 -0
- package/dist/server/relay.d.ts +34 -0
- package/dist/server/rooms.d.ts +162 -0
- package/dist/server/seat.d.ts +2 -0
- package/dist/server/seatSettings.d.ts +15 -0
- package/dist/server/secret.d.ts +5 -0
- package/dist/server/start.d.ts +54 -0
- package/dist/server/websocket.d.ts +74 -0
- package/dist/server.js +2861 -0
- package/dist/server.js.map +1 -0
- package/dist/session/can.d.ts +20 -0
- package/dist/session/commandReplay.d.ts +92 -0
- package/dist/session/debug.d.ts +65 -0
- package/dist/session/delay.d.ts +15 -0
- package/dist/session/delta.d.ts +98 -0
- package/dist/session/entityState.d.ts +1 -0
- package/dist/session/local.d.ts +214 -0
- package/dist/session/memory.d.ts +27 -0
- package/dist/session/protocol.d.ts +1155 -0
- package/dist/session/remote.d.ts +530 -0
- package/dist/session/replay.d.ts +114 -0
- package/dist/session/seed.d.ts +7 -0
- package/dist/session/share.d.ts +78 -0
- package/dist/session/socket.d.ts +8 -0
- package/dist/session/wire.d.ts +153 -0
- package/dist/session/worker.d.ts +227 -0
- package/dist/shared.d.ts +171 -0
- package/dist/sides.d.ts +75 -0
- package/dist/sight.d.ts +27 -0
- package/dist/simulate-oXBiw1Ff.js +167 -0
- package/dist/simulate-oXBiw1Ff.js.map +1 -0
- package/dist/simulate-worker.d.ts +1 -0
- package/dist/simulate-worker.js +28 -0
- package/dist/simulate-worker.js.map +1 -0
- package/dist/simulate.d.ts +154 -0
- package/dist/smart.d.ts +9 -0
- package/dist/spatial.d.ts +62 -0
- package/dist/spawning.d.ts +33 -0
- package/dist/stances.d.ts +76 -0
- package/dist/start.d.ts +71 -0
- package/dist/stats.d.ts +122 -0
- package/dist/summons.d.ts +63 -0
- package/dist/systems/abilities.d.ts +3 -0
- package/dist/systems/combat.d.ts +71 -0
- package/dist/systems/combatTold.d.ts +14 -0
- package/dist/systems/construction.d.ts +34 -0
- package/dist/systems/economy.d.ts +21 -0
- package/dist/systems/fog.d.ts +19 -0
- package/dist/systems/life.d.ts +3 -0
- package/dist/systems/movement.d.ts +105 -0
- package/dist/systems/orders.d.ts +7 -0
- package/dist/systems/production.d.ts +49 -0
- package/dist/systems/productionQueue.d.ts +40 -0
- package/dist/systems/victory.d.ts +14 -0
- package/dist/talk.d.ts +65 -0
- package/dist/tech.d.ts +62 -0
- package/dist/techTree.d.ts +38 -0
- package/dist/terrain.d.ts +173 -0
- package/dist/terrainSave.d.ts +29 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +822 -0
- package/dist/testing.js.map +1 -0
- package/dist/tiles.d.ts +34 -0
- package/dist/timers.d.ts +146 -0
- package/dist/tomes.d.ts +48 -0
- package/dist/trade.d.ts +28 -0
- package/dist/transport.d.ts +76 -0
- package/dist/tunables.d.ts +45 -0
- package/dist/upkeep.d.ts +16 -0
- package/dist/veterancy.d.ts +80 -0
- package/dist/walls.d.ts +86 -0
- package/dist/world.d.ts +1118 -0
- package/package.json +80 -5
- package/README.md +0 -3
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { Rng } from './rng';
|
|
2
|
+
import { type GameMap, type MapCamp, type MapDoodad, type MapObject, type MapPlayer, type MapRegion } from './map';
|
|
3
|
+
import type { MapProblem } from './mapFields';
|
|
4
|
+
import type { Vec2 } from './math';
|
|
5
|
+
import type { AreaShape } from './areas';
|
|
6
|
+
import type { PlayerId } from './entity';
|
|
7
|
+
import type { Registry } from './registry';
|
|
8
|
+
/**
|
|
9
|
+
* How a map is mirrored, so that it is fair: not at all, across x, across z, both ways, a half turn about the middle,
|
|
10
|
+
* or quarter turns (a square map, its sides even). As the editor's symmetry says it
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export type MapSymmetry = 'none' | 'x' | 'z' | 'both' | 'half' | 'quarter';
|
|
15
|
+
/**
|
|
16
|
+
* What a map is made with (`generateMap`): the seed, the size, the players, the symmetry, and the game's own
|
|
17
|
+
* parameters (`MapGenerator.params`), each at its default where not said
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export interface GeneratorOptions {
|
|
22
|
+
seed: number;
|
|
23
|
+
width: number;
|
|
24
|
+
depth: number;
|
|
25
|
+
players: number;
|
|
26
|
+
symmetry?: MapSymmetry;
|
|
27
|
+
/** The map's name: "Generated <seed>" when left out */
|
|
28
|
+
name?: string;
|
|
29
|
+
/** The game's own parameters, by id, as the dialog's sliders and switches set them */
|
|
30
|
+
params?: Record<string, number | string | boolean>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A parameter of a generator (`MapGenerator.params`): a slider, a switch or a choice in the editor's dialog and the
|
|
34
|
+
* page's form, and a value in code (`GeneratorOptions.params`)
|
|
35
|
+
*
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
export interface GeneratorParamDef {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
/** A number on a slider (the default), a switch, or one of `choices` */
|
|
43
|
+
kind?: 'number' | 'boolean' | 'choice';
|
|
44
|
+
default: number | string | boolean;
|
|
45
|
+
min?: number;
|
|
46
|
+
max?: number;
|
|
47
|
+
step?: number;
|
|
48
|
+
choices?: {
|
|
49
|
+
value: string;
|
|
50
|
+
label: string;
|
|
51
|
+
}[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* What was put down by a pass, for the passes after to avoid or use (`GeneratorContext.placed`)
|
|
55
|
+
*
|
|
56
|
+
* @beta
|
|
57
|
+
*/
|
|
58
|
+
export interface GeneratorMark {
|
|
59
|
+
kind: string;
|
|
60
|
+
x: number;
|
|
61
|
+
z: number;
|
|
62
|
+
radius: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* What a pass works with (`GeneratorPass.run`): the map as the passes before left it, the seed's numbers, noise that
|
|
66
|
+
* repeats across the map, the symmetry, and what to put down with
|
|
67
|
+
*
|
|
68
|
+
* @beta
|
|
69
|
+
*/
|
|
70
|
+
export interface GeneratorContext {
|
|
71
|
+
map: GameMap;
|
|
72
|
+
/** The seed's numbers: every draw of a pass is one of these, so the same seed makes the same map */
|
|
73
|
+
rng: Rng;
|
|
74
|
+
options: GeneratorOptions;
|
|
75
|
+
registry: Registry;
|
|
76
|
+
/** A parameter as it is: what the options say, or its default (`MapGenerator.params`), or `fallback` where neither says */
|
|
77
|
+
param<T extends number | string | boolean>(id: string, fallback: T): T;
|
|
78
|
+
/**
|
|
79
|
+
* A place, and the places the symmetry mirrors or turns it to (the first is the place itself): what is put down at
|
|
80
|
+
* one is put down at the others, so the map is fair
|
|
81
|
+
*/
|
|
82
|
+
symmetric(x: number, z: number): Vec2[];
|
|
83
|
+
/** Whether a cell is the first of its mirrored set: what is done once a set is done at this one, and mirrored from it */
|
|
84
|
+
canonical(cx: number, cz: number): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* What `draw` makes, made once for a place and the places the symmetry mirrors it to: the first call of a set draws
|
|
87
|
+
* (and spends the seed's numbers), the calls for its mirrors get the same. For a choice put down at every mirror
|
|
88
|
+
* (a camp's creeps), so the map stays fair
|
|
89
|
+
*/
|
|
90
|
+
once<T>(x: number, z: number, draw: () => T): T;
|
|
91
|
+
/**
|
|
92
|
+
* Noise that repeats across the map, by a name (the same name is the same noise), 0..1 at a point of the map in
|
|
93
|
+
* cells; `cells` are the sizes of its features, coarsest first (`[32, 16, 8]` for hills). Mirrored as the map is
|
|
94
|
+
*/
|
|
95
|
+
noise(name: string, cells?: readonly number[]): (x: number, z: number) => number;
|
|
96
|
+
/** What the passes before put down, by kind */
|
|
97
|
+
placed: GeneratorMark[];
|
|
98
|
+
/** Puts a mark down for the passes after: nothing on the map, only in `placed` */
|
|
99
|
+
mark(kind: string, x: number, z: number, radius: number): void;
|
|
100
|
+
/** Whether nothing marked is within `radius` of a place (of `kinds` alone, when said) */
|
|
101
|
+
free(x: number, z: number, radius: number, kinds?: readonly string[]): boolean;
|
|
102
|
+
/** The level of the ground at a point: its cell's cliff level */
|
|
103
|
+
levelAt(x: number, z: number): number;
|
|
104
|
+
/** Whether a point is on the map and on ground something walks: no deep water, not off the map */
|
|
105
|
+
walkable(x: number, z: number): boolean;
|
|
106
|
+
/** Scenery put down, with an id of its own: the model by its path in `models/`, as big as it says, turned as it says */
|
|
107
|
+
addDoodad(doodad: Omit<MapDoodad, 'id' | 'scale' | 'yaw'> & {
|
|
108
|
+
scale?: number | [number, number, number];
|
|
109
|
+
yaw?: number;
|
|
110
|
+
}): MapDoodad;
|
|
111
|
+
/** A unit or a building of a type put down, with an id of its own, for a player (`MAP_NEUTRAL`, `MAP_CREEPS`, or one of the map's) */
|
|
112
|
+
addObject(type: string, owner: PlayerId, x: number, z: number, more?: Partial<Omit<MapObject, 'id' | 'type' | 'owner' | 'x' | 'z'>>): MapObject;
|
|
113
|
+
/** Creeps that guard a spot, with an id of their own */
|
|
114
|
+
addCamp(x: number, z: number, units: string[], more?: Partial<Omit<MapCamp, 'id' | 'x' | 'z' | 'units'>>): MapCamp;
|
|
115
|
+
/** A region the rules watch by name, with an id of its own */
|
|
116
|
+
addRegion(name: string, shape: AreaShape, more?: Partial<Omit<MapRegion, 'id' | 'name' | 'shape'>>): MapRegion;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A pass of a generator: one thing done to the map, in its turn (`MapGenerator.passes`)
|
|
120
|
+
*
|
|
121
|
+
* @beta
|
|
122
|
+
*/
|
|
123
|
+
export interface GeneratorPass {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
run(ctx: GeneratorContext): void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A game's generator (`GameModule.generator`): its parameters, as the dialog and the page show them, and its passes
|
|
130
|
+
* in order. `generateMap` runs it
|
|
131
|
+
*
|
|
132
|
+
* @beta
|
|
133
|
+
*/
|
|
134
|
+
export interface MapGenerator {
|
|
135
|
+
params: GeneratorParamDef[];
|
|
136
|
+
passes: GeneratorPass[];
|
|
137
|
+
/**
|
|
138
|
+
* How many seeds are tried where the map comes out with a problem that keeps it from being played (an error, a start
|
|
139
|
+
* cut off from the others or blocked): 4 when left out
|
|
140
|
+
*/
|
|
141
|
+
tries?: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* How a map was made, kept with it (`GameMap.generated`): the same again from the same
|
|
145
|
+
*
|
|
146
|
+
* @beta
|
|
147
|
+
*/
|
|
148
|
+
export interface GeneratedWith {
|
|
149
|
+
seed: number;
|
|
150
|
+
options: GeneratorOptions;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The map a generator makes of options: its passes run in order on a map of the size and players asked, with the
|
|
154
|
+
* game's tiles; then checked (`checkMap`). A map with a problem that keeps it from being played (a start cut off from
|
|
155
|
+
* the others, or where nothing walks) is thrown away and the next seed tried, `tries` times; the last is given with
|
|
156
|
+
* its problems. The map says how it was made (`GameMap.generated`)
|
|
157
|
+
*
|
|
158
|
+
* @beta
|
|
159
|
+
*/
|
|
160
|
+
export declare function generateMap(generator: MapGenerator, options: GeneratorOptions, registry: Registry): {
|
|
161
|
+
map: GameMap;
|
|
162
|
+
problems: MapProblem[];
|
|
163
|
+
seed: number;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* The places a point is mirrored or turned to, the point first (as the editor's `mirrors`)
|
|
167
|
+
*
|
|
168
|
+
* @beta
|
|
169
|
+
*/
|
|
170
|
+
export declare function symmetricPlaces(symmetry: MapSymmetry, width: number, depth: number, x: number, z: number): Vec2[];
|
|
171
|
+
/**
|
|
172
|
+
* What `terrainPass` takes: the parameters of the generator it reads where they are not given here
|
|
173
|
+
*
|
|
174
|
+
* @beta
|
|
175
|
+
*/
|
|
176
|
+
export interface TerrainPassOptions {
|
|
177
|
+
/** How many cliff levels the ground rises through, 1 (flat) to 4: the parameter `levels`, or 2 */
|
|
178
|
+
levels?: number;
|
|
179
|
+
/** How much of the map is under water, 0..1: the parameter `water`, or 0.15 */
|
|
180
|
+
water?: number;
|
|
181
|
+
/** How much the ground rolls within a level, 0..1: the parameter `roughness`, or 0.4 */
|
|
182
|
+
roughness?: number;
|
|
183
|
+
/** How many cells a hill is across, about: the parameter `hills`, or 24 */
|
|
184
|
+
hills?: number;
|
|
185
|
+
/** Whether ramps are cut so that every part of the ground can be walked to: yes when left out */
|
|
186
|
+
ramps?: boolean;
|
|
187
|
+
/** How wide a ramp is, in cells: 3 when left out */
|
|
188
|
+
rampWidth?: number;
|
|
189
|
+
/**
|
|
190
|
+
* The lie of the land, where it is not the noise's alone: the ground's value at a point (high is high), made from the
|
|
191
|
+
* point, the plateau noise there (0..1) and the map; the levels and the water are cut from the values as ever (the
|
|
192
|
+
* lowest share water). A bay (`basinShape`: the corners high, a sea in the middle, an island in it), a valley, a
|
|
193
|
+
* ridge: a shape of the game's own
|
|
194
|
+
*/
|
|
195
|
+
shape?: (x: number, z: number, noise: number, map: GameMap) => number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* What `basinShape` takes
|
|
199
|
+
*
|
|
200
|
+
* @beta
|
|
201
|
+
*/
|
|
202
|
+
export interface BasinShapeOptions {
|
|
203
|
+
/** How big the island in the middle is, 0..1 of the way to the corners: 0.14 when left out, 0 for no island */
|
|
204
|
+
island?: number;
|
|
205
|
+
/** How much the noise moves the shore and the island about, 0..1: 0.25 when left out */
|
|
206
|
+
roughness?: number;
|
|
207
|
+
/**
|
|
208
|
+
* How high the island rises, in the shape's values (the corners are at 1, the middle of the sea at 0): 0.4 when
|
|
209
|
+
* left out, which with `water` at 0.2 and three levels lands it on the lowest dry level, the beach's, so that fords
|
|
210
|
+
* of shallow water reach it with no cliff between
|
|
211
|
+
*/
|
|
212
|
+
height?: number;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The lie of a bay, for `terrainPass`'s `shape`: the corners high, the ground falling to a sea in the middle, an
|
|
216
|
+
* island in it. With `water` at 0.25–0.35 the sea takes the middle and the shore runs round it; the starts in the
|
|
217
|
+
* corners (`startsPass` with a spread of 0.4), the way between them along the shore
|
|
218
|
+
*
|
|
219
|
+
* @beta
|
|
220
|
+
*/
|
|
221
|
+
export declare function basinShape(options?: BasinShapeOptions): NonNullable<TerrainPassOptions['shape']>;
|
|
222
|
+
/**
|
|
223
|
+
* The ground: a height field of noise, mirrored as the map is, quantised into cliff levels with the ground rolling
|
|
224
|
+
* within each, water in the low ground, and ramps cut between the levels so that every part can be walked to
|
|
225
|
+
*
|
|
226
|
+
* @beta
|
|
227
|
+
*/
|
|
228
|
+
export declare function terrainPass(options?: TerrainPassOptions): GeneratorPass;
|
|
229
|
+
/**
|
|
230
|
+
* What `tilesPass` takes: how a cell is painted, from what the ground is there
|
|
231
|
+
*
|
|
232
|
+
* @beta
|
|
233
|
+
*/
|
|
234
|
+
export interface TilesPassOptions {
|
|
235
|
+
/**
|
|
236
|
+
* The tile a cell is painted with, by id, or nothing for none (the ground's own colours): from its level, the slope
|
|
237
|
+
* there (radians), how wet it is (a noise, 0..1) and whether it is by the water. The engine's own rule when left
|
|
238
|
+
* out: `sand` by the water, `rock` on steep ground (the cliffs), `snow` on the top of four levels or more, `dirt`
|
|
239
|
+
* where it is dry, each where the game has such a tile
|
|
240
|
+
*/
|
|
241
|
+
by?: (cell: {
|
|
242
|
+
x: number;
|
|
243
|
+
z: number;
|
|
244
|
+
level: number;
|
|
245
|
+
slope: number;
|
|
246
|
+
moisture: number;
|
|
247
|
+
shore: boolean;
|
|
248
|
+
}, tiles: readonly string[]) => string | undefined;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The paint: each cell a tile by what the ground is there, through the game's tiles by name
|
|
252
|
+
*
|
|
253
|
+
* @beta
|
|
254
|
+
*/
|
|
255
|
+
export declare function tilesPass(options?: TilesPassOptions): GeneratorPass;
|
|
256
|
+
/**
|
|
257
|
+
* What `startsPass` takes
|
|
258
|
+
*
|
|
259
|
+
* @beta
|
|
260
|
+
*/
|
|
261
|
+
export interface StartsPassOptions {
|
|
262
|
+
/** How many cells around a start are flattened and dried: 6 when left out */
|
|
263
|
+
clearing?: number;
|
|
264
|
+
/** How far from the map's middle the starts stand, 0..0.5 of its size: 0.36 when left out */
|
|
265
|
+
spread?: number;
|
|
266
|
+
/** What a game puts at a start: its town hall and workers. Nothing when left out */
|
|
267
|
+
from?: (player: MapPlayer, at: Vec2, ctx: GeneratorContext) => void;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The starts: as far apart as the symmetry allows (mirrored from one, or around the middle), each on flat, dry ground
|
|
271
|
+
* (a clearing made for it), the player's `start` set, and what the game puts there
|
|
272
|
+
*
|
|
273
|
+
* @beta
|
|
274
|
+
*/
|
|
275
|
+
export declare function startsPass(options?: StartsPassOptions): GeneratorPass;
|
|
276
|
+
/**
|
|
277
|
+
* The nearest place to one that is not in the water, at a cell's middle: for a pass of a game's own that puts something
|
|
278
|
+
* down where the ground may be wet
|
|
279
|
+
*
|
|
280
|
+
* @beta
|
|
281
|
+
*/
|
|
282
|
+
export declare const nearestDryGround: (ctx: GeneratorContext, at: Vec2, reach: number) => Vec2;
|
|
283
|
+
/**
|
|
284
|
+
* The ground around a place made flat and dry: one level (the one there, or `level`), no water, no ramps, the ground at
|
|
285
|
+
* one height eased into what is around; mirrored as the map is, unless `alone`. What a start's clearing and a mine's
|
|
286
|
+
* are made with, for a pass of a game's own
|
|
287
|
+
*
|
|
288
|
+
* @beta
|
|
289
|
+
*/
|
|
290
|
+
export declare const clearGround: (ctx: GeneratorContext, at: Vec2, radius: number, alone?: boolean, level?: number) => void;
|
|
291
|
+
/**
|
|
292
|
+
* What `scatterPass` takes: how much of what, where
|
|
293
|
+
*
|
|
294
|
+
* @beta
|
|
295
|
+
*/
|
|
296
|
+
export interface ScatterPassOptions {
|
|
297
|
+
/** What the things are, for the passes after (`placed`): `trees`, `rocks` */
|
|
298
|
+
kind: string;
|
|
299
|
+
/** Puts one down at a place: a doodad, a unit, a camp, a region */
|
|
300
|
+
what: (ctx: GeneratorContext, at: Vec2) => void;
|
|
301
|
+
/** How much of the map they cover, 0..1: the parameter `<kind>` where the generator has one, or 0.12 */
|
|
302
|
+
density?: number;
|
|
303
|
+
/** How far apart they are at least, in cells: 1.5 when left out */
|
|
304
|
+
spacing?: number;
|
|
305
|
+
/** How big each is, for what comes after to keep off: half the spacing when left out */
|
|
306
|
+
radius?: number;
|
|
307
|
+
/** How far from a start they keep, in cells: 10 when left out */
|
|
308
|
+
avoid?: number;
|
|
309
|
+
/** What else they keep off, by kind (`placed`), with how far: the starts always */
|
|
310
|
+
avoidKinds?: Record<string, number>;
|
|
311
|
+
/** Where they may go: a cell's level, slope, water and the noise of the kind (0..1, patches). On any dry ground when left out */
|
|
312
|
+
where?: (cell: {
|
|
313
|
+
x: number;
|
|
314
|
+
z: number;
|
|
315
|
+
level: number;
|
|
316
|
+
slope: number;
|
|
317
|
+
noise: number;
|
|
318
|
+
shore: boolean;
|
|
319
|
+
}) => boolean;
|
|
320
|
+
/** In patches of a noise (how much the noise decides, 0 even, 1 all in patches): 0.6 when left out */
|
|
321
|
+
patches?: number;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Things scattered over the map: as many as the density says, in patches of a noise, at least `spacing` apart, off
|
|
325
|
+
* the starts and what else they avoid, where they may go; each put down by `what`, mirrored as the map is. Trees now;
|
|
326
|
+
* rocks, houses, ruins and the rest the same way, with another `what`
|
|
327
|
+
*
|
|
328
|
+
* @beta
|
|
329
|
+
*/
|
|
330
|
+
export declare function scatterPass(options: ScatterPassOptions): GeneratorPass;
|
|
331
|
+
/**
|
|
332
|
+
* What `resourcesPass` takes: where the game's mines go, and what the game puts there
|
|
333
|
+
*
|
|
334
|
+
* @beta
|
|
335
|
+
*/
|
|
336
|
+
export interface ResourcesPassOptions {
|
|
337
|
+
/** How far from each start its own stands, in cells: 8 when left out; `false` for none at the starts (a game puts those down itself) */
|
|
338
|
+
main?: number | false;
|
|
339
|
+
/** How many more there are besides the starts', spread over the map and mirrored: 2 when left out */
|
|
340
|
+
extra?: number;
|
|
341
|
+
/** How far apart the extra ones keep from each other and from the starts, in cells: 20 when left out */
|
|
342
|
+
spacing?: number;
|
|
343
|
+
/**
|
|
344
|
+
* How many cells around each are made flat and dry for it, as a start's clearing is: 3 when left out, enough for a
|
|
345
|
+
* mine of 4 by 4; 0 for none
|
|
346
|
+
*/
|
|
347
|
+
clearing?: number;
|
|
348
|
+
/** Puts the resource down: the game's mine, a camp guarding it. Told the start it is for, where it is one's */
|
|
349
|
+
from: (ctx: GeneratorContext, at: Vec2, start?: MapPlayer) => void;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Resources: one near each start (towards the map's middle, as far as `main` says), and more spread over the map,
|
|
353
|
+
* mirrored as the map is, each put down by the game
|
|
354
|
+
*
|
|
355
|
+
* @beta
|
|
356
|
+
*/
|
|
357
|
+
export declare function resourcesPass(options: ResourcesPassOptions): GeneratorPass;
|
|
358
|
+
/**
|
|
359
|
+
* What `roadsPass` takes
|
|
360
|
+
*
|
|
361
|
+
* @beta
|
|
362
|
+
*/
|
|
363
|
+
export interface RoadsPassOptions {
|
|
364
|
+
/** The tile the road is painted with, by id */
|
|
365
|
+
tile: string;
|
|
366
|
+
/** How wide, in cells: 2 when left out */
|
|
367
|
+
width?: number;
|
|
368
|
+
/** Between what: every two starts when left out, or places of the map's own */
|
|
369
|
+
between?: Vec2[];
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Roads between the starts (or places given), the way something on foot would go (over the level map, by ramps, around
|
|
373
|
+
* water; the gentlest ground preferred), painted with a tile
|
|
374
|
+
*
|
|
375
|
+
* @beta
|
|
376
|
+
*/
|
|
377
|
+
export declare function roadsPass(options: RoadsPassOptions): GeneratorPass;
|
|
378
|
+
/**
|
|
379
|
+
* What the engine's preset takes from a game: what its scenery is
|
|
380
|
+
*
|
|
381
|
+
* @beta
|
|
382
|
+
*/
|
|
383
|
+
export interface PresetGeneratorOptions {
|
|
384
|
+
/** The models of trees, by their paths in `models/`: one picked for each. No trees when left out */
|
|
385
|
+
trees?: string[];
|
|
386
|
+
/** How big a tree is drawn, and how much that varies: 1, by a fifth, when left out */
|
|
387
|
+
treeScale?: {
|
|
388
|
+
scale?: number;
|
|
389
|
+
vary?: number;
|
|
390
|
+
};
|
|
391
|
+
/** The models of rocks, the same way. None when left out */
|
|
392
|
+
rocks?: string[];
|
|
393
|
+
/** What a game puts at a start (`startsPass`): its hall and workers */
|
|
394
|
+
start?: StartsPassOptions['from'];
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* A generator to take whole: hills and water, the paint, the starts, trees in patches and rocks about, with the
|
|
398
|
+
* parameters `levels`, `water`, `roughness`, `hills`, `trees` and `rocks`; what the trees and rocks are is the game's
|
|
399
|
+
* to say
|
|
400
|
+
*
|
|
401
|
+
* @beta
|
|
402
|
+
*/
|
|
403
|
+
export declare function presetGenerator(options?: PresetGeneratorOptions): MapGenerator;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type GeneratorOptions } from './generate';
|
|
2
|
+
import { type GameModule } from './game';
|
|
3
|
+
import type { GameMap } from './map';
|
|
4
|
+
import type { MapProblem } from './mapFields';
|
|
5
|
+
import type { NavigationPort, NavigationWorkerLike } from './navigation/builds';
|
|
6
|
+
/**
|
|
7
|
+
* A map a generator made (`generateMap`): the map, what is wrong with it, and the seed it came out of
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export interface GeneratedMap {
|
|
12
|
+
map: GameMap;
|
|
13
|
+
problems: MapProblem[];
|
|
14
|
+
seed: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Makes a map of options somewhere else than this thread (`mapGeneratorWorker`): a menu's preview of a random map that
|
|
18
|
+
* does not stop the page while it is made
|
|
19
|
+
*
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
export type MapGenerating = (options: GeneratorOptions) => Promise<GeneratedMap>;
|
|
23
|
+
/**
|
|
24
|
+
* What a worker's file of a game's maps does: it makes, with the game's generator (`GameModule.generator`) and its
|
|
25
|
+
* registry, the map of each set of options it is sent, and sends it back. A worker's file of two lines, the game's rules
|
|
26
|
+
* imported and this called with them; `port` is where it hears, as for `serveNavigationBuilds`: the worker's own scope
|
|
27
|
+
* when left out
|
|
28
|
+
*
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
export declare function serveMapGenerator(rules: GameModule, port?: NavigationPort): void;
|
|
32
|
+
/**
|
|
33
|
+
* Maps made in a worker whose file serves them (`serveMapGenerator`): the page makes the worker as its bundler wants it,
|
|
34
|
+
* `mapGeneratorWorker(() => new Worker(new URL('./generate.worker.ts', import.meta.url), { type: 'module' }))`. Given
|
|
35
|
+
* as a function, the worker is made at the first map asked for: a menu that is never opened fetches none of it
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare function mapGeneratorWorker(given: NavigationWorkerLike | (() => NavigationWorkerLike)): MapGenerating;
|
package/dist/grid.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Terrain } from './terrain';
|
|
2
|
+
/**
|
|
3
|
+
* Min cell of a footprint centered as close as possible to the given point
|
|
4
|
+
*
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export declare const footprintCell: (x: number, z: number, w: number, d: number) => {
|
|
8
|
+
x: number;
|
|
9
|
+
z: number;
|
|
10
|
+
};
|
|
11
|
+
export interface GridOptions {
|
|
12
|
+
/** Steepest slope (radians) that can be built on */
|
|
13
|
+
maxBuildSlope?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Placement grid. One cell per world unit, tracking where structures stand and
|
|
17
|
+
* where the ground is flat enough to build.
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export declare class BuildGrid {
|
|
22
|
+
private readonly terrain;
|
|
23
|
+
readonly width: number;
|
|
24
|
+
readonly depth: number;
|
|
25
|
+
/** Id of the structure occupying each cell, 0 when free */
|
|
26
|
+
private readonly occupant;
|
|
27
|
+
private readonly buildable;
|
|
28
|
+
/** The steepest a cell is built on */
|
|
29
|
+
private readonly maxBuildSlope;
|
|
30
|
+
constructor(terrain: Terrain, options?: GridOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Works out again where can be built, in a rectangle of cells and the ring about it (a slope is of the vertices about a
|
|
33
|
+
* cell): after the ground was reshaped there (`World.reshapeGround`). What stands there stays where it is
|
|
34
|
+
*/
|
|
35
|
+
groundChanged(rect: {
|
|
36
|
+
x: number;
|
|
37
|
+
z: number;
|
|
38
|
+
width: number;
|
|
39
|
+
depth: number;
|
|
40
|
+
}): void;
|
|
41
|
+
inBounds(x: number, z: number): boolean;
|
|
42
|
+
occupantAt(x: number, z: number): number;
|
|
43
|
+
isBuildable(x: number, z: number): boolean;
|
|
44
|
+
isFree(x: number, z: number): boolean;
|
|
45
|
+
/** Min cell of a footprint centered as close as possible to the given point */
|
|
46
|
+
cellFor(x: number, z: number, w: number, d: number): {
|
|
47
|
+
x: number;
|
|
48
|
+
z: number;
|
|
49
|
+
};
|
|
50
|
+
canPlace(cellX: number, cellZ: number, w: number, d: number): boolean;
|
|
51
|
+
occupy(cellX: number, cellZ: number, w: number, d: number, id: number): void;
|
|
52
|
+
release(cellX: number, cellZ: number, w: number, d: number, id: number): void;
|
|
53
|
+
}
|
package/dist/ground.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type TerrainSave } from './terrainSave';
|
|
2
|
+
import { Terrain } from './terrain';
|
|
3
|
+
/**
|
|
4
|
+
* The ground of a save or a welcome: all of it, or the map it started as and what changed of it
|
|
5
|
+
*
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export type SavedGround = TerrainSave | GroundChanges;
|
|
9
|
+
/**
|
|
10
|
+
* The ground as a map the game has, and the cells of it that changed: in a save and in a welcome
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export interface GroundChanges {
|
|
15
|
+
/** The map it started as, by its name (`GameMap.name`) and a hash of the ground it makes (`groundHash`) */
|
|
16
|
+
map: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
width: number;
|
|
19
|
+
depth: number;
|
|
20
|
+
/** For each layer that changed: which cells (packed as 32-bit numbers), and what each holds now */
|
|
21
|
+
changes: Partial<Record<GroundLayer, {
|
|
22
|
+
count: number;
|
|
23
|
+
at: string;
|
|
24
|
+
to: string;
|
|
25
|
+
}>>;
|
|
26
|
+
/** The same for the game's layers of cells (`Terrain.cells`), by id */
|
|
27
|
+
cells?: Record<string, {
|
|
28
|
+
count: number;
|
|
29
|
+
at: string;
|
|
30
|
+
to: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** The part of the map play happens in, as it is now */
|
|
33
|
+
bounds?: {
|
|
34
|
+
x: number;
|
|
35
|
+
z: number;
|
|
36
|
+
width: number;
|
|
37
|
+
depth: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
declare const LAYERS: readonly ['heights', 'levels', 'water', 'waterHeights', 'tiles', 'blocked'];
|
|
41
|
+
/** @beta */
|
|
42
|
+
export type GroundLayer = (typeof LAYERS)[number];
|
|
43
|
+
/**
|
|
44
|
+
* Whether a save's ground is the changes of a map, not the whole of it
|
|
45
|
+
*
|
|
46
|
+
* @beta
|
|
47
|
+
*/
|
|
48
|
+
export declare const isGroundChanges: (ground: SavedGround) => ground is GroundChanges;
|
|
49
|
+
/**
|
|
50
|
+
* A hash of a ground, every layer of it and its size: two grounds of the same hash are the same ground
|
|
51
|
+
*
|
|
52
|
+
* @beta
|
|
53
|
+
*/
|
|
54
|
+
export declare function groundHash(terrain: Terrain): string;
|
|
55
|
+
/**
|
|
56
|
+
* The ground a world started on, from a map: kept with the world (`World.ground`), not in its save
|
|
57
|
+
*
|
|
58
|
+
* @beta
|
|
59
|
+
*/
|
|
60
|
+
export interface GroundBase {
|
|
61
|
+
map: string;
|
|
62
|
+
/** A hash of the ground (`groundHash`): worked out the first time it is asked for */
|
|
63
|
+
readonly hash: string;
|
|
64
|
+
terrain: Terrain;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A part of the ground as it is, to put in another of the same size (`applyTerrainPatch`): a rectangle of cells and
|
|
68
|
+
* every layer of it, the vertices at its corners included. What the editor's Play here sends of the map's ground as it
|
|
69
|
+
* is edited (`debug.ground`, EQ10), and what a session is told of it (`ground`)
|
|
70
|
+
*
|
|
71
|
+
* @beta
|
|
72
|
+
*/
|
|
73
|
+
export interface TerrainPatch {
|
|
74
|
+
/** The first cell, and how many across and down */
|
|
75
|
+
x: number;
|
|
76
|
+
z: number;
|
|
77
|
+
width: number;
|
|
78
|
+
depth: number;
|
|
79
|
+
/** Per vertex, row by row: `(width + 1) * (depth + 1)` of them */
|
|
80
|
+
heights: number[];
|
|
81
|
+
waterHeights: number[];
|
|
82
|
+
/** Per cell, row by row: `width * depth` of them */
|
|
83
|
+
levels: number[];
|
|
84
|
+
water: number[];
|
|
85
|
+
tiles: number[];
|
|
86
|
+
blocked: number[];
|
|
87
|
+
/** The game's layers of cells (`Terrain.cells`), by id, per cell: those in either ground */
|
|
88
|
+
cells?: Record<string, number[]>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The cells of two grounds of one size that are not the same, as the smallest rectangle around them; none where they
|
|
92
|
+
* are the same. Every layer, the game's layers of cells too. Two of other sizes: all of `after`
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export declare function groundDifference(before: Terrain, after: Terrain): {
|
|
97
|
+
x: number;
|
|
98
|
+
z: number;
|
|
99
|
+
width: number;
|
|
100
|
+
depth: number;
|
|
101
|
+
} | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* A rectangle of cells of a ground as it is (`TerrainPatch`): to be put in another
|
|
104
|
+
*
|
|
105
|
+
* @beta
|
|
106
|
+
*/
|
|
107
|
+
export declare function terrainPatch(terrain: Terrain, rect: {
|
|
108
|
+
x: number;
|
|
109
|
+
z: number;
|
|
110
|
+
width: number;
|
|
111
|
+
depth: number;
|
|
112
|
+
}): TerrainPatch;
|
|
113
|
+
/**
|
|
114
|
+
* What is wrong with a patch for a ground (`TerrainPatch`): out of it, or of layers of other lengths. Nothing when it fits
|
|
115
|
+
*
|
|
116
|
+
* @beta
|
|
117
|
+
*/
|
|
118
|
+
export declare function terrainPatchProblem(terrain: Terrain, patch: TerrainPatch): string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Puts a patch (`TerrainPatch`) in a ground, in place: its heights, water, paint and levels, and the game's layers of
|
|
121
|
+
* cells (a layer the patch has that the ground has not is made). Nothing else: what the rules make of the ground is
|
|
122
|
+
* `World.reshapeGround`'s. Throws where it does not fit (`terrainPatchProblem`)
|
|
123
|
+
*
|
|
124
|
+
* @beta
|
|
125
|
+
*/
|
|
126
|
+
export declare function applyTerrainPatch(terrain: Terrain, patch: TerrainPatch): void;
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Entity } from './entity';
|
|
2
|
+
import type { Registry } from './registry';
|
|
3
|
+
import type { Terrain } from './terrain';
|
|
4
|
+
import type { World } from './world';
|
|
5
|
+
/**
|
|
6
|
+
* How fast one on foot goes over a cell of the map, as a multiplier: the tile's `speed` times the `speed` of every
|
|
7
|
+
* layer of cells that is not 0 there; 1 where nothing says. Off the map, 1
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export declare function groundSpeedOfCell(world: World, x: number, z: number): number;
|
|
12
|
+
/** `groundSpeedOfCell` of a game's ground before there is a world of it: what its navigation is cut with */
|
|
13
|
+
export declare function groundSpeedOn(registry: Registry, terrain: Terrain, x: number, z: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* How fast a unit goes where it stands, as a multiplier of its speed: the ground's for one on foot
|
|
16
|
+
* (`groundSpeedOfCell`), 1 for what flies or sails
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare function groundSpeedAt(world: World, entity: Entity): number;
|
|
21
|
+
/** Whether any of a game's ground slows or speeds one on foot: a tile, or a layer of cells, with a speed of its own */
|
|
22
|
+
export declare function hasGroundSpeeds(registry: Registry): boolean;
|