diff --git a/src/App.tsx b/src/App.tsx index 595ee53..e3b8ff5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -38,8 +38,8 @@ const App = () => { return (
- + {dispatchScene[currentScene as keyof typeof dispatchScene]} diff --git a/src/components/MainScene/Lain.tsx b/src/components/MainScene/Lain.tsx index 5b10cb6..f7c5830 100644 --- a/src/components/MainScene/Lain.tsx +++ b/src/components/MainScene/Lain.tsx @@ -82,8 +82,8 @@ export const LainIntro = () => ( export const LainStanding = () => ( ); @@ -100,18 +100,20 @@ export const LainMoveDown = () => ( export const LainMoveLeft = () => ( ); export const LainMoveRight = () => ( ); @@ -353,35 +355,39 @@ type LainProps = { const Lain = (props: LainProps) => { const lainMoveState = useLainStore((state) => state.lainMoveState); - const lainAnimationDispatch = { - standing: , - site_left: , - site_right: , - site_up: , - site_down: , - select_level_down: , - select_level_up: , - throw_node: , - pause_game: , - rip_node: , - prayer: , - scratch_head: , - spin: , - stretch: , - stretch_2: , - thinking: , - touch_sleeve: , - blush: , - hands_behind_head: , - hands_on_hips: , - hands_on_hips_2: , - hands_together: , - lean_forward: , - lean_left: , - lean_right: , - look_around: , - play_with_hair: , - }; + const lainAnimationDispatch = useMemo(() => { + const anims = { + standing: , + site_left: , + site_right: , + site_up: , + site_down: , + select_level_down: , + select_level_up: , + throw_node: , + pause_game: , + rip_node: , + prayer: , + scratch_head: , + spin: , + stretch: , + stretch_2: , + thinking: , + touch_sleeve: , + blush: , + hands_behind_head: , + hands_on_hips: , + hands_on_hips_2: , + hands_together: , + lean_forward: , + lean_left: , + lean_right: , + look_around: , + play_with_hair: , + }; + + return anims[lainMoveState as keyof typeof anims]; + }, [lainMoveState]); const [introFinished, setIntroFinished] = useState(false); @@ -398,13 +404,7 @@ const Lain = (props: LainProps) => { return ( - {stopIntroAnim ? ( - lainAnimationDispatch[ - lainMoveState as keyof typeof lainAnimationDispatch - ] - ) : ( - - )} + {stopIntroAnim ? lainAnimationDispatch : } ); diff --git a/src/components/MainScene/SyncedComponentLoader.tsx b/src/components/MainScene/SyncedComponentLoader.tsx index d2c90fb..0025db4 100644 --- a/src/components/MainScene/SyncedComponentLoader.tsx +++ b/src/components/MainScene/SyncedComponentLoader.tsx @@ -3,13 +3,10 @@ import HUD from "./SyncedComponents/HUD"; import GreenTextRenderer from "../TextRenderer/GreenTextRenderer"; import YellowTextRenderer from "../TextRenderer/YellowTextRenderer"; import YellowOrb from "./SyncedComponents/YellowOrb"; -import LevelSelection from "./SyncedComponents/LevelSelection"; import GrayPlanes from "./SyncedComponents/GrayPlanes"; import Starfield from "./SyncedComponents/Starfield"; import Site from "./SyncedComponents/Site"; import MiddleRing from "./SyncedComponents/MiddleRing"; -import { a } from "@react-spring/three"; -import NodeExplosion from "./SyncedComponents/Site/NodeAnimations/NodeExplosion"; type SyncedComponentLoaderProps = { paused: boolean; diff --git a/src/components/MainScene/SyncedComponents/HUD.tsx b/src/components/MainScene/SyncedComponents/HUD.tsx index e10297a..509b1a4 100644 --- a/src/components/MainScene/SyncedComponents/HUD.tsx +++ b/src/components/MainScene/SyncedComponents/HUD.tsx @@ -21,7 +21,7 @@ const HUD = () => { bigHUDPositionX: active, longHUDPositionX: active, boringHUDPositionX: active, - config: { duration: 500 }, + config: { duration: 400 }, }); const bigHUDPosX = hudElementState.bigHUDPositionX.to( diff --git a/src/components/TextRenderer/GreenTextRenderer.tsx b/src/components/TextRenderer/GreenTextRenderer.tsx index fcdb1ff..54196c3 100644 --- a/src/components/TextRenderer/GreenTextRenderer.tsx +++ b/src/components/TextRenderer/GreenTextRenderer.tsx @@ -12,7 +12,7 @@ const GreenTextRenderer = () => { const { greenTextPosXToggle } = useSpring({ greenTextPosXToggle: greenTextActive, - config: { duration: 500 }, + config: { duration: 400 }, }); const greenTextPosX = greenTextPosXToggle.to( diff --git a/src/core/StateManagers/EventManager.tsx b/src/core/StateManagers/EventManager.tsx index c2dd6ed..23abd57 100644 --- a/src/core/StateManagers/EventManager.tsx +++ b/src/core/StateManagers/EventManager.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useEffect, useRef, useState } from "react"; import SiteManager from "./MainSceneManagers/SiteManager"; import MiddleRingManager from "./MainSceneManagers/MiddleRingManager"; import LainManager from "./MainSceneManagers/LainManager"; @@ -36,6 +36,7 @@ import PauseComponentManager from "./MainSceneManagers/PauseComponentManager"; import MediaYellowTextManager from "./MediaYellowTextManager"; import GameSaver from "./GameSaver"; import GameLoader from "./GameLoader"; +import { useFrame } from "react-three-fiber"; const getKeyCodeAssociation = (keyCode: number): string => { const keyCodeAssocs = { @@ -137,6 +138,42 @@ const EventManager = () => { const [inputCooldown, setInputCooldown] = useState(false); + const timePassedSinceLastKeyPress = useRef(-1); + + useFrame(() => { + const now = Date.now(); + if ( + timePassedSinceLastKeyPress.current > -1 && + currentScene === "main" && + now > timePassedSinceLastKeyPress.current + 10000 && + mainSubscene !== "pause" + ) { + const moves = [ + "prayer", + "touch_sleeve", + "thinking", + "stretch_2", + "stretch", + "spin", + "scratch_head", + "blush", + "hands_behind_head", + "hands_on_hips", + "hands_on_hips_2", + "hands_together", + "lean_forward", + "lean_left", + "lean_right", + "look_around", + "play_with_hair", + ]; + + const event = moves[Math.floor(Math.random() * moves.length)]; + setEventState({ event: event }); + timePassedSinceLastKeyPress.current = now - 2500; + } + }); + const handleKeyPress = useCallback( (event) => { const { keyCode } = event; @@ -144,6 +181,7 @@ const EventManager = () => { const keyPress = getKeyCodeAssociation(keyCode); if (keyPress && !inputCooldown) { + timePassedSinceLastKeyPress.current = Date.now() + 2500; let event; switch (currentScene) { case "main": diff --git a/src/core/StateManagers/MainSceneManagers/MiddleRingManager.tsx b/src/core/StateManagers/MainSceneManagers/MiddleRingManager.tsx index 7e65664..951b945 100644 --- a/src/core/StateManagers/MainSceneManagers/MiddleRingManager.tsx +++ b/src/core/StateManagers/MainSceneManagers/MiddleRingManager.tsx @@ -228,7 +228,6 @@ const MiddleRingManager = (props: any) => { const dispatchedObject = dispatchObject(props.eventState); if (dispatchedObject) { - console.log(dispatchedObject); dispatchedObject.action.apply(null, dispatchedObject.value as any); } } diff --git a/src/store.ts b/src/store.ts index 50d1854..3e12f4c 100644 --- a/src/store.ts +++ b/src/store.ts @@ -609,3 +609,4 @@ export const useEndSceneStore = create((set) => ({ set((state) => ({ mediaPlayedCount: state.mediaPlayedCount + 1 })), resetMediaPlayedCount: () => set(() => ({ mediaPlayedCount: 0 })), })); +