Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

10.2 KB
Raw Blame

API surface — esengine/logic

Symbols: 0 public · 0 beta · 72 experimental · 0 deprecated

AiScriptGraphs — const @experimental

ResourceDef<ScriptGraphs>

BUILTIN_NODE_KINDS — const @experimental

readonly string[]

CompiledScriptGraph — interface @experimental

dataSources: Map<string, { node: string; port: string; }>
destroys: string[]
events: Map<string, string[]>
execTargets: Map<string, string>
graph: ScriptGraph
inputNode: string | undefined
nodes: Map<string, ScriptGraphNode>
outputNode: string | undefined
prefabs: Map<string, PreparedPrefab>
problems: string[]
shapes: Map<string, ScriptNodeShape>
starts: string[]
starvedInputs: Map<string, string[]>
updates: string[]

DEFAULT_STEP_BUDGET — const @experimental

4096

MAX_CALL_DEPTH — const @experimental

16

SCRIPT_GRAPH_VERSION — const @experimental

"1.0"

ScriptFrame — interface @experimental

calls: Map<string, ScriptFrame>
produced: Map<string, Record<string, ScriptValue>>
timers: Map<string, number>
vars: Map<string, ScriptValue>

ScriptGraph — interface @experimental

edges: ScriptGraphEdge[]
inputs: ScriptGraphPort[] | undefined
name: string | undefined
nodes: ScriptGraphNode[]
outputs: ScriptGraphPort[] | undefined
variables: ScriptGraphVariable[] | undefined
version: string

ScriptGraphAgent — const @experimental

ComponentDef<ScriptGraphAgentData>

ScriptGraphAgentData — interface @experimental

graph: string

ScriptGraphEdge — interface @experimental

from: string
fromPort: string
id: string
to: string
toPort: string

ScriptGraphNode — interface @experimental

id: string
kind: string
literals: Record<string, ScriptValue> | undefined
ref: string | undefined
x: number | undefined
y: number | undefined

ScriptGraphPlugin — class @experimental

build: (app: App) => void
name: string
static new (): ScriptGraphPlugin
static prototype: ScriptGraphPlugin

ScriptGraphPort — interface @experimental

default: ScriptValue | undefined
label: string | undefined
name: string
type: "any" | "bool" | "entity" | "number" | "string"

ScriptGraphSignature — interface @experimental

inputs: readonly ScriptGraphPort[]
outputs: readonly ScriptGraphPort[]

ScriptGraphVariable — interface @experimental

default: ScriptValue | undefined
name: string
type: "bool" | "entity" | "number" | "string"

ScriptGraphWorldView — interface @experimental

get: <C extends AnyComponentDef>(entity: Entity, component: C) => ComponentData<C>
getEntitiesWithComponents: (components: readonly AnyComponentDef[]) => readonly Entity[]
has: (entity: Entity, component: AnyComponentDef) => boolean
set: <C extends AnyComponentDef>(entity: Entity, component: C, data: ComponentData<C>) => void

ScriptGraphs — class @experimental

blackboard: (entity: Entity) => Blackboard
halted: (entity: Entity) => boolean
setVariable: (entity: Entity, name: string, value: ScriptValue) => void
variable: (entity: Entity, name: string) => ScriptValue
static new (states: Map<Entity, AgentState>): ScriptGraphs
static prototype: ScriptGraphs

ScriptNodeShape — interface @experimental

entry: "destroy" | "event" | "start" | "update" | undefined
execIn: boolean
execOut: readonly string[]
inputs: readonly ScriptPort[]
outputs: readonly ScriptPort[]
pure: boolean

ScriptPort — interface @experimental

label: string | undefined
name: string
type: ScriptValueType

ScriptRunState — interface @experimental

calls: Map<string, ScriptFrame>
halted: boolean
produced: Map<string, Record<string, ScriptValue>>
reported: Set<string>
started: boolean
timers: Map<string, number>
vars: Map<string, ScriptValue>

ScriptTickContext — interface @experimental

bb: Blackboard
budget: number | undefined
ctx: Ctx
dt: number
onProblem: ((message: string) => void) | undefined
registry: AiRegistry<Ctx>
resolveGraph: ((ref: string) => CompiledScriptGraph | undefined) | undefined
world: World | undefined

ScriptValue — type @experimental

boolean | number | string | null

ScriptValueType — type @experimental

'exec' | 'bool' | 'number' | 'string' | 'entity' | 'any'

ScriptVerbCatalog — interface @experimental

getActionOutputs: (name: string) => readonly AiOutputDef[]
getActionParams: (name: string) => readonly AiParamDef[]
graphSignature: (ref: string) => ScriptGraphSignature | null
hasAction: (name: string) => boolean
isActionPure: (name: string) => boolean

THEN — const @experimental

"then"

addScriptGraphPort — function @experimental

(graph: ScriptGraph, side: "inputs" | "outputs", port: ScriptGraphPort): ScriptGraph

addScriptNode — function @experimental

(graph: ScriptGraph, kind: string, x: number, y: number, ref?: string): { graph: ScriptGraph; id: string; }

addScriptVariable — function @experimental

(graph: ScriptGraph, variable: ScriptGraphVariable): ScriptGraph

agentGraphBlackboard — function @experimental

(states: Map<Entity, AgentState>, entity: Entity): Blackboard

allScriptGraphs — function @experimental

(): Iterable<CompiledScriptGraph>

canConnect — function @experimental

(from: ScriptValueType, to: ScriptValueType): boolean

canConnectPorts — function @experimental

(graph: ScriptGraph, catalog: ScriptVerbCatalog, from: string, fromPort: string, to: string, toPort: string): boolean

clearScriptGraphStore — function @experimental

(): void

coerceValue — function @experimental

(value: ScriptValue, type: ScriptValueType): ScriptValue

compileAgainstRegistry — function @experimental

(graph: ScriptGraph, signatures?: ReadonlyMap<string, ScriptGraphSignature>): CompiledScriptGraph

compileScriptGraph — function @experimental

(graph: ScriptGraph, catalog: ScriptVerbCatalog): CompiledScriptGraph

connectScriptNodes — function @experimental

(graph: ScriptGraph, catalog: ScriptVerbCatalog, from: string, fromPort: string, to: string, toPort: string): ScriptGraph

createScriptRunState — function @experimental

(compiled: CompiledScriptGraph): ScriptRunState

defaultForType — function @experimental

(type: ScriptValueType): ScriptValue

describeNode — function @experimental

(node: ScriptGraphNode, graph: ScriptGraph, catalog: ScriptVerbCatalog): ScriptNodeShape | null

destroyScriptGraph — function @experimental

<Ctx>(compiled: CompiledScriptGraph, run: ScriptRunState, tick: ScriptTickContext<Ctx>): void

disconnectScriptExec — function @experimental

(graph: ScriptGraph, from: string, fromPort: string): ScriptGraph

disconnectScriptInput — function @experimental

(graph: ScriptGraph, to: string, toPort: string): ScriptGraph

emptyScriptGraph — function @experimental

(name?: string): ScriptGraph

ensureBuiltinScriptNodes — function @experimental

(): void

fireScriptGraphEvent — function @experimental

<Ctx>(compiled: CompiledScriptGraph, run: ScriptRunState, tick: ScriptTickContext<Ctx>, type: string, target: number, other?: number): void

getScriptGraph — function @experimental

(key: string): CompiledScriptGraph | undefined

graphCallRef — function @experimental

(node: ScriptGraphNode): string

isCallableGraph — function @experimental

(graph: ScriptGraph): boolean

moveScriptNode — function @experimental

(graph: ScriptGraph, id: string, x: number, y: number): ScriptGraph

registerScriptGraph — function @experimental

(key: string, graph: ScriptGraph): CompiledScriptGraph

removeScriptEdge — function @experimental

(graph: ScriptGraph, id: string): ScriptGraph

removeScriptGraphPort — function @experimental

(graph: ScriptGraph, side: "inputs" | "outputs", name: string): ScriptGraph

removeScriptNode — function @experimental

(graph: ScriptGraph, id: string): ScriptGraph

removeScriptVariable — function @experimental

(graph: ScriptGraph, name: string): ScriptGraph

renameScriptGraphPort — function @experimental

(graph: ScriptGraph, side: "inputs" | "outputs", from: string, to: string): ScriptGraph

renameScriptVariable — function @experimental

(graph: ScriptGraph, from: string, to: string): ScriptGraph

retypeScriptGraphPort — function @experimental

(graph: ScriptGraph, side: "inputs" | "outputs", name: string, type: ScriptGraphPort["type"]): ScriptGraph

scriptCatalog — function @experimental

(verbs: Omit<ScriptVerbCatalog, "graphSignature">, signatures?: ReadonlyMap<string, ScriptGraphSignature>): ScriptVerbCatalog

scriptGraphCallRefs — function @experimental

(graph: ScriptGraph): string[]

scriptGraphEdges — function @experimental

(graph: ScriptGraph): readonly ScriptGraphEdge[]

scriptGraphLeaves — function @experimental

(compiled: CompiledScriptGraph): Iterable<LeafRef>

scriptGraphPlugin — const @experimental

ScriptGraphPlugin

scriptGraphPrefabRefs — function @experimental

(graph: ScriptGraph): string[]

scriptGraphTouches — function @experimental

(app: App): SystemTouches

sequenceCount — function @experimental

(node: ScriptGraphNode): number

setScriptNodeLiteral — function @experimental

(graph: ScriptGraph, id: string, port: string, value: ScriptValue): ScriptGraph

signatureOf — function @experimental

(graph: ScriptGraph): ScriptGraphSignature

spawnPrefabRef — function @experimental

(node: ScriptGraphNode): string

stepScriptGraph — function @experimental

<Ctx>(compiled: CompiledScriptGraph, run: ScriptRunState, tick: ScriptTickContext<Ctx>): void

stepScriptGraphs — function @experimental

(world: ScriptGraphWorldView, commands: CommandsInstance, dt: number, states: Map<Entity, AgentState>, resolveGraph?: (ref: string) => CompiledScriptGraph | undefined, onProblem?: (entity: Entity, message: string) => void, input?: InputState): void