1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00
sapphire/src/servers/sapphire_zone/Zone/Cell.h

121 lines
2 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _CELL_H
#define _CELL_H
#include <stdint.h>
#include "Forwards.h"
2017-08-08 13:53:47 +02:00
#include <set>
namespace Core {
typedef std::set< Entity::CharaPtr > CharaSet;
2017-08-08 13:53:47 +02:00
class Cell
{
friend class Zone;
private:
bool m_bForcedActive;
uint16_t m_posX;
uint16_t m_posY;
CharaSet m_charas;
2017-08-08 13:53:47 +02:00
bool m_bActive;
bool m_bLoaded;
2017-08-08 13:53:47 +02:00
bool m_bUnloadPending;
uint16_t m_playerCount;
ZonePtr m_pZone;
public:
Cell();
~Cell();
void init( uint32_t x, uint32_t y, ZonePtr pZone );
2017-08-08 13:53:47 +02:00
void addChara( Entity::CharaPtr pAct );
2017-08-08 13:53:47 +02:00
void removeChara( Entity::CharaPtr pAct );
2017-08-08 13:53:47 +02:00
bool hasChara( Entity::CharaPtr pAct )
2017-08-08 13:53:47 +02:00
{
return (m_charas.find(pAct) != m_charas.end());
2017-08-08 13:53:47 +02:00
}
bool hasPlayers() const
{
return ((m_playerCount > 0) ? true : false);
}
size_t getCharaCount() const
2017-08-08 13:53:47 +02:00
{
return m_charas.size();
2017-08-08 13:53:47 +02:00
}
void removeCharas();
2017-08-08 13:53:47 +02:00
CharaSet::iterator begin()
2017-08-08 13:53:47 +02:00
{
return m_charas.begin();
2017-08-08 13:53:47 +02:00
}
CharaSet::iterator end()
2017-08-08 13:53:47 +02:00
{
return m_charas.end();
2017-08-08 13:53:47 +02:00
}
void setActivity(bool state);
bool isActive() const
{
return m_bActive;
}
bool isLoaded() const
{
return m_bLoaded;
}
uint32_t getPlayerCount() const
{
return m_playerCount;
}
bool isUnloadPending() const
{
return m_bUnloadPending;
}
void setUnloadPending(bool up)
{
m_bUnloadPending = up;
}
void queueUnloadPending();
void cancelPendingUnload();
void unload();
void setPermanentActivity(bool val)
{
m_bForcedActive = val;
}
bool isForcedActive() const
{
return m_bForcedActive;
}
uint16_t getPosX() const
{
return m_posX;
}
uint16_t getPosY() const
{
return m_posY;
}
};
}
#endif