Skip to content

Instantiable Constructors

Mtax edited this page Mar 27, 2025 · 1 revision

Description

Instantiable Constructors are Script Assets, with code configuring Blueprint Objects, managing their Instances and containing Event Methods they are supplied with. Each Instantiable Constructor either is or inherits the Instance constructor, which contains primary properties and methods used in their operations, each described below.

Each Instantiable Constructor can only have one Instance instantiated at a time. To operate multiple Instances, it needs to be constructed and instantiated again.

Specification

Destruction
Elements
destroyInstance()
None

Properties

Name
Type
Default
Modifiable
Description
object
Object
Yes
An Object Asset, the Instance of which will be created and operated by this constructor.
instance
undefined
No
Reference to the Instance operated by this constructor after it is created.
priority
{int}
10
Yes
The order in which repeatable events are executed by the Event Queue. The lower the number, the earlier it is executed during appropriate Event. The number 0 is implied to be the lowest value applicable and hence, the highest priority.
stepEventQueue
Yes
The Priority Queue of the Event Queue into which the Event Method of the Step Event will be submitted, causing it to execute either only after a frame cycle is finished or every frame.

Methods

Name
Type
Arguments
Returns
Description
Various Event Methods
createEvent: {any}...
Other: None.
Not applicable.
The function to execute by the Instance of object during its Event. This execution will be attempted every time that Event executes, so it should refer to an empty function when nothing is intended to be executed.
getBaseInstanceData()
None.
Returns a struct containing properties added or Built-In Instance Variables configured in the Instance created when createInstance() is called. At minimum, this struct must contain the reference to this constructor in its base property.
createInstance()
argument? {any|any[]}
location? {Vector2}
added_data?... {struct}
{handle:instance} | On error: {noone}
Instantiates this constructor by creating an Instance of object at specified location with variables added or configured from any number of specified structs.
destroyInstance()
None.
Uses Event Queue.instanceLayer to destroy the Instance referred to by the instance property and sets it to undefined.

Implementing additional Instantiable Constructors

1. Create a new Script Asset and name it using the same name pattern as Blueprint Object that will use it.
2. In the Script Asset code, declare a constructor that inherits Instance constructor.
3. Implement the Blueprint Object and declare a static object property with a value referring to its Object Asset.
4. Add static methods with names of events that its Blueprint Object will operate, that were not inherited from Instance, assigning their default value to null.

After performing above steps, the Instantiable Constructor is functional and can be configured further, such a by declaring modifiable properties with changed values or declaring a static getBaseInstanceData() method, which would add or change the variables of the Instance. Then, it can be inherited by Constructors inheriting Instantiable Constructors.

Clone this wiki locally