2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptSpawnPoint.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
#include "Runtime/World/CWorld.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-04-27 00:21:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-04-27 00:21:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CScriptSpawnPoint::CScriptSpawnPoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
|
|
|
const zeus::CTransform& xf,
|
2018-01-06 06:50:42 +00:00
|
|
|
const rstl::reserved_vector<u32, int(CPlayerState::EItemType::Max)>& itemCounts,
|
|
|
|
bool defaultSpawn, bool active, bool morphed)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CEntity(uid, info, active, name), x34_xf(xf), x64_itemCounts(itemCounts) {
|
2019-03-08 04:16:42 +00:00
|
|
|
#ifndef NDEBUG
|
2020-05-20 16:19:00 +00:00
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::MorphBall)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::MorphBallBombs)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::PhazonSuit)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::ThermalVisor)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::XRayVisor)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::GrappleBeam)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::BoostBall)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::ChargeBeam)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::PowerBombs)] = 8;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::SpaceJumpBoots)] = 1;
|
|
|
|
x64_itemCounts[size_t(CPlayerState::EItemType::Missiles)] =
|
|
|
|
std::max(x64_itemCounts[size_t(CPlayerState::EItemType::Missiles)], u32(5));
|
2019-03-08 04:16:42 +00:00
|
|
|
#endif
|
2018-12-08 05:30:43 +00:00
|
|
|
x10c_24_firstSpawn = defaultSpawn;
|
|
|
|
x10c_25_morphed = morphed;
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpawnPoint::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpawnPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
|
|
|
|
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
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) {
|
2021-03-15 22:43:28 +00:00
|
|
|
plState->ReInitializePowerUp(EPlayerItemType(i), GetPowerup(EPlayerItemType(i)));
|
2018-12-08 05:30:43 +00:00
|
|
|
plState->ResetAndIncrPickUp(EPlayerItemType(i), GetPowerup(EPlayerItemType(i)));
|
|
|
|
}
|
|
|
|
}
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (GetActive()) {
|
|
|
|
CPlayer* player = stateMgr.Player();
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x4_areaId != stateMgr.GetNextAreaId()) {
|
2019-08-14 14:58:54 +00:00
|
|
|
CGameArea* area = stateMgr.GetWorld()->GetArea(x4_areaId);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (area->IsPostConstructed() && area->GetOcclusionState() == CGameArea::EOcclusionState::Occluded) {
|
|
|
|
/* while (!area->TryTakingOutOfARAM()) {} */
|
2019-08-14 14:58:54 +00:00
|
|
|
CWorld::PropogateAreaChain(CGameArea::EOcclusionState::Visible, area, stateMgr.GetWorld());
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +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);
|
|
|
|
|
2020-05-07 16:18:57 +00:00
|
|
|
if (area->IsPostConstructed() && area->GetOcclusionState() == CGameArea::EOcclusionState::Visible) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CWorld::PropogateAreaChain(CGameArea::EOcclusionState::Occluded,
|
2019-08-14 14:58:54 +00:00
|
|
|
stateMgr.GetWorld()->GetArea(stateMgr.GetNextAreaId()), stateMgr.GetWorld());
|
2020-05-07 16:18:57 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else {
|
|
|
|
player->Teleport(GetTransform(), stateMgr, true);
|
|
|
|
player->SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState(x10c_25_morphed), stateMgr);
|
|
|
|
}
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
2016-08-14 21:11:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CEntity::SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
|
|
|
}
|
2016-04-27 00:21:08 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
u32 CScriptSpawnPoint::GetPowerup(CPlayerState::EItemType item) const {
|
2020-05-20 16:19:00 +00:00
|
|
|
const auto idx = static_cast<size_t>(item);
|
|
|
|
if (item >= CPlayerState::EItemType::Max) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return x64_itemCounts.front();
|
2020-05-07 16:18:57 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return x64_itemCounts[idx];
|
2016-04-27 00:21:08 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|