@rpgjs/server 3.1.0 → 3.3.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/lib/Game/Map.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { RpgCommonMap, RpgShape, RpgCommonGame } from '@rpgjs/common';
1
+ import { RpgCommonMap, RpgShape, RpgCommonGame, AbstractObject } from '@rpgjs/common';
2
2
  import { EventOptions } from '../decorators/event';
3
3
  import { RpgPlayer, EventMode, RpgEvent } from '../Player/Player';
4
4
  import { RpgServerEngine } from '../server';
5
+ import { Observable } from 'rxjs';
6
+ import { HitBox, MovingHitbox } from '@rpgjs/types';
5
7
  export declare type EventPosOption = {
6
8
  x: number;
7
9
  y: number;
@@ -111,8 +113,39 @@ export declare class RpgMap extends RpgCommonMap {
111
113
  * @memberof Map
112
114
  */
113
115
  removeEvent(eventId: string): boolean;
114
- createEvent(obj: EventPosOption, mode: EventMode, shape?: any): RpgEvent | null;
116
+ createEvent(obj: EventPosOption, mode: EventMode, shape?: RpgShape): RpgEvent | null;
115
117
  createEvents(eventsList: EventOption[], mode: EventMode): EventsList;
118
+ /**
119
+ * Allows to create a temporary hitbox on the map that can have a movement
120
+ For example, you can use it to explode a bomb and find all the affected players, or during a sword strike, you can create a moving hitbox and find the affected players again
121
+ * @title Create a temporary and moving hitbox
122
+ * @since 3.2.0
123
+ * @method map.createMovingHitbox(hitboxes,options)
124
+ * @param {Array<{ width: number, height: number, x: number, y: number }>} hitboxes Create several hitboxes that will give an effect of movement
125
+ * @param {object} [options]
126
+ * @param {speed} [options.speed=1] speed of movement (in frames)
127
+ * @returns {Observable<AbstractObject>} You find the methods of position and movement of an event
128
+ * @memberof Map
129
+ * @example
130
+ *
131
+ * ```ts
132
+ * // Two hitboxes that will be done very quickly
133
+ * map.createMovingHitbox(
134
+ * [
135
+ * { x: 0, y: 0, width: 100, height: 100 },
136
+ * { x: 20, y: 0, width: 100, height: 100 }
137
+ * ]
138
+ * ).subscribe({
139
+ * next(hitbox) {
140
+ * console.log(hitbox.otherPlayersCollision)
141
+ * },
142
+ * complete() {
143
+ * console.log('finish')
144
+ * }
145
+ * })
146
+ * ```
147
+ */
148
+ createMovingHitbox(hitboxes: Pick<HitBox, 'width' | 'height' | 'x' | 'y'>[], options?: MovingHitbox): Observable<AbstractObject>;
116
149
  setSync(schema: any): void;
117
150
  }
118
151
  export interface RpgMap {
package/lib/Game/Map.js CHANGED
@@ -105,6 +105,7 @@ class RpgMap extends common_1.RpgCommonMap {
105
105
  object.getShapes().forEach(shape => shape.out(event));
106
106
  event.getShapes().forEach(shape => shape.out(object));
107
107
  }
108
+ object.stopMoveTo();
108
109
  this.grid.clearObjectInCells(object.id);
109
110
  for (let playerId in this.players) {
110
111
  if (object.id == playerId)
@@ -117,7 +118,7 @@ class RpgMap extends common_1.RpgCommonMap {
117
118
  // last player before removed of this map
118
119
  if (this.nbPlayers === 1) {
119
120
  // clear cache for this map
120
- common_1.RpgCommonMap.buffer.delete(this.id);
121
+ this._server.sceneMap.removeMap(this.id);
121
122
  }
122
123
  }
123
124
  // Hook: called by simple-room package
@@ -217,6 +218,7 @@ class RpgMap extends common_1.RpgCommonMap {
217
218
  let ret = {};
218
219
  for (let key in events) {
219
220
  this.events[key] = events[key];
221
+ this.events[key].updateInVirtualGrid();
220
222
  this.events[key].execMethod('onInit');
221
223
  // force to get Proxy object to sync with client
222
224
  ret = Object.assign(Object.assign({}, ret), { [key]: this.events[key] });
@@ -268,15 +270,15 @@ class RpgMap extends common_1.RpgCommonMap {
268
270
  // Create an instance of RpgEvent and assign its options
269
271
  const ev = this.game.addEvent(event);
270
272
  const _shape = shape || this.getEventShape(ev.name);
273
+ ev.map = this.id;
274
+ ev.server = this._server;
271
275
  ev.width = event.width || this.tileWidth;
272
276
  ev.height = event.height || this.tileHeight;
273
277
  if (_shape && _shape.properties)
274
278
  ev.properties = _shape.properties;
275
279
  if (event.hitbox)
276
280
  ev.setHitbox(event.hitbox.width, event.hitbox.height);
277
- ev.map = this.id;
278
281
  ev.teleport(position || ev.name);
279
- ev.server = this._server;
280
282
  return ev;
281
283
  }
282
284
  createEvents(eventsList, mode) {
@@ -291,6 +293,39 @@ class RpgMap extends common_1.RpgCommonMap {
291
293
  }
292
294
  return events;
293
295
  }
296
+ /**
297
+ * Allows to create a temporary hitbox on the map that can have a movement
298
+ For example, you can use it to explode a bomb and find all the affected players, or during a sword strike, you can create a moving hitbox and find the affected players again
299
+ * @title Create a temporary and moving hitbox
300
+ * @since 3.2.0
301
+ * @method map.createMovingHitbox(hitboxes,options)
302
+ * @param {Array<{ width: number, height: number, x: number, y: number }>} hitboxes Create several hitboxes that will give an effect of movement
303
+ * @param {object} [options]
304
+ * @param {speed} [options.speed=1] speed of movement (in frames)
305
+ * @returns {Observable<AbstractObject>} You find the methods of position and movement of an event
306
+ * @memberof Map
307
+ * @example
308
+ *
309
+ * ```ts
310
+ * // Two hitboxes that will be done very quickly
311
+ * map.createMovingHitbox(
312
+ * [
313
+ * { x: 0, y: 0, width: 100, height: 100 },
314
+ * { x: 20, y: 0, width: 100, height: 100 }
315
+ * ]
316
+ * ).subscribe({
317
+ * next(hitbox) {
318
+ * console.log(hitbox.otherPlayersCollision)
319
+ * },
320
+ * complete() {
321
+ * console.log('finish')
322
+ * }
323
+ * })
324
+ * ```
325
+ */
326
+ createMovingHitbox(hitboxes, options = {}) {
327
+ return this._createMovingHitbox(this.game, this._server.tick, this.id, hitboxes, options);
328
+ }
294
329
  setSync(schema) {
295
330
  return this.$setSchema(schema);
296
331
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Map.js","sourceRoot":"","sources":["../../src/Game/Map.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAA4E;AAC5E,wCAA8C;AAE9C,6CAAiE;AACjE,uDAA4C;AAmB5C,MAAM,SAAU,SAAQ,iBAAQ;IAI5B,MAAM;QACF,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAA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ACjB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,kBAAkB,CACd,QAAwD,EACxD,UAAwB,EAAE;QAC1B,OAAO,IAAI,CAAC,mBAAmB,CAC3B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,CAAC,IAAW,EACxB,IAAI,CAAC,EAAE,EACP,QAAQ,EACR,OAAO,CAAQ,CAAA;IACvB,CAAC;IAED,OAAO,CAAC,MAAW;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;CACJ;AAzTD,wBAyTC"}
@@ -2,6 +2,7 @@ import { ParameterManager } from './ParameterManager';
2
2
  import { RpgPlayer } from './Player';
3
3
  import { ElementManager } from './ElementManager';
4
4
  import { EffectManager } from './EffectManager';
5
+ import { RpgServerEngine } from '../server';
5
6
  export declare class BattleManager {
6
7
  /**
7
8
  * Apply damage. Player will lose HP. the `otherPlayer` parameter is the other player, the one who attacks.
@@ -31,5 +32,5 @@ export declare class BattleManager {
31
32
  }
32
33
  export interface BattleManager extends ParameterManager, ElementManager, EffectManager {
33
34
  name: string;
34
- server: any;
35
+ server: RpgServerEngine;
35
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BattleManager.js","sourceRoot":"","sources":["../../src/Player/BattleManager.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,yDAAqD;AAErD,wCAImB;AACnB,8CAAwC;AACxC,qDAAkD;AAClD,mDAAgD;AAEhD,MAAM,EACF,WAAW,EACd,GAAG,cAAK,CAAA;AAET,MAAa,aAAa;IAEtB;;;;;;;;;;;;;;;;SAgBK;IACL,WAAW,CAAC,WAAsB,EAAE,KAAW;QAO3C,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE;YACxB,MAAM,MAAM,GAAG,EAAE,CAAA;YACjB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBACjC,MAAM,CAAC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AC,CAAA;IAC3C,CAAC;CACJ;AAlGD,sCAkGC;AAED,WAAW,CAAC,aAAa,EAAE,CAAC,mCAAgB,EAAE,+BAAc,EAAE,6BAAa,CAAC,CAAC,CAAA"}
@@ -0,0 +1,397 @@
1
+ import { BarComponentObject, ComponentObject, LayoutObject, LayoutOptions, TextComponentObject, LayoutPositionEnum, ShapeComponentObject, ImageComponentObject, TileComponentObject, DebugComponentObject, TextComponentStyleObject } from '@rpgjs/types';
2
+ export declare const Components: {
3
+ /**
4
+ * Displays a bar
5
+ *
6
+ * Example:
7
+ *
8
+ * ```ts
9
+ * import { Components } from '@rpgjs/server'
10
+ * Components.bar('hp', 'param.maxHp', {
11
+ * bgColor: '#ab0606'
12
+ * })
13
+ * ```
14
+ *
15
+ * For text, you can use the following variables:
16
+ * - {$current} current value
17
+ * - {$max} maximum value
18
+ * - {$percent} percentage
19
+ *
20
+ * Example:
21
+ *
22
+ * ```ts
23
+ * import { Components } from '@rpgjs/server'
24
+ * Components.bar('hp', 'param.maxHp', {
25
+ * bgColor: '#ab0606'
26
+ * }, 'HP: {$current}/{$max}')
27
+ * ```
28
+ *
29
+ * and you can also use the variables of player:
30
+ *
31
+ * ```ts
32
+ * import { Components } from '@rpgjs/server'
33
+ * Components.bar('hp', 'param.maxHp', {
34
+ * bgColor: '#ab0606'
35
+ * }, 'HP: {$current}/{$max} - {name}') // HP: 100/100 - John
36
+ * ```
37
+ *
38
+ * @title Bar Component
39
+ * @param {string} current Parameter that corresponds to the current value
40
+ * @param {string} max Parameter that corresponds to the maximum value
41
+ * @param {object} [style] style
42
+ * @param {string} [style.bgColor] background color. Hexadecimal format.
43
+ * @param {string} [style.fillColor] fill color. Hexadecimal format.
44
+ * @param {string} [style.borderColor] border color. Hexadecimal format.
45
+ * @param {number} [style.borderWidth] border width
46
+ * @param {number} [style.height] height
47
+ * @param {number} [style.width] width
48
+ * @param {number} [style.borderRadius] border radius
49
+ * @param {number} [style.opacity] opacity
50
+ * @param {string | null} [text] text above bar. if null, no text will be displayed. You can use the variables
51
+ * @returns {BarComponentObject}
52
+ * @memberof Components
53
+ * @since 3.3.0
54
+ */
55
+ bar: (current: string, max: string, style?: BarComponentObject['value']['style'], text?: string | null | undefined) => BarComponentObject;
56
+ /**
57
+ * Displays a life bar
58
+ *
59
+ * @title HP Bar Component
60
+ * @param {object} [style] style. See bar style (Components.bar())
61
+ * @param {string | null} [text] test above bar (Components.bar())
62
+ * @returns {BarComponentObject}
63
+ * @memberof Components
64
+ * @since 3.3.0
65
+ */
66
+ hpBar(style?: BarComponentObject['value']['style'], text?: string | null | undefined): BarComponentObject;
67
+ /**
68
+ * Displays a SP bar
69
+ *
70
+ * @title SP Bar Component
71
+ * @param {object} [style] style. See bar style (Components.bar())
72
+ * @param {string | null} [text] test above bar (Components.bar())
73
+ * @returns {BarComponentObject}
74
+ * @memberof Components
75
+ * @since 3.3.0
76
+ */
77
+ spBar(style?: BarComponentObject['value']['style'], text?: string | null | undefined): BarComponentObject;
78
+ /**
79
+ * Put on the text. You can read the content of a variable with {} format (see example below)
80
+ *
81
+ * Example:
82
+ *
83
+ * ```ts
84
+ * import { Components } from '@rpgjs/server'
85
+ * Components.text('Hello World')
86
+ * ```
87
+ *
88
+ * Example with variable:
89
+ *
90
+ * ```ts
91
+ * import { Components } from '@rpgjs/server'
92
+ * Components.text('{name}')
93
+ * ```
94
+ *
95
+ * Other example with position:
96
+ *
97
+ * ```ts
98
+ * import { Components } from '@rpgjs/server'
99
+ * Components.text('X: {position.x} Y: {position.y}')
100
+ * ```
101
+ *
102
+ * With style:
103
+ *
104
+ * ```ts
105
+ * import { Components } from '@rpgjs/server'
106
+ * Components.text('Hello World', {
107
+ * fill: '#ffffff',
108
+ * fontSize: 20,
109
+ * fontFamily: 'Arial',
110
+ * stroke: '#000000',
111
+ * fontStyle: 'italic',
112
+ * fontWeight: 'bold'
113
+ * })
114
+ * ```
115
+ *
116
+ * @title Text Component
117
+ * @param {string} value source
118
+ * @param {object} [style] style
119
+ * @param {string} [style.fill] color. Hexadecimal format.
120
+ * @param {number} [style.fontSize] font size
121
+ * @param {string} [style.fontFamily] font family
122
+ * @param {string} [style.stroke] stroke color. Hexadecimal format.
123
+ * @param {'normal' | 'italic' | 'oblique'} [style.fontStyle] font style
124
+ * @param {'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'} [style.fontWeight] font weight
125
+ * @param {number} [style.opacity] opacity. Between 0 and 1
126
+ * @param {boolean} [style.wordWrap] word wrap
127
+ * @param {'left' | 'center' | 'right' | 'justify'} [style.align] align
128
+ * @returns {TextComponentObject}
129
+ * @memberof Components
130
+ * @since 3.3.0
131
+ */
132
+ text(value: string, style?: TextComponentStyleObject | undefined): TextComponentObject;
133
+ /**
134
+ * Add a shape
135
+ *
136
+ * Example:
137
+ *
138
+ * ```ts
139
+ * import { Components } from '@rpgjs/server'
140
+ * Components.shape({
141
+ * fill: '#ffffff',
142
+ * type: 'circle',
143
+ * radius: 10
144
+ * })
145
+ * ```
146
+ *
147
+ * You can use parameters:
148
+ *
149
+ * ```ts
150
+ * import { Components } from '@rpgjs/server'
151
+ * Components.shape({
152
+ * fill: '#ffffff',
153
+ * type: 'circle',
154
+ * radius: 'hp'
155
+ * })
156
+ * ```
157
+ *
158
+ * Here, the radius will be the same as the hp value
159
+ *
160
+ * @title Shape Component
161
+ * @param {object} value
162
+ * @param {string} value.fill color. Hexadecimal format.
163
+ * @param {number | string} [value.opacity] opacity. Between 0 and 1
164
+ * @param {string} value.type type of shape. Can be 'circle' or 'rectangle', 'ellipse' or 'polygon', 'line' or 'rounded-rectangle'
165
+ * @param {number | string} [value.radius] if type is circle, radius of the circle
166
+ * @param {number | string} [value.width] if type is rectangle or ellipse, width of the rectangle
167
+ * @param {number | string} [value.height] if type is rectangle or ellipse, height of the rectangle
168
+ * @param {number | string} [value.x1] if type is line, x1 position of the line
169
+ * @param {number | string} [value.y1] if type is line, y1 position of the line
170
+ * @param {number | string} [value.x2] if type is line, x2 position of the line
171
+ * @param {number | string} [value.y2] if type is line, y2 position of the line
172
+ * @param {number[]} [value.points] if type is polygon, points of the polygon
173
+ * @param {object} [value.line] border style
174
+ * @param {string} [value.line.color] border color. Hexadecimal format.
175
+ * @param {number} [value.line.width] border width
176
+ * @param {number} [value.line.alpha] border opacity. Between 0 and 1
177
+ * @returns {ShapeComponentObject}
178
+ * @memberof Components
179
+ * @since 3.3.0
180
+ */
181
+ shape(value: ShapeComponentObject['value']): ShapeComponentObject;
182
+ /**
183
+ * Put the link to an image or the identifier of an image (if the spritesheet exists)
184
+ *
185
+ * Example:
186
+ *
187
+ * ```ts
188
+ * import { Components } from '@rpgjs/server'
189
+ * Components.image('mygraphic.png')
190
+ * ```
191
+ *
192
+ * @title Image Component
193
+ * @param {string} value source
194
+ * @returns {ImageComponentObject}
195
+ * @memberof Components
196
+ * @since 3.3.0
197
+ */
198
+ image(value: string): ImageComponentObject;
199
+ /**
200
+ * Indicates the tile ID
201
+ *
202
+ * Example:
203
+ *
204
+ * ```ts
205
+ * import { Components } from '@rpgjs/server'
206
+ * Components.tile(3)
207
+ * ```
208
+ *
209
+ * @title Tile Component
210
+ * @param {number} value tile ID
211
+ * @returns {TileComponentObject}
212
+ * @memberof Components
213
+ * @since 3.3.0
214
+ */
215
+ tile(value: number): TileComponentObject;
216
+ debug(): DebugComponentObject;
217
+ };
218
+ export declare class ComponentManager {
219
+ layout: LayoutObject<any>;
220
+ /**
221
+ * Give the spritesheet identifier
222
+ *
223
+ * Since version 3.0.0-rc, you can define several graphic elements. If you put a number, it represents the tile ID in the tileset
224
+ *
225
+ * Example 1:
226
+ * ```ts
227
+ * player.setGraphic(['body', 'shield'])
228
+ * ```
229
+ *
230
+ * Example 2:
231
+ * ```ts
232
+ * player.setGraphic(3) // Use tile #3
233
+ * ```
234
+ *
235
+ * > You must, on the client side, create the spritesheet in question. Guide: [Create Sprite](/guide/create-sprite.html)
236
+ *
237
+ * @title Set Graphic
238
+ * @method player.setGraphic(graphic)
239
+ * @param {string | number | (string | number)[]} graphic
240
+ * @returns {void}
241
+ * @memberof ComponentManager
242
+ */
243
+ setGraphic(graphic: string | number | (string | number)[]): void;
244
+ /**
245
+ * Delete components
246
+ *
247
+ * @title Remove Components
248
+ * @param {string} position Position of the components. Can be: `top`, `center`, `bottom`, `left`, `right`
249
+ * @memberof ComponentManager
250
+ * @since 3.3.0
251
+ */
252
+ removeComponents(position: LayoutPositionEnum): void;
253
+ /**
254
+ * Delete components by id.
255
+ *
256
+ * @title Remove Component By Id
257
+ * @param {string} position Position of the components. Can be: `top`, `center`, `bottom`, `left`, `right`
258
+ * @param {string} id Id of the component
259
+ * @since 3.3.0
260
+ */
261
+ removeComponentById(position: LayoutPositionEnum, id: string): void;
262
+ /**
263
+ * Merges components with existing components
264
+ *
265
+ * For use layout and options, see [setComponentsTop](/api/player.html#setcomponentstop)
266
+ *
267
+ * @title Merge Components
268
+ * @param {string} position Position of the components. Can be: `top`, `center`, `bottom`, `left`, `right`
269
+ * @param {Object} layout
270
+ * @param {Object} options
271
+ * @memberof ComponentManager
272
+ * @since 3.3.0
273
+ */
274
+ mergeComponent<T = any>(position: LayoutPositionEnum, layout: ComponentObject<T>[][] | ComponentObject<T>[] | ComponentObject<T>, options?: LayoutOptions): void;
275
+ private setComponents;
276
+ /**
277
+ * Add components to the center of the graphic.
278
+ *
279
+ * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
280
+ *
281
+ * > Be careful, because if you assign, it deletes the graphics and if the lines are superimposed (unlike the other locations)
282
+ *
283
+ * @title Set Components Center
284
+ * @method player.setComponentsCenter(layout,options)
285
+ * @param {Object} layout
286
+ * @param {Object} options
287
+ * @memberof ComponentManager
288
+ * @since 3.3.0
289
+ */
290
+ setComponentsCenter<T = any>(layout: ComponentObject<T>[][] | ComponentObject<T>[] | ComponentObject<T>, options?: LayoutOptions): void;
291
+ /**
292
+ * Add components to the top of the graphic. e.g. text, life bar etc. The block will be centred
293
+ * The first array corresponds to the rows, and the nested table to the array in the row
294
+ *
295
+ * Example:
296
+ *
297
+ * ```ts
298
+ * import { Components } from '@rpgjs/server'
299
+ *
300
+ * player.setComponentsTop([
301
+ * [Components.text('Hello World')],
302
+ * [Components.hpBar()]
303
+ * ]) // 2 lines with 1 component each
304
+ * ```
305
+ *
306
+ * or
307
+ *
308
+ * ```ts
309
+ * import { Components } from '@rpgjs/server'
310
+ *
311
+ * player.setComponentsTop([
312
+ * [Components.text('Hello World'), Components.hpBar()]
313
+ * ]) // 1 line with 2 components
314
+ * ```
315
+ *
316
+ * You can be faster if you only have lines
317
+ *
318
+ * ```ts
319
+ * player.setComponentsTop([
320
+ * Components.text('Hello World'),
321
+ * Components.hpBar()
322
+ * ]) // 2 lines with 1 component each
323
+ * ```
324
+ *
325
+ * or one component:
326
+ *
327
+ * ```ts
328
+ * player.setComponentsTop(Components.text('Hello World')) // 1 line with 1 component
329
+ * ```
330
+ *
331
+ * You can add options to manage the style
332
+ *
333
+ * ```ts
334
+ * player.setComponentsTop([
335
+ * Components.text('Hello World'),
336
+ * Components.hpBar()
337
+ * ], {
338
+ * width: 100,
339
+ * height: 20,
340
+ * marginTop: 10,
341
+ * })
342
+ * ```
343
+ *
344
+ * @title Set Components Top
345
+ * @method player.setComponentsTop(layout,options)
346
+ * @param {ComponentObject[][] | ComponentObject[] | ComponentObject} layout Components
347
+ * @param {Object} [options = {}] Options
348
+ * @param {number} [options.width] Width of the block
349
+ * @param {number} [options.height = 20] Height of the block
350
+ * @param {number} [options.marginTop] Margin top
351
+ * @param {number} [options.marginBottom] Margin bottom
352
+ * @param {number} [options.marginLeft] Margin left
353
+ * @param {number} [options.marginRight] Margin right
354
+ * @memberof ComponentManager
355
+ * @since 3.3.0
356
+ */
357
+ setComponentsTop<T = any>(layout: ComponentObject<T>[][] | ComponentObject<T>[] | ComponentObject<T>, options?: LayoutOptions): void;
358
+ /**
359
+ * Add components to the bottom of the graphic.
360
+ *
361
+ * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
362
+ *
363
+ * @title Set Components Bottom
364
+ * @method player.setComponentsBottom(layout,options)
365
+ * @param {Object} layout
366
+ * @param {Object} options
367
+ * @memberof ComponentManager
368
+ * @since 3.3.0
369
+ */
370
+ setComponentsBottom<T = any>(layout: ComponentObject<T>[][] | ComponentObject<T>[] | ComponentObject<T>, options?: LayoutOptions): void;
371
+ /**
372
+ * Add components to the left of the graphic.
373
+ *
374
+ * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
375
+ *
376
+ * @title Set Components Left
377
+ * @method player.setComponentsLeft(layout,options)
378
+ * @param {Object} layout
379
+ * @param {Object} options
380
+ * @memberof ComponentManager
381
+ * @since 3.3.0
382
+ */
383
+ setComponentsLeft<T = any>(layout: ComponentObject<T>[][] | ComponentObject<T>[] | ComponentObject<T>, options?: LayoutOptions): void;
384
+ /**
385
+ * Add components to the right of the graphic.
386
+ *
387
+ * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
388
+ *
389
+ * @title Set Components Right
390
+ * @method player.setComponentsRight(layout,options)
391
+ * @param {Object} layout
392
+ * @param {Object} options
393
+ * @memberof ComponentManager
394
+ * @since 3.3.0
395
+ */
396
+ setComponentsRight<T = any>(layout: ComponentObject<T>[][] | ComponentObject<T>[] | ComponentObject<T>, options?: LayoutOptions): void;
397
+ }