Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- src/components/PixiGame.tsx +1 -1
- src/components/PlayerDetails.tsx +16 -16
src/components/PixiGame.tsx
CHANGED
|
@@ -32,7 +32,7 @@ export const PixiGame = (props: {
|
|
| 32 |
const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId: props.worldId, oauthToken }) ?? null;
|
| 33 |
|
| 34 |
const humanPlayerId = [...props.game.world.players.values()].find(
|
| 35 |
-
(p) =>
|
| 36 |
)?.id;
|
| 37 |
|
| 38 |
const moveTo = useSendInput(props.engineId, 'moveTo');
|
|
|
|
| 32 |
const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId: props.worldId, oauthToken }) ?? null;
|
| 33 |
|
| 34 |
const humanPlayerId = [...props.game.world.players.values()].find(
|
| 35 |
+
(p) => p.human === humanTokenIdentifier,
|
| 36 |
)?.id;
|
| 37 |
|
| 38 |
const moveTo = useSendInput(props.engineId, 'moveTo');
|
src/components/PlayerDetails.tsx
CHANGED
|
@@ -14,7 +14,7 @@ export default function PlayerDetails({
|
|
| 14 |
worldId,
|
| 15 |
engineId,
|
| 16 |
game,
|
| 17 |
-
playerId:
|
| 18 |
setSelectedElement,
|
| 19 |
scrollViewRef,
|
| 20 |
currentPlayerId,
|
|
@@ -31,34 +31,34 @@ export default function PlayerDetails({
|
|
| 31 |
const oauthToken = oauth ? oauth.userInfo.fullname : undefined;
|
| 32 |
const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId, oauthToken });
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
);
|
| 37 |
const humanConversation = humanPlayer ? game.world.playerConversation(humanPlayer) : undefined;
|
| 38 |
// Always select the other player if we're in a conversation with them.
|
| 39 |
if (humanPlayer && humanConversation) {
|
| 40 |
const otherPlayerIds = [...humanConversation.participants.keys()].filter(
|
| 41 |
-
(p) =>
|
| 42 |
);
|
| 43 |
-
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
|
|
|
| 47 |
const playerConversation = player && game.world.playerConversation(player);
|
| 48 |
|
| 49 |
const previousConversation = useQuery(
|
| 50 |
api.world.previousConversation,
|
| 51 |
-
|
| 52 |
);
|
| 53 |
|
| 54 |
-
const playerDescription =
|
| 55 |
|
| 56 |
const startConversation = useSendInput(engineId, 'startConversation');
|
| 57 |
const acceptInvite = useSendInput(engineId, 'acceptInvite');
|
| 58 |
const rejectInvite = useSendInput(engineId, 'rejectInvite');
|
| 59 |
const leaveConversation = useSendInput(engineId, 'leaveConversation');
|
| 60 |
|
| 61 |
-
if (!
|
| 62 |
return (
|
| 63 |
<div className="h-full text-xl flex text-center items-center p-4">
|
| 64 |
Click on an agent on the map to see chat history.
|
|
@@ -68,7 +68,7 @@ export default function PlayerDetails({
|
|
| 68 |
if (!player) {
|
| 69 |
return null;
|
| 70 |
}
|
| 71 |
-
const isMe = humanPlayer &&
|
| 72 |
const canInvite = !isMe && !playerConversation && humanPlayer && !humanConversation;
|
| 73 |
const sameConversation =
|
| 74 |
!isMe &&
|
|
@@ -79,10 +79,10 @@ export default function PlayerDetails({
|
|
| 79 |
|
| 80 |
const humanStatus =
|
| 81 |
humanPlayer && humanConversation && humanConversation.participants.get(humanPlayer.id)?.status;
|
| 82 |
-
const playerStatus = playerConversation && playerConversation.participants.get(
|
| 83 |
const haveInvite = sameConversation && humanStatus?.kind === 'invited';
|
| 84 |
const waitingForAccept =
|
| 85 |
-
sameConversation && playerConversation.participants.get(
|
| 86 |
const waitingForNearby =
|
| 87 |
sameConversation && playerStatus?.kind === 'walkingOver' && humanStatus?.kind === 'walkingOver';
|
| 88 |
|
|
@@ -92,14 +92,14 @@ export default function PlayerDetails({
|
|
| 92 |
humanStatus?.kind === 'participating';
|
| 93 |
|
| 94 |
const onStartConversation = async () => {
|
| 95 |
-
if (!humanPlayer || !
|
| 96 |
return;
|
| 97 |
}
|
| 98 |
console.log(`Starting conversation`);
|
| 99 |
-
await toastOnError(startConversation({ playerId: humanPlayer.id, invitee:
|
| 100 |
};
|
| 101 |
const onAcceptInvite = async () => {
|
| 102 |
-
if (!humanPlayer || !humanConversation || !
|
| 103 |
return;
|
| 104 |
}
|
| 105 |
await toastOnError(
|
|
|
|
| 14 |
worldId,
|
| 15 |
engineId,
|
| 16 |
game,
|
| 17 |
+
playerId: playerId,
|
| 18 |
setSelectedElement,
|
| 19 |
scrollViewRef,
|
| 20 |
currentPlayerId,
|
|
|
|
| 31 |
const oauthToken = oauth ? oauth.userInfo.fullname : undefined;
|
| 32 |
const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId, oauthToken });
|
| 33 |
|
| 34 |
+
onst players = [...game.world.players.values()];
|
| 35 |
+
const humanPlayer = players.find((p) => p.human === humanTokenIdentifier);
|
|
|
|
| 36 |
const humanConversation = humanPlayer ? game.world.playerConversation(humanPlayer) : undefined;
|
| 37 |
// Always select the other player if we're in a conversation with them.
|
| 38 |
if (humanPlayer && humanConversation) {
|
| 39 |
const otherPlayerIds = [...humanConversation.participants.keys()].filter(
|
| 40 |
+
(p) => p !== humanPlayer.id,
|
| 41 |
);
|
| 42 |
+
playerId = otherPlayerIds[0];
|
| 43 |
}
|
| 44 |
|
| 45 |
+
|
| 46 |
+
const player = playerId && game.world.players.get(playerId);
|
| 47 |
const playerConversation = player && game.world.playerConversation(player);
|
| 48 |
|
| 49 |
const previousConversation = useQuery(
|
| 50 |
api.world.previousConversation,
|
| 51 |
+
playerId ? { worldId, playerId: playerId } : 'skip',
|
| 52 |
);
|
| 53 |
|
| 54 |
+
const playerDescription = playerId && game.playerDescriptions.get(playerId);
|
| 55 |
|
| 56 |
const startConversation = useSendInput(engineId, 'startConversation');
|
| 57 |
const acceptInvite = useSendInput(engineId, 'acceptInvite');
|
| 58 |
const rejectInvite = useSendInput(engineId, 'rejectInvite');
|
| 59 |
const leaveConversation = useSendInput(engineId, 'leaveConversation');
|
| 60 |
|
| 61 |
+
if (!playerId) {
|
| 62 |
return (
|
| 63 |
<div className="h-full text-xl flex text-center items-center p-4">
|
| 64 |
Click on an agent on the map to see chat history.
|
|
|
|
| 68 |
if (!player) {
|
| 69 |
return null;
|
| 70 |
}
|
| 71 |
+
const isMe = humanPlayer && player.id === humanPlayer.id;
|
| 72 |
const canInvite = !isMe && !playerConversation && humanPlayer && !humanConversation;
|
| 73 |
const sameConversation =
|
| 74 |
!isMe &&
|
|
|
|
| 79 |
|
| 80 |
const humanStatus =
|
| 81 |
humanPlayer && humanConversation && humanConversation.participants.get(humanPlayer.id)?.status;
|
| 82 |
+
const playerStatus = playerConversation && playerConversation.participants.get(playerId)?.status;
|
| 83 |
const haveInvite = sameConversation && humanStatus?.kind === 'invited';
|
| 84 |
const waitingForAccept =
|
| 85 |
+
sameConversation && playerConversation.participants.get(playerId)?.status.kind === 'invited';
|
| 86 |
const waitingForNearby =
|
| 87 |
sameConversation && playerStatus?.kind === 'walkingOver' && humanStatus?.kind === 'walkingOver';
|
| 88 |
|
|
|
|
| 92 |
humanStatus?.kind === 'participating';
|
| 93 |
|
| 94 |
const onStartConversation = async () => {
|
| 95 |
+
if (!humanPlayer || !playerId) {
|
| 96 |
return;
|
| 97 |
}
|
| 98 |
console.log(`Starting conversation`);
|
| 99 |
+
await toastOnError(startConversation({ playerId: humanPlayer.id, invitee: playerId }));
|
| 100 |
};
|
| 101 |
const onAcceptInvite = async () => {
|
| 102 |
+
if (!humanPlayer || !humanConversation || !playerId) {
|
| 103 |
return;
|
| 104 |
}
|
| 105 |
await toastOnError(
|