@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,184 @@
|
|
|
1
|
+
import type { Entity, PlayerId } from './entity';
|
|
2
|
+
import type { MapFieldDef } from './mapFields';
|
|
3
|
+
import type { Registry } from './registry';
|
|
4
|
+
import type { World } from './world';
|
|
5
|
+
/**
|
|
6
|
+
* Components are typed state a game module or a mod keeps where the engine has no field for it: on an entity
|
|
7
|
+
* (`entity.get(key)`), for the whole world (`world.state(key)`) or for each player (`player.state(key)`). The engine's
|
|
8
|
+
* own parts are components too (`core.`: what a shop sells, an illusion's source), so that a game pays for what it uses
|
|
9
|
+
* and nothing else.
|
|
10
|
+
*
|
|
11
|
+
* A component is plain data, so that it goes into a save with the rest of the world (see `saveWorld`): numbers,
|
|
12
|
+
* text, lists and plain objects, with other entities by id.
|
|
13
|
+
*
|
|
14
|
+
* `T` is what the component holds; `S` is what a player's snapshot carries of it (`snapshot`), `T` itself when it is
|
|
15
|
+
* sent as it is
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface Component<T, S = T> {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
/** What it starts as. Needed for world and player state, which is there from the moment it is asked for */
|
|
22
|
+
readonly default?: () => T;
|
|
23
|
+
/**
|
|
24
|
+
* Who gets an entity's component in their snapshot (`EntityState.components`), for a game's view to show:
|
|
25
|
+
* the player it belongs to, their allies too, or everyone who sees the entity. Nobody when left out
|
|
26
|
+
*/
|
|
27
|
+
readonly replicate?: Audience;
|
|
28
|
+
/**
|
|
29
|
+
* `false` for what is the app's, not the game's rules (where the screen is played from, a tool's own): kept in the
|
|
30
|
+
* app's saves, but left out of a scenario (`scenarioOfWorld`), which is loaded where only the game is (a test)
|
|
31
|
+
*/
|
|
32
|
+
readonly portable?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* What a player's snapshot carries of it, worked out for each player told (`replicate`): a part of it, rounded,
|
|
35
|
+
* or shaped for the screen (a shop's stock with how far the next one is, not the seconds left). A copy of the whole
|
|
36
|
+
* value when left out. What it returns is plain data; `undefined` sends nothing to that player
|
|
37
|
+
*
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
snapshot?(value: T, entity: Entity, view: SnapshotView): S | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Whether two snapshots of it say the same, for the delta a player is sent (`same`): field by field, as the
|
|
43
|
+
* component knows its shape. Compared as text (`JSON.stringify`) when left out, which costs with a big value
|
|
44
|
+
*
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
same?(a: S, b: S): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Filed in the world's index (`world.index.with(key)`, always kept), and by owner too (`'owner'`:
|
|
50
|
+
* `world.index.with(key, player)`) for what a player asks for often (their heroes), so a system goes through what
|
|
51
|
+
* has the component and nothing else
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
readonly index?: boolean | 'owner';
|
|
56
|
+
/**
|
|
57
|
+
* A field of the map editor's for it: what is placed on a map starts with the component set to what the field says
|
|
58
|
+
* (`MapObject.data[id]`, under the component's own id), the editor's Inspector shows it for what `for` names, and
|
|
59
|
+
* the game has it from the moment the world is made, with nothing to copy over in a `mapObject` hook
|
|
60
|
+
*
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
63
|
+
readonly field?: ComponentFieldDef;
|
|
64
|
+
/**
|
|
65
|
+
* What an entity starts with of it, as it is made (`World.spawn`), by its type: a building that makes things gets
|
|
66
|
+
* its queue, a unit that carries its slots. Run for every entity made, the engine's parts first and in their order,
|
|
67
|
+
* before the `made` hook; what it does not want of an entity, it leaves alone
|
|
68
|
+
*
|
|
69
|
+
* @beta
|
|
70
|
+
*/
|
|
71
|
+
readonly onSpawn?: (entity: Entity, world: World) => void;
|
|
72
|
+
/**
|
|
73
|
+
* What is called off of it as the entity leaves its owner: it dies (before the `death` hook), or is given to
|
|
74
|
+
* another (`World.setOwner`). Run for an entity that has it
|
|
75
|
+
*
|
|
76
|
+
* @beta
|
|
77
|
+
*/
|
|
78
|
+
readonly onLeave?: (entity: Entity, world: World) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Whether a structure that has it stands open now, in nobody's way (a gate opened): what puts the world back from a
|
|
81
|
+
* save leaves it out of the ways as it was. The part that opens and shuts it takes it out and puts it back as it
|
|
82
|
+
* goes (`World.nav`). Run for an entity that has it
|
|
83
|
+
*
|
|
84
|
+
* @beta
|
|
85
|
+
*/
|
|
86
|
+
passable?(value: T, entity: Entity): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* What a save keeps of it, where that is not its value as it is (plain data: numbers, text, lists, plain objects): a
|
|
89
|
+
* `Map` as its entries, an effect as where it is in its ability. Its value as it is when left out, which has to be
|
|
90
|
+
* plain data then
|
|
91
|
+
*
|
|
92
|
+
* @beta
|
|
93
|
+
*/
|
|
94
|
+
save?(value: T, world: World): unknown;
|
|
95
|
+
/** It again, of what `save` gave, as a save is loaded: the save's value as it is when left out @beta */
|
|
96
|
+
load?(saved: unknown, registry: Registry): T;
|
|
97
|
+
/**
|
|
98
|
+
* The ids of the game's definitions a save of it names (of what `save` gave, or its value): what a save is checked
|
|
99
|
+
* for before a world is made of it, so that one naming what the game no longer has is refused all at once, saying
|
|
100
|
+
* what (`SaveMissing`)
|
|
101
|
+
*
|
|
102
|
+
* @beta
|
|
103
|
+
*/
|
|
104
|
+
refs?(saved: unknown): SavedRefs;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The ids of the game's definitions a component's saved value names, by kind (`Component.refs`)
|
|
108
|
+
*
|
|
109
|
+
* @beta
|
|
110
|
+
*/
|
|
111
|
+
export interface SavedRefs {
|
|
112
|
+
units?: readonly string[];
|
|
113
|
+
abilities?: readonly string[];
|
|
114
|
+
buffs?: readonly string[];
|
|
115
|
+
items?: readonly string[];
|
|
116
|
+
upgrades?: readonly string[];
|
|
117
|
+
}
|
|
118
|
+
/** @beta */
|
|
119
|
+
export type Audience = 'owner' | 'allies' | 'everyone';
|
|
120
|
+
/**
|
|
121
|
+
* A map field of a component's: as a game's own field on a map (`MapFieldDef`), its id the component's
|
|
122
|
+
*
|
|
123
|
+
* @beta
|
|
124
|
+
*/
|
|
125
|
+
export type ComponentFieldDef = Omit<MapFieldDef, 'id'>;
|
|
126
|
+
/**
|
|
127
|
+
* Who a snapshot is being made for, as a component shapes its part of it
|
|
128
|
+
*
|
|
129
|
+
* @beta
|
|
130
|
+
*/
|
|
131
|
+
export interface SnapshotView {
|
|
132
|
+
readonly world: World;
|
|
133
|
+
/** The player it is made for; `undefined` for an observer */
|
|
134
|
+
readonly player: PlayerId | undefined;
|
|
135
|
+
/** Whether the entity is the player's own */
|
|
136
|
+
readonly own: boolean;
|
|
137
|
+
/** Whether the entity's owner is the player, or an ally of theirs (an observer is everyone's) */
|
|
138
|
+
readonly ally: boolean;
|
|
139
|
+
readonly observer: boolean;
|
|
140
|
+
/** Whether the player's team can see another entity right now (`SessionView.knows`): what else of it the part may name */
|
|
141
|
+
readonly knows: (entity: Entity) => boolean;
|
|
142
|
+
/** Whether an owner is the player or an ally of theirs (`SessionView.isAlly`) */
|
|
143
|
+
readonly isAlly: (owner: PlayerId) => boolean;
|
|
144
|
+
/** Whether the player's team sees a spot of the map right now (`SessionView.sees`) */
|
|
145
|
+
readonly sees: (x: number, z: number) => boolean;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* What `defineComponent` takes: everything of a component but its id
|
|
149
|
+
*
|
|
150
|
+
* @beta
|
|
151
|
+
*/
|
|
152
|
+
export type ComponentOptions<T, S = T> = Omit<Component<T, S>, 'id' | 'slot'>;
|
|
153
|
+
/**
|
|
154
|
+
* A typed key for state of a game's own: `const wave = defineComponent<WaveState>('td.waves', { default: () => ... })`.
|
|
155
|
+
* Give it a prefix of the game's or the mod's: the engine's own are `core.`. A game lists its own
|
|
156
|
+
* (`GameModule.components`), and its world finds them by id in its registry: another game of the process may have one
|
|
157
|
+
* of the same id, and a module loaded again (as a dev server does) defines it again.
|
|
158
|
+
*
|
|
159
|
+
* With `snapshot` and `same` the component shapes what players are sent of it and how a change is found; with `index`
|
|
160
|
+
* it is filed for systems to go through; with `field` the map editor sets it
|
|
161
|
+
*
|
|
162
|
+
* @beta
|
|
163
|
+
*/
|
|
164
|
+
export declare function defineComponent<T, S = T>(id: string, options?: ComponentOptions<T, S>): Component<T, S>;
|
|
165
|
+
/**
|
|
166
|
+
* What a snapshot carries of a component, typed: `snapshotOf(entity.state, shopStock)` on a screen, or in a computer
|
|
167
|
+
* player's view. `undefined` when the player was not told it
|
|
168
|
+
*
|
|
169
|
+
* @beta
|
|
170
|
+
*/
|
|
171
|
+
export declare function snapshotOf<T, S>(state: {
|
|
172
|
+
components?: Record<string, unknown>;
|
|
173
|
+
}, component: Component<T, S>): S | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* State kept by component, for the world or a player. Asking for one that is not there yet makes it from the
|
|
176
|
+
* component's default
|
|
177
|
+
*/
|
|
178
|
+
export declare class StateStore {
|
|
179
|
+
/** By component id. Plain data, for a save */
|
|
180
|
+
readonly values: Record<string, unknown>;
|
|
181
|
+
get<T>(key: Component<T, unknown>): T;
|
|
182
|
+
set<T>(key: Component<T, unknown>, value: T): void;
|
|
183
|
+
has(key: Component<unknown, unknown>): boolean;
|
|
184
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PlayerId } from './entity';
|
|
2
|
+
import type { World } from './world';
|
|
3
|
+
import type { AiOptions } from './ai/options';
|
|
4
|
+
import type { Brain, BrainDef } from './ai/brain';
|
|
5
|
+
import type { ComputerPlayer, ComputerSystem } from './ai/computer';
|
|
6
|
+
/**
|
|
7
|
+
* How a brain is seated at a player (`BrainDef.seat`): the system the seat is, a computer thinking in it. What
|
|
8
|
+
* `defineBrain` and `defineComputer` give a brain, so that the core seats it without knowing how
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export type BrainSeat = (world: World, player: PlayerId, options: AiOptions) => ComputerSystem;
|
|
13
|
+
/**
|
|
14
|
+
* What a seat is asked for (`world.computers.seat(player, request)`): the brain (one of the game's, `defineBrain`, or
|
|
15
|
+
* its id; the first the game lists when left out) and what it is seated with (`AiOptions`)
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface SeatRequest extends AiOptions {
|
|
20
|
+
/** The brain, or its id (one the game lists in `GameModule.brains`): the first the game lists when left out */
|
|
21
|
+
brain?: BrainDef | string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A seat as a save keeps it (`core.computers`): the brain by id, and the data part of its options
|
|
25
|
+
*
|
|
26
|
+
* @beta
|
|
27
|
+
*/
|
|
28
|
+
export interface ComputerSeat {
|
|
29
|
+
/** The brain's id. Left out for the first brain the game lists */
|
|
30
|
+
brain?: string;
|
|
31
|
+
/** What it was seated with, the data of it (`AiOptions`) */
|
|
32
|
+
options: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Who the computer plays, by player, with what they were seated with: in the world, so that a save keeps it and a
|
|
36
|
+
* loaded game seats them again by itself (`world.computers`)
|
|
37
|
+
*/
|
|
38
|
+
export declare const computerSeats: import("./components").Component<Record<string, ComputerSeat>, Record<string, ComputerSeat>>;
|
|
39
|
+
/**
|
|
40
|
+
* What every seat of the world is given where its request says nothing (`world.computers.defaults`): data only, kept in
|
|
41
|
+
* the world so a save has it, and a computer seated after a load gets it too
|
|
42
|
+
*/
|
|
43
|
+
export declare const computerDefaults: import("./components").Component<Record<string, unknown>, Record<string, unknown>>;
|
|
44
|
+
/**
|
|
45
|
+
* The computer players of a world: who is seated, kept in the world and in a save (`core.computers`), so that a game
|
|
46
|
+
* loaded from a save has them back without the game's doing, and how the game reaches a seated brain while it plays
|
|
47
|
+
* (`tell`, `pause`, `get`)
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
export declare class Computers {
|
|
52
|
+
private readonly world;
|
|
53
|
+
/** The seats, by player, in the order they were taken */
|
|
54
|
+
private readonly seats;
|
|
55
|
+
constructor(world: World);
|
|
56
|
+
/**
|
|
57
|
+
* Seats the computer at a player, and remembers it: a game loaded from a save of this one has it back, with its memory
|
|
58
|
+
* (`restore`). `request.brain` is one of the game's (`defineBrain`; one listed in `GameModule.brains` is found again by
|
|
59
|
+
* its id for a load, one that is not is kept by id only, and a load without it warns and leaves the seat empty), or
|
|
60
|
+
* its id, or left out for the first brain the game lists. Of the rest of the request (`AiOptions`), the data is kept
|
|
61
|
+
* (numbers, lists, names); a function given in it is dropped from the save, said in the log, and a load has what the
|
|
62
|
+
* brain's definition gives: a game that wants its function back after a load puts it in the brain it lists in
|
|
63
|
+
* `GameModule.brains`. A player seated already is unseated first. What thinks in it is a `Brain` unless the brain was
|
|
64
|
+
* made otherwise (`defineComputer`: say which)
|
|
65
|
+
*/
|
|
66
|
+
seat<C extends ComputerPlayer = Brain>(player: PlayerId, request?: SeatRequest): ComputerSystem<C>;
|
|
67
|
+
/**
|
|
68
|
+
* What every computer seated from now on is given where its request says nothing (`AiOptions`, data only: a
|
|
69
|
+
* difficulty, a personality), over what the map says of the player (`MapPlayer.data.ai`): a campaign's difficulty,
|
|
70
|
+
* set before a mission seats its computers. Kept in the world, so a save has it. Those seated already keep what they
|
|
71
|
+
* were seated with
|
|
72
|
+
*/
|
|
73
|
+
get defaults(): Readonly<Pick<AiOptions, 'difficulty' | 'personality'>>;
|
|
74
|
+
set defaults(defaults: Pick<AiOptions, 'difficulty' | 'personality'>);
|
|
75
|
+
/** Takes the computer out of a player's seat, and out of what a save remembers. False where none was seated */
|
|
76
|
+
unseat(player: PlayerId): boolean;
|
|
77
|
+
/** The seat the computer plays a player from, while it does */
|
|
78
|
+
get(player: PlayerId): ComputerSystem | undefined;
|
|
79
|
+
/** The players the computer plays, in the order they were seated */
|
|
80
|
+
list(): PlayerId[];
|
|
81
|
+
/**
|
|
82
|
+
* Tells a computer player a word, with data to go with it: what a mission's script says to its brain
|
|
83
|
+
* (`world.computers.tell(ENEMY, 'raid', { at })`), taken by a rule of the brain's (`when.told`). False where nobody is
|
|
84
|
+
* seated there, or what is seated takes no words
|
|
85
|
+
*/
|
|
86
|
+
tell(player: PlayerId, word: string, data?: unknown): boolean;
|
|
87
|
+
/** Has a computer player sit still until `resume`: kept in a save. False where none is seated, or it cannot be paused */
|
|
88
|
+
pause(player: PlayerId): boolean;
|
|
89
|
+
/** Has a paused computer player think again */
|
|
90
|
+
resume(player: PlayerId): boolean;
|
|
91
|
+
private setPaused;
|
|
92
|
+
/** The system a player's seat is: the brain's own seat (`BrainDef.seat`), the first brain the game lists where none is named. Throws for a game that lists none */
|
|
93
|
+
private seated;
|
|
94
|
+
/**
|
|
95
|
+
* The brain a player is seated with where the seat names none, by id: the map's for the player (`MapAi.brain`, where
|
|
96
|
+
* the map gives the player to the computer), else its race's (`GameAi.races[race].brain`), else the game's defaults'
|
|
97
|
+
* (`GameAi.defaults.brain`). Nothing where none says: the game's first brain
|
|
98
|
+
*/
|
|
99
|
+
private brainFor;
|
|
100
|
+
/** A brain by id: one the game lists (`GameModule.brains`) */
|
|
101
|
+
brain(id: string): BrainDef | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Seats again the computers a save remembers, in a world loaded from it: what `loadWorld` does before the game's
|
|
104
|
+
* `afterLoad`. One the game seated already is left as it is; one whose brain is not to be found (seated by an object
|
|
105
|
+
* the game does not list) is left empty, and the log says so
|
|
106
|
+
*/
|
|
107
|
+
restore(): void;
|
|
108
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Entity } from './entity';
|
|
2
|
+
import type { GamePack } from './packs/pack';
|
|
3
|
+
import type { World } from './world';
|
|
4
|
+
/**
|
|
5
|
+
* Hiding places painted on a map, as a layer of cells (`CellLayerDef`): tall grass, a forest's edge. Who stands in one
|
|
6
|
+
* is seen by another team only from inside the same patch of it (the cells of the layer that touch, sides or corners),
|
|
7
|
+
* or from close by (`reach`). An attacker in one is seen by whom it hits for a moment, as anyone is (`expose`), and
|
|
8
|
+
* what detects the invisible (`entity.detected`) sees it too. A game turns it on, on as many layers as it likes:
|
|
9
|
+
*
|
|
10
|
+
* export const rules = { ...myGame, packs: [withConcealment({ layer: 'bush' })] }
|
|
11
|
+
*
|
|
12
|
+
* Everything that asks what a team sees (`world.isVisibleTo`) goes by it: what units pick to attack, the commands a
|
|
13
|
+
* player may give, the fog's memory, and each player's snapshots, so the computer player and the players over a wire
|
|
14
|
+
* see what the rules let them. Nothing is saved: it is worked out from the layer and where everyone stands
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
export interface ConcealmentOptions {
|
|
19
|
+
/** The layer of cells that hides (`Terrain.cells`): any cell of it with a value other than 0 */
|
|
20
|
+
layer: string;
|
|
21
|
+
/** How near, in cells, someone of another team has to be to see into it from outside: 2 when left out */
|
|
22
|
+
reach?: number;
|
|
23
|
+
/**
|
|
24
|
+
* What it hides: units on the ground, of anyone, when left out (not structures, not what flies). A game's own, to hide
|
|
25
|
+
* heroes only or let some types never hide
|
|
26
|
+
*/
|
|
27
|
+
hides?: (world: World, entity: Entity) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a team sees a hidden entity anyway, after what the patch and `reach` make of it: a ward, a scout's ability.
|
|
30
|
+
* Asked only of what would otherwise be hidden
|
|
31
|
+
*/
|
|
32
|
+
seenBy?: (world: World, entity: Entity, team: number) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether one hidden in it gives itself away by moving, as the brush of a hero arena game shakes: the teams that do not see it are
|
|
35
|
+
* told where it moves in it and steps into it (a `rustle` event, where they see the ground; not who), and their
|
|
36
|
+
* screens shake the bushes there. `true` for every team, a function to say for each (`team`), no when left out:
|
|
37
|
+
* a hidden unit shakes nothing on the screens of those who do not see it
|
|
38
|
+
*/
|
|
39
|
+
rustle?: boolean | ((world: World, entity: Entity, team: number) => boolean);
|
|
40
|
+
/** How often one moving in it is told again, in seconds: 0.3 when left out. Stepping in is told at once */
|
|
41
|
+
rustleEvery?: number;
|
|
42
|
+
/** The id of its hook and its system, to replace or leave out: `concealment:<layer>` when left out */
|
|
43
|
+
id?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The patch of a layer an entity stands in, 1 and up, or 0 where it stands in none (`ConcealmentOptions`). For a
|
|
47
|
+
* game's rules and screen: who is in the grass
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
export declare function patchAt(world: World, layer: string, x: number, z: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* A game where what stands in a layer of cells is hidden from the teams that are not in it with them (see
|
|
54
|
+
* `ConcealmentOptions`): a `visible` hook, and a system that works out who has someone in which patch at the start of
|
|
55
|
+
* every tick (the same in every copy of the game, whoever asks what in between). On as many layers as it is given
|
|
56
|
+
*
|
|
57
|
+
* @beta
|
|
58
|
+
*/
|
|
59
|
+
export declare function withConcealment(options: ConcealmentOptions): GamePack;
|
|
60
|
+
/** One hidden moving in a layer: where the player sees the ground, to whom the rules tell it, a shake of the bushes */
|
|
61
|
+
export declare const toldRustle: import("./replication").ReplicatedEvent;
|