2016-04-27 00:21:08 +00:00
|
|
|
#include "CScriptSpawnPoint.hpp"
|
2017-01-07 01:58:05 +00:00
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CWorld.hpp"
|
|
|
|
#include "CPlayer.hpp"
|
2017-02-12 04:43:33 +00:00
|
|
|
#include "Particle/CGenDescription.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-04-27 00:21:08 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2018-01-06 06:50:42 +00:00
|
|
|
CScriptSpawnPoint::CScriptSpawnPoint(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
const rstl::reserved_vector<u32, int(CPlayerState::EItemType::Max)>& itemCounts,
|
|
|
|
bool defaultSpawn, bool active, bool morphed)
|
2016-08-14 21:11:44 +00:00
|
|
|
: CEntity(uid, info, active, name), x34_xf(xf), x64_itemCounts(itemCounts)
|
2016-04-27 00:21:08 +00:00
|
|
|
{
|
2018-09-10 01:04:57 +00:00
|
|
|
#ifndef NDEBUG
|
2018-10-11 22:57:05 +00:00
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::GravitySuit)] = 1;
|
2018-01-07 05:19:49 +00:00
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::ThermalVisor)] = 1;
|
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::XRayVisor)] = 1;
|
2018-06-16 02:26:58 +00:00
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::GrappleBeam)] = 1;
|
2018-06-22 03:08:47 +00:00
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::BoostBall)] = 1;
|
2018-06-24 02:39:53 +00:00
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::ChargeBeam)] = 1;
|
2018-10-11 22:57:05 +00:00
|
|
|
x64_itemCounts[int(CPlayerState::EItemType::PowerBombs)] = 8;
|
2018-09-10 01:04:57 +00:00
|
|
|
#endif
|
2016-08-14 21:11:44 +00:00
|
|
|
x10c_24_firstSpawn = defaultSpawn;
|
2017-01-07 01:58:05 +00:00
|
|
|
x10c_25_morphed = morphed;
|
|
|
|
}
|
|
|
|
|
2017-01-15 03:07:01 +00:00
|
|
|
void CScriptSpawnPoint::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
2017-01-07 01:58:05 +00:00
|
|
|
void CScriptSpawnPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
|
|
|
|
{
|
|
|
|
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
|
|
|
|
|
|
|
if (msg == EScriptObjectMessage::SetToZero || msg == EScriptObjectMessage::Reset)
|
|
|
|
{
|
|
|
|
if (msg == EScriptObjectMessage::Reset)
|
|
|
|
{
|
|
|
|
using EPlayerItemType = CPlayerState::EItemType;
|
|
|
|
const std::shared_ptr<CPlayerState>& plState = stateMgr.GetPlayerState();
|
|
|
|
for (u32 i = 0; i < u32(EPlayerItemType::Max); ++i)
|
|
|
|
{
|
|
|
|
plState->ReInitalizePowerUp(EPlayerItemType(i), GetPowerup(EPlayerItemType(i)));
|
|
|
|
plState->ResetAndIncrPickUp(EPlayerItemType(i), GetPowerup(EPlayerItemType(i)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetActive())
|
|
|
|
{
|
|
|
|
CPlayer* player = stateMgr.Player();
|
|
|
|
|
|
|
|
if (x4_areaId != stateMgr.GetNextAreaId())
|
|
|
|
{
|
|
|
|
CGameArea* area = stateMgr.WorldNC()->GetArea(x4_areaId);
|
2017-03-31 19:51:40 +00:00
|
|
|
if (area->IsPostConstructed() && area->GetOcclusionState() == CGameArea::EOcclusionState::Occluded)
|
2017-01-07 01:58:05 +00:00
|
|
|
{
|
|
|
|
/* while (!area->TryTakingOutOfARAM()) {} */
|
2017-03-31 19:51:40 +00:00
|
|
|
CWorld::PropogateAreaChain(CGameArea::EOcclusionState::Visible, area, stateMgr.WorldNC());
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stateMgr.SetCurrentAreaId(x4_areaId);
|
|
|
|
stateMgr.SetActorAreaId(*stateMgr.Player(), x4_areaId);
|
|
|
|
player->Teleport(GetTransform(), stateMgr, true);
|
|
|
|
player->SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState(x10c_25_morphed), stateMgr);
|
|
|
|
|
2017-03-31 19:51:40 +00:00
|
|
|
if (area->IsPostConstructed() && area->GetOcclusionState() == CGameArea::EOcclusionState::Visible)
|
|
|
|
CWorld::PropogateAreaChain(CGameArea::EOcclusionState::Occluded,
|
2017-01-07 01:58:05 +00:00
|
|
|
stateMgr.WorldNC()->GetArea(stateMgr.GetNextAreaId()),
|
|
|
|
stateMgr.WorldNC());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->Teleport(GetTransform(), stateMgr, true);
|
|
|
|
player->SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState(x10c_25_morphed), stateMgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CEntity::SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
|
|
|
}
|
2016-08-14 21:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 CScriptSpawnPoint::GetPowerup(CPlayerState::EItemType item) const
|
|
|
|
{
|
|
|
|
int idx = int(item);
|
2018-01-06 06:50:42 +00:00
|
|
|
if (idx >= int(CPlayerState::EItemType::Max) || idx < 0)
|
2016-08-14 21:11:44 +00:00
|
|
|
return x64_itemCounts.front();
|
|
|
|
return x64_itemCounts[idx];
|
2016-04-27 00:21:08 +00:00
|
|
|
}
|
|
|
|
}
|