mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-12 22:42:03 -04:00
Move tracking of edge activated hat values into target.
This commit is contained in:
parent
19737d4e39
commit
6c4fb29523
4 changed files with 40 additions and 34 deletions
src/engine
|
@ -221,13 +221,6 @@ class Runtime extends EventEmitter {
|
|||
*/
|
||||
this._hats = {};
|
||||
|
||||
/**
|
||||
* Currently known values for edge-activated hats.
|
||||
* Keys are block ID for the hat; values are the currently known values.
|
||||
* @type {Object.<string, *>}
|
||||
*/
|
||||
this._edgeActivatedHatValues = {};
|
||||
|
||||
/**
|
||||
* A list of script block IDs that were glowing during the previous frame.
|
||||
* @type {!Array.<!string>}
|
||||
|
@ -1230,26 +1223,6 @@ class Runtime extends EventEmitter {
|
|||
this._hats[opcode].edgeActivated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an edge-activated hat block value.
|
||||
* @param {!string} blockId ID of hat to store value for.
|
||||
* @param {!string} threadTargetId Target ID for the thread that the block belongs to
|
||||
* @param {*} newValue Value to store for edge-activated hat.
|
||||
* @return {*} The old value for the edge-activated hat.
|
||||
*/
|
||||
updateEdgeActivatedValue (blockId, threadTargetId, newValue) {
|
||||
const blockAndTargetId = `${blockId}_${threadTargetId}`;
|
||||
const oldValue = this._edgeActivatedHatValues[blockAndTargetId];
|
||||
this._edgeActivatedHatValues[blockAndTargetId] = newValue;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all edge-activaed hat values.
|
||||
*/
|
||||
clearEdgeActivatedValues () {
|
||||
this._edgeActivatedHatValues = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach the audio engine
|
||||
|
@ -1689,7 +1662,7 @@ class Runtime extends EventEmitter {
|
|||
this.stopAll();
|
||||
this.emit(Runtime.PROJECT_START);
|
||||
this.ioDevices.clock.resetProjectTimer();
|
||||
this.clearEdgeActivatedValues();
|
||||
this.targets.forEach(target => target.clearEdgeActivatedValues());
|
||||
// Inform all targets of the green flag.
|
||||
for (let i = 0; i < this.targets.length; i++) {
|
||||
this.targets[i].onGreenFlag();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue