Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix selection bug #2662

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions client/apps/game/src/three/scenes/worldmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,13 @@ export default class WorldmapScene extends HexagonScene {
if (this.isNavigationViewOpen()) {
this.closeNavigationViews();
} else {
this.clearEntitySelection();
this.clearHexSelection();
this.clearSelection();
}
}
});

window.addEventListener("urlChanged", () => {
this.clearEntitySelection();
this.clearHexSelection();
this.clearSelection();
});
}

Expand Down Expand Up @@ -313,7 +311,7 @@ export default class WorldmapScene extends HexagonScene {
this.clearCache();
this.updateVisibleChunks(true);
});
this.clearEntitySelection();
this.clearSelection();
}

protected handleHexSelection(hexCoords: HexPosition) {
Expand Down Expand Up @@ -368,7 +366,7 @@ export default class WorldmapScene extends HexagonScene {

private onArmySelection(selectedEntityId: ID | null) {
if (!selectedEntityId) {
this.clearEntitySelection();
this.clearSelection();
return;
}

Expand All @@ -384,13 +382,11 @@ export default class WorldmapScene extends HexagonScene {
this.highlightHexManager.highlightHexes(travelPaths.getHighlightedHexes());
}

private clearEntitySelection() {
private clearSelection() {
this.highlightHexManager.highlightHexes([]);
this.state.updateTravelPaths(new Map());
this.structurePreview?.clearPreviewStructure();
}

private clearHexSelection() {
this.state.updateSelectedEntityId(null);
this.state.setSelectedHex(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export const AllResourceArrivals = memo(
addSubscribedIds(unsubscribedIds);

// Move API call outside of state updates
getEntitiesFromTorii(dojo.network.toriiClient, dojo.network.contractComponents as any, unsubscribedIds, ["s1_eternum-DetachedResource"]).catch(
(error) => console.error("Fetch failed", error),
);
getEntitiesFromTorii(dojo.network.toriiClient, dojo.network.contractComponents as any, unsubscribedIds, [
"s1_eternum-DetachedResource",
]).catch((error) => console.error("Fetch failed", error));
console.log("AddToSubscriptionStart - 5");
}, [arrivals, subscribedIds, addSubscribedIds]);

Expand Down
Loading