/*:
 * @target MZ
 * @author Aerosys
 * @url https://aerosys.blog
 * @plugindesc [Tier 2] [Version 1.2.0] [MV & MZ]
 * @base MK_SpawnEvents
 * @base MK_MapManipulation
 * 
 * 
 * @help
 * 
 * ----------------------------------------------------------------------------
 * Rules
 * ----------------------------------------------------------------------------
 * 
 * 1. <not applicable>
 * 
 * 2. You may not redistribute this Plugin or claim it as your own.
 *    
 *    a) Exception: You may redistribute this plugin as part of your game when
 *       releasing it.
 *    b) Exception: You may send this plugin to another person when you hire
 *       them for personal modifications.
 * 
 * 3. You may modify this plugin's source code for your needs but cannot
 *    redistribute your modifications.
 * 
 * 4. You may create plugins based on this (e.g. addon or extension) for your
 *    needs but you cannot redistribute them.
 * 
 * 5. When multiple people work on the project, purchasing a license for every
 *    team member is not required.
 * 
 * 
 * NEED SUPPORT?
 * Contact me: mail<at>aerosys.blog
 * 
 * 
 * @endofhelp
 * 
 * 
 * @command startBuildMode
 * @text Start Build Mode
 * 
 * @arg blueprintName
 * @text Blueprint
 * 
 * 
 * @command quitBuildMode
 * @text Quit Build Mode
 * 
 * 
 * @command startRestoreMode
 * @text Start Restore Mode
 * 
 * 
 * @command quitRestoreMode
 * @text Quit Restore Mode
 * 
 * 
 * @command addOrRemoveBlueprint
 * @text Learn/Forget Blueprint
 * 
 * @arg blueprintName
 * @text Blueprint Name
 * @default REQUIRED
 * 
 * @arg mode
 * @type select
 * @option Learn
 * @option Forget
 * @default Learn
 * 
 * 
 * @command setShovelMode
 * @text Set Shovel Mode
 * 
 * @arg mode
 * @text Mode
 * @type boolean
 * @default true
 * 
 * 
 * @command changeBuildCostModifier
 * @text Change Build Cost Modifier
 * 
 * @arg modifier
 * @text Modifier
 * @type number
 * @decimals 1
 * @default 1.0
 * 
 * 
 * @param general
 * @text General
 * 
 * @param blueprints
 * @parent general
 * @text Blueprints
 * @type struct<Blueprint>[]
 * @default []
 * 
 * @param commonEvents
 * @parent general
 * @text Variables & Common Events
 * @type struct<CommonEvents>
 * @desc All those options are optional
 * 
 * @param staminaVariableId
 * @parent general
 * @text Stamina Variable
 * @type variable
 * 
 * @param a
 * @text _
 * 
 * @param soundEffects
 * @text Sound Effects
 * 
 * @param onBuildSE
 * @parent soundEffects
 * @text SE: when build
 * @type file
 * @dir audio/se
 * @require 1
 * @default Jump2
 * 
 * @param onRestoreSE
 * @parent soundEffects
 * @text SE: when restore
 * @type file
 * @dir audio/se
 * @require 1
 * @default Run
 * 
 * @param b
 * @text _
 * 
 * @param graphics
 * @text Graphics
 * 
 * @param spritePreviewUpdateEval
 * @parent graphics
 * @text JS: Sprite Preview (update)
 * @type note
 * @default "// constants\nconst canBuildHere = arguments[0];\n\n// function\nthis.opacity = 0.1 * Math.sin(Date.now() / 200) * 255\n                 + 200;\n\nthis.setColorTone(canBuildHere\n  ? [ 0, 0, 0, 0 ]\n  : [ -100, -100, -100, 0 ]\n);"
 * 
 * @param eraserColor
 * @parent graphics
 * @text Eraser Color (HEX)
 * @default #cccccc
 * 
 * @param eraserOpacity
 * @parent graphics
 * @text Eraser Opacity
 * @type number
 * @default 122
 * 
 * @param c
 * @text _
 * 
 * @param helpWindow
 * @text Help Window
 * 
 * @param showHelpWindow
 * @parent helpWindow
 * @text Show?
 * @type boolean
 * @default true
 * 
 * @param helpWindowRectangleEval
 * @parent helpWindow
 * @text JS: Rectangle
 * @type note
 * @default "const nLines = 3;\n\nconst width = Graphics.width * 0.3;\nconst height = 'MZ' == Utils.RPGMAKER_NAME\n  ? this.calcWindowHeight(nLines)\n  : new Window_Base(0, 0, 0, 0).fittingHeight(nLines);\nconst x = Graphics.width - width - 20;\nconst y = Graphics.height - height - 10;\n\nreturn new Rectangle(x, y, width, height);"
 * 
 * @param helpWindowDrawEval
 * @parent helpWindow
 * @text JS: Draw
 * @type note
 * @default "const vocabulary = arguments[0];\nconst x1 = 10;\nconst x2 = this.contentsWidth() / 2 + 10;\nconst w1 = this.contentsWidth() / 2 - 10;\nconst w2 = w1;\n\nthis.resetTextColor();\nthis.drawText(\n    vocabulary.moveObject,\n    x2,\n    0,\n    w2,\n);\nthis.drawText(\n    vocabulary.placeObject,\n    x2,\n    this.lineHeight(),\n    w2,\n);\nthis.drawText(\n    vocabulary.quit,\n    x2,\n    2 * this.lineHeight(),\n    w2,\n);\n\nconst color = 'MZ' == Utils.RPGMAKER_NAME\n    ? ColorManager.systemColor()\n    : this.systemColor();\nthis.changeTextColor(color);\n\nthis.drawText(\n    vocabulary.arrowKeys,\n    x1,\n    0,\n    w1,\n    'right',\n);\nthis.drawText(\n    vocabulary.actionKey,\n    x1,\n    this.lineHeight(),\n    w1,\n    'right',\n);\nthis.drawText(\n    vocabulary.cancelKey,\n    x1,\n    2 * this.lineHeight(),\n    w1,\n    'right',\n);"
 * 
 * @param z
 * @text _
 * 
 * @param vocabulary
 * @text Vocabulary
 * @type struct<Vocabulary>
 * @default {"arrowKeys":"Arrows/Mouse","moveObject":"Move","actionKey":"Enter","placeObject":"Place","cancelKey":"Esc","quit":"Quit"}
 * 
 */

/*~struct~Blueprint:
 *
 * @param name
 * @text Name
 * @default REQUIRED
 * @desc Must be unique!
 * 
 * @param category
 * @text Category
 * @desc Categorizing is optional but is recommended
 * 
 * @param description
 * @text Description
 * @type note
 * 
 * @param sourceMapSettings
 * @text Source Map
 * 
 * @param sourceMapName
 * @parent sourceMapSettings
 * @text Sourcemap Name
 * @default REQUIRED
 * 
 * @param regionIds
 * @parent sourceMapSettings
 * @text Region ID(s)
 * @default 1
 * @desc Use 1,2,4 to select 1, 2, and 4. Use 1-3 to select 1, 2, 3. Use * to select all from the map.
 * 
 * @param requirements
 * @text Requirements
 * 
 * @param requiredItems
 * @parent requirements
 * @text Items
 * @type struct<ItemAndQuantity>[]
 * 
 * @param gold
 * @parent requirements
 * @text Gold
 * @type number
 * 
 * @param staminaCost
 * @parent requirements
 * @text Stamina
 * @type number
 * 
 * @param conditions
 * @text Conditions
 * 
 * @param preconditionSwitchId
 * @parent conditions
 * @text Switch
 * @type switch
 * @desc When given, this Switch must be ON to allow this build
 * 
 * @param preconditionVariableId
 * @parent conditions
 * @text Variable
 * @type variable
 * @desc When given, this Variable must be >= the given value (see: next Plugin Parameter)
 * 
 * @param preconditionVariableLargerThan
 * @parent conditions
 * @text >=
 * @type number
 * @default 1
 * 
 * @param preconditionEval
 * @parent conditions
 * @text JS: Custom Code
 * @type note
 * 
 * @param onBuildSE
 * @text SE: when build
 * @type file
 * @dir audio/se
 * @require 1
 * 
 * @param shakeScreen
 * @text Shake Screen when build?
 * @type boolean
 * 
 * @param postBuildEvents
 * @text Post Build Events
 * 
 * @param switchId
 * @parent postBuildEvents
 * @text Switch
 * @type switch
 * @desc When given, this Switch is turned ON when building
 * 
 * @param commonEventId
 * @parent postBuildEvents
 * @text Common Event
 * @type common_event
 * @desc When given, this Common Event is started when building. The global Common Event will be skipped.
 * 
 * @param onBuildEval
 * @parent postBuildEvents
 * @text JS: Custom Code
 * @type note
 * 
 * @param others
 * @text Others
 * 
 * @param initiallyAvailable
 * @parent others
 * @text Initially available?
 * @type boolean
 * @default false
 */

/*~struct~ItemAndQuantity:
 *
 * @param item
 * @text Item
 * @type item
 * 
 * @param quantity
 * @text Quantity
 * @type number
 * @default 1
 * 
 */

/*~struct~CommonEvents:
 *
 * @param variables
 * @text Variables
 * 
 * @param onBuildSetVariableId
 * @parent variables
 * @text last Blueprint
 * @type variable
 * @desc This Variable contains the last built blueprint name as STRING for later retrieval
 * 
 * @param onBuildSetRegionIdVariableId
 * @parent variables
 * @text last Region ID
 * @type variable
 * @desc This Variable contains the last built Region ID for later retrieval
 *
 * @param a
 * @text _
 * 
 * @param commonEvents
 * @text Common Events
 * 
 * @param onStartBuildModeCommonEventId
 * @parent commonEvents
 * @text Start Build Mode
 * @type common_event
 * 
 * @param onQuitBuildModeCommonEventId
 * @parent commonEvents
 * @text Quit Build Mode
 * @type common_event
 * 
 * @param onBuildCommonEventId
 * @parent commonEvents
 * @text On Build
 * @type common_event
 * 
 * @param onRestoreCommonEventId
 * @parent commonEvents
 * @text On Restore
 * @type common_event
 * 
 * @param onNotEnoughStaminaCommonEventId
 * @parent commonEvents
 * @text Not enough Stamina
 * @type common_event
 * 
 * @param onNotEnoughMaterialsCommonEventId
 * @parent commonEvents
 * @text Not enough Materials
 * @type common_event
 * 
 * @param onCannotBuildHereCommonEventId
 * @parent commonEvents
 * @text Cannot build here
 * @type common_event
 * 
 * @param onCannotBuildRightNowCommonEventId
 * @parent commonEvents
 * @text Cannot build right now
 * @type common_event
 * 
 */

/*~struct~Vocabulary:
 *
 * @param arrowKeys
 * @text Arrow Keys
 * @default Arrows/Mouse
 * 
 * @param moveObject
 * @text Move Object
 * @default Move
 * 
 * @param actionKey
 * @text Action Key
 * @default Enter
 * 
 * @param placeObject
 * @text Place
 * @default Place
 * 
 * @param cancelKey
 * @text Quit Key
 * @default Esc
 * 
 * @param quit
 * @text Quit
 * @default Quit
 * 
 */


var MK = MK || { };
MK.Sandbox = { };


(function(){const _0x34d698='MK_SandboxEngine',_0x198c84=_0x2474e1=>{const _0x20ce93=('An\x20Error\x20has\x20occurred\x20in\x20the\x20Plugin\x20%1:\x20%2\x20'+'If\x20the\x20problem\x20persists,\x20contact\x20the\x20Plugin\x20Creator.')['format'](_0x34d698,_0x2474e1);throw Error(_0x20ce93);};!PluginManager['_parameters'][_0x34d698['toLowerCase']()]&&_0x198c84(('Please\x20check\x20that\x20this\x20plugin\x27s\x20filename\x20is\x20\x22%1.js\x22.\x20'+'Subdirectories\x20(e.g.:\x20js/plugins/xy/thisPlugin.js)\x20are\x20not\x20allowed.')['format'](_0x34d698));const _0x3ac579=(_0x597fb7,_0x1babb1)=>{!_0x597fb7&&_0x198c84(('The\x20Plugin\x20Parameter\x20\x22%1\x22\x20is\x20missing.\x20'+'Please\x20check\x20it\x20in\x20the\x20Plugin\x20Manager.\x20It\x20may\x20help\x20to\x20re-install\x20this\x20Plugin\x20(i.e.:\x20remove,\x20re-add).')['format'](_0x1babb1));try{return JSON['parse'](_0x597fb7);}catch(_0x3d1f9e){_0x198c84(('The\x20Plugin\x20Parameter\x20\x22%1\x22\x20is\x20corrupted.\x20'+'Please\x20check\x20it\x20in\x20the\x20Plugin\x20Manager.\x20It\x20may\x20help\x20to\x20re-install\x20this\x20Plugin\x20(i.e.:\x20remove,\x20re-add).')['format'](_0x1babb1));}},_0x43de28=(_0x1b97d5,_0x48e5bc)=>{!_0x1b97d5&&_0x198c84(('The\x20Plugin\x20Parameter\x20\x22%1\x22\x20is\x20missing.\x20'+'Please\x20check\x20it\x20in\x20the\x20Plugin\x20Manager.\x20It\x20may\x20help\x20to\x20re-install\x20this\x20Plugin\x20(i.e.:\x20remove,\x20re-add).')['format'](_0x48e5bc));try{return new Function(JSON['parse'](_0x1b97d5));}catch(_0x554e1b){_0x198c84(('The\x20Plugin\x20Parameter\x20\x22%1\x22\x20contains\x20an\x20error\x20and\x20could\x20not\x20be\x20interpreted.\x20'+'Please\x20check\x20it\x20in\x20the\x20Plugin\x20Manager.\x20It\x20may\x20also\x20help\x20to\x20re-install\x20this\x20Plugin\x20(i.e.:\x20remove,\x20re-add).\x20'+'Cause:\x20%2')['format'](_0x48e5bc,_0x554e1b));}},_0x4ffd38=(_0x5908f6,_0x8f81af)=>{if(!_0x5908f6)_0x198c84('The\x20required\x20Plugin\x20\x22%1\x22\x20is\x20missing.\x20Please\x20add\x20it\x20to\x20the\x20Plugin\x20Manager.'['format'](_0x8f81af));},_0x3063a4=(_0x1ad052,_0x4bd80e)=>{const _0x252d69=typeof _0x4bd80e!=='undefined'?_0x1ad052:0x0,_0x4f70f2=typeof _0x4bd80e!=='undefined'?_0x4bd80e:_0x1ad052,_0x29ab19=[];for(let _0x31ab04=_0x252d69;_0x31ab04<_0x4f70f2;_0x31ab04++){_0x29ab19['push'](_0x31ab04);}return _0x29ab19;},_0x3c415a=Scene_Boot['prototype']['start'];Scene_Boot['prototype']['start']=function(){_0x3c415a['call'](this),_0x4ffd38(MK['MapManipulation'],'MK_MapManipulation'),_0x4ffd38(MK['SpawnEvents'],'MK_SpawnEvents');};const _0x12ffd1=PluginManager['parameters'](_0x34d698),_0x463871=_0x12ffd1['commonEvents']&&_0x3ac579(_0x12ffd1['commonEvents'],'Variables\x20&\x20Common\x20Events'),_0x590832=Number(_0x12ffd1['staminaVariableId']),_0x333fc0=Number(_0x463871['onBuildSetVariableId']),_0xea4216=Number(_0x463871['onBuildSetRegionIdVariableId']),_0x352361=Number(_0x463871['onStartBuildModeCommonEventId']),_0x2fca3a=Number(_0x463871['onBuildCommonEventId']),_0x429107=Number(_0x463871['onRestoreCommonEventId']),_0x3b0079=Number(_0x463871['onNotEnoughStaminaCommonEventId']),_0x3e3fb7=Number(_0x463871['onNotEnoughMaterialsCommonEventId']),_0x284118=Number(_0x463871['onCannotBuildHereCommonEventId']),_0x5b10af=Number(_0x463871['onCannotBuildRightNowCommonEventId']),_0x48ebb4=Number(_0x463871['onQuitBuildModeCommonEventId']),_0x183c7e=_0x12ffd1['onBuildSE'],_0x3155e6=_0x12ffd1['onRestoreSE'],_0x319100=_0x43de28(_0x12ffd1['spritePreviewUpdateEval'],'Sprite\x20Preview\x20(update)'),_0x31a26c=_0x12ffd1['eraserColor'],_0xa097ab=Number(_0x12ffd1['eraserOpacity']),_0x1dbe0b='true'==_0x12ffd1['showHelpWindow'],_0x29eecd=_0x43de28(_0x12ffd1['helpWindowRectangleEval'],'Help\x20Window\x20Rectangle'),_0xdb4361=_0x43de28(_0x12ffd1['helpWindowDrawEval'],'Help\x20Window\x20Draw'),_0x3270f6=_0x3ac579(_0x12ffd1['vocabulary'],'Vocabulary'),_0x231dd3=_0x3ac579(_0x12ffd1['blueprints']||'[\x20]','Blueprints')['map'](JSON['parse'])['map'](_0x12a509=>({'blueprintName':_0x12a509['name'],'category':_0x12a509['category'],'description':JSON['parse'](_0x12a509['description']||'\x22\x22'),'sourceMapName':_0x12a509['sourceMapName'],'regionIds':_0x12a509['regionIds'],'requiredItems':JSON['parse'](_0x12a509['requiredItems']||'[\x20]')['map'](JSON['parse'])['map'](_0x5b2cfc=>({'itemId':Number(_0x5b2cfc['item'])||0x0,'quantity':Number(_0x5b2cfc['quantity'])||0x0})),'staminaCost':Number(_0x12a509['staminaCost']||0x0),'gold':Number(_0x12a509['gold'])||0x0,'onBuildSE':_0x12a509['onBuildSE'],'shakeScreen':_0x12a509['shakeScreen']=='true','preconditionSwitchId':Number(_0x12a509['preconditionSwitchId']),'preconditionVariableId':Number(_0x12a509['preconditionVariableId']),'preconditionVariableLargerThan':Number(_0x12a509['preconditionVariableLargerThan'])||0x0,'preconditionEval':_0x12a509['preconditionEval']&&_0x43de28(_0x12a509['preconditionEval'],'Precondition\x20Custom\x20Code'),'switchId':Number(_0x12a509['switchId']),'commonEventId':Number(_0x12a509['commonEventId']),'onBuildEval':_0x12a509['onBuildEval']&&_0x43de28(_0x12a509['onBuildEval'],'on\x20build\x20Custom\x20Code'),'initiallyAvailable':'true'==_0x12a509['initiallyAvailable']}));function _0x3a3a44(){this['initialize'](...arguments);}_0x3a3a44['prototype']=Object['create']('MZ'==Utils['RPGMAKER_NAME']?Sprite_Clickable['prototype']:Sprite['prototype']),_0x3a3a44['prototype']['constructor']=_0x3a3a44,_0x3a3a44['prototype']['initialize']=function(){Sprite['prototype']['initialize']['apply'](this,arguments),this['_lastX']=TouchInput['x'],this['_lastY']=TouchInput['y'],this['jumpToPlayer']();},_0x3a3a44['prototype']['update']=function(){'MZ'==Utils['RPGMAKER_NAME']?Sprite_Clickable['prototype']['update']['call'](this):Sprite['prototype']['update']['call'](this),MK['Sandbox']['isShovelMode']()?this['moveAheadOfPlayer']():(this['moveByMouse'](),this['moveByKeyboard']());},_0x3a3a44['prototype']['moveByMouse']=function(){if(TouchInput['x']!=this['_lastX']||TouchInput['y']!=this['_lastY']){this['_lastX']=TouchInput['x'],this['_lastY']=TouchInput['y'];const _0x1ec986=$gameMap['adjustX']($gameMap['canvasToMapX'](TouchInput['x'])),_0x4bdd53=$gameMap['adjustY']($gameMap['canvasToMapY'](TouchInput['y'])),_0x136c23=_0x1ec986*$gameMap['tileWidth'](),_0x158759=_0x4bdd53*$gameMap['tileHeight']();this['move'](_0x136c23,_0x158759);}},_0x3a3a44['prototype']['moveByKeyboard']=function(){if(Input['isTriggered']('up'))this['moveByDelta'](0x0,-0x1);if(Input['isTriggered']('left'))this['moveByDelta'](-0x1,0x0);if(Input['isTriggered']('right'))this['moveByDelta'](0x1,0x0);if(Input['isTriggered']('down'))this['moveByDelta'](0x0,0x1);},_0x3a3a44['prototype']['moveByDelta']=function(_0x408a22,_0x444647){const _0x344fad=$gameMap['adjustX'](this['getMapX']()+_0x408a22)*$gameMap['tileWidth'](),_0x591e98=$gameMap['adjustY'](this['getMapY']()+_0x444647)*$gameMap['tileHeight']();0x0<=_0x344fad&&_0x344fad<Graphics['width']&&0x0<=_0x591e98&&_0x591e98<Graphics['height']&&this['move'](_0x344fad,_0x591e98);},_0x3a3a44['prototype']['moveAheadOfPlayer']=function(){const _0x4384a3=$gameMap['roundXWithDirection']($gameMap['adjustX']($gamePlayer['x']),$gamePlayer['direction']()),_0xfe0f39=$gameMap['roundYWithDirection']($gameMap['adjustY']($gamePlayer['y']),$gamePlayer['direction']());this['move'](_0x4384a3*$gameMap['tileWidth'](),_0xfe0f39*$gameMap['tileHeight']());},_0x3a3a44['prototype']['jumpToPlayer']=function(){this['move']($gameMap['adjustX']($gamePlayer['x'])*$gameMap['tileWidth'](),$gameMap['adjustY']($gamePlayer['y'])*$gameMap['tileHeight']());},_0x3a3a44['prototype']['getMapX']=function(){return $gameMap['canvasToMapX'](this['x']);},_0x3a3a44['prototype']['getMapY']=function(){return $gameMap['canvasToMapY'](this['y']);},_0x3a3a44['prototype']['getMapXCentered']=function(){return $gameMap['canvasToMapX'](this['x']+Math['floor'](this['width']/0x2));},_0x3a3a44['prototype']['getMapYCentered']=function(){return $gameMap['canvasToMapY'](this['y']+Math['floor'](this['height']/0x2));};const _0x7dee05=(_0x55323d,_0x577a5e,_0x6e4b2,_0x11b78a,_0x1a1906)=>(_0x6e4b2*_0x1a1906+_0x577a5e)*_0x11b78a+_0x55323d,_0x27d1b1=(_0x2d6533,_0x55fe00,_0x4dbd6c,_0x40c872)=>_0x2d6533['data'][_0x7dee05(_0x55fe00,_0x4dbd6c,_0x40c872,_0x2d6533['width'],_0x2d6533['height'])];function _0x25b46f(){this['initialize'](...arguments);}_0x25b46f['prototype']=Object['create'](_0x3a3a44['prototype']),_0x25b46f['prototype']['constructor']=_0x25b46f,_0x25b46f['prototype']['initialize']=function(_0x5e1ccd){this['blueprint']=_0x5e1ccd,this['blueprintName']=_0x5e1ccd['blueprintName'];const _0x26126d=$dataTilesets[$gameMap['tilesetId']()];this['tilesetBitmaps']=_0x26126d&&_0x26126d['tilesetNames']['map'](_0x1bb5d2=>ImageManager['loadTileset'](_0x1bb5d2)),this['sourceMapName']=_0x5e1ccd&&_0x5e1ccd['sourceMapName'],this['sourceMap']=this['sourceMapName']&&MK['MapManipulation']['getSourceMap'](this['sourceMapName']),this['regionIds']=MK['Sandbox']['getRegionIdsFromBlueprint'](_0x5e1ccd),this['info']=MK['MapManipulation']['getAssetInfo'](this['sourceMapName'],this['regionIds'][0x0]);if(!_0x26126d)_0x198c84('The\x20current\x20Map\x20has\x20no\x20Tileset.\x20This\x20is\x20not\x20allowed.');if(!this['sourceMap'])_0x198c84('The\x20Source\x20Map\x20\x22%1\x22\x20does\x20not\x20exist.'['format'](this['sourceMapName']));if(!this['info'])_0x198c84('The\x20blueprint\x20\x22%1\x22\x20is\x20not\x20found\x20on\x20the\x20Asset\x20Map.'['format'](this['blueprintName']));const _0x478f32=new Bitmap(this['info']['width']*$gameMap['tileWidth'](),this['info']['height']*$gameMap['tileHeight']());_0x3a3a44['prototype']['initialize']['call'](this,_0x478f32),this['refresh']();},_0x25b46f['prototype']['update']=function(){_0x3a3a44['prototype']['update']['call'](this);const _0x18e8ff=this['regionIds']['find'](_0x51f4ad=>$gameMap['checkAreaMatches'](this['getMapX'](),this['getMapY'](),this['sourceMapName'],_0x51f4ad));_0x18e8ff&&_0x18e8ff!=this['regionId']&&(this['regionId']=_0x18e8ff,this['info']=MK['MapManipulation']['getAssetInfo'](this['sourceMapName'],_0x18e8ff),this['refresh']());const _0x448b42=this['canBuildHere']();_0x319100['call'](this,_0x448b42);},_0x25b46f['prototype']['refresh']=function(){this['performDraw']();},_0x25b46f['prototype']['performDraw']=function(){this['bitmap']['clear']();const _0x203aac=this['info']['width'],_0xce7c2d=this['info']['height'];_0x3063a4(_0x203aac)['forEach'](_0x5174a3=>_0x3063a4(_0xce7c2d)['forEach'](_0xd32f9=>_0x3063a4(0x4)['forEach'](_0x2a12b9=>this['drawSpot'](_0x5174a3,_0xd32f9,_0x2a12b9)))),_0x3063a4(_0x203aac)['forEach'](_0x52cd90=>_0x3063a4(_0xce7c2d)['forEach'](_0x4900f1=>this['drawEvent'](_0x52cd90,_0x4900f1)));},_0x25b46f['prototype']['drawSpot']=function(_0xe536f0,_0x149892,_0x2c7d84){const _0x78b9bb=_0x27d1b1(this['sourceMap'],this['info']['x']+_0xe536f0,this['info']['y']+_0x149892,_0x2c7d84);if(Tilemap['isTileA5'](_0x78b9bb))this['drawTileA5'](_0x78b9bb,_0xe536f0,_0x149892);else{if(Tilemap['isAutotile'](_0x78b9bb))this['drawAutotile'](_0x78b9bb,_0xe536f0,_0x149892);else{if(_0x78b9bb)this['drawBTile'](_0x78b9bb,_0xe536f0,_0x149892);}}},_0x25b46f['prototype']['drawAutotile']=function(_0x5e2567,_0x22375d,_0x27454f){const _0x57407c=$gameMap['tileWidth'](),_0x11faab=$gameMap['tileHeight'](),_0xe78471=_0x57407c/0x2,_0x1f288b=_0x11faab/0x2,_0x499bd6=Tilemap['getAutotileKind'](_0x5e2567),_0x342a07=Tilemap['getAutotileShape'](_0x5e2567),_0x210f60=_0x499bd6%0x8,_0xfcef1=Math['floor'](_0x499bd6/0x8);let _0x361900=Tilemap['FLOOR_AUTOTILE_TABLE'],_0x1f23bf,_0x1e44f0,_0x2b9f0f;if(Tilemap['isTileA1'](_0x5e2567)){_0x1f23bf=0x0;if(_0x499bd6==0x0)_0x1e44f0=0x0,_0x2b9f0f=0x0;else{if(_0x499bd6==0x1)_0x1e44f0=0x0,_0x2b9f0f=0x3;else{if(_0x499bd6==0x2)_0x1e44f0=0x6,_0x2b9f0f=0x0;else _0x499bd6==0x3?(_0x1e44f0=0x6,_0x2b9f0f=0x3):(_0x1e44f0=Math['floor'](_0x210f60/0x4)*0x8,_0x2b9f0f=_0xfcef1*0x6+Math['floor'](_0x210f60/0x2)%0x2*0x3,_0x499bd6%0x2!=0x0&&(_0x1e44f0+=0x6,_0x361900=Tilemap['WATERFALL_AUTOTILE_TABLE']));}}}Tilemap['isTileA2'](_0x5e2567)&&(_0x1f23bf=0x1,_0x1e44f0=_0x210f60*0x2,_0x2b9f0f=(_0xfcef1-0x2)*0x3);Tilemap['isTileA3'](_0x5e2567)&&(_0x1f23bf=0x2,_0x1e44f0=_0x210f60*0x2,_0x2b9f0f=(_0xfcef1-0x6)*0x2,_0x361900=Tilemap['WALL_AUTOTILE_TABLE']);Tilemap['isTileA4'](_0x5e2567)&&(_0x1f23bf=0x3,_0x1e44f0=_0x210f60*0x2,_0x2b9f0f=Math['floor']((_0xfcef1-0xa)*2.5+(_0xfcef1%0x2===0x1?0.5:0x0)),_0xfcef1%0x2===0x1&&(_0x361900=Tilemap['WALL_AUTOTILE_TABLE']));for(let _0x123cb8=0x0;_0x123cb8<0x4;_0x123cb8++){const _0x1a84ee=_0x361900[_0x342a07][_0x123cb8][0x0],_0x1f8132=_0x361900[_0x342a07][_0x123cb8][0x1],_0x36b989=(_0x1e44f0*0x2+_0x1a84ee)*_0xe78471,_0x19caa2=(_0x2b9f0f*0x2+_0x1f8132)*_0x1f288b,_0x456fa0=_0x123cb8%0x2*_0xe78471+_0x57407c*_0x22375d,_0x185fd7=Math['floor'](_0x123cb8/0x2)*_0x1f288b+_0x11faab*_0x27454f;this['blt'](_0x1f23bf,_0x36b989,_0x19caa2,_0xe78471,_0x1f288b,_0x456fa0,_0x185fd7);}},_0x25b46f['prototype']['drawTileA5']=function(_0x4ced96,_0x7985db,_0x57b5c7){this['drawNormalTile'](0x4,_0x4ced96,_0x7985db,_0x57b5c7);},_0x25b46f['prototype']['drawBTile']=function(_0x45958f,_0x26311d,_0x44957d){const _0x5cf70e=Math['floor'](_0x45958f/0x100)+0x5;this['drawNormalTile'](_0x5cf70e,_0x45958f,_0x26311d,_0x44957d);},_0x25b46f['prototype']['drawNormalTile']=function(_0x19024d,_0x1fff36,_0x3343df,_0x3ddaec){const _0x257c72=$gameMap['tileWidth'](),_0x3afa6f=$gameMap['tileHeight'](),_0x868de8=(Math['floor'](_0x1fff36/0x80)%0x2*0x8+_0x1fff36%0x8)*_0x257c72,_0x17f974=Math['floor'](_0x1fff36%0x100/0x8)%0x10*_0x3afa6f;this['blt'](_0x19024d,_0x868de8,_0x17f974,_0x257c72,_0x3afa6f,_0x257c72*_0x3343df,_0x3afa6f*_0x3ddaec);},_0x25b46f['prototype']['drawEvent']=function(_0x55e2cd,_0x4381f9){const _0x181d49=this['sourceMap']['events']['find'](_0x11f3c2=>_0x11f3c2&&_0x11f3c2['x']==_0x55e2cd+this['info']['x']&&_0x11f3c2['y']==_0x4381f9+this['info']['y']);if(_0x181d49){const _0x52d1d9=_0x181d49['pages'][0x0],_0x43275e=_0x52d1d9['image']['characterIndex'],_0x5b638c=_0x52d1d9['image']['characterName'],_0x52c4ef=_0x52d1d9['image']['direction'],_0x26da5d=_0x52d1d9['image']['pattern'],_0x10ab57=_0x52d1d9['image']['tileId'];if(_0x5b638c){const _0x3b189d=ImageManager['loadCharacter'](_0x5b638c);_0x3b189d['addLoadListener'](()=>{const _0x4dfd6c=ImageManager['isBigCharacter'](_0x5b638c),_0x238d4d=ImageManager['isObjectCharacter'](_0x5b638c),_0x3e7894=_0x3b189d['width']/(_0x4dfd6c?0x3:0xc),_0x1f4dd4=_0x3b189d['height']/(_0x4dfd6c?0x4:0x8),_0x108cb7=_0x4dfd6c?0x0:Math['floor'](_0x43275e%0x4)*0x3,_0x391071=_0x4dfd6c?0x0:Math['floor'](_0x43275e/0x4)*0x4,_0xfc91b0=(_0x52c4ef-0x2)/0x2,_0x5849f7=(_0x108cb7+_0x26da5d)*_0x3e7894,_0xecf856=(_0x391071+_0xfc91b0)*_0x1f4dd4,_0x3604e9=(_0x55e2cd+0.5)*$gameMap['tileWidth']()-_0x3e7894/0x2,_0x809f4c=(_0x4381f9+0x1)*$gameMap['tileHeight']()-_0x1f4dd4-(_0x238d4d?0x0:0x6);this['bitmap']['blt'](_0x3b189d,_0x5849f7,_0xecf856,_0x3e7894,_0x1f4dd4,_0x3604e9,_0x809f4c);});}if(_0x10ab57){const _0x29da99=$gameMap['tileWidth'](),_0x4d367b=$gameMap['tileHeight'](),_0x2026ee=(Math['floor'](_0x10ab57/0x80)%0x2*0x8+_0x10ab57%0x8)*_0x29da99,_0x23ec6e=Math['floor'](_0x10ab57%0x100/0x8)%0x10*_0x4d367b,_0x47a7d4=Math['floor'](_0x10ab57/0x100)+0x5,_0x11f9be=this['tilesetBitmaps'][_0x47a7d4];_0x11f9be&&this['bitmap']['blt'](_0x11f9be,_0x2026ee,_0x23ec6e,_0x29da99,_0x4d367b,_0x55e2cd*_0x29da99,_0x4381f9*_0x4d367b);}}},_0x25b46f['prototype']['blt']=function(_0x53efa8,_0xa35b20,_0xa0bbac,_0x347e3f,_0x1d8536,_0x42d543,_0xe3475){const _0x528c98=this['tilesetBitmaps']&&this['tilesetBitmaps'][_0x53efa8];_0x528c98?this['bitmap']['blt'](_0x528c98,_0xa35b20,_0xa0bbac,_0x347e3f,_0x1d8536,_0x42d543,_0xe3475):this['bitmap']['clearRect'](_0x42d543,_0xe3475,_0x347e3f,_0x1d8536);},_0x25b46f['prototype']['onClick']=function(){MK['Sandbox']['buildByTouchInput']();},_0x25b46f['prototype']['canBuildHere']=function(){return MK['Sandbox']['canBuildAt'](this['blueprintName'],this['getMapX'](),this['getMapY']());};function _0xa0505(){this['initialize'](...arguments);}_0xa0505['prototype']=Object['create'](_0x3a3a44['prototype']),_0xa0505['prototype']['constructor']=_0xa0505,_0xa0505['prototype']['initialize']=function(){const _0x481b29=new Bitmap($gameMap['tileWidth'](),$gameMap['tileHeight']());_0x481b29['fillRect'](0x0,0x0,_0x481b29['width'],_0x481b29['height'],this['getColor']()),_0x3a3a44['prototype']['initialize']['call'](this,_0x481b29);},_0xa0505['prototype']['getColor']=function(){return _0x31a26c;},_0xa0505['prototype']['update']=function(){_0x3a3a44['prototype']['update']['call'](this),this['opacity']=0.2*Math['sin'](Date['now']()/0xc8)*0xff+_0xa097ab;},_0xa0505['prototype']['onClick']=function(){MK['Sandbox']['restoreByTouchInput']();};function _0x3b1515(){this['initialize'](...arguments);}_0x3b1515['prototype']=Object['create'](Window_Base['prototype']),_0x3b1515['prototype']['constructor']=_0x3b1515,_0x3b1515['prototype']['initialize']=function(){Window_Base['prototype']['initialize']['apply'](this,arguments),this['drawContents']();},_0x3b1515['prototype']['drawContents']=function(){_0xdb4361['call'](this,_0x3270f6);};function _0x5bab6d(){$gameTemp['previewSprite']&&SceneManager['_scene']['removeChild']($gameTemp['previewSprite']),$gameTemp['previewSprite']=undefined;}function _0x2269d1(_0x5692a4){_0x5bab6d(),$gameTemp['previewSprite']=new _0x25b46f(_0x5692a4),SceneManager['_scene']['addChild']($gameTemp['previewSprite']);}function _0x367510(){$gameTemp['eraserSprite']&&SceneManager['_scene']['removeChild']($gameTemp['eraserSprite']),$gameTemp['eraserSprite']=undefined;}function _0x519289(){_0x367510(),$gameTemp['eraserSprite']=new _0xa0505(),SceneManager['_scene']['addChild']($gameTemp['eraserSprite']);}MK['Sandbox']['startBuildMode']=function(_0x5b7a79){if(!MK['Sandbox']['canStartBuildMode']())return;_0x5bab6d();const _0x5e181c=MK['Sandbox']['blueprint'](_0x5b7a79);$gameTemp['isBuildMode']=!!_0x5e181c,$gameTemp['selectedBlueprintName']=_0x5e181c&&_0x5b7a79,_0x5e181c&&_0x2269d1(_0x5e181c),_0x352361&&$gameTemp['reserveCommonEvent'](_0x352361);},MK['Sandbox']['canStartBuildMode']=function(){return!MK['Sandbox']['isBuildMode']()&&!MK['Sandbox']['isRestoreMode']()&&SceneManager['_scene']instanceof Scene_Map;},MK['Sandbox']['quitBuildMode']=function(){if(!MK['Sandbox']['isBuildMode']())return;$gameTemp['isBuildMode']=![],$gameTemp['selectedBlueprintName']=undefined,_0x5bab6d(),_0x48ebb4&&$gameTemp['reserveCommonEvent'](_0x48ebb4);},MK['Sandbox']['isBuildMode']=function(){return $gameTemp['isBuildMode'];},MK['Sandbox']['buildByTouchInput']=function(){if(!MK['Sandbox']['isBuildMode']())return;MK['Sandbox']['buildIfConditionsMet']($gameTemp['selectedBlueprintName'],$gameTemp['previewSprite']['getMapX'](),$gameTemp['previewSprite']['getMapY']());},MK['Sandbox']['buildIfConditionsMet']=function(_0x2fb61e,_0x141d55,_0x40b28b){const _0x573598=MK['Sandbox']['blueprint'](_0x2fb61e),_0x231fc8=_0x573598&&_0x573598['sourceMapName'];if(!_0x231fc8){_0x573598['switchId']&&$gameSwitches['setValue'](_0x573598['switchId'],![]);return;}if(!MK['Sandbox']['requirementsMet'](_0x2fb61e)){_0x573598['switchId']&&$gameSwitches['setValue'](_0x573598['switchId'],![]),_0x333fc0&&$gameVariables['setValue'](_0x333fc0,_0x2fb61e),_0x5b10af&&$gameTemp['reserveCommonEvent'](_0x5b10af);return;}if(!MK['Sandbox']['hasEnoughStamina'](_0x2fb61e)){_0x573598['switchId']&&$gameSwitches['setValue'](_0x573598['switchId'],![]),_0x333fc0&&$gameVariables['setValue'](_0x333fc0,_0x2fb61e),_0x3b0079&&$gameTemp['reserveCommonEvent'](_0x3b0079);return;}if(!MK['Sandbox']['hasAllRequiredMaterials'](_0x2fb61e)){_0x573598['switchId']&&$gameSwitches['setValue'](_0x573598['switchId'],![]),_0x333fc0&&$gameVariables['setValue'](_0x333fc0,_0x2fb61e),_0x3e3fb7&&$gameTemp['reserveCommonEvent'](_0x3e3fb7);return;}if(!MK['Sandbox']['canBuildAt'](_0x2fb61e,_0x141d55,_0x40b28b)){_0x573598['switchId']&&$gameSwitches['setValue'](_0x573598['switchId'],![]),_0x333fc0&&$gameVariables['setValue'](_0x333fc0,_0x2fb61e),_0x284118&&$gameTemp['reserveCommonEvent'](_0x284118);return;}MK['Sandbox']['build'](_0x2fb61e,_0x141d55,_0x40b28b);},MK['Sandbox']['build']=function(_0xeec930,_0x5d7531,_0x38584c){const _0x1a2238=MK['Sandbox']['blueprint'](_0xeec930),_0x5df39e=_0x1a2238&&_0x1a2238['sourceMapName'],_0x421e52=_0x1a2238&&MK['Sandbox']['getRegionIdsFromBlueprint'](_0x1a2238),_0x28dce2=_0x421e52&&_0x421e52['find'](_0x930b49=>$gameMap['checkAreaMatches'](_0x5d7531,_0x38584c,_0x5df39e,_0x930b49)),_0x5d70d5=_0x5df39e&&_0x28dce2&&MK['MapManipulation']['getAssetInfo'](_0x5df39e,_0x28dce2);if(!_0x5d70d5)return;$gameMap['modifyByRegionId'](_0x5df39e,_0x28dce2,_0x5d7531,_0x38584c),MK['SpawnEvents']['spawnFromRectangle'](_0x5df39e,new Rectangle(_0x5d70d5['x'],_0x5d70d5['y'],_0x5d70d5['width'],_0x5d70d5['height']),_0x5d7531,_0x38584c),_0x2b9363(_0x1a2238['onBuildSE']||_0x183c7e);if(_0x1a2238['shakeScreen'])_0x40cc76();_0x20a07e(_0x1a2238),_0x1841e6(_0x1a2238),_0x2dfd9f(_0x1a2238),_0x333fc0&&$gameVariables['setValue'](_0x2fca3a,_0xeec930),_0xea4216&&$gameVariables['setValue'](_0xea4216,_0x28dce2),_0x1a2238['switchId']&&$gameSwitches['setValue'](_0x1a2238['switchId'],!![]),_0x1a2238['onBuildEval']&&_0x1a2238['onBuildEval']();if(_0x1a2238['commonEventId'])$gameTemp['reserveCommonEvent'](_0x1a2238['commonEventId']);else{if(_0x2fca3a)$gameTemp['reserveCommonEvent'](_0x2fca3a);}},MK['Sandbox']['requirementsMet']=function(_0x2431a3){const _0xec77a3=MK['Sandbox']['blueprint'](_0x2431a3);return _0xec77a3&&(!_0xec77a3['preconditionSwitchId']||$gameSwitches['value'](_0xec77a3['preconditionSwitchId']))&&(!_0xec77a3['preconditionVariableId']||$gameVariables['value'](_0xec77a3['preconditionVariableId']))>=_0xec77a3['preconditionVariableLargerThan']&&(!_0xec77a3['preconditionEval']||_0xec77a3['preconditionEval']());},MK['Sandbox']['canBuildAt']=function(_0x480cd2,_0x536682,_0x31a762){const _0x555452=MK['Sandbox']['blueprint'](_0x480cd2),_0x357211=MK['Sandbox']['getRegionIdsFromBlueprint'](_0x555452),_0x12c1fc=MK['MapManipulation']['getAssetInfo'](_0x555452['sourceMapName'],_0x357211[0x0]);return _0x555452&&_0x357211['length']&&_0x357211['some'](_0x29309e=>$gameMap['checkAreaMatches'](_0x536682,_0x31a762,_0x555452['sourceMapName'],_0x29309e))&&!(_0x536682<=$gamePlayer['x']&&$gamePlayer['x']<_0x536682+_0x12c1fc['width']&&_0x31a762<=$gamePlayer['y']&&$gamePlayer['y']<_0x31a762+_0x12c1fc['height']);};function _0x20a07e(_0x2eea67){_0x2eea67['requiredItems']['forEach'](_0x5a2a5a=>$gameParty['loseItem']($dataItems[_0x5a2a5a['itemId']],Math['round'](_0x5a2a5a['quantity']*$gameSystem['buildCostModifier']())));}function _0x1841e6(_0x100a3e){$gameParty['loseGold'](Math['round'](_0x100a3e['gold']*$gameSystem['buildCostModifier']()));}function _0x2dfd9f(_0x5bbdff){if(MK['Sandbox']['hasStaminaEnabled']()){const _0x319695=Math['round'](_0x5bbdff['staminaCost']*$gameSystem['buildCostModifier']());$gameVariables['setValue'](_0x590832,MK['Sandbox']['currentStamina']()-_0x319695);}}MK['Sandbox']['hasStaminaEnabled']=function(){return!!_0x590832;},MK['Sandbox']['currentStamina']=function(){return _0x590832?$gameVariables['value'](_0x590832):0x0;},MK['Sandbox']['startRestoreMode']=function(){if(!MK['Sandbox']['canEnableRestoreMode']())return;$gameTemp['restoreMode']=!![],_0x367510(),_0x519289();},MK['Sandbox']['canEnableRestoreMode']=function(){return MK['Sandbox']['canStartBuildMode']();},MK['Sandbox']['isRestoreMode']=function(){return!!$gameTemp['restoreMode'];},MK['Sandbox']['restoreByTouchInput']=function(){if(!MK['Sandbox']['isRestoreMode']())return;const _0x33cf65=$gameTemp['eraserSprite']['getMapX'](),_0x29af88=$gameTemp['eraserSprite']['getMapY']();$gameMap['restoreByRectangle'](_0x33cf65,_0x29af88,0x1,0x1),MK['SpawnEvents']['unspawnFromRectangle'](_0x33cf65,_0x29af88,0x1,0x1),_0x2b9363(_0x3155e6),_0x429107&&$gameTemp['reserveCommonEvent'](_0x429107);},MK['Sandbox']['quitRestoreMode']=function(){_0x367510(),$gameTemp['eraserSprite']=undefined,$gameTemp['restoreMode']=![];},MK['Sandbox']['setShovelMode']=function(_0x17fb07){$gameTemp['shovelMode']=_0x17fb07;},MK['Sandbox']['isShovelMode']=function(){return $gameTemp['shovelMode'];},MK['Sandbox']['blueprint']=function(_0x29c081){return _0x231dd3['find'](_0x2d2461=>_0x2d2461['blueprintName']==_0x29c081);},MK['Sandbox']['allBlueprints']=function(){return _0x231dd3;};const _0x83aace=DataManager['setupNewGame'];DataManager['setupNewGame']=function(){_0x83aace['call'](this),_0x231dd3['filter'](_0x195656=>_0x195656&&_0x195656['initiallyAvailable'])['forEach'](_0x29500b=>$gameParty['learnBlueprint'](_0x29500b['blueprintName']));},MK['Sandbox']['hasEnoughStamina']=function(_0x179a73){const _0x5b5b64=MK['Sandbox']['blueprint'](_0x179a73);if(!_0x5b5b64)return![];if(!MK['Sandbox']['hasStaminaEnabled']())return!![];const _0x41bd62=Math['round'](_0x5b5b64['staminaCost']*$gameSystem['buildCostModifier']());return MK['Sandbox']['currentStamina']()>=_0x41bd62;},MK['Sandbox']['hasAllRequiredMaterials']=function(_0x482567){const _0x1d7a89=MK['Sandbox']['blueprint'](_0x482567);if(_0x1d7a89){const _0x20a38d=_0x2e78ad(_0x1d7a89),_0x1947ca=Math['round'](_0x1d7a89['gold']*$gameSystem['buildCostModifier']())<=$gameParty['gold']();return _0x20a38d&&_0x1947ca;}};function _0x2e78ad(_0x1361a5){return _0x1361a5['requiredItems']['every'](_0x48d3c9=>{const _0x5f16d2=Math['round'](_0x48d3c9['quantity']*$gameSystem['buildCostModifier']()),_0x5a16a5=$gameParty['numItems']($dataItems[_0x48d3c9['itemId']]);return _0x5a16a5>=_0x5f16d2;});}MK['Sandbox']['canBuild']=function(_0x3e28af){return MK['Sandbox']['requirementsMet'](_0x3e28af)&&MK['Sandbox']['hasAllRequiredMaterials'](_0x3e28af);},MK['Sandbox']['getRegionIdsFromBlueprint']=function(_0x2b9935){!_0x2b9935&&_0x198c84('FATAL:\x20Illegal\x20argument');const _0x571503=_0x2b9935['regionIds'];!_0x571503&&_0x198c84('The\x20blueprint\x20\x22%1\x22\x20doesn\x27t\x20have\x20any\x20Region\x20ID\x20assigned'['format'](_0x2b9935['blueprintName']));if('*'==_0x571503)return MK['MapManipulation']['getRegionIds'](_0x2b9935['sourceMapName']);if(_0x571503['includes'](','))return _0x571503['split'](',')['map'](Number)['filter'](Boolean);const _0x1def54=/(\d+)\-(\d+)/g,_0x4091c7=_0x1def54['exec'](_0x571503);if(_0x4091c7&&_0x4091c7[0x0]&&_0x4091c7[0x1])return _0x3063a4(Number(_0x4091c7[0x0]),Number(_0x4091c7[0x1]));if(Number(_0x571503)>0x0)return[Number(_0x571503)];_0x198c84('The\x20blueprint\x20%s\x20Region\x20IDs\x20are\x20invalid:\x20%2'['format'](_0x2b9935['blueprintName'],_0x571503));},Game_Party['prototype']['learnedBlueprints']=function(){return this['_blueprints']=this['_blueprints']||[],_0x231dd3['filter'](_0x3317dd=>this['hasBlueprint'](_0x3317dd['blueprintName']));};const _0x37acbe=(_0x5e7b33,_0x194dd4)=>_0x5e7b33&&_0x194dd4&&_0x5e7b33['trim']()['toLowerCase']()==_0x194dd4['trim']()['toLowerCase']();Game_Party['prototype']['hasBlueprint']=function(_0x2cc237){return this['_blueprints']['includes'](_0x2cc237)||this['items']()['some'](_0x2eedb3=>_0x2eedb3['meta']&&_0x37acbe(_0x2eedb3['meta']['Blueprint'],_0x2cc237));},Game_Party['prototype']['learnBlueprint']=function(_0x4ea2e6){this['_blueprints']=this['_blueprints']||[];if(!this['_blueprints']['includes'](_0x4ea2e6))this['_blueprints']['push'](_0x4ea2e6);},Game_Party['prototype']['forgetBlueprint']=function(_0x30502a){this['_blueprints']=this['_blueprints']||[],this['_blueprints']['remove'](_0x30502a);},Game_System['prototype']['buildCostModifier']=function(){return this['_buildCostModifier']!==undefined?this['_buildCostModifier']:0x1;},Game_System['prototype']['setBuildCostModifier']=function(_0x4e7bae){this['_buildCostModifier']=_0x4e7bae;};const _0x8bbab7=Scene_Map['prototype']['createDisplayObjects'];Scene_Map['prototype']['createDisplayObjects']=function(){_0x8bbab7['call'](this),this['createSandboxHelpWindow'](),this['createSandboxCancelButton']();},Scene_Map['prototype']['createSandboxHelpWindow']=function(){const _0x118bb5=this['sandboxHelpWindowRectangle']();'MZ'==Utils['RPGMAKER_NAME']?this['_mk_sandbox_helpWindow']=new _0x3b1515(_0x118bb5):this['_mk_sandbox_helpWindow']=new _0x3b1515(_0x118bb5['x'],_0x118bb5['y'],_0x118bb5['width'],_0x118bb5['height']),this['_mk_sandbox_helpWindow']['hide'](),this['addWindow'](this['_mk_sandbox_helpWindow']);},Scene_Map['prototype']['sandboxHelpWindowRectangle']=function(){return _0x29eecd['call'](this);},Scene_Map['prototype']['createSandboxCancelButton']=function(){this['_menuButton']&&(this['_mk_sandbox_cancelButton']=new Sprite_Button('cancel'),this['_mk_sandbox_cancelButton']['x']=this['_menuButton']['x']+this['_menuButton']['width']-this['_mk_sandbox_cancelButton']['width'],this['_mk_sandbox_cancelButton']['y']=this['_menuButton']['y'],this['_mk_sandbox_cancelButton']['visible']=![],this['_mk_sandbox_cancelButton']['setClickHandler'](this['onSandboxCancel']['bind'](this)),this['addWindow'](this['_mk_sandbox_cancelButton']));};const _0x259495=Scene_Map['prototype']['update'];Scene_Map['prototype']['update']=function(){_0x259495['call'](this),MK['Sandbox']['isBuildMode']()&&Input['isTriggered']('ok')&&MK['Sandbox']['buildByTouchInput'](),MK['Sandbox']['isBuildMode']()&&(Input['isTriggered']('cancel')||TouchInput['isCancelled']())&&MK['Sandbox']['quitBuildMode'](),MK['Sandbox']['isRestoreMode']()&&Input['isTriggered']('ok')&&MK['Sandbox']['restoreByTouchInput'](),MK['Sandbox']['isRestoreMode']()&&(Input['isTriggered']('cancel')||TouchInput['isCancelled']())&&MK['Sandbox']['quitRestoreMode'](),this['updateSandboxHelpWindow'](),this['updateSandboxCancelButton']();},Scene_Map['prototype']['updateSandboxHelpWindow']=function(){this['_mk_sandbox_helpWindow']['visible']=_0x1dbe0b&&MK['Sandbox']['isBuildMode']()&&!MK['Sandbox']['isShovelMode']();},Scene_Map['prototype']['updateSandboxCancelButton']=function(){const _0x5e83a5=this['_mk_sandbox_cancelButton'];_0x5e83a5&&(_0x5e83a5['visible']=MK['Sandbox']['isCancelButtonVisible']());};const _0x310d6d=Game_Player['prototype']['update'];Game_Player['prototype']['update']=function(){_0x310d6d['apply'](this,arguments),MK['Sandbox']['isBuildMode']()&&!MK['Sandbox']['isShovelMode']()&&this['turnTowardCharacter']({'x':$gameTemp['previewSprite']['getMapXCentered'](),'y':$gameTemp['previewSprite']['getMapYCentered']()}),MK['Sandbox']['isRestoreMode']()&&!MK['Sandbox']['isShovelMode']()&&this['turnTowardCharacter']({'x':$gameTemp['eraserSprite']['getMapX'](),'y':$gameTemp['eraserSprite']['getMapY']()});};const _0x2a8639=Game_Player['prototype']['canMove'];Game_Player['prototype']['canMove']=function(){return _0x2a8639['call'](this)&&(MK['Sandbox']['isShovelMode']()||!MK['Sandbox']['isBuildMode']()&&!MK['Sandbox']['isRestoreMode']());};const _0x56fff8=Game_Player['prototype']['canStartLocalEvents'];Game_Player['prototype']['canStartLocalEvents']=function(){return _0x56fff8['call'](this)&&!MK['Sandbox']['isBuildMode']()&&!MK['Sandbox']['isRestoreMode']();},Scene_Map['prototype']['onSandboxCancel']=function(){MK['Sandbox']['isBuildMode']()&&MK['Sandbox']['quitBuildMode'](),MK['Sandbox']['isRestoreMode']()&&MK['Sandbox']['quitRestoreMode']();},MK['Sandbox']['isCancelButtonVisible']=function(){return ConfigManager['touchUI']&&(MK['Sandbox']['isBuildMode']()||MK['Sandbox']['isRestoreMode']());};const _0x5cb86f=Scene_Map['prototype']['isAnyButtonPressed'];Scene_Map['prototype']['isAnyButtonPressed']=function(){return _0x5cb86f['call'](this)||this['_mk_sandbox_cancelButton']&&this['_mk_sandbox_cancelButton']['isPressed']();};const _0x45b1c6=Scene_Map['prototype']['isMenuEnabled'];Scene_Map['prototype']['isMenuEnabled']=function(){return _0x45b1c6['call'](this)&&!MK['Sandbox']['isBuildMode']()&&!MK['Sandbox']['isRestoreMode']();};PluginManager['registerCommand']&&(PluginManager['registerCommand'](_0x34d698,'startBuildMode',_0xf4491e=>{MK['Sandbox']['startBuildMode'](_0xf4491e['blueprintName']);}),PluginManager['registerCommand'](_0x34d698,'quitBuildMode',()=>{MK['Sandbox']['quitBuildMode']();}),PluginManager['registerCommand'](_0x34d698,'startRestoreMode',()=>{MK['Sandbox']['startRestoreMode']();}),PluginManager['registerCommand'](_0x34d698,'quitRestoreMode',()=>{MK['Sandbox']['quitRestoreMode']();}),PluginManager['registerCommand'](_0x34d698,'addOrRemoveBlueprint',_0x24899d=>{'Learn'==_0x24899d['mode']?$gameParty['learnBlueprint'](_0x24899d['blueprintName']):$gameParty['forgetBlueprint'](_0x24899d['blueprintName']);}),PluginManager['registerCommand'](_0x34d698,'setShovelMode',_0x5d0753=>{MK['Sandbox']['setShovelMode']('true'==_0x5d0753['mode']);}),PluginManager['registerCommand'](_0x34d698,'changeBuildCostModifier',_0x4f61bd=>{$gameSystem['setBuildCostModifier'](Number(_0x4f61bd['modifier'])||0x0);}));const _0x2b9363=_0x1c5389=>{_0x1c5389&&AudioManager['playSe']({'name':_0x1c5389,'volume':0x64,'pitch':0x64,'pan':0x0});},_0x40cc76=()=>$gameScreen['startShake'](0x5,0x5,0xa);function _0x34e25d(){return!Utils['isNwjs']()&&window['location']['hostname']=='play.aerosys.blog';}function _0x22aed(){return _0x34e25d()||MK['Sandbox']['unlockKey']==='20022c0e-fbeb-4363-b8e8-7063217f16e9';}const _0x82b037=Game_Map['prototype']['getModifications'];Game_Map['prototype']['getModifications']=function(){return _0x22aed()?_0x82b037['call'](this):{};};}());