2016-04-20 21:07:18 +00:00
|
|
|
#include "CScriptWorldTeleporter.hpp"
|
2017-08-08 22:12:14 +00:00
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CWorldTransManager.hpp"
|
|
|
|
#include "CWorld.hpp"
|
|
|
|
#include "CGameState.hpp"
|
|
|
|
#include "IMain.hpp"
|
|
|
|
#include "TCastTo.hpp"
|
2016-04-20 21:07:18 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2017-07-30 11:00:30 +00:00
|
|
|
CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
2017-08-13 05:26:14 +00:00
|
|
|
bool active, CAssetId worldId, CAssetId areaId)
|
2017-07-30 11:00:30 +00:00
|
|
|
: CEntity(uid, info, active, name)
|
2017-08-08 22:12:14 +00:00
|
|
|
, x34_worldId(worldId)
|
|
|
|
, x38_areaId(areaId)
|
|
|
|
, x3c_type(ETeleporterType::NoTransition)
|
|
|
|
, x40_24_upElevator(false)
|
|
|
|
, x40_25_inTransition(false)
|
|
|
|
, x40_27_fadeWhite(false)
|
2017-07-30 11:00:30 +00:00
|
|
|
{
|
|
|
|
}
|
2017-08-08 22:12:14 +00:00
|
|
|
|
|
|
|
CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
2017-08-13 05:26:14 +00:00
|
|
|
bool active, CAssetId worldId, CAssetId areaId,
|
|
|
|
CAssetId playerAncs, u32 charIdx, u32 defaultAnim,
|
|
|
|
const zeus::CVector3f& playerScale, CAssetId platformModel,
|
|
|
|
const zeus::CVector3f& platformScale, CAssetId backgroundModel,
|
2017-08-08 22:12:14 +00:00
|
|
|
const zeus::CVector3f& backgroundScale, bool upElevator, u16 soundId,
|
|
|
|
u8 volume, u8 panning)
|
|
|
|
: CEntity(uid, info, active, name)
|
|
|
|
, x34_worldId(worldId)
|
|
|
|
, x38_areaId(areaId)
|
|
|
|
, x3c_type(ETeleporterType::Elevator)
|
|
|
|
, x40_24_upElevator(upElevator)
|
|
|
|
, x40_25_inTransition(false)
|
|
|
|
, x40_27_fadeWhite(false)
|
|
|
|
, x50_playerAnim(playerAncs, charIdx, defaultAnim)
|
|
|
|
, x5c_playerScale(playerScale)
|
|
|
|
, x68_platformModel(platformModel)
|
|
|
|
, x6c_platformScale(platformScale)
|
|
|
|
, x78_backgroundModel(backgroundModel)
|
|
|
|
, x7c_backgroundScale(backgroundScale)
|
|
|
|
, x88_soundId(CSfxManager::TranslateSFXID(soundId))
|
|
|
|
, x8a_volume(volume)
|
|
|
|
, x8b_panning(panning)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
2017-08-13 05:26:14 +00:00
|
|
|
bool active, CAssetId worldId, CAssetId areaId, u16 soundId, u8 volume,
|
|
|
|
u8 panning, CAssetId fontId, CAssetId stringId, bool fadeWhite,
|
2017-08-08 22:12:14 +00:00
|
|
|
float charFadeIn, float charsPerSecond, float showDelay)
|
|
|
|
: CEntity(uid, info, active, name)
|
|
|
|
, x34_worldId(worldId)
|
|
|
|
, x38_areaId(areaId)
|
|
|
|
, x3c_type(ETeleporterType::Text)
|
|
|
|
, x40_24_upElevator(false)
|
|
|
|
, x40_25_inTransition(false)
|
|
|
|
, x40_27_fadeWhite(fadeWhite)
|
|
|
|
, x44_charFadeIn(charFadeIn)
|
|
|
|
, x48_charsPerSecond(charsPerSecond)
|
|
|
|
, x4c_showDelay(showDelay)
|
|
|
|
, x88_soundId(CSfxManager::TranslateSFXID(soundId))
|
|
|
|
, x8a_volume(volume)
|
|
|
|
, x8b_panning(panning)
|
|
|
|
, x8c_fontId(fontId)
|
|
|
|
, x90_stringId(stringId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptWorldTeleporter::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptWorldTeleporter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (GetActive())
|
|
|
|
{
|
|
|
|
const std::shared_ptr<CWorldTransManager>& transMgr = mgr.WorldTransManager();
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case EScriptObjectMessage::Stop:
|
|
|
|
x40_25_inTransition = false;
|
|
|
|
transMgr->DisableTransition();
|
|
|
|
transMgr->SfxStop();
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Play:
|
|
|
|
StartTransition(mgr);
|
|
|
|
transMgr->SetSfx(x88_soundId, x8a_volume, x8b_panning);
|
|
|
|
transMgr->SfxStart();
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::SetToZero:
|
|
|
|
{
|
|
|
|
const auto& world = mgr.WorldNC();
|
|
|
|
world->SetPauseState(true);
|
2017-08-13 05:26:14 +00:00
|
|
|
CAssetId currentWorld = g_GameState->CurrentWorldAssetId();
|
2017-08-08 22:12:14 +00:00
|
|
|
|
|
|
|
if (g_ResFactory->GetResourceTypeById(currentWorld) == SBIG('MLVL'))
|
|
|
|
{
|
|
|
|
StartTransition(mgr);
|
|
|
|
g_GameState->SetCurrentWorldId(x34_worldId);
|
|
|
|
g_GameState->CurrentWorldState().SetDesiredAreaAssetId(x38_areaId);
|
|
|
|
g_Main->SetFlowState(EFlowState::None);
|
|
|
|
mgr.SetShouldQuitGame(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x40_25_inTransition = false;
|
|
|
|
transMgr->DisableTransition();
|
|
|
|
g_GameState->SetCurrentWorldId(currentWorld);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CEntity::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptWorldTeleporter::StartTransition(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (!x40_25_inTransition)
|
|
|
|
{
|
|
|
|
const auto& transMgr = mgr.WorldTransManager();
|
|
|
|
switch(x3c_type)
|
|
|
|
{
|
|
|
|
case ETeleporterType::NoTransition:
|
|
|
|
transMgr->DisableTransition();
|
|
|
|
break;
|
|
|
|
case ETeleporterType::Elevator:
|
2017-08-13 05:26:14 +00:00
|
|
|
if (x50_playerAnim.GetACSFile().IsValid() && x50_playerAnim.GetCharacter() != -1)
|
2017-08-08 22:12:14 +00:00
|
|
|
{
|
|
|
|
transMgr->EnableTransition(CAnimRes(x50_playerAnim.GetACSFile(), x50_playerAnim.GetCharacter(),
|
|
|
|
x5c_playerScale, x50_playerAnim.GetInitialAnimation(),true),
|
|
|
|
x68_platformModel, x6c_platformScale, x78_backgroundModel,
|
|
|
|
x7c_backgroundScale, x40_24_upElevator);
|
|
|
|
x40_25_inTransition = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ETeleporterType::Text:
|
|
|
|
transMgr->EnableTransition(x8c_fontId, x90_stringId, 0, x40_27_fadeWhite, x44_charFadeIn, x48_charsPerSecond,
|
|
|
|
x4c_showDelay);
|
|
|
|
x40_25_inTransition = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-20 21:07:18 +00:00
|
|
|
}
|