File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,10 @@ class Target extends EventEmitter {
2020 /**
2121 * @param {Runtime } runtime Reference to the runtime.
2222 * @param {?Blocks } blocks Blocks instance for the blocks owned by this target.
23+ * @param {?Object.<string, *> } comments Array of comments owned by this target.
2324 * @constructor
2425 */
25- constructor ( runtime , blocks ) {
26+ constructor ( runtime , blocks , comments ) {
2627 super ( ) ;
2728
2829 if ( ! blocks ) {
@@ -55,7 +56,7 @@ class Target extends EventEmitter {
5556 * Key is the comment id.
5657 * @type {Object.<string,*> }
5758 */
58- this . comments = { } ;
59+ this . comments = comments || { } ;
5960 /**
6061 * Dictionary of custom state for this target.
6162 * This can be used to store target-specific custom state for blocks which need it.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class RenderedTarget extends Target {
1515 * @constructor
1616 */
1717 constructor ( sprite , runtime ) {
18- super ( runtime , sprite . blocks ) ;
18+ super ( runtime , sprite . blocks , sprite . comments ) ;
1919
2020 /**
2121 * Reference to the sprite that this is a render of.
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ class Sprite {
5454 if ( this . runtime && this . runtime . audioEngine ) {
5555 this . soundBank = this . runtime . audioEngine . createBank ( ) ;
5656 }
57+ /**
58+ * Dictionary of comments for this target.
59+ * Key is the comment id.
60+ * @type {Object.<string.*> }
61+ */
62+ this . comments = { } ;
5763 }
5864
5965 /**
@@ -145,7 +151,11 @@ class Sprite {
145151 newSprite . blocks . createBlock ( block ) ;
146152 } ) ;
147153
148-
154+ Object . keys ( this . comments ) . forEach ( commentId => {
155+ const newComment = this . comments [ commentId ] ;
156+ newSprite . comments [ newComment . id ] = newComment ;
157+ } ) ;
158+
149159 const allNames = this . runtime . targets . map ( t => t . sprite . name ) ;
150160 newSprite . name = StringUtil . unusedName ( this . name , allNames ) ;
151161
You can’t perform that action at this time.
0 commit comments