<!-- SOLID-PLAYTIME · part 164 -->
epthWrite:!1})),this.heroTrail.frustumCulled=!1,this.scene.add(this.heroTrail)}prepareTrials(){le.forEach((t,e)=>{let n=new he;n.visible=!1;let i=this.mesh(n,new fn(34,38,2,this.mobile?20:32),this.mat(591635,t.color),0,-1,0);i.rotation.y=e*0.21,i.receiveShadow=!0;for(let c=0;c<3;c+=1){let u=this.mesh(n,new cn(11+c*8,0.16,5,this.mobile?36:64),this.glow(c%2?65535:t.color,0.55),0,0.15+c*0.05,0);u.rotation.x=Math.PI/2}let s=[],a=2+Math.min(e,3);for(let c=0;c<a;c+=1){let u=this.buildFigure(t.color,0.78+e*0.025),f=c/a*Math.PI*2;u.position.set(Math.sin(f)*17,0,Math.cos(f)*17),n.add(u),s.push({group:u,alive:!0,hp:1+Math.floor(e/3),phase:c,angle:f,speed:2.2+e*0.12})}let r=this.buildFigure(t.color,e===le.length-1?1.75:1.35);r.position.set(0,0,-8),n.add(r);let o=e===le.length-1?12:4+Math.floor(e/2),l={group:r,alive:!0,hp:o,phase:0,angle:0,speed:1.6+e*0.08};this.trial.add(n),this.trialArenas.push({group:n,enemies:s,boss:l})})}resize(){let t=Math.max(1,this.mount.clientWidth),e=Math.max(1,this.mount.clientHeight);this.renderer.setSize(t,e,!1),this.camera.aspect=t/e,this.camera.updateProjectionMatrix()}setMovement(t,e){this.moveX=t,this.moveY=e}setActive(t){if(this.gameplayActive=t,!t)this.setMovement(0,0),this.setRun(!1),this.setVision(!1)}setRun(t){this.runHeld=t}setVision(t){this.vision=t&&this.radiance>0.03,this.visionGroup.visible=this.vision}orbit(t,e){this.yaw-=t*0.006*this.progress.settings.sensitivity,this.camera.position.y+=e*0.002}jump(){if((this.grounded||this.coyote>0)&&this.jumpAnticipation<=0)this.jumpQueued=!0,this.hasJumped=!0,this.jumpAnticipation=0.09}attack(){if(this.attackClock>0)return;if(this.nearby&&this.trialIndex===null){this.interact();return}if(this.trialIndex===null)return;if(this.attackClock=0.34,this.sword)this.sword.rotation.x=-1.15;let t=!1;for(let n of this.enemies){if(!n.alive)continue;if(n.group.position.distanceTo(this.hero.position)<9){if(n.hp-=this.radiance>=0.98?3:1,t=!0,n.hp<=0)n.alive=!1,n.group.visible=!1,this.radiance=Math.min(1,this.radiance+0.22),this.burst(n.group.position.x,n.group.position.y+2,n.group.position.z,16711935)}}let e=this.enemies.some((n)=>n.alive);if(!e&&this.boss?.alive){if(this.boss.group.position.distanceTo(this.hero.position)<12||this.radiance>=0.98){let i=this.radiance>=0.98;if(this.boss.hp-=i?3:1,this.bossHits+=i?3:1,this.radiance=i?0.16:Math.min(1,this.radiance+0.08),t=!0,this.onEvent({type:"message",text:i?"DAWNBEAM":"THE BLADE ANSWERS"}),this.burst(this.boss.group.position.x,this.boss.group.position.y+3,this.boss.group.position.z,16765514),this.trialIndex===le.length-1)this.updateEmperorPhase();if(this.boss.hp<=0)this.completeTrial()}}if(!t)this.onEvent({type:"message",text:e?"BREAK THE SENTINELS":"THE BLADE FINDS ONLY AIR"})}interact(){if(!this.nearby||this.trialIndex!==null)return;if(this.nearby.kind==="haven"){this.health=1,this.radiance=1,this.onEvent({type:"message",text:"THE FAR SHORE RESTORES THE LIGHT"});return}if(this.nearby.kind==="castle"){if(this.progress.cleared<le.length)this.onEvent({type:"message",text:"THE ROAD HOME IS NOT YET OPEN"});else this.onEvent({type:"home"});return}if(this.nearby.index!==this.progress.cleared){this.onEvent({type:"message",text:this.nearby.index<this.progress.cleared?"THIS NIGHTMARE IS DREAMED":"THIS THRESHOLD IS SEALED"});return}this.startTrial(this.nearby.index)}startTrial(t){let e=le[t],n=this.trialArenas[t];if(!e||!n)return;this.trialIndex=t,this.trialArenas.forEach((i)=>{i.group.visible=!1}),n.group.visible=!0,this.enemies=n.enemies,this.boss=n.boss,this.bossHits=0,this.world.visible=!1,this.visionGroup.visible=!1,this.trial.visible=!0,this.x=0,this.z=24,this.y=0.15,this.hero.position.set(this.x,this.y,this.z),this.scene.remove(this.hero),this.trial.add(this.hero),this.onEvent({type:"message",text:`${e.name} • ${e.boss}`}),this.emitHud(!0)}updateEmperorPhase(){if(!this.boss)return;let t=this.bossHits<4?0:this.bossHits<8?1:2;if(t!==this.boss.phase)this.boss.phase=t,this.boss.group.scale.setScalar(1.75+t*0.24),this.onEvent({type:"message",text:["THE CROWN DESCENDS","THE VOID ANSWERS","THE LAST LIGHT"][t]??"THE LAST LIGHT"})}completeTrial(){let t=this.trialIndex,e=t===null?null:le[t];if(t===null||!e)return;if(this.progress.cleared=Math.max(this.progress.cleared,t+1),!this.progress.chest.includes(e.reward))this.progress.chest.push(e.reward);this.trialIndex=null,this.trial.visible=!1,this.world.visible=!0,this.scene.remove(this.hero),this.world.add(this.hero),this.x=e.x,this.z=e.z+22,this.y=this.ground(this.x,this.z)+0.15;let n=this.progress.cleared===le.length;if(n){if(this.progress.chest.push("GOLDEN ROAD"),this.goldenRoad)this.goldenRoad.visible=!0}this.syncProgress(),this.onEvent({type:"ceremony",title:n?"THE LIGHT REMAINS":"NIGHTMARE DREAMED",text:n?"The Emperor is dreamed. White-gold lightning walks the highlands. The golden road has remembered its King.":`${e.line} ${le[t+1]?.name??"THE ROAD"} is now unsealed.`})}fastTravel(t,e){if(this.trialIndex!==null)return;this.