@v12-engine/engine 0.0.0-stage → 0.1.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/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,464 @@
|
|
|
1
|
+
import type { AdvanceState, AlongPath, AttackGroundState, AttackState, FollowState, HoldState, PatrolState } from './orders/basic';
|
|
2
|
+
import type { GameFileDef } from './gameFiles';
|
|
3
|
+
import type { ReplicatedEvent, SnapshotPart } from './replication';
|
|
4
|
+
import { type DataDefs, type DataKind } from './gameData';
|
|
5
|
+
import { Definitions } from './definitions';
|
|
6
|
+
import type { BuildState, RepairState, WorkState } from './orders/build';
|
|
7
|
+
import type { CastState } from './orders/cast';
|
|
8
|
+
import type { HarvestState } from './orders/harvest';
|
|
9
|
+
import type { ItemOrderState } from './orders/items';
|
|
10
|
+
import type { BoardState, LoadState, UnloadState } from './transport';
|
|
11
|
+
import type { RaceDef } from './races';
|
|
12
|
+
import type { Logger } from './log';
|
|
13
|
+
import type { Component } from './components';
|
|
14
|
+
import { type EventKey } from './events';
|
|
15
|
+
import type { EffectHandler, EffectKind } from './abilities/effects';
|
|
16
|
+
import type { CommandDef } from './commands';
|
|
17
|
+
import { type AbilityDef, type BuffDef, type DayCycle, type ItemDef, type ResourceDef, type ResourceKind, type StatDef, type Stats, type UnitTypeDef, type UpgradeDef, type UpkeepTier } from './defs';
|
|
18
|
+
import type { Entity, EntityId, Order, PlayerId } from './entity';
|
|
19
|
+
import type { Vec2 } from './math';
|
|
20
|
+
import type { StatPart } from './stats';
|
|
21
|
+
import type { FormationDef } from './formation';
|
|
22
|
+
import type { AssembledGame, GameModule } from './game';
|
|
23
|
+
import { type GameRules } from './rules';
|
|
24
|
+
import type { TileDef } from './tiles';
|
|
25
|
+
import type { PrefabDef } from './prefabs';
|
|
26
|
+
import type { TunableDef } from './tunables';
|
|
27
|
+
import type { World } from './world';
|
|
28
|
+
import type { CellLayerDef } from './cellLayers';
|
|
29
|
+
import type { ResolvedScore } from './score';
|
|
30
|
+
/** @beta */
|
|
31
|
+
export type OrderStatus = 'running' | 'done' | 'failed';
|
|
32
|
+
/**
|
|
33
|
+
* What an order can be given, every order's field in one: for what reads an order of any type (the queue, a save, a
|
|
34
|
+
* screen's waypoints). An order of a type is given its own of them (`OrderInits`)
|
|
35
|
+
*
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
export interface OrderParams {
|
|
39
|
+
target?: EntityId;
|
|
40
|
+
point?: Vec2;
|
|
41
|
+
/** Type to build, for build orders */
|
|
42
|
+
unitType?: string;
|
|
43
|
+
/** Ability to use, for cast orders */
|
|
44
|
+
ability?: string;
|
|
45
|
+
/** An item: the one to use, drop or hand over by its place in the inventory, or the one on the ground to pick up */
|
|
46
|
+
item?: number;
|
|
47
|
+
/** Direction to face at the end. Commands fill this in with the direction of travel */
|
|
48
|
+
facing?: number;
|
|
49
|
+
/**
|
|
50
|
+
* For a move: the group goes at the pace of its slowest (campaign plan GP1), so that it arrives together. The
|
|
51
|
+
* command works the pace out (`speedCap`)
|
|
52
|
+
*/
|
|
53
|
+
together?: boolean;
|
|
54
|
+
/** For a move: the fastest it goes, set by the command for a group that goes `together`: the slowest one's speed */
|
|
55
|
+
speedCap?: number;
|
|
56
|
+
/** A path of the map, by its name (`MapPath`): for the orders that go along one (`followPath`, `attackPath`) */
|
|
57
|
+
path?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Which way along `path`: to its first point or its last. Away from the end the unit is nearer to when left out: a
|
|
60
|
+
* minion back on its lane after a chase, past its middle, goes on the way it was going
|
|
61
|
+
*/
|
|
62
|
+
towards?: 'first' | 'last';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* What each order type is given (`Order.init`), by type (design review E14): the engine's, and a game's own added by
|
|
66
|
+
* declaration merging, as `OrderStates` is:
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* declare module '@v12-engine/engine' {
|
|
70
|
+
* interface OrderInits {
|
|
71
|
+
* 'mygame.dig': { point?: Vec2 }
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* Every field may be missing from what a command sends, which comes from a player: the behaviour's `accepts` checks
|
|
77
|
+
* what it needs
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export interface OrderInits {
|
|
82
|
+
move: Pick<OrderParams, 'point' | 'facing' | 'target' | 'together' | 'speedCap'>;
|
|
83
|
+
hold: Pick<OrderParams, 'facing'>;
|
|
84
|
+
attack: Pick<OrderParams, 'target' | 'facing'>;
|
|
85
|
+
attackMove: Pick<OrderParams, 'point' | 'facing'>;
|
|
86
|
+
followPath: Pick<OrderParams, 'path' | 'towards'>;
|
|
87
|
+
attackPath: Pick<OrderParams, 'path' | 'towards'>;
|
|
88
|
+
patrolPath: Pick<OrderParams, 'path' | 'towards'>;
|
|
89
|
+
patrol: Pick<OrderParams, 'point' | 'facing'>;
|
|
90
|
+
follow: Pick<OrderParams, 'target'>;
|
|
91
|
+
attackGround: Pick<OrderParams, 'point' | 'target'>;
|
|
92
|
+
cast: Pick<OrderParams, 'ability' | 'item' | 'target' | 'point'>;
|
|
93
|
+
harvest: Pick<OrderParams, 'target'>;
|
|
94
|
+
return: Pick<OrderParams, 'target'>;
|
|
95
|
+
build: Pick<OrderParams, 'unitType' | 'point' | 'facing'>;
|
|
96
|
+
construct: Pick<OrderParams, 'target'>;
|
|
97
|
+
repair: Pick<OrderParams, 'target'>;
|
|
98
|
+
pickUp: Pick<OrderParams, 'target' | 'item'>;
|
|
99
|
+
dropItem: Pick<OrderParams, 'item' | 'point' | 'target'>;
|
|
100
|
+
board: Pick<OrderParams, 'target'>;
|
|
101
|
+
load: Pick<OrderParams, 'target'>;
|
|
102
|
+
unload: Pick<OrderParams, 'point'>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* What an order of a type is given: its `OrderInits` entry, every order's fields (`OrderParams`) for a type not in it
|
|
106
|
+
*
|
|
107
|
+
* @beta
|
|
108
|
+
*/
|
|
109
|
+
export type OrderInitOf<Type extends string> = Type extends keyof OrderInits ? OrderInits[Type] : OrderParams;
|
|
110
|
+
/**
|
|
111
|
+
* What a command asks a unit to do: the order's type and what it is given (`OrderInitOf`). Turned into an `Order` once
|
|
112
|
+
* it is accepted
|
|
113
|
+
*
|
|
114
|
+
* @beta
|
|
115
|
+
*/
|
|
116
|
+
export type OrderInit<Type extends string = string> = {
|
|
117
|
+
type: Type;
|
|
118
|
+
/**
|
|
119
|
+
* The formation units ordered to a point together take, by id (`FormationDef`): the engine's `rows`, `circle`,
|
|
120
|
+
* `square` or `none`, or a game's own. What the rules say (`GameRules.movement.formation`: `rows`) when left out
|
|
121
|
+
*/
|
|
122
|
+
formation?: string;
|
|
123
|
+
} & OrderInitOf<Type>;
|
|
124
|
+
/**
|
|
125
|
+
* Logic behind an order type. Orders are the only way units act, which is what
|
|
126
|
+
* makes queueing work for everything. Game modules can register their own.
|
|
127
|
+
*
|
|
128
|
+
* `State` is what it keeps in the order (`Order.state`), every field optional: the order starts with none of them.
|
|
129
|
+
* `OrderStates` names each order type's, for `registry.order(type)` to hand back the behaviour typed
|
|
130
|
+
*
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
export interface OrderBehavior<State extends object = Record<string, any>, Init extends object = OrderParams> {
|
|
134
|
+
type: string;
|
|
135
|
+
/** Units ordered to a point together are spread out in a formation instead of all walking to the same spot */
|
|
136
|
+
formation?: boolean;
|
|
137
|
+
/** Whether the entity is able to carry out this order at all */
|
|
138
|
+
accepts(world: World, entity: Entity, init: Init): boolean;
|
|
139
|
+
/** Called once when the order reaches the front of the queue */
|
|
140
|
+
start?(world: World, entity: Entity, order: Order<State, Init>): void;
|
|
141
|
+
update(world: World, entity: Entity, order: Order<State, Init>, dt: number): OrderStatus;
|
|
142
|
+
/** Called when the order finishes or is interrupted, to undo anything it left behind */
|
|
143
|
+
end?(world: World, entity: Entity, order: Order<State, Init>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Whether the unit is in the middle of it and cannot be called away (a cast past turning back): what was to come
|
|
146
|
+
* after is dropped, it is finished first (`interrupt`). Never, when left out
|
|
147
|
+
*/
|
|
148
|
+
committed?(order: Order<State, Init>): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Whether the unit stands waiting by a fight for a spot in it (an attack-move held up): an ally on its way may ask it
|
|
151
|
+
* aside (`rules.movement.makesWay`). Never, when left out
|
|
152
|
+
*/
|
|
153
|
+
waiting?(order: Order<State, Init>): boolean;
|
|
154
|
+
/** Whether the unit keeps something up that being stunned breaks off (a channelled ability). Never, when left out */
|
|
155
|
+
channelling?(order: Order<State, Init>): boolean;
|
|
156
|
+
/** Whether the unit has begun what it builds (its site is down): what it builds is counted as itself. Never, when left out */
|
|
157
|
+
building?(order: Order<State, Init>): boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A fact the engine asks of an order, its behaviour's to say (`OrderBehavior.committed`, `waiting`, `channelling`,
|
|
161
|
+
* `building`)
|
|
162
|
+
*
|
|
163
|
+
* @beta
|
|
164
|
+
*/
|
|
165
|
+
export type OrderFact = 'committed' | 'waiting' | 'channelling' | 'building';
|
|
166
|
+
/**
|
|
167
|
+
* What each order type keeps in its orders (`Order.state`), by type: the engine's, and a game's own added to it by
|
|
168
|
+
* declaration merging, for `registry.order(type)` to say what its behaviour keeps:
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* declare module '@v12-engine/engine' {
|
|
172
|
+
* interface OrderStates {
|
|
173
|
+
* 'mygame.dig': { dug?: number }
|
|
174
|
+
* }
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @beta
|
|
179
|
+
*/
|
|
180
|
+
export interface OrderStates {
|
|
181
|
+
move: NoState;
|
|
182
|
+
hold: HoldState;
|
|
183
|
+
attack: AttackState;
|
|
184
|
+
attackMove: AdvanceState;
|
|
185
|
+
followPath: AlongPath;
|
|
186
|
+
attackPath: AlongPath & AdvanceState;
|
|
187
|
+
patrol: PatrolState;
|
|
188
|
+
follow: FollowState;
|
|
189
|
+
attackGround: AttackGroundState;
|
|
190
|
+
cast: CastState;
|
|
191
|
+
harvest: HarvestState;
|
|
192
|
+
return: HarvestState;
|
|
193
|
+
build: BuildState;
|
|
194
|
+
construct: WorkState;
|
|
195
|
+
repair: RepairState;
|
|
196
|
+
pickUp: ItemOrderState;
|
|
197
|
+
dropItem: ItemOrderState;
|
|
198
|
+
board: BoardState;
|
|
199
|
+
load: LoadState;
|
|
200
|
+
unload: UnloadState;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* What an order that keeps nothing keeps
|
|
204
|
+
*
|
|
205
|
+
* @beta
|
|
206
|
+
*/
|
|
207
|
+
export type NoState = Record<string, never>;
|
|
208
|
+
/**
|
|
209
|
+
* What an order of a type keeps: its `OrderStates` entry, any plain data for a type not in it
|
|
210
|
+
*
|
|
211
|
+
* @beta
|
|
212
|
+
*/
|
|
213
|
+
export type OrderStateOf<Type extends string> = Type extends keyof OrderStates ? OrderStates[Type] : Record<string, any>;
|
|
214
|
+
/**
|
|
215
|
+
* The part of a tick a system runs in, see `PHASES` in the scheduler
|
|
216
|
+
*
|
|
217
|
+
* @beta
|
|
218
|
+
*/
|
|
219
|
+
export type SystemPhase = 'commands' | 'decide' | 'move' | 'resolve' | 'cleanup';
|
|
220
|
+
/**
|
|
221
|
+
* Something that runs every tick, or every few: moves units, lands attacks, works out what each team sees.
|
|
222
|
+
* When it runs is worked out once, from its phase, then from what it says it comes before and after.
|
|
223
|
+
*
|
|
224
|
+
* @beta
|
|
225
|
+
*/
|
|
226
|
+
export interface System {
|
|
227
|
+
/** Unique in a world. A game's system with the name of a core one takes its place */
|
|
228
|
+
name: string;
|
|
229
|
+
/** `cleanup` when left out: after everything else in the tick */
|
|
230
|
+
phase?: SystemPhase;
|
|
231
|
+
/** Names of systems in the same phase this one runs ahead of, or after */
|
|
232
|
+
before?: string[];
|
|
233
|
+
after?: string[];
|
|
234
|
+
/** Runs once in so many ticks, for work that does not need doing every tick. Every tick when left out */
|
|
235
|
+
every?: number;
|
|
236
|
+
/** With `every`, the tick in each round it runs at: systems with the same `every` and other offsets spread the work */
|
|
237
|
+
offset?: number;
|
|
238
|
+
/**
|
|
239
|
+
* `dt` is the time since it last ran: the length of a tick, times `every`. Before `each`, for a system that has
|
|
240
|
+
* both. One of the two is needed
|
|
241
|
+
*/
|
|
242
|
+
update?(world: World, dt: number): void;
|
|
243
|
+
/**
|
|
244
|
+
* What `each` is run for (OB5): every actor (`'actors'`, when left out), what has a component, in the order of its
|
|
245
|
+
* id as a walk through the actors would meet it (`EntityIndex.ordered`: a system about a few, like the buildings
|
|
246
|
+
* that train, does not look at every unit and tree), or the actors a test says yes to
|
|
247
|
+
*
|
|
248
|
+
* @beta
|
|
249
|
+
*/
|
|
250
|
+
over?: SystemOver;
|
|
251
|
+
/**
|
|
252
|
+
* Run for each entity of `over`, in order, after `update`. The dead are not left out: a system that wants only the
|
|
253
|
+
* living says so
|
|
254
|
+
*
|
|
255
|
+
* @beta
|
|
256
|
+
*/
|
|
257
|
+
each?(world: World, entity: Entity, dt: number): void;
|
|
258
|
+
/**
|
|
259
|
+
* What it keeps in itself, for a save: plain data. For state that is easier kept in a system than in a component
|
|
260
|
+
* (`World.state`): a computer player's plans, a director's mood
|
|
261
|
+
*/
|
|
262
|
+
save?(world: World): unknown;
|
|
263
|
+
/** Takes back what `save` gave, in a world loaded from a save: when it is made, or added again (`addSystem`) */
|
|
264
|
+
restore?(world: World, data: unknown): void;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* What a system runs `each` for (`System.over`): every actor, what has a component, or the actors a test says yes to
|
|
268
|
+
*
|
|
269
|
+
* @beta
|
|
270
|
+
*/
|
|
271
|
+
export type SystemOver = 'actors' | Component<unknown, unknown> | ((entity: Entity, world: World) => boolean);
|
|
272
|
+
/**
|
|
273
|
+
* A system, or what makes one for each world: for a system that keeps state of its own, which belongs to one game
|
|
274
|
+
*
|
|
275
|
+
* @beta
|
|
276
|
+
*/
|
|
277
|
+
export type SystemDef = System | ((world: World) => System);
|
|
278
|
+
/**
|
|
279
|
+
* What is thrown for a component or an event of its own that a game uses without listing it (`GameModule.components`,
|
|
280
|
+
* `GameModule.events`): no world finds it by its id, so a save, a snapshot or the index would lose it
|
|
281
|
+
*
|
|
282
|
+
* @beta
|
|
283
|
+
*/
|
|
284
|
+
export declare class UnlistedError extends Error {
|
|
285
|
+
/** What it is: a component or an event */
|
|
286
|
+
readonly kind: 'component' | 'event';
|
|
287
|
+
/** Its id */
|
|
288
|
+
readonly id: string;
|
|
289
|
+
/** The id of the game that used it */
|
|
290
|
+
readonly game: string;
|
|
291
|
+
constructor(
|
|
292
|
+
/** What it is: a component or an event */
|
|
293
|
+
kind: 'component' | 'event',
|
|
294
|
+
/** Its id */
|
|
295
|
+
id: string,
|
|
296
|
+
/** The id of the game that used it */
|
|
297
|
+
game: string);
|
|
298
|
+
}
|
|
299
|
+
/** @beta */
|
|
300
|
+
export declare class Registry {
|
|
301
|
+
/** The game's unit types, buildings and resources (`GameModule.units`) */
|
|
302
|
+
readonly units: Definitions<UnitTypeDef>;
|
|
303
|
+
/** The orders units can be given, the engine's and the game's, by type */
|
|
304
|
+
readonly orders: Definitions<OrderBehavior<Record<string, any>, OrderParams>>;
|
|
305
|
+
/** How groups line up (`GameModule.formations`) */
|
|
306
|
+
readonly formations: Definitions<FormationDef>;
|
|
307
|
+
/** The game's research (`GameModule.upgrades`) */
|
|
308
|
+
readonly upgrades: Definitions<UpgradeDef>;
|
|
309
|
+
/** Every ability there is, of units, heroes and items alike (`GameModule.abilities`) */
|
|
310
|
+
readonly abilities: Definitions<AbilityDef>;
|
|
311
|
+
/** The game's buffs (`GameModule.buffs`) */
|
|
312
|
+
readonly buffs: Definitions<BuffDef>;
|
|
313
|
+
/** The game's items (`GameModule.items`) */
|
|
314
|
+
readonly items: Definitions<ItemDef>;
|
|
315
|
+
/** The game's races, in its order (`GameModule.races`): none in a game without */
|
|
316
|
+
readonly races: Definitions<RaceDef>;
|
|
317
|
+
/** The game's prefabs (`GameModule.prefabs`) */
|
|
318
|
+
readonly prefabs: Definitions<PrefabDef>;
|
|
319
|
+
/** The commands a world takes, the engine's and the game's, by type */
|
|
320
|
+
readonly commands: Definitions<CommandDef<import("./fields").Fields>>;
|
|
321
|
+
/** What each type of an ability's effect does, by type */
|
|
322
|
+
readonly effects: Definitions<EffectKind<keyof import("./defs").EffectTypes>>;
|
|
323
|
+
/**
|
|
324
|
+
* The kinds of definition a game's data is kept for (`DataKind`), each its collection: what the Data panel, mods,
|
|
325
|
+
* saves and a game's reload walk, one loop each
|
|
326
|
+
*/
|
|
327
|
+
readonly kinds: {
|
|
328
|
+
readonly [K in DataKind]: Definitions<DataDefs[K]>;
|
|
329
|
+
};
|
|
330
|
+
/** The components the game lists (`GameModule.components`), and those its app keeps in its worlds, by id */
|
|
331
|
+
private readonly components;
|
|
332
|
+
/** The engine's own components (`coreComponents`) and the listed, by id: what `component` finds, in one look */
|
|
333
|
+
private readonly known;
|
|
334
|
+
/** The events of its own the game lists (`GameModule.events`), by id */
|
|
335
|
+
private readonly events;
|
|
336
|
+
/** Takes in the components and events a game lists. Throws for an id that is there twice, another way */
|
|
337
|
+
defineParts(components: readonly Component<unknown>[], events: readonly EventKey<unknown>[]): void;
|
|
338
|
+
/** A component of this game by its id: one the game lists, or one of the engine's own (`coreComponents`). None for any other */
|
|
339
|
+
component(id: string): Component<unknown> | undefined;
|
|
340
|
+
/** A component of this game by its id, as something of the world uses it: throws for one the game does not list (`UnlistedError`) */
|
|
341
|
+
used(id: string): Component<unknown>;
|
|
342
|
+
/**
|
|
343
|
+
* An event of the game's own by its id: listed, or the engine's (`core.`). One of a game's that it does not list
|
|
344
|
+
* throws (`UnlistedError`)
|
|
345
|
+
*/
|
|
346
|
+
event(id: string): EventKey<unknown> | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* The components the game lists, for what goes through them all: the map's fields they have
|
|
349
|
+
*
|
|
350
|
+
* @beta
|
|
351
|
+
*/
|
|
352
|
+
listedComponents(): Iterable<Component<unknown, unknown>>;
|
|
353
|
+
/** Whether the game lists a component or an event, or it is one of the engine's own */
|
|
354
|
+
lists(kind: 'component' | 'event', id: string): boolean;
|
|
355
|
+
/** The log of the world this is the registry of, once there is one (`World.log`) */
|
|
356
|
+
log?: Logger;
|
|
357
|
+
/**
|
|
358
|
+
* Takes the definitions of another registry of the same game over its own (`world.reload`): its unit types,
|
|
359
|
+
* abilities, buffs, items, upgrades and races, the code of its effects and orders, its rules, and its module. Those
|
|
360
|
+
* it has that the other has not are kept (a world may have units of them). What the game is made of otherwise (its
|
|
361
|
+
* resources, stats, components, events) stays as it is: a world was made of it
|
|
362
|
+
*/
|
|
363
|
+
takeFrom(other: Registry): void;
|
|
364
|
+
/** Lowest threshold first. Empty for a game without upkeep */
|
|
365
|
+
upkeep: UpkeepTier[];
|
|
366
|
+
/** Id of the game module it was made from */
|
|
367
|
+
game: string;
|
|
368
|
+
/** The game module it was made from */
|
|
369
|
+
module: GameModule | null;
|
|
370
|
+
private hashed?;
|
|
371
|
+
/** What identifies the game exactly, mods and code included (see `gameHash`). Worked out the first time it is asked for */
|
|
372
|
+
get hash(): string;
|
|
373
|
+
private dataHashed?;
|
|
374
|
+
/**
|
|
375
|
+
* What identifies the game's data: everything but how its code reads (see `gameHash`). What a server and a player
|
|
376
|
+
* check they share: the two run builds of the same code that print it differently
|
|
377
|
+
*/
|
|
378
|
+
get dataHash(): string;
|
|
379
|
+
/** The version of what the game keeps in a save (`GameModule.saves.version`): 1 for a game that says none */
|
|
380
|
+
get saveVersion(): number;
|
|
381
|
+
/** The game's own stats, next to the engine's (`GameModule.stats`) */
|
|
382
|
+
stats: StatDef[];
|
|
383
|
+
/** The game put together with its packs (`assembleGame`): set as the registry is made of it */
|
|
384
|
+
assembly: AssembledGame | null;
|
|
385
|
+
/** The engine's parts and the game's that give an entity something as it is made (`Component.onSpawn`), in order */
|
|
386
|
+
spawning: readonly Component<unknown, unknown>[];
|
|
387
|
+
/** The engine's parts and the game's that call something off as an entity leaves its owner (`Component.onLeave`) */
|
|
388
|
+
leaving: readonly Component<unknown, unknown>[];
|
|
389
|
+
/** The engine's parts and the game's that may have a structure stand open, in nobody's way (`Component.passable`) */
|
|
390
|
+
passing: readonly Component<unknown, unknown>[];
|
|
391
|
+
/** Whether a structure stands open now, in nobody's way, by its parts (`Component.passable`): a gate opened */
|
|
392
|
+
standsOpen(entity: Entity): boolean;
|
|
393
|
+
/** What the game's packs add to a unit's stats (`GamePack.stats`): a hero's growth */
|
|
394
|
+
statParts: StatPart[];
|
|
395
|
+
/** How each event of the world is told to a player, the engine's then the packs' (`replicateEvent`), in order */
|
|
396
|
+
replications: readonly ReplicatedEvent[];
|
|
397
|
+
/** The parts of a player's snapshot, the engine's then the packs' (`SnapshotPart`), in order */
|
|
398
|
+
snapshotParts: readonly SnapshotPart[];
|
|
399
|
+
/** What the game counts of its players (`GameRules.score`), its stats made: null for a game that counts nothing */
|
|
400
|
+
score: ResolvedScore | null;
|
|
401
|
+
/** What each of the game's own files was read as (`GameModule.files`), by id */
|
|
402
|
+
private files;
|
|
403
|
+
/** The game's own files (`GameModule.files`), by id */
|
|
404
|
+
private fileDefs;
|
|
405
|
+
/** What the rules read of a file of the game's own data (`GameModule.files`): throws for one the game does not list */
|
|
406
|
+
file<T>(def: GameFileDef<T>): T;
|
|
407
|
+
/** Puts what a file of the game's is read as, for this registry's world alone: the editor's panel, as it is edited */
|
|
408
|
+
setFile<T>(def: GameFileDef<T>, value: T): void;
|
|
409
|
+
/** A file of the game's own data by its id (`waves.json`): what reads it, for an editor that writes it. None for one the game does not list */
|
|
410
|
+
fileDef(id: string): GameFileDef<unknown> | undefined;
|
|
411
|
+
/** A prefab of the game's by id, for `world.spawnPrefab`; throws for one there is not */
|
|
412
|
+
prefab(id: string): PrefabDef;
|
|
413
|
+
/** What the ground can be painted with, in the order of their indices: the first is 1 (`GameModule.tiles`) */
|
|
414
|
+
tiles: TileDef[];
|
|
415
|
+
/** The game's layers of cells (`GameModule.cellLayers`): what `Terrain.cells` is keyed by, with what each means */
|
|
416
|
+
cellLayers: CellLayerDef[];
|
|
417
|
+
/** The numbers of the rules to be tuned while the game plays (`GameModule.tunables`) */
|
|
418
|
+
tunables: TunableDef[];
|
|
419
|
+
/** A tunable by id, or nothing for one the game does not have */
|
|
420
|
+
tunable(id: string): TunableDef | undefined;
|
|
421
|
+
/** The index of a tile of the game, for painting the ground in code: `terrain.tiles[cell] = registry.tile('road')` */
|
|
422
|
+
tile(id: string): number;
|
|
423
|
+
/** The ids of the game's tiles, in the order of their indices */
|
|
424
|
+
get tileIds(): string[];
|
|
425
|
+
/** Every stat there is in the game, the engine's first */
|
|
426
|
+
statKeys: string[];
|
|
427
|
+
/** Every stat of the game at 0, its own at their default: what base stats start from */
|
|
428
|
+
statDefaults: Readonly<Stats>;
|
|
429
|
+
/** The game's numbers that are not about any one unit (`GameModule.rules`) */
|
|
430
|
+
rules: Readonly<GameRules>;
|
|
431
|
+
/** Null for a game where it is always day */
|
|
432
|
+
day: DayCycle | null;
|
|
433
|
+
/** What the game tells each player about itself, see `GameModule.report`. Asked by the session that runs the world */
|
|
434
|
+
report: ((world: World, player: PlayerId) => Record<string, unknown>) | null;
|
|
435
|
+
/** The resources of the game, in the order players are shown them */
|
|
436
|
+
resources: ResourceDef[];
|
|
437
|
+
/**
|
|
438
|
+
* The resource prices, bounties, revives and sales are in: the game's money. Null for a game without one,
|
|
439
|
+
* where there is nothing of that kind to pay with
|
|
440
|
+
*/
|
|
441
|
+
currency: ResourceKind | null;
|
|
442
|
+
/** The command type, or undefined for one the game does not have: commands come from outside, and may name anything */
|
|
443
|
+
command(type: string): CommandDef | undefined;
|
|
444
|
+
/** The definition of a resource, or undefined for one the game does not have */
|
|
445
|
+
resource(id: ResourceKind): ResourceDef | undefined;
|
|
446
|
+
/** A unit type by id: throws for one the game does not have (`units`) */
|
|
447
|
+
unit(id: string): UnitTypeDef;
|
|
448
|
+
/** An upgrade by id: throws for one the game does not have (`upgrades`) */
|
|
449
|
+
upgrade(id: string): UpgradeDef;
|
|
450
|
+
/** A race by id: throws for one the game does not have (`races`) */
|
|
451
|
+
race(id: string): RaceDef;
|
|
452
|
+
/** An ability by id: throws for one the game does not have (`abilities`) */
|
|
453
|
+
ability(id: string): AbilityDef;
|
|
454
|
+
/** A buff by id: throws for one the game does not have (`buffs`) */
|
|
455
|
+
buff(id: string): BuffDef;
|
|
456
|
+
/** An item by id: throws for one the game does not have (`items`) */
|
|
457
|
+
item(id: string): ItemDef;
|
|
458
|
+
/** What an effect type does: throws for one there is not (`effects`) */
|
|
459
|
+
effect(type: string): EffectHandler;
|
|
460
|
+
/** An order type's behaviour, typed by what its orders keep (`OrderStates`): throws for one there is not (`orders`) */
|
|
461
|
+
order<Type extends string>(type: Type): OrderBehavior<OrderStateOf<Type>, OrderInitOf<Type>>;
|
|
462
|
+
/** A formation by id: throws for one there is not (`formations`) */
|
|
463
|
+
formation(id: string): FormationDef;
|
|
464
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { GamePack } from './packs/pack';
|
|
2
|
+
import type { ResourceKind, UnitTypeDef } from './defs';
|
|
3
|
+
import type { Entity, PlayerId } from './entity';
|
|
4
|
+
import type { World } from './world';
|
|
5
|
+
/**
|
|
6
|
+
* What rubble or a pile is to be, as a game says it for a death: the unit type it is, and how much of its resource it
|
|
7
|
+
* holds (the type's `resource.amount` when left out)
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export interface RemainsSpec {
|
|
12
|
+
type: string;
|
|
13
|
+
amount?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What the remains of a game are made of (`withRemains`)
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export interface RemainsOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The rubble a fallen building leaves, put down where it stood once it is gone: a type (a resource with a footprint,
|
|
23
|
+
* see `rubbleType`), worked out for the death, or `null` for none. None when left out
|
|
24
|
+
*/
|
|
25
|
+
rubble?: string | ((world: World, dead: Entity) => RemainsSpec | string | null | undefined);
|
|
26
|
+
/**
|
|
27
|
+
* The pile a fallen unit drops: a type (a resource with no footprint, see `pileType`) and how much, or `null` for
|
|
28
|
+
* none. None when left out
|
|
29
|
+
*/
|
|
30
|
+
piles?: (world: World, dead: Entity, killer: Entity | undefined) => RemainsSpec | null | undefined;
|
|
31
|
+
/** How near a unit comes to a pile to pick it up, in cells: 0.8 when left out */
|
|
32
|
+
reach?: number;
|
|
33
|
+
/** Who may pick a pile up: any unit of a player's that is not a structure, when left out */
|
|
34
|
+
picksUp?: (world: World, unit: Entity, pile: Entity) => boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What a pile holds: the resource and how much. Told to everyone, for its look and its tooltip
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare const pileOf: import("./components").Component<{
|
|
42
|
+
kind: ResourceKind;
|
|
43
|
+
amount: number;
|
|
44
|
+
}, {
|
|
45
|
+
kind: ResourceKind;
|
|
46
|
+
amount: number;
|
|
47
|
+
}>;
|
|
48
|
+
/** The piles there are and the rubble to put down once the building it is of is gone, kept with the world */
|
|
49
|
+
export declare const remains: import("./components").Component<{
|
|
50
|
+
piles: number[];
|
|
51
|
+
rubble: Record<number, {
|
|
52
|
+
type: string;
|
|
53
|
+
amount?: number;
|
|
54
|
+
x: number;
|
|
55
|
+
z: number;
|
|
56
|
+
}>;
|
|
57
|
+
}, {
|
|
58
|
+
piles: number[];
|
|
59
|
+
rubble: Record<number, {
|
|
60
|
+
type: string;
|
|
61
|
+
amount?: number;
|
|
62
|
+
x: number;
|
|
63
|
+
z: number;
|
|
64
|
+
}>;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* A pile was picked up: by whom (a unit's id and its owner), what and how much
|
|
68
|
+
*
|
|
69
|
+
* @beta
|
|
70
|
+
*/
|
|
71
|
+
export declare const pileTaken: import("./events").EventKey<{
|
|
72
|
+
pile: number;
|
|
73
|
+
by: number;
|
|
74
|
+
player: PlayerId;
|
|
75
|
+
kind: ResourceKind;
|
|
76
|
+
amount: number;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* A type of rubble, to put in the game's units: a resource that blocks its footprint, gathered (cleared) as `kind`
|
|
80
|
+
* by the game's workers, with no look of its own (the game's looks give it one)
|
|
81
|
+
*
|
|
82
|
+
* @beta
|
|
83
|
+
*/
|
|
84
|
+
export declare function rubbleType(def: {
|
|
85
|
+
id: string;
|
|
86
|
+
name?: string;
|
|
87
|
+
footprint: {
|
|
88
|
+
w: number;
|
|
89
|
+
d: number;
|
|
90
|
+
};
|
|
91
|
+
kind: ResourceKind;
|
|
92
|
+
amount?: number;
|
|
93
|
+
slots?: number;
|
|
94
|
+
}): UnitTypeDef;
|
|
95
|
+
/**
|
|
96
|
+
* A type of pile, to put in the game's units: something lying on the ground that blocks nothing, is fought by nobody,
|
|
97
|
+
* and is handed (`pileOf`: its kind and how much) to who walks over it. `kind` and `amount` are what it holds when the
|
|
98
|
+
* death that drops it says nothing else
|
|
99
|
+
*
|
|
100
|
+
* @beta
|
|
101
|
+
*/
|
|
102
|
+
export declare function pileType(def: {
|
|
103
|
+
id: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
kind: ResourceKind;
|
|
106
|
+
amount?: number;
|
|
107
|
+
}): UnitTypeDef & {
|
|
108
|
+
pile: {
|
|
109
|
+
kind: ResourceKind;
|
|
110
|
+
amount: number;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Remains that are things for a game (`RemainsOptions`): rubble where buildings fell, piles where units did. The game
|
|
115
|
+
* is the same otherwise; its units list the types (`rubbleType`, `pileType`, or its own)
|
|
116
|
+
*
|
|
117
|
+
* @beta
|
|
118
|
+
*/
|
|
119
|
+
export declare function withRemains(options?: RemainsOptions): GamePack;
|