Testhostplaycanvasmobile / 208.bundle.js
kwabs22
First commit after mobile control creation
0bc2025
"use strict";(self.webpackChunkplaycanvas_game=self.webpackChunkplaycanvas_game||[]).push([[208],{208:(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});const o={id:"nightshift_horror",title:"Nightshift Horror",type:"mission",async build(e,t,i){console.log("[NightshiftHorror] Building security office...");const o=t.createRoom({size:[15,3.5,12],position:[0,0,0],lighting:"dim"});o.name="SecurityOffice",e.root.addChild(o);const a=i.create("SecurityDesk",{components:{model:{type:"box"},collision:{type:"box",halfExtents:[2,.4,1]},rigidbody:{type:"static"}},position:[0,.8,-3],scale:[4,.8,2]});if(a.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.3,.2,.1),e.update(),a.model.meshInstances.forEach(t=>t.material=e)}o.addChild(a),[[-1.5,.7,0],[0,.7,0],[1.5,.7,0]].forEach((e,t)=>{const o=i.create(`Monitor_${t}`,{components:{model:{type:"box"},collision:{type:"box",halfExtents:[.4,.3,.1]},rigidbody:{type:"static"}},position:e,scale:[.8,.6,.2],tags:["interactive","monitor","security_camera"]});if(o.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.1,.1,.1),e.emissive=new pc.Color(0,.3,.5),e.emissiveIntensity=.5,e.update(),o.model.meshInstances.forEach(t=>t.material=e)}a.addChild(o)}),[{pos:[-7,1.5,0],name:"DoorLeft"},{pos:[7,1.5,0],name:"DoorRight"}].forEach(e=>{const t=i.create(e.name,{components:{model:{type:"box"},collision:{type:"box",halfExtents:[.1,1.5,1]},rigidbody:{type:"kinematic"}},position:e.pos,scale:[.2,3,2],tags:["door"]});if(t.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.5,.5,.5),e.metalness=.8,e.update(),t.model.meshInstances.forEach(t=>t.material=e)}o.addChild(t)}),[{pos:[-5.5,2.5,-4],rotation:[0,45,0],name:"SecurityCamera_0"},{pos:[0,2.8,4.5],rotation:[0,180,0],name:"SecurityCamera_1"},{pos:[5.5,2.5,-4],rotation:[0,-45,0],name:"SecurityCamera_2"}].forEach(e=>{const t=i.create(`${e.name}_Mount`,{components:{model:{type:"cylinder"},collision:{type:"cylinder",radius:.1,height:.3}},position:e.pos,scale:[.2,.3,.2],tags:["camera_mount"]});if(t.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.3,.3,.3),e.metalness=.9,e.update(),t.model.meshInstances.forEach(t=>t.material=e)}const a=i.create(e.name,{components:{model:{type:"box"},collision:{type:"box",halfExtents:[.15,.1,.2]}},position:[0,.2,0],rotation:e.rotation,scale:[.3,.2,.4],tags:["security_camera","interactive"]});if(a.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.2,.2,.2),e.metalness=.8,e.update(),a.model.meshInstances.forEach(t=>t.material=e)}const s=i.create(`${e.name}_Lens`,{components:{model:{type:"sphere"}},position:[0,0,.15],scale:[.3,.3,.3],tags:["camera_lens"]});if(s.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.1,.1,.1),e.emissive=new pc.Color(.2,.8,.2),e.emissiveIntensity=.3,e.update(),s.model.meshInstances.forEach(t=>t.material=e)}a.addChild(s),t.addChild(a),o.addChild(t)});const s=i.create("Flashlight",{components:{model:{type:"cylinder"},collision:{type:"cylinder",radius:.1,height:.3}},position:[1,1.2,-2.5],rotation:[0,0,90],scale:[.2,.3,.2],tags:["interactive","pickup","flashlight"]});if(s.model){const e=new pc.StandardMaterial;e.diffuse=new pc.Color(.8,.8,.2),e.update(),s.model.meshInstances.forEach(t=>t.material=e)}o.addChild(s);const n=i.createLight("spot",{color:new pc.Color(1,.9,.7),intensity:.5,range:5,innerConeAngle:30,outerConeAngle:45,position:[0,2,-2],rotation:[45,0,0]});o.addChild(n);const r=i.create("AmbientSound",{position:[0,0,0],tags:["audio","ambient"]});o.addChild(r);const l=i.create("SpawnPoint",{position:[0,0,3]});return o.addChild(l),o},objectives:[{id:"find_flashlight",name:"Find a Light Source",description:"The power is failing. Find the flashlight on the desk.",type:"simple",rewards:{items:[{id:"flashlight",quantity:1}],experience:50}},{id:"survive_night",name:"Survive Until Dawn",description:"Monitor the security cameras and keep the doors closed",type:"timer",timeLimit:60,rewards:{experience:300,items:[{id:"security_badge",quantity:1}]}},{id:"check_cameras",name:"Monitor Activity",description:"Check all three security cameras (use monitors or interact directly with cameras)",type:"counter",target:3,progress:0,rewards:{experience:75}}],state:{powerLevel:100,flashlightActive:!1,doorsLocked:{left:!0,right:!0},threatsActive:[],camerasChecked:new Set,nightProgress:0,nightCompleted:!1},onLoad(e,t){console.log("[NightshiftHorror] Horror mission started");const i=t.getSystem("objectivemanager");i&&(i.clearAllObjectives(),this.objectives.forEach(e=>{i.defineObjective(e.id,e)}),i.startObjective("find_flashlight")),this.setupInteractions(e,t),this.startPowerDrain(e,t),this.initializePersistentStats(e),e.fire("ui:notification",{text:"Night shift begins... Something feels wrong.",type:"warning",duration:4e3})},setupInteractions(e,t){this.entityInteractHandler=i=>{if("Flashlight"===i&&!this.state.flashlightActive){const i=e.root.findByName("Flashlight");if(i){i.enabled=!1,this.state.flashlightActive=!0;const o=t.getSystem("objectivemanager");o&&(o.completeObjective("find_flashlight"),o.startObjective("survive_night"),o.startObjective("check_cameras")),this.attachFlashlight(e),e.fire("ui:notification",{text:"Flashlight acquired. Use F to toggle.",type:"success"})}}if(i.includes("Monitor_")||i.includes("SecurityCamera_")){let o;if(console.log(`[NightshiftHorror] Interacting with ${i}`),(i.includes("Monitor_")||i.includes("SecurityCamera_"))&&(o=i.split("_")[1]),console.log(`[NightshiftHorror] Camera ID: ${o}, Already checked:`,this.state.camerasChecked.has(o)),this.state.camerasChecked.has(o)){const t=i.includes("Monitor_")?"Monitor":"Camera";e.fire("ui:notification",{text:`${t} ${parseInt(o)+1}: Already monitored`,type:"info",duration:1500})}else{this.state.camerasChecked.add(o);const i=t.getSystem("objectivemanager");i&&(i.updateObjective("check_cameras",this.state.camerasChecked.size),console.log(`[NightshiftHorror] Updated camera objective progress: ${this.state.camerasChecked.size}/3`));const a={0:"West Camera: Movement detected in west corridor...",1:"Center Camera: Static interference... something moved!",2:"East Camera: Shadow passed by the east entrance!"}[o]||`Camera ${parseInt(o)+1}: Feed active`,s=e.root.findByName(`SecurityCamera_${o}`);if(s){const e=s.findByName(`SecurityCamera_${o}_Lens`);e&&this.blinkCameraLens(e)}e.fire("ui:notification",{text:a,type:"warning",duration:3e3})}}},this.updateHandler=()=>{this.state.flashlightActive&&e.keyboard?.wasPressed(pc.KEY_F)&&this.toggleFlashlight(e)},this.doorToggleHandler=t=>{const i=e.root.findByName(t);if(i){const e=this.state.doorsLocked[t.toLowerCase().replace("door","")];e?i.translateLocal(0,3,0):i.translateLocal(0,-3,0),this.state.doorsLocked[t.toLowerCase().replace("door","")]=!e}},e.on("entity:interact",this.entityInteractHandler),e.on("update",this.updateHandler),e.on("door:toggle",this.doorToggleHandler)},attachFlashlight(e){const t=e.root.findByTag("player")[0];if(!t)return;const i=new pc.Entity("PlayerFlashlight");i.addComponent("light",{type:"spot",color:new pc.Color(1,.95,.8),intensity:2,range:15,innerConeAngle:20,outerConeAngle:30,castShadows:!0}),i.setLocalPosition(.3,1.5,.5),i.enabled=!1,t.addChild(i),this.playerFlashlight=i},blinkCameraLens(e){if(!e||!e.model)return;const t=e.model.meshInstances[0].material,i=new pc.StandardMaterial;i.diffuse=new pc.Color(.1,.1,.1),i.emissive=new pc.Color(.8,.2,.2),i.emissiveIntensity=1,i.update(),e.model.meshInstances.forEach(e=>e.material=i),setTimeout(()=>{e&&e.model&&e.model.meshInstances.forEach(e=>e.material=t)},300)},toggleFlashlight(e){this.playerFlashlight&&(this.playerFlashlight.enabled=!this.playerFlashlight.enabled,this.playerFlashlight.enabled&&(this.state.powerLevel-=2),e.fire("ui:notification",{text:"Flashlight: "+(this.playerFlashlight.enabled?"ON":"OFF"),type:"info",duration:1e3}))},initializePersistentStats(e){e.fire("ui:persistent",{id:"nightshift_power",text:`Power: ${this.state.powerLevel}%`,type:"warning",color:new pc.Color(1,.8,.2)}),e.fire("ui:persistent",{id:"nightshift_time",text:"Time: 12:00 AM",type:"info",color:new pc.Color(.7,.9,1)})},startPowerDrain(e,t){this.powerInterval=setInterval(()=>{this.state.powerLevel=Math.max(0,this.state.powerLevel-1),this.state.nightProgress+=1,Math.random()<.1&&this.triggerRandomEvent(e),this.state.nightProgress>=60&&this.completeNight(e,t),this.state.powerLevel<=0&&this.powerFailure(e),this.updatePersistentStats(e)},1e3)},updatePersistentStats(e){let t;t=this.state.powerLevel>50?new pc.Color(.2,.8,.2):this.state.powerLevel>25?new pc.Color(1,.8,.2):new pc.Color(.8,.2,.2),e.fire("ui:persistent",{id:"nightshift_power",text:`Power: ${this.state.powerLevel}%`,type:"warning",color:t});const i=Math.floor(this.state.nightProgress/10),o=0===i?"12:00 AM":`${i}:00 AM`;e.fire("ui:persistent",{id:"nightshift_time",text:`Time: ${o}`,type:"info",color:new pc.Color(.7,.9,1)})},triggerRandomEvent(e){const t=[()=>{e.fire("ui:notification",{text:"You hear footsteps outside...",type:"warning"})},()=>{e.fire("ui:notification",{text:"Something bangs on the left door!",type:"error"})},()=>{const t=e.root.findByName("Light");t&&(t.enabled=!1,setTimeout(()=>t.enabled=!0,200))}];(0,t[Math.floor(Math.random()*t.length)])()},powerFailure(e){e.root.findByTag("light").forEach(e=>{"PlayerFlashlight"!==e.name&&(e.enabled=!1)}),e.fire("ui:notification",{text:"POWER FAILURE! Emergency lighting only!",type:"error",duration:3e3})},completeNight(e,t){this.state.nightCompleted||(this.state.nightCompleted=!0,clearInterval(this.powerInterval),e.fire("ui:notification",{text:"6:00 AM - You survived the night shift!",type:"success",duration:5e3}),e.root.findByTag("light").forEach(e=>{e.enabled=!0}))},onUnload(e,t){console.log("[NightshiftHorror] Mission ended"),this.powerInterval&&(clearInterval(this.powerInterval),this.powerInterval=null),this.entityInteractHandler&&e.off("entity:interact",this.entityInteractHandler),this.updateHandler&&e.off("update",this.updateHandler),this.doorToggleHandler&&e.off("door:toggle",this.doorToggleHandler),e.fire("ui:persistent:remove",{id:"nightshift_power"}),e.fire("ui:persistent:remove",{id:"nightshift_time"}),this.state.nightCompleted=!1,this.state.flashlightActive=!1,this.state.nightProgress=0,this.state.powerLevel=100,this.state.camerasChecked.clear()}}}}]);