the-world-engine
Version:
three.js based, unity like game engine for browser
111 lines (110 loc) • 3.61 kB
TypeScript
import type { EngineGlobalObject } from "../EngineGlobalObject";
import type { Component } from "./Component";
import type { ComponentConstructor } from "./ComponentConstructor";
import type { GameObjectBuilder } from "./GameObjectBuilder";
import { Transform } from "./Transform";
/**
* base class for all entities in scenes
* do not drive this class
*/
export declare class GameObject {
private readonly _engineGlobalObject;
private readonly _instanceId;
private _activeInHierarchy;
private _activeSelf;
private readonly _transform;
/**
* add a child game object
* @param gameObjectBuilder
*/
addChildFromBuilder(gameObjectBuilder: GameObjectBuilder): GameObject;
private onChangeParent;
/**
* add a component to this game object
* it can be failed depending on the disallowMultipleComponent or requiredComponent option
* @param componentCtor
* @returns if success, return the component instance
*/
addComponent<T extends Component>(componentCtor: ComponentConstructor<T>): T | null;
/**
* get component of componentCtor: ComponentConstructor<T> in the GameObject
* @param componentCtor
* @returns if success, return the component instance
*/
getComponent<T extends Component>(componentCtor: ComponentConstructor<T>): T | null;
/**
* get all components in the GameObject
*/
getComponents(): Component[];
/**
* get components of componentCtor: ComponentConstructor<T> in the GameObject
* @param componentCtor
* @returns
*/
getComponents<T extends Component>(componentCtor: ComponentConstructor<T>): T[];
/**
* returns the component of componentCtor: ComponentConstructor<T> in the GameObject or any of its children using depth first search
* @param componentCtor
* @returns
*/
getComponentInChildren<T extends Component>(componentCtor: ComponentConstructor<T>): T | null;
/**
* returns all components in the GameObject or any of its children using depth first search
*/
getComponentsInChildren(): Component[];
/**
* returns all components of componentCtor: ComponentConstructor<T> in the GameObject or any of its children using depth first search
* @param componentCtor
*/
getComponentsInChildren<T extends Component>(componentCtor: ComponentConstructor<T>): T[];
private _destroyed;
/**
* destroy the GameObject
*/
destroy(): void;
private static destroyRecursively;
private destroyEventProcess;
/**
* global engine object
*/
get engine(): EngineGlobalObject;
/**
* defines whether the GameObject is active in the Scene
*/
get activeInHierarchy(): boolean;
private set activeInHierarchy(value);
private setActiveInHierarchyWithEvent;
/**
* defines whether the GameObject is active in the Scene
*/
get activeSelf(): boolean;
/**
* defines whether the GameObject is active in the Scene
*/
set activeSelf(value: boolean);
/**
* get transform of the GameObject
*/
get transform(): Transform;
/**
* get name of the GameObject
*/
get name(): string;
/**
* set name of the GameObject
*/
set name(value: string);
/**
* get instance id of the GameObject
*/
get instanceId(): number;
/**
* if instantiate process is finished, this will be true
*/
get initialized(): boolean;
/**
* does the gameobject exist?
*/
get exists(): boolean;
private checkGameObjectIsExist;
}