1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 00:27:44 +00:00
sapphire/src/world/Territory/Zone.h

179 lines
4.6 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _ZONE_H
#define _ZONE_H
#include <unordered_map>
2018-03-06 22:22:19 +01:00
#include <Common.h>
2017-08-08 13:53:47 +02:00
#include "Cell.h"
#include "CellHandler.h"
#include "ForwardsZone.h"
2017-08-08 13:53:47 +02:00
#include <set>
#include <map>
2018-10-25 12:44:51 +11:00
#include <memory>
2017-08-08 13:53:47 +02:00
#include <stdio.h>
#include <string.h>
namespace Sapphire
2018-11-06 10:36:45 +01:00
{
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
class ZonePosition;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
using FestivalPair = std::pair< uint16_t, uint16_t >;
2018-12-02 02:01:41 +01:00
namespace Data
{
struct InstanceContent;
struct TerritoryType;
}
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
class Zone : public CellHandler< Cell >, public std::enable_shared_from_this< Zone >
{
protected:
uint32_t m_territoryTypeId;
uint32_t m_guId;
std::string m_placeName;
std::string m_internalName;
std::string m_bgPath;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
std::unordered_map< int32_t, Entity::PlayerPtr > m_playerMap;
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
Common::Weather m_currentWeather;
Common::Weather m_weatherOverride;
std::map< uint8_t, int32_t > m_weatherRateMap;
2017-08-08 13:53:47 +02:00
2019-01-31 12:46:51 +11:00
int64_t m_lastMobUpdate;
int64_t m_lastUpdate;
2017-08-08 13:53:47 +02:00
uint64_t m_lastActivityTime;
2018-12-02 02:01:41 +01:00
FestivalPair m_currentFestival;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
2018-12-02 02:01:41 +01:00
uint32_t m_nextEObjId;
uint32_t m_nextActorId;
FrameworkPtr m_pFw;
2019-01-06 23:34:19 +01:00
std::vector< Entity::SpawnGroup > m_spawnGroups;
uint32_t m_effectCounter;
2018-12-02 02:01:41 +01:00
public:
Zone();
Zone( uint16_t territoryTypeId, uint32_t guId, const std::string& internalName,
const std::string& placeName, FrameworkPtr pFw );
2018-12-02 02:01:41 +01:00
virtual ~Zone();
2018-12-02 02:01:41 +01:00
/*! overrides the zone's weather, set to 0 to unlock */
void setWeatherOverride( Common::Weather weather );
2018-12-02 02:01:41 +01:00
Common::Weather getCurrentWeather() const;
2018-12-02 02:01:41 +01:00
const FestivalPair& getCurrentFestival() const;
2018-12-02 02:01:41 +01:00
void setCurrentFestival( uint16_t festivalId, uint16_t additionalFestivalId = 0 );
std::shared_ptr< Data::TerritoryType > getTerritoryTypeInfo() const;
uint64_t getLastActivityTime() const;
2018-12-02 02:01:41 +01:00
virtual bool init();
2018-12-02 02:01:41 +01:00
virtual void loadCellCache();
2018-12-02 02:01:41 +01:00
virtual uint32_t getTerritoryTypeId() const;
2018-12-02 02:01:41 +01:00
virtual void onBeforePlayerZoneIn( Entity::Player& player ) {};
2018-12-02 02:01:41 +01:00
virtual void onPlayerZoneIn( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onFinishLoading( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onInitDirector( Entity::Player& player );
2018-12-02 02:01:41 +01:00
virtual void onDirectorSync( Entity::Player& player ) {};
2018-12-02 02:01:41 +01:00
virtual void onLeaveTerritory( Entity::Player& player );
virtual void onUpdate( uint64_t tickCount );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
virtual void onRegisterEObj( Entity::EventObjectPtr object ) {};
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
virtual void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
Common::Weather getNextWeather();
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void pushActor( Entity::ActorPtr pActor );
2018-02-03 02:11:29 +11:00
2018-12-02 02:01:41 +01:00
void removeActor( Entity::ActorPtr pActor );
2018-12-02 02:01:41 +01:00
void updateActorPosition( Entity::Actor& pActor );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
bool isCellActive( uint32_t x, uint32_t y );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void updateCellActivity( uint32_t x, uint32_t y, int32_t radius );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void queuePacketForRange( Entity::Player& sourcePlayer, uint32_t range,
Network::Packets::FFXIVPacketBasePtr pPacketEntry );
2018-12-02 02:01:41 +01:00
void queuePacketForZone( Entity::Player& sourcePlayer, Network::Packets::FFXIVPacketBasePtr pPacketEntry,
bool forSelf = false );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
uint32_t getGuId() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
uint32_t getNextEObjId();
2017-08-08 13:53:47 +02:00
uint32_t getNextActorId();
2018-12-02 02:01:41 +01:00
const std::string& getName() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
const std::string& getInternalName() const;
2017-08-08 13:53:47 +02:00
const std::string& getBgPath() const;
2018-12-02 02:01:41 +01:00
std::size_t getPopCount() const;
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
void loadWeatherRates();
2018-12-31 13:54:31 +01:00
bool loadSpawnGroups();
2018-12-02 02:01:41 +01:00
bool checkWeather();
void updateBNpcs( uint64_t tickCount );
2017-08-08 13:53:47 +02:00
bool update( uint64_t tickCount );
2017-08-08 13:53:47 +02:00
void updateSessions( uint64_t tickCount, bool changedWeather );
2017-08-08 13:53:47 +02:00
2018-12-02 02:01:41 +01:00
Entity::EventObjectPtr registerEObj( const std::string& name, uint32_t objectId, uint32_t mapLink,
uint8_t state, Common::FFXIVARR_POSITION3 pos, float scale, float rotation );
2018-12-02 02:01:41 +01:00
void registerEObj( Entity::EventObjectPtr object );
Entity::BNpcPtr createBNpcFromLevelEntry( uint32_t levelId, uint8_t level, uint8_t type,
uint32_t hp, uint16_t nameId, uint32_t directorId, uint8_t bnpcType );
Entity::BNpcPtr getActiveBNpcByLevelId( uint32_t levelId );
2018-12-02 02:01:41 +01:00
Entity::EventObjectPtr getEObj( uint32_t objId );
2018-12-02 02:01:41 +01:00
InstanceContentPtr getAsInstanceContent();
2019-03-31 11:27:11 +02:00
QuestBattlePtr getAsQuestBattle();
void updateSpawnPoints();
uint32_t getNextEffectSequence();
2018-12-02 02:01:41 +01:00
};
2017-08-08 13:53:47 +02:00
}
#endif