@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,76 @@
|
|
|
1
|
+
import type { GamePack } from './packs/pack';
|
|
2
|
+
import { type Entity } from './entity';
|
|
3
|
+
/**
|
|
4
|
+
* A stance: how a unit without orders takes to the enemies around it
|
|
5
|
+
*
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export interface StanceDef {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
/** The key on the command card, for the HUD's buttons (`stanceButtons` of the client) */
|
|
13
|
+
hotkey?: string;
|
|
14
|
+
/** What it attacks of its own accord: anything in its acquisition range, only what its attack reaches, or nothing */
|
|
15
|
+
acquire: 'any' | 'near' | 'none';
|
|
16
|
+
/** Whether it chases what it fights past the reach of its attack */
|
|
17
|
+
pursue: boolean;
|
|
18
|
+
/** Whether it fights back whoever hits it, for a stance that acquires nothing */
|
|
19
|
+
fireBack: boolean;
|
|
20
|
+
/** Where it goes once a fight is over: back where it stood, or nowhere */
|
|
21
|
+
returnTo: 'post' | 'none';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The four stances every RTS has: aggressive (the engine's own way, when no stance is set), defensive, hold fire and no
|
|
25
|
+
* attack. A game gives `withStances` its own list in their place, or adds to these
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export declare const STANCES: readonly StanceDef[];
|
|
30
|
+
/**
|
|
31
|
+
* The stance of a unit that was given none: the engine's own way
|
|
32
|
+
*
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_STANCE = "aggressive";
|
|
36
|
+
/**
|
|
37
|
+
* The stance a unit is in, by its id; absent for one in the default stance. Told to its owner, so that the HUD shows it
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare const stance: import("./components").Component<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* The stance of a unit, as a definition: the one its component names, else the default (the first of `stances` with
|
|
44
|
+
* the default's id, else the first of them)
|
|
45
|
+
*
|
|
46
|
+
* @beta
|
|
47
|
+
*/
|
|
48
|
+
export declare function stanceOf(entity: Entity, stances?: readonly StanceDef[]): StanceDef;
|
|
49
|
+
/**
|
|
50
|
+
* Puts units of the player's in a stance (`{ entities, stance }`). Units of another's, and ids of nothing, are left
|
|
51
|
+
* out. A stance the game has not got is kept as a word and behaves as the default: the hooks know the game's list
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
export declare const stanceCommand: import("#engine/commands").DefinedCommand<"stance", {
|
|
56
|
+
entities: import("./fields").Check<number[]>;
|
|
57
|
+
stance: import("./fields").Check<string>;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* What a game turns stances on with (`withStances`)
|
|
61
|
+
*
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export interface StancesOptions {
|
|
65
|
+
/** The stances of this game, in the order the HUD shows them: the usual four (`STANCES`) when left out */
|
|
66
|
+
stances?: readonly StanceDef[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A game whose units have stances: the component, the command, and the engine's acquisition read through hooks. In
|
|
70
|
+
* the default stance nothing changes. Defensive units fire at what their attack reaches and let go of what steps out
|
|
71
|
+
* of it, returning to where they stood (the engine's own way home); hold fire fires back at the last to hit it; no
|
|
72
|
+
* attack leaves everyone alone. A unit given an attack order fights whatever its stance
|
|
73
|
+
*
|
|
74
|
+
* @beta
|
|
75
|
+
*/
|
|
76
|
+
export declare function withStances(options?: StancesOptions): GamePack;
|
package/dist/start.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { PlayerId } from './entity';
|
|
2
|
+
import { type Vec2 } from './math';
|
|
3
|
+
import type { World } from './world';
|
|
4
|
+
/**
|
|
5
|
+
* A start in code: puts down a base at the start location, whatever it likes
|
|
6
|
+
*
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export interface StartCode {
|
|
10
|
+
/** Puts down a base at the start location. Only for players the map places nothing for */
|
|
11
|
+
spawn(world: World, player: PlayerId, at: Vec2): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A start as data: a hall at the start location and workers on the side of the closest gold mine, as in a classic melee
|
|
15
|
+
* game (`startingBase` puts it down). Every id is a unit type of the game's (`checkRaces` says where one is not)
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface StartData {
|
|
20
|
+
/** The unit type put down at the start location: a town hall */
|
|
21
|
+
hall: string;
|
|
22
|
+
/** The workers put down beside it, facing the closest gold mine */
|
|
23
|
+
workers: {
|
|
24
|
+
type: string;
|
|
25
|
+
count: number;
|
|
26
|
+
};
|
|
27
|
+
/** What else is put down with the workers, in the same row after them: a race's first fighter */
|
|
28
|
+
units?: {
|
|
29
|
+
type: string;
|
|
30
|
+
count: number;
|
|
31
|
+
}[];
|
|
32
|
+
/**
|
|
33
|
+
* What the race builds on the closest gold mine to gather it, put down there already standing (the undead's cursed
|
|
34
|
+
* mine). With it, the closest mine is found at any distance; without, the workers face a mine within 20 cells
|
|
35
|
+
*/
|
|
36
|
+
onMine?: string;
|
|
37
|
+
/** How far from the hall the workers stand: 5 cells when left out */
|
|
38
|
+
distance?: number;
|
|
39
|
+
/** The angle between two workers in the row, in radians: 0.35 when left out */
|
|
40
|
+
spread?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What each player gets at the beginning of a game on a map, for players the map places nothing for: as data
|
|
44
|
+
* (`StartData`: a hall, workers and what else by unit type, editable in the Data panel) or as code (`StartCode`). What
|
|
45
|
+
* they start with of each resource is in its `ResourceDef`
|
|
46
|
+
*
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
export type StartDef = StartCode | StartData;
|
|
50
|
+
/** Whether a start is the data form */
|
|
51
|
+
export declare const isStartData: (start: StartDef) => start is StartData;
|
|
52
|
+
/**
|
|
53
|
+
* Puts down what a start as data says (`StartData`): the hall at the point, what the race builds on the closest gold
|
|
54
|
+
* mine (`onMine`) on it, and the workers and the other units in a row on the side of the hall that faces the mine,
|
|
55
|
+
* facing it. With no mine in reach, the row faces north. A classic melee start; a race's `start` as data does this
|
|
56
|
+
*
|
|
57
|
+
* @beta
|
|
58
|
+
*/
|
|
59
|
+
export declare function startingBase(world: World, player: PlayerId, at: Vec2, start: StartData): void;
|
|
60
|
+
/**
|
|
61
|
+
* Puts down a player's start at a point, whichever form it is in: the code's `spawn`, or the base the data describes
|
|
62
|
+
* (`startingBase`). Nothing for no start
|
|
63
|
+
*
|
|
64
|
+
* @beta
|
|
65
|
+
*/
|
|
66
|
+
export declare function spawnStart(world: World, start: StartDef | undefined, player: PlayerId, at: Vec2): void;
|
|
67
|
+
/** The unit type ids a start as data names, each with where it is said (`start.hall`, `start.units[1].type`); none for code */
|
|
68
|
+
export declare function startIds(start: StartDef | undefined): {
|
|
69
|
+
where: string;
|
|
70
|
+
id: string;
|
|
71
|
+
}[];
|
package/dist/stats.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type DamageType, type StatChange, type StatKey, type Stats } from './defs';
|
|
2
|
+
import type { Entity } from './entity';
|
|
3
|
+
import type { World } from './world';
|
|
4
|
+
/**
|
|
5
|
+
* What adds up a unit's stats in the sum: what a stat source is handed (`StatPart.add`)
|
|
6
|
+
*
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export interface StatSum {
|
|
10
|
+
/** Adds a change to the stats, `times` over (1 when left out) */
|
|
11
|
+
add(change: StatChange, times?: number): void;
|
|
12
|
+
/** What a stat comes to so far: all that was added to it, by the parts it was made bigger or smaller by */
|
|
13
|
+
get(stat: StatKey): number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A part of the stats a pack adds (`GamePack.stats`): a hero's growth by its level, in the heroes pack. `stamp` is a
|
|
17
|
+
* number that changes whenever what it adds does, and is 0 when it adds nothing: the stats are added up again when it
|
|
18
|
+
* changes, however it changed (a game that sets a hero's level itself says nothing, and need not)
|
|
19
|
+
*
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
export interface StatPart {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
stamp(entity: Entity): number;
|
|
25
|
+
add(world: World, entity: Entity, sum: StatSum): void;
|
|
26
|
+
/**
|
|
27
|
+
* What it makes of the stats once everything else is added (research, the packs' parts, items, buffs, the `stats`
|
|
28
|
+
* hook), read with `sum.get`: a hero's strength into health, in the attributes pack (`withAttributes`)
|
|
29
|
+
*/
|
|
30
|
+
derive?(world: World, entity: Entity, sum: StatSum): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Says the stats of an entity, or of every entity when none is said, are to be added up again the next time they are
|
|
34
|
+
* asked for: what a `stats` hook or a buff's `change` reads changed (an ally came near, a flag of the game's). What
|
|
35
|
+
* the engine knows about (buffs, items, levels, research, the time of day) it notices by itself
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare function invalidateStats(world: World, entity?: Entity): void;
|
|
40
|
+
/**
|
|
41
|
+
* The stats of an entity the last time they were worked out, and everything they were worked out from.
|
|
42
|
+
*
|
|
43
|
+
* Stats are asked for all the time: on every hit (for both sides), every target search, every fog update.
|
|
44
|
+
* Adding them up means going through the owner's research, what the unit carries and every buff on it,
|
|
45
|
+
* and allocates. Checking whether any of that changed is a handful of comparisons and allocates nothing,
|
|
46
|
+
* so `statsOf` does that first and only adds up again when something did.
|
|
47
|
+
*
|
|
48
|
+
* The inputs are compared, rather than the cache being thrown away wherever they change, so that nothing
|
|
49
|
+
* can change a buff or an item and forget to say so: game modules and mods change them directly.
|
|
50
|
+
*
|
|
51
|
+
* Not game state: it can be dropped at any time (and is never saved or sent), it is rebuilt on the next ask.
|
|
52
|
+
*/
|
|
53
|
+
export interface StatsCache {
|
|
54
|
+
stats: Readonly<Stats>;
|
|
55
|
+
/** `changedStats` of `stats`, once someone asked. The same object for as long as the stats stay the same */
|
|
56
|
+
changed?: Partial<Stats>;
|
|
57
|
+
changedFor?: Readonly<Stats>;
|
|
58
|
+
def: Entity['def'];
|
|
59
|
+
night: boolean;
|
|
60
|
+
owner: number;
|
|
61
|
+
/** What each of the packs' stat sources stamped it with (`StatPart.stamp`), in their order */
|
|
62
|
+
stamps: number[];
|
|
63
|
+
upgradesVersion: number;
|
|
64
|
+
/** `World.statsVersion` when it was worked out: `invalidateStats` for every entity moves it on */
|
|
65
|
+
statsVersion: number;
|
|
66
|
+
/** Ids of what it carries, in slot order, empty slots left out */
|
|
67
|
+
items: string[];
|
|
68
|
+
/** Id, level and stacks of every buff, in order */
|
|
69
|
+
buffIds: string[];
|
|
70
|
+
buffLevels: number[];
|
|
71
|
+
buffStacks: number[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The stats of an entity as they are right now: what its type starts with at this time of day, and on top of that
|
|
75
|
+
* its levels, the research of its owner, what it carries and the buffs on it.
|
|
76
|
+
*
|
|
77
|
+
* The result is shared and must not be changed. It stays the same object for as long as the stats stay the same.
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export declare function statsOf(world: World, entity: Entity): Readonly<Stats>;
|
|
82
|
+
/**
|
|
83
|
+
* Brings the most health and mana an entity can have in line with its stats.
|
|
84
|
+
* What is gained is added to what it has, what is lost is only taken when it has more than it can hold.
|
|
85
|
+
*
|
|
86
|
+
* @beta
|
|
87
|
+
*/
|
|
88
|
+
export declare function refreshVitals(world: World, entity: Entity): void;
|
|
89
|
+
/**
|
|
90
|
+
* What is left of damage once the armor or the magic resist of the target had its say, as a part of it: 100 of it
|
|
91
|
+
* halve what arrives, and below 0 it adds. The engine's formula: the game's is `world.rules.combat.mitigation`, which
|
|
92
|
+
* is this unless the game says (penetration: `withMobaStats`)
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export declare function mitigation(type: DamageType, target: Readonly<Stats>): number;
|
|
97
|
+
/**
|
|
98
|
+
* How long an attack of the entity takes: from the start of the swing to the hit, and from one swing to the next. Of
|
|
99
|
+
* its first attack, or the one at that place (`UnitTypeDef.attacks`), by the speed stat it reads (`AttackDef.stats`)
|
|
100
|
+
*
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
export declare function attackTiming(world: World, entity: Entity, weapon?: number): {
|
|
104
|
+
swing: number;
|
|
105
|
+
period: number;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Seconds an ability of the entity takes to be ready again
|
|
109
|
+
*
|
|
110
|
+
* @beta
|
|
111
|
+
*/
|
|
112
|
+
export declare function cooldownOf(world: World, entity: Entity, seconds: number): number;
|
|
113
|
+
/**
|
|
114
|
+
* How long an attack takes, from the start of the swing to the hit, and from one swing to the next, for a unit
|
|
115
|
+
* whose type attacks `base` times a second and that now attacks `speed` times. Undefined for what does not attack
|
|
116
|
+
*
|
|
117
|
+
* @beta
|
|
118
|
+
*/
|
|
119
|
+
export declare function swingTiming(damagePoint: number, base: number, speed: number): {
|
|
120
|
+
swing: number;
|
|
121
|
+
period: number;
|
|
122
|
+
} | undefined;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Entity, PlayerId } from './entity';
|
|
2
|
+
import type { Vec2 } from './math';
|
|
3
|
+
import type { World } from './world';
|
|
4
|
+
/**
|
|
5
|
+
* What is left of a unit that died, for a while (see `corpses`)
|
|
6
|
+
*
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export interface Corpse {
|
|
10
|
+
/** The id the unit had: the screen keeps its body lying for as long as the corpse is there */
|
|
11
|
+
id: number;
|
|
12
|
+
type: string;
|
|
13
|
+
owner: PlayerId;
|
|
14
|
+
x: number;
|
|
15
|
+
z: number;
|
|
16
|
+
/** When it is gone, in seconds of the game */
|
|
17
|
+
until: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The corpses of a world. Saved with it
|
|
21
|
+
*
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export declare const corpses: import("./components").Component<Corpse[], Corpse[]>;
|
|
25
|
+
/**
|
|
26
|
+
* On a unit a spell brought: who brought it. Dispelling hurts what carries it
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
export declare const summoned: import("./components").Component<{
|
|
31
|
+
by: number;
|
|
32
|
+
}, {
|
|
33
|
+
by: number;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* On an illusion: whose copy it is, the part of its damage it deals, and how much more it takes. Told to its side
|
|
37
|
+
* only: to everyone else it is the real one
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare const illusion: import("./components").Component<{
|
|
42
|
+
of: number;
|
|
43
|
+
dealt: number;
|
|
44
|
+
taken: number;
|
|
45
|
+
}, {
|
|
46
|
+
of: number;
|
|
47
|
+
dealt: number;
|
|
48
|
+
taken: number;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Takes up to `most` corpses nearest a point, within `radius`, out of the world, and gives them
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
export declare function takeCorpses(world: World, point: Vec2, radius: number, most: number): Corpse[];
|
|
56
|
+
/**
|
|
57
|
+
* Whether killing an entity gains its killer nothing: an illusion
|
|
58
|
+
*
|
|
59
|
+
* @beta
|
|
60
|
+
*/
|
|
61
|
+
export declare const worthless: (entity: Entity) => boolean;
|
|
62
|
+
/** The corpses where the player sees (`Snapshot.corpses`): none to a computer, and left out where there are none */
|
|
63
|
+
export declare const corpsesPart: import("./replication").SnapshotPart<keyof import(".").Snapshot>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type Entity } from '#engine/entity';
|
|
2
|
+
import { type Vec2 } from '#engine/math';
|
|
3
|
+
import type { System } from '#engine/registry';
|
|
4
|
+
import type { World } from '#engine/world';
|
|
5
|
+
export type EngageResult = 'invalid' | 'attacking' | 'chasing' | 'outOfRange';
|
|
6
|
+
/**
|
|
7
|
+
* Whether an attacker may attack a target: its attack reaches it, it is an enemy, and the `canAttack` hook agrees.
|
|
8
|
+
* `ordered`: a player told it to (an attack order), which a game may let it do to its own side (`CanAttack.ordered`)
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export declare function canAttack(world: World, attacker: Entity, target: Entity, ordered?: boolean): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether one of an attacker's attacks can hit a target where it is, whoever's it is: the ground, the air, the kinds it
|
|
15
|
+
* names (`pickAttack`). For a `canAttack` handler that lets a unit attack what is not an enemy
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export declare function attackReaches(world: World, attacker: Entity, target: Entity): boolean;
|
|
20
|
+
export declare function canSee(world: World, viewer: Entity, target: Entity): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the target stands on higher ground than the attacker. Nothing is uphill from the air
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export declare function shootsUphill(world: World, attacker: Entity, target: Entity): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* What a search for a target found: the best, and whether it passed over one it would have taken but for leaving it
|
|
29
|
+
* alone for now (`shun`): what asking again with `shunned` would have found something for, without looking again
|
|
30
|
+
*/
|
|
31
|
+
export interface TargetFound {
|
|
32
|
+
target: Entity | undefined;
|
|
33
|
+
passedOver: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Best enemy within `range` of the entity (its acquisition range by default), as the `targetScore` hook sees it. Those
|
|
37
|
+
* it leaves alone for now (`shun`) are not, unless `shunned` says to count them too: to know whether a fight is still on
|
|
38
|
+
*/
|
|
39
|
+
export declare const acquireTarget: (world: World, entity: Entity, range?: number, shunned?: boolean) => Entity | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Best enemy it can hit from where it stands: within the range of the attack it would use against each (`pickAttack`),
|
|
42
|
+
* and `slack` more. For one that holds its ground
|
|
43
|
+
*
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
export declare function acquireInRange(world: World, entity: Entity, slack?: number): Entity | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* `acquireTarget`, and whether it passed over a target it leaves alone for now (`TargetFound`). What it gives back is
|
|
49
|
+
* the search's own, used again by the next search: read it at once
|
|
50
|
+
*/
|
|
51
|
+
export declare function searchTarget(world: World, entity: Entity, range?: number, shunned?: boolean, inRange?: number): Readonly<TargetFound>;
|
|
52
|
+
export declare function cancelSwing(entity: Entity): void;
|
|
53
|
+
export type BombardResult = 'attacking' | 'outOfRange';
|
|
54
|
+
/** One tick of attacking a spot on the ground, for attacks that can. Getting into range is up to the caller */
|
|
55
|
+
export declare function bombard(world: World, entity: Entity, point: Vec2, dt: number): BombardResult;
|
|
56
|
+
/**
|
|
57
|
+
* Drives one tick of fighting a target: close the distance, turn, swing, hit.
|
|
58
|
+
* Every order that fights (attack, attack-move, hold, idle auto-attack) goes through here.
|
|
59
|
+
*/
|
|
60
|
+
export declare function engage(world: World, entity: Entity, target: Entity | undefined, dt: number, chase: boolean, ordered?: boolean): EngageResult;
|
|
61
|
+
/**
|
|
62
|
+
* One tick of an attack that fires as the unit walks (`AttackDef.onTheMove`): what it shot at last tick while it can
|
|
63
|
+
* still be hit from where the unit is, else the best in range (looked for every fourth tick), swung at without a stop
|
|
64
|
+
* or a turn. Gives back what it is shooting at, none for nothing
|
|
65
|
+
*
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
export declare function fireOnTheMove(world: World, entity: Entity, current: number | undefined, dt: number): number | undefined;
|
|
69
|
+
/** Stops fighting: aborts the swing and lets the unit be pushed around again. */
|
|
70
|
+
export declare function disengage(world: World, entity: Entity): void;
|
|
71
|
+
export declare const combatSystem: System;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What players are told of fights (the combat system's events): a swing, a shot landing, a miss, a blast. Beside the
|
|
3
|
+
* combat system, which emits them
|
|
4
|
+
*/
|
|
5
|
+
/** A swing, to those who see the attacker */
|
|
6
|
+
export declare const toldAttack: import("..").ReplicatedEvent;
|
|
7
|
+
/** A shot landing: to its side, and to those who see where */
|
|
8
|
+
export declare const toldShot: import("..").ReplicatedEvent;
|
|
9
|
+
/** A miss, to those who see who missed or who was missed */
|
|
10
|
+
export declare const toldMiss: import("..").ReplicatedEvent;
|
|
11
|
+
/** A blast: to its side, and to those who see where */
|
|
12
|
+
export declare const toldImpact: import("..").ReplicatedEvent;
|
|
13
|
+
/** The projectiles in flight the player is told of: their side's, and those where they see (`Snapshot.projectiles`); none to a computer */
|
|
14
|
+
export declare const projectilesPart: import("..").SnapshotPart<keyof import("..").Snapshot>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConstructionState, Entity } from '#engine/entity';
|
|
2
|
+
import type { EntityState } from '#engine/session/protocol';
|
|
3
|
+
import type { System } from '#engine/registry';
|
|
4
|
+
/** Whether two parts done of a whole say the same to a screen: to a hundredth, what a bar shows and the wire sends */
|
|
5
|
+
export declare const sameHundredth: (a: number, b: number) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* A structure being built: how far it is, how long it takes, who works on it (`UnitTypeDef.construction`). Set as a
|
|
8
|
+
* site is put down (`SpawnOptions.underConstruction`), taken off once it stands; a structure's only (a unit given it is
|
|
9
|
+
* not seen as one). Everyone who sees it is told how far it is (0..1)
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export declare const constructionSite: import("#engine/components").Component<ConstructionState, number>;
|
|
14
|
+
/**
|
|
15
|
+
* What a structure being built has done and needs: none once it stands, or for what was put down whole (`constructionSite`)
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export declare const underConstruction: (entity: Entity) => ConstructionState | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* How far a structure in a snapshot is built, 0..1: undefined for one that stands (a screen's, a computer player's view)
|
|
22
|
+
*
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
export declare const builtSoFar: (state: EntityState) => number | undefined;
|
|
26
|
+
export declare const constructionSystem: System;
|
|
27
|
+
/** A structure begun, to those who see it: with how long it takes */
|
|
28
|
+
export declare const toldConstructionStarted: import("..").ReplicatedEvent;
|
|
29
|
+
/** A structure finished, to those who see it */
|
|
30
|
+
export declare const toldBuilt: import("..").ReplicatedEvent;
|
|
31
|
+
/** A structure called off while being built, to those who see it */
|
|
32
|
+
export declare const toldConstructionCancelled: import("..").ReplicatedEvent;
|
|
33
|
+
/** A blow of a builder's hammer, to those who see the builder */
|
|
34
|
+
export declare const toldWork: import("..").ReplicatedEvent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { System } from '#engine/registry';
|
|
2
|
+
import type { SessionView } from '../replication';
|
|
3
|
+
import type { MineInfo } from '../session/protocol';
|
|
4
|
+
/**
|
|
5
|
+
* Keeps every player's supply in sync with what they own and have queued: what their units take (`GameRules.supply.of`,
|
|
6
|
+
* those in a queue too) against what their finished buildings provide, changed by the game's `supplyCap` hook and held
|
|
7
|
+
* under the game's most. The same for each of the game's other pools (`GameRules.supply.pools`), from the types' `supplies`
|
|
8
|
+
* and `suppliesProvided`
|
|
9
|
+
*/
|
|
10
|
+
export declare const supplySystem: System;
|
|
11
|
+
/** A tree chopped, to those who see the worker and the tree */
|
|
12
|
+
export declare const toldChop: import("..").ReplicatedEvent;
|
|
13
|
+
/** What an entity carries or holds of a resource changed: its side's alone */
|
|
14
|
+
export declare const toldResource: import("..").ReplicatedEvent;
|
|
15
|
+
/**
|
|
16
|
+
* Where the game's money is mined, as the map shows it, seen or not (`GameSession.mines`). Worked out once a tick: a
|
|
17
|
+
* walk of every entity, which twelve computers would each take a think. The same list every time within a tick, to read
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export declare function minesFor(view: SessionView): readonly MineInfo[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Entity } from '#engine/entity';
|
|
2
|
+
import type { System } from '#engine/registry';
|
|
3
|
+
/**
|
|
4
|
+
* Lets a team see the entity for a while, for having attacked it: from the dark, from high ground, from anywhere
|
|
5
|
+
*
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export declare function expose(entity: Entity, team: number): void;
|
|
9
|
+
/**
|
|
10
|
+
* Works out what every team sees, every few ticks: clears the `visible` grids and lights a circle around
|
|
11
|
+
* everything that looks around (units and buildings by their sight, reveal spells, scouting missiles,
|
|
12
|
+
* invisible units that were found, attackers that gave themselves away).
|
|
13
|
+
*/
|
|
14
|
+
export declare const fogSystem: System;
|
|
15
|
+
/**
|
|
16
|
+
* What the player is told of the spots revealed (`Snapshot.reveals`): their team's own, and another's only where they see:
|
|
17
|
+
* where an enemy's spell looks is the enemy's to know. A quiet one shows what it shows, and is nothing to draw; none to a computer
|
|
18
|
+
*/
|
|
19
|
+
export declare const revealsPart: import("..").SnapshotPart<keyof import("..").Snapshot>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { type Entity } from '#engine/entity';
|
|
2
|
+
import { type Vec2 } from '#engine/math';
|
|
3
|
+
import type { AgentState } from '#engine/navigation/navigation';
|
|
4
|
+
import type { System } from '#engine/registry';
|
|
5
|
+
import type { World } from '#engine/world';
|
|
6
|
+
/** @beta */
|
|
7
|
+
export interface MoveOptions {
|
|
8
|
+
/** Arrive once this close to the goal. `ARRIVE_RANGE` when left out */
|
|
9
|
+
range?: number;
|
|
10
|
+
groupId?: number;
|
|
11
|
+
/** Direction to turn to after arriving */
|
|
12
|
+
facing?: number;
|
|
13
|
+
/**
|
|
14
|
+
* A step aside for another (`stepAside`), or any short move that is nobody's business: the unit goes round nobody
|
|
15
|
+
* and asks nobody to make way on it, so that one step does not set off the next
|
|
16
|
+
*/
|
|
17
|
+
aside?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Point a unit should walk to in order to reach the target: next to its edge for structures, its spot around it for
|
|
21
|
+
* one fighting it (see `engagement.ts`)
|
|
22
|
+
*/
|
|
23
|
+
export declare function approachPoint(world: World, entity: Entity, target: Entity): Vec2;
|
|
24
|
+
/** Sends a walking unit on as it was, after something held it (a builder waiting for room): its stretch, or its goal */
|
|
25
|
+
export declare function walkOn(world: World, entity: Entity): void;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a unit walking to a point, the way around what is in the way. How it goes is in `entity.movement.status`:
|
|
28
|
+
* `moving` on the way, `arrived` once there, `failed` when there is no way there or it got stuck. An order calls
|
|
29
|
+
* this once and then watches the status; calling it again with the same goal starts the walk over
|
|
30
|
+
*
|
|
31
|
+
* @beta
|
|
32
|
+
*/
|
|
33
|
+
export declare function moveTo(world: World, entity: Entity, goal: Vec2, options?: MoveOptions): void;
|
|
34
|
+
/**
|
|
35
|
+
* Walks towards an entity until within `range` of its edge. Safe to call every tick.
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare function moveToEntity(world: World, entity: Entity, target: Entity, range: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Stops a unit where it is. Its status is `idle` after
|
|
42
|
+
*
|
|
43
|
+
* @beta
|
|
44
|
+
*/
|
|
45
|
+
export declare function halt(world: World, entity: Entity): void;
|
|
46
|
+
/**
|
|
47
|
+
* Anchored units stand their ground instead of being pushed around by units walking past.
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
export declare function setAnchored(world: World, entity: Entity, anchored: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Ghosts walk through other units. Classic RTS games do this for workers hauling resources so mining never jams.
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export declare function setGhost(world: World, entity: Entity, ghost: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Turns a unit a little towards a point, as far as it turns in `dt` seconds. For orders that aim at something
|
|
60
|
+
*
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
63
|
+
export declare function faceTowards(entity: Entity, point: Vec2, dt: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Whether another unit stands in a mover's way: there, standing still, and on the same crowd, where each steers
|
|
66
|
+
* round the other and neither walks through. What moves is steered round by the navigation; what is a ghost is walked
|
|
67
|
+
* through; what flies, sails or is of another size goes its own way. What the mover walks to, or stands where it is
|
|
68
|
+
* going, is not in its way either: it stops by it, close enough (a follower by the one it follows, a unit sent where
|
|
69
|
+
* another stands), rather than send it off
|
|
70
|
+
*
|
|
71
|
+
* @beta
|
|
72
|
+
*/
|
|
73
|
+
export declare function standsInWay(world: World, mover: Entity, other: Entity): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Asks an ally standing in a unit's way to step aside, as the rules allow (`GameRules.movement.makesWay`, the `makeWay` hook).
|
|
76
|
+
* `direction` is the way the unit is heading, a unit long; `agent` where its path goes, for the step to be off it.
|
|
77
|
+
* True when it goes
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export declare function stepAside(world: World, mover: Entity, other: Entity, direction: Vec2, agent: AgentState): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Asks friendly units that are standing around in front of a unit to step aside.
|
|
84
|
+
* Avoidance alone cannot get a unit out of a tight group of idle ones: they would have to move, and nothing tells them to.
|
|
85
|
+
*
|
|
86
|
+
* @beta
|
|
87
|
+
*/
|
|
88
|
+
export declare function makeWay(world: World, entity: Entity): void;
|
|
89
|
+
/**
|
|
90
|
+
* Looks ahead of a unit on its way for units standing in it (within `GameRules.movement.lookAhead`): a way round the knot
|
|
91
|
+
* they make is taken where it is not much longer (`GameRules.movement.goesAround`, the `detour` hook); otherwise those of
|
|
92
|
+
* them that make way (`GameRules.movement.makesWay`) are asked to step aside before the unit reaches them. The way round is
|
|
93
|
+
* beside the knot, on the side it sticks out less, at the knot's middle; the unit heads there, and on to its path
|
|
94
|
+
* from there. The number of units sent to this per tick is spread by their ids (`LOOK_AHEAD_INTERVAL`)
|
|
95
|
+
*
|
|
96
|
+
* @beta
|
|
97
|
+
*/
|
|
98
|
+
export declare function lookAhead(world: World, entity: Entity, agent: AgentState): void;
|
|
99
|
+
/**
|
|
100
|
+
* Over how many ticks the chasers look for new paths after the navigation changed: an eighth of them each tick
|
|
101
|
+
*
|
|
102
|
+
* @beta
|
|
103
|
+
*/
|
|
104
|
+
export declare const REPATH_SPREAD = 8;
|
|
105
|
+
export declare const movementSystem: System;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Entity, Order } from '#engine/entity';
|
|
2
|
+
import type { System } from '#engine/registry';
|
|
3
|
+
import type { World } from '#engine/world';
|
|
4
|
+
/** Runs the order at the front of every queue */
|
|
5
|
+
export declare const orderSystem: System;
|
|
6
|
+
/** One tick of an order: started when it has not been, and taken off the queue when it is over */
|
|
7
|
+
export declare function runOrder(world: World, entity: Entity, order: Order, dt: number): void;
|