Source: Game_SelfSwitches.js

Game_SelfSwitches.js

//-----------------------------------------------------------------------------
// Game_SelfSwitches
//
// The game object class for self switches.
/**
 * The game object class for self switches.
 *
 * @class
 */
function Game_SelfSwitches() {
    this.initialize(...arguments);
}

/**
 * Initialize the self switches
 */
Game_SelfSwitches.prototype.initialize = function() {
    this.clear();
};

/**
 * Clear all self switches
 */
Game_SelfSwitches.prototype.clear = function() {
    this._data = {};
};

/**
 * Get the self switch value for the given self switch key
 *
 * @param {Array} key - The self switch key
 * @param {boolean} value - The value stored in the self switch
 */
Game_SelfSwitches.prototype.value = function(key) {
    return !!this._data[key];
};

/**
 * Set the self switch value for the given self switch key
 *
 * @param {Array} key - The self switch key
 * @param {boolean} value - The value to store in the self switch
 */
Game_SelfSwitches.prototype.setValue = function(key, value) {
    if (value) {
        this._data[key] = true;
    } else {
        delete this._data[key];
    }
    this.onChange();
};

/**
 * Processing when a self switch's value is changed
 */
Game_SelfSwitches.prototype.onChange = function() {
    $gameMap.requestRefresh();
};