Fix issues uncovered where clones were triggering automatically on create.

This commit is contained in:
Karishma Chadha 2018-12-12 13:25:19 -05:00
parent 6c4fb29523
commit e5b00dfd95
3 changed files with 10 additions and 2 deletions

View file

@ -63,11 +63,13 @@ const handleReport = function (resolvedValue, sequencer, thread, blockCached, la
// true and used to be false, or the stack was activated explicitly
// via stack click
if (!thread.stackClick) {
const hasOldEdgeValue = thread.target.hasEdgeActivatedValue(currentBlockId);
const oldEdgeValue = thread.target.updateEdgeActivatedValue(
currentBlockId,
resolvedValue
);
const edgeWasActivated = !oldEdgeValue && resolvedValue;
const edgeWasActivated = hasOldEdgeValue ? (!oldEdgeValue && resolvedValue) : resolvedValue;
if (!edgeWasActivated) {
sequencer.retireThread(thread);
}

View file

@ -103,6 +103,10 @@ class Target extends EventEmitter {
return oldValue;
}
hasEdgeActivatedValue (blockId) {
return this._edgeActivatedHatValues.hasOwnProperty(blockId);
}
/**
* Clear all edge-activaed hat values.
*/

View file

@ -1,6 +1,7 @@
const log = require('../util/log');
const MathUtil = require('../util/math-util');
const StringUtil = require('../util/string-util');
const Clone = require('../util/clone');
const Target = require('../engine/target');
const StageLayering = require('../engine/stage-layering');
@ -1015,8 +1016,9 @@ class RenderedTarget extends Target {
newClone.size = this.size;
newClone.currentCostume = this.currentCostume;
newClone.rotationStyle = this.rotationStyle;
newClone.effects = JSON.parse(JSON.stringify(this.effects));
newClone.effects = Clone.simple(this.effects);
newClone.variables = this.duplicateVariables();
newClone._edgeActivatedHatValues = Clone.simple(this._edgeActivatedHatValues);
newClone.initDrawable(StageLayering.SPRITE_LAYER);
newClone.updateAllDrawableProperties();
// Place behind the current target.