From 6c5c6b7b8e8896105021e7abcfe0e1092ff232f1 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 9 Feb 2022 21:21:10 -0800 Subject: [PATCH] commit when car work --- dGame/dComponents/InventoryComponent.cpp | 64 ++++++++++++++++++++---- dGame/dComponents/InventoryComponent.h | 6 +++ 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 922b2de3..359ea458 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -23,6 +23,7 @@ #include "CharacterComponent.h" #include "dZoneManager.h" #include "PropertyManagementComponent.h" +#include "DestroyableComponent.h" InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) { @@ -909,16 +910,34 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) const auto type = static_cast(item->GetInfo().itemType); - if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) + if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == false) { + auto startPosition = m_Parent->GetPosition() + NiPoint3::UNIT_Y + 10; + + auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X); + auto angles = startRotation.GetEulerAngles(); + angles.y -= M_PI; + startRotation = NiQuaternion::FromEulerAngles(angles); + + GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); + EntityInfo info {}; info.lot = 8092; - info.pos = m_Parent->GetPosition(); - info.rot = m_Parent->GetRotation(); + info.pos = startPosition; + info.rot = startRotation; info.spawnerID = m_Parent->GetObjectID(); - auto* carEntity = EntityManager::Instance()->CreateEntity(info, nullptr, dZoneManager::Instance()->GetZoneControlObject()); - dZoneManager::Instance()->GetZoneControlObject()->AddChild(carEntity); + auto* carEntity = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent); + m_Parent->AddChild(carEntity); + + // auto *destroyableComponent = carEntity->GetComponent(); + + // // Setup the vehicle stats. + // if (destroyableComponent != nullptr) { + // destroyableComponent->SetMaxImagination(60); + // destroyableComponent->SetImagination(0); + // destroyableComponent->SetIsImmune(true); + // } auto* possessableComponent = carEntity->GetComponent(); @@ -929,7 +948,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) auto* moduleAssemblyComponent = carEntity->GetComponent(); - if (moduleAssemblyComponent) + if (moduleAssemblyComponent != nullptr) { moduleAssemblyComponent->SetSubKey(item->GetSubKey()); moduleAssemblyComponent->SetUseOptionalParts(false); @@ -960,14 +979,33 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) EntityManager::Instance()->ConstructEntity(carEntity); EntityManager::Instance()->SerializeEntity(m_Parent); - //EntityManager::Instance()->SerializeEntity(dZoneManager::Instance()->GetZoneControlObject()); + GameMessages::SendSetJetPackMode(m_Parent, false); - GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(), m_Parent->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendRacingPlayerLoaded(m_Parent->GetObjectID(), m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendRacingPlayerLoaded(m_Parent->GetObjectID(), m_Parent->GetObjectID(), carEntity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendVehicleUnlockInput(carEntity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); - //GameMessages::SendVehicleSetWheelLockState(carEntity->GetObjectID(), false, false, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendTeleport(m_Parent->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); + GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition, startRotation, m_Parent->GetSystemAddress(), true, true); + EntityManager::Instance()->SerializeEntity(m_Parent); + // m_Parent->AddDieCallback([item, this](){ + // this->UnEquipItem(item); + // this->EquipItem(item); + // }); + // carEntity->AddDieCallback([item, this](){ + // this->UnEquipItem(item); + // this->EquipItem(item); + // }); + hasCarEquipped = true; + equippedCarEntity = carEntity; return; + } else if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) + { + // auto *playerInstance = dynamic_cast(m_Parent); + // playerInstance->SendToZone(1200); + + // equippedCarEntity->Kill(); } if (!building) @@ -1019,6 +1057,14 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) void InventoryComponent::UnEquipItem(Item* item) { + // if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == true) + // { + // auto *playerInstance = dynamic_cast(m_Parent); + // playerInstance->SendToZone(1200); + + // equippedCarEntity->Kill(); + // return; + // } if (!item->IsEquipped()) { return; diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 7082cfff..f337ae8b 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -15,6 +15,7 @@ #include "Component.h" #include "ItemSetPassiveAbility.h" #include "ItemSetPassiveAbilityID.h" +#include "PossessorComponent.h" class Entity; class ItemSet; @@ -384,6 +385,11 @@ private: */ LOT m_Consumable; + /** + * Currently has a car equipped + */ + bool hasCarEquipped = false; + Entity* equippedCarEntity = nullptr; /** * Creates all the proxy items (subitems) for a parent item * @param parent the parent item to generate all the subitems for