Skip to content

Conversation

@PJensen
Copy link
Owner

@PJensen PJensen commented Nov 8, 2025

Summary

  • add a reusable tile map store and rebuild dungeon generation to stamp floor and wall entities while deriving lighting geometry from the grid
  • replace analytic sweep movement with cardinal tile stepping, wiring door toggles and monster AI to the tile map
  • snap demo scene placements to tile centers and keep spawns on-grid for consistent orthogonal navigation

Testing

  • npm test (fails: repository is missing src/lib/ecs-js/index.js so the test runner cannot resolve the ECS library)

Codex Task

Copilot AI review requested due to automatic review settings November 8, 2025 20:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the movement system from continuous analytic geometry to grid-aligned tile-based movement. The system now uses a tile map for collision detection and pathfinding, replacing the previous geometry kernel sweep-based movement.

Key changes:

  • Introduced a new tile map system with walkability and opacity flags
  • Replaced sweep-based continuous movement with cardinal-direction grid steps
  • Updated positions to use integer grid coordinates throughout

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/rules/environment/tileMap.js New module providing tile map data structure and utilities for grid-based collision
src/rules/systems/movementSystem.js Refactored to use cardinal steps on tile grid instead of analytic geometry sweeps
src/rules/systems/aiChaseSystem.js Updated AI to chase using grid-aligned cardinal directions
src/rules/systems/interactionSystem.js Added tile map updates when doors open/close
src/rules/environment/dungeonGenerator.js Modified to generate tile-based dungeons and sync with geometry kernel
src/rules/environment/index.js Added exports for tile map functions
src/main/scene/demoScene.js Adjusted entity positions to grid-aligned integer coordinates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 22 to 23
if (absX !== 0) return { x: Math.sign(dx), y: 0 };
return { x: 0, y: Math.sign(dy) };
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 22-23 are unreachable. When absX === absY (and both non-zero), line 20 evaluates to false and line 21 evaluates to false, but then line 22 checks if absX !== 0 which will always be true in this case. This means line 22 will always execute for the absX === absY case, making line 23 unreachable. Consider simplifying to: return { x: Math.sign(dx), y: 0 }; on line 22 without the condition, or if you want Y-preference when equal, change line 22's condition to if (absY === 0).

Suggested change
if (absX !== 0) return { x: Math.sign(dx), y: 0 };
return { x: 0, y: Math.sign(dy) };
// If absX === absY and both non-zero, prefer X direction
return { x: Math.sign(dx), y: 0 };

Copilot uses AI. Check for mistakes.
const key = tileKey(nextX, nextY);
const occ = tileOccupants.get(key) || null;
if (!walkable) {
blockedBy = occ;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a tile is not walkable but has no occupant (occ is null), blockedBy is set to null. This could cause issues in the subsequent blockedBy check at line 138 where blockedBy?.interactable is accessed. If the intent is to only set blockedBy when there's an actual occupant, the assignment should be conditional: if (occ) blockedBy = occ;. If unwalkable tiles should always block regardless of occupants, the logic is correct but could be clearer.

Suggested change
blockedBy = occ;
if (occ) blockedBy = occ;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants