Refine FOW visuals, Turn Skipping logic, and UI Polish
This commit is contained in:
@@ -957,46 +957,40 @@ export class GameRenderer {
|
||||
if (!this.dungeonGroup) return;
|
||||
|
||||
const visibleSet = new Set(visibleTileIds);
|
||||
const visibleCellKeys = new Set();
|
||||
|
||||
// 1. Update Tile Visibility & Collect Visible Cells
|
||||
this.dungeonGroup.children.forEach(mesh => {
|
||||
const isVisible = visibleSet.has(mesh.userData.tileId);
|
||||
mesh.visible = isVisible;
|
||||
if (isVisible && mesh.userData.cells) {
|
||||
mesh.userData.cells.forEach(cell => {
|
||||
visibleCellKeys.add(`${cell.x},${cell.y}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 2. Hide/Show Entities based on Tile Visibility
|
||||
if (this.entities) {
|
||||
this.entities.forEach((mesh, id) => {
|
||||
// Get grid coords (World X, -Z)
|
||||
const gx = Math.round(mesh.position.x);
|
||||
const gy = Math.round(-mesh.position.z);
|
||||
const key = `${gx},${gy}`;
|
||||
|
||||
// If the cell is visible, show the entity. Otherwise hide it.
|
||||
if (visibleCellKeys.has(key)) {
|
||||
mesh.visible = true;
|
||||
} else {
|
||||
mesh.visible = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Also update Doors (in exitGroup)
|
||||
if (this.exitGroup) {
|
||||
this.exitGroup.children.forEach(door => {
|
||||
// If door connects to AT LEAST ONE visible tile, it should be visible?
|
||||
// Or if it is part of a visible tile?
|
||||
// Doors usually belong to the tile they were spawned with?
|
||||
// Logic: Check if door is within/adjacent to visible cells?
|
||||
// Door userData has `cells`.
|
||||
// We need to map cells to tileIds? We don't have that map here.
|
||||
// Simplified: If the door is physically close to a visible tile, show it.
|
||||
|
||||
// Better approach:
|
||||
// Engine should pass visible cells?
|
||||
// Using tileIds is robust for tiles.
|
||||
// For doors: we can check if any of the door's cells are roughly inside a visible tile's bounding box?
|
||||
// Or just show all doors for now? No, floating doors in darkness.
|
||||
|
||||
// Hack: Show door if its position is near a visible tile.
|
||||
let doorVisible = false;
|
||||
const dx = door.position.x;
|
||||
const dy = -door.position.z; // World Z is -Grid Y
|
||||
|
||||
// Check against visible meshes
|
||||
// This is O(N*M), slow.
|
||||
// But N (visible tiles) is small (1-5).
|
||||
|
||||
// Let's assume doors connected to visible tiles are visible.
|
||||
// I need to know which tile a door belongs to.
|
||||
// I will skip door FOW for this iteration or make them always visible but dim?
|
||||
// Let's hide them by default and check proximity.
|
||||
|
||||
door.visible = false;
|
||||
// Can't easily check without grid.
|
||||
// Engine will handle Door visibility via `setEntityVisibility`? No, they are meshes not entities.
|
||||
});
|
||||
|
||||
// Re-iterate to show close doors
|
||||
@@ -1028,6 +1022,48 @@ export class GameRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
setEntityTarget(entityId, isTarget) {
|
||||
const mesh = this.entities.get(entityId);
|
||||
if (!mesh) return;
|
||||
|
||||
// Remove existing target ring
|
||||
const oldRing = mesh.getObjectByName("TargetRing");
|
||||
if (oldRing) mesh.remove(oldRing);
|
||||
|
||||
if (isTarget) {
|
||||
// Blue Ring logic
|
||||
const ringGeom = new THREE.RingGeometry(0.3, 0.4, 32);
|
||||
const ringMat = new THREE.MeshBasicMaterial({
|
||||
color: 0x00AADD, // Light Blue
|
||||
side: THREE.DoubleSide,
|
||||
transparent: true,
|
||||
opacity: 0.8
|
||||
});
|
||||
const ring = new THREE.Mesh(ringGeom, ringMat);
|
||||
ring.rotation.x = -Math.PI / 2;
|
||||
// Align with floor (relative to mesh center)
|
||||
const h = 1.56;
|
||||
ring.position.y = -h / 2 + 0.06; // Slightly above floor/selection
|
||||
|
||||
ring.name = "TargetRing";
|
||||
mesh.add(ring);
|
||||
}
|
||||
}
|
||||
|
||||
clearAllActiveRings() {
|
||||
if (!this.entities) return;
|
||||
this.entities.forEach(mesh => {
|
||||
const ring = mesh.getObjectByName("ActiveRing"); // Green ring
|
||||
if (ring) mesh.remove(ring);
|
||||
const ring2 = mesh.getObjectByName("SelectionRing"); // Yellow ring
|
||||
if (ring2) ring2.visible = false;
|
||||
|
||||
// Also clear TargetRing if any
|
||||
const ring3 = mesh.getObjectByName("TargetRing");
|
||||
if (ring3) mesh.remove(ring3);
|
||||
});
|
||||
}
|
||||
|
||||
openDoor(doorMesh) {
|
||||
if (!doorMesh || !doorMesh.userData.isDoor) return;
|
||||
if (doorMesh.userData.isOpen) return; // Already open
|
||||
|
||||
Reference in New Issue
Block a user