Phase 4.1: Extract GridData base class from UIGrid (#252, #270, #271, #277)

Extract all grid data members and methods into GridData base class.
UIGrid now inherits from both UIDrawable (rendering) and GridData (state).

- GridData holds: grid dimensions, cell storage (flat/chunked), entities,
  spatial hash, TCOD map, FOV state, Dijkstra caches, layers, cell
  callbacks, children collection
- GridData provides: at(), syncTCODMap/Cell(), computeFOV(), isInFOV(),
  layer management (add/remove/sort/getByName), initStorage()
- UIGrid retains: texture, box, sprites, renderTexture, camera (center,
  zoom, rotation), fill_color, perspective, cell hover/click dispatch,
  all Python API static methods, render()

Fix dangling parent_grid pointers: change UIGrid* to GridData* in
GridLayer, UIGridPoint, GridChunk, ChunkManager (closes #270, closes
#271, closes #277). All 258 tests pass unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-03-16 07:45:12 -04:00
commit 13d5512a41
9 changed files with 379 additions and 340 deletions

View file

@ -16,6 +16,7 @@ static PyObject* sfColor_to_PyObject(sf::Color color);
static sf::Color PyObject_to_sfColor(PyObject* obj);
class UIGrid;
class GridData;
class UIEntity;
class UIGridPoint;
class UIGridPointState;
@ -40,7 +41,7 @@ class UIGridPoint
public:
bool walkable, transparent; // Pathfinding/FOV properties
int grid_x, grid_y; // Position in parent grid
UIGrid* parent_grid; // Parent grid reference for TCOD sync
GridData* parent_grid; // Parent grid reference for TCOD sync (#252)
UIGridPoint();
// Built-in property accessors (walkable, transparent only)