Skip to content

Commit

Permalink
Add Wait event to hold still while area ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
tiliv committed May 30, 2024
1 parent 732b14f commit f1d4ea0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default function App({
title: startWorld.replace(/\.txt$/, '').toUpperCase(),
items: [
battle && {name: 'Sheathe', event: 'Sheathe'},
{name: 'Wait', event: 'Wait'},
{name: 'Shout', event: 'Ambient'},
{name: 'Hide', event: 'Ambient'},
].filter(Boolean),
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/useLocation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ export default function useLocation({
setAreaTick((tick) => tick + 1);
tickArea();
}, [localX, localY, posX, posY]);

// Respond to 'Wait' event
useEffect(() => {
const waitHandler = () => {
setAreaTick((tick) => tick + 1);
tickArea();
};
window.addEventListener('Wait', waitHandler);
return () => window.removeEventListener('Wait', waitHandler);
}, [tickArea]);

return {
layers: {
solid,
Expand Down

0 comments on commit f1d4ea0

Please sign in to comment.