mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-11-06 15:42:06 +00:00
Merge remote-tracking branch 'origin/main' into grim-lu
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document): Component(parent) {
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) {
|
||||
this->m_Dirty = true;
|
||||
this->m_Equipped = {};
|
||||
this->m_Pushed = {};
|
||||
@@ -116,6 +116,9 @@ Inventory* InventoryComponent::GetInventory(const eInventoryType type) {
|
||||
case eInventoryType::VENDOR_BUYBACK:
|
||||
size = 27u;
|
||||
break;
|
||||
case eInventoryType::DONATION:
|
||||
size = 24u;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -797,7 +800,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) {
|
||||
}
|
||||
}
|
||||
|
||||
void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate, unsigned& flags) {
|
||||
void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate) {
|
||||
if (bIsInitialUpdate || m_Dirty) {
|
||||
outBitStream->Write(true);
|
||||
|
||||
@@ -855,10 +858,6 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b
|
||||
outBitStream->Write(false);
|
||||
}
|
||||
|
||||
void InventoryComponent::ResetFlags() {
|
||||
m_Dirty = false;
|
||||
}
|
||||
|
||||
void InventoryComponent::Update(float deltaTime) {
|
||||
for (auto* set : m_Itemsets) {
|
||||
set->Update(deltaTime);
|
||||
@@ -914,18 +913,26 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
if (character != nullptr && !skipChecks) {
|
||||
// Hacky proximity rocket
|
||||
if (item->GetLot() == 6416) {
|
||||
const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCH);
|
||||
const auto rocketLauchPads = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCH);
|
||||
|
||||
const auto position = m_Parent->GetPosition();
|
||||
|
||||
for (auto* lauchPad : rocketLauchPads) {
|
||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
for (auto* launchPad : rocketLauchPads) {
|
||||
if (!launchPad) continue;
|
||||
|
||||
auto prereq = launchPad->GetVarAsString(u"rocketLaunchPreCondition");
|
||||
if (!prereq.empty()) {
|
||||
PreconditionExpression expression(prereq);
|
||||
if (!expression.Check(m_Parent)) continue;
|
||||
}
|
||||
|
||||
if (Vector3::DistanceSquared(launchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
|
||||
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
|
||||
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
||||
|
||||
lauchPad->OnUse(m_Parent);
|
||||
launchPad->OnUse(m_Parent);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -967,7 +974,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
|
||||
EquipScripts(item);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void InventoryComponent::UnEquipItem(Item* item) {
|
||||
@@ -997,12 +1004,12 @@ void InventoryComponent::UnEquipItem(Item* item) {
|
||||
|
||||
UnequipScripts(item);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Trigger property event
|
||||
if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) {
|
||||
PropertyManagementComponent::Instance()->GetParent()->OnZonePropertyModelRemovedWhileEquipped(m_Parent);
|
||||
dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_Parent);
|
||||
Game::zoneManager->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,7 +1055,7 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
if (possessorComponent->GetIsDismounting()) return;
|
||||
|
||||
// Check to see if we are already mounting something
|
||||
auto* currentlyPossessedEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||
auto* currentlyPossessedEntity = Game::entityManager->GetEntity(possessorComponent->GetPossessable());
|
||||
auto currentlyPossessedItem = possessorComponent->GetMountItemID();
|
||||
|
||||
if (currentlyPossessedItem) {
|
||||
@@ -1071,21 +1078,11 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
info.rot = startRotation;
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
|
||||
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent);
|
||||
auto* mount = Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
||||
|
||||
// Check to see if the mount is a vehicle, if so, flip it
|
||||
auto* vehicleComponent = mount->GetComponent<VehiclePhysicsComponent>();
|
||||
if (vehicleComponent) {
|
||||
auto angles = startRotation.GetEulerAngles();
|
||||
// Make it right side up
|
||||
angles.x -= PI;
|
||||
// Make it going in the direction of the player
|
||||
angles.y -= PI;
|
||||
startRotation = NiQuaternion::FromEulerAngles(angles);
|
||||
mount->SetRotation(startRotation);
|
||||
// We're pod racing now
|
||||
characterComponent->SetIsRacing(true);
|
||||
}
|
||||
if (vehicleComponent) characterComponent->SetIsRacing(true);
|
||||
|
||||
// Setup the destroyable stats
|
||||
auto* destroyableComponent = mount->GetComponent<DestroyableComponent>();
|
||||
@@ -1106,9 +1103,9 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
GameMessages::SendSetJetPackMode(m_Parent, false);
|
||||
|
||||
// Make it go to the client
|
||||
EntityManager::Instance()->ConstructEntity(mount);
|
||||
Game::entityManager->ConstructEntity(mount);
|
||||
// Update the possessor
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// have to unlock the input so it vehicle can be driven
|
||||
if (vehicleComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress());
|
||||
@@ -1190,7 +1187,7 @@ void InventoryComponent::PopEquippedItems() {
|
||||
destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
|
||||
destroyableComponent->SetArmor(static_cast<int32_t>(destroyableComponent->GetMaxArmor()));
|
||||
destroyableComponent->SetImagination(static_cast<int32_t>(destroyableComponent->GetMaxImagination()));
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
m_Dirty = true;
|
||||
@@ -1510,7 +1507,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
info.rot = NiQuaternion::IDENTITY;
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
|
||||
auto* pet = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* pet = Game::entityManager->CreateEntity(info);
|
||||
|
||||
auto* petComponent = pet->GetComponent<PetComponent>();
|
||||
|
||||
@@ -1518,7 +1515,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
petComponent->Activate(item);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(pet);
|
||||
Game::entityManager->ConstructEntity(pet);
|
||||
}
|
||||
|
||||
void InventoryComponent::SetDatabasePet(LWOOBJID id, const DatabasePet& data) {
|
||||
@@ -1627,7 +1624,7 @@ void InventoryComponent::SetNPCItems(const std::vector<LOT>& items) {
|
||||
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item), 1, slot++ }, true);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
InventoryComponent::~InventoryComponent() {
|
||||
|
||||
Reference in New Issue
Block a user