@defold-typescript/types 0.5.4 → 0.6.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.
- package/api-targets.json +1 -1
- package/generated/b2d.d.ts +3 -0
- package/generated/buffer.d.ts +44 -38
- package/generated/builtin-messages.d.ts +1 -1
- package/generated/camera.d.ts +3 -0
- package/generated/collectionfactory.d.ts +47 -40
- package/generated/collectionproxy.d.ts +23 -18
- package/generated/crash.d.ts +3 -0
- package/generated/factory.d.ts +32 -24
- package/generated/go.d.ts +293 -293
- package/generated/graphics.d.ts +3 -0
- package/generated/gui.d.ts +303 -283
- package/generated/http.d.ts +26 -16
- package/generated/iac.d.ts +3 -0
- package/generated/iap.d.ts +6 -3
- package/generated/image.d.ts +30 -26
- package/generated/json.d.ts +36 -32
- package/generated/kinds/gui-script.d.ts +7 -5
- package/generated/kinds/render-script.d.ts +7 -5
- package/generated/kinds/script.d.ts +7 -5
- package/generated/label.d.ts +16 -9
- package/generated/liveupdate.d.ts +29 -26
- package/generated/model.d.ts +57 -45
- package/generated/msg.d.ts +12 -9
- package/generated/particlefx.d.ts +50 -34
- package/generated/physics.d.ts +153 -133
- package/generated/profiler.d.ts +45 -41
- package/generated/push.d.ts +5 -2
- package/generated/render.d.ts +410 -349
- package/generated/resource.d.ts +619 -572
- package/generated/socket.d.ts +49 -33
- package/generated/sound.d.ts +83 -72
- package/generated/sprite.d.ts +36 -32
- package/generated/sys.d.ts +198 -189
- package/generated/tilemap.d.ts +43 -39
- package/generated/timer.d.ts +42 -36
- package/generated/vmath.d.ts +254 -229
- package/generated/webview.d.ts +3 -0
- package/generated/window.d.ts +23 -17
- package/generated/zlib.d.ts +15 -12
- package/index.d.ts +3 -1
- package/package.json +6 -2
- package/scripts/example-store-io.ts +18 -0
- package/scripts/fidelity-audit.ts +61 -1
- package/scripts/fidelity-baseline.json +10 -10
- package/scripts/ref-doc-delta.ts +143 -0
- package/scripts/regen.ts +23 -10
- package/src/core-types.ts +14 -0
- package/src/doc-comment.ts +2 -1
- package/src/emit-dts.ts +238 -18
- package/src/engine-globals.d.ts +2 -0
- package/src/example-store.ts +44 -0
- package/src/go-overloads.d.ts +73 -0
- package/src/index.ts +5 -0
- package/src/lifecycle.ts +157 -16
- package/src/message-dispatch.d.ts +21 -0
- package/src/message-guard.d.ts +19 -0
- package/src/msg-overloads.d.ts +20 -0
- package/src/publish-dts.ts +1 -1
package/api-targets.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"namespace": "go",
|
|
28
28
|
"fixture": "go_doc.json",
|
|
29
29
|
"outFile": "go.d.ts",
|
|
30
|
-
"skipFunctions": ["get", "set"]
|
|
30
|
+
"skipFunctions": ["get", "set", "property"]
|
|
31
31
|
},
|
|
32
32
|
{ "namespace": "graphics", "fixture": "graphics_doc.json", "outFile": "graphics.d.ts" },
|
|
33
33
|
{ "namespace": "gui", "fixture": "gui_doc.json", "outFile": "gui.d.ts" },
|
package/generated/b2d.d.ts
CHANGED
package/generated/buffer.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import type { Hash, Opaque } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for manipulating buffers and streams
|
|
7
|
+
*/
|
|
5
8
|
namespace buffer {
|
|
6
9
|
/**
|
|
7
10
|
* Float, single precision, 4 bytes
|
|
@@ -51,13 +54,13 @@ declare global {
|
|
|
51
54
|
* @param srcoffset - the offset to start copying data from
|
|
52
55
|
* @param count - the number of elements to copy
|
|
53
56
|
* @example
|
|
54
|
-
* ```
|
|
55
|
-
* How to copy elements (e.g. vertices) from one buffer to another
|
|
56
|
-
*
|
|
57
|
-
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0,
|
|
57
|
+
* ```ts
|
|
58
|
+
* // How to copy elements (e.g. vertices) from one buffer to another
|
|
59
|
+
* // copy entire buffer
|
|
60
|
+
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, srcbuffer.length);
|
|
58
61
|
*
|
|
59
|
-
*
|
|
60
|
-
* buffer.copy_buffer(dstbuffer, 0, srcbuffer,
|
|
62
|
+
* // copy last 10 elements to the front of another buffer
|
|
63
|
+
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, srcbuffer.length - 10, 10);
|
|
61
64
|
* ```
|
|
62
65
|
*/
|
|
63
66
|
function copy_buffer(dst: Opaque<"buffer">, dstoffset: number, src: Opaque<"buffer">, srcoffset: number, count: number): void;
|
|
@@ -72,12 +75,12 @@ declare global {
|
|
|
72
75
|
* @param srcoffset - the offset to start copying data from (measured in value type)
|
|
73
76
|
* @param count - the number of values to copy (measured in value type)
|
|
74
77
|
* @example
|
|
75
|
-
* ```
|
|
76
|
-
* How to update a texture of a sprite:
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* buffer.copy_stream(dststream, 0, srcstream, 0,
|
|
78
|
+
* ```ts
|
|
79
|
+
* // How to update a texture of a sprite:
|
|
80
|
+
* // copy entire stream
|
|
81
|
+
* const srcstream = buffer.get_stream(srcbuffer, hash("xyz"));
|
|
82
|
+
* const dststream = buffer.get_stream(dstbuffer, hash("xyz"));
|
|
83
|
+
* buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);
|
|
81
84
|
* ```
|
|
82
85
|
*/
|
|
83
86
|
function copy_stream(dst: Opaque<"bufferstream">, dstoffset: number, src: Opaque<"bufferstream">, srcoffset: number, count: number): void;
|
|
@@ -94,21 +97,24 @@ declare global {
|
|
|
94
97
|
* - number `count`: The number of values each element should hold
|
|
95
98
|
* @returns the new buffer
|
|
96
99
|
* @example
|
|
97
|
-
* ```
|
|
98
|
-
* How to create and initialize a buffer
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
100
|
+
* ```ts
|
|
101
|
+
* // How to create and initialize a buffer
|
|
102
|
+
* export default defineScript({
|
|
103
|
+
* init(self) {
|
|
104
|
+
* const size = 128;
|
|
105
|
+
* self.image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
106
|
+
* self.imagestream = buffer.get_stream(self.image, hash("rgb"));
|
|
103
107
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
108
|
+
* for (let y = 0; y < self.height; y++) {
|
|
109
|
+
* for (let x = 0; x < self.width; x++) {
|
|
110
|
+
* const index = y * self.width * 3 + x * 3;
|
|
111
|
+
* self.imagestream[index + 0] = self.r;
|
|
112
|
+
* self.imagestream[index + 1] = self.g;
|
|
113
|
+
* self.imagestream[index + 2] = self.b;
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* },
|
|
117
|
+
* });
|
|
112
118
|
* ```
|
|
113
119
|
*/
|
|
114
120
|
function create(element_count: number, declaration: { name?: Hash | string; type?: Opaque<"constant">; count?: number }): Opaque<"buffer">;
|
|
@@ -126,11 +132,11 @@ declare global {
|
|
|
126
132
|
* @param buf - the buffer to get the metadata from
|
|
127
133
|
* @param metadata_name - name of the metadata entry
|
|
128
134
|
* @example
|
|
129
|
-
* ```
|
|
130
|
-
* How to get a metadata entry from a buffer
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* if
|
|
135
|
+
* ```ts
|
|
136
|
+
* // How to get a metadata entry from a buffer
|
|
137
|
+
* // retrieve a metadata entry named "somefloats" and its numeric type
|
|
138
|
+
* const [values, type] = buffer.get_metadata(buf, hash("somefloats"));
|
|
139
|
+
* if (values) print(`${values.length} values in 'somefloats'`);
|
|
134
140
|
* ```
|
|
135
141
|
*/
|
|
136
142
|
function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | unknown, Opaque<"constant"> | unknown]>;
|
|
@@ -151,13 +157,13 @@ declare global {
|
|
|
151
157
|
* @param values - actual metadata, an array of numeric values
|
|
152
158
|
* @param value_type - type of values when stored
|
|
153
159
|
* @example
|
|
154
|
-
* ```
|
|
155
|
-
* How to set a metadata entry on a buffer
|
|
156
|
-
*
|
|
157
|
-
* buffer.set_metadata(buf, hash("somefloats"),
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* buffer.set_metadata(buf, hash("somefloats"),
|
|
160
|
+
* ```ts
|
|
161
|
+
* // How to set a metadata entry on a buffer
|
|
162
|
+
* // create a new metadata entry with three floats
|
|
163
|
+
* buffer.set_metadata(buf, hash("somefloats"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);
|
|
164
|
+
* // ...
|
|
165
|
+
* // update to a new set of values
|
|
166
|
+
* buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
|
|
161
167
|
* ```
|
|
162
168
|
*/
|
|
163
169
|
function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type: Opaque<"constant">): void;
|
|
@@ -19,7 +19,7 @@ declare global {
|
|
|
19
19
|
load: Record<string, never>;
|
|
20
20
|
model_animation_done: { animation_id: Hash; playback: number };
|
|
21
21
|
play_animation: { id: Hash };
|
|
22
|
-
play_sound: { delay?: number; gain?: number; play_id?: number };
|
|
22
|
+
play_sound: { delay?: number; gain?: number; play_id?: number; start_time?: number; start_frame?: number };
|
|
23
23
|
proxy_loaded: Record<string, never>;
|
|
24
24
|
proxy_unloaded: Record<string, never>;
|
|
25
25
|
ray_cast_missed: { group: Hash; request_id: number };
|
package/generated/camera.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import type { Hash, Opaque, Quaternion, Url, Vector3 } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for controlling collection factory components which are
|
|
7
|
+
* used to dynamically spawn collections into the runtime.
|
|
8
|
+
*/
|
|
5
9
|
namespace collectionfactory {
|
|
6
10
|
/**
|
|
7
11
|
* loaded
|
|
@@ -38,40 +42,43 @@ declare global {
|
|
|
38
42
|
* @param scale - uniform scaling to apply to the newly spawned collection (must be greater than 0).
|
|
39
43
|
* @returns a table mapping the id:s from the collection to the new instance id:s
|
|
40
44
|
* @example
|
|
41
|
-
* ```
|
|
42
|
-
* How to spawn a collection of game objects:
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* // How to spawn a collection of game objects:
|
|
47
|
+
* export default defineScript({
|
|
48
|
+
* init(self) {
|
|
49
|
+
* // Spawn a small group of enemies.
|
|
50
|
+
* const pos = vmath.vector3(100, 12.5, 0);
|
|
51
|
+
* const rot = vmath.quat_rotation_z(Math.PI / 2);
|
|
52
|
+
* const scale = 0.5;
|
|
53
|
+
* const props = {
|
|
54
|
+
* [hash("/enemy_leader")]: { health: 1000.0 },
|
|
55
|
+
* [hash("/enemy_1")]: { health: 200.0 },
|
|
56
|
+
* [hash("/enemy_2")]: { health: 400.0, color: hash("green") },
|
|
57
|
+
* };
|
|
52
58
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
59
|
+
* self.enemy_ids = collectionfactory.create("#enemyfactory", pos, rot, props, scale);
|
|
60
|
+
* // enemy_ids now map to the spawned instance ids:
|
|
61
|
+
* //
|
|
62
|
+
* // pprint(self.enemy_ids)
|
|
63
|
+
* //
|
|
64
|
+
* // DEBUG:SCRIPT:
|
|
65
|
+
* // {
|
|
66
|
+
* // hash: [/enemy_leader] = hash: [/collection0/enemy_leader],
|
|
67
|
+
* // hash: [/enemy_1] = hash: [/collection0/enemy_1],
|
|
68
|
+
* // hash: [/enemy_2] = hash: [/collection0/enemy_2]
|
|
69
|
+
* // }
|
|
64
70
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
71
|
+
* // Send "attack" message to the leader. First look up its instance id.
|
|
72
|
+
* const leader_id = self.enemy_ids[hash("/enemy_leader")];
|
|
73
|
+
* msg.post(leader_id, "attack");
|
|
74
|
+
* },
|
|
75
|
+
* });
|
|
69
76
|
*
|
|
70
|
-
* How to delete a spawned collection:
|
|
71
|
-
* go.delete(self.enemy_ids)
|
|
77
|
+
* // How to delete a spawned collection:
|
|
78
|
+
* go.delete(self.enemy_ids);
|
|
72
79
|
* ```
|
|
73
80
|
*/
|
|
74
|
-
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3):
|
|
81
|
+
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): LuaMap<Hash, Hash>;
|
|
75
82
|
/**
|
|
76
83
|
* This returns status of the collection factory.
|
|
77
84
|
* Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
|
|
@@ -96,9 +103,9 @@ declare global {
|
|
|
96
103
|
* `result`
|
|
97
104
|
* boolean True if resource were loaded successfully
|
|
98
105
|
* @example
|
|
99
|
-
* ```
|
|
100
|
-
* How to load resources of a collection factory prototype.
|
|
101
|
-
* collectionfactory.load("#factory",
|
|
106
|
+
* ```ts
|
|
107
|
+
* // How to load resources of a collection factory prototype.
|
|
108
|
+
* collectionfactory.load("#factory", (self, url, result) => {});
|
|
102
109
|
* ```
|
|
103
110
|
*/
|
|
104
111
|
function load(url?: string | Hash | Url, complete_function?: (self: unknown, url: unknown, result: unknown) => void): void;
|
|
@@ -109,11 +116,11 @@ declare global {
|
|
|
109
116
|
* @param url - the collection factory component
|
|
110
117
|
* @param prototype - the path to the new prototype, or `nil`
|
|
111
118
|
* @example
|
|
112
|
-
* ```
|
|
113
|
-
* How to unload the previous
|
|
114
|
-
* collectionfactory.unload("#factory")
|
|
115
|
-
* collectionfactory.set_prototype("#factory", "/main/levels/level1.collectionc")
|
|
116
|
-
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* // How to unload the previous prototype's resources, and then spawn a new collection:
|
|
121
|
+
* collectionfactory.unload("#factory"); // unload the previous resources
|
|
122
|
+
* collectionfactory.set_prototype("#factory", "/main/levels/level1.collectionc");
|
|
123
|
+
* const ids = collectionfactory.create("#factory", go.get_world_position(), vmath.quat());
|
|
117
124
|
* ```
|
|
118
125
|
*/
|
|
119
126
|
function set_prototype(url?: string | Hash | Url, prototype?: string): void;
|
|
@@ -123,9 +130,9 @@ declare global {
|
|
|
123
130
|
*
|
|
124
131
|
* @param url - the collection factory component to unload
|
|
125
132
|
* @example
|
|
126
|
-
* ```
|
|
127
|
-
* How to unload resources of a collection factory prototype loaded with collectionfactory.load
|
|
128
|
-
* collectionfactory.unload("#factory")
|
|
133
|
+
* ```ts
|
|
134
|
+
* // How to unload resources of a collection factory prototype loaded with collectionfactory.load:
|
|
135
|
+
* collectionfactory.unload("#factory");
|
|
129
136
|
* ```
|
|
130
137
|
*/
|
|
131
138
|
function unload(url?: string | Hash | Url): void;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import type { Hash, Url } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Messages for controlling and interacting with collection proxies
|
|
7
|
+
* which are used to dynamically load collections into the runtime.
|
|
8
|
+
*/
|
|
5
9
|
namespace collectionproxy {
|
|
6
10
|
/**
|
|
7
11
|
* It's impossible to change the collection if the collection is already loaded.
|
|
@@ -27,13 +31,13 @@ declare global {
|
|
|
27
31
|
* @returns the resources, or an empty list if the
|
|
28
32
|
* collection was not excluded.
|
|
29
33
|
* @example
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* function print_resources(self, cproxy) {
|
|
36
|
+
* const resources = collectionproxy.get_resources(cproxy);
|
|
37
|
+
* for (const v of resources) {
|
|
38
|
+
* print(`Resource: ${v}`);
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
37
41
|
* ```
|
|
38
42
|
*/
|
|
39
43
|
function get_resources(collectionproxy: Url): Record<string | number, unknown>;
|
|
@@ -46,17 +50,18 @@ declare global {
|
|
|
46
50
|
* @param url - the collection proxy component
|
|
47
51
|
* @param prototype - the path to the new collection, or `nil`
|
|
48
52
|
* @example
|
|
49
|
-
* ```
|
|
50
|
-
* The example
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* // The example assumes the script belongs to an instance with a
|
|
55
|
+
* // collection-proxy-component with id "proxy".
|
|
56
|
+
* const [ok, error] = collectionproxy.set_collection("/go#collectionproxy", "/LU/3.collectionc");
|
|
57
|
+
* if (ok) {
|
|
58
|
+
* print("The collection has been changed to /LU/3.collectionc");
|
|
59
|
+
* } else {
|
|
60
|
+
* print("Error changing collection to /LU/3.collectionc ", error);
|
|
61
|
+
* }
|
|
62
|
+
* msg.post("/go#collectionproxy", "load");
|
|
63
|
+
* msg.post("/go#collectionproxy", "init");
|
|
64
|
+
* msg.post("/go#collectionproxy", "enable");
|
|
60
65
|
* ```
|
|
61
66
|
*/
|
|
62
67
|
function set_collection(url?: string | Hash | Url, prototype?: string): LuaMultiReturn<[boolean, number]>;
|
package/generated/crash.d.ts
CHANGED
package/generated/factory.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import type { Hash, Opaque, Quaternion, Url, Vector3 } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions for controlling factory components which are used to
|
|
7
|
+
* dynamically spawn game objects into the runtime.
|
|
8
|
+
*/
|
|
5
9
|
namespace factory {
|
|
6
10
|
/**
|
|
7
11
|
* loaded
|
|
@@ -30,21 +34,25 @@ declare global {
|
|
|
30
34
|
* @param scale - the scale of the new game object (must be greater than 0), the scale of the game object containing the factory is used by default, or if the value is `nil`
|
|
31
35
|
* @returns the global id of the spawned game object
|
|
32
36
|
* @example
|
|
33
|
-
* ```
|
|
34
|
-
* How to create a new game object:
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* // How to create a new game object:
|
|
39
|
+
* export default defineScript({
|
|
40
|
+
* init(self) {
|
|
41
|
+
* // create a new game object and provide property values
|
|
42
|
+
* self.my_created_object = factory.create("#factory", undefined, undefined, { my_value: 1 });
|
|
43
|
+
* // communicate with the object
|
|
44
|
+
* msg.post(self.my_created_object, "hello");
|
|
45
|
+
* },
|
|
46
|
+
* });
|
|
41
47
|
*
|
|
42
|
-
* And then let the new game object have a script attached:
|
|
43
|
-
* go.property("my_value", 0)
|
|
48
|
+
* // And then let the new game object have a script attached:
|
|
49
|
+
* go.property("my_value", 0);
|
|
44
50
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
51
|
+
* export default defineScript({
|
|
52
|
+
* init(self) {
|
|
53
|
+
* // do something with self.my_value which is now one
|
|
54
|
+
* },
|
|
55
|
+
* });
|
|
48
56
|
* ```
|
|
49
57
|
*/
|
|
50
58
|
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash;
|
|
@@ -73,9 +81,9 @@ declare global {
|
|
|
73
81
|
* `result`
|
|
74
82
|
* boolean True if resources were loaded successfully
|
|
75
83
|
* @example
|
|
76
|
-
* ```
|
|
77
|
-
* How to load resources of a factory prototype.
|
|
78
|
-
* factory.load("#factory",
|
|
84
|
+
* ```ts
|
|
85
|
+
* // How to load resources of a factory prototype.
|
|
86
|
+
* factory.load("#factory", (self, url, result) => {});
|
|
79
87
|
* ```
|
|
80
88
|
*/
|
|
81
89
|
function load(url?: string | Hash | Url, complete_function?: (self: unknown, url: unknown, result: unknown) => void): void;
|
|
@@ -85,11 +93,11 @@ declare global {
|
|
|
85
93
|
* @param url - the factory component
|
|
86
94
|
* @param prototype - the path to the new prototype, or `nil`
|
|
87
95
|
* @example
|
|
88
|
-
* ```
|
|
89
|
-
* How to unload the previous
|
|
90
|
-
* factory.unload("#factory")
|
|
91
|
-
* factory.set_prototype("#factory", "/main/levels/enemyA.goc")
|
|
92
|
-
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* // How to unload the previous prototype's resources, and then spawn a new game object:
|
|
98
|
+
* factory.unload("#factory"); // unload the previous resources
|
|
99
|
+
* factory.set_prototype("#factory", "/main/levels/enemyA.goc");
|
|
100
|
+
* const id = factory.create("#factory", go.get_world_position(), vmath.quat());
|
|
93
101
|
* ```
|
|
94
102
|
*/
|
|
95
103
|
function set_prototype(url?: string | Hash | Url, prototype?: string): void;
|
|
@@ -99,9 +107,9 @@ declare global {
|
|
|
99
107
|
*
|
|
100
108
|
* @param url - the factory component to unload
|
|
101
109
|
* @example
|
|
102
|
-
* ```
|
|
103
|
-
* How to unload resources of a factory prototype loaded with factory.load
|
|
104
|
-
* factory.unload("#factory")
|
|
110
|
+
* ```ts
|
|
111
|
+
* // How to unload resources of a factory prototype loaded with factory.load:
|
|
112
|
+
* factory.unload("#factory");
|
|
105
113
|
* ```
|
|
106
114
|
*/
|
|
107
115
|
function unload(url?: string | Hash | Url): void;
|