Commit d6508a0c authored by timel's avatar timel

feat: valtio logic in fixedslot/singleslot

parent b4062341
Pipeline #21375 passed with stages
in 13 minutes and 21 seconds
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
clearAllIdleInteractivities, clearAllIdleInteractivities,
type CardState, type CardState,
clearAllPlaceInteradtivities, clearAllPlaceInteradtivities,
messageStore,
} from "@/valtioStores"; } from "@/valtioStores";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
...@@ -57,7 +58,7 @@ export const FixedSlot = (props: { ...@@ -57,7 +58,7 @@ export const FixedSlot = (props: {
: props.rotation; : props.rotation;
const edgesWidth = 2.0; const edgesWidth = 2.0;
const edgesColor = BABYLON.Color4.FromColor3(BABYLON.Color3.Yellow()); const edgesColor = BABYLON.Color4.FromColor3(BABYLON.Color3.Yellow());
const dispatch = store.dispatch; // const dispatch = store.dispatch;
const faceDown = const faceDown =
snapState.location.position === ygopro.CardPosition.FACEDOWN_DEFENSE || snapState.location.position === ygopro.CardPosition.FACEDOWN_DEFENSE ||
...@@ -77,36 +78,50 @@ export const FixedSlot = (props: { ...@@ -77,36 +78,50 @@ export const FixedSlot = (props: {
clearAllPlaceInteradtivities(1); clearAllPlaceInteradtivities(1);
} else if (snapState.occupant) { } else if (snapState.occupant) {
// 中央弹窗展示选中卡牌信息 // 中央弹窗展示选中卡牌信息
dispatch(setCardModalMeta(snapState.occupant)); // dispatch(setCardModalMeta(snapState.occupant));
dispatch( messageStore.cardModal.meta = snapState.occupant;
setCardModalInteractivies( // dispatch(
snapState.idleInteractivities.map((interactivity) => { // setCardModalInteractivies(
return { // snapState.idleInteractivities.map((interactivity) => {
desc: interactTypeToString(interactivity.interactType), // return {
response: interactivity.response, // desc: interactTypeToString(interactivity.interactType),
}; // response: interactivity.response,
}) // };
) // })
); // )
dispatch(setCardModalCounters(snapState.counters)); // );
dispatch(setCardModalIsOpen(true)); messageStore.cardModal.interactivies =
snapState.idleInteractivities.map((interactivity) => ({
desc: interactTypeToString(interactivity.interactType),
response: interactivity.response,
}));
// dispatch(setCardModalCounters(snapState.counters));
messageStore.cardModal.counters = snapState.counters;
// dispatch(setCardModalIsOpen(true));
messageStore.cardModal.isOpen = true;
// 侧边栏展示超量素材信息 // 侧边栏展示超量素材信息
if ( if (
snapState.overlay_materials && snapState.overlay_materials &&
snapState.overlay_materials.length > 0 snapState.overlay_materials.length > 0
) { ) {
dispatch( // dispatch(
setCardListModalInfo( // setCardListModalInfo(
snapState.overlay_materials?.map((overlay) => { // snapState.overlay_materials?.map((overlay) => {
return { // return {
meta: overlay, // meta: overlay,
interactivies: [], // interactivies: [],
}; // };
}) || [] // }) || []
) // )
); // );
dispatch(setCardListModalIsOpen(true)); messageStore.cardListModal.list =
snapState.overlay_materials?.map((overlay) => ({
meta: overlay,
interactivies: [],
})) || [];
// dispatch(setCardListModalIsOpen(true));
messageStore.cardListModal.isOpen = true;
} }
} }
}, },
......
...@@ -13,6 +13,8 @@ import { store } from "@/store"; ...@@ -13,6 +13,8 @@ import { store } from "@/store";
import { interactTypeToString } from "../utils"; import { interactTypeToString } from "../utils";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { messageStore } from "@/valtioStores";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
const transform = NeosConfig.ui.card.transform; const transform = NeosConfig.ui.card.transform;
export const Depth = 0.005; export const Depth = 0.005;
...@@ -24,7 +26,7 @@ export const SingleSlot = (props: { ...@@ -24,7 +26,7 @@ export const SingleSlot = (props: {
}) => { }) => {
const snapState = useSnapshot(props.state); const snapState = useSnapshot(props.state);
const boxRef = useRef(null); const boxRef = useRef(null);
const dispatch = store.dispatch; // const dispatch = store.dispatch;
const edgeRender = const edgeRender =
snapState.find((item) => snapState.find((item) =>
item === undefined ? false : item.idleInteractivities.length > 0 item === undefined ? false : item.idleInteractivities.length > 0
...@@ -35,26 +37,38 @@ export const SingleSlot = (props: { ...@@ -35,26 +37,38 @@ export const SingleSlot = (props: {
useClick( useClick(
(_event) => { (_event) => {
if (snapState.length != 0) { if (snapState.length != 0) {
dispatch( // dispatch(
setCardListModalInfo( // setCardListModalInfo(
snapState // snapState
.filter( // .filter(
(item) => item.occupant !== undefined && item.occupant.id !== 0 // (item) => item.occupant !== undefined && item.occupant.id !== 0
) // )
.map((item) => { // .map((item) => {
return { // return {
meta: item.occupant, // meta: item.occupant,
interactivies: item.idleInteractivities.map((interactivy) => { // interactivies: item.idleInteractivities.map((interactivy) => {
return { // return {
desc: interactTypeToString(interactivy.interactType), // desc: interactTypeToString(interactivy.interactType),
response: interactivy.response, // response: interactivy.response,
}; // };
}), // }),
}; // };
}) // })
// )
// );
messageStore.cardListModal.list = snapState
.filter(
(item) => item.occupant !== undefined && item.occupant.id !== 0
) )
); .map((item) => ({
dispatch(setCardListModalIsOpen(true)); meta: item.occupant,
interactivies: item.idleInteractivities.map((interactivy) => ({
desc: interactTypeToString(interactivy.interactType),
response: interactivy.response,
})),
}));
// dispatch(setCardListModalIsOpen(true));
messageStore.cardListModal.isOpen = true;
} }
}, },
boxRef, boxRef,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment