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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): what can go on an entity is a question with an answer
yhh4f520866e84f
diff --git a/desktop/shared/toolCatalog.mjs b/desktop/shared/toolCatalog.mjsindex 2e4a8f9f1..03bc7bb71 100644--- a/desktop/shared/toolCatalog.mjs+++ b/desktop/shared/toolCatalog.mjs@@ -95,9 +95,11 @@ export const TOOLS = [{ name: 'describe_component',description: "A component TYPE's fields before you write any: key, label, inspector type, enum options and the default. "+ 'Ask this instead of guessing a field name — the registry knows that ShapeRenderer takes `shapeType` (0 Circle / 1 Capsule / 2 RoundedRect), not `shape` or `fill`. '- + 'get_inspector answers the same question about a LIVE entity; this one needs no entity to exist.',- schema: obj({ component: { type: 'string' } }, ['component']),- method: 'describeComponent', args: (i) => [i.component] },+ + 'get_inspector answers the same question about a LIVE entity; this one needs no entity to exist. '+ + 'WITHOUT `component` it lists every component that can be added (name, label, category), including the '+ + "project's own — which is the answer to \"what can I put on an entity\", and beats guessing at names.",+ schema: obj({ component: { type: 'string' } }),+ method: 'describeComponent', args: (i) => [i.component ?? null] },{ name: 'get_field_value',description: "One component field's current value (null if the field does not exist).",schema: obj({ entity: { type: 'number' }, component: { type: 'string' }, key: { type: 'string' } },diff --git a/desktop/src/engine/EditorControlSurface.ts b/desktop/src/engine/EditorControlSurface.tsindex 2b59dfcef..b5ca47835 100644--- a/desktop/src/engine/EditorControlSurface.ts+++ b/desktop/src/engine/EditorControlSurface.ts@@ -27,7 +27,7 @@ import type {import type { SceneData, PrefabData, SubsystemStatus, EventBindingRow } from 'esengine';import { Material, Sprite, Renderer } from 'esengine';import { EngineHost } from './EngineHost';-import { isRequiredEmpty, componentByName, userSchema, coerceEnumInput, componentAuthorability, inspectorFields } from './schema';+import { isRequiredEmpty, componentByName, userSchema, coerceEnumInput, componentAuthorability, inspectorFields, modelAddableComponentEntries } from './schema';import { ViewportController } from './ViewportController';import { PerfMonitor, type PerfSnapshot, type FrameSample, type SessionCapture } from './PerfMonitor';import type { SceneCommandsImpl, EditorTransaction } from './SceneCommands';@@ -606,7 +606,16 @@ export class EditorControlSurfaceImpl {* not `fill`) and that it takes 0/1/2 rather than "rectangle". The registry* knew all of that from the start.*/- describeComponent(component: string): InspectorField[] {+ describeComponent(+ component?: string | null,+ ): InspectorField[] | Array<{ name: string; label: string; category: string }> {+ // No name: the catalog itself. "What can I put on an entity" had no door at+ // all — a driver that did not already know a name guessed ("FSMComponent",+ // "StateMachine") and was refused by each in turn. The Add Component menu+ // has always had this list; it was reachable only by opening the menu.+ if (!component) {+ return modelAddableComponentEntries({ id: 0, name: '', parent: null, children: [], components: [] });+ }return inspectorFields(component, {});}getFieldValue(entity: EntityId, component: string, key: string): InspectorFieldValue | null {