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 {
20
20
/**
21
21
* @param {Runtime } runtime Reference to the runtime.
22
22
* @param {?Blocks } blocks Blocks instance for the blocks owned by this target.
23
+ * @param {?Object.<string, *> } comments Array of comments owned by this target.
23
24
* @constructor
24
25
*/
25
- constructor ( runtime , blocks ) {
26
+ constructor ( runtime , blocks , comments ) {
26
27
super ( ) ;
27
28
28
29
if ( ! blocks ) {
@@ -55,7 +56,7 @@ class Target extends EventEmitter {
55
56
* Key is the comment id.
56
57
* @type {Object.<string,*> }
57
58
*/
58
- this . comments = { } ;
59
+ this . comments = comments || { } ;
59
60
/**
60
61
* Dictionary of custom state for this target.
61
62
* 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 {
15
15
* @constructor
16
16
*/
17
17
constructor ( sprite , runtime ) {
18
- super ( runtime , sprite . blocks ) ;
18
+ super ( runtime , sprite . blocks , sprite . comments ) ;
19
19
20
20
/**
21
21
* 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 {
54
54
if ( this . runtime && this . runtime . audioEngine ) {
55
55
this . soundBank = this . runtime . audioEngine . createBank ( ) ;
56
56
}
57
+ /**
58
+ * Dictionary of comments for this target.
59
+ * Key is the comment id.
60
+ * @type {Object.<string.*> }
61
+ */
62
+ this . comments = { } ;
57
63
}
58
64
59
65
/**
@@ -145,7 +151,11 @@ class Sprite {
145
151
newSprite . blocks . createBlock ( block ) ;
146
152
} ) ;
147
153
148
-
154
+ Object . keys ( this . comments ) . forEach ( commentId => {
155
+ const newComment = this . comments [ commentId ] ;
156
+ newSprite . comments [ newComment . id ] = newComment ;
157
+ } ) ;
158
+
149
159
const allNames = this . runtime . targets . map ( t => t . sprite . name ) ;
150
160
newSprite . name = StringUtil . unusedName ( this . name , allNames ) ;
151
161
You can’t perform that action at this time.
0 commit comments