"use strict";(self.webpackChunkplaycanvas_game=self.webpackChunkplaycanvas_game||[]).push([[881],{881:(e,t,i)=>{i.r(t),i.d(t,{default:()=>a});const a={id:"medical_bay",title:"Medical Bay",type:"scene",async build(e,t,i){console.log("[MedicalBayScene] Building medical bay scene...");const a=t.createRoom({size:[20,4,15],position:[0,0,0],lighting:"clinical"});a.name="MedicalBayRoom",e.root.addChild(a),[[-6,.5,-3],[-6,.5,3],[6,.5,-3],[6,.5,3]].forEach((e,t)=>{const s=i.create(`MedBed_${t}`,{components:{model:{type:"box"},collision:{type:"box",halfExtents:[1,.4,2]},rigidbody:{type:"static"}},position:e,scale:[2,.8,4]});if(s.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.9,.9,.9),e.update(),s.model.meshInstances.forEach(t=>t.material=e)}s.tags.add("interactive","medical_bed"),a.addChild(s)});const s=i.create("MedicalCabinet",{components:{model:{type:"box"},collision:{type:"box",halfExtents:[1.5,1,.5]},rigidbody:{type:"static"}},position:[0,1,-7],scale:[3,2,1],tags:["interactive"]});if(s.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.7,.8,.9),e.update(),s.model.meshInstances.forEach(t=>t.material=e)}s.tags.add("interactive","supply_cabinet"),a.addChild(s);const n=i.createNPC("doctor_hayes",{position:[0,0,0],displayName:"Dr. Hayes",dialogue:{greeting:"Thank goodness you're here! We have an emergency situation.",topics:{emergency:"Multiple patients came in with unknown symptoms. We need help.",supplies:"The medical supplies are running low. Check the cabinet.",patients:"Please check on all the patients and report back to me.",status:"How are the examinations going? Any concerning findings?"}}});n.tags.add("medical_staff"),a.addChild(n);const o=i.createLight("point",{color:new pc.Color(1,1,1),intensity:2,range:10,position:[-5,3,0]});a.addChild(o);const c=i.createLight("point",{color:new pc.Color(1,1,1),intensity:2,range:10,position:[5,3,0]});a.addChild(c);const l=i.create("SpawnPoint",{position:[0,0,5]});return a.addChild(l),a},objectives:[{id:"medical_arrival",name:"Medical Bay Assessment",description:"Assess the medical emergency situation",type:"simple",autoStart:!0,rewards:{experience:15}},{id:"examine_patients",name:"Check on Patients",description:"Examine all 4 medical beds to assess patient conditions",type:"counter",target:4,progress:0,rewards:{experience:40,items:[{id:"medical_data",quantity:1}]}},{id:"find_medicine",name:"Collect Medical Supplies",description:"Search the medical cabinet for emergency supplies",type:"simple",rewards:{items:[{id:"health_potion",quantity:3},{id:"antibiotics",quantity:2}],experience:30}},{id:"talk_to_doctor",name:"Consult Dr. Hayes",description:"Speak with Dr. Hayes about the emergency situation",type:"simple",rewards:{experience:50,items:[{id:"medical_report",quantity:1}]}},{id:"emergency_complete",name:"Emergency Response Complete",description:"Successfully assist with the medical bay emergency",type:"simple",prerequisites:["examine_patients","find_medicine","talk_to_doctor"],rewards:{experience:100,skillPoints:1,items:[{id:"medical_badge",quantity:1}]}}],state:{bedsExamined:new Set,suppliesCollected:!1,doctorConsulted:!1,completionInProgress:!1},onLoad(e,t){console.log("[MedicalBayScene] Scene loaded, setting up medical objectives...");const i=t.getSystem("objectivemanager");i&&(i.clearAllObjectives(),this.objectives.forEach(e=>{i.defineObjective(e.id,e)}),i.startObjective("medical_arrival")),this.setupInteractions(e,t),e.fire("ui:notification",{text:"EMERGENCY: Medical bay requires immediate assistance!",type:"warning",duration:5e3}),this.startMainObjectivesTimer=setTimeout(()=>{try{const e=t.getSystem("objectivemanager");if(!e)return void console.warn("[MedicalBayScene] ObjectiveManager not available during auto-start");e.objectives.has("medical_arrival")&&e.completeObjective("medical_arrival"),e.objectives.has("examine_patients")&&e.startObjective("examine_patients"),e.objectives.has("find_medicine")&&e.startObjective("find_medicine"),e.objectives.has("talk_to_doctor")&&e.startObjective("talk_to_doctor")}catch(e){console.error("[MedicalBayScene] Error during auto-start objectives:",e)}},3e3)},setupInteractions(e,t){const i=t.getSystem("objectivemanager"),a=t=>{if(console.log(`[MedicalBayScene] Interacting with: ${t}`),t.startsWith("MedBed_")&&!this.state.bedsExamined.has(t)){this.state.bedsExamined.add(t);const a=t.split("_")[1],s=["stable","critical","recovering","needs medication"][parseInt(a)];if(e.fire("ui:notification",{text:`Patient ${parseInt(a)+1}: Status - ${s}`,type:"info",duration:3e3}),i){const t=i.objectives.get("examine_patients");t&&"active"===t.state&&(i.updateObjective("examine_patients",this.state.bedsExamined.size),this.state.bedsExamined.size>=4&&this.checkCompletionStatus(i,e))}}else"MedicalCabinet"!==t||this.state.suppliesCollected||(this.state.suppliesCollected=!0,e.fire("ui:notification",{text:"Found: Emergency medical supplies and medications",type:"success",duration:4e3}),i&&(i.completeObjective("find_medicine"),this.checkCompletionStatus(i,e)))};e.on("interaction:triggered",a),this.interactHandler=a;const s=t=>{"doctor_hayes"!==t||this.state.doctorConsulted||(this.state.doctorConsulted=!0,e.fire("ui:notification",{text:'Dr. Hayes: "Thank you for your assistance! The crisis is under control."',type:"info",duration:5e3}),i&&(i.completeObjective("talk_to_doctor"),this.checkCompletionStatus(i,e)))};e.on("npc:interact",s),this.npcHandler=s},checkCompletionStatus(e,t){this.state.completionInProgress?console.log("[MedicalBayScene] Completion already in progress, ignoring duplicate call"):this.state.bedsExamined.size>=4&&this.state.suppliesCollected&&this.state.doctorConsulted&&(console.log("[MedicalBayScene] All objectives complete, starting final sequence"),this.state.completionInProgress=!0,e.startObjective("emergency_complete"),this.completionTimer=setTimeout(()=>{try{e.completeObjective("emergency_complete"),t.fire("ui:notification",{text:"MISSION SUCCESS: Medical emergency successfully resolved!",type:"success",duration:6e3}),console.log("[MedicalBayScene] Mission completion sequence finished")}catch(e){console.error("[MedicalBayScene] Error during completion:",e)}finally{this.completionTimer=null,this.state.completionInProgress=!1}},2e3))},onUnload(e,t){console.log("[MedicalBayScene] Cleaning up medical bay scene..."),this.startMainObjectivesTimer&&(clearTimeout(this.startMainObjectivesTimer),this.startMainObjectivesTimer=null),this.completionTimer&&(clearTimeout(this.completionTimer),this.completionTimer=null),this.interactHandler&&(e.off("interaction:triggered",this.interactHandler),this.interactHandler=null),this.npcHandler&&(e.off("npc:interact",this.npcHandler),this.npcHandler=null),e.root.findByTag("npc").forEach(e=>{e.cleanupLabel&&e.cleanupLabel()}),this.state&&(this.state.bedsExamined?.clear(),this.state.suppliesCollected=!1,this.state.doctorConsulted=!1,this.state.completionInProgress=!1)}}}}]);