Files
WarhammerQuest/implementación/implementation_plan_rotation.md

1.5 KiB

Paradigm Shift: Explicit Rotations & Corridors

Goal

To eliminate dynamic rotation calculations which caused alignment issues, specifically for asymmetric tiles like Corridors (2x6). We will implement explicit exit definitions for all 4 rotations for Corridors, just like we did for Rooms.

Steps

1. Update TileDefinitions.js

  • Modify corridor_straight and corridor_steps.
  • Change exitConfigurations from an array of simple arrays to an array of objects.
  • Each object will represent a configuration (Straight, Corner-Left, Corner-Right) but will contain exitsByRotation for NORTH, EAST, SOUTH, WEST.
  • Pre-calculate coordinates for these rotations based on the 2x6 layout.

2. Rewrite DungeonGenerator.js

  • Simplify step():
    • Iterate through TileDefinitions that might apply.
    • Handle pendingExits.
  • New Alignment Logic:
    • Pick a card.
    • If it has exitConfigurations (Corridors), iterate them.
      • Inside, iterate 4 Rotations.
      • Inside, iterate Exits.
    • If it has simple definitions (Rooms), iterate 4 Rotations.
      • Inside, iterate Exits.
  • Placement:
    • Calculate GlobalPos = TargetConnection - LocalExitPos.
    • Check Validity (Opposite Direction).
    • Check canPlace.
  • Cleanup: Remove deprecated methods like getRotatedOffset.

Expected Outcome

  • Corridors align perfectly in all directions.
  • No gaps.
  • Code is easier to understand (no complex matrix rotation math in JS, just lookups).