Finish JerryScript Entity/Scene wiring; remove JSON serialize/deserialize
Register Entity, the generic Component wrapper, and Scene as JerryScript classes (modulelist.c ties them together, plus their .d.ts stubs), so scenes/entities can be built from script going forward instead of the JSON scene format. With scripting now the intended authoring path, drop the JSON serialize/deserialize machinery entirely: componentdefinition_t's serialize/deserialize callbacks, every component's *Serialize/ *Deserialize function, entitySerialize/entityDeserialize, sceneSerialize/sceneDeserialize, and the "prefabs/<name>.json"/ "scenes/<name>.json" asset fallback in entityPrefabResolveAndApply/ scenePrefabResolveAndApply (C-coded prefabs only now). physicsshape.c and its test are removed outright since they only existed for this. game.c's test scene now comes from the existing overworldSceneCreate() C builder instead of loading the now-deleted assets/scenes/test.json. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* A component attached to an Entity. Generic across every component
|
||||
* type for now -- there are no typed per-type properties yet (e.g. no
|
||||
* `.position` on a POSITION component), just the operations every
|
||||
* component supports regardless of type. Only ever obtained via
|
||||
* Entity.add()/Entity.getComponent(), never constructed directly.
|
||||
*/
|
||||
declare class Component {
|
||||
/** The componenttype_t this component was added as, e.g. POSITION. */
|
||||
readonly type: number;
|
||||
|
||||
/** The id of the Entity this component belongs to. */
|
||||
readonly entityId: number;
|
||||
|
||||
/** Removes this component from its entity. */
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Component type constants, usable with Entity.add()/getComponent().
|
||||
* The numeric values are opaque/build-specific; treat the names as the
|
||||
* stable API.
|
||||
*/
|
||||
declare const POSITION: number;
|
||||
declare const CAMERA: number;
|
||||
declare const RENDERABLE: number;
|
||||
declare const PHYSICS: number;
|
||||
declare const TRIGGER: number;
|
||||
declare const ANIMATION: number;
|
||||
declare const PLAYER: number;
|
||||
declare const INTERACTABLE: number;
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/// <reference path="component/component.d.ts" />
|
||||
|
||||
/**
|
||||
* A game entity. `new Entity()` adds it to the currently active scene's
|
||||
* entity manager (see Scene.getActive()) -- throws if no scene is
|
||||
* active.
|
||||
*/
|
||||
declare class Entity {
|
||||
constructor();
|
||||
|
||||
/** The engine-assigned numeric entity ID. */
|
||||
readonly id: number;
|
||||
|
||||
/** Optional name; empty string if unset. */
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Adds a component of the given type (e.g. POSITION) to this entity
|
||||
* and returns its wrapper.
|
||||
*/
|
||||
add(type: number): Component;
|
||||
|
||||
/**
|
||||
* Gets this entity's component of the given type, or undefined if it
|
||||
* doesn't have one.
|
||||
*/
|
||||
getComponent(type: number): Component | undefined;
|
||||
|
||||
/** Removes this entity and all its position-component descendants. */
|
||||
dispose(): void;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/// <reference path="entity/entity.d.ts" />
|
||||
/// <reference path="entity/component/component.d.ts" />
|
||||
/// <reference path="scene/scene.d.ts" />
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* A scene: an isolated pool of entities/components. `new Scene()`
|
||||
* creates an empty scene -- it is not made active automatically, call
|
||||
* `.setActive()` for that. `Entity`/`Component` always operate on
|
||||
* whichever scene is currently active, not on a specific Scene
|
||||
* instance.
|
||||
*/
|
||||
declare class Scene {
|
||||
constructor();
|
||||
|
||||
/** The engine-assigned numeric scene ID. */
|
||||
readonly id: number;
|
||||
|
||||
/** Makes this the active scene (see Scene.getActive()). */
|
||||
setActive(): void;
|
||||
|
||||
/** Destroys this scene and all its entities/components. */
|
||||
dispose(): void;
|
||||
|
||||
/** Gets the currently active scene, or undefined if none is active. */
|
||||
static getActive(): Scene | undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user