|
Zappy GUI
C++ graphic client: renderer, camera, network
|
Manages 8-slot spatial assignment per tile for resources and eggs. More...
#include <TileSlotMap.hpp>
Collaboration diagram for TileSlotMap:Classes | |
| struct | TileOccupancy |
Public Member Functions | |
| std::array< int, 7 > | updateResourceSlots (int tileX, int tileY, const Resources &resources) |
| Updates slot assignments for all resource types on a tile. Assigns a slot when count goes 0→nonzero, releases when nonzero→0. | |
| void | syncEggs (const std::unordered_map< int, Egg > &eggs) |
| Syncs egg slot assignments against the current egg map. Assigns slots to new eggs, releases slots for eggs that have disappeared. | |
| int | eggSlot (int eggId) const |
| Returns the slot index for an egg id, or -1 if unknown. | |
| float | resourceRotation (int tileX, int tileY, int resourceType) const |
| Returns the stable random Y rotation for a resource slot, or 0 if absent. | |
| void | clear () |
| Resets all state. Call on reconnect. | |
Static Public Member Functions | |
| static std::pair< float, float > | slotOffset (int slotIndex) |
| Returns the XZ offset pair {dx, dz} for a slot index (0-7). | |
Static Private Member Functions | |
| static uint64_t | tileKey (int x, int y) |
| static uint64_t | resourceKey (int x, int y, int resourceType) |
Private Attributes | |
| std::unordered_map< uint64_t, TileOccupancy > | _tileOccupancy |
| std::unordered_map< uint64_t, int > | _resourceSlots |
| std::unordered_map< uint64_t, float > | _resourceRotations |
| std::unordered_map< int, int > | _eggSlots |
| std::unordered_map< int, std::pair< int, int > > | _eggTile |
| std::unordered_set< int > | _knownEggs |
Static Private Attributes | |
| static constexpr int | SLOT_COUNT = 8 |
| static constexpr float | CORNER = 0.35f |
Manages 8-slot spatial assignment per tile for resources and eggs.
Slots are shared between resource types and eggs on the same tile so they never overlap each other or the player-reserved tile center. Slot assignment is detected frame-by-frame from world state changes, mirroring the pattern of the old _resourcePositions cache.
Definition at line 19 of file TileSlotMap.hpp.
| void TileSlotMap::clear | ( | ) |
Resets all state. Call on reconnect.
Definition at line 116 of file TileSlotMap.cpp.
References _eggSlots, _eggTile, _knownEggs, _resourceRotations, _resourceSlots, and _tileOccupancy.
Referenced by RaylibRenderer::init().
Here is the caller graph for this function:| int TileSlotMap::eggSlot | ( | int | eggId | ) | const |
Returns the slot index for an egg id, or -1 if unknown.
Definition at line 104 of file TileSlotMap.cpp.
References _eggSlots.
Referenced by RaylibRenderer::_drawSelectionHighlight(), RaylibRenderer::_render3D(), and SelectionFinder::findFromRay().
Here is the caller graph for this function:
|
staticprivate |
Definition at line 39 of file TileSlotMap.cpp.
Referenced by resourceRotation(), and updateResourceSlots().
Here is the caller graph for this function:| float TileSlotMap::resourceRotation | ( | int | tileX, |
| int | tileY, | ||
| int | resourceType | ||
| ) | const |
Returns the stable random Y rotation for a resource slot, or 0 if absent.
Definition at line 110 of file TileSlotMap.cpp.
References _resourceRotations, and resourceKey().
Referenced by RaylibRenderer::_render3D().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns the XZ offset pair {dx, dz} for a slot index (0-7).
Definition at line 16 of file TileSlotMap.cpp.
References SLOT_OFFSETS.
Referenced by RaylibRenderer::_drawSelectionHighlight(), RaylibRenderer::_render3D(), EntityRenderer::drawResources(), and SelectionFinder::findFromRay().
Here is the caller graph for this function:| void TileSlotMap::syncEggs | ( | const std::unordered_map< int, Egg > & | eggs | ) |
Syncs egg slot assignments against the current egg map. Assigns slots to new eggs, releases slots for eggs that have disappeared.
Definition at line 74 of file TileSlotMap.cpp.
References _eggSlots, _eggTile, _knownEggs, _tileOccupancy, and tileKey().
Referenced by RaylibRenderer::_render3D().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Definition at line 34 of file TileSlotMap.cpp.
Referenced by syncEggs(), and updateResourceSlots().
Here is the caller graph for this function:| std::array< int, 7 > TileSlotMap::updateResourceSlots | ( | int | tileX, |
| int | tileY, | ||
| const Resources & | resources | ||
| ) |
Updates slot assignments for all resource types on a tile. Assigns a slot when count goes 0→nonzero, releases when nonzero→0.
Definition at line 46 of file TileSlotMap.cpp.
References _resourceRotations, _resourceSlots, _tileOccupancy, resourceKey(), and tileKey().
Referenced by RaylibRenderer::_render3D().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 64 of file TileSlotMap.hpp.
Referenced by clear(), eggSlot(), and syncEggs().
|
private |
Definition at line 65 of file TileSlotMap.hpp.
Referenced by clear(), and syncEggs().
|
private |
Definition at line 66 of file TileSlotMap.hpp.
Referenced by clear(), and syncEggs().
|
private |
Definition at line 63 of file TileSlotMap.hpp.
Referenced by clear(), resourceRotation(), and updateResourceSlots().
|
private |
Definition at line 62 of file TileSlotMap.hpp.
Referenced by clear(), and updateResourceSlots().
|
private |
Definition at line 61 of file TileSlotMap.hpp.
Referenced by clear(), syncEggs(), and updateResourceSlots().
|
staticconstexprprivate |
Definition at line 48 of file TileSlotMap.hpp.
|
staticconstexprprivate |
Definition at line 47 of file TileSlotMap.hpp.