mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-01-24 05:37:41 +00:00
removed unnccessary work
This commit is contained in:
parent
5eb801eb12
commit
e73793c1a3
@ -263,29 +263,12 @@ void PetComponent::OnUse(Entity* originator)
|
|||||||
|
|
||||||
auto position = originatorPosition;
|
auto position = originatorPosition;
|
||||||
|
|
||||||
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector(); //m_Parent->GetRotation().GetForwardVector();
|
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector();
|
||||||
forward.y = 0;
|
forward.y = 0;
|
||||||
|
|
||||||
if (dpWorld::Instance().IsLoaded())
|
if (dpWorld::Instance().IsLoaded())
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (interactionDistance > 2)
|
|
||||||
{
|
|
||||||
interactionDistance -= 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
NiPoint3 attempt = petPosition + forward * interactionDistance;
|
NiPoint3 attempt = petPosition + forward * interactionDistance;
|
||||||
|
|
||||||
/*
|
|
||||||
float deg = std::atan2(petPosition.z - originatorPosition.z, petPosition.x - originatorPosition.x); //* 180 / M_PI;
|
|
||||||
|
|
||||||
auto position = NiPoint3(
|
|
||||||
petPosition.x + interactionDistance * std::cos(-deg),
|
|
||||||
petPosition.y,
|
|
||||||
petPosition.z + interactionDistance * std::sin(-deg)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
float y = dpWorld::Instance().GetHeightAtPoint(attempt);
|
float y = dpWorld::Instance().GetHeightAtPoint(attempt);
|
||||||
|
|
||||||
@ -309,8 +292,6 @@ void PetComponent::OnUse(Entity* originator)
|
|||||||
|
|
||||||
|
|
||||||
auto rotation = NiQuaternion::LookAt(position, petPosition);
|
auto rotation = NiQuaternion::LookAt(position, petPosition);
|
||||||
|
|
||||||
//GameMessages::SendTeleport(originator->GetObjectID(), position, rotation, originator->GetSystemAddress(), true);
|
|
||||||
|
|
||||||
GameMessages::SendNotifyPetTamingMinigame(
|
GameMessages::SendNotifyPetTamingMinigame(
|
||||||
originator->GetObjectID(),
|
originator->GetObjectID(),
|
||||||
@ -532,14 +513,12 @@ void PetComponent::Update(float deltaTime)
|
|||||||
m_Timer = 1;
|
m_Timer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::TryBuild(std::vector<Brick>& bricks, bool clientFailed)
|
void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||||
{
|
|
||||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||||
|
|
||||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||||
|
|
||||||
if (tamer == nullptr)
|
if (tamer == nullptr) {
|
||||||
{
|
|
||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -547,19 +526,11 @@ void PetComponent::TryBuild(std::vector<Brick>& bricks, bool clientFailed)
|
|||||||
|
|
||||||
const auto& cached = buildCache.find(m_Parent->GetLOT());
|
const auto& cached = buildCache.find(m_Parent->GetLOT());
|
||||||
|
|
||||||
if (cached == buildCache.end())
|
if (cached == buildCache.end()) return;
|
||||||
{
|
|
||||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, false, 0, tamer->GetSystemAddress());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* destroyableComponent = tamer->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = tamer->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyableComponent == nullptr)
|
if (destroyableComponent == nullptr) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto imagination = destroyableComponent->GetImagination();
|
auto imagination = destroyableComponent->GetImagination();
|
||||||
|
|
||||||
@ -569,59 +540,17 @@ void PetComponent::TryBuild(std::vector<Brick>& bricks, bool clientFailed)
|
|||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(tamer);
|
EntityManager::Instance()->SerializeEntity(tamer);
|
||||||
|
|
||||||
const auto& trueBricks = BrickDatabase::Instance()->GetBricks(cached->second.buildFile);
|
if (clientFailed) {
|
||||||
|
if (imagination < cached->second.imaginationCost) {
|
||||||
if (trueBricks.empty() || bricks.empty())
|
|
||||||
{
|
|
||||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, false, 0, tamer->GetSystemAddress());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* brickIDTable = CDClientManager::Instance()->GetTable<CDBrickIDTableTable>("BrickIDTable");
|
|
||||||
|
|
||||||
int32_t correct = 0;
|
|
||||||
|
|
||||||
for (const auto& brick : bricks)
|
|
||||||
{
|
|
||||||
const auto brickEntries = brickIDTable->Query([brick](const CDBrickIDTable& entry)
|
|
||||||
{
|
|
||||||
return entry.NDObjectID == brick.designerID;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (brickEntries.empty())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto designerID = brickEntries[0].LEGOBrickID;
|
|
||||||
|
|
||||||
for (const auto& trueBrick : trueBricks)
|
|
||||||
{
|
|
||||||
if (designerID == trueBrick.designerID && brick.materialID == trueBrick.materialID)
|
|
||||||
{
|
|
||||||
correct++;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto success = correct >= cached->second.numValidPieces;
|
|
||||||
|
|
||||||
GameMessages::SendPetTamingTryBuildResult(m_Tamer, success, correct, tamer->GetSystemAddress());
|
|
||||||
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
if (imagination < cached->second.imaginationCost)
|
|
||||||
{
|
|
||||||
ClientFailTamingMinigame();
|
ClientFailTamingMinigame();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (numBricks == 0) return;
|
||||||
|
|
||||||
|
GameMessages::SendPetTamingTryBuildResult(m_Tamer, !clientFailed, numBricks, tamer->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
|
void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
|
||||||
@ -727,7 +656,6 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
|
|||||||
|
|
||||||
if (missionComponent != nullptr)
|
if (missionComponent != nullptr)
|
||||||
{
|
{
|
||||||
//missionComponent->ForceProgress(506, 768, 1, false);
|
|
||||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PET_TAMING, m_Parent->GetLOT());
|
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PET_TAMING, m_Parent->GetLOT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user