adofai 2.9.13 → 2.9.15

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.
Files changed (46) hide show
  1. package/dist/src/effectProcessor.d.ts +32 -0
  2. package/dist/src/effectProcessor.js +89 -0
  3. package/dist/src/format.d.ts +8 -0
  4. package/dist/src/format.js +46 -0
  5. package/dist/src/index.d.ts +5 -0
  6. package/dist/src/index.js +48 -0
  7. package/dist/src/parser/ArrayBufferParser.d.ts +9 -0
  8. package/dist/src/parser/ArrayBufferParser.js +108 -0
  9. package/dist/src/parser/BufferParser.d.ts +9 -0
  10. package/dist/src/parser/BufferParser.js +102 -0
  11. package/{src/parser/Parser.ts → dist/src/parser/Parser.d.ts} +5 -6
  12. package/dist/src/parser/Parser.js +5 -0
  13. package/dist/src/parser/StringParser.d.ts +7 -0
  14. package/{src/parser/StringParser.ts → dist/src/parser/StringParser.js} +448 -438
  15. package/dist/src/parser/index.d.ts +16 -0
  16. package/dist/src/parser/index.js +28 -0
  17. package/{src/parser.ts → dist/src/parser.d.ts} +1 -2
  18. package/dist/src/parser.js +14 -0
  19. package/dist/src/pathdata.d.ts +13 -0
  20. package/dist/src/pathdata.js +16 -0
  21. package/dist/src/presets.d.ts +10 -0
  22. package/{src/presets.ts → dist/src/presets.js} +12 -19
  23. package/dist/src/structure/Level.d.ts +54 -0
  24. package/dist/src/structure/Level.js +387 -0
  25. package/{src/structure/interfaces.ts → dist/src/structure/interfaces.d.ts} +33 -38
  26. package/dist/src/structure/interfaces.js +2 -0
  27. package/{src/structure.ts → dist/src/structure.d.ts} +4 -6
  28. package/dist/src/structure.js +4 -0
  29. package/dist/umd/index.js +2 -0
  30. package/dist/umd/index.js.LICENSE.txt +1 -0
  31. package/package.json +8 -4
  32. package/.babelrc +0 -5
  33. package/index.ts +0 -12
  34. package/src/effectProcessor.ts +0 -82
  35. package/src/format.ts +0 -69
  36. package/src/parser/ArrayBufferParser.ts +0 -101
  37. package/src/parser/BufferParser.ts +0 -93
  38. package/src/parser/index.ts +0 -28
  39. package/src/pathdata.ts +0 -20
  40. package/src/structure/Level.ts +0 -351
  41. package/src/structure.ts.bak +0 -412
  42. package/test/Buffer.js +0 -2030
  43. package/test/editor.html +0 -501
  44. package/test/index.html +0 -31
  45. package/tsconfig.json +0 -17
  46. package/webpack.config.mjs +0 -35
@@ -0,0 +1,16 @@
1
+ import { LevelOptions, ParseProvider } from '../structure';
2
+ declare class BaseParser {
3
+ static parseError(f: string): string;
4
+ /**
5
+ * @param {string} t - Input Content
6
+ * @param {object} provider - ParserProvider
7
+ * @returns {LevelOptions} ADOFAI File Object
8
+ */
9
+ static parseAsObject(t: string, provider?: ParseProvider): LevelOptions;
10
+ /**
11
+ * @param {string} t - Input Content
12
+ * @returns {string} ADOFAI File Content
13
+ */
14
+ static parseAsText(t: string): string;
15
+ }
16
+ export default BaseParser;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const StringParser_1 = __importDefault(require("./StringParser"));
7
+ class BaseParser {
8
+ static parseError(f) {
9
+ return f;
10
+ }
11
+ /**
12
+ * @param {string} t - Input Content
13
+ * @param {object} provider - ParserProvider
14
+ * @returns {LevelOptions} ADOFAI File Object
15
+ */
16
+ static parseAsObject(t, provider) {
17
+ const parser = provider || new StringParser_1.default();
18
+ return parser.parse(BaseParser.parseAsText(t));
19
+ }
20
+ /**
21
+ * @param {string} t - Input Content
22
+ * @returns {string} ADOFAI File Content
23
+ */
24
+ static parseAsText(t) {
25
+ return this.parseError(t);
26
+ }
27
+ }
28
+ exports.default = BaseParser;
@@ -2,6 +2,5 @@ import Parser from "./parser/index";
2
2
  import BufferParser from './parser/BufferParser';
3
3
  import ArrayBufferParser from "./parser/ArrayBufferParser";
4
4
  import StringParser from "./parser/StringParser";
5
-
6
- export {StringParser, BufferParser, ArrayBufferParser}
5
+ export { StringParser, BufferParser, ArrayBufferParser };
7
6
  export default Parser;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ArrayBufferParser = exports.BufferParser = exports.StringParser = void 0;
7
+ const index_1 = __importDefault(require("./parser/index"));
8
+ const BufferParser_1 = __importDefault(require("./parser/BufferParser"));
9
+ exports.BufferParser = BufferParser_1.default;
10
+ const ArrayBufferParser_1 = __importDefault(require("./parser/ArrayBufferParser"));
11
+ exports.ArrayBufferParser = ArrayBufferParser_1.default;
12
+ const StringParser_1 = __importDefault(require("./parser/StringParser"));
13
+ exports.StringParser = StringParser_1.default;
14
+ exports.default = index_1.default;
@@ -0,0 +1,13 @@
1
+ interface PathDataTable {
2
+ [key: string]: number;
3
+ }
4
+ /**
5
+ * @param {string} pathdata - PathData from ADOFAI
6
+ * @returns {Array<number>} Converted AngleData
7
+ */
8
+ declare function parseToangleData(pathdata: string): number[];
9
+ declare const _default: {
10
+ pathDataTable: PathDataTable;
11
+ parseToangleData: typeof parseToangleData;
12
+ };
13
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const pathDataTable = { "R": 0, "p": 15, "J": 30, "E": 45, "T": 60, "o": 75, "U": 90, "q": 105, "G": 120, "Q": 135, "H": 150, "W": 165, "L": 180, "x": 195, "N": 210, "Z": 225, "F": 240, "V": 255, "D": 270, "Y": 285, "B": 300, "C": 315, "M": 330, "A": 345, "5": 555, "6": 666, "7": 777, "8": 888, "!": 999 };
4
+ /**
5
+ * @param {string} pathdata - PathData from ADOFAI
6
+ * @returns {Array<number>} Converted AngleData
7
+ */
8
+ function parseToangleData(pathdata) {
9
+ let pt = Array.from(String(pathdata));
10
+ let result = pt.map(t => pathDataTable[t]);
11
+ return result;
12
+ }
13
+ exports.default = {
14
+ pathDataTable,
15
+ parseToangleData
16
+ };
@@ -0,0 +1,10 @@
1
+ export interface Preset {
2
+ type: 'include' | 'exclude' | "special";
3
+ events: string[];
4
+ [key: string]: any;
5
+ }
6
+ export declare const preset_noeffect: Preset;
7
+ export declare const preset_noholds: Preset;
8
+ export declare const preset_nomovecamera: Preset;
9
+ export declare const preset_noeffect_completely: Preset;
10
+ export declare const preset_inner_no_deco: Preset;
@@ -1,10 +1,7 @@
1
- export interface Preset {
2
- type: 'include'|'exclude'|"special";
3
- events: string[];
4
- [key: string]: any;
5
- }
6
-
7
- export const preset_noeffect: Preset = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preset_inner_no_deco = exports.preset_noeffect_completely = exports.preset_nomovecamera = exports.preset_noholds = exports.preset_noeffect = void 0;
4
+ exports.preset_noeffect = {
8
5
  type: 'exclude', events: [
9
6
  'Flash',
10
7
  'SetFilter',
@@ -17,20 +14,17 @@ export const preset_noeffect: Preset = {
17
14
  'ShakeScreen'
18
15
  ]
19
16
  };
20
-
21
- export const preset_noholds: Preset = {
17
+ exports.preset_noholds = {
22
18
  type: 'exclude', events: [
23
19
  'Hold',
24
20
  ]
25
- }
26
-
27
- export const preset_nomovecamera: Preset = {
21
+ };
22
+ exports.preset_nomovecamera = {
28
23
  type: 'exclude', events: [
29
24
  'MoveCamera',
30
25
  ]
31
- }
32
-
33
- export const preset_noeffect_completely: Preset = {
26
+ };
27
+ exports.preset_noeffect_completely = {
34
28
  type: 'exclude', events: [
35
29
  "AddDecoration",
36
30
  "AddText",
@@ -73,13 +67,12 @@ export const preset_noeffect_completely: Preset = {
73
67
  "ScaleMargin",
74
68
  "ScaleRadius"
75
69
  ]
76
- }
77
-
78
- export const preset_inner_no_deco: Preset = {
70
+ };
71
+ exports.preset_inner_no_deco = {
79
72
  type: "special", events: [
80
73
  "MoveDecorations",
81
74
  "SetText",
82
75
  "SetObject",
83
76
  "SetDefaultText"
84
77
  ]
85
- }
78
+ };
@@ -0,0 +1,54 @@
1
+ import { AdofaiEvent, LevelOptions, Tile, ParseProvider } from './interfaces';
2
+ export declare class Level {
3
+ private _events;
4
+ private guidCallbacks;
5
+ private guidCounter;
6
+ private _options;
7
+ private _provider?;
8
+ angleData: number[];
9
+ actions: AdofaiEvent[];
10
+ settings: Record<string, any>;
11
+ __decorations: AdofaiEvent[];
12
+ tiles: Tile[];
13
+ private _angleDir;
14
+ private _twirlCount;
15
+ constructor(opt: string | LevelOptions, provider?: ParseProvider);
16
+ generateGUID(): string;
17
+ load(): Promise<boolean>;
18
+ on(eventName: string, callback: Function): string;
19
+ trigger(eventName: string, data: any): void;
20
+ off(guid: string): void;
21
+ private _createArray;
22
+ private _changeAngle;
23
+ private _parsechangedAngle;
24
+ private _filterByFloor;
25
+ private _flattenAngleDatas;
26
+ private _flattenActionsWithFloor;
27
+ private _filterByFloorwithDeco;
28
+ private _flattenDecorationsWithFloor;
29
+ private _parseAngle;
30
+ filterActionsByEventType(en: string): {
31
+ index: number;
32
+ action: AdofaiEvent;
33
+ }[];
34
+ getActionsByIndex(en: string, index: number): {
35
+ count: number;
36
+ actions: AdofaiEvent[];
37
+ };
38
+ calculateTileCoordinates(): void;
39
+ floorOperation(info?: {
40
+ type: 'append' | 'insert' | 'delete';
41
+ direction: number;
42
+ id?: number;
43
+ }): void;
44
+ appendFloor(args: {
45
+ direction: number;
46
+ }): void;
47
+ clearDeco(): boolean;
48
+ clearEffect(presetName: string): void;
49
+ clearEvent(preset: {
50
+ type: string;
51
+ events: string[];
52
+ }): void;
53
+ export(type: 'string' | 'object', indent?: number, useAdofaiStyle?: boolean): string | Record<string, any>;
54
+ }
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __rest = (this && this.__rest) || function (s, e) {
45
+ var t = {};
46
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
47
+ t[p] = s[p];
48
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
49
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
50
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
51
+ t[p[i]] = s[p[i]];
52
+ }
53
+ return t;
54
+ };
55
+ var __importDefault = (this && this.__importDefault) || function (mod) {
56
+ return (mod && mod.__esModule) ? mod : { "default": mod };
57
+ };
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.Level = void 0;
60
+ const pathdata_1 = __importDefault(require("../pathdata"));
61
+ const format_1 = __importDefault(require("../format"));
62
+ const parser_1 = __importDefault(require("../parser"));
63
+ const effectProcessor_1 = __importDefault(require("../effectProcessor"));
64
+ const presets = __importStar(require("../presets"));
65
+ class Level {
66
+ constructor(opt, provider) {
67
+ this._events = new Map();
68
+ this.guidCallbacks = new Map();
69
+ this.guidCounter = 0;
70
+ this._options = opt;
71
+ this._provider = provider;
72
+ }
73
+ generateGUID() {
74
+ return `event_${Date.now()}_${this.guidCounter++}_${Math.floor(Math.random() * 1000)}`;
75
+ }
76
+ load() {
77
+ return new Promise((resolve, reject) => {
78
+ let opt = this._options;
79
+ let options;
80
+ switch (typeof opt) {
81
+ case 'string':
82
+ try {
83
+ options = parser_1.default.parseAsObject(opt, this._provider);
84
+ }
85
+ catch (e) {
86
+ reject(e);
87
+ return;
88
+ }
89
+ break;
90
+ case 'object':
91
+ options = Object.assign({}, opt);
92
+ break;
93
+ default:
94
+ reject("Options must be String or Object");
95
+ return;
96
+ }
97
+ if (options && typeof options === 'object' && options !== null && typeof options.pathData !== 'undefined') {
98
+ this.angleData = pathdata_1.default.parseToangleData(options['pathData']);
99
+ }
100
+ else {
101
+ if (options && typeof options === 'object' && options !== null && typeof options.angleData !== 'undefined') {
102
+ this.angleData = options['angleData'];
103
+ }
104
+ else {
105
+ reject("There is not any angle datas.");
106
+ return;
107
+ }
108
+ }
109
+ if (options && typeof options === 'object' && options !== null && typeof options.actions !== 'undefined') {
110
+ this.actions = options['actions'];
111
+ }
112
+ else {
113
+ this.actions = [];
114
+ }
115
+ if (options && typeof options === 'object' && options !== null && typeof options.settings !== 'undefined') {
116
+ this.settings = options['settings'];
117
+ }
118
+ else {
119
+ reject("There is no ADOFAI settings.");
120
+ return;
121
+ }
122
+ if (options && typeof options === 'object' && options !== null && typeof options.decorations !== 'undefined') {
123
+ this.__decorations = options['decorations'];
124
+ }
125
+ else {
126
+ this.__decorations = [];
127
+ }
128
+ this.tiles = [];
129
+ this._angleDir = -180;
130
+ this._twirlCount = 0;
131
+ this._createArray(this.angleData.length, { angleData: this.angleData, actions: this.actions, decorations: this.__decorations })
132
+ .then(e => {
133
+ this.tiles = e;
134
+ this.trigger('load', this);
135
+ resolve(true);
136
+ }).catch(e => {
137
+ reject(e);
138
+ });
139
+ });
140
+ }
141
+ on(eventName, callback) {
142
+ if (!this._events.has(eventName)) {
143
+ this._events.set(eventName, []);
144
+ }
145
+ const guid = this.generateGUID();
146
+ const eventCallbacks = this._events.get(eventName);
147
+ eventCallbacks.push({ guid, callback });
148
+ this.guidCallbacks.set(guid, { eventName, callback });
149
+ return guid;
150
+ }
151
+ trigger(eventName, data) {
152
+ if (!this._events.has(eventName))
153
+ return;
154
+ const callbacks = this._events.get(eventName);
155
+ callbacks.forEach(({ callback }) => callback(data));
156
+ }
157
+ off(guid) {
158
+ if (!this.guidCallbacks.has(guid))
159
+ return;
160
+ const { eventName } = this.guidCallbacks.get(guid);
161
+ this.guidCallbacks.delete(guid);
162
+ if (!this._events.has(eventName))
163
+ return;
164
+ const callbacks = this._events.get(eventName);
165
+ const index = callbacks.findIndex(cb => cb.guid === guid);
166
+ if (index !== -1) {
167
+ callbacks.splice(index, 1);
168
+ }
169
+ }
170
+ _createArray(xLength, opt) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ let m = Array.from({ length: xLength }, (_, i) => ({
173
+ direction: opt.angleData[i],
174
+ _lastdir: opt.angleData[i - 1] || 0,
175
+ actions: this._filterByFloor(opt.actions, i),
176
+ angle: this._parseAngle(opt.angleData, i, this._twirlCount % 2),
177
+ addDecorations: this._filterByFloorwithDeco(opt.decorations, i),
178
+ twirl: this._twirlCount,
179
+ extraProps: {}
180
+ }));
181
+ return m;
182
+ });
183
+ }
184
+ _changeAngle() {
185
+ let y = 0;
186
+ let m = this.tiles.map(t => {
187
+ y++;
188
+ t.angle = this._parsechangedAngle(t.direction, y, t.twirl, t._lastdir);
189
+ return t;
190
+ });
191
+ return m;
192
+ }
193
+ _parsechangedAngle(agd, i, isTwirl, lstagd) {
194
+ let prev = 0;
195
+ if (i === 0) {
196
+ this._angleDir = 180;
197
+ }
198
+ if (agd === 999) {
199
+ this._angleDir = lstagd;
200
+ if (isNaN(this._angleDir)) {
201
+ this._angleDir = 0;
202
+ }
203
+ prev = 0;
204
+ }
205
+ else {
206
+ if (isTwirl === 0) {
207
+ prev = (this._angleDir - agd) % 360;
208
+ }
209
+ else {
210
+ prev = 360 - (this._angleDir - agd) % 360;
211
+ }
212
+ if (prev === 0) {
213
+ prev = 360;
214
+ }
215
+ this._angleDir = agd + 180;
216
+ }
217
+ return prev;
218
+ }
219
+ _filterByFloor(arr, i) {
220
+ let actionT = arr.filter(item => item.floor === i);
221
+ this._twirlCount += actionT.filter(t => t.eventType === 'Twirl').length;
222
+ return actionT.map((_a) => {
223
+ var { floor } = _a, rest = __rest(_a, ["floor"]);
224
+ return rest;
225
+ });
226
+ }
227
+ _flattenAngleDatas(arr) {
228
+ return arr.map(item => item.direction);
229
+ }
230
+ _flattenActionsWithFloor(arr) {
231
+ return arr.map(item => item.actions).flat();
232
+ }
233
+ _filterByFloorwithDeco(arr, i) {
234
+ let actionT = arr.filter(item => item.floor === i);
235
+ return actionT.map((_a) => {
236
+ var { floor } = _a, rest = __rest(_a, ["floor"]);
237
+ return rest;
238
+ });
239
+ }
240
+ _flattenDecorationsWithFloor(arr) {
241
+ return arr.map(item => item.addDecorations).flat();
242
+ }
243
+ _parseAngle(agd, i, isTwirl) {
244
+ let prev = 0;
245
+ if (i === 0) {
246
+ this._angleDir = 180;
247
+ }
248
+ if (agd[i] === 999) {
249
+ this._angleDir = agd[i - 1];
250
+ if (isNaN(this._angleDir)) {
251
+ this._angleDir = 0;
252
+ }
253
+ prev = 0;
254
+ }
255
+ else {
256
+ if (isTwirl === 0) {
257
+ prev = (this._angleDir - agd[i]) % 360;
258
+ }
259
+ else {
260
+ prev = 360 - (this._angleDir - agd[i]) % 360;
261
+ }
262
+ if (prev === 0) {
263
+ prev = 360;
264
+ }
265
+ this._angleDir = agd[i] + 180;
266
+ }
267
+ return prev;
268
+ }
269
+ filterActionsByEventType(en) {
270
+ return Object.entries(this.tiles)
271
+ .flatMap(([index, a]) => (a.actions || []).map(b => ({ b, index })))
272
+ .filter(({ b }) => b.eventType === en)
273
+ .map(({ b, index }) => ({
274
+ index: Number(index),
275
+ action: b
276
+ }));
277
+ }
278
+ getActionsByIndex(en, index) {
279
+ const filtered = this.filterActionsByEventType(en);
280
+ const matches = filtered.filter(item => item.index === index);
281
+ return {
282
+ count: matches.length,
283
+ actions: matches.map(item => item.action)
284
+ };
285
+ }
286
+ calculateTileCoordinates() {
287
+ let angles = this.angleData;
288
+ let floats = [];
289
+ let startPos = [0, 0];
290
+ for (let i = 0; i < this.tiles.length; i++) {
291
+ let value = angles[i];
292
+ if (value === 999) {
293
+ value = angles[i - 1] + 180;
294
+ }
295
+ floats.push(value);
296
+ }
297
+ for (let i = 0; i <= floats.length; i++) {
298
+ let angle1 = Number((i === floats.length) ? floats[i - 1] : floats[i]) || 0;
299
+ let angle2 = Number((i === 0) ? 0 : floats[i - 1]) || 0;
300
+ let currentTile = this.tiles[i];
301
+ if (this.getActionsByIndex('PositionTrack', i).count > 0) {
302
+ let pevent = this.getActionsByIndex('PositionTrack', i).actions[0];
303
+ if (pevent.positionOffset) {
304
+ if (pevent['editorOnly'] !== true && pevent['editorOnly'] !== 'Enabled') {
305
+ startPos[0] += pevent['positionOffset'][0];
306
+ startPos[1] += pevent['positionOffset'][1];
307
+ }
308
+ }
309
+ }
310
+ startPos[0] += Math.cos(angle1 * Math.PI / 180);
311
+ startPos[1] += Math.sin(angle1 * Math.PI / 180);
312
+ if (typeof currentTile !== 'undefined') {
313
+ currentTile.position = [
314
+ Number(startPos[0].toFixed(8)),
315
+ Number(startPos[1].toFixed(8))
316
+ ];
317
+ currentTile.extraProps.angle1 = angle1;
318
+ currentTile.extraProps.angle2 = angle2 - 180;
319
+ currentTile.extraProps.cangle = i === floats.length ? floats[i - 1] + 180 : floats[i];
320
+ }
321
+ }
322
+ }
323
+ floorOperation(info = { type: 'append', direction: 0 }) {
324
+ switch (info.type) {
325
+ case 'append':
326
+ this.appendFloor(info);
327
+ break;
328
+ case 'insert':
329
+ if (typeof info.id === 'number') {
330
+ this.tiles.splice(info.id, 0, {
331
+ direction: info.direction || 0,
332
+ angle: 0,
333
+ actions: [],
334
+ addDecorations: [],
335
+ _lastdir: this.tiles[info.id - 1].direction,
336
+ twirl: this.tiles[info.id - 1].twirl
337
+ });
338
+ }
339
+ break;
340
+ case 'delete':
341
+ if (typeof info.id === 'number') {
342
+ this.tiles.splice(info.id, 1);
343
+ }
344
+ break;
345
+ }
346
+ this._changeAngle();
347
+ }
348
+ appendFloor(args) {
349
+ this.tiles.push({
350
+ direction: args.direction,
351
+ angle: 0,
352
+ actions: [],
353
+ addDecorations: [],
354
+ _lastdir: this.tiles[this.tiles.length - 1].direction,
355
+ twirl: this.tiles[this.tiles.length - 1].twirl,
356
+ extraProps: {}
357
+ });
358
+ this._changeAngle();
359
+ }
360
+ clearDeco() {
361
+ this.tiles = effectProcessor_1.default.clearDecorations(this.tiles);
362
+ return true;
363
+ }
364
+ clearEffect(presetName) {
365
+ this.clearEvent(presets[presetName]);
366
+ }
367
+ clearEvent(preset) {
368
+ switch (preset.type) {
369
+ case 'include':
370
+ this.tiles = effectProcessor_1.default.keepEvents(preset.events, this.tiles);
371
+ break;
372
+ case 'exclude':
373
+ this.tiles = effectProcessor_1.default.clearEvents(preset.events, this.tiles);
374
+ break;
375
+ }
376
+ }
377
+ export(type, indent, useAdofaiStyle = true) {
378
+ const ADOFAI = {
379
+ angleData: this._flattenAngleDatas(this.tiles),
380
+ settings: this.settings,
381
+ actions: this._flattenActionsWithFloor(this.tiles),
382
+ decorations: this._flattenDecorationsWithFloor(this.tiles)
383
+ };
384
+ return type === 'object' ? ADOFAI : (0, format_1.default)(ADOFAI, indent, useAdofaiStyle);
385
+ }
386
+ }
387
+ exports.Level = Level;
@@ -1,38 +1,33 @@
1
- export interface AdofaiEvent {
2
- eventType: string;
3
- [key: string]: any;
4
- }
5
-
6
- export interface LevelOptions {
7
- pathData?: string;
8
- angleData?: number[];
9
- actions: AdofaiEvent[];
10
- settings: Record<string, any>;
11
- decorations: AdofaiEvent[];
12
- [key: string]: any;
13
- }
14
-
15
- export interface EventCallback {
16
- guid: string;
17
- callback: Function;
18
- }
19
-
20
- export interface GuidCallback {
21
- eventName: string;
22
- callback: Function;
23
- }
24
-
25
- export interface Tile {
26
- direction?: number;
27
- angle?: number;
28
- actions: AdofaiEvent[];
29
- addDecorations?: AdofaiEvent[];
30
- _lastdir?: number;
31
- twirl?: number;
32
- position?: number[];
33
- extraProps?: Record<string, any>;
34
- }
35
-
36
- export interface ParseProvider {
37
- parse(t: string): LevelOptions;
38
- }
1
+ export interface AdofaiEvent {
2
+ eventType: string;
3
+ [key: string]: any;
4
+ }
5
+ export interface LevelOptions {
6
+ pathData?: string;
7
+ angleData?: number[];
8
+ actions: AdofaiEvent[];
9
+ settings: Record<string, any>;
10
+ decorations: AdofaiEvent[];
11
+ [key: string]: any;
12
+ }
13
+ export interface EventCallback {
14
+ guid: string;
15
+ callback: Function;
16
+ }
17
+ export interface GuidCallback {
18
+ eventName: string;
19
+ callback: Function;
20
+ }
21
+ export interface Tile {
22
+ direction?: number;
23
+ angle?: number;
24
+ actions: AdofaiEvent[];
25
+ addDecorations?: AdofaiEvent[];
26
+ _lastdir?: number;
27
+ twirl?: number;
28
+ position?: number[];
29
+ extraProps?: Record<string, any>;
30
+ }
31
+ export interface ParseProvider {
32
+ parse(t: string): LevelOptions;
33
+ }