Fix some script bugs

This commit is contained in:
2026-06-07 18:47:34 -05:00
parent ed0420fdce
commit f8c9d33df2
8 changed files with 60 additions and 32 deletions
+6 -1
View File
@@ -31,7 +31,12 @@ interface AssetBatch {
/** `true` if any entry is in an `ERROR` state. */
readonly hasError: boolean;
/**
* Blocks until every entry is loaded.
* Returns a Promise that resolves when all entries have loaded, or rejects
* if any entry errors. Use with `await`.
*/
loaded(): Promise<void>;
/**
* Blocks (spin-waits) until every entry is loaded.
* Returns `this` for chaining.
* @throws If any entry fails to load.
*/
+6 -1
View File
@@ -33,7 +33,12 @@ interface AssetEntry {
/** Event proxy — subscribe up to 4 callbacks for when loading fails. */
readonly onError: AssetEventProxy;
/**
* Blocks until the entry reaches `LOADED` (or `ERROR`).
* Returns a Promise that resolves when the entry is loaded, or rejects on
* error. Use with `await`.
*/
loaded(): Promise<void>;
/**
* Blocks (spin-waits) until the entry reaches `LOADED` (or `ERROR`).
* Returns `this` for chaining.
* @throws If the load fails.
*/
+23
View File
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
/**
* An event proxy with up to 4 subscribable callback slots (indices 03).
* Assign a function to subscribe; assign `null` to unsubscribe.
*
* @example
* assets.onLoaded[0] = () => { Console.print('all loaded'); };
* assets.onLoaded[0] = null; // unsubscribe
*/
interface AssetEventProxy {
0: (() => void) | null;
1: (() => void) | null;
2: (() => void) | null;
3: (() => void) | null;
/** Number of available slots (always 4). */
readonly length: number;
}
+4 -12
View File
@@ -19,19 +19,11 @@ interface Component {
}
interface ComponentConstructor {
/** Sentinel for an invalid component ID. */
readonly INVALID: number;
readonly POSITION: number;
readonly CAMERA: number;
readonly POSITION: number;
readonly CAMERA: number;
readonly RENDERABLE: number;
readonly PHYSICS: number;
readonly TRIGGER: number;
readonly OVERWORLD: number;
readonly PLAYER: number;
readonly INTERACTABLE: number;
readonly OVERWORLD_CAMERA: number;
readonly OVERWORLD_TRIGGER: number;
readonly PHYSICS: number;
readonly TRIGGER: number;
new(): never;
}
+1 -5
View File
@@ -26,6 +26,7 @@
/// <reference path="./display/texture.d.ts" />
// asset
/// <reference path="./asset/asseteventproxy.d.ts" />
/// <reference path="./asset/assetentry.d.ts" />
/// <reference path="./asset/assetbatch.d.ts" />
/// <reference path="./asset/asset.d.ts" />
@@ -41,12 +42,7 @@
// entity / components
/// <reference path="./entity/component.d.ts" />
/// <reference path="./entity/component/camera.d.ts" />
/// <reference path="./entity/component/interactable.d.ts" />
/// <reference path="./entity/component/overworld.d.ts" />
/// <reference path="./entity/component/overworldcamera.d.ts" />
/// <reference path="./entity/component/overworldtrigger.d.ts" />
/// <reference path="./entity/component/physics.d.ts" />
/// <reference path="./entity/component/player.d.ts" />
/// <reference path="./entity/component/position.d.ts" />
/// <reference path="./entity/component/renderable.d.ts" />
/// <reference path="./entity/component/trigger.d.ts" />