mirror of
https://github.com/mudabbir-ahmad/MAD-Treasure-Hunt.git
synced 2026-10-07 19:00:20 +00:00
global claim fix attempt #2
This commit is contained in:
1 parent
fbd95892b5
commit
bb7e46cf4b
1 file changed
+9
-2
@@ -16,8 +16,15 @@ const usePlayerGame = (playerLocation, playerHeading, activeCaches, claimDistanc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selected = (activeCaches || []).find((c) => c.id === selectedCacheId);
|
const caches = activeCaches || [];
|
||||||
const visible = selected && isInClaimCone(playerHeading, playerLocation, selected.coordinates, claimDistance);
|
let selected = selectedCacheId ? caches.find((c) => c.id === selectedCacheId) : null;
|
||||||
|
let visible = selected && isInClaimCone(playerHeading, playerLocation, selected.coordinates, claimDistance);
|
||||||
|
|
||||||
|
if (!visible) {
|
||||||
|
selected = caches.find((c) => isInClaimCone(playerHeading, playerLocation, c.coordinates, claimDistance)) || null;
|
||||||
|
visible = Boolean(selected);
|
||||||
|
}
|
||||||
|
|
||||||
const newId = visible ? String(selected.id) : '';
|
const newId = visible ? String(selected.id) : '';
|
||||||
|
|
||||||
if (newId !== prevIdRef.current) {
|
if (newId !== prevIdRef.current) {
|
||||||
|
|||||||
Reference in new issue
Block a user