1.5 KiB
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_straightandcorridor_steps. - Change
exitConfigurationsfrom an array of simple arrays to an array of objects. - Each object will represent a configuration (Straight, Corner-Left, Corner-Right) but will contain
exitsByRotationforNORTH,EAST,SOUTH,WEST. - Pre-calculate coordinates for these rotations based on the 2x6 layout.
2. Rewrite DungeonGenerator.js
- Simplify
step():- Iterate through
TileDefinitionsthat might apply. - Handle
pendingExits.
- Iterate through
- 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.
- Calculate
- 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).