| 184 | } |
| 185 | |
| 186 | override async apply(): Promise<void> { |
| 187 | const defaultFunction = () => Promise.resolve(); |
| 188 | |
| 189 | this.element.setProps({ |
| 190 | mode: this.mode, |
| 191 | canvas: this.name, |
| 192 | // We need to pass the object this way so we can clone the state |
| 193 | // property instead of pasing it by reference. Otherwise, any changes |
| 194 | // made to it during execution would be kept there and the next time we |
| 195 | // use the same object, we'll receive the modified state object instead |
| 196 | // of a clean one. |
| 197 | object: { |
| 198 | layers: this.object.layers || ['base'], |
| 199 | props: this.object.props || {}, |
| 200 | state: { ...(this.object.state || {}) }, |
| 201 | start: this.object.start || defaultFunction, |
| 202 | stop: this.object.stop || defaultFunction, |
| 203 | resize: this.object.resize || defaultFunction, |
| 204 | }, |
| 205 | classes: this.classes |
| 206 | }); |
| 207 | |
| 208 | const gameScreen = this.engine.element().find('[data-screen="game"]'); |
| 209 | |
| 210 | if (this.mode === 'background') { |
| 211 | gameScreen.find('[data-ui="background"]').append(this.element); |
| 212 | } else if (this.mode === 'immersive') { |
| 213 | gameScreen.append(this.element); |
| 214 | } else if (this.mode === 'displayable' || this.mode === 'modal' || this.mode === 'character') { |
| 215 | (gameScreen.get(0) as unknown as Component)?.content('visuals')?.append(this.element); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | override async didApply({ updateHistory = true, updateState = true } = {}): Promise<ActionApplyResult> { |
| 220 | const statement = this._statement as string; |