1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-07 19:27:45 +00:00
sapphire/src/world/Territory/InstanceContent.h

203 lines
5.5 KiB
C
Raw Normal View History

#ifndef SAPPHIRE_INSTANCECONTENT_H
#define SAPPHIRE_INSTANCECONTENT_H
2019-07-21 22:33:33 +10:00
#include "Territory.h"
#include "Event/Director.h"
#include "Forwards.h"
#include <Exd/Structs.h>
2019-03-31 11:27:11 +02:00
namespace Sapphire
{
2019-07-21 22:33:33 +10:00
class InstanceContent : public Event::Director, public Territory
{
2019-03-31 11:27:11 +02:00
public:
enum InstanceContentState
{
Created,
DutyReset,
DutyInProgress,
DutyFinished,
Terminate
};
enum DirectorEventId : uint32_t
{
DEBUG_TimeSync = 0xC0000001,
DutyCommence = 0x80000001,
BattleGroundMusic = 0x80000002,
SetStringendoMode = 0x80000003,
DutyComplete = 0x80000004,
InvalidateTodoList = 0x80000005,
LoadingScreen = 0x80000007,
Forward = 0x80000008,
VoteState = 0x80000009,
VoteStart = 0x8000000A,
VoteResult = 0x8000000B,
VoteFinish = 0x8000000C,
TreasureVoteRefresh = 0x8000000D,
SetSharedGroupId = 0x8000000E,
FirstTimeNotify = 0x8000000F
};
enum EventHandlerOrderId : uint32_t
{
SheetDataReady = 0x80000000,
AbortContent = 0x80000001, //forceFlag
LuaOnStartCutscene = 0x80000002, //returnCode
VoteRequest = 0x80000003, //voteType
VoteReplay = 0x80000004 //voteType, accept
2019-03-31 11:27:11 +02:00
};
enum DirectorSceneId
{
None = 0,
SetupEventArgsOnStart = 1,
SetupEventArgsInProgress = 2,
DutyFailed = 5
};
enum TerminateReason : uint8_t
{
TimeExpired,
TimeLimitReached,
Abandoned,
Ended
};
2022-01-27 21:24:54 +01:00
InstanceContent( std::shared_ptr< Excel::ExcelStruct< Excel::InstanceContent > > pInstanceConfiguration,
2019-03-31 11:27:11 +02:00
uint16_t territoryType,
uint32_t guId,
const std::string& internalName,
const std::string& contentName,
uint32_t instanceContentId );
2019-03-31 11:27:11 +02:00
virtual ~InstanceContent();
2019-03-31 11:27:11 +02:00
bool init() override;
2019-03-31 11:27:11 +02:00
void onBeforePlayerZoneIn( Entity::Player& player ) override;
2019-03-31 11:27:11 +02:00
void onPlayerZoneIn( Entity::Player& player ) override;
2019-03-31 11:27:11 +02:00
void onLeaveTerritory( Entity::Player& player ) override;
2019-03-31 11:27:11 +02:00
void onInitDirector( Entity::Player& player ) override;
2019-03-31 11:27:11 +02:00
void onDirectorSync( Entity::Player& player ) override;
void onUpdate( uint64_t tickCount ) override;
void onEventHandlerOrder( Entity::Player& player, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3,
uint32_t arg4 ) override;
2019-03-31 11:27:11 +02:00
void onTalk( Entity::Player& player, uint32_t eventId, uint64_t actorId );
2019-03-31 11:27:11 +02:00
void onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) override;
2019-03-31 11:27:11 +02:00
void onRegisterEObj( Entity::EventObjectPtr object ) override;
void sendSharedGroup( uint32_t sharedGroupId, uint32_t timeIndex );
void sendInvalidateTodoList();
void sendDutyComplete();
void sendDutyCommence();
void sendForward();
void sendDutyFailed( bool force );
void sendVoteState();
void sendStringendoMode( uint16_t mode );
2019-03-31 11:27:11 +02:00
void setVar( uint8_t index, uint8_t value );
2019-03-31 11:27:11 +02:00
void setSequence( uint8_t value );
void setFlags( uint8_t value );
2019-03-31 11:27:11 +02:00
void startQte();
2019-03-31 11:27:11 +02:00
void startEventCutscene();
2019-03-31 11:27:11 +02:00
void endEventCutscene();
2019-03-31 11:27:11 +02:00
void clearDirector( Entity::Player& player );
2019-03-31 11:27:11 +02:00
/*! set the current bgm index (inside bgm.exd) */
void setCurrentBGM( uint16_t bgmId );
2019-03-31 11:27:11 +02:00
/*! set the current bgm for a specific player */
void setPlayerBGM( Entity::Player& player, uint16_t bgmId );
2019-03-31 11:27:11 +02:00
/*! get the currently playing bgm index */
uint16_t getCurrentBGM() const;
void setVoteState( bool state );
bool getVoteState() const;
2019-03-31 11:27:11 +02:00
bool hasPlayerPreviouslySpawned( Entity::Player& player ) const;
2019-03-31 11:27:11 +02:00
InstanceContentState getState() const;
2022-01-27 21:24:54 +01:00
std::shared_ptr< Excel::ExcelStruct< Excel::InstanceContent > > getInstanceConfiguration() const;
2019-03-31 11:27:11 +02:00
uint32_t getInstanceContentId() const;
2019-03-31 11:27:11 +02:00
Entity::EventObjectPtr getEObjByName( const std::string& name );
2019-03-31 11:27:11 +02:00
/*! binds a player to the instance */
bool bindPlayer( uint32_t playerId );
2019-03-31 11:27:11 +02:00
/*! removes bind of player from the instance */
void unbindPlayer( uint32_t playerId );
2019-03-31 11:27:11 +02:00
/*! return true if the player is bound to the instance */
bool isPlayerBound( uint32_t playerId ) const;
2019-03-31 11:27:11 +02:00
/*! number of milliseconds after all players are ready for the instance to commence (spawn circle removed) */
const uint32_t instanceStartDelay = 1250;
2018-03-15 23:37:21 +01:00
void setExpireValue( uint32_t value );
/*! return remaining time of instance lifetime */
uint32_t getExpireValue();
/*! return bitmask for current state of instance e.g. is vote active or single player instance */
uint32_t getOptionFlags();
void terminate( uint8_t reason );
bool isTerminationReady() const;
size_t getInstancePlayerCount() const;
2019-03-31 11:27:11 +02:00
private:
2022-01-27 21:24:54 +01:00
std::shared_ptr< Excel::ExcelStruct< Excel::InstanceContent > > m_instanceConfiguration;
2019-03-31 11:27:11 +02:00
uint32_t m_instanceContentId;
InstanceContentState m_state;
uint16_t m_currentBgm;
uint32_t m_instanceExpireTime;
uint64_t m_instanceTerminateTime;
2019-03-31 11:27:11 +02:00
uint64_t m_instanceCommenceTime;
bool m_voteState;
bool m_instanceTerminate;
2019-03-31 11:27:11 +02:00
Entity::EventObjectPtr m_pEntranceEObj;
2019-03-31 11:27:11 +02:00
std::map< std::string, Entity::EventObjectPtr > m_eventObjectMap;
std::unordered_map< uint32_t, Entity::EventObjectPtr > m_eventIdToObjectMap;
std::set< uint32_t > m_spawnedPlayers;
2018-03-15 23:37:21 +01:00
2019-03-31 11:27:11 +02:00
// the players which are bound to the instance, regardless of inside or offline
std::set< uint32_t > m_boundPlayerIds;
};
}
#endif //SAPPHIRE_INSTANCECONTENT_H