Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
進行状況が存在するときに反映する
Browse files Browse the repository at this point in the history
  • Loading branch information
calmery committed Feb 26, 2021
1 parent 921c060 commit c5aa957
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
34 changes: 33 additions & 1 deletion src/components/Exhibition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ExhibitionMenu } from "~/components/Exhibition/Menu";
import { ExhibitionOkusuriLandNotifications } from "~/components/Exhibition/OkusuriLandNotifications";
import { useMultiplay } from "~/hooks/exhibition/useMultuplay";
import { useScreenOrientation } from "~/hooks/exhibition/useScreenOrientation";
import { GraphicsQuality } from "~/types/exhibition";
import { AreaName, GraphicsQuality } from "~/types/exhibition";
import * as GA from "~/utils/exhibition/google-analytics";
import * as state from "~/utils/exhibition/state";
import { useOkusuriLand } from "~/utils/okusuri.land";
Expand All @@ -29,6 +29,37 @@ export const Exhibition: React.FC = () => {
"high"
);
const [ready, setReady] = useState(false);
const [defaultArea, setDefaultArea] = useState<AreaName | null>(null);

useEffect(() => {
const { area, creamsoda, location } = state.get();
let isCreamsodaExists = false;
let isLocationExists = false;
let isAreaExists = false;

if (creamsoda === "flower" || creamsoda === "water") {
isCreamsodaExists = true;
setCreamsoda(creamsoda);
}

if (
location === "2d-morning" ||
location === "2d-night" ||
location === "3d"
) {
isLocationExists = true;
setLocation(location);
}

if (area === "cloud" || area === "meadow" || area === "sea") {
isAreaExists = true;
setDefaultArea(area);
}

if (isCreamsodaExists && isLocationExists && isAreaExists) {
setReady(true);
}
}, []);

// Events

Expand Down Expand Up @@ -112,6 +143,7 @@ export const Exhibition: React.FC = () => {
{location === "3d" && creamsoda && (
<Exhibition3d
creamsoda={creamsoda}
defaultArea={defaultArea}
examine={okusuriLand.examine}
multiplay={multiplay}
onComplete={handleComplete3d}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Exhibition/2d/Night.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ export const Exhibition2dNight: React.FC<{
}, [onComplete, selectedCreamSoda]);

useEffect(() => {
const { hasKey } = state.get();
setRestricted(!hasKey);

(async () => {
try {
await preload();
Expand Down
21 changes: 19 additions & 2 deletions src/components/Exhibition/3d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,21 @@ export const fadeOut = css`

export const Exhibition3d: React.FC<{
creamsoda: "flower" | "water";
defaultArea: AreaName | null;
examine: ReturnType<typeof useOkusuriLand>["examine"];
multiplay: ReturnType<typeof useMultiplay>;
onComplete: () => void;
settings: { graphicsQuality: GraphicsQuality };
}> = ({ creamsoda, examine, multiplay, onComplete, settings }) => {
const defaultArea = creamsoda === "flower" ? "meadow" : "sea";
}> = ({
creamsoda,
defaultArea: _defaultArea,
examine,
multiplay,
onComplete,
settings,
}) => {
const defaultArea =
_defaultArea || (creamsoda === "flower" ? "meadow" : "sea");

const [currentAreaName, setCurrentAreaName] = useState<AreaName>(defaultArea);
const [firstUpdate, setFirstUpdate] = useState(true);
Expand Down Expand Up @@ -97,6 +106,14 @@ export const Exhibition3d: React.FC<{
next: defaultArea,
});

useEffect(() => {
const { accessory } = state.get();

if (accessory === "fried_egg" || accessory === "pancake") {
setPlayerAccessory(accessory);
}
}, []);

useEffect(() => {
state.set({ area: currentAreaName });

Expand Down

0 comments on commit c5aa957

Please sign in to comment.