@skewedaspect/sage 0.7.1 → 0.8.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.
@@ -14,16 +14,12 @@ export interface LevelProgressEvent {
14
14
  * Levels are responsible for creating and configuring their own scenes.
15
15
  */
16
16
  export declare abstract class Level {
17
- protected _name: string;
17
+ readonly name: string;
18
+ protected readonly _log: LoggerInterface;
18
19
  protected _sceneEngine?: SceneEngine;
19
20
  protected _eventBus?: GameEventBus;
20
21
  protected _scene: Scene | null;
21
- protected _log: LoggerInterface;
22
22
  constructor(name: string);
23
- /**
24
- * The name of this level
25
- */
26
- get name(): string;
27
23
  /**
28
24
  * The current scene for this level (null if not loaded)
29
25
  */
@@ -35,7 +31,7 @@ export declare abstract class Level {
35
31
  /**
36
32
  * Emit a progress event during loading
37
33
  */
38
- protected _emitProgress(progress: number, message: string): void;
34
+ protected $emitProgress(progress: number, message: string): void;
39
35
  /**
40
36
  * Load and create the scene for this level.
41
37
  * Progress events will be emitted during loading.
@@ -50,9 +46,11 @@ export declare abstract class Level {
50
46
  * Abstract method for building the scene content.
51
47
  * Concrete levels must implement this to create their specific content.
52
48
  *
49
+ * @param sceneEngine - The scene engine used to create the scene
50
+ *
53
51
  * @returns Promise that resolves to the created scene
54
52
  */
55
- protected abstract buildScene(): Promise<Scene>;
53
+ protected abstract buildScene(sceneEngine: SceneEngine): Promise<Scene>;
56
54
  /**
57
55
  * Dispose of this level's resources
58
56
  */
@@ -6,7 +6,7 @@ export declare class SceneEngine {
6
6
  private _engine;
7
7
  private _physics;
8
8
  private _log;
9
- constructor(canvas: GameCanvas, engine: AbstractEngine, physics: HavokPlugin, logger?: LoggingUtility);
9
+ constructor(canvas: GameCanvas, engine: AbstractEngine, physics: HavokPlugin, logger: LoggingUtility);
10
10
  /**
11
11
  * Creates a new scene with physics enabled
12
12
  * @returns A new Scene instance with physics enabled
@@ -50,7 +50,7 @@ export declare class SceneEngine {
50
50
  */
51
51
  createPointLight(name: string, position: Vector3, scene: Scene, intensity?: number): PointLight;
52
52
  /**
53
- * Creates a spot light (flashlight-like lighting)
53
+ * Creates a spotlight (flashlight-like lighting)
54
54
  * @param name - The name for the light
55
55
  * @param position - The position of the light
56
56
  * @param direction - The direction of the light
@@ -138,21 +138,20 @@ export declare class SceneEngine {
138
138
  }): Sound;
139
139
  /**
140
140
  * Loads a 3D model/asset from a file
141
- * @param rootUrl - The root URL where the file is located
142
141
  * @param sceneFilename - The filename of the scene file
143
142
  * @param scene - The scene to load the model into
144
143
  * @returns Promise that resolves with the loaded AssetContainer
145
144
  */
146
- loadModel(rootUrl: string, sceneFilename: string, scene: Scene): Promise<AssetContainer>;
145
+ loadModel(sceneFilename: string, scene: Scene): Promise<AssetContainer>;
147
146
  /**
148
147
  * Imports meshes from a file
149
148
  * @param meshNames - Array of mesh names to import (empty array imports all)
150
- * @param rootUrl - The root URL where the file is located
151
149
  * @param sceneFilename - The filename of the scene file
152
150
  * @param scene - The scene to import the meshes into
151
+ *
153
152
  * @returns Promise that resolves with the import result
154
153
  */
155
- importMeshes(meshNames: string[], rootUrl: string, sceneFilename: string, scene: Scene): Promise<{
154
+ importMeshes(meshNames: string[], sceneFilename: string, scene: Scene): Promise<{
156
155
  meshes: AbstractMesh[];
157
156
  particleSystems: any[];
158
157
  skeletons: any[];
@@ -14,31 +14,55 @@ export declare class LevelManager {
14
14
  private _registeredLevels;
15
15
  /** The currently active level */
16
16
  private _currentLevel;
17
+ /**
18
+ * Gets the currently active level
19
+ */
20
+ get currentLevel(): Level | null;
17
21
  constructor(eventBus: GameEventBus, sceneEngine: SceneEngine, logger?: LoggingUtility);
18
22
  /**
19
23
  * Handles level events from the event bus
20
24
  */
21
25
  private _handleLevelEvent;
26
+ /**
27
+ * Gets a loaded level by name
28
+ */
29
+ getLevel(name: string): Level | null;
22
30
  /**
23
31
  * Registers a level class that can be instantiated later
24
- * @param name - The name to register the level under
25
32
  * @param level - The level class instance
26
33
  */
27
- registerLevel(name: string, level: Level): void;
34
+ registerLevel(level: Level): void;
28
35
  /**
29
- * Loads and activates a level by name
36
+ * Loads a level. The level must already be registered.
37
+ *
30
38
  * @param levelName - The name of the level to load
39
+ *
31
40
  * @returns Promise that resolves when the level is loaded
32
41
  */
33
42
  loadLevel(levelName: string): Promise<void>;
34
43
  /**
35
- * Gets the currently active level
44
+ * Loads a level. The `Level` instance will be registered automatically.
45
+ * @param level - The Level instance to load
46
+ *
47
+ * @return Promise that resolves when the level is loaded
36
48
  */
37
- get currentLevel(): Level | null;
49
+ loadLevel(level: Level): Promise<void>;
38
50
  /**
39
- * Gets a loaded level by name
51
+ * Activates a level by name, loading it if necessary. The level must already be registered.
52
+ *
53
+ * @param levelName - The name of the level to activate
54
+ *
55
+ * @returns Promise that resolves when the level is activated.
40
56
  */
41
- getLevel(name: string): Level | null;
57
+ activateLevel(levelName: string): Promise<void>;
58
+ /**
59
+ * Activates a level, loading it if necessary. The `Level` instance will be registered automatically.
60
+ *
61
+ * @param level - The Level instance to activate
62
+ *
63
+ * @returns Promise that resolves when the level is activated.
64
+ */
65
+ activateLevel(level: Level): Promise<void>;
42
66
  /**
43
67
  * Unloads a level and disposes its resources
44
68
  */
package/dist/sage.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GameCanvas, RenderEngineOptions, SageOptions } from "./interfaces/game.d.ts";
2
2
  import { SkewedAspectGameEngine } from "./classes/gameEngine.d.ts";
3
3
  import { GameEventBus } from "./classes/eventBus.d.ts";
4
+ import { SceneEngine } from "./engines/scene.d.ts";
4
5
  import { GameEntityDefinition } from "./interfaces/entity.d.ts";
5
6
  /**
6
7
  * Creates an instance of SkewedAspectGameEngine.
@@ -17,7 +18,7 @@ export * from "./interfaces/entity.d.ts";
17
18
  export * from "./interfaces/game.d.ts";
18
19
  export * from "./interfaces/input.d.ts";
19
20
  export * from "./interfaces/logger.d.ts";
20
- export { GameEventBus, SkewedAspectGameEngine };
21
+ export { GameEventBus, SkewedAspectGameEngine, SceneEngine };
21
22
  export * from "./classes/eventBus.d.ts";
22
23
  export * from "./classes/entity.d.ts";
23
24
  export * from "./classes/level.d.ts";