|
|
"use strict";(self.webpackChunkplaycanvas_game=self.webpackChunkplaycanvas_game||[]).push([[576],{576:(e,t,a)=>{a.r(t),a.d(t,{default:()=>n});const n={name:"Tavern Scene",description:"A warm tavern where adventurers gather to share stories and find quests",async build(e,t,a){console.log("[TavernScene] Building tavern...");const n=a.create("TavernRoot",{position:[0,0,0],tags:["scene_root"]}),i=t.createRoom({size:[20,4,16],position:[0,0,0],lighting:"warm"});i.name="TavernRoom",n.addChild(i);const r=a.createLight("point",{color:new pc.Color(1,.6,.2),intensity:2,range:10,position:[-5,2,-5]});i.addChild(r);const o=a.create("BarCounter",{components:{model:{type:"box"},collision:{type:"box",halfExtents:[3,.5,.75]},rigidbody:{type:"static"}},position:[-6,.5,0],scale:[6,1,1.5],tags:["furniture","bar"]});if(o.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.4,.2,.1),e.update(),o.model.material=e}i.addChild(o),[[3,0,-4],[3,0,4],[-3,0,4]].forEach((e,t)=>{const n=a.create(`Table_${t}`,{components:{model:{type:"box"},collision:{type:"box",halfExtents:[1,.4,1]},rigidbody:{type:"static"}},position:[e[0],.4,e[2]],scale:[2,.8,2],tags:["furniture","table"]});if(n.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.5,.3,.2),e.update(),n.model.material=e}i.addChild(n)});const s=a.createNPC("bartender_grim",{position:[-4,0,0],displayName:"Grim the Bartender",dialogue:{greeting:"Welcome to the Rusty Tankard! What can I get you?",topics:{drink:"Our special today is Dragon's Breath Ale. Burns on the way down!",rumors:"Strange things happening at the old generator station...",quest:"Talk to the patron in the corner. He's been asking for help."}}});s.tags.add("bartender"),i.addChild(s);const c=a.createNPC("patron_mysterious",{position:[3,0,-4],displayName:"Mysterious Patron",dialogue:{greeting:"You look capable... I might have a job for you.",topics:{job:"The medical bay needs supplies delivered. Dangerous work.",payment:"100 gold pieces, plus whatever you find along the way.",accept:"Excellent! Head to the medical bay when you're ready."}}});c.tags.add("quest_giver"),i.addChild(c);const d=a.createNPC("bard_melody",{position:[0,0,6],displayName:"Melody the Bard",dialogue:{greeting:"♪ Welcome, traveler! Care to hear a song? ♪",topics:{song:"♪ The generator failed one night... ♪",tip:"A coin for your humble bard?",news:"I heard the nightshift at the station is cursed!"}}});d.tags.add("bard"),i.addChild(d);const l=a.create("QuestBoard",{components:{model:{type:"box"},collision:{type:"box",halfExtents:[1,1,.1]},rigidbody:{type:"static"}},position:[7,2,0],scale:[2,2,.2],tags:["interactive","quest_board"]});if(l.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.6,.4,.2),e.emissive=new pc.Color(.1,.05,0),e.update(),l.model.material=e}i.addChild(l);const p=a.create("SpawnPoint",{position:[0,0,7],tags:["spawn"]});return n.addChild(p),console.log("[TavernScene] Tavern built successfully"),n},objectives:[{id:"tavern_introduction",name:"Welcome to the Tavern",description:"Talk to the bartender",type:"simple",autoStart:!0,rewards:{experience:10}},{id:"gather_information",name:"Gather Information",description:"Talk to all three NPCs in the tavern",type:"counter",target:3,progress:0,prerequisites:["tavern_introduction"],rewards:{experience:30,gold:10}},{id:"accept_quest",name:"Accept a Quest",description:"Accept a quest from the mysterious patron",type:"simple",prerequisites:["gather_information"],rewards:{experience:50,items:[{id:"quest_scroll",quantity:1}]}},{id:"check_quest_board",name:"Check the Quest Board",description:"Interact with the quest board to see available missions",type:"simple",rewards:{experience:20}}],state:{npcsInteracted:new Set,questAccepted:!1,questInProgress:!1,drinksOrdered:0},onLoad(e,t){console.log("[TavernScene] Scene loaded, setting up objectives...");const a=t.getSystem("objectivemanager");a&&(a.clearAllObjectives(),this.objectives.forEach(e=>{a.defineObjective(e.id,e)}),a.startObjective("tavern_introduction"),a.startObjective("check_quest_board")),this.setupInteractions(e,t),e.fire("ui:notification",{text:"Welcome to the Rusty Tankard Tavern!",type:"info",duration:5e3})},setupInteractions(e,t){const a=t.getSystem("objectivemanager"),n=t=>{if(console.log(`[TavernScene] Interacting with NPC: ${t}`),"bartender_grim"===t&&a&&a.isObjectiveActive("tavern_introduction")&&(a.completeObjective("tavern_introduction"),a.startObjective("gather_information")),this.state.npcsInteracted.has(t)||(this.state.npcsInteracted.add(t),a&&a.isObjectiveActive("gather_information")&&(a.updateObjective("gather_information",this.state.npcsInteracted.size),this.state.npcsInteracted.size>=3&&(a.completeObjective("gather_information"),a.startObjective("accept_quest")))),"patron_mysterious"===t&&!this.state.questAccepted){if(this.state.questInProgress)return void console.log("[TavernScene] Quest acceptance already in progress");this.state.questInProgress=!0,setTimeout(()=>{try{e.fire("ui:notification",{text:"Quest Accepted: Medical Supply Delivery",type:"success",duration:3e3}),this.state.questAccepted=!0,a&&a.isObjectiveActive("accept_quest")&&a.completeObjective("accept_quest")}catch(e){console.error("[TavernScene] Error during quest acceptance:",e)}finally{this.state.questInProgress=!1}},2e3)}};e.on("npc:interact",n),this.npcHandler=n;const i=t=>{"QuestBoard"===t&&(console.log("[TavernScene] Quest board accessed"),e.fire("ui:notification",{text:"Available Quests:\n• Medical Supply Delivery\n• Generator Crisis\n• Nightshift Coverage",type:"info",duration:5e3}),a&&a.completeObjective("check_quest_board"))};e.on("interaction:triggered",i),this.interactHandler=i},onUnload(e,t){console.log("[TavernScene] Cleaning up tavern scene..."),this.npcHandler&&(e.off("npc:interact",this.npcHandler),this.npcHandler=null),this.interactHandler&&(e.off("interaction:triggered",this.interactHandler),this.interactHandler=null),e.root.findByTag("npc").forEach(e=>{e.cleanupLabel&&e.cleanupLabel()}),this.state&&(this.state.npcsInteracted?.clear(),this.state.questAccepted=!1,this.state.questInProgress=!1,this.state.drinksOrdered=0)}}}}]); |