Move RenderedTarget.runtime into Target

Some code in `Target` was already assuming a `runtime` property was
available, so this change just makes it official.
This commit is contained in:
Christopher Willis-Ford 2017-06-16 13:16:13 -07:00
parent b9aefa780f
commit 04871e24d6
2 changed files with 21 additions and 11 deletions

View file

@ -11,17 +11,25 @@ const uid = require('../util/uid');
* Examples include sprites/clones or potentially physical-world devices. * Examples include sprites/clones or potentially physical-world devices.
*/ */
/**
* @param {?Blocks} blocks Blocks instance for the blocks owned by this target.
* @constructor
*/
class Target extends EventEmitter { class Target extends EventEmitter {
constructor (blocks) {
/**
* @param {Runtime} runtime Reference to the runtime.
* @param {?Blocks} blocks Blocks instance for the blocks owned by this target.
* @constructor
*/
constructor (runtime, blocks) {
super(); super();
if (!blocks) { if (!blocks) {
blocks = new Blocks(); blocks = new Blocks();
} }
/**
* Reference to the runtime.
* @type {Runtime}
*/
this.runtime = runtime;
/** /**
* A unique ID for this target. * A unique ID for this target.
* @type {string} * @type {string}

View file

@ -4,14 +4,16 @@ const Target = require('../engine/target');
/** /**
* Rendered target: instance of a sprite (clone), or the stage. * Rendered target: instance of a sprite (clone), or the stage.
* @param {!Sprite} sprite Reference to the parent sprite.
* @param {Runtime} runtime Reference to the runtime.
* @constructor
*/ */
class RenderedTarget extends Target { class RenderedTarget extends Target {
/**
* @param {!Sprite} sprite Reference to the parent sprite.
* @param {Runtime} runtime Reference to the runtime.
* @constructor
*/
constructor (sprite, runtime) { constructor (sprite, runtime) {
super(sprite.blocks); super(runtime, sprite.blocks);
this.runtime = runtime;
/** /**
* Reference to the sprite that this is a render of. * Reference to the sprite that this is a render of.
* @type {!Sprite} * @type {!Sprite}
@ -19,7 +21,7 @@ class RenderedTarget extends Target {
this.sprite = sprite; this.sprite = sprite;
/** /**
* Reference to the global renderer for this VM, if one exists. * Reference to the global renderer for this VM, if one exists.
* @type {?RenderWebGLWorker} * @type {?RenderWebGL}
*/ */
this.renderer = null; this.renderer = null;
if (this.runtime) { if (this.runtime) {