Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
67d5bd0d
Commit
67d5bd0d
authored
Apr 25, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: valtio store logic 100%, ui/mat
parent
0ee5f4d1
Pipeline
#21363
passed with stages
in 15 minutes and 54 seconds
Changes
15
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
198 additions
and
86 deletions
+198
-86
src/env.d.ts
src/env.d.ts
+7
-0
src/ui/Duel/Message/CardListModal.tsx
src/ui/Duel/Message/CardListModal.tsx
+1
-1
src/ui/Duel/PlayMat/BanishedZone.tsx
src/ui/Duel/PlayMat/BanishedZone.tsx
+11
-4
src/ui/Duel/PlayMat/Deck.tsx
src/ui/Duel/PlayMat/Deck.tsx
+11
-4
src/ui/Duel/PlayMat/ExtraDeck.tsx
src/ui/Duel/PlayMat/ExtraDeck.tsx
+9
-4
src/ui/Duel/PlayMat/Field.tsx
src/ui/Duel/PlayMat/Field.tsx
+23
-10
src/ui/Duel/PlayMat/FixedSlot.tsx
src/ui/Duel/PlayMat/FixedSlot.tsx
+33
-25
src/ui/Duel/PlayMat/Graveyard.tsx
src/ui/Duel/PlayMat/Graveyard.tsx
+10
-4
src/ui/Duel/PlayMat/Hands.tsx
src/ui/Duel/PlayMat/Hands.tsx
+18
-4
src/ui/Duel/PlayMat/Magics.tsx
src/ui/Duel/PlayMat/Magics.tsx
+18
-7
src/ui/Duel/PlayMat/Monsters.tsx
src/ui/Duel/PlayMat/Monsters.tsx
+25
-13
src/ui/Duel/PlayMat/SingleSlot.tsx
src/ui/Duel/PlayMat/SingleSlot.tsx
+8
-10
src/valtioStores/matStore/types.ts
src/valtioStores/matStore/types.ts
+2
-0
src/valtioStores/messageStore/methods/clearAllPlaceInteradtivities.ts
...ores/messageStore/methods/clearAllPlaceInteradtivities.ts
+21
-0
src/valtioStores/messageStore/methods/index.ts
src/valtioStores/messageStore/methods/index.ts
+1
-0
No files found.
src/env.d.ts
View file @
67d5bd0d
...
...
@@ -10,3 +10,10 @@ interface ImportMetaEnv {
interface
ImportMeta
{
readonly
env
:
ImportMetaEnv
;
}
// 重新声明useSnapshot,暂时先这么写。原版的会把所有的改成readonly,引发一些棘手的类型报错。
import
"
valtio/react
"
;
declare
module
"
valtio/react
"
{
export
declare
function
useSnapshot
<
T
extends
object
>
(
proxyObject
:
T
):
T
;
export
{};
}
src/ui/Duel/Message/CardListModal.tsx
View file @
67d5bd0d
...
...
@@ -16,6 +16,7 @@ import { store } from "@/store";
import
{
messageStore
,
matStore
,
clearAllIdleInteractivities
as
FIXME_clearAllIdleInteractivities
,
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
...
...
@@ -44,7 +45,6 @@ export const CardListModal = () => {
<
Drawer
open=
{
isOpen
}
onClose=
{
handleOkOrCancel
}
>
<
List
itemLayout=
"horizontal"
// @ts-ignore 报错是因为类型不可变,实际上是没问题的
dataSource=
{
list
}
renderItem=
{
(
item
)
=>
(
<
List
.
Item
...
...
src/ui/Duel/PlayMat/BanishedZone.tsx
View file @
67d5bd0d
...
...
@@ -10,20 +10,27 @@ import {
import
{
cardSlotRotation
}
from
"
../utils
"
;
import
{
Depth
,
SingleSlot
}
from
"
./SingleSlot
"
;
import
{
matStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
const
NeosConfig
=
useConfig
();
export
const
BanishedZone
=
()
=>
{
const
meBanishedZone
=
useAppSelector
(
selectMeBanishedZone
).
inner
;
const
opBanishedZone
=
useAppSelector
(
selectOpBanishedZone
).
inner
;
// const meBanishedZone = useAppSelector(selectMeBanishedZone).inner;
// const opBanishedZone = useAppSelector(selectOpBanishedZone).inner;
const
meBanishedZone
=
useSnapshot
(
matStore
.
banishedZones
.
me
);
const
opBanishedZone
=
useSnapshot
(
matStore
.
banishedZones
.
op
);
return
(
<>
<
SingleSlot
state=
{
meBanishedZone
}
// 因为singleSlot里面会有snap,所以这儿可以直接传入store
state=
{
matStore
.
banishedZones
.
me
}
position=
{
banishedZonePosition
(
0
,
meBanishedZone
.
length
)
}
rotation=
{
cardSlotRotation
(
false
)
}
/>
<
SingleSlot
state=
{
opBanishedZone
}
state=
{
matStore
.
banishedZones
.
op
}
position=
{
banishedZonePosition
(
1
,
opBanishedZone
.
length
)
}
rotation=
{
cardSlotRotation
(
true
)
}
/>
...
...
src/ui/Duel/PlayMat/Deck.tsx
View file @
67d5bd0d
...
...
@@ -8,19 +8,26 @@ import { cardSlotRotation } from "../utils";
import
{
Depth
,
SingleSlot
}
from
"
./SingleSlot
"
;
const
NeosConfig
=
useConfig
();
import
{
matStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
export
const
CommonDeck
=
()
=>
{
const
meDeck
=
useAppSelector
(
selectMeDeck
).
inner
;
const
opDeck
=
useAppSelector
(
selectOpDeck
).
inner
;
// const meDeck = useAppSelector(selectMeDeck).inner;
// const opDeck = useAppSelector(selectOpDeck).inner;
const
meDeck
=
useSnapshot
(
matStore
.
decks
.
me
);
const
opDeck
=
useSnapshot
(
matStore
.
decks
.
op
);
return
(
<>
<
SingleSlot
state=
{
m
eDeck
}
state=
{
m
atStore
.
decks
.
me
}
position=
{
deckPosition
(
0
,
meDeck
.
length
)
}
rotation=
{
cardSlotRotation
(
false
)
}
/>
<
SingleSlot
state=
{
opDeck
}
state=
{
matStore
.
decks
.
op
}
position=
{
deckPosition
(
1
,
opDeck
.
length
)
}
rotation=
{
cardSlotRotation
(
true
)
}
/>
...
...
src/ui/Duel/PlayMat/ExtraDeck.tsx
View file @
67d5bd0d
...
...
@@ -12,19 +12,24 @@ import { Depth, SingleSlot } from "./SingleSlot";
const
NeosConfig
=
useConfig
();
import
{
matStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
export
const
ExtraDeck
=
()
=>
{
const
meExtraDeck
=
useAppSelector
(
selectMeExtraDeck
).
inner
;
const
opExtraDeck
=
useAppSelector
(
selectOpExtraDeck
).
inner
;
// const meExtraDeck = useAppSelector(selectMeExtraDeck).inner;
// const opExtraDeck = useAppSelector(selectOpExtraDeck).inner;
const
meExtraDeck
=
useSnapshot
(
matStore
.
extraDecks
.
me
);
const
opExtraDeck
=
useSnapshot
(
matStore
.
extraDecks
.
op
);
return
(
<>
<
SingleSlot
state=
{
m
eExtraDeck
}
state=
{
m
atStore
.
extraDecks
.
me
}
position=
{
extraDeckPosition
(
0
,
meExtraDeck
.
length
)
}
rotation=
{
cardSlotRotation
(
false
)
}
/>
<
SingleSlot
state=
{
opExtraDeck
}
state=
{
matStore
.
extraDecks
.
op
}
position=
{
extraDeckPosition
(
1
,
opExtraDeck
.
length
)
}
rotation=
{
cardSlotRotation
(
true
)
}
/>
...
...
src/ui/Duel/PlayMat/Field.tsx
View file @
67d5bd0d
...
...
@@ -10,34 +10,47 @@ import { FixedSlot } from "./FixedSlot";
import
{
Depth
}
from
"
./SingleSlot
"
;
const
NeosConfig
=
useConfig
();
import
{
matStore
,
clearAllPlaceInteradtivities
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
export
const
Field
=
()
=>
{
const
meField
=
useAppSelector
(
selectMeMagics
).
inner
.
find
(
(
_
,
sequence
)
=>
sequence
==
5
);
const
opField
=
useAppSelector
(
selectOpMagics
).
inner
.
find
(
(
_
,
sequence
)
=>
sequence
==
5
);
// const meField = useAppSelector(selectMeMagics).inner.find(
// (_, sequence) => sequence == 5
// );
// const opField = useAppSelector(selectOpMagics).inner.find(
// (_, sequence) => sequence == 5
// );
// 这儿的find可能是出于某种考虑,以后再深思
const
meField
=
useSnapshot
(
matStore
.
magics
.
me
[
5
]);
const
opField
=
useSnapshot
(
matStore
.
magics
.
op
[
5
]);
const
clearPlaceInteractivitiesAction
=
(
controller
:
number
)
=>
matStore
.
magics
.
of
(
controller
).
clearPlaceInteractivity
();
return
(
<>
{
meField
?
(
<
FixedSlot
state=
{
meField
}
s
napS
tate=
{
meField
}
sequence=
{
0
}
position=
{
fieldPosition
(
0
)
}
rotation=
{
cardSlotRotation
(
false
)
}
clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
)
:
(
<></>
)
}
{
opField
?
(
<
FixedSlot
state=
{
opField
}
s
napS
tate=
{
opField
}
sequence=
{
0
}
position=
{
fieldPosition
(
1
)
}
rotation=
{
cardSlotRotation
(
true
)
}
clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
)
:
(
<></>
...
...
src/ui/Duel/PlayMat/FixedSlot.tsx
View file @
67d5bd0d
...
...
@@ -18,6 +18,9 @@ import {
import
{
store
}
from
"
@/store
"
;
import
{
interactTypeToString
}
from
"
../utils
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
clearAllIdleInteractivities
}
from
"
@/valtioStores
"
;
const
NeosConfig
=
useConfig
();
...
...
@@ -30,19 +33,22 @@ const cardDefenceRotation = new BABYLON.Vector3(
);
export
const
FixedSlot
=
(
props
:
{
state
:
CardState
;
s
napS
tate
:
CardState
;
sequence
:
number
;
position
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
deffenseRotation
?:
BABYLON
.
Vector3
;
clearPlaceInteractivitiesAction
:
ActionCreatorWithPayload
<
number
,
string
>
;
// clearPlaceInteractivitiesAction: ActionCreatorWithPayload<number, string>;
clearPlaceInteractivitiesAction
:
(
controller
:
number
)
=>
void
;
})
=>
{
const
planeRef
=
useRef
(
null
);
// const snapState = useSnapshot(props.state);
const
snapState
=
props
.
snapState
;
const
rotation
=
props
.
s
tate
.
location
.
position
===
ygopro
.
CardPosition
.
DEFENSE
||
props
.
s
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEUP_DEFENSE
||
props
.
s
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
snapS
tate
.
location
.
position
===
ygopro
.
CardPosition
.
DEFENSE
||
snapS
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEUP_DEFENSE
||
snapS
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
?
props
.
deffenseRotation
||
cardDefenceRotation
:
props
.
rotation
;
const
edgesWidth
=
2.0
;
...
...
@@ -50,22 +56,24 @@ export const FixedSlot = (props: {
const
dispatch
=
store
.
dispatch
;
const
faceDown
=
props
.
s
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
||
props
.
s
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
||
props
.
s
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN
;
snapS
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_DEFENSE
||
snapS
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN_ATTACK
||
snapS
tate
.
location
.
position
===
ygopro
.
CardPosition
.
FACEDOWN
;
useClick
(
(
_event
)
=>
{
if
(
props
.
state
.
placeInteractivities
)
{
sendSelectPlaceResponse
(
props
.
state
.
placeInteractivities
.
response
);
dispatch
(
props
.
clearPlaceInteractivitiesAction
(
0
));
dispatch
(
props
.
clearPlaceInteractivitiesAction
(
1
));
}
else
if
(
props
.
state
.
occupant
)
{
if
(
snapState
.
placeInteractivities
)
{
sendSelectPlaceResponse
(
snapState
.
placeInteractivities
.
response
);
// dispatch(props.clearPlaceInteractivitiesAction(0));
// dispatch(props.clearPlaceInteractivitiesAction(1));
clearAllIdleInteractivities
(
0
);
clearAllIdleInteractivities
(
1
);
}
else
if
(
snapState
.
occupant
)
{
// 中央弹窗展示选中卡牌信息
dispatch
(
setCardModalMeta
(
props
.
s
tate
.
occupant
));
dispatch
(
setCardModalMeta
(
snapS
tate
.
occupant
));
dispatch
(
setCardModalInteractivies
(
props
.
s
tate
.
idleInteractivities
.
map
((
interactivity
)
=>
{
snapS
tate
.
idleInteractivities
.
map
((
interactivity
)
=>
{
return
{
desc
:
interactTypeToString
(
interactivity
.
interactType
),
response
:
interactivity
.
response
,
...
...
@@ -73,17 +81,17 @@ export const FixedSlot = (props: {
})
)
);
dispatch
(
setCardModalCounters
(
props
.
s
tate
.
counters
));
dispatch
(
setCardModalCounters
(
snapS
tate
.
counters
));
dispatch
(
setCardModalIsOpen
(
true
));
// 侧边栏展示超量素材信息
if
(
props
.
s
tate
.
overlay_materials
&&
props
.
s
tate
.
overlay_materials
.
length
>
0
snapS
tate
.
overlay_materials
&&
snapS
tate
.
overlay_materials
.
length
>
0
)
{
dispatch
(
setCardListModalInfo
(
props
.
s
tate
.
overlay_materials
?.
map
((
overlay
)
=>
{
snapS
tate
.
overlay_materials
?.
map
((
overlay
)
=>
{
return
{
meta
:
overlay
,
interactivies
:
[],
...
...
@@ -96,7 +104,7 @@ export const FixedSlot = (props: {
}
},
planeRef
,
[
props
.
s
tate
]
[
snapS
tate
]
);
return
(
...
...
@@ -109,8 +117,8 @@ export const FixedSlot = (props: {
rotation=
{
rotation
}
enableEdgesRendering
edgesWidth=
{
props
.
s
tate
.
placeInteractivities
||
props
.
s
tate
.
idleInteractivities
.
length
>
0
snapS
tate
.
placeInteractivities
||
snapS
tate
.
idleInteractivities
.
length
>
0
?
edgesWidth
:
0
}
...
...
@@ -119,15 +127,15 @@ export const FixedSlot = (props: {
<
standardMaterial
name=
{
`fixedslot-mat-${props.sequence}`
}
diffuseTexture=
{
props
.
s
tate
.
occupant
snapS
tate
.
occupant
?
faceDown
?
new
BABYLON
.
Texture
(
`${NeosConfig.assetsPath}/card_back.jpg`
)
:
new
BABYLON
.
Texture
(
`${NeosConfig.cardImgUrl}/${
props.s
tate.occupant.id}.jpg`
`${NeosConfig.cardImgUrl}/${
snapS
tate.occupant.id}.jpg`
)
:
new
BABYLON
.
Texture
(
`${NeosConfig.assetsPath}/card_slot.png`
)
}
alpha=
{
props
.
s
tate
.
occupant
?
1
:
0
}
alpha=
{
snapS
tate
.
occupant
?
1
:
0
}
></
standardMaterial
>
</
plane
>
);
...
...
src/ui/Duel/PlayMat/Graveyard.tsx
View file @
67d5bd0d
...
...
@@ -10,20 +10,26 @@ import {
import
{
cardSlotRotation
}
from
"
../utils
"
;
import
{
Depth
,
SingleSlot
}
from
"
./SingleSlot
"
;
import
{
matStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
const
NeosConfig
=
useConfig
();
export
const
Graveyard
=
()
=>
{
const
meGraveyard
=
useAppSelector
(
selectMeGraveyard
).
inner
;
const
opGraveyard
=
useAppSelector
(
selectOpGraveyard
).
inner
;
// const meGraveyard = useAppSelector(selectMeGraveyard).inner;
// const opGraveyard = useAppSelector(selectOpGraveyard).inner;
const
meGraveyard
=
useSnapshot
(
matStore
.
graveyards
.
me
);
const
opGraveyard
=
useSnapshot
(
matStore
.
graveyards
.
op
);
return
(
<>
<
SingleSlot
state=
{
m
eGraveyard
}
state=
{
m
atStore
.
graveyards
.
me
}
position=
{
graveyardPosition
(
0
,
meGraveyard
.
length
)
}
rotation=
{
cardSlotRotation
(
false
)
}
/>
<
SingleSlot
state=
{
opGraveyard
}
state=
{
matStore
.
graveyards
.
op
}
position=
{
graveyardPosition
(
1
,
opGraveyard
.
length
)
}
rotation=
{
cardSlotRotation
(
true
)
}
/>
...
...
src/ui/Duel/PlayMat/Hands.tsx
View file @
67d5bd0d
...
...
@@ -4,7 +4,7 @@ import { useHover } from "react-babylonjs";
import
{
useConfig
}
from
"
@/config
"
;
import
{
useAppSelector
,
useClick
}
from
"
@/hook
"
;
import
{
CardState
}
from
"
@/reducers/duel/generic
"
;
//
import { CardState } from "@/reducers/duel/generic";
import
{
selectMeHands
,
selectOpHands
}
from
"
@/reducers/duel/handsSlice
"
;
import
{
setCardModalInteractivies
,
...
...
@@ -12,6 +12,8 @@ import {
setCardModalMeta
,
}
from
"
@/reducers/duel/mod
"
;
import
{
store
}
from
"
@/store
"
;
import
{
matStore
,
type
CardState
,
messageStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
animated
,
useSpring
}
from
"
../spring
"
;
import
{
interactTypeToString
,
zip
}
from
"
../utils
"
;
...
...
@@ -26,9 +28,12 @@ const handRotation = new BABYLON.Vector3(rotation.x, rotation.y, rotation.z);
const
hoverScaling
=
NeosConfig
.
ui
.
card
.
handHoverScaling
;
export
const
Hands
=
()
=>
{
const
meHands
=
useAppSelector
(
selectMeHands
).
inner
;
const
meHands
=
useSnapshot
(
matStore
.
hands
.
me
);
const
opHands
=
useSnapshot
(
matStore
.
hands
.
op
);
// const meHands = useAppSelector(selectMeHands).inner;
// const opHands = useAppSelector(selectOpHands).inner;
const
meHandPositions
=
handPositons
(
0
,
meHands
);
const
opHands
=
useAppSelector
(
selectOpHands
).
inner
;
const
opHandPositions
=
handPositons
(
1
,
opHands
);
return
(
...
...
@@ -116,6 +121,7 @@ const CHand = (props: {
()
=>
{
if
(
state
.
occupant
)
{
dispatch
(
setCardModalMeta
(
state
.
occupant
));
messageStore
.
cardModal
.
meta
=
state
.
occupant
;
}
dispatch
(
setCardModalInteractivies
(
...
...
@@ -127,7 +133,14 @@ const CHand = (props: {
})
)
);
messageStore
.
cardModal
.
interactivies
=
state
.
idleInteractivities
.
map
(
(
interactive
)
=>
({
desc
:
interactTypeToString
(
interactive
.
interactType
),
response
:
interactive
.
response
,
})
);
dispatch
(
setCardModalIsOpen
(
true
));
messageStore
.
cardModal
.
isOpen
=
true
;
},
planeRef
,
[
state
]
...
...
@@ -145,7 +158,8 @@ const CHand = (props: {
rotation=
{
props
.
rotation
}
enableEdgesRendering
edgesWidth=
{
state
.
idleInteractivities
.
length
>
0
||
state
.
placeInteractivities
// state.idleInteractivities.length > 0 || state.placeInteractivities
state
.
idleInteractivities
.
length
>
0
||
state
.
placeInteractivity
?
edgesWidth
:
0
}
...
...
src/ui/Duel/PlayMat/Magics.tsx
View file @
67d5bd0d
...
...
@@ -2,13 +2,16 @@ import * as BABYLON from "@babylonjs/core";
import
{
useConfig
}
from
"
@/config
"
;
import
{
useAppSelector
}
from
"
@/hook
"
;
import
{
CardState
}
from
"
@/reducers/duel/generic
"
;
//
import { CardState } from "@/reducers/duel/generic";
import
{
selectMeMagics
,
selectOpMagics
}
from
"
@/reducers/duel/magicSlice
"
;
import
{
clearMagicPlaceInteractivities
}
from
"
@/reducers/duel/mod
"
;
import
{
cardSlotRotation
,
zip
}
from
"
../utils
"
;
import
{
FixedSlot
}
from
"
./FixedSlot
"
;
import
{
matStore
,
type
CardState
,
messageStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
const
NeosConfig
=
useConfig
();
// TODO: use config
const
left
=
-
2.15
;
...
...
@@ -16,11 +19,17 @@ const gap = 1.05;
const
transform
=
NeosConfig
.
ui
.
card
.
transform
;
export
const
Magics
=
()
=>
{
const
meMagics
=
useAppSelector
(
selectMeMagics
).
inner
;
// const meMagics = useAppSelector(selectMeMagics).inner;
// const opMagics = useAppSelector(selectOpMagics).inner;
const
meMagics
=
useSnapshot
(
matStore
.
magics
.
me
);
const
opMagics
=
useSnapshot
(
matStore
.
magics
.
op
);
const
meMagicPositions
=
magicPositions
(
0
,
meMagics
);
const
opMagics
=
useAppSelector
(
selectOpMagics
).
inner
;
const
opMagicPositions
=
magicPositions
(
1
,
opMagics
);
const
clearPlaceInteractivitiesAction
=
(
controller
:
number
)
=>
matStore
.
magics
.
of
(
controller
).
clearPlaceInteractivity
();
return
(
<>
{
zip
(
meMagics
,
meMagicPositions
)
...
...
@@ -28,12 +37,13 @@ export const Magics = () => {
.
map
(([
magic
,
position
],
sequence
)
=>
{
return
(
<
FixedSlot
state=
{
magic
}
s
napS
tate=
{
magic
}
key=
{
sequence
}
sequence=
{
sequence
}
position=
{
position
}
rotation=
{
cardSlotRotation
(
false
)
}
clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
);
})
}
...
...
@@ -42,12 +52,13 @@ export const Magics = () => {
.
map
(([
magic
,
position
],
sequence
)
=>
{
return
(
<
FixedSlot
state=
{
magic
}
s
napS
tate=
{
magic
}
key=
{
sequence
}
sequence=
{
sequence
}
position=
{
position
}
rotation=
{
cardSlotRotation
(
true
)
}
clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMagicPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
);
})
}
...
...
src/ui/Duel/PlayMat/Monsters.tsx
View file @
67d5bd0d
...
...
@@ -4,7 +4,7 @@ import * as BABYLON from "@babylonjs/core";
import
{
useConfig
}
from
"
@/config
"
;
import
{
useAppSelector
}
from
"
@/hook
"
;
import
{
CardState
}
from
"
@/reducers/duel/generic
"
;
//
import { CardState } from "@/reducers/duel/generic";
import
{
clearMonsterPlaceInteractivities
}
from
"
@/reducers/duel/mod
"
;
import
{
selectMeMonsters
,
...
...
@@ -14,16 +14,24 @@ import {
import
{
cardSlotDefenceRotation
,
cardSlotRotation
,
zip
}
from
"
../utils
"
;
import
{
FixedSlot
}
from
"
./FixedSlot
"
;
import
{
matStore
,
type
CardState
,
messageStore
}
from
"
@/valtioStores
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
const
NeosConfig
=
useConfig
();
const
transform
=
NeosConfig
.
ui
.
card
.
transform
;
const
floating
=
NeosConfig
.
ui
.
card
.
floating
;
const
left
=
-
2.15
;
// TODO: config
const
gap
=
1.05
;
const
clearPlaceInteractivitiesAction
=
(
controller
:
number
)
=>
matStore
.
monsters
.
of
(
controller
).
clearPlaceInteractivity
();
export
const
Monsters
=
()
=>
{
const
meMonsters
=
useAppSelector
(
selectMeMonsters
).
inner
;
// const meMonsters = useAppSelector(selectMeMonsters).inner;
// const opMonsters = useAppSelector(selectOpMonsters).inner;
const
meMonsters
=
useSnapshot
(
matStore
.
monsters
.
me
);
const
opMonsters
=
useSnapshot
(
matStore
.
monsters
.
op
);
const
meMonsterPositions
=
monsterPositions
(
0
,
meMonsters
);
const
opMonsters
=
useAppSelector
(
selectOpMonsters
).
inner
;
const
opMonsterPositions
=
monsterPositions
(
1
,
opMonsters
);
return
(
...
...
@@ -32,26 +40,28 @@ export const Monsters = () => {
.
slice
(
0
,
5
)
.
map
(([
monster
,
position
],
sequence
)
=>
(
<
FixedSlot
state=
{
monster
}
s
napS
tate=
{
monster
}
key=
{
sequence
}
sequence=
{
sequence
}
position=
{
position
}
rotation=
{
cardSlotRotation
(
false
)
}
deffenseRotation=
{
cardSlotDefenceRotation
()
}
clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
))
}
{
zip
(
opMonsters
,
opMonsterPositions
)
.
slice
(
0
,
5
)
.
map
(([
monster
,
position
],
sequence
)
=>
(
<
FixedSlot
state=
{
monster
}
s
napS
tate=
{
monster
}
key=
{
sequence
}
sequence=
{
sequence
}
position=
{
position
}
rotation=
{
cardSlotRotation
(
true
)
}
deffenseRotation=
{
cardSlotDefenceRotation
()
}
clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
))
}
<
ExtraMonsters
meMonsters=
{
meMonsters
}
opMonsters=
{
opMonsters
}
/>
...
...
@@ -79,31 +89,33 @@ const ExtraMonsters = (props: {
<>
{
meLeft
?
(
<
FixedSlot
state=
{
meLeft
}
s
napS
tate=
{
meLeft
}
sequence=
{
5
}
position=
{
leftPosition
}
rotation=
{
meRotation
}
deffenseRotation=
{
cardSlotDefenceRotation
()
}
clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
)
:
(
<></>
)
}
{
meRight
?
(
<
FixedSlot
state=
{
meRight
}
s
napS
tate=
{
meRight
}
sequence=
{
6
}
position=
{
rightPosition
}
rotation=
{
meRotation
}
deffenseRotation=
{
cardSlotDefenceRotation
()
}
clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
// clearPlaceInteractivitiesAction=
{
clearMonsterPlaceInteractivities
}
clearPlaceInteractivitiesAction=
{
clearPlaceInteractivitiesAction
}
/>
)
:
(
<></>
)
}
{
opLeft
?
(
<
FixedSlot
state=
{
opLeft
}
s
napS
tate=
{
opLeft
}
sequence=
{
5
}
position=
{
rightPosition
}
rotation=
{
opRotation
}
...
...
@@ -115,7 +127,7 @@ const ExtraMonsters = (props: {
)
}
{
opRight
?
(
<
FixedSlot
state=
{
opRight
}
s
napS
tate=
{
opRight
}
sequence=
{
6
}
position=
{
leftPosition
}
rotation=
{
opRotation
}
...
...
src/ui/Duel/PlayMat/SingleSlot.tsx
View file @
67d5bd0d
...
...
@@ -11,6 +11,7 @@ import {
import
{
store
}
from
"
@/store
"
;
import
{
interactTypeToString
}
from
"
../utils
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
const
NeosConfig
=
useConfig
();
const
transform
=
NeosConfig
.
ui
.
card
.
transform
;
...
...
@@ -21,10 +22,11 @@ export const SingleSlot = (props: {
position
:
BABYLON
.
Vector3
;
rotation
:
BABYLON
.
Vector3
;
})
=>
{
const
snapState
=
useSnapshot
(
props
.
state
);
const
boxRef
=
useRef
(
null
);
const
dispatch
=
store
.
dispatch
;
const
edgeRender
=
props
.
s
tate
.
find
((
item
)
=>
snapS
tate
.
find
((
item
)
=>
item
===
undefined
?
false
:
item
.
idleInteractivities
.
length
>
0
)
!==
undefined
;
const
edgesWidth
=
2.0
;
...
...
@@ -32,10 +34,10 @@ export const SingleSlot = (props: {
useClick
(
(
_event
)
=>
{
if
(
props
.
s
tate
.
length
!=
0
)
{
if
(
snapS
tate
.
length
!=
0
)
{
dispatch
(
setCardListModalInfo
(
props
.
s
tate
snapS
tate
.
filter
(
(
item
)
=>
item
.
occupant
!==
undefined
&&
item
.
occupant
.
id
!==
0
)
...
...
@@ -56,7 +58,7 @@ export const SingleSlot = (props: {
}
},
boxRef
,
[
props
.
s
tate
]
[
snapS
tate
]
);
return
(
...
...
@@ -64,11 +66,7 @@ export const SingleSlot = (props: {
name=
"single-slot"
ref=
{
boxRef
}
scaling=
{
new
BABYLON
.
Vector3
(
transform
.
x
,
transform
.
y
,
Depth
*
props
.
state
.
length
)
new
BABYLON
.
Vector3
(
transform
.
x
,
transform
.
y
,
Depth
*
snapState
.
length
)
}
position=
{
props
.
position
}
rotation=
{
props
.
rotation
}
...
...
@@ -81,7 +79,7 @@ export const SingleSlot = (props: {
diffuseTexture=
{
new
BABYLON
.
Texture
(
`${NeosConfig.assetsPath}/card_back.jpg`
)
}
alpha=
{
props
.
s
tate
.
length
==
0
?
0
:
1
}
alpha=
{
snapS
tate
.
length
==
0
?
0
:
1
}
/>
</
box
>
);
...
...
src/valtioStores/matStore/types.ts
View file @
67d5bd0d
...
...
@@ -42,6 +42,8 @@ export type DuelFieldState = CardState[] & {
clearPlaceInteractivity
:
()
=>
void
;
};
type
test
=
DuelFieldState
extends
(
infer
S
)[]
?
S
:
never
;
export
interface
MatState
{
selfType
:
number
;
...
...
src/valtioStores/messageStore/methods/clearAllPlaceInteradtivities.ts
0 → 100644
View file @
67d5bd0d
import
{
matStore
}
from
"
@/valtioStores
"
;
import
{
ygopro
}
from
"
@/api
"
;
/** 清空所有place互动性,也可以删除某一个zone的互动性。zone为空则为清除所有。 */
export
const
clearAllPlaceInteradtivities
=
(
controller
:
number
,
zone
?:
ygopro
.
CardZone
)
=>
{
if
(
zone
)
{
matStore
.
in
(
zone
).
of
(
controller
).
clearPlaceInteractivity
();
}
else
{
matStore
.
banishedZones
.
of
(
controller
).
clearPlaceInteractivity
();
matStore
.
decks
.
of
(
controller
).
clearPlaceInteractivity
();
matStore
.
extraDecks
.
of
(
controller
).
clearPlaceInteractivity
();
matStore
.
graveyards
.
of
(
controller
).
clearPlaceInteractivity
();
matStore
.
hands
.
of
(
controller
).
clearPlaceInteractivity
();
matStore
.
magics
.
of
(
controller
).
clearPlaceInteractivity
();
matStore
.
monsters
.
of
(
controller
).
clearPlaceInteractivity
();
}
};
src/valtioStores/messageStore/methods/index.ts
View file @
67d5bd0d
export
*
from
"
./clearAllIdleInteractivities
"
;
export
*
from
"
./fetchCheckCardMetasV2
"
;
export
*
from
"
./fetchCheckCardMetasV3
"
;
export
*
from
"
./clearAllPlaceInteradtivities
"
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment