@polyzone/core
Version:
PolyZone core API
48 lines (47 loc) • 1.67 kB
TypeScript
import type { GameObjectComponent } from "./GameObjectComponent";
import type { Transform } from "./Transform";
import type { Vector3 } from "../util/Vector3";
/**
* An object that lives within the game world.
* Components are used to build up behaviours whereas a GameObject by itself does nothing.
*/
export declare abstract class GameObject {
/**
* Add a component to this GameObject
*/
abstract addComponent(component: GameObjectComponent): void;
/**
* Remove a component from this GameObject.
* @param componentId The ID of the component to remove.
*/
abstract removeComponent(componentId: string): void;
/**
* Called once, after the game object is added to the world.
* When a scene is loaded, all objects are loaded before this is called.
*/
abstract init(): void;
/**
* Called once per frame.
* @param deltaTime Time (in seconds) since the last frame.
*/
abstract update(deltaTime: number): void;
/**
* Destroy this GameObject, removing it (and all of its components)
* from the World.
*/
abstract destroy(): void;
/**
* Called when this GameObject is destroyed.
*/
abstract onDestroy(): void;
/** Unique identifier for this GameObject */
abstract get id(): string;
/** Human-friendly name for this object */
abstract get name(): string;
/** Components attached to this GameObject */
abstract get components(): GameObjectComponent[];
/** Position, rotation, scale, hierarchy data */
abstract get transform(): Transform;
abstract get position(): Vector3;
abstract set position(value: Vector3);
}