@cyclonium/core 0.0.100
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/lib/2d/transform-2d-component.d.ts +67 -0
- package/lib/2d/transform-2d-component.js +206 -0
- package/lib/decorator/legacy/apply-legacy-decorators.d.ts +5 -0
- package/lib/decorator/legacy/apply-legacy-decorators.js +12 -0
- package/lib/decorator/legacy/editable/common.d.ts +3 -0
- package/lib/decorator/legacy/editable/common.js +16 -0
- package/lib/decorator/legacy/editable/editable.d.ts +23 -0
- package/lib/decorator/legacy/editable/editable.js +61 -0
- package/lib/decorator/legacy/legacy-component-decorator.d.ts +11 -0
- package/lib/decorator/legacy/legacy-component-decorator.js +91 -0
- package/lib/decorator/legacy/legacy-decorator.d.ts +3 -0
- package/lib/decorator/legacy/legacy-decorator.js +3 -0
- package/lib/decorator/legacy/legacy-general-decorator.d.ts +32 -0
- package/lib/decorator/legacy/legacy-general-decorator.js +94 -0
- package/lib/decorator/legacy/utils.d.ts +6 -0
- package/lib/decorator/legacy/utils.js +17 -0
- package/lib/export/2d.d.ts +2 -0
- package/lib/export/2d.js +2 -0
- package/lib/export/framework.d.ts +4 -0
- package/lib/export/framework.js +4 -0
- package/lib/export/internal.d.ts +2 -0
- package/lib/export/internal.js +2 -0
- package/lib/export/legacy-decorator.d.ts +4 -0
- package/lib/export/legacy-decorator.js +4 -0
- package/lib/export/log.d.ts +2 -0
- package/lib/export/log.js +2 -0
- package/lib/export/math/bounds-2d.d.ts +2 -0
- package/lib/export/math/bounds-2d.js +2 -0
- package/lib/export/math/geometry.d.ts +2 -0
- package/lib/export/math/geometry.js +2 -0
- package/lib/export/math/mat3.d.ts +2 -0
- package/lib/export/math/mat3.js +2 -0
- package/lib/export/math/number.d.ts +2 -0
- package/lib/export/math/number.js +2 -0
- package/lib/export/math/ray.d.ts +2 -0
- package/lib/export/math/ray.js +2 -0
- package/lib/export/math/transform-2d.d.ts +2 -0
- package/lib/export/math/transform-2d.js +2 -0
- package/lib/export/math/trigonometry.d.ts +2 -0
- package/lib/export/math/trigonometry.js +2 -0
- package/lib/export/math/vec2.d.ts +2 -0
- package/lib/export/math/vec2.js +2 -0
- package/lib/export/utils.d.ts +5 -0
- package/lib/export/utils.js +5 -0
- package/lib/framework/component.d.ts +90 -0
- package/lib/framework/component.js +322 -0
- package/lib/framework/coroutine.d.ts +105 -0
- package/lib/framework/coroutine.js +278 -0
- package/lib/framework/execution-order.d.ts +12 -0
- package/lib/framework/execution-order.js +17 -0
- package/lib/framework/tasking.d.ts +17 -0
- package/lib/framework/tasking.js +82 -0
- package/lib/math/bounds-2d.d.ts +2 -0
- package/lib/math/bounds-2d.js +13 -0
- package/lib/math/geometry.d.ts +4 -0
- package/lib/math/geometry.js +19 -0
- package/lib/math/mat3.d.ts +2 -0
- package/lib/math/mat3.js +2 -0
- package/lib/math/number.d.ts +2 -0
- package/lib/math/number.js +2 -0
- package/lib/math/ray.d.ts +12 -0
- package/lib/math/ray.js +26 -0
- package/lib/math/transform-2d.d.ts +2 -0
- package/lib/math/transform-2d.js +2 -0
- package/lib/math/trigonometry.d.ts +2 -0
- package/lib/math/trigonometry.js +2 -0
- package/lib/math/vec2.d.ts +5 -0
- package/lib/math/vec2.js +17 -0
- package/lib/utils/assert.d.ts +5 -0
- package/lib/utils/assert.js +14 -0
- package/lib/utils/enum.d.ts +3 -0
- package/lib/utils/enum.js +15 -0
- package/lib/utils/inheritance.d.ts +2 -0
- package/lib/utils/inheritance.js +5 -0
- package/lib/utils/logger.d.ts +7 -0
- package/lib/utils/logger.js +19 -0
- package/lib/utils/raw.d.ts +6 -0
- package/lib/utils/raw.js +26 -0
- package/package.json +44 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
var CoroutineInstructionType;
|
|
2
|
+
(function (CoroutineInstructionType) {
|
|
3
|
+
CoroutineInstructionType[CoroutineInstructionType["nextFrame"] = 0] = "nextFrame";
|
|
4
|
+
CoroutineInstructionType[CoroutineInstructionType["waitFor"] = 1] = "waitFor";
|
|
5
|
+
CoroutineInstructionType[CoroutineInstructionType["waitUntil"] = 2] = "waitUntil";
|
|
6
|
+
CoroutineInstructionType[CoroutineInstructionType["waitWhile"] = 3] = "waitWhile";
|
|
7
|
+
})(CoroutineInstructionType || (CoroutineInstructionType = {}));
|
|
8
|
+
const NEXT_FRAME_INSTRUCTION = {
|
|
9
|
+
type: CoroutineInstructionType.nextFrame,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resume the coroutine on the next coroutine update.
|
|
13
|
+
* @returns An opaque instruction to yield from a coroutine.
|
|
14
|
+
*/
|
|
15
|
+
export function nextFrame() {
|
|
16
|
+
return NEXT_FRAME_INSTRUCTION;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resume the coroutine after at least the given duration.
|
|
20
|
+
* @param seconds - Duration to wait, in seconds. Must be a non-negative finite number.
|
|
21
|
+
* @returns An opaque instruction to yield from a coroutine.
|
|
22
|
+
*/
|
|
23
|
+
export function waitFor(seconds) {
|
|
24
|
+
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
25
|
+
throw new Error('seconds must be a non-negative finite number.');
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
type: CoroutineInstructionType.waitFor,
|
|
29
|
+
seconds,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resume the coroutine when the predicate becomes true.
|
|
34
|
+
* @param predicate - Function evaluated each coroutine update with the current frame.
|
|
35
|
+
* @returns An opaque instruction to yield from a coroutine.
|
|
36
|
+
*/
|
|
37
|
+
export function waitUntil(predicate) {
|
|
38
|
+
return {
|
|
39
|
+
type: CoroutineInstructionType.waitUntil,
|
|
40
|
+
predicate,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resume the coroutine when the predicate becomes false.
|
|
45
|
+
* @param predicate - Function evaluated each coroutine update with the current frame.
|
|
46
|
+
* @returns An opaque instruction to yield from a coroutine.
|
|
47
|
+
*/
|
|
48
|
+
export function waitWhile(predicate) {
|
|
49
|
+
return {
|
|
50
|
+
type: CoroutineInstructionType.waitWhile,
|
|
51
|
+
predicate,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export class CoroutineRunner {
|
|
55
|
+
start(coroutine, opts) {
|
|
56
|
+
const record = new CoroutineRecord(this, coroutine, opts);
|
|
57
|
+
this._records.push(record);
|
|
58
|
+
record.start();
|
|
59
|
+
this._pruneIfNotDeferred();
|
|
60
|
+
return record;
|
|
61
|
+
}
|
|
62
|
+
update(deltaTime) {
|
|
63
|
+
this._frame++;
|
|
64
|
+
this._deltaTime = deltaTime;
|
|
65
|
+
this._beginPruneDeferral();
|
|
66
|
+
try {
|
|
67
|
+
const count = this._records.length;
|
|
68
|
+
for (let i = 0; i < count; i++) {
|
|
69
|
+
this._records[i].update();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
this._endPruneDeferral();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
stop(handle) {
|
|
77
|
+
stopCoroutine(handle);
|
|
78
|
+
this._pruneIfNotDeferred();
|
|
79
|
+
}
|
|
80
|
+
stopAll() {
|
|
81
|
+
this._beginPruneDeferral();
|
|
82
|
+
try {
|
|
83
|
+
const count = this._records.length;
|
|
84
|
+
for (let i = 0; i < count; i++) {
|
|
85
|
+
this._records[i].stop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
this._endPruneDeferral();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
get frame() {
|
|
93
|
+
return this._frame;
|
|
94
|
+
}
|
|
95
|
+
get deltaTime() {
|
|
96
|
+
return this._deltaTime;
|
|
97
|
+
}
|
|
98
|
+
get empty() {
|
|
99
|
+
return this._records.length === 0;
|
|
100
|
+
}
|
|
101
|
+
_records = [];
|
|
102
|
+
_frame = 0;
|
|
103
|
+
_deltaTime = 0;
|
|
104
|
+
_pruneDeferralDepth = 0;
|
|
105
|
+
_beginPruneDeferral() {
|
|
106
|
+
this._pruneDeferralDepth++;
|
|
107
|
+
}
|
|
108
|
+
_endPruneDeferral() {
|
|
109
|
+
this._pruneDeferralDepth--;
|
|
110
|
+
if (this._pruneDeferralDepth === 0) {
|
|
111
|
+
this._prune();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
_pruneIfNotDeferred() {
|
|
115
|
+
if (this._pruneDeferralDepth === 0) {
|
|
116
|
+
this._prune();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
_prune() {
|
|
120
|
+
this._records = this._records.filter((record) => !record.done);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function stopCoroutine(coroutine) {
|
|
124
|
+
if (coroutine instanceof CoroutineRecord) {
|
|
125
|
+
coroutine.stop();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
throw new Error('Invalid coroutine handle.');
|
|
129
|
+
}
|
|
130
|
+
class CoroutineRecord {
|
|
131
|
+
constructor(runner, coroutine, opts) {
|
|
132
|
+
this._runner = runner;
|
|
133
|
+
this._coroutine = coroutine;
|
|
134
|
+
this._signal = opts?.signal;
|
|
135
|
+
}
|
|
136
|
+
get running() {
|
|
137
|
+
return !this._done && !this._stopping;
|
|
138
|
+
}
|
|
139
|
+
get done() {
|
|
140
|
+
return this._done;
|
|
141
|
+
}
|
|
142
|
+
start() {
|
|
143
|
+
if (this._signal?.aborted) {
|
|
144
|
+
this.stop();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this._addAbortListener();
|
|
148
|
+
this._advance();
|
|
149
|
+
}
|
|
150
|
+
update() {
|
|
151
|
+
if (!this.running || this._yieldedAtFrame >= this._runner.frame) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this._elapsedTime += this._runner.deltaTime;
|
|
155
|
+
this._frame.deltaTime = this._runner.deltaTime;
|
|
156
|
+
this._frame.elapsedTime = this._elapsedTime;
|
|
157
|
+
this._frame.frame = this._runner.frame;
|
|
158
|
+
if (this._canResume(this._frame)) {
|
|
159
|
+
this._advance(this._frame);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
stop() {
|
|
163
|
+
if (this._done) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this._done = true;
|
|
167
|
+
this._removeAbortListener();
|
|
168
|
+
if (this._executing) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this._stopping = true;
|
|
172
|
+
try {
|
|
173
|
+
this._coroutine.return?.(undefined);
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
this._stopping = false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_runner;
|
|
180
|
+
_coroutine;
|
|
181
|
+
_signal;
|
|
182
|
+
_instruction = NEXT_FRAME_INSTRUCTION;
|
|
183
|
+
_frame = {
|
|
184
|
+
deltaTime: 0,
|
|
185
|
+
elapsedTime: 0,
|
|
186
|
+
frame: 0,
|
|
187
|
+
};
|
|
188
|
+
_yieldedAtFrame = 0;
|
|
189
|
+
_remainingSeconds = 0;
|
|
190
|
+
_elapsedTime = 0;
|
|
191
|
+
_done = false;
|
|
192
|
+
_executing = false;
|
|
193
|
+
_stopping = false;
|
|
194
|
+
_advance(frame) {
|
|
195
|
+
let result;
|
|
196
|
+
this._executing = true;
|
|
197
|
+
try {
|
|
198
|
+
result = frame === undefined ? this._coroutine.next() : this._coroutine.next(frame);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
this._done = true;
|
|
202
|
+
this._removeAbortListener();
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
this._executing = false;
|
|
207
|
+
}
|
|
208
|
+
if (this._done) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (result.done === true) {
|
|
212
|
+
this._done = true;
|
|
213
|
+
this._removeAbortListener();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this._setInstruction(result.value);
|
|
217
|
+
}
|
|
218
|
+
_setInstruction(instruction) {
|
|
219
|
+
if (instruction === null || instruction === undefined) {
|
|
220
|
+
this._instruction = NEXT_FRAME_INSTRUCTION;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
switch (instruction.type) {
|
|
224
|
+
case CoroutineInstructionType.nextFrame:
|
|
225
|
+
this._instruction = instruction;
|
|
226
|
+
break;
|
|
227
|
+
case CoroutineInstructionType.waitFor:
|
|
228
|
+
this._instruction = instruction;
|
|
229
|
+
break;
|
|
230
|
+
case CoroutineInstructionType.waitUntil:
|
|
231
|
+
case CoroutineInstructionType.waitWhile:
|
|
232
|
+
this._instruction = instruction;
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
throw new Error('Invalid coroutine instruction.');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
this._yieldedAtFrame = this._runner.frame;
|
|
239
|
+
switch (this._instruction.type) {
|
|
240
|
+
case CoroutineInstructionType.waitFor:
|
|
241
|
+
this._remainingSeconds = this._instruction.seconds;
|
|
242
|
+
break;
|
|
243
|
+
default:
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
_canResume(frame) {
|
|
248
|
+
switch (this._instruction.type) {
|
|
249
|
+
case CoroutineInstructionType.nextFrame:
|
|
250
|
+
return true;
|
|
251
|
+
case CoroutineInstructionType.waitFor:
|
|
252
|
+
this._remainingSeconds -= frame.deltaTime;
|
|
253
|
+
return this._remainingSeconds <= 0;
|
|
254
|
+
case CoroutineInstructionType.waitUntil:
|
|
255
|
+
return this._instruction.predicate(frame);
|
|
256
|
+
case CoroutineInstructionType.waitWhile:
|
|
257
|
+
return !this._instruction.predicate(frame);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
_addAbortListener() {
|
|
261
|
+
if (!this._signal || this._onAbort) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
this._onAbort = () => {
|
|
265
|
+
this.stop();
|
|
266
|
+
};
|
|
267
|
+
this._signal.addEventListener('abort', this._onAbort);
|
|
268
|
+
}
|
|
269
|
+
_removeAbortListener() {
|
|
270
|
+
if (!this._signal || !this._onAbort) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this._signal.removeEventListener('abort', this._onAbort);
|
|
274
|
+
this._onAbort = undefined;
|
|
275
|
+
}
|
|
276
|
+
_onAbort = undefined;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=coroutine.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CycloComponent } from './component.ts';
|
|
2
|
+
export declare enum PredefinedExecutionOrder {
|
|
3
|
+
earlier = -100,
|
|
4
|
+
physics = -50,
|
|
5
|
+
normal = 0,
|
|
6
|
+
notSoLate = 10,
|
|
7
|
+
later = 50,
|
|
8
|
+
rendering = 200
|
|
9
|
+
}
|
|
10
|
+
export declare function setExecutionOrder(componentClass: new (...args: never[]) => CycloComponent, value: number): void;
|
|
11
|
+
export declare function getExecutionOrder(componentClass: new (...args: never[]) => CycloComponent): number;
|
|
12
|
+
//# sourceMappingURL=execution-order.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CycloComponent } from "./component.js";
|
|
2
|
+
export var PredefinedExecutionOrder;
|
|
3
|
+
(function (PredefinedExecutionOrder) {
|
|
4
|
+
PredefinedExecutionOrder[PredefinedExecutionOrder["earlier"] = -100] = "earlier";
|
|
5
|
+
PredefinedExecutionOrder[PredefinedExecutionOrder["physics"] = -50] = "physics";
|
|
6
|
+
PredefinedExecutionOrder[PredefinedExecutionOrder["normal"] = 0] = "normal";
|
|
7
|
+
PredefinedExecutionOrder[PredefinedExecutionOrder["notSoLate"] = 10] = "notSoLate";
|
|
8
|
+
PredefinedExecutionOrder[PredefinedExecutionOrder["later"] = 50] = "later";
|
|
9
|
+
PredefinedExecutionOrder[PredefinedExecutionOrder["rendering"] = 200] = "rendering";
|
|
10
|
+
})(PredefinedExecutionOrder || (PredefinedExecutionOrder = {}));
|
|
11
|
+
export function setExecutionOrder(componentClass, value) {
|
|
12
|
+
componentClass._executionOrder = value;
|
|
13
|
+
}
|
|
14
|
+
export function getExecutionOrder(componentClass) {
|
|
15
|
+
return componentClass._executionOrder || PredefinedExecutionOrder.normal;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=execution-order.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const TaskPriority: {
|
|
2
|
+
predefined: Readonly<{
|
|
3
|
+
componentsLateUpdate: 0;
|
|
4
|
+
}>;
|
|
5
|
+
before(priority: number): number;
|
|
6
|
+
after(priority: number): number;
|
|
7
|
+
between(a: number, b: number): number;
|
|
8
|
+
};
|
|
9
|
+
interface Task<TThis = any> {
|
|
10
|
+
fn: (this: TThis, deltaTime: number) => void;
|
|
11
|
+
thisArg: TThis;
|
|
12
|
+
priority: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function addFrameTask<TThis>(task: Task<TThis>): void;
|
|
15
|
+
export declare function removeFrameTask<TThis>(task: Task<TThis>): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=tasking.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as cc from 'cc';
|
|
2
|
+
export const TaskPriority = {
|
|
3
|
+
predefined: Object.freeze({
|
|
4
|
+
componentsLateUpdate: 0,
|
|
5
|
+
}),
|
|
6
|
+
before(priority) {
|
|
7
|
+
return priority - 1;
|
|
8
|
+
},
|
|
9
|
+
after(priority) {
|
|
10
|
+
return priority + 1;
|
|
11
|
+
},
|
|
12
|
+
between(a, b) {
|
|
13
|
+
return (a + b) / 2;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
class TaskCluster {
|
|
17
|
+
add(task) {
|
|
18
|
+
const taskIndex = this._find(task);
|
|
19
|
+
if (taskIndex >= 0) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
this._tasks.push({
|
|
23
|
+
...task,
|
|
24
|
+
});
|
|
25
|
+
this._tasks.sort((a, b) => b.priority - a.priority);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
remove(task) {
|
|
29
|
+
const taskIndex = this._find(task);
|
|
30
|
+
if (taskIndex < 0) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
this._tasks.splice(taskIndex, 1);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
execute(deltaTime) {
|
|
37
|
+
for (const task of this._tasks) {
|
|
38
|
+
task.fn.call(task.thisArg, deltaTime);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
_tasks = [];
|
|
42
|
+
_find(task) {
|
|
43
|
+
return this._tasks.findIndex((t) => t.fn === task.fn && t.thisArg === task.thisArg);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class CycloTaskScheduler extends cc.System {
|
|
47
|
+
add(task) {
|
|
48
|
+
const cluster = this._getCluster(task.priority);
|
|
49
|
+
cluster.add(task);
|
|
50
|
+
}
|
|
51
|
+
remove(task) {
|
|
52
|
+
for (const cluster of [this._clusterBeforeComponentsLateUpdate, this._clusterAfterComponentsLateUpdate]) {
|
|
53
|
+
const removed = cluster.remove(task);
|
|
54
|
+
if (removed) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
update(deltaTime) {
|
|
60
|
+
this._clusterBeforeComponentsLateUpdate.execute(deltaTime);
|
|
61
|
+
}
|
|
62
|
+
postUpdate(deltaTime) {
|
|
63
|
+
this._clusterAfterComponentsLateUpdate.execute(deltaTime);
|
|
64
|
+
}
|
|
65
|
+
_clusterBeforeComponentsLateUpdate = new TaskCluster();
|
|
66
|
+
_clusterAfterComponentsLateUpdate = new TaskCluster();
|
|
67
|
+
_getCluster(priority) {
|
|
68
|
+
if (priority <= TaskPriority.predefined.componentsLateUpdate) {
|
|
69
|
+
return this._clusterBeforeComponentsLateUpdate;
|
|
70
|
+
}
|
|
71
|
+
return this._clusterAfterComponentsLateUpdate;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const taskScheduler = new CycloTaskScheduler();
|
|
75
|
+
cc.director.registerSystem('CycloTasks', taskScheduler, cc.System.Priority.MEDIUM);
|
|
76
|
+
export function addFrameTask(task) {
|
|
77
|
+
taskScheduler.add(task);
|
|
78
|
+
}
|
|
79
|
+
export function removeFrameTask(task) {
|
|
80
|
+
taskScheduler.remove(task);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=tasking.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Bounds2D } from '@cyclonium/math/bounds-2d';
|
|
2
|
+
import { applyLegacyDecorators, serializable, editable } from "../export/legacy-decorator.js";
|
|
3
|
+
import { cycloBuiltinClass } from "../decorator/legacy/legacy-decorator.js";
|
|
4
|
+
export * from '@cyclonium/math/bounds-2d';
|
|
5
|
+
applyLegacyDecorators(Bounds2D, {
|
|
6
|
+
classDecorators: [cycloBuiltinClass('Bounds2D')],
|
|
7
|
+
propertyDecorators: {
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
_min: [serializable, editable],
|
|
10
|
+
_max: [serializable, editable],
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=bounds-2d.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Vec2 } from "./vec2.js";
|
|
2
|
+
import { Ray2D } from "./ray.js";
|
|
3
|
+
export function raycastLineSegment2D(ray, p0, p1) {
|
|
4
|
+
const v1 = ray.origin.sub(p0);
|
|
5
|
+
const v2 = p1.sub(p0);
|
|
6
|
+
const v3 = new Vec2(-ray.direction.y, ray.direction.x);
|
|
7
|
+
const dot = Vec2.dot(v2, v3);
|
|
8
|
+
// Ray is parallel to line segment.
|
|
9
|
+
if (Math.abs(dot) < 1e-6) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const t1 = Vec2.cross(v2, v1) / dot;
|
|
13
|
+
const t2 = Vec2.dot(v1, v3) / dot;
|
|
14
|
+
if (t1 >= 0.0 && (t2 >= 0.0 && t2 <= 1.0)) {
|
|
15
|
+
return t1;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=geometry.js.map
|
package/lib/math/mat3.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Vec2 } from './vec2.ts';
|
|
2
|
+
export declare class Ray2D {
|
|
3
|
+
constructor(origin: Vec2, direction: Vec2);
|
|
4
|
+
get origin(): Vec2;
|
|
5
|
+
set origin(origin: Vec2);
|
|
6
|
+
get direction(): Vec2;
|
|
7
|
+
set direction(direction: Vec2);
|
|
8
|
+
at(distance: number): Vec2;
|
|
9
|
+
private _origin;
|
|
10
|
+
private _direction;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ray.d.ts.map
|
package/lib/math/ray.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Vec2 } from "./vec2.js";
|
|
2
|
+
export class Ray2D {
|
|
3
|
+
constructor(origin, direction) {
|
|
4
|
+
this.origin = origin.clone();
|
|
5
|
+
this.direction = direction.normalize();
|
|
6
|
+
}
|
|
7
|
+
get origin() {
|
|
8
|
+
return this._origin;
|
|
9
|
+
}
|
|
10
|
+
set origin(origin) {
|
|
11
|
+
Vec2.assign(this._origin, origin);
|
|
12
|
+
}
|
|
13
|
+
get direction() {
|
|
14
|
+
return this._direction;
|
|
15
|
+
}
|
|
16
|
+
set direction(direction) {
|
|
17
|
+
Vec2.assign(this._direction, direction);
|
|
18
|
+
this._direction.normalizeSelf();
|
|
19
|
+
}
|
|
20
|
+
at(distance) {
|
|
21
|
+
return this.origin.addMulScalar(this.direction, distance);
|
|
22
|
+
}
|
|
23
|
+
_origin = new Vec2();
|
|
24
|
+
_direction = new Vec2();
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ray.js.map
|
package/lib/math/vec2.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Vec2, v2 } from '@cyclonium/math/vec2';
|
|
2
|
+
import { applyLegacyDecorators } from "../decorator/legacy/apply-legacy-decorators.js";
|
|
3
|
+
import { editable, cycloBuiltinClass, serializable } from "../decorator/legacy/legacy-general-decorator.js";
|
|
4
|
+
import * as cc from 'cc';
|
|
5
|
+
applyLegacyDecorators(Vec2, {
|
|
6
|
+
classDecorators: [cycloBuiltinClass('Vec2')],
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
propertyDecorators: {
|
|
9
|
+
x: [serializable, editable],
|
|
10
|
+
y: [serializable, editable],
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export { Vec2, v2 };
|
|
14
|
+
export function _toCCVec2(v) {
|
|
15
|
+
return cc.v2(v.x, v.y);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=vec2.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function assert(value, message) {
|
|
2
|
+
if (!value) {
|
|
3
|
+
debugger;
|
|
4
|
+
throw new Error(`Assertion failed: ${message ?? '<no-message>'}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
8
|
+
(function (assert) {
|
|
9
|
+
function unreachable() {
|
|
10
|
+
assert(false, 'Unreachable');
|
|
11
|
+
}
|
|
12
|
+
assert.unreachable = unreachable;
|
|
13
|
+
})(assert || (assert = {}));
|
|
14
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ccenum, Enum } from 'cc';
|
|
2
|
+
export function markEnum(e) {
|
|
3
|
+
ccenum(e);
|
|
4
|
+
}
|
|
5
|
+
export function DynamicEnum(e) {
|
|
6
|
+
markEnum(e);
|
|
7
|
+
return new Proxy(e, {
|
|
8
|
+
set(target, p, newValue, receiver) {
|
|
9
|
+
const returnValue = Reflect.set(target, p, newValue, receiver);
|
|
10
|
+
Enum.update(target);
|
|
11
|
+
return returnValue;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=enum.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { director } from 'cc';
|
|
2
|
+
export const logger = {
|
|
3
|
+
verbose: wrapLogMethod(console.debug.bind(console)),
|
|
4
|
+
info: wrapLogMethod(console.log.bind(console)),
|
|
5
|
+
warn: wrapLogMethod(console.warn.bind(console)),
|
|
6
|
+
error: wrapLogMethod(console.error.bind(console)),
|
|
7
|
+
};
|
|
8
|
+
function wrapLogMethod(method) {
|
|
9
|
+
return (...args) => {
|
|
10
|
+
const prefix = `[${director.getTotalFrames()}]`;
|
|
11
|
+
if (typeof args[0] === 'string') {
|
|
12
|
+
return method(`${prefix}${args[0]}`, ...args.slice(1));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return method(prefix, ...args);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=logger.js.map
|
package/lib/utils/raw.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { cycloBuiltinClass } from "../export/internal.js";
|
|
8
|
+
let Raw = class Raw {
|
|
9
|
+
data;
|
|
10
|
+
constructor(data) {
|
|
11
|
+
this.data = data;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
Raw = __decorate([
|
|
15
|
+
cycloBuiltinClass('_Raw')
|
|
16
|
+
], Raw);
|
|
17
|
+
export { Raw };
|
|
18
|
+
export const dumpRaw = (target, propertyKey, descriptor) => {
|
|
19
|
+
const get = descriptor.get;
|
|
20
|
+
if (get) {
|
|
21
|
+
descriptor.get = function () {
|
|
22
|
+
return new Raw(get.call(this));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=raw.js.map
|