Перейти к основному содержанию

GameObject <T>

Class used to create and manipulate game objects. Game objects are Updatables that are being saved between game launches.

Index

Constructors

constructor

  • new GameObject<T>(type: string, prototype: T): GameObject<T>
  • Constructs a new GameObject with given params.


    Type parameters

    Parameters

    • type: string

      unique name for the game object type. Use package-like names to ensure your game object name is unique

    • prototype: T

    Returns GameObject<T>

Properties

readonlyPrototype
internal

Prototype: T

Prototype from which instantiated objects are created.

readonlygameobjectName

gameobjectName: string

Same as GameObject.originalName, but with suffix which are used for object saving to be unique.

readonlyisDeployed

isDeployed: boolean

true if current object was deployed or added directly.

readonlyisInstance

isInstance: boolean

true if current object is instance, prototype otherwise.

readonlyoriginalName

originalName: string

Original value passed to GameObject.constructor as type.

readonlysaverId
internal

saverId: number

Used when Saver.registerObject calling inside.

Methods

deploy

  • Creates a new game object with specified params and registers it for saving and as an Updatable.


    Parameters

    Returns GameObject<T>

    Instantiated game object.

destroy

  • destroy(): void
  • Destroys current game object.


    Returns void

instantiate

  • internal

    Creates a new game object without deploying it; you are shouldn't do it normally, it was called by GameObject.deploy.


    Returns GameObject<T>

    Instantiated game object.