8000 Look-up based on string or instance · ITCSsDeveloper/phaser@93b569c · GitHub
Skip to content

Commit 93b569c

Browse files
committed
Look-up based on string or instance
1 parent ba9b837 commit 93b569c

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

src/renderer/webgl/PipelineManager.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,35 +297,55 @@ var PipelineManager = new Class({
297297
},
298298

299299
/**
300-
* Checks if a pipeline is present in the Pipeline Manager.
300+
* Checks if a pipeline is present in this Pipeline Manager.
301301
*
302302
* @method Phaser.Renderer.WebGL.PipelineManager#has
303303
* @since 3.50.0
304304
*
305-
* @param {string} name - The name of the pipeline to check for.
305+
* @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} pipeline - Either the string-based name of the pipeline to get, or a pipeline instance to look-up.
306306
*
307307
* @return {boolean} `true` if the given pipeline is loaded, otherwise `false`.
308308
*/
309-
has: function (name)
309+
has: function (pipeline)
310310
{
311-
return this.pipelines.has(name);
311+
var pipelines = this.pipelines;
312+
313+
if (typeof pipeline === 'string')
314+
{
315+
return pipelines.has(pipeline);
316+
}
317+
else if (pipelines.contains(pipeline))
318+
{
319+
return true;
320+
}
321+
322+
return false;
312323
},
313324

314325
/**
315-
* Returns the pipeline instance based on the given name.
326+
* Returns the pipeline instance based on the given name, or instance.
316327
*
317-
* If no instance exists in this manager, it returns `undefined` instead.
328+
* If no instance, or matching name, exists in this manager, it returns `undefined`.
318329
*
319330
* @method Phaser.Renderer.WebGL.PipelineManager#get
320331
* @since 3.50.0
321332
*
322-
* @param {string} name - The name of the pipeline to get.
333+
* @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} pipeline - Either the string-based name of the pipeline to get, or a pipeline instance to look-up.
323334
*
324335
* @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline instance, or `undefined` if not found.
325336
*/
326-
get: function (name)
337+
get: function (pipeline)
327338
{
328-
return this.pipelines.get(name);
339+
var pipelines = this.pipelines;
340+
341+
if (typeof pipeline === 'string')
342+
{
343+
return pipelines.get(pipeline);
344+
}
345+
else if (pipelines.contains(pipeline))
346+
{
347+
return pipeline;
348+
}
329349
},
330350

331351
/**

0 commit comments

Comments
 (0)