39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
|
|
//
|
||
|
|
// Cellgrid: stores sprites in a grid.
|
||
|
|
//
|
||
|
|
// To create a grid, just create an empty table.
|
||
|
|
// In actual usage, the cellgrid will be stored in the registry
|
||
|
|
// in the field "cellgrid_cells". If you pass grid=nil to
|
||
|
|
// any of these routines, the system will automatically use
|
||
|
|
// the table in the registry.
|
||
|
|
//
|
||
|
|
// For purposes of this module, a "sprite" is any table
|
||
|
|
// having a metatable. The (X,Y,Z,Plane) of the sprite are
|
||
|
|
// stored as hidden fields inside the metatable.
|
||
|
|
//
|
||
|
|
// We preserve the invariant that sprites whose plane is nil
|
||
|
|
// are not stored in the grid. All sprites whose plane
|
||
|
|
// is a string are stored in the grid.
|
||
|
|
//
|
||
|
|
// When creating a new sprite, initialize plane to nil. That
|
||
|
|
// fits the invariant that sprites whose plane is nil are
|
||
|
|
// not stored in the grid. If you ever want to change the
|
||
|
|
// sprite's position, use cellgrid_setpos: that will
|
||
|
|
// preserve the invariant.
|
||
|
|
//
|
||
|
|
|
||
|
|
#ifndef CELLGRID_HPP
|
||
|
|
#define CELLGRID_HPP
|
||
|
|
|
||
|
|
#include "luastack.hpp"
|
||
|
|
|
||
|
|
int cellgrid_initgrid(lua_State *L);
|
||
|
|
int cellgrid_addplane(lua_State *L);
|
||
|
|
int cellgrid_setpos(lua_State *L);
|
||
|
|
int cellgrid_scanradius(lua_State *L);
|
||
|
|
int cellgrid_scanregion(lua_State *L);
|
||
|
|
|
||
|
|
#endif // CELLGRID_HPP
|
||
|
|
|
||
|
|
|