MCPcopy Create free account
hub / github.com/codecombat/codecombat / onNewWorld

Method onNewWorld

app/views/play/SpectateView.js:382–410  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

380 // Dynamic sound loading
381
382 onNewWorld (e) {
383 if (this.headless) { return }
384 const {
385 scripts
386 } = this.world // Since these worlds don't have scripts, preserve them.
387 this.world = e.world
388 this.world.scripts = scripts
389 const thangTypes = this.supermodel.getModels(ThangType)
390 const startFrame = this.lastWorldFramesLoaded != null ? this.lastWorldFramesLoaded : 0
391 if (this.world.frames.length === this.world.totalFrames) { // Finished loading
392 this.lastWorldFramesLoaded = 0
393 if (utils.getQueryVariable('autoplay') !== false) {
394 Backbone.Mediator.publish('level:set-playing', { playing: true }) // Since we paused at first, now we autostart playback.
395 }
396 } else {
397 this.lastWorldFramesLoaded = this.world.frames.length
398 }
399 return (() => {
400 const result = []
401 for (const [spriteName, message] of Array.from(this.world.thangDialogueSounds(startFrame))) {
402 const thangType = _.find(thangTypes, m => m.get('name') === spriteName)
403 const sound = AudioPlayer.soundForDialogue(message, thangType.get('soundTriggers'))
404 if (!thangType) { continue }
405 if (!sound) { continue }
406 result.push(AudioPlayer.preloadSoundReference(sound))
407 }
408 return result
409 })()
410 }
411
412 setSessions (sessionOne, sessionTwo) {
413 this.sessionOne = sessionOne

Callers

nothing calls this directly

Calls 2

publishMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected