/*:
 * @target MZ
 * @author Aerosys
 * @url https://aerosys.blog
 * @plugindesc [Tier 2] [Version 1.0.1] [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 removeAllFurniture
 * @text Remove All Furniture
 * @desc Disassembles all furnitures on the current map
 * 
 * 
 * @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
 * 
 * 
 * @command countByFurniturePlanName
 * @text Count Furnitures
 * 
 * @arg blueprintName
 * @default REQUIRED
 * 
 * @arg variableId
 * @text Variable to store into
 * @type variable
 * 
 * 
 * @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 controls
 * @text Controls
 * 
 * @param hotkeys
 * @parent controls
 * @text Hotkeys
 * @type struct<HotKeys>
 * @default {"furnitureNextVariant":"86","rotateViaPageUpPageDownOrCustom":"PageUp/PageDown","furnitureRotateLeft":"","furnitureRotateRight":""}
 * 
 * @param disableVariantFeature
 * @parent controls
 * @text Disable Variant Feature?
 * @type boolean
 * 
 * @param disableRotateFeature
 * @parent controls
 * @text Disable Rotate Feature?
 * @type boolean
 * 
 * @param b
 * @text _
 * 
 * @param soundEffects
 * @text Sound Effects
 * 
 * @param onBuildSE
 * @parent soundEffects
 * @text SE: when build
 * @type file
 * @dir audio/se
 * @require 1
 * @default Jump2
 * 
 * @param c
 * @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 d
 * @text _
 * 
 * @param helpWindow
 * @text Help Window
 * 
 * @param showHelpWindow
 * @parent helpWindow
 * @text Show?
 * @type boolean
 * @default true
 * 
 * @param z
 * @text _
 * 
 * @param vocabulary
 * @text Vocabulary
 * @type struct<Vocabulary>
 * @default {"arrowKeys":"Arrows/Mouse","moveObject":"Move","actionKey":"Enter","placeObject":"Place","swapVariantKey":"V/Mouse Wheel","swapVariant":"Swap Variant","rotateKey":"PageUp/PageDown","rotate":"Rotate","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 regionId
 * @parent sourceMapSettings
 * @text Region ID
 * @type number
 * @default 1
 * 
 * @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 rotatable
 * @text Rotatable?
 * @type boolean
 * 
 * @param maxBuildsByMap
 * @parent conditions
 * @text Max Builds per Map
 * @type number
 * @desc When given, limits how often this can be built on the same Map
 * 
 * @param onBuildSE
 * @text SE: when build
 * @type file
 * @dir audio/se
 * @require 1
 * 
 * @param shakeScreen
 * @text Shake Screen when build?
 * @type boolean
 * 
 * @param recycling
 * @text Recycling
 * 
 * @param noRefundMaterials
 * @parent recycling
 * @text No refund of Materials?
 * @type boolean
 * 
 * @param noRefundGold
 * @parent recycling
 * @text No refund of Gold?
 * @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 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~HotKeys:
 *
 * @param furnitureNextVariant
 * @text Cycle Next Variant
 * @type number
 * @default 86
 * @desc You can get the Key Code from e.g. http://keyjs.dev. Default is 86 which is letter "V"
 * 
 * @param rotateViaPageUpPageDownOrCustom
 * @text Rotate Keys?
 * @type select
 * @option PageUp/PageDown
 * @option Custom
 * @default PageUp/PageDown
 * 
 * @param furnitureRotateLeft
 * @parent rotateViaPageUpPageDownOrCustom
 * @text When custom: Rotate Left
 * @type number
 * @desc You can get the Key Code from e.g. http://keyjs.dev. Default is 33 which is PageUp
 * 
 * @param furnitureRotateRight
 * @parent rotateViaPageUpPageDownOrCustom
 * @text When custom: Rotate Right
 * @type number
 * @desc You can get the Key Code from e.g. http://keyjs.dev. Default is 34 which is PageDown
 *
 */

/*~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 swapVariantKey
 * @text Swap Variant Key
 * @default V/Mouse Wheel
 * 
 * @param swapVariant
 * @text Swap Variant
 * @default Swap Variant
 * 
 * @param rotateKey
 * @text Rotate Key
 * @default PageUp/PageDown
 * 
 * @param rotate
 * @text Rotate
 * @default Rotate
 * 
 * @param cancelKey
 * @text Quit Key
 * @default Esc
 * 
 * @param quit
 * @text Quit
 * @default Quit
 * 
 */


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


(function(){const _0x1e8553='MK_FurnitureSystem',_0x59b504=_0x2e49a9=>{const _0x5e350b=('An\x20Error\x20has\x20occurred\x20in\x20the\x20Plugin\x20%1:\x20%2\x20'+'If\x20the\x20problem\x20persists,\x20contact\x20the\x20Plugin\x20Creator.')['format'](_0x1e8553,_0x2e49a9);throw Error(_0x5e350b);};!PluginManager['_parameters'][_0x1e8553['toLowerCase']()]&&_0x59b504(('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'](_0x1e8553));const _0x15ff85=(_0x1f6326,_0x335e7a)=>{!_0x1f6326&&_0x59b504(('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'](_0x335e7a));try{return JSON['parse'](_0x1f6326);}catch(_0x2af1e7){_0x59b504(('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'](_0x335e7a));}},_0x3bf9d1=(_0x3657c7,_0x3593ec)=>{!_0x3657c7&&_0x59b504(('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'](_0x3593ec));try{return new Function(JSON['parse'](_0x3657c7));}catch(_0x1d5634){_0x59b504(('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'](_0x3593ec,_0x1d5634));}},_0x3902a4=(_0x4a237f,_0x299b8b)=>{if(!_0x4a237f)_0x59b504('The\x20required\x20Plugin\x20\x22%1\x22\x20is\x20missing.\x20Please\x20add\x20it\x20to\x20the\x20Plugin\x20Manager.'['format'](_0x299b8b));},_0x4dfbc4=PluginManager['parameters'](_0x1e8553),_0x5ef659=_0x4dfbc4['commonEvents']&&_0x15ff85(_0x4dfbc4['commonEvents'],'Variables\x20&\x20Common\x20Events'),_0x214c0a=Number(_0x4dfbc4['staminaVariableId']),_0x2ef755=Number(_0x5ef659['onBuildSetVariableId']),_0x43540e=Number(_0x5ef659['onBuildSetRegionIdVariableId']),_0x54f306=Number(_0x5ef659['onStartBuildModeCommonEventId']),_0xd01881=Number(_0x5ef659['onBuildCommonEventId']),_0xce6de6=Number(_0x5ef659['onNotEnoughStaminaCommonEventId']),_0x582808=Number(_0x5ef659['onNotEnoughMaterialsCommonEventId']),_0x2d635f=Number(_0x5ef659['onCannotBuildHereCommonEventId']),_0x19fe60=Number(_0x5ef659['onCannotBuildRightNowCommonEventId']),_0x4e0a64=Number(_0x5ef659['onQuitBuildModeCommonEventId']),_0x389548=_0x4dfbc4['onBuildSE'],_0x5646e1=_0x3bf9d1(_0x4dfbc4['spritePreviewUpdateEval'],'Sprite\x20Preview\x20(update)'),_0x54bf73='true'==_0x4dfbc4['showHelpWindow'],_0x16f7d2='true'==_0x4dfbc4['disableVariantFeature'],_0x50574c='true'==_0x4dfbc4['disableRotateFeature'],_0x4614ff=_0x15ff85(_0x4dfbc4['vocabulary'],'Vocabulary'),_0x255159=_0x15ff85(_0x4dfbc4['blueprints']||'[\x20]','Blueprints')['map'](JSON['parse'])['map'](_0x25238d=>({'blueprintName':_0x25238d['name'],'category':_0x25238d['category'],'description':JSON['parse'](_0x25238d['description']||'\x22\x22'),'sourceMapName':_0x25238d['sourceMapName'],'regionId':Number(_0x25238d['regionId']),'requiredItems':JSON['parse'](_0x25238d['requiredItems']||'[\x20]')['map'](JSON['parse'])['map'](_0x6b2cf4=>({'itemId':Number(_0x6b2cf4['item'])||0x0,'quantity':Number(_0x6b2cf4['quantity'])||0x0})),'staminaCost':Number(_0x25238d['staminaCost']||0x0),'gold':Number(_0x25238d['gold'])||0x0,'rotatable':_0x25238d['rotatable']=='true','onBuildSE':_0x25238d['onBuildSE'],'shakeScreen':_0x25238d['shakeScreen']=='true','preconditionSwitchId':Number(_0x25238d['preconditionSwitchId']),'preconditionVariableId':Number(_0x25238d['preconditionVariableId']),'preconditionVariableLargerThan':Number(_0x25238d['preconditionVariableLargerThan'])||0x0,'preconditionEval':_0x25238d['preconditionEval']&&_0x3bf9d1(_0x25238d['preconditionEval'],'Precondition\x20Custom\x20Code'),'maxBuildsByMap':Number(_0x25238d['maxBuildsByMap']),'noRefundMaterials':_0x25238d['noRefundMaterials']=='true','noRefundGold':_0x25238d['noRefundGold']=='true','switchId':Number(_0x25238d['switchId']),'commonEventId':Number(_0x25238d['commonEventId']),'onBuildEval':_0x25238d['onBuildEval']&&_0x3bf9d1(_0x25238d['onBuildEval'],'on\x20build\x20Custom\x20Code'),'initiallyAvailable':'true'==_0x25238d['initiallyAvailable']})),_0x4af4a8=_0x15ff85(_0x4dfbc4['hotkeys']||'{\x20}','Hotkeys');_0x4af4a8['furnitureNextVariant']=Number(_0x4af4a8['furnitureNextVariant'])||0x56,_0x4af4a8['furnitureRotateLeft']=Number(_0x4af4a8['furnitureRotateLeft'])||0x21,_0x4af4a8['furnitureRotateRight']=Number(_0x4af4a8['furnitureRotateRight'])||0x22,_0x4af4a8['rotateCustom']=_0x4af4a8['rotateViaPageUpPageDownOrCustom']=='Custom';const _0x11a529=Scene_Boot['prototype']['start'];Scene_Boot['prototype']['start']=function(){_0x11a529['call'](this),_0x3902a4(MK['MapManipulation'],'MK_MapManipulation'),_0x3902a4(MK['SpawnEvents'],'MK_SpawnEvents'),Input['keyMapper'][_0x4af4a8['furnitureNextVariant']]='furnitureNextVariant',_0x4af4a8['rotateCustom']&&(Input['keyMapper'][_0x4af4a8['furnitureRotateLeft']]='furnitureRotateLeft',Input['keyMapper'][_0x4af4a8['furnitureRotateRight']]='furnitureRotateRight');};function _0x14c69c(){this['initialize'](...arguments);}_0x14c69c['prototype']=Object['create']('MZ'==Utils['RPGMAKER_NAME']?Sprite_Clickable['prototype']:Sprite['prototype']),_0x14c69c['prototype']['constructor']=_0x14c69c,_0x14c69c['prototype']['initialize']=function(){Sprite['prototype']['initialize']['apply'](this,arguments),this['_lastX']=TouchInput['x'],this['_lastY']=TouchInput['y'],this['jumpToPlayer']();},_0x14c69c['prototype']['update']=function(){'MZ'==Utils['RPGMAKER_NAME']?Sprite_Clickable['prototype']['update']['call'](this):Sprite['prototype']['update']['call'](this),MK['Furniture']['isShovelMode']()?this['moveAheadOfPlayer']():(this['moveByMouse'](),this['moveByKeyboard']());},_0x14c69c['prototype']['moveByMouse']=function(){if(this['isAnyButtonPressed']())return;if(TouchInput['x']!=this['_lastX']||TouchInput['y']!=this['_lastY']){this['_lastX']=TouchInput['x'],this['_lastY']=TouchInput['y'];const _0x2c6083=$gameMap['adjustX']($gameMap['canvasToMapX'](TouchInput['x'])),_0x19fa66=$gameMap['adjustY']($gameMap['canvasToMapY'](TouchInput['y'])),_0x1c95d0=_0x2c6083*$gameMap['tileWidth'](),_0x21e8fb=_0x19fa66*$gameMap['tileHeight']();this['move'](_0x1c95d0,_0x21e8fb);}},_0x14c69c['prototype']['isAnyButtonPressed']=function(){return![];},_0x14c69c['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);},_0x14c69c['prototype']['moveByDelta']=function(_0x3ecfa3,_0x2cf68e){const _0x2a2e01=$gameMap['adjustX'](this['getMapX']()+_0x3ecfa3)*$gameMap['tileWidth'](),_0x896715=$gameMap['adjustY'](this['getMapY']()+_0x2cf68e)*$gameMap['tileHeight']();0x0<=_0x2a2e01&&_0x2a2e01<Graphics['width']&&0x0<=_0x896715&&_0x896715<Graphics['height']&&this['move'](_0x2a2e01,_0x896715);},_0x14c69c['prototype']['moveAheadOfPlayer']=function(){const _0x18baa5=$gameMap['roundXWithDirection']($gameMap['adjustX']($gamePlayer['x']),$gamePlayer['direction']()),_0x10b4e7=$gameMap['roundYWithDirection']($gameMap['adjustY']($gamePlayer['y']),$gamePlayer['direction']());this['move'](_0x18baa5*$gameMap['tileWidth'](),_0x10b4e7*$gameMap['tileHeight']());},_0x14c69c['prototype']['jumpToPlayer']=function(){this['move']($gameMap['adjustX']($gamePlayer['x'])*$gameMap['tileWidth'](),$gameMap['adjustY']($gamePlayer['y'])*$gameMap['tileHeight']());},_0x14c69c['prototype']['getMapX']=function(){return $gameMap['canvasToMapX'](this['x']);},_0x14c69c['prototype']['getMapY']=function(){return $gameMap['canvasToMapY'](this['y']);},_0x14c69c['prototype']['getMapXCentered']=function(){return $gameMap['canvasToMapX'](this['x']+Math['floor'](this['width']/0x2));},_0x14c69c['prototype']['getMapYCentered']=function(){return $gameMap['canvasToMapY'](this['y']+Math['floor'](this['height']/0x2));};function _0x4502d0(){this['initialize'](...arguments);}_0x4502d0['prototype']=Object['create'](_0x14c69c['prototype']),_0x4502d0['prototype']['constructor']=_0x4502d0,_0x4502d0['prototype']['initialize']=function(_0x35ccc9,{direction:_0x327e56,variant:_0x1d34f5}={}){this['blueprint']=_0x35ccc9,this['blueprintName']=_0x35ccc9['blueprintName'];const _0x21ec23=$dataTilesets[$gameMap['tilesetId']()];this['tilesetBitmaps']=_0x21ec23&&_0x21ec23['tilesetNames']['map'](_0x1f5dd3=>ImageManager['loadTileset'](_0x1f5dd3)),this['sourceMapName']=_0x35ccc9&&_0x35ccc9['sourceMapName'],this['sourceMap']=this['sourceMapName']&&MK['MapManipulation']['getSourceMap'](this['sourceMapName']),this['regionId']=_0x35ccc9['regionId'],this['info']=MK['MapManipulation']['getAssetInfo'](this['sourceMapName'],this['regionId']);if(!_0x21ec23)_0x59b504('The\x20current\x20Map\x20has\x20no\x20Tileset.\x20This\x20is\x20not\x20allowed.');if(!this['sourceMap'])_0x59b504('The\x20Source\x20Map\x20\x22%1\x22\x20does\x20not\x20exist.'['format'](this['sourceMapName']));if(!this['info'])_0x59b504('The\x20blueprint\x20\x22%1\x22\x20is\x20not\x20found\x20on\x20the\x20Asset\x20Map.'['format'](this['blueprintName']));this['numberOfVariants']=this['info']['n'],this['_variantIndex']=_0x1d34f5,this['_direction']=_0x327e56,this['event']=this['getEvent']();if(!this['event'])_0x59b504('The\x20furniture\x20event\x20for\x20blueprint\x20\x22%1\x22\x20is\x20missing\x20on\x20the\x20Asset\x20Map.'['format'](this['blueprintName']));const _0x2a97e0=new Bitmap($gameMap['tileWidth'](),$gameMap['tileHeight']());_0x14c69c['prototype']['initialize']['call'](this,_0x2a97e0),this['refresh']();},_0x4502d0['prototype']['isClickEnabled']=function(){return Sprite_Clickable['prototype']['isClickEnabled']['call'](this)&&!this['isAnyButtonPressed']();},_0x4502d0['prototype']['isAnyButtonPressed']=function(){return[SceneManager['_scene']['_mk_furniture_cancelButton'],$gameTemp['furnitureCycleVariantButton'],$gameTemp['furnitureRotateLeftButton'],$gameTemp['furnitureRotateRightButton']]['some'](_0x560fc4=>_0x560fc4&&_0x560fc4['isBeingTouched']());},_0x4502d0['prototype']['update']=function(){_0x14c69c['prototype']['update']['call'](this);const _0x2a1b3b=this['canBuildHere']();_0x5646e1['call'](this,_0x2a1b3b),this['updateRotation'](),this['updateVariants']();},_0x4502d0['prototype']['refresh']=function(){this['bitmap']['clear'](),this['drawEvent']();},_0x4502d0['prototype']['drawEvent']=function(){const _0x8b176a=this['event']['pages'][0x0],_0x47f740=_0x8b176a['image']['characterIndex'],_0x467a85=_0x8b176a['image']['characterName'],_0x794b3=this['direction'](),_0x3c282f=_0x8b176a['image']['pattern'],_0x1dfdff=_0x8b176a['image']['tileId'];if(_0x467a85){const _0x57716e=ImageManager['loadCharacter'](_0x467a85);_0x57716e['addLoadListener'](()=>{const _0x160dee=ImageManager['isBigCharacter'](_0x467a85),_0x4495cd=ImageManager['isObjectCharacter'](_0x467a85),_0x3f0bbb=_0x57716e['width']/(_0x160dee?0x3:0xc),_0x7de68b=_0x57716e['height']/(_0x160dee?0x4:0x8),_0x3a2809=_0x160dee?0x0:Math['floor'](_0x47f740%0x4)*0x3,_0x14699d=_0x160dee?0x0:Math['floor'](_0x47f740/0x4)*0x4,_0x79be15=(_0x794b3-0x2)/0x2,_0x127bfa=(_0x3a2809+_0x3c282f)*_0x3f0bbb,_0x3f0618=(_0x14699d+_0x79be15)*_0x7de68b,_0x392fdb=0.5*$gameMap['tileWidth']()-_0x3f0bbb/0x2,_0x1bbd7d=$gameMap['tileHeight']()-_0x7de68b-(_0x4495cd?0x0:0x6);this['bitmap']['blt'](_0x57716e,_0x127bfa,_0x3f0618,_0x3f0bbb,_0x7de68b,_0x392fdb,_0x1bbd7d);});}if(_0x1dfdff){const _0x4e814b=$gameMap['tileWidth'](),_0x45890c=$gameMap['tileHeight'](),_0x555303=(Math['floor'](_0x1dfdff/0x80)%0x2*0x8+_0x1dfdff%0x8)*_0x4e814b,_0xc8bfbb=Math['floor'](_0x1dfdff%0x100/0x8)%0x10*_0x45890c,_0x1df432=Math['floor'](_0x1dfdff/0x100)+0x5,_0x416866=this['tilesetBitmaps'][_0x1df432];_0x416866&&this['bitmap']['blt'](_0x416866,_0x555303,_0xc8bfbb,_0x4e814b,_0x45890c,0x0,0x0);}},_0x4502d0['prototype']['blt']=function(_0x1a486,_0x1de288,_0x353741,_0x39e879,_0xf58a74,_0x4f4979,_0x582e3f){const _0x18811b=this['tilesetBitmaps']&&this['tilesetBitmaps'][_0x1a486];_0x18811b?this['bitmap']['blt'](_0x18811b,_0x1de288,_0x353741,_0x39e879,_0xf58a74,_0x4f4979,_0x582e3f):this['bitmap']['clearRect'](_0x4f4979,_0x582e3f,_0x39e879,_0xf58a74);},_0x4502d0['prototype']['getEvent']=function(){const _0x17d9bb=this['info']['x']+this['variantIndex'](),_0x18d7f5=this['info']['y'];return this['sourceMap']['events']['filter'](Boolean)['find'](_0x217b04=>_0x217b04['x']==_0x17d9bb&&_0x217b04['y']==_0x18d7f5);},_0x4502d0['prototype']['onClick']=function(){MK['Furniture']['buildByTouchInput']();},_0x4502d0['prototype']['canBuildHere']=function(){return MK['Furniture']['canBuildAt'](this['blueprintName'],this['getMapX'](),this['getMapY']());},_0x4502d0['prototype']['updateRotation']=function(){if(_0x50574c)return;this['isRotatable']()&&this['isRotateLeftTriggered']()&&this['rotateLeft'](),this['isRotatable']()&&this['isRotateRightTriggered']()&&this['rotateRight']();},_0x4502d0['prototype']['isRotateLeftTriggered']=function(){return _0x4af4a8['rotateCustom']?Input['isTriggered']('furnitureRotateLeft'):Input['isTriggered']('pageup');},_0x4502d0['prototype']['isRotateRightTriggered']=function(){return _0x4af4a8['rotateCustom']?Input['isTriggered']('furnitureRotateRight'):Input['isTriggered']('pagedown');},_0x4502d0['prototype']['isRotatable']=function(){return this['blueprint']['rotatable'];},_0x4502d0['prototype']['direction']=function(){if(typeof this['_direction']=='number')return this['_direction'];const _0x26d77a=this['event']['pages'][0x0];return _0x26d77a['image']['characterName']?_0x26d77a['image']['direction']:0x2;},_0x4502d0['prototype']['rotateLeft']=function(){this['_direction']=[0x4,0x8,0x2,0x6][this['direction']()/0x2-0x1],this['refresh']();},_0x4502d0['prototype']['rotateRight']=function(){this['_direction']=[0x6,0x2,0x8,0x4][this['direction']()/0x2-0x1],this['refresh']();},_0x4502d0['prototype']['hasVariants']=function(){return this['numberOfVariants']>0x1;},_0x4502d0['prototype']['variantIndex']=function(){return this['_variantIndex']||0x0;},_0x4502d0['prototype']['updateVariants']=function(){if(_0x16f7d2)return;Input['isTriggered']('furnitureNextVariant')&&this['nextVariant'](),TouchInput['wheelY']>=0x14&&this['nextVariant'](),TouchInput['wheelY']<=-0x14&&this['previousVariant']();},_0x4502d0['prototype']['nextVariant']=function(){this['swapVariant'](0x1);},_0x4502d0['prototype']['previousVariant']=function(){this['swapVariant'](-0x1);},_0x4502d0['prototype']['swapVariant']=function(_0x5ba9bd){const _0x3c1e6b=(this['variantIndex']()+_0x5ba9bd)['mod'](this['numberOfVariants']);_0x3c1e6b!==this['variantIndex']()&&(this['_variantIndex']=_0x3c1e6b,this['event']=this['getEvent'](),!this['event']&&_0x59b504('The\x20furniture\x20event\x20for\x20blueprint\x20\x22%1\x22\x20(variant:\x20%2)\x20is\x20missing\x20on\x20the\x20Asset\x20Map.'['format'](this['blueprintName'],this['_variantIndex']+0x1)),this['refresh']());};function _0x3d9dbe(){this['initialize'](...arguments);}_0x3d9dbe['prototype']=Object['create'](Window_Base['prototype']),_0x3d9dbe['prototype']['constructor']=_0x3d9dbe,_0x3d9dbe['prototype']['initialize']=function(){Window_Base['prototype']['initialize']['apply'](this,arguments),this['drawContents']();},_0x3d9dbe['prototype']['lineHeight']=function(){return Math['floor'](Window_Base['prototype']['lineHeight']['call'](this)*0.8);},_0x3d9dbe['prototype']['drawContents']=function(){const _0x19e245=0xa,_0x613d01=this['contentsWidth']()/0x2+0xa,_0x145de2=this['contentsWidth']()/0x2-0xa,_0x239bb7=_0x145de2;this['resetFontSettings'](),this['makeFontSmaller'](),this['changeTextColor']('MZ'==Utils['RPGMAKER_NAME']?ColorManager['systemColor']():this['systemColor']()),this['actionKeys']()['forEach']((_0x239302,_0x4cbd5c)=>this['drawText'](_0x239302,_0x19e245,_0x4cbd5c*this['lineHeight'](),_0x145de2,'right')),this['resetTextColor'](),this['actionDescriptions']()['forEach']((_0x4cfc00,_0x296a9a)=>this['drawText'](_0x4cfc00,_0x613d01,_0x296a9a*this['lineHeight'](),_0x239bb7));},_0x3d9dbe['prototype']['actionKeys']=function(){return[_0x4614ff['arrowKeys']||'Arrows/Mouse',_0x4614ff['actionKey']||'Enter',!_0x16f7d2?_0x4614ff['swapVariantKey']||'V/Mouse\x20Wheel':null,!_0x50574c?_0x4614ff['rotateKey']||'PageUp/PageDown':null,_0x4614ff['cancelKey']||'Esc']['filter'](Boolean);},_0x3d9dbe['prototype']['actionDescriptions']=function(){return[_0x4614ff['moveObject']||'Move',_0x4614ff['placeObject']||'Place',!_0x16f7d2?_0x4614ff['swapVariant']||'Swap\x20Variant':null,!_0x50574c?_0x4614ff['rotate']||'Rotate':null,_0x4614ff['quit']||'Quit']['filter'](Boolean);};function _0x4b0e29(){$gameTemp['furniturePreviewSprite']&&(SceneManager['_scene']['removeChild']($gameTemp['furniturePreviewSprite']),$gameTemp['furniturePreviewSprite']=undefined),$gameTemp['furnitureCycleVariantButton']&&(SceneManager['_scene']['removeChild']($gameTemp['furnitureCycleVariantButton']),$gameTemp['furnitureCycleVariantButton']=undefined),$gameTemp['furnitureRotateLeftButton']&&(SceneManager['_scene']['removeChild']($gameTemp['furnitureRotateLeftButton']),$gameTemp['furnitureRotateLeftButton']=undefined),$gameTemp['furnitureRotateRightButton']&&(SceneManager['_scene']['removeChild']($gameTemp['furnitureRotateRightButton']),$gameTemp['furnitureRotateRightButton']=undefined);}function _0x2f12eb(_0x3e33b3,_0x1a9e4e={}){_0x4b0e29(),$gameTemp['furniturePreviewSprite']=new _0x4502d0(_0x3e33b3,_0x1a9e4e),SceneManager['_scene']['addChild']($gameTemp['furniturePreviewSprite']);}function _0x1649e0(_0x2bab61){if(!ConfigManager['touchUI'])return;const _0x5b0ed9=0x6,_0x4c17da=_0x5213ec(_0x2bab61),_0x46a4d2=_0xb76b94(_0x2bab61);let _0x239bf6,_0x356e52,_0xf2e56f;_0x4c17da&&(_0x239bf6=new Sprite_Button('menu'),_0x239bf6['setClickHandler'](()=>{const _0x388590=$gameTemp['furniturePreviewSprite'];_0x388590['nextVariant']();}),$gameTemp['furnitureCycleVariantButton']=_0x239bf6,SceneManager['_scene']['addChild'](_0x239bf6));_0x46a4d2&&(_0x356e52=new Sprite_Button('pageup'),_0x356e52['setClickHandler'](()=>{const _0x23644b=$gameTemp['furniturePreviewSprite'];_0x23644b['rotateLeft']();}),_0xf2e56f=new Sprite_Button('pagedown'),_0xf2e56f['setClickHandler'](()=>{const _0x5ea3d9=$gameTemp['furniturePreviewSprite'];_0x5ea3d9['rotateRight']();}),$gameTemp['furnitureRotateLeftButton']=_0x356e52,$gameTemp['furnitureRotateRightButton']=_0xf2e56f,SceneManager['_scene']['addChild'](_0x356e52),SceneManager['_scene']['addChild'](_0xf2e56f));if(_0x4c17da&&_0x46a4d2){const _0x31c916=_0x239bf6['width']+_0x356e52['width']+_0xf2e56f['width']+_0x5b0ed9*0x2;_0x239bf6['x']=(Graphics['boxWidth']-_0x31c916)/0x2+0x2,_0x356e52['x']=_0x239bf6['x']+_0x239bf6['width']+_0x5b0ed9,_0xf2e56f['x']=_0x356e52['x']+_0x356e52['width']+_0x5b0ed9,_0x239bf6['y']=Graphics['boxHeight']-_0x239bf6['height']-0xa,_0x356e52['y']=Graphics['boxHeight']-_0x356e52['height']-0xa,_0xf2e56f['y']=Graphics['boxHeight']-_0xf2e56f['height']-0xa;}_0x4c17da&&!_0x46a4d2&&(_0x239bf6['x']=Graphics['boxWidth']/0x2-_0x239bf6['width']/0x2,_0x239bf6['y']=Graphics['boxHeight']-_0x239bf6['height']-0xa);if(!_0x4c17da&&_0x46a4d2){const _0x4330db=_0x356e52['width']+_0xf2e56f['width']+_0x5b0ed9;_0x356e52['x']=(Graphics['boxWidth']-_0x4330db)/0x2,_0xf2e56f['x']=_0x356e52['x']+_0x356e52['width']+_0x5b0ed9,_0x356e52['y']=Graphics['boxHeight']-_0x356e52['height']-0xa,_0xf2e56f['y']=Graphics['boxHeight']-_0xf2e56f['height']-0xa;}}function _0x5213ec(_0x168bc9){const _0xaca8a5=MK['MapManipulation']['getAssetInfo'](_0x168bc9['sourceMapName'],_0x168bc9['regionId']);return _0xaca8a5&&_0xaca8a5['n']>0x1;}function _0xb76b94(_0x510928){return _0x510928['rotatable'];}MK['Furniture']['startBuildMode']=function(_0x55d37a,_0xdd5cb1={}){if(!MK['Furniture']['canStartBuildMode']())return;_0x4b0e29();const _0x5de288=MK['Furniture']['blueprint'](_0x55d37a);if(!_0x5de288)_0x59b504('The\x20blueprint\x20\x22%1\x22\x20does\x20not\x20exist.'['format'](_0x55d37a));$gameTemp['isFurniturePlacementMode']=!![],$gameTemp['selectedFurniturePlanName']=_0x55d37a,_0x2f12eb(_0x5de288,_0xdd5cb1),_0x1649e0(_0x5de288),_0x54f306&&$gameTemp['reserveCommonEvent'](_0x54f306);},MK['Furniture']['canStartBuildMode']=function(){return!MK['Furniture']['isBuildMode']()&&SceneManager['_scene']instanceof Scene_Map;},MK['Furniture']['quitBuildMode']=function(){if(!MK['Furniture']['isBuildMode']())return;$gameTemp['isFurniturePlacementMode']=![],$gameTemp['selectedFurniturePlanName']=undefined,_0x4b0e29(),_0x4e0a64&&$gameTemp['reserveCommonEvent'](_0x4e0a64);},MK['Furniture']['isBuildMode']=function(){return $gameTemp['isFurniturePlacementMode'];},MK['Furniture']['buildByTouchInput']=function(){if(!MK['Furniture']['isBuildMode']())return;const _0x387777=$gameTemp['furniturePreviewSprite'],_0x159725={'direction':_0x387777['_direction'],'variant':_0x387777['_variantIndex']};MK['Furniture']['buildIfConditionsMet']($gameTemp['selectedFurniturePlanName'],$gameTemp['furniturePreviewSprite']['getMapX'](),$gameTemp['furniturePreviewSprite']['getMapY'](),_0x159725);},MK['Furniture']['buildIfConditionsMet']=function(_0xd291ac,_0x5dea11,_0x3d0266,_0x5109af={}){const _0x518ed8=MK['Furniture']['blueprint'](_0xd291ac),_0x128c86=_0x518ed8&&_0x518ed8['sourceMapName'];if(!_0x128c86){_0x518ed8['switchId']&&$gameSwitches['setValue'](_0x518ed8['switchId'],![]);return;}if(!MK['Furniture']['requirementsMet'](_0xd291ac)){_0x518ed8['switchId']&&$gameSwitches['setValue'](_0x518ed8['switchId'],![]),_0x2ef755&&$gameVariables['setValue'](_0x2ef755,_0xd291ac),_0x19fe60&&$gameTemp['reserveCommonEvent'](_0x19fe60);return;}if(!MK['Furniture']['hasEnoughStamina'](_0xd291ac)){_0x518ed8['switchId']&&$gameSwitches['setValue'](_0x518ed8['switchId'],![]),_0x2ef755&&$gameVariables['setValue'](_0x2ef755,_0xd291ac),_0xce6de6&&$gameTemp['reserveCommonEvent'](_0xce6de6);return;}if(!MK['Furniture']['hasAllRequiredMaterials'](_0xd291ac)){_0x518ed8['switchId']&&$gameSwitches['setValue'](_0x518ed8['switchId'],![]),_0x2ef755&&$gameVariables['setValue'](_0x2ef755,_0xd291ac),_0x582808&&$gameTemp['reserveCommonEvent'](_0x582808);return;}if(!MK['Furniture']['canBuildAt'](_0xd291ac,_0x5dea11,_0x3d0266)){_0x518ed8['switchId']&&$gameSwitches['setValue'](_0x518ed8['switchId'],![]),_0x2ef755&&$gameVariables['setValue'](_0x2ef755,_0xd291ac),_0x2d635f&&$gameTemp['reserveCommonEvent'](_0x2d635f);return;}MK['Furniture']['build'](_0xd291ac,_0x5dea11,_0x3d0266,_0x5109af);},MK['Furniture']['build']=function(_0x4d8b69,_0x4eee3d,_0x44b86,{direction:_0x496775,variant:_0x30a0bd}={}){const _0x1847cf=MK['Furniture']['blueprint'](_0x4d8b69),_0x2eb72c=_0x1847cf&&_0x1847cf['sourceMapName'],_0x4ab513=_0x1847cf['regionId'],_0x2893be=_0x2eb72c&&_0x4ab513&&MK['MapManipulation']['getAssetInfo'](_0x2eb72c,_0x4ab513);if(!_0x2893be)return;const _0x205607=_0x2893be['x']+(_0x30a0bd||0x0),_0xeade17=_0x2893be['y'],_0x410642=MK['SpawnEvents']['spawnFromXy'](_0x1847cf['sourceMapName'],_0x205607,_0xeade17,_0x4eee3d,_0x44b86);if(!_0x410642)return;_0x496775!==undefined&&(_0x410642['_direction']=_0x496775);$gameMap['registerEventAsFurniture'](_0x410642['eventId'](),{'blueprintName':_0x4d8b69,'direction':_0x496775,'variant':_0x30a0bd}),_0x891c5c(_0x1847cf['onBuildSE']||_0x389548);if(_0x1847cf['shakeScreen'])_0x59e876();_0x5aec1a(_0x1847cf),_0x5ee303(_0x1847cf),_0x496425(_0x1847cf),_0x2ef755&&$gameVariables['setValue'](_0xd01881,_0x4d8b69),_0x43540e&&$gameVariables['setValue'](_0x43540e,_0x4ab513),_0x1847cf['switchId']&&$gameSwitches['setValue'](_0x1847cf['switchId'],!![]),_0x1847cf['onBuildEval']&&_0x1847cf['onBuildEval']();if(_0x1847cf['commonEventId'])$gameTemp['reserveCommonEvent'](_0x1847cf['commonEventId']);else{if(_0xd01881)$gameTemp['reserveCommonEvent'](_0xd01881);}},MK['Furniture']['requirementsMet']=function(_0x91225d){const _0x4eaca4=MK['Furniture']['blueprint'](_0x91225d);return _0x4eaca4&&(!_0x4eaca4['preconditionSwitchId']||$gameSwitches['value'](_0x4eaca4['preconditionSwitchId']))&&(!_0x4eaca4['preconditionVariableId']||$gameVariables['value'](_0x4eaca4['preconditionVariableId']))>=_0x4eaca4['preconditionVariableLargerThan']&&(!_0x4eaca4['maxBuildsByMap']||$gameMap['countByFurniturePlanName'](_0x91225d)<_0x4eaca4['maxBuildsByMap'])&&(!_0x4eaca4['preconditionEval']||_0x4eaca4['preconditionEval']());},MK['Furniture']['canBuildAt']=function(_0x4ee8a2,_0x51dd25,_0x128dc2){const _0x5cc069=MK['Furniture']['blueprint'](_0x4ee8a2);return _0x5cc069&&$gameMap['checkAreaMatches'](_0x51dd25,_0x128dc2,_0x5cc069['sourceMapName'],_0x5cc069['regionId'])&&!($gamePlayer['x']==_0x51dd25&&$gamePlayer['y']==_0x128dc2);};function _0x5aec1a(_0x4276eb){_0x4276eb['requiredItems']['forEach'](_0xa49be9=>$gameParty['loseItem']($dataItems[_0xa49be9['itemId']],Math['round'](_0xa49be9['quantity']*$gameSystem['buildCostModifier']())));}function _0x5ee303(_0x2c54cd){$gameParty['loseGold'](Math['round'](_0x2c54cd['gold']*$gameSystem['buildCostModifier']()));}function _0x496425(_0x1859a4){if(MK['Furniture']['hasStaminaEnabled']()){const _0x245821=Math['round'](_0x1859a4['staminaCost']*$gameSystem['buildCostModifier']());$gameVariables['setValue'](_0x214c0a,MK['Furniture']['currentStamina']()-_0x245821);}}function _0x2df86c(_0x22aed7){if(_0x22aed7['noRefundMaterials'])return;const _0x43aa5f=$gameMap['_interpreter'];_0x22aed7['requiredItems']['forEach'](({itemId:_0x255251,quantity:_0x1a5b9c})=>{const _0x205503=$dataItems[_0x255251];_0x1a5b9c=Math['round'](_0x1a5b9c*$gameSystem['buildCostModifier']()),_0x205503&&_0x1a5b9c&&(_0x43aa5f?_0x43aa5f['command126']([_0x255251,0x0,0x0,_0x1a5b9c]):$gameParty['gainItem'](_0x205503,_0x1a5b9c));});}function _0x45fc2a(_0x1334a8){if(_0x1334a8['noRefundGold'])return;const _0x48b94e=Math['round'](_0x1334a8['gold']*$gameSystem['buildCostModifier']())||0x0,_0x3394e8=$gameMap['_interpreter'];_0x48b94e&&(_0x3394e8?_0x3394e8['command125']([0x0,0x0,_0x48b94e]):$gameParty['gainGold'](_0x48b94e));}MK['Furniture']['hasStaminaEnabled']=function(){return!!_0x214c0a;},MK['Furniture']['currentStamina']=function(){return _0x214c0a?$gameVariables['value'](_0x214c0a):0x0;},MK['Furniture']['setShovelMode']=function(_0x1e9ea4){$gameTemp['furnitureShovelMode']=_0x1e9ea4;},MK['Furniture']['isShovelMode']=function(){return $gameTemp['furnitureShovelMode'];},MK['Furniture']['unbuildAtXY']=function(_0x3dcaa5,_0x53c8eb){$gameMap['events']()['filter'](_0x2169d6=>_0x2169d6['x']==_0x3dcaa5&&_0x2169d6['y']==_0x53c8eb)['forEach'](_0x3162f3=>MK['Furniture']['unbuildByEventId'](_0x3162f3['eventId']()));},MK['Furniture']['unbuildByEventId']=function(_0x3f5c59){const _0x27d735=$gameMap['event'](_0x3f5c59);_0x27d735&&_0x27d735['isFurniture']()&&_0x27d735['erase']();},MK['Furniture']['unbuildByFurniturePlanName']=function(_0x40769b){$gameMap['events']()['filter'](_0x24a712=>_0x24a712['isFurniture']())['filter'](_0x3b70f0=>_0x3b70f0['furniturePlanName']()==_0x40769b)['forEach'](_0x553180=>MK['Furniture']['unbuildByEventId'](_0x553180['eventId']()));},MK['Furniture']['unbuildAll']=function(){$gameMap['events']()['filter'](_0x376d35=>_0x376d35['isFurniture']())['forEach'](_0x296d99=>MK['Furniture']['unbuildByEventId'](_0x296d99['eventId']()));},Game_Map['prototype']['registerEventAsFurniture']=function(_0x143e19,_0x5d3fd7){const _0x259a66=this['event'](_0x143e19);if(!_0x259a66)return;this['_furnitures']=this['_furnitures']||{},this['_furnitures'][this['mapId']()]=this['_furnitures'][this['mapId']()]||{},this['_furnitures'][this['mapId']()][_0x143e19]=_0x5d3fd7;},Game_Map['prototype']['unregisterEventAsFurniture']=function(_0x1c5cdc){const _0x18b7a1=this['event'](_0x1c5cdc);if(!_0x18b7a1||!this['_furnitures'])return;this['_furnitures']=this['_furnitures']||{},this['_furnitures'][this['mapId']()]=this['_furnitures'][this['mapId']()]||{},delete this['_furnitures'][this['mapId']()][_0x1c5cdc];},Game_Event['prototype']['isFurniture']=function(){return!!this['furnitureInfo']();},Game_Event['prototype']['furnitureInfo']=function(){const _0xf3798b=$gameMap['_furnitures']&&$gameMap['_furnitures'][$gameMap['mapId']()];if(_0xf3798b)return _0xf3798b[this['eventId']()];},Game_Event['prototype']['furniturePlanName']=function(){const _0x953f75=this['furnitureInfo']();return _0x953f75?_0x953f75['blueprintName']:undefined;},Game_Event['prototype']['furniturePlan']=function(){const _0x4f4ee6=this['furniturePlanName']();return MK['Furniture']['blueprint'](_0x4f4ee6);};const _0x5020f1=MK['SpawnEvents']['unspawn'];MK['SpawnEvents']['unspawn']=function(_0x2e46c0){const _0x4c6a1b=$gameMap['event'](_0x2e46c0),_0x54e0b9=_0x4c6a1b&&_0x4c6a1b['furniturePlan']();_0x54e0b9&&(_0x45fc2a(_0x54e0b9),_0x2df86c(_0x54e0b9)),$gameMap['unregisterEventAsFurniture'](_0x2e46c0),_0x5020f1['call'](this,_0x2e46c0);},Game_Map['prototype']['countByFurniturePlanName']=function(_0x24d180){return this['events']()['filter'](_0xc909ec=>_0xc909ec['furniturePlanName']()==_0x24d180)['length'];},MK['Furniture']['startMove']=function(_0x19bd36){if(!MK['Furniture']['canStartBuildMode']())return;const _0x5bf1e0=$gameMap['event'](_0x19bd36);if(_0x5bf1e0&&_0x5bf1e0['isFurniture']()){const _0xda24da=_0x5bf1e0['furnitureInfo'](),_0x4bab0e=_0x5bf1e0['furniturePlanName']();MK['Furniture']['unbuildByEventId'](_0x19bd36),MK['Furniture']['startBuildMode'](_0x4bab0e,{'direction':_0xda24da['direction'],'variant':_0xda24da['variant']});}},Game_Event['prototype']['startMoveAsFurniture']=function(){this['isFurniture']()&&MK['Furniture']['startMove'](this['eventId']());},Game_Interpreter['prototype']['moveFurniture']=function(){const _0x101c23=this['isOnCurrentMap']()?this['eventId']():0x0,_0x397441=$gameMap['event'](_0x101c23);_0x397441&&_0x397441['startMoveAsFurniture']();},Game_Interpreter['prototype']['unbuildFurniture']=function(){const _0x12646c=this['isOnCurrentMap']()?this['eventId']():0x0,_0x365b2e=$gameMap['event'](_0x12646c);_0x365b2e&&MK['Furniture']['unbuildByEventId'](_0x12646c);},MK['Furniture']['blueprint']=function(_0x1b97cd){return _0x255159['find'](_0x34230d=>_0x34230d['blueprintName']==_0x1b97cd);},MK['Furniture']['allBlueprints']=function(){return _0x255159;};const _0x399106=DataManager['setupNewGame'];DataManager['setupNewGame']=function(){_0x399106['call'](this),_0x255159['filter'](_0x15fdd5=>_0x15fdd5&&_0x15fdd5['initiallyAvailable'])['forEach'](_0x296d33=>$gameParty['learnFurniturePlan'](_0x296d33['blueprintName']));},MK['Furniture']['hasEnoughStamina']=function(_0x1adcb2){const _0x32a9a3=MK['Furniture']['blueprint'](_0x1adcb2);if(!_0x32a9a3)return![];if(!MK['Furniture']['hasStaminaEnabled']())return!![];const _0x7d4e98=Math['round'](_0x32a9a3['staminaCost']*$gameSystem['buildCostModifier']());return MK['Furniture']['currentStamina']()>=_0x7d4e98;},MK['Furniture']['hasAllRequiredMaterials']=function(_0x46a4f2){const _0x385993=MK['Furniture']['blueprint'](_0x46a4f2);if(_0x385993){const _0xe5c006=_0x51ccc9(_0x385993),_0x3c33be=Math['round'](_0x385993['gold']*$gameSystem['buildCostModifier']())<=$gameParty['gold']();return _0xe5c006&&_0x3c33be;}};function _0x51ccc9(_0x590af1){return _0x590af1['requiredItems']['every'](_0xd1dca0=>{const _0x22e3e2=Math['round'](_0xd1dca0['quantity']*$gameSystem['buildCostModifier']()),_0x31916b=$gameParty['numItems']($dataItems[_0xd1dca0['itemId']]);return _0x31916b>=_0x22e3e2;});}MK['Furniture']['canBuild']=function(_0x40d007){return MK['Furniture']['requirementsMet'](_0x40d007)&&MK['Furniture']['hasAllRequiredMaterials'](_0x40d007);},Game_Party['prototype']['learnedFurniturePlans']=function(){return this['_furniturePlans']=this['_furniturePlans']||[],_0x255159['filter'](_0x258451=>this['hasFurniturePlan'](_0x258451['blueprintName']));};const _0x2c223b=(_0x3ce4e6,_0x131a15)=>_0x3ce4e6&&_0x131a15&&_0x3ce4e6['trim']()['toLowerCase']()==_0x131a15['trim']()['toLowerCase']();Game_Party['prototype']['hasFurniturePlan']=function(_0x1ae7dc){return this['_furniturePlans']['includes'](_0x1ae7dc)||this['items']()['some'](_0x3e5a2d=>_0x3e5a2d['meta']&&_0x2c223b(_0x3e5a2d['meta']['Furniture'],_0x1ae7dc));},Game_Party['prototype']['learnFurniturePlan']=function(_0x2791cb){this['_furniturePlans']=this['_furniturePlans']||[];if(!this['_furniturePlans']['includes'](_0x2791cb))this['_furniturePlans']['push'](_0x2791cb);},Game_Party['prototype']['forgetFurniturePlan']=function(_0x773234){this['_furniturePlans']=this['_furniturePlans']||[],this['_furniturePlans']['remove'](_0x773234);},Game_System['prototype']['buildCostModifier']=function(){return this['_buildCostModifier']!==undefined?this['_buildCostModifier']:0x1;},Game_System['prototype']['setBuildCostModifier']=function(_0x4a391b){this['_buildCostModifier']=_0x4a391b;};const _0x2239c7=Scene_Map['prototype']['createDisplayObjects'];Scene_Map['prototype']['createDisplayObjects']=function(){_0x2239c7['call'](this),this['createFurnitureHelpWindow'](),this['createFurnitureCancelButton']();},Scene_Map['prototype']['createFurnitureHelpWindow']=function(){const _0x5e2c96=this['furnitureHelpWindowRectangle']();'MZ'==Utils['RPGMAKER_NAME']?this['_mk_furniture_helpWindow']=new _0x3d9dbe(_0x5e2c96):this['_mk_furniture_helpWindow']=new _0x3d9dbe(_0x5e2c96['x'],_0x5e2c96['y'],_0x5e2c96['width'],_0x5e2c96['height']),this['_mk_furniture_helpWindow']['hide'](),this['addWindow'](this['_mk_furniture_helpWindow']);},Scene_Map['prototype']['furnitureHelpWindowRectangle']=function(){const _0x414388=Math['floor']((Graphics['boxWidth']-0x14)*0.4),_0x26237b=this['furnitureHelpWindowHeight'](),_0x58f561=Graphics['boxWidth']-_0x414388-0xa,_0x21cf78=Graphics['boxHeight']-_0x26237b-0xa;return new Rectangle(_0x58f561,_0x21cf78,_0x414388,_0x26237b);},Scene_Map['prototype']['furnitureHelpWindowHeight']=function(){const _0x295303=Utils['RPGMAKER_NAME']=='MZ'?new _0x3d9dbe(new Rectangle(0x0,0x0,0x0,0x0)):new _0x3d9dbe(0x0,0x0,0x0,0x0),_0x91716=_0x295303['actionKeys']()['length'];return _0x295303['fittingHeight'](_0x91716);},Scene_Map['prototype']['createFurnitureCancelButton']=function(){if(this['_menuButton']){const _0x41fcc0=new Sprite_Button('cancel');_0x41fcc0['x']=this['_menuButton']['x']+this['_menuButton']['width']-_0x41fcc0['width'],_0x41fcc0['y']=this['_menuButton']['y'],_0x41fcc0['visible']=![],_0x41fcc0['setClickHandler'](this['onFurnitureCancel']['bind'](this)),this['_mk_furniture_cancelButton']=_0x41fcc0,this['addWindow'](_0x41fcc0);}};const _0x493cfa=Scene_Map['prototype']['update'];Scene_Map['prototype']['update']=function(){_0x493cfa['call'](this),MK['Furniture']['isBuildMode']()&&Input['isTriggered']('ok')&&MK['Furniture']['buildByTouchInput'](),MK['Furniture']['isBuildMode']()&&(Input['isTriggered']('cancel')||TouchInput['isCancelled']())&&MK['Furniture']['quitBuildMode'](),this['updateFurnitureHelpWindow'](),this['updateFurnitureCancelButton']();},Scene_Map['prototype']['updateFurnitureHelpWindow']=function(){this['_mk_furniture_helpWindow']['visible']=_0x54bf73&&MK['Furniture']['isBuildMode']()&&!MK['Furniture']['isShovelMode']();},Scene_Map['prototype']['updateFurnitureCancelButton']=function(){const _0x4de8d2=this['_mk_furniture_cancelButton'];_0x4de8d2&&(_0x4de8d2['visible']=MK['Furniture']['isCancelButtonVisible']());};const _0x6b3965=Game_Player['prototype']['update'];Game_Player['prototype']['update']=function(){_0x6b3965['apply'](this,arguments),MK['Furniture']['isBuildMode']()&&!MK['Furniture']['isShovelMode']()&&this['turnTowardCharacter']({'x':$gameTemp['furniturePreviewSprite']['getMapXCentered'](),'y':$gameTemp['furniturePreviewSprite']['getMapYCentered']()});};const _0x5978fc=Game_Player['prototype']['canMove'];Game_Player['prototype']['canMove']=function(){return _0x5978fc['call'](this)&&(!MK['Furniture']['isBuildMode']()||MK['Furniture']['isShovelMode']());};const _0xf9c488=Game_Player['prototype']['canStartLocalEvents'];Game_Player['prototype']['canStartLocalEvents']=function(){return _0xf9c488['call'](this)&&!MK['Furniture']['isBuildMode']();},Scene_Map['prototype']['onFurnitureCancel']=function(){MK['Furniture']['isBuildMode']()&&MK['Furniture']['quitBuildMode']();},MK['Furniture']['isCancelButtonVisible']=function(){return ConfigManager['touchUI']&&MK['Furniture']['isBuildMode']();};const _0x5df571=Scene_Map['prototype']['isAnyButtonPressed'];Scene_Map['prototype']['isAnyButtonPressed']=function(){const _0x38a8c4=[this['_mk_furniture_cancelButton'],$gameTemp['furniturePreviewSprite'],$gameTemp['furnitureCycleVariantButton'],$gameTemp['furnitureRotateLeftButton'],$gameTemp['furnitureRotateRightButton']];return _0x38a8c4['filter'](Boolean)['some'](_0x110641=>_0x110641['isPressed']())||_0x5df571['call'](this);};const _0x47a382=Scene_Map['prototype']['isMenuEnabled'];Scene_Map['prototype']['isMenuEnabled']=function(){return _0x47a382['call'](this)&&!MK['Furniture']['isBuildMode']();};PluginManager['registerCommand']&&(PluginManager['registerCommand'](_0x1e8553,'startBuildMode',_0x172d8a=>{MK['Furniture']['startBuildMode'](_0x172d8a['blueprintName']);}),PluginManager['registerCommand'](_0x1e8553,'quitBuildMode',()=>{MK['Furniture']['quitBuildMode']();}),PluginManager['registerCommand'](_0x1e8553,'removeAllFurniture',()=>{MK['Furniture']['unbuildAll']();}),PluginManager['registerCommand'](_0x1e8553,'addOrRemoveBlueprint',_0x56ffe9=>{'Learn'==_0x56ffe9['mode']?$gameParty['learnFurniturePlan'](_0x56ffe9['blueprintName']):$gameParty['forgetFurniturePlan'](_0x56ffe9['blueprintName']);}),PluginManager['registerCommand'](_0x1e8553,'setShovelMode',_0x29d2fb=>{MK['Furniture']['setShovelMode']('true'==_0x29d2fb['mode']);}),PluginManager['registerCommand'](_0x1e8553,'changeBuildCostModifier',_0x3de53f=>{$gameSystem['setBuildCostModifier'](Number(_0x3de53f['modifier'])||0x0);}),PluginManager['registerCommand'](_0x1e8553,'countByFurniturePlanName',_0x4bf57e=>{const _0x3d6b79=$gameMap['countByFurniturePlanName'](_0x4bf57e['blueprintName']);$gameVariables['setValue'](Number(_0x4bf57e['variableId'])||0x0,_0x3d6b79);}));const _0x891c5c=_0x4a96e8=>{_0x4a96e8&&AudioManager['playSe']({'name':_0x4a96e8,'volume':0x64,'pitch':0x64,'pan':0x0});},_0x59e876=()=>$gameScreen['startShake'](0x5,0x5,0xa);function _0x432817(){return!Utils['isNwjs']()&&window['location']['hostname']=='play.aerosys.blog';}function _0x57f798(){return _0x432817()||MK['Furniture']['unlockKey']==='20022c0e-yxcv-4363-asdf-7063217f16e9';}const _0x1b588f=Scene_Boot['prototype']['start'];Scene_Boot['prototype']['start']=function(){_0x1b588f['call'](this);if(!_0x57f798()){const _0x272e78=Game_Map['prototype']['persistedSpawnedEvents'];Game_Map['prototype']['persistedSpawnedEvents']=function(){const _0x5e1de2=this['_furnitures']&&this['_furnitures'][this['mapId']()];return _0x272e78['call'](this)['filter'](_0x24d4d5=>!(_0x5e1de2&&_0x5e1de2[_0x24d4d5['eventId']]));};}};}());