mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
instance objects, gameobj implementation
This commit is contained in:
parent
23d958e768
commit
01e22b679d
8 changed files with 178 additions and 2 deletions
|
@ -5,3 +5,55 @@ Core::Entity::GameObject::GameObject( ObjKind type ) :
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Core::Entity::GameObject::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
Core::Entity::GameObject::ObjKind Core::Entity::GameObject::getObjKind() const
|
||||
{
|
||||
return m_objKind;
|
||||
}
|
||||
|
||||
Core::Common::FFXIVARR_POSITION3& Core::Entity::GameObject::getPos()
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
void Core::Entity::GameObject::setPos( float x, float y, float z )
|
||||
{
|
||||
m_pos.x = x;
|
||||
m_pos.y = y;
|
||||
m_pos.z = z;
|
||||
}
|
||||
|
||||
void Core::Entity::GameObject::setPos( const Core::Common::FFXIVARR_POSITION3& pos )
|
||||
{
|
||||
m_pos = pos;
|
||||
}
|
||||
|
||||
float Core::Entity::GameObject::getRot() const
|
||||
{
|
||||
return m_rot;
|
||||
}
|
||||
|
||||
void Core::Entity::GameObject::setRot( float rot )
|
||||
{
|
||||
m_rot = rot;
|
||||
}
|
||||
|
||||
bool Core::Entity::GameObject::isPlayer() const
|
||||
{
|
||||
return m_objKind == ObjKind::Player;
|
||||
}
|
||||
|
||||
bool Core::Entity::GameObject::isBNpc() const
|
||||
{
|
||||
return m_objKind == ObjKind::BattleNpc;
|
||||
}
|
||||
|
||||
bool Core::Entity::GameObject::isENpc() const
|
||||
{
|
||||
return m_objKind == ObjKind::EventNpc;
|
||||
}
|
|
@ -50,8 +50,8 @@ namespace Core {
|
|||
ObjKind m_objKind;
|
||||
|
||||
public:
|
||||
GameObject( ObjKind type );
|
||||
virtual ~GameObject() {};
|
||||
explicit GameObject( ObjKind type );
|
||||
//virtual ~GameObject() {};
|
||||
|
||||
uint32_t getId() const;
|
||||
|
||||
|
|
47
src/servers/sapphire_zone/Actor/InstanceObject.cpp
Normal file
47
src/servers/sapphire_zone/Actor/InstanceObject.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "InstanceObject.h"
|
||||
#include "Zone/InstanceContent.h"
|
||||
|
||||
Core::Entity::InstanceObject::InstanceObject( uint32_t objectId, uint32_t hierachyId ) :
|
||||
Core::Entity::GameObject( ObjKind::EventObj ),
|
||||
m_hierachyId( hierachyId )
|
||||
{
|
||||
m_id = objectId;
|
||||
}
|
||||
|
||||
Core::Entity::InstanceObject::InstanceObject( uint32_t objectId, uint32_t hierachyId, Common::FFXIVARR_POSITION3 pos )
|
||||
: InstanceObject( objectId, hierachyId )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Core::Entity::InstanceObject::getHierachyId() const
|
||||
{
|
||||
return m_hierachyId;
|
||||
}
|
||||
|
||||
void Core::Entity::InstanceObject::setHierachyId( uint32_t hierachyId )
|
||||
{
|
||||
m_hierachyId = hierachyId;
|
||||
}
|
||||
|
||||
uint8_t Core::Entity::InstanceObject::getState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void Core::Entity::InstanceObject::setState( uint8_t state )
|
||||
{
|
||||
m_state = state;
|
||||
|
||||
m_parentInstance->updateInstanceObj( InstanceObjectPtr( this ) );
|
||||
}
|
||||
|
||||
void Core::Entity::InstanceObject::setParentInstance( Core::InstanceContentPtr instance )
|
||||
{
|
||||
m_parentInstance = instance;
|
||||
}
|
||||
|
||||
Core::InstanceContentPtr Core::Entity::InstanceObject::getParentInstance() const
|
||||
{
|
||||
return m_parentInstance;
|
||||
}
|
33
src/servers/sapphire_zone/Actor/InstanceObject.h
Normal file
33
src/servers/sapphire_zone/Actor/InstanceObject.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef SAPPHIRE_INSTANCEOBJECT_H
|
||||
#define SAPPHIRE_INSTANCEOBJECT_H
|
||||
|
||||
#include "GameObject.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
namespace Entity
|
||||
{
|
||||
class InstanceObject : public GameObject
|
||||
{
|
||||
public:
|
||||
InstanceObject( uint32_t objectId, uint32_t hierachyId );
|
||||
InstanceObject( uint32_t objectId, uint32_t hierachyId, Common::FFXIVARR_POSITION3 pos );
|
||||
|
||||
uint32_t getHierachyId() const;
|
||||
void setHierachyId( uint32_t hierachyId );
|
||||
|
||||
uint8_t getState() const;
|
||||
void setState( uint8_t state );
|
||||
|
||||
InstanceContentPtr getParentInstance() const;
|
||||
void setParentInstance( InstanceContentPtr instance );
|
||||
|
||||
protected:
|
||||
uint32_t m_hierachyId;
|
||||
uint8_t m_state;
|
||||
InstanceContentPtr m_parentInstance;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //SAPPHIRE_INSTANCEOBJECT_H
|
|
@ -34,6 +34,7 @@ namespace Core
|
|||
TYPE_FORWARD( BattleNpc );
|
||||
TYPE_FORWARD( EventNpc );
|
||||
TYPE_FORWARD( BattleNpcTemplate );
|
||||
TYPE_FORWARD( InstanceObject );
|
||||
}
|
||||
|
||||
namespace Event
|
||||
|
|
|
@ -9,11 +9,19 @@ public:
|
|||
|
||||
void onInit( InstanceContent& instance ) override
|
||||
{
|
||||
auto exit = new Entity::InstanceObject( EXIT_OBJECT, 0, { 0, 0, -10 } );
|
||||
instance.registerInstanceObj( Entity::InstanceObjectPtr( exit ) );
|
||||
|
||||
auto start = new Entity::InstanceObject( START_CIRCLE, 4236868, { 0, 0, 24 } );
|
||||
instance.registerInstanceObj( Entity::InstanceObjectPtr( start ) );
|
||||
}
|
||||
|
||||
void onUpdate( InstanceContent& instance, uint32_t currTime ) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr auto EXIT_OBJECT = 2000139;
|
||||
static constexpr auto START_CIRCLE = 2000182;
|
||||
};
|
|
@ -213,3 +213,33 @@ void Core::InstanceContent::setVar( uint8_t index, uint8_t value )
|
|||
sendDirectorVars( playerIt.second );
|
||||
}
|
||||
}
|
||||
|
||||
void Core::InstanceContent::registerInstanceObj( Core::Entity::InstanceObjectPtr object )
|
||||
{
|
||||
if( !object )
|
||||
return;
|
||||
|
||||
object->setParentInstance( InstanceContentPtr( this ) );
|
||||
|
||||
m_instanceObjects[object->getId()] = object;
|
||||
}
|
||||
|
||||
Core::Entity::InstanceObjectPtr Core::InstanceContent::getInstanceObject( uint32_t objId )
|
||||
{
|
||||
auto obj = m_instanceObjects.find( objId );
|
||||
if( obj == m_instanceObjects.end() )
|
||||
return nullptr;
|
||||
|
||||
return obj->second;
|
||||
}
|
||||
|
||||
void Core::InstanceContent::updateInstanceObj( Core::Entity::InstanceObjectPtr object )
|
||||
{
|
||||
if( !object )
|
||||
return;
|
||||
|
||||
for( const auto& playerId : m_playerMap )
|
||||
{
|
||||
// send that packet with le data
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
#include "Event/Director.h"
|
||||
#include "Forwards.h"
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include "Actor/InstanceObject.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
@ -35,6 +36,9 @@ public:
|
|||
|
||||
void setVar( uint8_t index, uint8_t value );
|
||||
|
||||
void registerInstanceObj( Entity::InstanceObjectPtr object );
|
||||
Entity::InstanceObjectPtr getInstanceObject( uint32_t objId );
|
||||
void updateInstanceObj( Entity::InstanceObjectPtr object );
|
||||
|
||||
Core::Data::ExdDataGenerated::InstanceContentPtr getInstanceContentInfo() const;
|
||||
|
||||
|
@ -48,6 +52,7 @@ private:
|
|||
|
||||
int64_t m_instanceExpireTime;
|
||||
|
||||
std::unordered_map< uint32_t, Core::Entity::InstanceObjectPtr > m_instanceObjects;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue