Testhostplaycanvasmobile / 664.bundle.js
kwabs22
First commit after mobile control creation
0bc2025
"use strict";(self.webpackChunkplaycanvas_game=self.webpackChunkplaycanvas_game||[]).push([[664],{664:(e,t,i)=>{i.r(t),i.d(t,{default:()=>n});const n={id:"generator_crisis",title:"Generator Crisis",type:"mission",async build(e,t,i){console.log("[GeneratorCrisis] Building generator room...");const n=t.createRoom({size:[25,5,20],position:[0,0,0],lighting:"emergency"});n.name="GeneratorRoom",e.root.addChild(n);const a=i.create("MainGenerator",{components:{model:{type:"cylinder"},collision:{type:"cylinder",radius:2,height:4},rigidbody:{type:"static"}},position:[0,2,-5],scale:[4,4,4],tags:["interactive","mission_critical"]});if(a.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.3,.3,.3),e.emissive=new pc.Color(.8,.2,.2),e.emissiveIntensity=.5,e.update(),a.model.meshInstances.forEach(t=>t.material=e)}n.addChild(a),[[-8,1,-5],[8,1,-5],[0,1,5]].forEach((e,t)=>{const a=i.create(`ControlPanel_${t}`,{components:{model:{type:"box"},collision:{type:"box",halfExtents:[1,1,.2]},rigidbody:{type:"static"}},position:e,scale:[2,2,.4],tags:["interactive","control_panel"]});if(a.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.2,.2,.3),e.emissive=0===t?new pc.Color(0,1,0):new pc.Color(1,0,0),e.emissiveIntensity=.3,e.update(),a.model.meshInstances.forEach(t=>t.material=e)}n.addChild(a)});const o=i.createNPC("engineer_chen",{position:[5,0,0],displayName:"Engineer Chen",dialogue:{greeting:"The generator is failing! We need to fix it quickly!",topics:{generator:"The main power coupling has failed. Check the control panels.",help:"Activate all three control panels in the correct sequence.",sequence:"Green first, then the two red panels."}}});n.addChild(o);const s=i.createLight("point",{color:new pc.Color(1,0,0),intensity:1,range:15,position:[0,4,0]});let r=0;const c=e=>{s&&s.light&&(r+=10*e,s.light.intensity=.5+.5*Math.sin(r))};e.on("update",c),this.flickerHandler=c,n.addChild(s);const l=i.create("Sparks",{position:[0,3,-3]});n.addChild(l);const d=i.create("SpawnPoint",{position:[0,0,8]});return n.addChild(d),n},objectives:[{id:"talk_to_engineer",name:"Talk to the Engineer",description:"Find out what happened to the generator",type:"simple",rewards:{experience:30}},{id:"activate_panels",name:"Restore Power",description:"Activate control panels in correct sequence",type:"counter",target:3,progress:0,timeLimit:300,rewards:{experience:150,items:[{id:"tech_parts",quantity:5}]}},{id:"generator_fixed",name:"Crisis Averted",description:"The generator is back online!",type:"simple",prerequisites:["activate_panels"],rewards:{experience:200,skillPoints:1}}],state:{panelsActivated:[],correctSequence:["ControlPanel_0","ControlPanel_1","ControlPanel_2"],generatorFixed:!1},onLoad(e,t){console.log("[GeneratorCrisis] Mission started");const i=t.getSystem("objectivemanager");i&&(i.clearAllObjectives(),this.objectives.forEach(e=>{i.defineObjective(e.id,e)}),i.startObjective("talk_to_engineer")),this.setupPanelInteractions(e,t),e.fire("ui:notification",{text:"WARNING: Generator failure detected!",type:"error",duration:5e3})},setupPanelInteractions(e,t){const i=i=>{if(!i.includes("ControlPanel_"))return;const n=t.getSystem("objectivemanager");n&&!this.state.generatorFixed&&(this.state.panelsActivated.includes(i)?e.fire("ui:notification",{text:"Panel already activated",type:"warning"}):(this.state.panelsActivated.push(i),n.updateObjective("activate_panels",this.state.panelsActivated.length),this.state.panelsActivated.every((e,t)=>e===this.state.correctSequence[t])?(e.fire("ui:notification",{text:`Panel activated (${this.state.panelsActivated.length}/3)`,type:"success"}),3===this.state.panelsActivated.length&&this.fixGenerator(e,t)):(e.fire("ui:notification",{text:"Wrong sequence! Panels reset.",type:"error"}),this.state.panelsActivated=[],n.updateObjective("activate_panels",0),this.resetPanels(e))))};e.on("entity:interact",i),this.interactHandler=i},resetPanels(e){for(let t=0;t<3;t++){const i=e.root.findByName(`ControlPanel_${t}`);if(i&&i.model){const e=i.model.meshInstances[0].material;e.emissive=0===t?new pc.Color(0,1,0):new pc.Color(1,0,0),e.update()}}},fixGenerator(e,t){if(this.state.generatorFixed)return void console.log("[GeneratorCrisis] Generator already fixed, ignoring duplicate call");this.state.generatorFixed=!0;const i=e.root.findByName("MainGenerator");if(i&&i.model){const e=i.model.meshInstances[0].material;e.emissive=new pc.Color(0,.5,1),e.update()}const n=t.getSystem("objectivemanager");n&&(n.completeObjective("activate_panels"),n.startObjective("generator_fixed"),this.completionTimeout=setTimeout(()=>{n&&n.completeObjective("generator_fixed")},1e3)),e.fire("ui:notification",{text:"Generator restored! Crisis averted!",type:"success",duration:5e3});const a=e.root.findByName("Light");a&&(a.light.color=new pc.Color(1,1,1),a.light.intensity=1)},onUnload(e,t){console.log("[GeneratorCrisis] Cleaning up mission..."),this.flickerHandler&&(e.off("update",this.flickerHandler),this.flickerHandler=null),this.interactHandler&&(e.off("entity:interact",this.interactHandler),this.interactHandler=null),this.completionTimeout&&(clearTimeout(this.completionTimeout),this.completionTimeout=null),this.state.panelsActivated=[],this.state.generatorFixed=!1,console.log("[GeneratorCrisis] Mission cleanup complete")}}}}]);