-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTileTagging.hpp
35 lines (32 loc) · 1.09 KB
/
TileTagging.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "VectorUtility.hpp"
#ifndef TILE_TAGGING_HEADER_HPP
#define TILE_TAGGING_HEADER_HPP
namespace StrategyGoo
{
template< typename REFRENCE_TYPE >
bool AddEntityToTile( entt::registry& registry, REFRENCE_TYPE toRefrence, BoardPosition tile, GameBoard* board )
{
auto tileID = ( *board )[ tile.x ][ tile.y ].GetID();
if( registry.has< REFRENCE_TYPE >( tileID ) == false ) {
registry.emplace< REFRENCE_TYPE >( tileID, toRefrence );
return true;
}
return false;
}
template< typename REFRENCE_TYPE >
bool RemoveEntityFromTile( entt::registry& registry, BoardPosition tile, GameBoard* board )
{
auto tileID = ( *board )[ tile.x ][ tile.y ].GetID();
if( registry.has< REFRENCE_TYPE >( tileID ) == true ) {
registry.remove< REFRENCE_TYPE >( tileID );
return true;
}
return false;
}
template< typename REFRENCE_TYPE >
bool MoveEntity( entt::registry& registry, REFRENCE_TYPE toRefrence, BoardPosition tile, GameBoard* board ) {
return ( AddEntityToTile( registry, toRefrence, tile, board ) &&
RemoveEntityFromTile< REFRENCE_TYPE >( registry, tile, board ) );
}
}
#endif