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

Method loadThangTypes

ozaria/engine/cinematic/Loader.js:105–133  ·  view source on GitHub ↗

* Iterate through the shotSetups and start loading the required thangTypes. * Doesn't block until `load` method is called. * * TODO: Add retry logic to the getThang function.

(shots)

Source from the content-addressed store, hash-verified

103 * TODO: Add retry logic to the getThang function.
104 */
105 loadThangTypes (shots) {
106 const slugs = []
107 shots
108 .forEach(shot => {
109 const { slug } = getLeftCharacterThangTypeSlug(shot) || {}
110 if (slug) {
111 slugs.push(slug)
112 }
113 const { slug: slug2 } = getRightCharacterThangTypeSlug(shot) || {}
114 if (slug2) {
115 slugs.push(slug2)
116 }
117 const backgroundSlug = getBackgroundSlug(shot) || {}
118 if (backgroundSlug) {
119 slugs.push(backgroundSlug)
120 }
121 const heroPetSlug = (getHeroPet(shot) || {}).slug
122 if (heroPetSlug) {
123 slugs.push(heroPetSlug)
124 }
125 })
126 // Now we have a list of only slugs, we can fetch the data,
127 // storing the promise in our `loadedThangTypes` Map.
128 slugs
129 .filter(character => character)
130 .filter(slug => typeof slug === 'string')
131 .filter(slug => !(this.loadedThangTypes.has(slug) || this.loadingThangTypes.has(slug)))
132 .forEach(slug => this.queueThangType(slug))
133 }
134
135 /**
136 * Queues a ThangType resource for async loading.

Callers 1

loadAssetsMethod · 0.95

Calls 2

queueThangTypeMethod · 0.95
filterMethod · 0.80

Tested by

no test coverage detected