fix(Core/Grids): Grid improvements (#20955)
This commit is contained in:
@@ -20,7 +20,8 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "MapDefines.h"
|
||||
#include "NGrid.h"
|
||||
#include "GridCell.h"
|
||||
#include "MapGrid.h"
|
||||
|
||||
// Forward class definitions
|
||||
class Corpse;
|
||||
@@ -31,8 +32,6 @@ class Pet;
|
||||
class Player;
|
||||
class ObjectGuid;
|
||||
|
||||
#define MAX_NUMBER_OF_CELLS 8
|
||||
|
||||
#define CENTER_GRID_ID (MAX_NUMBER_OF_GRIDS/2)
|
||||
|
||||
#define CENTER_GRID_OFFSET (SIZE_OF_GRIDS/2)
|
||||
@@ -73,8 +72,8 @@ enum GridMapTypeMask
|
||||
GRID_MAP_TYPE_MASK_ALL = 0x1F
|
||||
};
|
||||
|
||||
typedef Grid<Player, AllWorldObjectTypes, AllGridObjectTypes> GridType;
|
||||
typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes> NGridType;
|
||||
typedef GridCell<AllWorldObjectTypes, AllGridObjectTypes> GridCellType;
|
||||
typedef MapGrid<AllWorldObjectTypes, AllGridObjectTypes> MapGridType;
|
||||
|
||||
typedef TypeMapContainer<AllGridObjectTypes> GridTypeMapContainer;
|
||||
typedef TypeMapContainer<AllWorldObjectTypes> WorldTypeMapContainer;
|
||||
@@ -187,6 +186,13 @@ namespace Acore
|
||||
return Compute<GridCoord, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS);
|
||||
}
|
||||
|
||||
inline GridCoord ComputeGridCoordSimple(float x, float y)
|
||||
{
|
||||
int gx = (int)(CENTER_GRID_ID - x / SIZE_OF_GRIDS);
|
||||
int gy = (int)(CENTER_GRID_ID - y / SIZE_OF_GRIDS);
|
||||
return GridCoord((MAX_NUMBER_OF_GRIDS - 1) - gx, (MAX_NUMBER_OF_GRIDS - 1) - gy);
|
||||
}
|
||||
|
||||
inline CellCoord ComputeCellCoord(float x, float y)
|
||||
{
|
||||
return Compute<CellCoord, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
|
||||
|
||||
Reference in New Issue
Block a user