mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-10-08 22:00:17 +00:00
🐛 don't open text when quest is going
This commit is contained in:
parent
bed8bfa868
commit
9ffc0abbcf
1 changed files with 21 additions and 1 deletions
|
@ -1,6 +1,11 @@
|
|||
import { useDispatch, useSelector } from "react-redux";
|
||||
import styled, { keyframes } from "styled-components";
|
||||
import { selectDirection, selectPos, selectMap } from "../state/gameSlice";
|
||||
import {
|
||||
selectDirection,
|
||||
selectPos,
|
||||
selectMap,
|
||||
selectMapId,
|
||||
} from "../state/gameSlice";
|
||||
import { useEffect, useState } from "react";
|
||||
import useEvent from "../app/use-event";
|
||||
import emitter, { Event } from "../app/emitter";
|
||||
|
@ -11,6 +16,7 @@ import {
|
|||
showText,
|
||||
} from "../state/uiSlice";
|
||||
import { Direction } from "../state/state-types";
|
||||
import { useActiveMapQuests } from "../app/use-quests";
|
||||
|
||||
interface TextProps {
|
||||
$done: boolean;
|
||||
|
@ -97,6 +103,8 @@ const Text = () => {
|
|||
const map = useSelector(selectMap);
|
||||
const startMenuOpen = useSelector(selectStartMenu);
|
||||
const text = useSelector(selectText);
|
||||
const mapId = useSelector(selectMapId);
|
||||
const quests = useActiveMapQuests(mapId);
|
||||
|
||||
useEffect(() => {
|
||||
setLiveIndex(0);
|
||||
|
@ -140,6 +148,18 @@ const Text = () => {
|
|||
break;
|
||||
}
|
||||
|
||||
// If there is a quest at this position, don't open text
|
||||
if (quests.length > 0) {
|
||||
const isQuest = quests.some((quest) => {
|
||||
if (quest.trigger !== "talk") return false;
|
||||
const yPos = quest.positions[y];
|
||||
if (!yPos) return false;
|
||||
if (!yPos.includes(x)) return false;
|
||||
return true;
|
||||
});
|
||||
if (isQuest) return;
|
||||
}
|
||||
|
||||
// Open new textbox
|
||||
if (map.text[y] && map.text[y][x] && map.text[y][x].length > 0) {
|
||||
emitter.emit(Event.StopMoving);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue