@kuncat/avoidant 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AvoidantGame.svelte +160 -49
- package/dist/components/board.svelte +19 -2
- package/dist/components/board.svelte.d.ts +3 -0
- package/dist/components/fragment.glsl +9 -0
- package/dist/paraglide/messages/_index.d.ts +10 -0
- package/dist/paraglide/messages/_index.js +11 -1
- package/dist/paraglide/messages/field_tutorial_mode.d.ts +16 -0
- package/dist/paraglide/messages/field_tutorial_mode.js +29 -0
- package/dist/paraglide/messages/field_void_fraction.d.ts +16 -0
- package/dist/paraglide/messages/field_void_fraction.js +29 -0
- package/dist/paraglide/messages/tutorial_action_dismiss.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_action_dismiss.js +29 -0
- package/dist/paraglide/messages/tutorial_action_next.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_action_next.js +29 -0
- package/dist/paraglide/messages/tutorial_after_safe_deducible.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_after_safe_deducible.js +29 -0
- package/dist/paraglide/messages/tutorial_after_safe_guess.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_after_safe_guess.js +29 -0
- package/dist/paraglide/messages/tutorial_after_void.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_after_void.js +29 -0
- package/dist/paraglide/messages/tutorial_awaiting_first_click.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_awaiting_first_click.js +29 -0
- package/dist/paraglide/messages/tutorial_intro.d.ts +16 -0
- package/dist/paraglide/messages/tutorial_intro.js +29 -0
- package/dist/paraglide/messages/tutorial_won.d.ts +18 -0
- package/dist/paraglide/messages/tutorial_won.js +29 -0
- package/dist/styles/global.css +1 -1
- package/dist/tutorial.svelte.d.ts +42 -0
- package/dist/tutorial.svelte.js +113 -0
- package/dist/wasm/avoidant_wasm.d.ts +3 -3
- package/dist/wasm/avoidant_wasm.js +15 -15
- package/dist/wasm/avoidant_wasm_bg.wasm +0 -0
- package/dist/wasm/avoidant_wasm_bg.wasm.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
3
|
import { slide } from "svelte/transition";
|
|
4
|
+
import { SvelteSet } from "svelte/reactivity";
|
|
4
5
|
import init, { GameState, type GameOptions, type MapData } from "../wasm/avoidant_wasm";
|
|
5
6
|
import { Canvas, T } from "@threlte/core";
|
|
6
7
|
import { OrbitControls } from "@threlte/extras";
|
|
7
|
-
import { MOUSE } from "three";
|
|
8
|
+
import { MOUSE, TOUCH } from "three";
|
|
8
9
|
import Board from "./board.svelte";
|
|
9
10
|
import { MAP_HEIGHT, MAP_WIDTH } from "../generated/shared-constants";
|
|
10
11
|
import { m } from "../paraglide/messages";
|
|
11
12
|
import { getLocale, locales, setLocale } from "../paraglide/runtime";
|
|
12
13
|
import { generateMap } from "../workers/mapgen-client";
|
|
14
|
+
import { TutorialState } from "../tutorial.svelte";
|
|
13
15
|
|
|
14
16
|
const PLAYER_NAME_STORAGE_KEY = "avoidant:playerName";
|
|
15
17
|
const SIZE_PRESETS = { small: 80, medium: 160, large: 320 } as const;
|
|
@@ -67,6 +69,7 @@
|
|
|
67
69
|
let gameState = $state<GameState | undefined>(undefined);
|
|
68
70
|
let terrain = $state<MapData["terrain"] | undefined>(undefined);
|
|
69
71
|
let numCellsInput = $state(SIZE_PRESETS.medium);
|
|
72
|
+
let voidFractionInput = $state(0.15625);
|
|
70
73
|
let rngSeedInput = $state(0);
|
|
71
74
|
let playerNameInput = $state(
|
|
72
75
|
typeof window !== "undefined"
|
|
@@ -74,9 +77,12 @@
|
|
|
74
77
|
: m.default_player_name(),
|
|
75
78
|
);
|
|
76
79
|
let isTutorialMode = $state(false);
|
|
77
|
-
let
|
|
80
|
+
let tutorial = $state<TutorialState | undefined>(undefined);
|
|
81
|
+
let exploredCellsSeen = new SvelteSet<number>();
|
|
82
|
+
let pendingTutorialClick = $state<number | undefined>(undefined);
|
|
78
83
|
let setupMode: "host" | "join" | undefined = $state(undefined);
|
|
79
84
|
let sizePreset = $state<SizePreset>("medium");
|
|
85
|
+
let isAdvancedSettingsOpen = $state(false);
|
|
80
86
|
let relayServersInput = $state("");
|
|
81
87
|
let relayServersInitialized = false;
|
|
82
88
|
let hasRelayServersConfigured = $derived(parseRelayServersInput(relayServersInput).length > 0);
|
|
@@ -91,6 +97,9 @@
|
|
|
91
97
|
let isGeneratingInvite = $state(false);
|
|
92
98
|
let networkSnapshot = $derived(gameState?.networkSnapshot);
|
|
93
99
|
let score = $derived(gameState?.score);
|
|
100
|
+
let cellMetadataStore = $derived(gameState?.cellMetadata);
|
|
101
|
+
let cellsStore = $derived(gameState?.cells);
|
|
102
|
+
let pulsesStore = $derived(gameState?.uiState?.pulses);
|
|
94
103
|
let numSafeUnexploredCells = $derived(
|
|
95
104
|
$score ? Math.max(0, $score.totalCells - $score.voidTotal - $score.safeExplored) : 0,
|
|
96
105
|
);
|
|
@@ -100,7 +109,7 @@
|
|
|
100
109
|
let connectedPeerCount = $derived(
|
|
101
110
|
($networkSnapshot?.peers ?? []).filter((peer) => peer.isConnected).length,
|
|
102
111
|
);
|
|
103
|
-
let
|
|
112
|
+
let cameraFov = $state(50);
|
|
104
113
|
|
|
105
114
|
function toggleScoreBreakdown() {
|
|
106
115
|
isScoreBreakdownPinned = !isScoreBreakdownPinned;
|
|
@@ -113,7 +122,7 @@
|
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
124
|
|
|
116
|
-
function
|
|
125
|
+
function calculateCoverFov(
|
|
117
126
|
viewportWidth: number,
|
|
118
127
|
viewportHeight: number,
|
|
119
128
|
elevationMin: number,
|
|
@@ -163,17 +172,23 @@
|
|
|
163
172
|
const projectedWidth = Math.max(1e-6, maxRight - minRight);
|
|
164
173
|
const projectedHeight = Math.max(1e-6, maxUp - minUp);
|
|
165
174
|
|
|
166
|
-
|
|
167
|
-
|
|
175
|
+
const aspect = Math.max(1e-6, viewportWidth / viewportHeight);
|
|
176
|
+
|
|
177
|
+
// For perspective cover framing, choose the smaller of width/height fitting FOVs so the map fills the viewport similarly to the previous orthographic cover zoom.
|
|
178
|
+
const verticalFovForHeight = 2 * Math.atan(projectedHeight / (2 * CAMERA_ORBIT_RADIUS));
|
|
179
|
+
const verticalFovForWidth = 2 * Math.atan(projectedWidth / (2 * CAMERA_ORBIT_RADIUS * aspect));
|
|
180
|
+
const coverFovRadians = Math.min(verticalFovForHeight, verticalFovForWidth) * 0.99;
|
|
181
|
+
const coverFovDegrees = (coverFovRadians * 180) / Math.PI;
|
|
182
|
+
return Math.min(120, Math.max(10, coverFovDegrees));
|
|
168
183
|
}
|
|
169
184
|
|
|
170
|
-
function
|
|
185
|
+
function setInitialCameraFov() {
|
|
171
186
|
if (typeof window !== "undefined") {
|
|
172
187
|
const viewportWidth = Math.max(1, window.innerWidth);
|
|
173
188
|
const viewportHeight = Math.max(1, window.innerHeight);
|
|
174
189
|
const elevationMin = gameState?.elevationMin ?? 0;
|
|
175
190
|
const elevationMax = gameState?.elevationMax ?? 0;
|
|
176
|
-
|
|
191
|
+
cameraFov = calculateCoverFov(viewportWidth, viewportHeight, elevationMin, elevationMax);
|
|
177
192
|
}
|
|
178
193
|
}
|
|
179
194
|
|
|
@@ -213,7 +228,7 @@
|
|
|
213
228
|
|
|
214
229
|
$effect(() => {
|
|
215
230
|
if (!gameState) return;
|
|
216
|
-
|
|
231
|
+
setInitialCameraFov();
|
|
217
232
|
});
|
|
218
233
|
|
|
219
234
|
$effect(() => {
|
|
@@ -232,6 +247,35 @@
|
|
|
232
247
|
}
|
|
233
248
|
});
|
|
234
249
|
|
|
250
|
+
$effect(() => {
|
|
251
|
+
if (sizePreset === "custom") isTutorialMode = false;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
$effect(() => {
|
|
255
|
+
if (!tutorial || !$cellMetadataStore || !$cellsStore) return;
|
|
256
|
+
const metadata = $cellMetadataStore;
|
|
257
|
+
// Track every newly-explored cell immediately so we don't backfill later, but defer the tutorial state transition until any chord/flood pulses have settled — otherwise we'd announce the result and highlight the next safe cell mid-sweep.
|
|
258
|
+
for (let i = 0; i < metadata.length; i++) {
|
|
259
|
+
if (metadata[i].isExplored && !exploredCellsSeen.has(i)) {
|
|
260
|
+
exploredCellsSeen.add(i);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const pulsesActive = ($pulsesStore?.length ?? 0) > 0;
|
|
264
|
+
const anyRevealing = metadata.some((entry) => entry.isRevealing);
|
|
265
|
+
if (pulsesActive || anyRevealing) return;
|
|
266
|
+
const clicked = pendingTutorialClick;
|
|
267
|
+
if (clicked === undefined) return;
|
|
268
|
+
pendingTutorialClick = undefined;
|
|
269
|
+
tutorial.observeExplore(clicked, $cellsStore, metadata);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
$effect(() => {
|
|
273
|
+
if (!tutorial || !$score) return;
|
|
274
|
+
if ($score.completed) {
|
|
275
|
+
tutorial.observeWin($score.efficiency);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
235
279
|
function hexCells(radius: number): string[] {
|
|
236
280
|
const cells: string[] = [];
|
|
237
281
|
const dx = radius * Math.sqrt(3);
|
|
@@ -302,6 +346,7 @@
|
|
|
302
346
|
try {
|
|
303
347
|
const resolvedNumCells =
|
|
304
348
|
sizePreset === "custom" ? $state.snapshot(numCellsInput) : SIZE_PRESETS[sizePreset];
|
|
349
|
+
const voidFraction = sizePreset === "custom" ? $state.snapshot(voidFractionInput) : 0.15625;
|
|
305
350
|
const relayUrls = parseRelayServersInput($state.snapshot(relayServersInput));
|
|
306
351
|
const options: GameOptions = {
|
|
307
352
|
elevationMax: 6.0,
|
|
@@ -310,6 +355,7 @@
|
|
|
310
355
|
relayUrls: relayUrls.length > 0 ? relayUrls : undefined,
|
|
311
356
|
rngSeed: $state.snapshot(rngSeedInput),
|
|
312
357
|
spikiness: 0.8,
|
|
358
|
+
voidFraction: voidFraction,
|
|
313
359
|
};
|
|
314
360
|
status = m.status_generating_map();
|
|
315
361
|
gameState = new GameState(options);
|
|
@@ -317,6 +363,9 @@
|
|
|
317
363
|
gameState.applyMapCells(generated.cells);
|
|
318
364
|
terrain = generated.terrain;
|
|
319
365
|
inviteTicket = "";
|
|
366
|
+
exploredCellsSeen = new SvelteSet<number>();
|
|
367
|
+
pendingTutorialClick = undefined;
|
|
368
|
+
tutorial = isTutorialMode ? new TutorialState() : undefined;
|
|
320
369
|
} catch (error) {
|
|
321
370
|
console.error("Failed to start game", error);
|
|
322
371
|
} finally {
|
|
@@ -402,6 +451,9 @@
|
|
|
402
451
|
ticketInput = "";
|
|
403
452
|
joinError = undefined;
|
|
404
453
|
status = undefined;
|
|
454
|
+
tutorial = undefined;
|
|
455
|
+
exploredCellsSeen = new SvelteSet<number>();
|
|
456
|
+
pendingTutorialClick = undefined;
|
|
405
457
|
rngSeedInput = Math.floor(Date.now() / 1000);
|
|
406
458
|
}
|
|
407
459
|
|
|
@@ -614,36 +666,14 @@
|
|
|
614
666
|
{/each}
|
|
615
667
|
</div>
|
|
616
668
|
</div>
|
|
617
|
-
<div class="mb-4 w-full px-3">
|
|
618
|
-
<details class="advanced-settings">
|
|
619
|
-
<summary class="advanced-settings-summary">{m.label_advanced_settings()}</summary>
|
|
620
|
-
<div class="advanced-settings-content">
|
|
621
|
-
<label class="field-label" for="relay-servers"
|
|
622
|
-
><a
|
|
623
|
-
href="https://docs.iroh.computer/deployment/dedicated-infrastructure"
|
|
624
|
-
target="_blank"
|
|
625
|
-
rel="noopener noreferrer">{m.field_relay_servers()}</a
|
|
626
|
-
></label
|
|
627
|
-
>
|
|
628
|
-
<textarea
|
|
629
|
-
class="field field-textarea mb-1"
|
|
630
|
-
id="relay-servers"
|
|
631
|
-
bind:value={relayServersInput}
|
|
632
|
-
rows="4"
|
|
633
|
-
spellcheck="false"
|
|
634
|
-
></textarea>
|
|
635
|
-
<p class="field-help">{m.text_relay_servers_hint()}</p>
|
|
636
|
-
</div>
|
|
637
|
-
</details>
|
|
638
|
-
</div>
|
|
639
669
|
{#if sizePreset === "custom"}
|
|
640
670
|
<div class="w-full px-3" transition:slide={{ duration: 180 }}>
|
|
641
671
|
<div class="-mx-3 flex flex-wrap">
|
|
642
672
|
<div class="mb-6 w-full px-3 md:mb-0 md:w-1/2">
|
|
643
|
-
<label class="field-label" for="
|
|
673
|
+
<label class="field-label" for="size-input">{m.field_size()}</label>
|
|
644
674
|
<input
|
|
645
675
|
class="field"
|
|
646
|
-
id="
|
|
676
|
+
id="size-input"
|
|
647
677
|
type="number"
|
|
648
678
|
inputmode="numeric"
|
|
649
679
|
bind:value={numCellsInput}
|
|
@@ -653,23 +683,79 @@
|
|
|
653
683
|
/>
|
|
654
684
|
</div>
|
|
655
685
|
<div class="w-full px-3 md:w-1/2">
|
|
656
|
-
<label class="field-label" for="
|
|
686
|
+
<label class="field-label" for="void-fraction-input">
|
|
687
|
+
{m.field_void_fraction()}
|
|
688
|
+
</label>
|
|
657
689
|
<input
|
|
658
690
|
class="field"
|
|
659
|
-
id="
|
|
691
|
+
id="void-fraction-input"
|
|
660
692
|
type="number"
|
|
661
693
|
inputmode="numeric"
|
|
662
|
-
bind:value={
|
|
694
|
+
bind:value={voidFractionInput}
|
|
695
|
+
max="0.999"
|
|
663
696
|
min="0"
|
|
697
|
+
step="0.001"
|
|
664
698
|
/>
|
|
665
699
|
</div>
|
|
666
700
|
</div>
|
|
667
701
|
</div>
|
|
668
702
|
{/if}
|
|
669
|
-
|
|
670
|
-
<
|
|
671
|
-
|
|
672
|
-
|
|
703
|
+
<div class="mb-4 w-full px-3">
|
|
704
|
+
<div class="advanced-settings" class:advanced-settings-open={isAdvancedSettingsOpen}>
|
|
705
|
+
<button
|
|
706
|
+
type="button"
|
|
707
|
+
class="advanced-settings-summary w-full"
|
|
708
|
+
aria-expanded={isAdvancedSettingsOpen}
|
|
709
|
+
aria-controls="advanced-settings-content"
|
|
710
|
+
onclick={() => (isAdvancedSettingsOpen = !isAdvancedSettingsOpen)}
|
|
711
|
+
>
|
|
712
|
+
{m.label_advanced_settings()}
|
|
713
|
+
</button>
|
|
714
|
+
{#if isAdvancedSettingsOpen}
|
|
715
|
+
<div
|
|
716
|
+
id="advanced-settings-content"
|
|
717
|
+
class="advanced-settings-content"
|
|
718
|
+
transition:slide={{ duration: 180 }}
|
|
719
|
+
>
|
|
720
|
+
<label class="field-label" for="relay-servers"
|
|
721
|
+
><a
|
|
722
|
+
href="https://docs.iroh.computer/deployment/dedicated-infrastructure"
|
|
723
|
+
target="_blank"
|
|
724
|
+
rel="noopener noreferrer">{m.field_relay_servers()}</a
|
|
725
|
+
></label
|
|
726
|
+
>
|
|
727
|
+
<textarea
|
|
728
|
+
class="field field-textarea mb-1"
|
|
729
|
+
id="relay-servers"
|
|
730
|
+
bind:value={relayServersInput}
|
|
731
|
+
rows="4"
|
|
732
|
+
spellcheck="false"
|
|
733
|
+
></textarea>
|
|
734
|
+
<p class="field-help">{m.text_relay_servers_hint()}</p>
|
|
735
|
+
<div class="mt-6 w-full">
|
|
736
|
+
<label class="field-label" for="rng-seed-input">{m.field_seed()}</label>
|
|
737
|
+
<input
|
|
738
|
+
class="field"
|
|
739
|
+
id="rng-seed-input"
|
|
740
|
+
type="number"
|
|
741
|
+
inputmode="numeric"
|
|
742
|
+
bind:value={rngSeedInput}
|
|
743
|
+
min="0"
|
|
744
|
+
/>
|
|
745
|
+
</div>
|
|
746
|
+
</div>
|
|
747
|
+
{/if}
|
|
748
|
+
</div>
|
|
749
|
+
</div>
|
|
750
|
+
<div class="checkbox-field mb-4 flex w-full items-center gap-2 px-3">
|
|
751
|
+
<label class="field-label mb-0!" for="tutorial-mode">{m.field_tutorial_mode()}</label>
|
|
752
|
+
<input
|
|
753
|
+
id="tutorial-mode"
|
|
754
|
+
type="checkbox"
|
|
755
|
+
bind:checked={isTutorialMode}
|
|
756
|
+
disabled={sizePreset === "custom"}
|
|
757
|
+
/>
|
|
758
|
+
</div>
|
|
673
759
|
</div>
|
|
674
760
|
<div class="flex flex-wrap justify-center gap-2">
|
|
675
761
|
<button class="btn btn-secondary" type="button" onclick={() => (setupMode = undefined)}>
|
|
@@ -693,12 +779,12 @@
|
|
|
693
779
|
<input class="field" id="join-player-name" type="text" bind:value={playerNameInput} />
|
|
694
780
|
</div>
|
|
695
781
|
<div class="mb-6 w-full px-3 md:mb-0">
|
|
696
|
-
<label class="field-label" for="
|
|
782
|
+
<label class="field-label" for="ticket-input"
|
|
697
783
|
>{m.field_ticket_or_invitation_url()}</label
|
|
698
784
|
>
|
|
699
785
|
<input
|
|
700
786
|
class="field"
|
|
701
|
-
id="
|
|
787
|
+
id="ticket-input"
|
|
702
788
|
type="text"
|
|
703
789
|
bind:value={ticketInput}
|
|
704
790
|
oninput={() => (joinError = undefined)}
|
|
@@ -785,14 +871,22 @@
|
|
|
785
871
|
{#if gameState}
|
|
786
872
|
<div id="game-canvas-container" style="height: 100vh; width: 100%;">
|
|
787
873
|
<Canvas colorSpace="srgb-linear">
|
|
788
|
-
<T.
|
|
874
|
+
<T.PerspectiveCamera
|
|
789
875
|
makeDefault
|
|
790
|
-
|
|
876
|
+
fov={cameraFov}
|
|
791
877
|
near={0.1}
|
|
792
878
|
far={1000}
|
|
793
879
|
position={cameraPosition}
|
|
794
880
|
/>
|
|
795
|
-
<Board
|
|
881
|
+
<Board
|
|
882
|
+
bind:gameState
|
|
883
|
+
{terrain}
|
|
884
|
+
interactive={tutorial?.isExplorationAllowed ?? true}
|
|
885
|
+
highlightedCellIndex={tutorial?.highlightedCellIndex}
|
|
886
|
+
onCellClicked={(cellIndex) => {
|
|
887
|
+
if (tutorial) pendingTutorialClick = cellIndex;
|
|
888
|
+
}}
|
|
889
|
+
/>
|
|
796
890
|
<OrbitControls
|
|
797
891
|
enableDamping
|
|
798
892
|
enablePan={true}
|
|
@@ -800,15 +894,32 @@
|
|
|
800
894
|
enableRotate={true}
|
|
801
895
|
minPolarAngle={0}
|
|
802
896
|
maxPolarAngle={Math.PI / 2}
|
|
803
|
-
target={[MAP_CENTER_X, 0, MAP_CENTER_Z]}
|
|
804
897
|
mouseButtons={{ LEFT: MOUSE.PAN, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.ROTATE }}
|
|
898
|
+
target={[MAP_CENTER_X, 0, MAP_CENTER_Z]}
|
|
899
|
+
touches={{ ONE: TOUCH.PAN, TWO: TOUCH.DOLLY_ROTATE }}
|
|
805
900
|
/>
|
|
806
901
|
</Canvas>
|
|
807
902
|
</div>
|
|
808
903
|
{/if}
|
|
809
904
|
|
|
810
|
-
{#if
|
|
811
|
-
<div
|
|
812
|
-
|
|
905
|
+
{#if tutorial && tutorial.phase.kind !== "done"}
|
|
906
|
+
<div
|
|
907
|
+
class="tutorial-panel fixed inset-x-0 bottom-0 z-20 flex justify-center px-4 pb-4"
|
|
908
|
+
transition:slide={{ duration: 180 }}
|
|
909
|
+
>
|
|
910
|
+
<div
|
|
911
|
+
class="pointer-events-auto flex w-full max-w-2xl items-start gap-3 rounded-md bg-slate-900/85 px-4 py-3 text-sm text-slate-100 shadow-lg backdrop-blur"
|
|
912
|
+
>
|
|
913
|
+
{tutorial.text}
|
|
914
|
+
{#if tutorial.canAdvance}
|
|
915
|
+
<button class="btn btn-primary" type="button" onclick={() => tutorial?.next()}>
|
|
916
|
+
{m.tutorial_action_next()}
|
|
917
|
+
</button>
|
|
918
|
+
{:else if tutorial.phase.kind === "won"}
|
|
919
|
+
<button class="btn btn-primary" type="button" onclick={() => tutorial?.dismiss()}>
|
|
920
|
+
{m.tutorial_action_dismiss()}
|
|
921
|
+
</button>
|
|
922
|
+
{/if}
|
|
923
|
+
</div>
|
|
813
924
|
</div>
|
|
814
925
|
{/if}
|
|
@@ -70,9 +70,18 @@
|
|
|
70
70
|
interface Props {
|
|
71
71
|
gameState: GameState;
|
|
72
72
|
terrain?: { positions: number[]; normals: number[]; cellIndices: number[] } | undefined;
|
|
73
|
+
interactive?: boolean;
|
|
74
|
+
highlightedCellIndex?: number | undefined;
|
|
75
|
+
onCellClicked?: (cellIndex: number) => void;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
let {
|
|
78
|
+
let {
|
|
79
|
+
gameState = $bindable(),
|
|
80
|
+
terrain = undefined,
|
|
81
|
+
interactive = true,
|
|
82
|
+
highlightedCellIndex = undefined,
|
|
83
|
+
onCellClicked = undefined,
|
|
84
|
+
}: Props = $props();
|
|
76
85
|
let cells = $derived(gameState?.cells);
|
|
77
86
|
let cellMetadata = $derived(gameState?.cellMetadata);
|
|
78
87
|
let pulses = $derived(gameState?.uiState?.pulses);
|
|
@@ -84,7 +93,8 @@
|
|
|
84
93
|
const now = performance.now();
|
|
85
94
|
const hasActivePulses = $pulses.some((p) => now - p.createdAtMs < Math.max(1, p.durationMs));
|
|
86
95
|
const hasFallingCells = fallStart.size > 0;
|
|
87
|
-
|
|
96
|
+
const hasHighlight = highlightedCellIndex !== undefined;
|
|
97
|
+
if (hasActivePulses || hasFallingCells || hasHighlight) {
|
|
88
98
|
nowMs = now;
|
|
89
99
|
|
|
90
100
|
if (hasFallingCells) {
|
|
@@ -303,6 +313,8 @@
|
|
|
303
313
|
pulseOriginCells: { value: new Array(MAX_PULSES).fill(-1) },
|
|
304
314
|
pulseIsRemote: { value: new Array(MAX_PULSES).fill(0) },
|
|
305
315
|
pulseMaxRadii: { value: new Array(MAX_PULSES).fill(0) },
|
|
316
|
+
uHighlightedCell: { value: -1 },
|
|
317
|
+
uTime: { value: 0 },
|
|
306
318
|
},
|
|
307
319
|
}),
|
|
308
320
|
);
|
|
@@ -413,15 +425,20 @@
|
|
|
413
425
|
terrainMaterial.uniforms.pulseOriginCells.value = pulseOriginCellsUniform;
|
|
414
426
|
terrainMaterial.uniforms.pulseIsRemote.value = pulseIsRemoteUniform;
|
|
415
427
|
terrainMaterial.uniforms.pulseMaxRadii.value = pulseMaxRadiiUniform;
|
|
428
|
+
terrainMaterial.uniforms.uHighlightedCell.value =
|
|
429
|
+
highlightedCellIndex === undefined ? -1 : highlightedCellIndex;
|
|
430
|
+
terrainMaterial.uniforms.uTime.value = nowMs;
|
|
416
431
|
invalidate();
|
|
417
432
|
});
|
|
418
433
|
|
|
419
434
|
function handleTerrainClick(event: { point: Vector3; face: { a: number } | null }) {
|
|
435
|
+
if (!interactive) return;
|
|
420
436
|
if (!event.face || $cells.length === 0) return;
|
|
421
437
|
const aCellIndexArr = terrainGeometry.attributes.aCellIndex.array as Float32Array;
|
|
422
438
|
const cellIndex = aCellIndexArr[event.face.a];
|
|
423
439
|
if (cellIndex === undefined) return;
|
|
424
440
|
gameState.queueExplorePulse(cellIndex, event.point.x, event.point.y, event.point.z);
|
|
441
|
+
onCellClicked?.(cellIndex);
|
|
425
442
|
}
|
|
426
443
|
</script>
|
|
427
444
|
|
|
@@ -26,6 +26,9 @@ interface Props {
|
|
|
26
26
|
normals: number[];
|
|
27
27
|
cellIndices: number[];
|
|
28
28
|
} | undefined;
|
|
29
|
+
interactive?: boolean;
|
|
30
|
+
highlightedCellIndex?: number | undefined;
|
|
31
|
+
onCellClicked?: (cellIndex: number) => void;
|
|
29
32
|
}
|
|
30
33
|
declare const Board: import("svelte").Component<Props, {}, "gameState">;
|
|
31
34
|
type Board = ReturnType<typeof Board>;
|
|
@@ -17,6 +17,8 @@ uniform float pulseMaxRadii[MAX_PULSES];
|
|
|
17
17
|
uniform vec3 uLightDir;
|
|
18
18
|
uniform float uAmbient;
|
|
19
19
|
uniform float uDiffuse;
|
|
20
|
+
uniform float uHighlightedCell;
|
|
21
|
+
uniform float uTime;
|
|
20
22
|
|
|
21
23
|
float remapClamped(float value, float inMin, float inMax, float outMin, float outMax) {
|
|
22
24
|
float t = clamp((value - inMin) / (inMax - inMin), 0.0, 1.0);
|
|
@@ -88,6 +90,13 @@ void main() {
|
|
|
88
90
|
vec3 pulseTint = mix(localPulseTint, remotePulseTint, remoteFactor);
|
|
89
91
|
vec3 finalColor = mix(terrainColor, pulseTint, totalRing * 0.85);
|
|
90
92
|
|
|
93
|
+
// Pulsing glow for a tutorial-highlighted cell. `uHighlightedCell` is -1 when no cell is highlighted.
|
|
94
|
+
if (uHighlightedCell >= 0.0 && abs(vCellIndex - uHighlightedCell) < 0.5) {
|
|
95
|
+
float glowPulse = 0.5 + 0.5 * sin(uTime * 0.005);
|
|
96
|
+
vec3 glowColor = vec3(0.4745, 0.8667, 0.6706);
|
|
97
|
+
finalColor = mix(finalColor, glowColor, 0.35 + 0.45 * glowPulse);
|
|
98
|
+
}
|
|
99
|
+
|
|
91
100
|
float alpha = isExplored > 0.5 ? 1.0 : 0.25;
|
|
92
101
|
// Fade alpha while an explored void cell is falling.
|
|
93
102
|
if (isVoid > 0.5 && isExplored > 0.5) {
|
|
@@ -21,6 +21,8 @@ export * from "./field_relay_servers.js";
|
|
|
21
21
|
export * from "./field_seed.js";
|
|
22
22
|
export * from "./field_size.js";
|
|
23
23
|
export * from "./field_ticket_or_invitation_url.js";
|
|
24
|
+
export * from "./field_tutorial_mode.js";
|
|
25
|
+
export * from "./field_void_fraction.js";
|
|
24
26
|
export * from "./label_advanced_settings.js";
|
|
25
27
|
export * from "./label_players.js";
|
|
26
28
|
export * from "./label_safe_cells_explored.js";
|
|
@@ -39,4 +41,12 @@ export * from "./status_loading.js";
|
|
|
39
41
|
export * from "./status_preparing.js";
|
|
40
42
|
export * from "./text_avoided.js";
|
|
41
43
|
export * from "./text_relay_servers_hint.js";
|
|
44
|
+
export * from "./tutorial_action_dismiss.js";
|
|
45
|
+
export * from "./tutorial_action_next.js";
|
|
46
|
+
export * from "./tutorial_after_safe_deducible.js";
|
|
47
|
+
export * from "./tutorial_after_safe_guess.js";
|
|
48
|
+
export * from "./tutorial_after_void.js";
|
|
49
|
+
export * from "./tutorial_awaiting_first_click.js";
|
|
50
|
+
export * from "./tutorial_intro.js";
|
|
51
|
+
export * from "./tutorial_won.js";
|
|
42
52
|
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
@@ -23,6 +23,8 @@ export * from './field_relay_servers.js'
|
|
|
23
23
|
export * from './field_seed.js'
|
|
24
24
|
export * from './field_size.js'
|
|
25
25
|
export * from './field_ticket_or_invitation_url.js'
|
|
26
|
+
export * from './field_tutorial_mode.js'
|
|
27
|
+
export * from './field_void_fraction.js'
|
|
26
28
|
export * from './label_advanced_settings.js'
|
|
27
29
|
export * from './label_players.js'
|
|
28
30
|
export * from './label_safe_cells_explored.js'
|
|
@@ -40,4 +42,12 @@ export * from './status_joining_game.js'
|
|
|
40
42
|
export * from './status_loading.js'
|
|
41
43
|
export * from './status_preparing.js'
|
|
42
44
|
export * from './text_avoided.js'
|
|
43
|
-
export * from './text_relay_servers_hint.js'
|
|
45
|
+
export * from './text_relay_servers_hint.js'
|
|
46
|
+
export * from './tutorial_action_dismiss.js'
|
|
47
|
+
export * from './tutorial_action_next.js'
|
|
48
|
+
export * from './tutorial_after_safe_deducible.js'
|
|
49
|
+
export * from './tutorial_after_safe_guess.js'
|
|
50
|
+
export * from './tutorial_after_void.js'
|
|
51
|
+
export * from './tutorial_awaiting_first_click.js'
|
|
52
|
+
export * from './tutorial_intro.js'
|
|
53
|
+
export * from './tutorial_won.js'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "Tutorial Mode" |
|
|
5
|
+
*
|
|
6
|
+
* @param {Field_Tutorial_ModeInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const field_tutorial_mode: ((inputs?: Field_Tutorial_ModeInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Field_Tutorial_ModeInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Field_Tutorial_ModeInputs = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Field_Tutorial_ModeInputs */
|
|
7
|
+
|
|
8
|
+
const en_field_tutorial_mode = /** @type {(inputs: Field_Tutorial_ModeInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Tutorial Mode`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_field_tutorial_mode = /** @type {(inputs: Field_Tutorial_ModeInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`তালিম মোড`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Tutorial Mode" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Field_Tutorial_ModeInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const field_tutorial_mode = /** @type {((inputs?: Field_Tutorial_ModeInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Field_Tutorial_ModeInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_field_tutorial_mode(inputs)
|
|
28
|
+
return bn_field_tutorial_mode(inputs)
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "Void Cell Fraction" |
|
|
5
|
+
*
|
|
6
|
+
* @param {Field_Void_FractionInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const field_void_fraction: ((inputs?: Field_Void_FractionInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Field_Void_FractionInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Field_Void_FractionInputs = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Field_Void_FractionInputs */
|
|
7
|
+
|
|
8
|
+
const en_field_void_fraction = /** @type {(inputs: Field_Void_FractionInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Void Cell Fraction`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_field_void_fraction = /** @type {(inputs: Field_Void_FractionInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`শূন্য সেলের অনুপাত`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Void Cell Fraction" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Field_Void_FractionInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const field_void_fraction = /** @type {((inputs?: Field_Void_FractionInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Field_Void_FractionInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_field_void_fraction(inputs)
|
|
28
|
+
return bn_field_void_fraction(inputs)
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* | output |
|
|
3
|
+
* | --- |
|
|
4
|
+
* | "Dismiss" |
|
|
5
|
+
*
|
|
6
|
+
* @param {Tutorial_Action_DismissInputs} inputs
|
|
7
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
8
|
+
* @returns {LocalizedString}
|
|
9
|
+
*/
|
|
10
|
+
export const tutorial_action_dismiss: ((inputs?: Tutorial_Action_DismissInputs, options?: {
|
|
11
|
+
locale?: "en" | "bn";
|
|
12
|
+
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Tutorial_Action_DismissInputs, {
|
|
13
|
+
locale?: "en" | "bn";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export type LocalizedString = import("../runtime.js").LocalizedString;
|
|
16
|
+
export type Tutorial_Action_DismissInputs = {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
|
5
|
+
|
|
6
|
+
/** @typedef {{}} Tutorial_Action_DismissInputs */
|
|
7
|
+
|
|
8
|
+
const en_tutorial_action_dismiss = /** @type {(inputs: Tutorial_Action_DismissInputs) => LocalizedString} */ () => {
|
|
9
|
+
return /** @type {LocalizedString} */ (`Dismiss`)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bn_tutorial_action_dismiss = /** @type {(inputs: Tutorial_Action_DismissInputs) => LocalizedString} */ () => {
|
|
13
|
+
return /** @type {LocalizedString} */ (`বাতিল করুন`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* | output |
|
|
18
|
+
* | --- |
|
|
19
|
+
* | "Dismiss" |
|
|
20
|
+
*
|
|
21
|
+
* @param {Tutorial_Action_DismissInputs} inputs
|
|
22
|
+
* @param {{ locale?: "en" | "bn" }} options
|
|
23
|
+
* @returns {LocalizedString}
|
|
24
|
+
*/
|
|
25
|
+
export const tutorial_action_dismiss = /** @type {((inputs?: Tutorial_Action_DismissInputs, options?: { locale?: "en" | "bn" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Tutorial_Action_DismissInputs, { locale?: "en" | "bn" }, {}>} */ ((inputs = {}, options = {}) => {
|
|
26
|
+
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
|
27
|
+
if (locale === "en") return en_tutorial_action_dismiss(inputs)
|
|
28
|
+
return bn_tutorial_action_dismiss(inputs)
|
|
29
|
+
});
|