Polyphase Game Engine
Loading...
Searching...
No Matches
TileMap Class Reference

#include <TileMap.h>

Inheritance diagram for TileMap:
Asset Object

Public Member Functions

 DECLARE_ASSET (TileMap, Asset)
 
 TileMap ()
 
virtual ~TileMap ()
 
virtual void LoadStream (Stream &stream, Platform platform) override
 
virtual void SaveStream (Stream &stream, Platform platform) override
 
virtual void Create () override
 
virtual void Destroy () override
 
virtual void GatherProperties (std::vector< Property > &outProps) override
 
virtual glm::vec4 GetTypeColor () override
 
virtual const char * GetTypeName () override
 
TileSetGetTileSet () const
 
void SetTileSet (TileSet *tileSet)
 
glm::ivec2 GetTileSize () const
 
void SetTileSize (glm::ivec2 size)
 
glm::vec2 GetOrigin () const
 
void SetOrigin (glm::vec2 origin)
 
int32_t GetNumLayers () const
 
TileMapLayerGetLayer (int32_t layerIndex)
 
const TileMapLayerGetLayer (int32_t layerIndex) const
 
TileCell GetCell (int32_t cellX, int32_t cellY, int32_t layerIndex=0) const
 
void SetCell (int32_t cellX, int32_t cellY, const TileCell &cell, int32_t layerIndex=0)
 
void ClearCell (int32_t cellX, int32_t cellY, int32_t layerIndex=0)
 
bool IsCellOccupied (int32_t cellX, int32_t cellY, int32_t layerIndex=0) const
 
int32_t GetTile (int32_t cellX, int32_t cellY, int32_t layerIndex=0) const
 
void SetTile (int32_t cellX, int32_t cellY, int32_t tileIndex, int32_t layerIndex=0)
 
int32_t ReplaceTile (int32_t oldIndex, int32_t newIndex, int32_t layerIndex=0)
 
int32_t ReplaceTilesWithTag (const std::string &tag, int32_t newIndex, int32_t layerIndex=0)
 
int32_t CountTileUses (int32_t tileIndex, int32_t layerIndex=0) const
 
glm::ivec2 GetMinUsed () const
 
glm::ivec2 GetMaxUsed () const
 
bool HasContent () const
 
const std::unordered_set< int64_t > & GetDirtyChunks () const
 
void ClearDirtyChunks ()
 
void MarkAllDirty ()
 
- Public Member Functions inherited from Asset
 DECLARE_FACTORY_MANAGER (Asset)
 
 DECLARE_FACTORY (Asset, Asset)
 
 DECLARE_OBJECT (Asset, Object)
 
 Asset ()
 
virtual ~Asset ()
 
virtual void Copy (Asset *srcAsset)
 
const std::string & GetName () const
 
bool IsLoaded () const
 
bool IsRefCounted () const
 
int32_t GetRefCount () const
 
bool IsEmbedded () const
 
void SetEmbedded (bool embed)
 
bool IsEngineAsset () const
 
void SetEngineAsset (bool engineAsset)
 
void SetName (const std::string &name)
 
void IncrementRefCount ()
 
void DecrementRefCount ()
 
void LoadFile (const char *path, AsyncLoadRequest *request=nullptr)
 
void LoadEmbedded (const EmbeddedFile *embeddedAsset, AsyncLoadRequest *request=nullptr)
 
void SaveFile (const char *path, Platform platform)
 
virtual bool Import (const std::string &path, ImportOptions *options=nullptr)
 
virtual const char * GetTypeImportExt ()
 
virtual bool ShouldSnapshotForPie () const
 
bool IsTransient () const
 
void SetTransient (bool transient)
 
uint64_t GetUuid () const
 
void SetUuid (uint64_t uuid)
 
void EnsureUuid ()
 
void WriteHeader (Stream &stream)
 
- Public Member Functions inherited from Object
virtual ~Object ()=default
 
virtual const char * RuntimeName () const =0
 
virtual const char * RuntimeParentName () const =0
 
virtual RuntimeId InstanceRuntimeId () const =0
 
virtual ObjectQueryInterface (RuntimeId id) const
 
virtual bool Is (RuntimeId id) const
 
virtual bool Is (const char *name) const
 
virtual bool DrawCustomProperty (Property &prop)
 
template<typename T >
T * As () const
 
virtual bool Equals (const Object *rhs) const
 

Static Public Member Functions

static int64_t PackChunkKey (int32_t chunkX, int32_t chunkY)
 
static void UnpackChunkKey (int64_t key, int32_t &outChunkX, int32_t &outChunkY)
 
static int32_t FloorDivChunk (int32_t cell)
 
static int32_t FloorModChunk (int32_t cell)
 
static bool HandlePropChange (class Datum *datum, uint32_t index, const void *newValue)
 
- Static Public Member Functions inherited from Asset
static AssetHeader ReadHeader (Stream &stream)
 
static std::string GetNameFromPath (const std::string &path)
 
static std::string GetDirectoryFromPath (const std::string &path)
 
static const char * GetNameFromTypeId (TypeId id)
 
static TypeId GetTypeIdFromName (const char *name)
 
- Static Public Member Functions inherited from Object
static const char * ClassRuntimeName ()
 

Protected Member Functions

void EnsureLayer (int32_t layerIndex)
 
void RecomputeUsedBounds ()
 

Protected Attributes

AssetRef mTileSet
 
glm::ivec2 mTileSize = { 1, 1 }
 
glm::vec2 mOrigin = { 0.0f, 0.0f }
 
bool mAllowNegativeCoords = true
 
std::vector< TileMapLayermLayers
 
glm::ivec2 mMinUsed = { 0, 0 }
 
glm::ivec2 mMaxUsed = { 0, 0 }
 
bool mHasContent = false
 
std::unordered_set< int64_t > mDirtyChunks
 
- Protected Attributes inherited from Asset
uint32_t mVersion = 0
 
TypeId mType = INVALID_TYPE_ID
 
uint64_t mUuid = 0
 
bool mEmbedded = false
 
bool mLoaded = false
 
bool mEnableRefCount = true
 
bool mEngineAsset = false
 
bool mTransient = false
 
std::string mName = "Asset"
 
int32_t mRefCount = 0
 

Constructor & Destructor Documentation

◆ TileMap()

TileMap::TileMap ( )

◆ ~TileMap()

TileMap::~TileMap ( )
virtual

Member Function Documentation

◆ ClearCell()

void TileMap::ClearCell ( int32_t  cellX,
int32_t  cellY,
int32_t  layerIndex = 0 
)

◆ ClearDirtyChunks()

void TileMap::ClearDirtyChunks ( )
inline

◆ CountTileUses()

int32_t TileMap::CountTileUses ( int32_t  tileIndex,
int32_t  layerIndex = 0 
) const

◆ Create()

void TileMap::Create ( )
overridevirtual

Reimplemented from Asset.

◆ DECLARE_ASSET()

TileMap::DECLARE_ASSET ( TileMap  ,
Asset   
)

◆ Destroy()

void TileMap::Destroy ( )
overridevirtual

Reimplemented from Asset.

◆ EnsureLayer()

void TileMap::EnsureLayer ( int32_t  layerIndex)
protected

◆ FloorDivChunk()

int32_t TileMap::FloorDivChunk ( int32_t  cell)
static

◆ FloorModChunk()

int32_t TileMap::FloorModChunk ( int32_t  cell)
static

◆ GatherProperties()

void TileMap::GatherProperties ( std::vector< Property > &  outProps)
overridevirtual

Reimplemented from Asset.

◆ GetCell()

TileCell TileMap::GetCell ( int32_t  cellX,
int32_t  cellY,
int32_t  layerIndex = 0 
) const

◆ GetDirtyChunks()

const std::unordered_set< int64_t > & TileMap::GetDirtyChunks ( ) const
inline

◆ GetLayer() [1/2]

TileMapLayer * TileMap::GetLayer ( int32_t  layerIndex)

◆ GetLayer() [2/2]

const TileMapLayer * TileMap::GetLayer ( int32_t  layerIndex) const

◆ GetMaxUsed()

glm::ivec2 TileMap::GetMaxUsed ( ) const
inline

◆ GetMinUsed()

glm::ivec2 TileMap::GetMinUsed ( ) const
inline

◆ GetNumLayers()

int32_t TileMap::GetNumLayers ( ) const
inline

◆ GetOrigin()

glm::vec2 TileMap::GetOrigin ( ) const
inline

◆ GetTile()

int32_t TileMap::GetTile ( int32_t  cellX,
int32_t  cellY,
int32_t  layerIndex = 0 
) const

◆ GetTileSet()

TileSet * TileMap::GetTileSet ( ) const

◆ GetTileSize()

glm::ivec2 TileMap::GetTileSize ( ) const
inline

◆ GetTypeColor()

glm::vec4 TileMap::GetTypeColor ( )
overridevirtual

Reimplemented from Asset.

◆ GetTypeName()

const char * TileMap::GetTypeName ( )
overridevirtual

Reimplemented from Asset.

◆ HandlePropChange()

bool TileMap::HandlePropChange ( class Datum datum,
uint32_t  index,
const void *  newValue 
)
static

◆ HasContent()

bool TileMap::HasContent ( ) const
inline

◆ IsCellOccupied()

bool TileMap::IsCellOccupied ( int32_t  cellX,
int32_t  cellY,
int32_t  layerIndex = 0 
) const

◆ LoadStream()

void TileMap::LoadStream ( Stream stream,
Platform  platform 
)
overridevirtual

Reimplemented from Asset.

◆ MarkAllDirty()

void TileMap::MarkAllDirty ( )

◆ PackChunkKey()

int64_t TileMap::PackChunkKey ( int32_t  chunkX,
int32_t  chunkY 
)
static

◆ RecomputeUsedBounds()

void TileMap::RecomputeUsedBounds ( )
protected

◆ ReplaceTile()

int32_t TileMap::ReplaceTile ( int32_t  oldIndex,
int32_t  newIndex,
int32_t  layerIndex = 0 
)

◆ ReplaceTilesWithTag()

int32_t TileMap::ReplaceTilesWithTag ( const std::string &  tag,
int32_t  newIndex,
int32_t  layerIndex = 0 
)

◆ SaveStream()

void TileMap::SaveStream ( Stream stream,
Platform  platform 
)
overridevirtual

Reimplemented from Asset.

◆ SetCell()

void TileMap::SetCell ( int32_t  cellX,
int32_t  cellY,
const TileCell cell,
int32_t  layerIndex = 0 
)

◆ SetOrigin()

void TileMap::SetOrigin ( glm::vec2  origin)
inline

◆ SetTile()

void TileMap::SetTile ( int32_t  cellX,
int32_t  cellY,
int32_t  tileIndex,
int32_t  layerIndex = 0 
)

◆ SetTileSet()

void TileMap::SetTileSet ( TileSet tileSet)

◆ SetTileSize()

void TileMap::SetTileSize ( glm::ivec2  size)
inline

◆ UnpackChunkKey()

void TileMap::UnpackChunkKey ( int64_t  key,
int32_t &  outChunkX,
int32_t &  outChunkY 
)
static

Member Data Documentation

◆ mAllowNegativeCoords

bool TileMap::mAllowNegativeCoords = true
protected

◆ mDirtyChunks

std::unordered_set<int64_t> TileMap::mDirtyChunks
protected

◆ mHasContent

bool TileMap::mHasContent = false
protected

◆ mLayers

std::vector<TileMapLayer> TileMap::mLayers
protected

◆ mMaxUsed

glm::ivec2 TileMap::mMaxUsed = { 0, 0 }
protected

◆ mMinUsed

glm::ivec2 TileMap::mMinUsed = { 0, 0 }
protected

◆ mOrigin

glm::vec2 TileMap::mOrigin = { 0.0f, 0.0f }
protected

◆ mTileSet

AssetRef TileMap::mTileSet
protected

◆ mTileSize

glm::ivec2 TileMap::mTileSize = { 1, 1 }
protected

The documentation for this class was generated from the following files: