Entity cell_pos — integer logical position decoupled from render position #295
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#300 Behavior data struct and primitive implementations
john/McRogueFace
#302 Pathfinding with entity collision labels
john/McRogueFace
Reference
john/McRogueFace#295
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add an integer logical position (
cell_pos) to entities, fully decoupled from the float render position (x/y). This eliminates thefloor()asymmetry problem during movement animation and provides unambiguous cell membership for turn-based logic.Problem
Entity positions are
sf::Vector2ffloats. During animated movement:floor()puts the entity at the new cell as soon as the coordinate changes by any amountfloor()keeps the entity at the previous cell until animation completesThis makes spatial queries unreliable during animation and forces workarounds for turn-based games.
Proposed API
Relationship to existing properties
cell_pos(int, int)x/yfloatgrid_pos(int, int)cell_posC++ backing
Behavior
cell_positionandpositionset from constructor argscell_posdoes NOT updatex/y; settingx/ydoes NOT updatecell_poscell_pos-based lookupgrid.at(x, y).entities: Returns entities whosecell_posincludes(x, y)tile_size=(2,3)andcell_pos=(5,5)claims cells(5,5)through(6,7)Dependencies
Files likely affected
src/UIEntity.h/cpp— addcell_position, property accessorssrc/SpatialHash.h/cpp— switch to integer cell-based trackingsrc/UIGridPoint.cpp—.entitiesproperty usescell_possrc/UIEntityCollection.h/cpp— entity insertion setscell_posgrid.step()— turn manager for entity behaviors #301GridViewandGrid,FOVLayerandPathLayer#252Roadmap context
Part of the Grid & Entity Overhaul Roadmap (
docs/GRID_ENTITY_OVERHAUL_ROADMAP.md), Phase 2 (Entity Data Model Extensions).Breaking change:
grid_posbecomes an alias forcell_pos, decoupled fromx/y. Code that readsgrid_posexpecting it to track the float position must be updated. See roadmap for full migration details.Foundation for the entire behavior system — all behavior movement operates on
cell_pos, and the spatial hash switches to integer cell-based tracking.mcrfpy.Behaviorenum — behavior type identifiers #297mcrfpy.Triggerenum — behavior trigger type identifiers #298