mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
commit when car work
This commit is contained in:
parent
42f6f2f10b
commit
6c5c6b7b8e
@ -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<eItemType>(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<DestroyableComponent>();
|
||||
|
||||
// // Setup the vehicle stats.
|
||||
// if (destroyableComponent != nullptr) {
|
||||
// destroyableComponent->SetMaxImagination(60);
|
||||
// destroyableComponent->SetImagination(0);
|
||||
// destroyableComponent->SetIsImmune(true);
|
||||
// }
|
||||
|
||||
auto* possessableComponent = carEntity->GetComponent<PossessableComponent>();
|
||||
|
||||
@ -929,7 +948,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks)
|
||||
|
||||
auto* moduleAssemblyComponent = carEntity->GetComponent<ModuleAssemblyComponent>();
|
||||
|
||||
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<Player *>(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<Player *>(m_Parent);
|
||||
// playerInstance->SendToZone(1200);
|
||||
|
||||
// equippedCarEntity->Kill();
|
||||
// return;
|
||||
// }
|
||||
if (!item->IsEquipped())
|
||||
{
|
||||
return;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user