mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
yard object spawning (mostly) working
This commit is contained in:
parent
fab6a27354
commit
99d52f18f1
6 changed files with 104 additions and 9 deletions
|
@ -4,12 +4,12 @@ Sapphire::Inventory::HousingItem::HousingItem( uint64_t uId, uint32_t catalogId
|
|||
Sapphire::Item( uId, catalogId, false )
|
||||
{ }
|
||||
|
||||
float Sapphire::Inventory::HousingItem::getRot() const
|
||||
uint16_t Sapphire::Inventory::HousingItem::getRot() const
|
||||
{
|
||||
return m_rotation;
|
||||
}
|
||||
|
||||
void Sapphire::Inventory::HousingItem::setRot( float rot )
|
||||
void Sapphire::Inventory::HousingItem::setRot( uint16_t rot )
|
||||
{
|
||||
m_rotation = rot;
|
||||
}
|
||||
|
|
|
@ -9,16 +9,17 @@ namespace Sapphire::Inventory
|
|||
{
|
||||
public:
|
||||
HousingItem( uint64_t uId, uint32_t catalogId );
|
||||
virtual ~HousingItem() = default;
|
||||
|
||||
void setRot( float rot );
|
||||
float getRot() const;
|
||||
void setRot( uint16_t rot );
|
||||
uint16_t getRot() const;
|
||||
|
||||
void setPos( Common::FFXIVARR_POSITION3 pos );
|
||||
Common::FFXIVARR_POSITION3 getPos() const;
|
||||
|
||||
private:
|
||||
Common::FFXIVARR_POSITION3 m_position;
|
||||
float m_rotation;
|
||||
uint16_t m_rotation;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Sapphire
|
|||
public:
|
||||
Item( uint64_t uId, uint32_t catalogId, bool isHq = false );
|
||||
|
||||
~Item() = default;
|
||||
virtual ~Item() = default;
|
||||
|
||||
uint32_t getId() const;
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories()
|
|||
res->getFloat( "PosZ" )
|
||||
} );
|
||||
|
||||
item->setRot( res->getFloat( "Rotation" ) );
|
||||
item->setRot( res->getUInt( "Rotation" ) );
|
||||
}
|
||||
|
||||
ContainerIdToContainerMap& estateInv = m_estateInventories[ ident ];
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "Actor/EventObject.h"
|
||||
#include "Land.h"
|
||||
#include "House.h"
|
||||
#include "Inventory/HousingItem.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "HousingZone.h"
|
||||
|
@ -51,7 +53,7 @@ bool Sapphire::HousingZone::init()
|
|||
}
|
||||
|
||||
|
||||
int housingIndex;
|
||||
uint32_t housingIndex = 0;
|
||||
if( m_territoryTypeId == 339 )
|
||||
housingIndex = 0;
|
||||
else if( m_territoryTypeId == 340 )
|
||||
|
@ -64,6 +66,44 @@ bool Sapphire::HousingZone::init()
|
|||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Sapphire::Data::HousingLandSet >( housingIndex );
|
||||
|
||||
// build yard objects array indices
|
||||
int16_t cursor = -1;
|
||||
uint16_t index = 0;
|
||||
for( const auto size : info->plotSize )
|
||||
{
|
||||
uint16_t itemMax = 0;
|
||||
switch( size )
|
||||
{
|
||||
case 0:
|
||||
itemMax = 20;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
itemMax = 30;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
itemMax = 40;
|
||||
break;
|
||||
}
|
||||
|
||||
int16_t start = cursor + 1;
|
||||
int16_t end = cursor + itemMax;
|
||||
|
||||
m_yardObjectArrayBounds[ index++ ] = std::make_pair( start, end );
|
||||
|
||||
// reset cursor for subdivision
|
||||
if( index == 30 )
|
||||
{
|
||||
cursor = -1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
cursor += itemMax;
|
||||
}
|
||||
|
||||
|
||||
auto housingMgr = g_fw.get< World::Manager::HousingMgr >();
|
||||
auto landCache = housingMgr->getLandCacheMap();
|
||||
|
||||
|
@ -83,7 +123,8 @@ bool Sapphire::HousingZone::init()
|
|||
// setup house
|
||||
if( entry.m_houseId )
|
||||
{
|
||||
auto house = make_House( entry.m_houseId, m_landSetId, land->getLandIdent(), entry.m_estateName, entry.m_estateComment );
|
||||
auto house = make_House( entry.m_houseId, m_landSetId, land->getLandIdent(), entry.m_estateName,
|
||||
entry.m_estateComment );
|
||||
|
||||
housingMgr->updateHouseModels( house );
|
||||
land->setHouse( house );
|
||||
|
@ -95,6 +136,32 @@ bool Sapphire::HousingZone::init()
|
|||
|
||||
if( entry.m_houseId > 0 )
|
||||
registerEstateEntranceEObj( entry.m_landId );
|
||||
|
||||
// add items to yard object array
|
||||
auto& inventory = housingMgr->getEstateInventory( land->getLandIdent() );
|
||||
auto& externalContainer = inventory[ InventoryType::HousingExteriorPlacedItems ];
|
||||
|
||||
auto arrayBounds = m_yardObjectArrayBounds[ entry.m_landId ];
|
||||
uint8_t yardMapIndex = entry.m_landId <= 29 ? 0 : 1;
|
||||
|
||||
for( auto& item : externalContainer->getItemMap() )
|
||||
{
|
||||
Common::YardObject obj{};
|
||||
|
||||
auto housingItem = std::dynamic_pointer_cast< Inventory::HousingItem >( item.second );
|
||||
assert( housingItem );
|
||||
|
||||
auto pos = housingItem->getPos();
|
||||
|
||||
obj.itemId = housingItem->getAdditionalData();
|
||||
obj.itemRotation = housingItem->getRot();
|
||||
|
||||
obj.pos_x = Util::floatToUInt16( pos.x );
|
||||
obj.pos_y = Util::floatToUInt16( pos.y );
|
||||
obj.pos_z = Util::floatToUInt16( pos.z );
|
||||
|
||||
m_yardObjects[ yardMapIndex ][ item.first + arrayBounds.first ] = obj;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -274,3 +341,16 @@ Sapphire::Entity::EventObjectPtr Sapphire::HousingZone::registerEstateEntranceEO
|
|||
|
||||
return eObj;
|
||||
}
|
||||
|
||||
void Sapphire::HousingZone::updateYardObjects( Sapphire::Common::LandIdent ident )
|
||||
{
|
||||
auto housingMgr = g_fw.get< World::Manager::HousingMgr >();
|
||||
auto& landStorage = housingMgr->getEstateInventory( ident );
|
||||
|
||||
auto yardContainer = landStorage[ InventoryType::HousingExteriorPlacedItems ];
|
||||
|
||||
for( const auto& item : yardContainer->getItemMap() )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -52,13 +52,26 @@ namespace Sapphire
|
|||
|
||||
Entity::EventObjectPtr registerEstateEntranceEObj( uint8_t landId );
|
||||
|
||||
void updateYardObjects( Common::LandIdent ident );
|
||||
|
||||
private:
|
||||
using LandPtrMap = std::unordered_map< uint8_t, Sapphire::LandPtr >;
|
||||
using YardObjectArray = std::array< Common::YardObject, 800 >;
|
||||
using YardObjectMap = std::map< uint8_t, YardObjectArray >;
|
||||
|
||||
/*!
|
||||
* @brief Maps the start and end index of the yard object array for a specific plot
|
||||
*
|
||||
* pair.first = start index
|
||||
* pair.second = end index
|
||||
*/
|
||||
using YardObjectArrayBoundsPair = std::pair< uint16_t, uint16_t >;
|
||||
|
||||
/*!
|
||||
* @brief Maps each plot to a YardObjectArrayBoundsPair to the start/end index of the yard object array.
|
||||
*/
|
||||
using YardObjectArrayBoundsArray = std::array< YardObjectArrayBoundsPair, 60 >;
|
||||
|
||||
const uint32_t m_landSetMax = 18;
|
||||
LandPtrMap m_landPtrMap;
|
||||
uint8_t m_wardNum;
|
||||
|
@ -66,6 +79,7 @@ namespace Sapphire
|
|||
uint32_t m_territoryTypeId;
|
||||
|
||||
YardObjectMap m_yardObjects;
|
||||
YardObjectArrayBoundsArray m_yardObjectArrayBounds;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue