dead-bunny/js/plugins/Nore_CommonEvent.js
2025-01-12 01:21:39 -06:00

70 lines
2.3 KiB
JavaScript

/*:ja
* @target MZ
* @author ル
*
* @command run
* @text コモンイベント実行
* @des コモンイベント実行
*/
var Nore;
(function (Nore) {
var pluginName = "Nore_CommonEvent";
PluginManager.registerCommand(pluginName, "run", function (args) {
var commonEventId = $commonEvent.nextCommonEvent();
if (isNaN(commonEventId)) {
console.error("コモンイベントが存在しません:");
return;
}
p("Nore_commonEvent commonEvent:" + commonEventId);
//$gameTemp.reserveCommonEvent(commonEventId);
//$gameMap._interpreter.setupReservedCommonEvent()
var commonEvent = $dataCommonEvents[commonEventId];
$gameMap._interpreter.setupChild(commonEvent.list, 0);
});
var DataManager_createGameObjects = DataManager.createGameObjects;
DataManager.createGameObjects = function () {
DataManager_createGameObjects.call(this);
$commonEvent = new Game_ReservedCommonEvent();
};
var _DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function (contents) {
_DataManager_extractSaveContents.call(this, contents);
$commonEvent = contents.reservedCommonEvent;
};
var _DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function () {
var contents = _DataManager_makeSaveContents.call(this);
contents.reservedCommonEvent = $commonEvent;
return contents;
};
})(Nore || (Nore = {}));
var CommonEventData = /** @class */ (function () {
function CommonEventData(commonEventId, id) {
this.commonEventId = commonEventId;
this._id = id;
}
CommonEventData.prototype.id = function () {
return this._id;
};
return CommonEventData;
})();
var Game_ReservedCommonEvent = /** @class */ (function () {
function Game_ReservedCommonEvent() {
this._commonEventList = [];
}
Game_ReservedCommonEvent.prototype.reserveCommonEvent = function (
commonEventId,
id
) {
this._commonEventList.push(new CommonEventData(commonEventId, id));
$gameSwitches.setValue(8, true);
};
Game_ReservedCommonEvent.prototype.isCommonEventReserved = function () {
return this._commonEventList.length > 0;
};
Game_ReservedCommonEvent.prototype.nextCommonEvent = function () {
return this._commonEventList.shift();
};
return Game_ReservedCommonEvent;
})();
var $commonEvent;