2021-12-05 17:54:36 +00:00
|
|
|
#include "NtAssemblyTubeServer.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
|
|
|
#include "eMissionTaskType.h"
|
|
|
|
#include "eMissionState.h"
|
2023-03-20 13:10:52 +00:00
|
|
|
#include "RenderComponent.h"
|
2023-03-25 10:26:39 +00:00
|
|
|
#include "eEndBehavior.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eStateChangeType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void NtAssemblyTubeServer::OnStartup(Entity* self) {
|
|
|
|
self->SetProximityRadius(5, "teleport");
|
|
|
|
}
|
|
|
|
|
|
|
|
void NtAssemblyTubeServer::OnPlayerLoaded(Entity* self, Entity* player) {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NtAssemblyTubeServer::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
|
|
|
if (status != "ENTER" || !entering->IsPlayer() || name != "teleport") return;
|
|
|
|
|
|
|
|
auto* player = entering;
|
|
|
|
const auto playerID = player->GetObjectID();
|
|
|
|
|
|
|
|
RunAssemblyTube(self, player);
|
|
|
|
|
|
|
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
|
|
|
|
|
|
|
if (missionComponent != nullptr) {
|
|
|
|
missionComponent->Progress(eMissionTaskType::SCRIPT, self->GetLOT());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NtAssemblyTubeServer::RunAssemblyTube(Entity* self, Entity* player) {
|
|
|
|
const auto playerID = player->GetObjectID();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto iter = m_TeleportingPlayerTable.find(playerID);
|
|
|
|
if (iter == m_TeleportingPlayerTable.end()) m_TeleportingPlayerTable[playerID] = false;
|
|
|
|
const auto bPlayerBeingTeleported = m_TeleportingPlayerTable[playerID];
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (player->IsPlayer() && !bPlayerBeingTeleported) {
|
|
|
|
auto teleCinematic = self->GetVar<std::u16string>(u"Cinematic");
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
GameMessages::SendSetStunned(playerID, eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
|
2021-12-05 17:54:36 +00:00
|
|
|
true, true, true, true, true, true, true
|
|
|
|
);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!teleCinematic.empty()) {
|
|
|
|
const auto teleCinematicUname = teleCinematic;
|
|
|
|
GameMessages::SendPlayCinematic(player->GetObjectID(), teleCinematicUname, player->GetSystemAddress(),
|
2023-03-25 10:26:39 +00:00
|
|
|
true, true, true, false, eEndBehavior::RETURN, false, -1, false, true
|
2021-12-05 17:54:36 +00:00
|
|
|
);
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(player, u"tube-sucker", 4.0f);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto animTime = 3;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddCallbackTimer(animTime, [this, self, playerID]() {
|
|
|
|
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (player == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
TeleportPlayer(self, player);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NtAssemblyTubeServer::TeleportPlayer(Entity* self, Entity* player) {
|
|
|
|
auto destinationGroup = self->GetVar<std::u16string>(u"teleGroup");
|
|
|
|
auto* destination = self;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!destinationGroup.empty()) {
|
|
|
|
const auto& groupObjs = EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
|
|
|
|
|
|
|
|
if (!groupObjs.empty()) {
|
|
|
|
destination = groupObjs[0];
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
const auto destPosition = destination->GetPosition();
|
|
|
|
const auto destRotation = destination->GetRotation();
|
|
|
|
|
|
|
|
GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true);
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(player, u"tube-resurrect", 4.0f);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
const auto animTime = 2;
|
|
|
|
|
2021-12-22 03:51:38 +00:00
|
|
|
const auto playerID = player->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
self->AddCallbackTimer(animTime, [this, self, playerID]() {
|
|
|
|
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
|
|
|
|
|
|
|
if (player == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnlockPlayer(self, player);
|
|
|
|
});
|
|
|
|
|
|
|
|
const auto useSound = self->GetVar<std::string>(u"sound1");
|
|
|
|
|
|
|
|
if (!useSound.empty()) {
|
|
|
|
GameMessages::SendPlayNDAudioEmitter(player, player->GetSystemAddress(), useSound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NtAssemblyTubeServer::UnlockPlayer(Entity* self, Entity* player) {
|
|
|
|
const auto playerID = player->GetObjectID();
|
|
|
|
|
|
|
|
m_TeleportingPlayerTable[playerID] = false;
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
GameMessages::SendSetStunned(playerID, eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY,
|
2021-12-05 17:54:36 +00:00
|
|
|
true, true, true, true, true, true, true
|
|
|
|
);
|
|
|
|
}
|