Merge branch 'master' of ssh://git.axiodl.com:6431/AxioDL/urde

This commit is contained in:
Jack Andersen 2018-05-05 10:57:15 -10:00
commit 570a6ca57a
122 changed files with 943 additions and 518 deletions

3
.gitmodules vendored
View File

@ -37,3 +37,6 @@
[submodule "NESEmulator/fixNES"]
path = NESEmulator/fixNES
url = https://github.com/jackoalan/fixNES.git
[submodule "Editor/locale"]
path = Editor/locale
url = ../urde-translations.git

1
Editor/locale Submodule

@ -0,0 +1 @@
Subproject commit b2436bbd0331d15df34b68345770d295513cbd9d

View File

@ -1,8 +0,0 @@
bintoc(en_US.cpp en_US.yaml L_en_US)
bintoc(en_GB.cpp en_GB.yaml L_en_GB)
bintoc(ja_JP.cpp ja_JP.yaml L_ja_JP)
add_library(UrdeLocales
en_US.yaml en_US.cpp
en_GB.yaml en_GB.cpp
ja_JP.yaml ja_JP.cpp
locale.hpp locale.cpp)

View File

@ -1,18 +0,0 @@
en_GB:
color: "Colour"
branch: "Branch"
commit: "Commit"
date: "Date"
new_project: "New Project"
open_project: "Open Project"
extract_game: "Extract Game"
name: "Name"
type: "Type"
size: "Size"
directory: "Directory"
file: "File"
file_name: "File Name"
cancel: "Cancel"
system_locations: "System Locations"
recent_projects: "Recent Projects"
recent_files: "Recent Files"

View File

@ -1,18 +0,0 @@
en_US:
color: "Color"
branch: "Branch"
commit: "Commit"
date: "Date"
new_project: "New Project"
open_project: "Open Project"
extract_game: "Extract Game"
name: "Name"
type: "Type"
size: "Size"
directory: "Directory"
file: "File"
file_name: "File Name"
cancel: "Cancel"
system_locations: "System Locations"
recent_projects: "Recent Projects"
recent_files: "Recent Files"

View File

@ -1,18 +0,0 @@
ja_JP:
color: "色"
branch: "分派"
commit: "預ける"
date: "年月日"
new_project: "新しいプロジェクト"
open_project: "プロジェクトを開きます"
extract_game: "ビデオゲームを抽出"
name: "名"
type: "タイプ"
size: "サイズ"
directory: "ディレクトリ"
file: "ファイル"
file_name: "ファイル名"
cancel: "キャンセル"
system_locations: "システムの場所"
recent_projects: "最近使ったプロジェクト"
recent_files: "最近使用したファイル"

View File

@ -1,69 +0,0 @@
#include "locale.hpp"
#include <cstring>
#include <clocale>
#include <algorithm>
#undef min
#undef max
extern "C" const uint8_t L_en_US[];
extern "C" size_t L_en_US_SZ;
extern "C" const uint8_t L_en_GB[];
extern "C" size_t L_en_GB_SZ;
extern "C" const uint8_t L_ja_JP[];
extern "C" size_t L_ja_JP_SZ;
namespace urde
{
using namespace std::literals;
static const specter::Locale Locales[] =
{
{"en_US"sv, "US English"sv, L_en_US, L_en_US_SZ},
{"en_GB"sv, "British English"sv, L_en_GB, L_en_GB_SZ},
{"ja_JP"sv, "Japanese"sv, L_ja_JP, L_ja_JP_SZ}
};
std::vector<std::pair<std::string_view, std::string_view>> ListLocales()
{
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
std::vector<std::pair<std::string_view, std::string_view>> ret;
ret.reserve(localeCount);
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
ret.emplace_back(l.name(), l.fullName());
}
return ret;
}
const specter::Locale* LookupLocale(std::string_view name)
{
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
if (!name.compare(l.name()))
return &l;
}
return nullptr;
}
const specter::Locale* SystemLocaleOrEnglish()
{
const char* sysLocale = std::setlocale(LC_ALL, nullptr);
size_t sysLocaleLen = std::strlen(sysLocale);
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
if (!l.name().compare(0, std::min(l.name().size(), sysLocaleLen), sysLocale))
return &l;
}
return Locales;
}
}

View File

@ -1,15 +0,0 @@
#ifndef URDE_LOCALE_HPP
#define URDE_LOCALE_HPP
#include <specter/Translator.hpp>
namespace urde
{
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
const specter::Locale* LookupLocale(std::string_view name);
const specter::Locale* SystemLocaleOrEnglish();
}
#endif // URDE_LOCALE_HPP

View File

@ -59,7 +59,6 @@ struct Application : boo::IApplicationCallback
hecl::Runtime::FileStoreManager m_fileMgr;
hecl::CVarManager m_cvarManager;
hecl::CVarCommons m_cvarCommons;
hecl::Console m_console;
std::unique_ptr<ViewManager> m_viewManager;
bool m_running = true;
@ -67,12 +66,9 @@ struct Application : boo::IApplicationCallback
Application() :
m_fileMgr(_S("urde")),
m_cvarManager(m_fileMgr),
m_cvarCommons(m_cvarManager),
m_console(&m_cvarManager)
m_cvarCommons(m_cvarManager)
{
//hecl::Console::RegisterLogger(&m_console);
m_viewManager = std::make_unique<ViewManager>(m_fileMgr, m_cvarManager);
m_console.registerCommand("quit", "Quits application instantly", "", std::bind(&Application::quit, this, std::placeholders::_1, std::placeholders::_2));
}
virtual ~Application() = default;
@ -122,6 +118,8 @@ struct Application : boo::IApplicationCallback
}
}
m_cvarManager.parseCommandLine(app->getArgs());
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor);
@ -147,11 +145,6 @@ struct Application : boo::IApplicationCallback
{
return m_cvarCommons.getDeepColor();
}
void quit(hecl::Console* con = nullptr, const std::vector<std::string>& arg = std::vector<std::string>())
{
m_running = false;
}
};
}

View File

@ -56,7 +56,8 @@ const std::pair<int, const SGameOption*> GameOptionsRegistry[] =
{5, VisorOpts},
{5, DisplayOpts},
{4, SoundOpts},
{4, ControllerOpts}
{4, ControllerOpts},
{0, nullptr}
};
CPersistentOptions::CPersistentOptions(CBitStreamReader& stream)

View File

@ -14,7 +14,7 @@ const u32 CPlayerState::PowerUpMaxValues[41] =
1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
const char* PowerUpNames[41]=
const char* CPlayerState::PowerUpNames[41]=
{
"Power Beam",
"Ice Beam",
@ -69,9 +69,14 @@ CPlayerState::CPlayerState()
CPlayerState::CPlayerState(CBitStreamReader& stream)
: x188_staticIntf(5)
{
x4_enabledItems = stream.ReadEncoded(0x20);
u32 tmp = stream.ReadEncoded(0x20);
xc_health.SetHP(*reinterpret_cast<float*>(&tmp));
x4_enabledItems = u32(stream.ReadEncoded(0x20u));
union
{
float fHP;
u32 iHP;
} hp;
hp.iHP = u32(stream.ReadEncoded(0x20u));
xc_health.SetHP(hp.fHP);
x8_currentBeam = EBeamId(stream.ReadEncoded(CBitStreamReader::GetBitCount(5)));
x20_currentSuit = EPlayerSuit(stream.ReadEncoded(CBitStreamReader::GetBitCount(4)));
x24_powerups.resize(41);
@ -80,8 +85,8 @@ CPlayerState::CPlayerState(CBitStreamReader& stream)
if (PowerUpMaxValues[i] == 0)
continue;
u32 a = stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i]));
u32 b = stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i]));
u32 a = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
u32 b = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
x24_powerups[i] = CPowerUp(a, b);
}
@ -93,15 +98,20 @@ CPlayerState::CPlayerState(CBitStreamReader& stream)
x170_scanTimes.emplace_back(state.first, time);
}
x180_scanCompletionRate.first = stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100));
x180_scanCompletionRate.second = stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100));
x180_scanCompletionRate.first = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100u)));
x180_scanCompletionRate.second = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100u)));
}
void CPlayerState::PutTo(CBitStreamWriter& stream)
{
stream.WriteEncoded(x4_enabledItems, 32);
float hp = xc_health.GetHP();
stream.WriteEncoded(*reinterpret_cast<u32*>(&hp), 32);
union
{
float fHP;
u32 iHP;
} hp;
hp.fHP = xc_health.GetHP();
stream.WriteEncoded(hp.iHP, 32);
stream.WriteEncoded(u32(x8_currentBeam), CBitStreamWriter::GetBitCount(5));
stream.WriteEncoded(u32(x20_currentSuit), CBitStreamWriter::GetBitCount(4));
for (u32 i = 0; i < x24_powerups.size(); ++i)
@ -262,8 +272,8 @@ void CPlayerState::UpdateVisorTransition(float dt)
if (x14_currentVisor == x18_transitioningVisor)
{
x1c_visorTransitionFactor += dt;
if (x1c_visorTransitionFactor > 0.2)
x1c_visorTransitionFactor = 0.2;
if (x1c_visorTransitionFactor > 0.2f)
x1c_visorTransitionFactor = 0.2f;
}
else
{
@ -338,7 +348,7 @@ u32 CPlayerState::GetItemAmount(CPlayerState::EItemType type) const
return 0;
}
void CPlayerState::DecrPickup(CPlayerState::EItemType type, s32 amount)
void CPlayerState::DecrPickup(CPlayerState::EItemType type, u32 amount)
{
if (type >= EItemType::Max)
return;
@ -347,14 +357,11 @@ void CPlayerState::DecrPickup(CPlayerState::EItemType type, s32 amount)
x24_powerups[u32(type)].x0_amount -= amount;
}
void CPlayerState::IncrPickup(EItemType type, s32 amount)
void CPlayerState::IncrPickup(EItemType type, u32 amount)
{
if (type >= EItemType::Max)
return;
if (amount < 0)
return;
switch(type)
{
case EItemType::Missiles:
@ -376,31 +383,29 @@ void CPlayerState::IncrPickup(EItemType type, s32 amount)
case EItemType::Newborn:
{
CPowerUp& pup = x24_powerups[u32(type)];
pup.x0_amount = std::min(pup.x0_amount + amount, pup.x4_capacity);
pup.x0_amount = std::min(pup.x0_amount + u32(amount), pup.x4_capacity);
if (type == EItemType::EnergyTanks)
IncrPickup(EItemType::HealthRefill, 9999);
break;
}
case EItemType::HealthRefill:
{
float health = CalculateHealth(amount);
xc_health.SetHP(std::min(health, xc_health.GetHP() + amount));
}
xc_health.SetHP(std::min(amount + xc_health.GetHP(), CalculateHealth()));
[[fallthrough]];
default:
break;
}
}
void CPlayerState::ResetAndIncrPickUp(CPlayerState::EItemType type, s32 amount)
void CPlayerState::ResetAndIncrPickUp(CPlayerState::EItemType type, u32 amount)
{
x24_powerups[u32(type)].x0_amount = 0;
IncrPickup(type, amount);
}
float CPlayerState::CalculateHealth(u32 health)
float CPlayerState::CalculateHealth()
{
return (GetBaseHealthCapacity() + (health * GetEnergyTankCapacity()));
return (GetEnergyTankCapacity() * x24_powerups[u32(EItemType::EnergyTanks)].x0_amount) + GetBaseHealthCapacity();
}
void CPlayerState::InitializePowerUp(CPlayerState::EItemType type, u32 capacity)
@ -408,8 +413,8 @@ void CPlayerState::InitializePowerUp(CPlayerState::EItemType type, u32 capacity)
if (type >= EItemType::Max)
return;
CPowerUp& pup = x24_powerups[(u32)type];
pup.x4_capacity = zeus::clamp(u32(0), pup.x4_capacity + capacity, PowerUpMaxValues[u32(type)]);
CPowerUp& pup = x24_powerups[u32(type)];
pup.x4_capacity = zeus::clamp(0u, pup.x4_capacity + capacity, PowerUpMaxValues[u32(type)]);
pup.x0_amount = std::min(pup.x0_amount, pup.x4_capacity);
if (type >= EItemType::PowerSuit && type <= EItemType::PhazonSuit)
{

View File

@ -102,12 +102,13 @@ public:
private:
static const u32 PowerUpMaxValues[41];
static const char* PowerUpNames[41];
struct CPowerUp
{
int x0_amount = 0;
int x4_capacity = 0;
u32 x0_amount = 0;
u32 x4_capacity = 0;
CPowerUp() {}
CPowerUp(int amount, int capacity) : x0_amount(amount), x4_capacity(capacity) {}
CPowerUp(u32 amount, u32 capacity) : x0_amount(amount), x4_capacity(capacity) {}
};
union
{
@ -161,12 +162,12 @@ public:
bool HasPowerUp(EItemType type) const;
u32 GetItemCapacity(EItemType type) const;
u32 GetItemAmount(EItemType type) const;
void DecrPickup(EItemType type, s32 amount);
void IncrPickup(EItemType type, s32 amount);
void ResetAndIncrPickUp(EItemType type, s32 amount);
void DecrPickup(EItemType type, u32 amount);
void IncrPickup(EItemType type, u32 amount);
void ResetAndIncrPickUp(EItemType type, u32 amount);
static float GetEnergyTankCapacity() { return 100.f; }
static float GetBaseHealthCapacity() { return 99.f; }
float CalculateHealth(u32 health);
float CalculateHealth();
void ReInitalizePowerUp(EItemType type, u32 capacity);
void InitializePowerUp(EItemType type, u32 capacity);
u32 GetLogScans() const { return x180_scanCompletionRate.first; }
@ -182,6 +183,7 @@ public:
CPlayerState();
CPlayerState(CBitStreamReader& stream);
void PutTo(CBitStreamWriter& stream);
static u32 GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; }
};
}

View File

@ -49,6 +49,7 @@
#include "World/CScriptDoor.hpp"
#include "Input/ControlMapper.hpp"
#include "MP1/MP1.hpp"
#include "GameGlobalObjects.hpp"
#include <cmath>
@ -209,6 +210,12 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
CGameCollision::InitCollision();
ControlMapper::ResetCommandFilters();
x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow");
g_StateManager = this;
}
CStateManager::~CStateManager()
{
g_StateManager = nullptr;
}
void CStateManager::UpdateThermalVisor()
@ -353,7 +360,7 @@ TAreaId CStateManager::GetVisAreaId() const
CMaterialFilter::EFilterType::Include), nullptr);
for (TUniqueId id : nearList)
if (TCastToConstPtr<CScriptDock> dock = GetObjectById(id))
if (dock->GetDestinationAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation))
if (dock->GetAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation))
return dock->GetCurrentConnectedAreaId(*this);
return curArea;
@ -1460,7 +1467,7 @@ void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& p
zeus::CVector3f delta = a2.GetTranslation() - pos;
if (delta.magSquared() >= info.GetRadius() * info.GetRadius())
{
rstl::optional_object<zeus::CAABox> bounds = a2.GetTouchBounds();
std::experimental::optional<zeus::CAABox> bounds = a2.GetTouchBounds();
if (!bounds)
return;
if (CCollidableSphere::Sphere_AABox_Bool(zeus::CSphere{pos, info.GetRadius()}, *bounds))
@ -1518,7 +1525,7 @@ bool CStateManager::TestRayDamage(const zeus::CVector3f& pos, const CActor& dama
EMaterialTypes::Character);
static const CMaterialFilter filter(incList, exList, CMaterialFilter::EFilterType::IncludeExclude);
rstl::optional_object<zeus::CAABox> bounds = damagee.GetTouchBounds();
std::experimental::optional<zeus::CAABox> bounds = damagee.GetTouchBounds();
if (!bounds)
return false;
@ -2098,7 +2105,7 @@ void CStateManager::CrossTouchActors()
CActor& actor = static_cast<CActor&>(*ent);
if (!actor.GetActive() || !actor.GetCallTouch())
continue;
rstl::optional_object<zeus::CAABox> touchAABB = actor.GetTouchBounds();
std::experimental::optional<zeus::CAABox> touchAABB = actor.GetTouchBounds();
if (!touchAABB)
continue;
@ -2115,7 +2122,7 @@ void CStateManager::CrossTouchActors()
if (!ent2)
continue;
rstl::optional_object<zeus::CAABox> touchAABB2 = ent2->GetTouchBounds();
std::experimental::optional<zeus::CAABox> touchAABB2 = ent2->GetTouchBounds();
if (!ent2->GetActive() || !touchAABB2)
continue;
@ -2465,7 +2472,7 @@ void CStateManager::UpdateSortedLists()
std::experimental::optional<zeus::CAABox> CStateManager::CalculateObjectBounds(const CActor& actor)
{
rstl::optional_object<zeus::CAABox> bounds = actor.GetTouchBounds();
std::experimental::optional<zeus::CAABox> bounds = actor.GetTouchBounds();
if (bounds)
{
zeus::CAABox aabb;

View File

@ -245,6 +245,7 @@ public:
const std::weak_ptr<CPlayerState>&,
const std::weak_ptr<CWorldTransManager>&,
const std::weak_ptr<CWorldLayerState>&);
~CStateManager();
u32 GetInputFrameIdx() const { return x8d4_inputFrameIdx; }
bool RenderLast(TUniqueId);

View File

@ -551,7 +551,7 @@ zeus::CVector3f CBallCamera::ConstrainYawAngle(const CPlayer& player, float dist
{
lookDir = player.GetMoveDir();
TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(x3dc_tooCloseActorId);
if ((!door || !door->x2a8_26_useConservativeCameraDistance) &&
if ((!door || !door->x2a8_26_isOpen) &&
(x400_state == EBallCameraState::Boost || x400_state == EBallCameraState::Chase))
lookDir = player.GetLeaveMorphDir();
}
@ -1294,7 +1294,7 @@ void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr)
if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(x3dc_tooCloseActorId))
{
if (!door->x2a8_26_useConservativeCameraDistance)
if (!door->x2a8_26_isOpen)
{
if (x400_state == EBallCameraState::Boost)
{
@ -1454,7 +1454,7 @@ void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr)
finalPos = ClampElevationToWater(finalPos, mgr);
if (ballToCam2.magnitude() < 2.f && x3dc_tooCloseActorId != kInvalidUniqueId && x3e0_tooCloseActorDist < 5.f)
if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(x3dc_tooCloseActorId))
if (!door->x2a8_26_useConservativeCameraDistance)
if (!door->x2a8_26_isOpen)
finalPos = GetTranslation();
float backupZ = finalPos.z;
@ -1770,7 +1770,7 @@ bool CBallCamera::IsBallNearDoor(const zeus::CVector3f& pos, CStateManager& mgr)
{
TCastToConstPtr<CScriptDoor> door =
mgr.GetObjectById(mgr.GetCameraManager()->GetBallCamera()->x3dc_tooCloseActorId);
if (!door || door->x2a8_26_useConservativeCameraDistance)
if (!door || door->x2a8_26_isOpen)
return false;
auto tb = door->GetTouchBounds();
@ -1820,14 +1820,14 @@ bool CBallCamera::ConstrainElevationAndDistance(float& elevation, float& distanc
stretchFac = zeus::clamp(-1.f, std::fabs(x3e0_tooCloseActorDist / (3.f * distance)), 1.f);
if (x3e0_tooCloseActorDist < 3.f * distance)
doorClose = true;
if (door->x2a8_26_useConservativeCameraDistance)
if (door->x2a8_26_isOpen)
newDistance = stretchFac * (distance - x468_conservativeDoorCamDistance) +
x468_conservativeDoorCamDistance;
else
newDistance = stretchFac * (distance - 5.f) + 5.f;
if (x18d_28_obtuseDirection)
newDistance *= 1.f + x308_speedFactor;
baseElevation = door->x2a8_26_useConservativeCameraDistance ? 0.75f : 1.5f;
baseElevation = door->x2a8_26_isOpen ? 0.75f : 1.5f;
springSpeed = 4.f;
}
}

View File

@ -52,6 +52,7 @@ protected:
TLockedToken<CTexture> x24_texObj; // Used to be auto_ptr
float GetT(bool invert) const;
public:
virtual ~CCameraFilterPassBase() = default;
virtual void Update(float dt)=0;
virtual void SetFilter(EFilterType type, EFilterShape shape,
float time, const zeus::CColor& color, CAssetId txtr)=0;

View File

@ -45,7 +45,7 @@ CAnimData::CAnimData(CAssetId id,
int defaultAnim, int charIdx, bool loop,
const TLockedToken<CCharLayoutInfo>& layout,
const TToken<CSkinnedModel>& model,
const rstl::optional_object<TToken<CMorphableSkinnedModel>>& iceModel,
const std::experimental::optional<TToken<CMorphableSkinnedModel>>& iceModel,
const std::weak_ptr<CAnimSysContext>& ctx,
const std::shared_ptr<CAnimationManager>& animMgr,
const std::shared_ptr<CTransitionManager>& transMgr,
@ -651,7 +651,7 @@ void CAnimData::RenderAuxiliary(const zeus::CFrustum& frustum) const
}
void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags,
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
const std::experimental::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes)
{
SetupRender(model, drawFlags, morphEffect, morphMagnitudes);
@ -660,7 +660,7 @@ void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags,
void CAnimData::SetupRender(CSkinnedModel& model,
const CModelFlags& drawFlags,
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
const std::experimental::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes)
{
if (!x220_30_poseBuilt)
@ -949,7 +949,7 @@ void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedTo
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose,
const CModelFlags& drawFlags,
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
const std::experimental::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes)
{
model.Calculate(pose, drawFlags, morphEffect, morphMagnitudes);

View File

@ -114,13 +114,13 @@ private:
std::shared_ptr<CTransitionManager> x1fc_transMgr;
float x200_speedScale = 1.f;
u32 x204_charIdx;
s32 x204_charIdx;
u16 x208_defaultAnim;
u32 x20c_passedBoolCount = 0;
u32 x210_passedIntCount = 0;
u32 x214_passedParticleCount = 0;
u32 x218_passedSoundCount = 0;
u32 x21c_particleLightIdx = 0;
s32 x21c_particleLightIdx = 0;
union
{
@ -251,7 +251,7 @@ public:
u32 GetPassedParticlePOICount() const { return x214_passedParticleCount; }
u32 GetPassedSoundPOICount() const { return x218_passedSoundCount; }
u32 GetCharacterIndex() const { return x204_charIdx; }
s32 GetCharacterIndex() const { return x204_charIdx; }
};
}

View File

@ -13,6 +13,7 @@ class CActor;
class CBodyState
{
public:
virtual ~CBodyState() = default;
virtual bool IsInAir(const CBodyController&) const { return false; }
virtual bool IsDead() const { return false; }
virtual bool IsDying() const { return false; }

View File

@ -124,7 +124,7 @@ CCharacterFactory::CreateCharacter(int charIdx, bool loop,
const_cast<CCharacterFactory*>(this)->x70_cacheResPool.GetObj
({FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm);
rstl::optional_object<TToken<CMorphableSkinnedModel>> iceModel;
std::experimental::optional<TToken<CMorphableSkinnedModel>> iceModel;
if (charInfo.GetIceModelId().IsValid() &&
charInfo.GetIceSkinRulesId().IsValid())
iceModel.emplace(const_cast<CCharacterFactory*>(this)->x70_cacheResPool.GetObj

View File

@ -79,7 +79,7 @@ CCharacterInfo::CCharacterInfo(CInputStream& in)
std::vector<CEffectComponent>& comps = x98_effects.back().second;
u32 compCount = in.readUint32Big();
comps.reserve(compCount);
for (u32 j=0 ; j<compCount ; ++i)
for (u32 j=0 ; j<compCount ; ++j)
comps.emplace_back(in);
}
}
@ -95,7 +95,7 @@ CCharacterInfo::CCharacterInfo(CInputStream& in)
u32 aidxCount = in.readUint32Big();
xb0_animIdxs.reserve(aidxCount);
for (u32 i=0 ; i<aidxCount ; ++i)
xb0_animIdxs.push_back(in.readUint32Big());
xb0_animIdxs.push_back(in.readInt32Big());
}
}

View File

@ -39,7 +39,7 @@ private:
CAssetId xa8_cmdlOverlay = 0;
CAssetId xac_cskrOverlay = 0;
std::vector<u32> xb0_animIdxs;
std::vector<s32> xb0_animIdxs;
public:
CCharacterInfo(CInputStream& in);
@ -59,7 +59,7 @@ public:
CAssetId GetIceSkinRulesId() const { return xac_cskrOverlay; }
const CParticleResData& GetParticleResData() const { return x44_partRes; }
u32 GetAnimationIndex(u32 idx) const { return xb0_animIdxs.at(idx); }
s32 GetAnimationIndex(s32 idx) const { return xb0_animIdxs.at(idx); }
const CPASDatabase& GetPASDatabase() const { return x30_pasDatabase; }
};
}

View File

@ -9,7 +9,7 @@ namespace urde
{
CPOINode::CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time,
u32 index, bool c, float weight, u32 e, u32 f)
u32 index, bool c, float weight, s32 e, s32 f)
: x4_(1),
x8_name(name),
x18_type(type),
@ -29,8 +29,8 @@ CPOINode::CPOINode(CInputStream& in)
x24_index(in.readUint32Big()),
x28_(in.readBool()),
x2c_weight(in.readFloatBig()),
x30_charIdx(in.readUint32Big()),
x34_flags(in.readUint32Big())
x30_charIdx(in.readInt32Big()),
x34_flags(in.readInt32Big())
{}
bool CPOINode::operator>(const CPOINode& other) const

View File

@ -30,11 +30,11 @@ protected:
u32 x24_index;
bool x28_;
float x2c_weight;
u32 x30_charIdx = -1;
u32 x34_flags;
s32 x30_charIdx = -1;
s32 x34_flags;
public:
CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time,
u32 index, bool, float weight, u32 charIdx, u32 flags);
u32 index, bool, float weight, s32 charIdx, s32 flags);
CPOINode(CInputStream& in);
virtual ~CPOINode() = default;
@ -44,8 +44,8 @@ public:
EPOIType GetPoiType() const { return x18_type; }
u32 GetIndex() const {return x24_index;}
float GetWeight() const { return x2c_weight; }
u32 GetCharacterIndex() const { return x30_charIdx; }
u32 GetFlags() const { return x34_flags; }
s32 GetCharacterIndex() const { return x30_charIdx; }
s32 GetFlags() const { return x34_flags; }
bool operator>(const CPOINode& other) const;
bool operator<(const CPOINode& other) const;

View File

@ -263,7 +263,8 @@ void CParticleDatabase::AddToRendererClippedParticleGenMap(const std::map<std::s
{
for (auto& e : map)
{
if (frustum.aabbFrustumTest(*e.second->GetBounds()))
auto bounds = e.second->GetBounds();
if (bounds && frustum.aabbFrustumTest(*bounds))
e.second->AddToRenderer();
}
}
@ -274,8 +275,11 @@ void CParticleDatabase::AddToRendererClippedParticleGenMapMasked(const std::map<
for (auto& e : map)
{
if ((e.second->GetFlags() & mask) == target)
if (frustum.aabbFrustumTest(*e.second->GetBounds()))
{
auto bounds = e.second->GetBounds();
if (bounds && frustum.aabbFrustumTest(*bounds))
e.second->AddToRenderer();
}
}
}

View File

@ -130,7 +130,7 @@ void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager&
bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); }
rstl::optional_object<zeus::CAABox> CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); }
std::experimental::optional<zeus::CAABox> CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); }
bool CParticleGenInfoGeneric::HasActiveParticles() const { return x84_system->GetParticleCount() != 0; }

View File

@ -50,7 +50,7 @@ public:
virtual void SetGlobalScale(const zeus::CVector3f& scale) = 0;
virtual void SetParticleEmission(bool, CStateManager& stateMgr) = 0;
virtual bool IsSystemDeletable() const = 0;
virtual rstl::optional_object<zeus::CAABox> GetBounds() const = 0;
virtual std::experimental::optional<zeus::CAABox> GetBounds() const = 0;
virtual bool HasActiveParticles() const = 0;
virtual void DestroyParticles() = 0;
virtual bool HasLight() const = 0;
@ -105,7 +105,7 @@ public:
void SetGlobalScale(const zeus::CVector3f& scale);
void SetParticleEmission(bool, CStateManager& stateMgr);
bool IsSystemDeletable() const;
rstl::optional_object<zeus::CAABox> GetBounds() const;
std::experimental::optional<zeus::CAABox> GetBounds() const;
bool HasActiveParticles() const;
void DestroyParticles();
bool HasLight() const;

View File

@ -17,7 +17,7 @@ public:
struct SRayResult
{
zeus::CPlane x0_plane;
rstl::optional_object<CCollisionSurface> x10_surface;
std::experimental::optional<CCollisionSurface> x10_surface;
float x3c_t;
};

View File

@ -1,11 +1,11 @@
#include "CBallFilter.hpp"
#include "CollisionUtil.hpp"
namespace urde
{
void CBallFilter::Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const
{
CollisionUtil::AddAverageToFront(in, out);
}
}

View File

@ -138,9 +138,9 @@ zeus::CTransform CCollisionActor::GetPrimitiveTransform() const
return xf;
}
rstl::optional_object<zeus::CAABox> CCollisionActor::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CCollisionActor::GetTouchBounds() const
{
rstl::optional_object<zeus::CAABox> aabox;
std::experimental::optional<zeus::CAABox> aabox;
if (x258_primitiveType == EPrimitiveType::OBBTreeGroup)
aabox = {x27c_obbTreeGroupPrimitive->CalculateAABox(x34_transform)};
else if (x258_primitiveType == EPrimitiveType::AABox)

View File

@ -49,7 +49,7 @@ public:
zeus::CVector3f GetOrbitPosition(const CStateManager &) const;
const CCollisionPrimitive* GetCollisionPrimitive() const;
zeus::CTransform GetPrimitiveTransform() const;
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void SetDamageVulnerability(const CDamageVulnerability& vuln);
const zeus::CVector3f& GetBoxSize() const { return x260_boxSize; }
TUniqueId GetOwnerId() const { return x25c_owner; }

View File

@ -179,7 +179,7 @@ CCollisionResponseData::CCollisionResponseData(CInputStream& in, CSimplePool* re
}
}
const rstl::optional_object<TLockedToken<CGenDescription>>&
const std::experimental::optional<TLockedToken<CGenDescription>>&
CCollisionResponseData::GetParticleDescription(EWeaponCollisionResponseTypes type) const
{
if (x0_generators[u32(type)])
@ -211,7 +211,7 @@ CCollisionResponseData::GetParticleDescription(EWeaponCollisionResponseTypes typ
return x0_generators[u32(type)];
}
const rstl::optional_object<TLockedToken<CDecalDescription>>&
const std::experimental::optional<TLockedToken<CDecalDescription>>&
CCollisionResponseData::GetDecalDescription(EWeaponCollisionResponseTypes type) const
{
return x20_decals[u32(type)];

View File

@ -46,9 +46,9 @@ class CCollisionResponseData
{
static const EWeaponCollisionResponseTypes skWorldMaterialTable[32];
static const s32 kInvalidSFX;
std::vector<rstl::optional_object<TLockedToken<CGenDescription>>> x0_generators;
std::vector<std::experimental::optional<TLockedToken<CGenDescription>>> x0_generators;
std::vector<s32> x10_sfx;
std::vector<rstl::optional_object<TLockedToken<CDecalDescription>>> x20_decals;
std::vector<std::experimental::optional<TLockedToken<CDecalDescription>>> x20_decals;
float x30_RNGE;
float x34_FOFF;
@ -59,8 +59,8 @@ class CCollisionResponseData
bool CheckAndAddResourceToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool);
public:
CCollisionResponseData(CInputStream& in, CSimplePool* resPool);
const rstl::optional_object<TLockedToken<CGenDescription>>& GetParticleDescription(EWeaponCollisionResponseTypes) const;
const rstl::optional_object<TLockedToken<CDecalDescription>>& GetDecalDescription(EWeaponCollisionResponseTypes type) const;
const std::experimental::optional<TLockedToken<CGenDescription>>& GetParticleDescription(EWeaponCollisionResponseTypes) const;
const std::experimental::optional<TLockedToken<CDecalDescription>>& GetDecalDescription(EWeaponCollisionResponseTypes type) const;
s32 GetSoundEffectId(EWeaponCollisionResponseTypes) const;
static EWeaponCollisionResponseTypes GetWorldCollisionResponseType(s32);
static bool ResponseTypeIsEnemyShielded(EWeaponCollisionResponseTypes);

View File

@ -4,7 +4,6 @@
namespace urde::CollisionUtil
{
bool LineIntersectsOBBox(const zeus::COBBox& obb, const zeus::CMRay& ray, float& d)
{
zeus::CVector3f norm;
@ -1236,4 +1235,8 @@ bool AABox_AABox_Moving(const zeus::CAABox& aabb0, const zeus::CAABox& aabb1, co
return true;
}
void AddAverageToFront(const CCollisionInfoList& in, CCollisionInfoList& out)
{
}
}

View File

@ -47,6 +47,7 @@ bool MovingSphereAABox(const zeus::CSphere& sphere, const zeus::CAABox& aabb, co
double& d, zeus::CVector3f& point, zeus::CVector3f& normal);
bool AABox_AABox_Moving(const zeus::CAABox& aabb0, const zeus::CAABox& aabb1, const zeus::CVector3f& dir,
double& d, zeus::CVector3f& point, zeus::CVector3f& normal);
void AddAverageToFront(const CCollisionInfoList& in, CCollisionInfoList& out);
}
}
#endif // __URDE_COLLISIONUTIL_HPP__

View File

@ -18,6 +18,7 @@ class CInGameTweakManagerBase* g_TweakManager = nullptr;
class CBooRenderer* g_Renderer = nullptr;
class CStringTable* g_MainStringTable = nullptr;
class CInputGenerator* g_InputGenerator = nullptr;
class CStateManager* g_StateManager = nullptr;
ITweakGame* g_tweakGame = nullptr;
ITweakPlayer* g_tweakPlayer = nullptr;

View File

@ -52,6 +52,7 @@ extern class CInGameTweakManagerBase* g_TweakManager;
extern class CBooRenderer* g_Renderer;
extern class CStringTable* g_MainStringTable;
extern class CInputGenerator* g_InputGenerator;
extern class CStateManager* g_StateManager;
#if USE_DOWNCAST_TWEAKS
using ITweakGame = DataSpec::DNAMP1::CTweakGame;

View File

@ -731,6 +731,11 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
m_nextFogVolumeFilter = m_fogVolumeFilters.end();
}
CBooRenderer::~CBooRenderer()
{
g_Renderer = nullptr;
}
void CBooRenderer::AddWorldSurfaces(CBooModel& model)
{
CBooSurface* surf = model.x3c_firstSortedSurface;

View File

@ -203,6 +203,7 @@ class CBooRenderer : public IRenderer
public:
CBooRenderer(IObjectStore& store, IFactory& resFac);
~CBooRenderer();
void AddWorldSurfaces(CBooModel& model);

View File

@ -201,6 +201,7 @@ private:
static CBooModel* g_LastModelCached;
static bool g_DummyTextures;
static bool g_RenderModelBlack;
public:
~CBooModel();
@ -269,6 +270,7 @@ public:
static void DisableShadowMaps();
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
};
class CModel

View File

@ -47,6 +47,7 @@ void CBooModel::KillCachedViewDepState()
}
bool CBooModel::g_DummyTextures = false;
bool CBooModel::g_RenderModelBlack = false;
zeus::CVector3f CBooModel::g_ReflectViewPos = {};
@ -494,6 +495,8 @@ void CBooModel::DisableAllLights()
void CBooModel::RemapMaterialData(SShader& shader)
{
if (!shader.m_geomLayout)
return;
x4_matSet = &shader.m_matSet;
m_geomLayout = &*shader.m_geomLayout;
m_matSetIdx = shader.m_matSetIdx;
@ -506,6 +509,8 @@ void CBooModel::RemapMaterialData(SShader& shader)
void CBooModel::RemapMaterialData(SShader& shader,
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& pipelines)
{
if (!shader.m_geomLayout)
return;
x4_matSet = &shader.m_matSet;
m_geomLayout = &*shader.m_geomLayout;
m_matSetIdx = shader.m_matSetIdx;
@ -1095,10 +1100,18 @@ void CBooModel::DrawAlpha(const CModelFlags& flags,
const CSkinRules* cskr,
const CPoseAsTransforms* pose) const
{
CModelFlags rFlags = flags;
/* Check if we're overriding with RenderModelBlack */
if (g_RenderModelBlack)
{
rFlags.m_extendedShader = EExtendedShader::SolidColor;
rFlags.x4_color = zeus::CColor::skBlack;
}
if (TryLockTextures())
{
UpdateUniformData(flags, cskr, pose);
DrawAlphaSurfaces(flags);
UpdateUniformData(rFlags, cskr, pose);
DrawAlphaSurfaces(rFlags);
}
}
@ -1106,10 +1119,17 @@ void CBooModel::DrawNormal(const CModelFlags& flags,
const CSkinRules* cskr,
const CPoseAsTransforms* pose) const
{
CModelFlags rFlags = flags;
/* Check if we're overriding with RenderModelBlack */
if (g_RenderModelBlack)
{
rFlags.m_extendedShader = EExtendedShader::SolidColor;
rFlags.x4_color = zeus::CColor::skBlack;
}
if (TryLockTextures())
{
UpdateUniformData(flags, cskr, pose);
DrawNormalSurfaces(flags);
UpdateUniformData(rFlags, cskr, pose);
DrawNormalSurfaces(rFlags);
}
}
@ -1117,10 +1137,18 @@ void CBooModel::Draw(const CModelFlags& flags,
const CSkinRules* cskr,
const CPoseAsTransforms* pose) const
{
CModelFlags rFlags = flags;
/* Check if we're overriding with RenderModelBlack */
if (g_RenderModelBlack)
{
rFlags.m_extendedShader = EExtendedShader::SolidColor;
rFlags.x4_color = zeus::CColor::skBlack;
}
if (TryLockTextures())
{
UpdateUniformData(flags, cskr, pose);
DrawSurfaces(flags);
UpdateUniformData(rFlags, cskr, pose);
DrawSurfaces(rFlags);
}
}

View File

@ -33,7 +33,7 @@ CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model,
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose,
const CModelFlags& drawFlags,
const rstl::optional_object<CVertexMorphEffect>& morphEffect,
const std::experimental::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes)
{
if (morphEffect || g_PointGenFunc)

View File

@ -19,6 +19,7 @@ public:
{
virtual boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, ShaderImp& filter)=0;
virtual ~IDataBindingFactory() = default;
};
static std::unique_ptr<IDataBindingFactory> m_bindFactory;

View File

@ -18,6 +18,7 @@ public:
{
virtual boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
ShaderImp& filter)=0;
virtual ~IDataBindingFactory() = default;
};
static std::unique_ptr<IDataBindingFactory> m_bindFactory;

View File

@ -180,6 +180,7 @@ void CHudMissileInterface::Update(float dt, const CStateManager& mgr)
{
case EInventoryStatus::Warning:
string = g_MainStringTable->GetString(12); // Missiles Low
break;
case EInventoryStatus::Depleted:
string = g_MainStringTable->GetString(13); // Depleted
default: break;

View File

@ -10,6 +10,7 @@
namespace hecl
{
class CVarManager;
class Console;
}
namespace urde
@ -51,6 +52,7 @@ public:
virtual void SetFlowState(EFlowState) = 0;
virtual size_t GetExpectedIdSize() const = 0;
virtual void WarmupShaders() = 0;
virtual hecl::Console* Console() const = 0;
};
}

View File

@ -18,9 +18,9 @@ struct CBitStreamReader : athena::io::MemoryReader
u32 x1c_val = 0;
u32 x20_bitOffset = 0;
public:
static s32 GetBitCount(s32 maxVal)
static u32 GetBitCount(u32 maxVal)
{
s32 ret = 0;
u32 ret = 0;
while (maxVal != 0)
{
maxVal /= 2;

View File

@ -2006,6 +2006,7 @@ CFrontEndUI::CFrontEndUI()
m->ResetGameState();
g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id));
g_GameState->CurrentWorldState().SetAreaId(2);
g_GameState->GameOptions().ResetToDefaults();
g_GameState->WriteBackupBuf();

View File

@ -577,7 +577,7 @@ void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr)
CPlayer& player = mgr.GetPlayer();
zeus::CAABox playerAABB = zeus::CAABox::skNullBox;
if (rstl::optional_object<zeus::CAABox> aabb = player.GetTouchBounds())
if (std::experimental::optional<zeus::CAABox> aabb = player.GetTouchBounds())
playerAABB = *aabb;
zeus::CAABox aabb;
@ -596,7 +596,7 @@ void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr)
continue;
if (trigger->GetDamageInfo().GetDamage() == 0.f)
continue;
if (rstl::optional_object<zeus::CAABox> aabb = trigger->GetTouchBounds())
if (std::experimental::optional<zeus::CAABox> aabb = trigger->GetTouchBounds())
{
float dist = playerAABB.distanceBetween(*aabb);
if (dist < threatDist)

View File

@ -48,15 +48,23 @@
#include "AutoMapper/CMapWorld.hpp"
#include "AutoMapper/CMapArea.hpp"
#include "AutoMapper/CMapUniverse.hpp"
#include "World/CStateMachine.hpp"
#include "CScannableObjectInfo.hpp"
#include "Audio/CAudioGroupSet.hpp"
#include "Audio/CSfxManager.hpp"
#include "Audio/CMidiManager.hpp"
#include "CDependencyGroup.hpp"
#include "MP1OriginalIDs.hpp"
#include "CStateManager.hpp"
#include "World/CPlayer.hpp"
#include <discord-rpc.h>
namespace hecl
{
extern CVar* com_enableCheats;
extern CVar* com_developer;
};
namespace urde
{
URDE_DECL_SPECIALIZE_SHADER(CParticleSwooshShaders)
@ -354,9 +362,20 @@ void CGameGlobalObjects::AddPaksAndFactories()
fmgr->AddFactory(FOURCC('DPSC'), FFactoryFunc(FDecalDataFactory));
fmgr->AddFactory(FOURCC('MAPA'), FFactoryFunc(FMapAreaFactory));
fmgr->AddFactory(FOURCC('MAPU'), FFactoryFunc(FMapUniverseFactory));
fmgr->AddFactory(FOURCC('AFSM'), FFactoryFunc(FAiFiniteStateMachineFactory));
}
}
CGameGlobalObjects::~CGameGlobalObjects()
{
g_ResFactory = nullptr;
g_SimplePool = nullptr;
g_CharFactoryBuilder = nullptr;
g_AiFuncMap = nullptr;
g_GameState = nullptr;
g_TweakManager = nullptr;
}
void CMain::AddWorldPaks()
{
CResLoader* loader = g_ResFactory->GetResLoader();
@ -431,6 +450,70 @@ void CMain::EnsureWorldPakReady(CAssetId mlvl)
/* TODO: Schedule resource list load for World Pak containing mlvl */
}
void CMain::Give(hecl::Console* console, const std::vector<std::string>& args)
{
if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState()))
return;
std::string type = args[0];
athena::utility::tolower(type);
console->report(hecl::Console::Level::Info, "Cheater....., Greatly increasing Metroid encounters, have fun!");
std::shared_ptr<CPlayerState> pState = g_GameState->GetPlayerState();
if (type == "all")
{
for (u32 item = 0; item < u32(CPlayerState::EItemType::Max); ++item)
{
pState->ReInitalizePowerUp(CPlayerState::EItemType(item),
CPlayerState::GetPowerUpMaxValue(CPlayerState::EItemType(item)));
pState->IncrPickup(CPlayerState::EItemType(item),
CPlayerState::GetPowerUpMaxValue(CPlayerState::EItemType(item)));
}
pState->IncrPickup(CPlayerState::EItemType::HealthRefill, 99999);
}
else if (type == "missile")
{
s32 missiles = 250;
if (args.size() == 2)
{
missiles = s32(strtol(args[1].c_str(), nullptr, 10));
missiles = zeus::clamp(-250, missiles, 250);
}
u32 curCap = pState->GetItemCapacity(CPlayerState::EItemType::Missiles);
if (missiles > 0 && curCap < u32(missiles))
{
u32 tmp = ((u32(missiles) / 5) + (missiles % 5)) * 5;
pState->ReInitalizePowerUp(CPlayerState::EItemType::Missiles, tmp);
}
if (missiles > 0)
pState->IncrPickup(CPlayerState::EItemType::Missiles, u32(missiles));
else
pState->DecrPickup(CPlayerState::EItemType::Missiles, zeus::clamp(0u, u32(abs(missiles)), pState->GetItemAmount(CPlayerState::EItemType::Missiles)));
}
}
void CMain::Teleport(hecl::Console *, const std::vector<std::string>& args)
{
if (!g_StateManager || args.size() < 3)
return;
zeus::CVector3f loc;
for (u32 i = 0; i < 3; ++i)
loc[i] = strtof(args[i].c_str(), nullptr);
zeus::CTransform xf = g_StateManager->Player()->GetTransform();
xf.origin = loc;
if (args.size() == 6)
{
zeus::CVector3f angle;
for (u32 i = 0; i < 3; ++i)
angle[i] = zeus::degToRad(strtof(args[i + 3].c_str(), nullptr));
xf.setRotation(zeus::CMatrix3f(zeus::CQuaternion(angle)));
}
g_StateManager->Player()->Teleport(xf, *g_StateManager, false);
}
void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx)
{
bool fusionBackup = g_GameState->SystemOptions().GetPlayerFusionSuitActive();
@ -486,8 +569,7 @@ void CMain::UpdateDiscordPresence(CAssetId worldSTRG)
{
if (CPlayerState* pState = g_GameState->GetPlayerState().get())
{
u32 itemPercent = u32(std::ceil(pState->CalculateItemCollectionRate() * 100.f /
pState->GetPickupTotal()));
u32 itemPercent = pState->CalculateItemCollectionRate() * 100 / pState->GetPickupTotal();
if (DiscordItemPercent != itemPercent)
{
DiscordItemPercent = itemPercent;
@ -534,6 +616,10 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
m_cvarMgr = cvarMgr;
m_console = std::make_unique<hecl::Console>(m_cvarMgr);
m_console->registerCommand("quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2));
m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
m_console->registerCommand("Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), (hecl::SConsoleCommand::ECommandFlags::Cheat | hecl::SConsoleCommand::ECommandFlags::Developer));
InitializeSubsystems(storeMgr);
x128_globalObjects.PostInitialize();
x70_tweaks.RegisterTweaks(m_cvarMgr);
@ -672,6 +758,7 @@ void CMain::ShutdownSubsystems()
void CMain::Shutdown()
{
m_console->unregisterCommand("Give");
x164_archSupport.reset();
ShutdownSubsystems();
TShader<CParticleSwooshShaders>::Shutdown();

View File

@ -101,6 +101,8 @@ public:
g_TweakManager = &x150_tweakManager;
}
~CGameGlobalObjects();
void PostInitialize()
{
AddPaksAndFactories();
@ -260,6 +262,7 @@ private:
std::vector<SObjectTag> m_warmupTags;
std::vector<SObjectTag>::iterator m_warmupIt;
bool m_needsWarmupClear = false;
bool m_doQuit = false;
void InitializeSubsystems(const hecl::Runtime::FileStoreManager& storeMgr);
static void InitializeDiscord();
@ -297,8 +300,8 @@ public:
void MemoryCardInitializePump();
bool CheckReset() { return false; }
bool CheckTerminate() { return false; }
bool CheckReset() { return m_doQuit; }
bool CheckTerminate() { return m_doQuit; }
void DrawDebugMetrics(double, CStopWatch&) {}
void DoPredrawMetrics() {}
void FillInAssetIDs();
@ -323,7 +326,11 @@ public:
size_t GetExpectedIdSize() const { return sizeof(u32); }
void quit(hecl::Console*, const std::vector<std::string>&)
{
m_doQuit = true;
}
void Give(hecl::Console*, const std::vector<std::string>&);
void Teleport(hecl::Console*, const std::vector<std::string>&);
hecl::Console* Console() const { return m_console.get(); }
};
}

View File

@ -9,7 +9,7 @@ namespace urde::MP1
CBeetle::CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData,
const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CBeetle::EEntranceType, const CDamageInfo&,
const CDamageVulnerability&, const zeus::CVector3f&, float, float, float, const CDamageVulnerability&,
const CActorParameters& aParams, const rstl::optional_object<CStaticRes>)
const CActorParameters& aParams, const std::experimental::optional<CStaticRes>)
: CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground,
EColliderType::One, EBodyType::BiPedal, aParams, bool(flavor))
{

View File

@ -22,7 +22,7 @@ public:
CBeetle(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, CPatterned::EFlavorType,EEntranceType, const CDamageInfo &, const CDamageVulnerability&,
const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, const CActorParameters&,
const rstl::optional_object<CStaticRes>);
const std::experimental::optional<CStaticRes>);
void Accept(IVisitor &visitor);
};

View File

@ -25,7 +25,7 @@ CMetroidPrimeProjectile::CMetroidPrimeProjectile(
const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage,
TUniqueId uid, TAreaId aid, TUniqueId owner, const SPrimeProjectileInfo& auxData,
TUniqueId homingTarget, EProjectileAttrib attribs, const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg)
: CEnergyProjectile(active, desc, type, xf, materials, damage, uid, aid, owner, homingTarget, attribs, false,
scale, visorParticle, visorSfx, sendCollideMsg), x3d8_auxData(auxData)

View File

@ -30,7 +30,7 @@ public:
const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage,
TUniqueId uid, TAreaId aid, TUniqueId owner, const SPrimeProjectileInfo& auxData,
TUniqueId homingTarget, EProjectileAttrib attribs, const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg);
};

View File

@ -1 +1,19 @@
#include "CParasite.hpp"
#include "World/CActorParameters.hpp"
#include "Character/CModelData.hpp"
#include "World/CPatternedInfo.hpp"
#include "TCastTo.hpp"
namespace urde::MP1
{
CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo)
: CWallWalker(ECharacter::Parasite, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, EColliderType::One, EBodyType::WallWalker, CActorParameters::None(), -1, false)
{
}
void CParasite::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
}

View File

@ -3,12 +3,19 @@
#include "World/CWallWalker.hpp"
namespace urde
{
class CModelData;
}
namespace urde::MP1
{
class CParasite : public CWallWalker
{
public:
CParasite();
CParasite(TUniqueId, std::string_view, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CPatternedInfo&);
void Accept(IVisitor&);
};
}
#endif // __URDE_MP1_CPARASITE_HPP__

View File

@ -435,7 +435,7 @@ void CElementGen::UpdateExistingParticles()
x25c_activeParticleCount = 0;
CParticleGlobals::SetEmitterTime(x74_curFrame);
CParticleGlobals::g_particleAccessParameters = nullptr;
CParticleGlobals::g_particleAccessParameters = &x60_advValues[x25c_activeParticleCount];
for (auto it = x30_particles.begin(); it != x30_particles.end();)
{
@ -1035,6 +1035,7 @@ void CElementGen::RenderModels()
CParticleGlobals::SetParticleLifetime(particle.x0_endFrame - particle.x28_startFrame);
int partFrame = x74_curFrame - particle.x28_startFrame - 1;
CParticleGlobals::UpdateParticleLifetimeTweenValues(partFrame);
CParticleGlobals::g_particleAccessParameters = &x60_advValues[i];
CVectorElement* pmop = desc->x6c_x58_PMOP.get();
if (pmop)
pmop->GetValue(partFrame, pmopVec);
@ -1276,7 +1277,7 @@ void CElementGen::RenderLines()
m_lineRenderer->AddVertex(p1, particle.x34_color, constWidth, {uvs.xMin, uvs.yMin});
m_lineRenderer->AddVertex(p2, particle.x34_color, constWidth, {uvs.xMax, uvs.yMax});
}
else
else if (widt)
{
float width = 1.f;
widt->GetValue(0, width);
@ -1936,10 +1937,10 @@ bool CElementGen::IsSystemDeletable() const
return false;
}
rstl::optional_object<zeus::CAABox> CElementGen::GetBounds() const
std::experimental::optional<zeus::CAABox> CElementGen::GetBounds() const
{
if (GetParticleCountAll() == 0)
return {};
return std::experimental::nullopt;
else
return {x2f0_systemBounds};
}

View File

@ -228,7 +228,7 @@ public:
const zeus::CColor& GetModulationColor() const;
float GetGeneratorRate() const { return x98_generatorRate; }
bool IsSystemDeletable() const;
rstl::optional_object<zeus::CAABox> GetBounds() const;
std::experimental::optional<zeus::CAABox> GetBounds() const;
u32 GetParticleCount() const;
bool SystemHasLight() const;
CLight GetLight() const;

View File

@ -815,7 +815,7 @@ bool CParticleElectric::IsSystemDeletable() const
return true;
}
rstl::optional_object<zeus::CAABox> CParticleElectric::GetBounds() const
std::experimental::optional<zeus::CAABox> CParticleElectric::GetBounds() const
{
if (GetParticleCount() <= 0)
return {};

View File

@ -127,7 +127,7 @@ public:
const zeus::CVector3f& GetGlobalScale() const;
const zeus::CColor& GetModulationColor() const;
bool IsSystemDeletable() const;
rstl::optional_object<zeus::CAABox> GetBounds() const;
std::experimental::optional<zeus::CAABox> GetBounds() const;
u32 GetParticleCount() const;
bool SystemHasLight() const;
CLight GetLight() const;

View File

@ -51,7 +51,7 @@ public:
virtual const zeus::CColor& GetModulationColor() const=0;
virtual float GetGeneratorRate() const { return 1.f; }
virtual bool IsSystemDeletable() const=0;
virtual rstl::optional_object<zeus::CAABox> GetBounds() const=0;
virtual std::experimental::optional<zeus::CAABox> GetBounds() const=0;
virtual u32 GetParticleCount() const=0;
virtual bool SystemHasLight() const=0;
virtual CLight GetLight() const=0;

View File

@ -1150,7 +1150,7 @@ bool CParticleSwoosh::IsSystemDeletable() const
return true;
}
rstl::optional_object<zeus::CAABox> CParticleSwoosh::GetBounds() const
std::experimental::optional<zeus::CAABox> CParticleSwoosh::GetBounds() const
{
if (GetParticleCount() <= 1)
{

View File

@ -150,7 +150,7 @@ public:
const zeus::CVector3f& GetGlobalScale() const;
const zeus::CColor& GetModulationColor() const;
bool IsSystemDeletable() const;
rstl::optional_object<zeus::CAABox> GetBounds() const;
std::experimental::optional<zeus::CAABox> GetBounds() const;
u32 GetParticleCount() const;
bool SystemHasLight() const;
CLight GetLight() const;

View File

@ -146,7 +146,7 @@ public:
}
}
rstl::optional_object<T> GetAverage() const
std::experimental::optional<T> GetAverage() const
{
if (this->empty())
return {};
@ -154,7 +154,7 @@ public:
return {urde::GetAverage<T>(this->data(), this->size())};
}
rstl::optional_object<T> GetEntry(int i) const
std::experimental::optional<T> GetEntry(int i) const
{
if (i >= this->size())
return {};

View File

@ -15,7 +15,7 @@ struct CBeamInfo
CAssetId xc_;
CAssetId x10_;
CAssetId x14_;
u32 x18_;
s32 x18_;
float x1c_;
float x20_;
float x24_;

View File

@ -5,37 +5,46 @@ namespace urde
{
CBeamProjectile::CBeamProjectile(const TToken<CWeaponDescription>& wDesc, std::string_view name, EWeaponType wType,
const zeus::CTransform& xf, int flags, float f1, float f2, EMaterialTypes matType,
const zeus::CTransform& xf, s32 flags, float f1, float f2, EMaterialTypes matType,
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
EProjectileAttrib attribs, bool b1)
: CGameProjectile(false, wDesc, name, wType, xf, matType, dInfo, uid, aid, owner, kInvalidUniqueId, attribs, false,
zeus::CVector3f::skOne, {}, -1, false)
, x2e8_(std::abs(flags))
, x2ec_(x2e8_)
, x2f0_(1.f / x2ec_)
, x2f4_(f1)
, x300_(b1 == false ? x2ec_ : 0.f)
, x464_24_(b1)
, x464_25_(false)
{
}
void CBeamProjectile::Think(float, CStateManager &)
{
}
rstl::optional_object<zeus::CAABox> CBeamProjectile::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CBeamProjectile::GetTouchBounds() const
{
if (!GetActive())
return {};
if (!x464_25_)
{
zeus::CVector3f pos = GetTranslation();
return {{pos - 1.f, pos + 1.f}};
}
return {};
}
void CBeamProjectile::Touch(CActor &, CStateManager &)
void CBeamProjectile::CalculateRenderBounds()
{
x9c_renderBounds = x354_.getTransformedAABox(x324_);
}
void CBeamProjectile::ResetBeam(CStateManager &, bool)
{
if (x464_24_)
x300_ = 0.f;
}
void CBeamProjectile::UpdateFX(const zeus::CTransform &, float, CStateManager &)
{
}
void CBeamProjectile::Accept(urde::IVisitor& visitor)

View File

@ -6,9 +6,26 @@ namespace urde
{
class CBeamProjectile : public CGameProjectile
{
u32 x2e8_;
float x2ec_;
float x2f0_;
float x2f4_;
u32 x2f8_ = 0;
TUniqueId x2fc_ = kInvalidUniqueId;
TUniqueId x2fe_ = kInvalidUniqueId;
float x300_;
float x304_;
float x308_;
zeus::CVector3f x30c_ = zeus::CVector3f::skUp;
zeus::CTransform x324_;
zeus::CAABox x354_ = zeus::CAABox::skNullBox;
rstl::reserved_vector<zeus::CVector3f, 10> x384_;
rstl::reserved_vector<zeus::CVector3f, 8> x400_;
bool x464_24_ : 1;
bool x464_25_ : 1;
public:
CBeamProjectile(const TToken<CWeaponDescription>& wDesc, std::string_view name, EWeaponType wType,
const zeus::CTransform& xf, int flags, float f1, float f2, EMaterialTypes matType,
const zeus::CTransform& xf, s32 flags, float f1, float f2, EMaterialTypes matType,
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
EProjectileAttrib attribs, bool b1);
@ -26,9 +43,8 @@ public:
void GetMaxLength();
s32 GetIntMaxLength();
void Think(float, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void CalculateRenderBounds();
virtual void ResetBeam(CStateManager&, bool);
virtual void UpdateFX(const zeus::CTransform&, float, CStateManager&);
};

View File

@ -19,7 +19,7 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken<CWeaponDescriptio
const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& damage,
TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget,
EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg)
: CGameProjectile(active, desc, "GameProjectile", type, xf, excludeMat, damage, uid, aid,
owner, homingTarget, attribs, underwater, scale, visorParticle, visorSfx, sendCollideMsg),

View File

@ -31,7 +31,7 @@ public:
const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& damage,
TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget,
EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg);
void SetCameraShake(const CCameraShakeData& data) { x2fc_camShake = data; x3d0_27_camShakeDirty = true; }
void PlayImpactSound(const zeus::CVector3f& pos, EWeaponCollisionResponseTypes type);

View File

@ -18,7 +18,7 @@ CGameProjectile::CGameProjectile(bool active, const TToken<CWeaponDescription>&
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater,
const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg)
: CWeapon(uid, aid, active, owner, wType, name, xf,
CMaterialFilter::MakeIncludeExclude(

View File

@ -18,9 +18,9 @@ class CWeaponDescription;
class CProjectileTouchResult
{
TUniqueId x0_id;
rstl::optional_object<CRayCastResult> x4_result;
std::experimental::optional<CRayCastResult> x4_result;
public:
CProjectileTouchResult(TUniqueId id, const rstl::optional_object<CRayCastResult>& result)
CProjectileTouchResult(TUniqueId id, const std::experimental::optional<CRayCastResult>& result)
: x0_id(id), x4_result(result) {}
TUniqueId GetActorId() const { return x0_id; }
bool HasRayCastResult() const { return x4_result.operator bool(); }
@ -30,7 +30,7 @@ public:
class CGameProjectile : public CWeapon
{
protected:
rstl::optional_object<TLockedToken<CGenDescription>> x158_visorParticle;
std::experimental::optional<TLockedToken<CGenDescription>> x158_visorParticle;
u16 x168_visorSfx;
CProjectileWeapon x170_projectile;
zeus::CVector3f x298_lastOrigin;
@ -62,7 +62,7 @@ public:
EWeaponType wType, const zeus::CTransform& xf, EMaterialTypes excludeMat,
const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner,
TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg);
virtual void Accept(IVisitor &visitor);

View File

@ -91,7 +91,7 @@ zeus::CVector3f CProjectileWeapon::GetTranslation() const
return x14_localToWorldXf * (x44_localXf * x8c_projOffset + x80_localOffset) + x74_worldOffset;
}
rstl::optional_object<zeus::CAABox> CProjectileWeapon::GetBounds() const
std::experimental::optional<zeus::CAABox> CProjectileWeapon::GetBounds() const
{
zeus::CAABox aabb;
bool ret = false;
@ -160,7 +160,7 @@ float CProjectileWeapon::GetAudibleRange() const
return x4_weaponDesc->x94_COLR.m_res->GetAudibleRange();
}
rstl::optional_object<TLockedToken<CDecalDescription>>
std::experimental::optional<TLockedToken<CDecalDescription>>
CProjectileWeapon::GetDecalForCollision(EWeaponCollisionResponseTypes type) const
{
if (!x4_weaponDesc->x94_COLR)
@ -175,7 +175,7 @@ u16 CProjectileWeapon::GetSoundIdForCollision(EWeaponCollisionResponseTypes type
return u16(x4_weaponDesc->x94_COLR.m_res->GetSoundEffectId(type));
}
rstl::optional_object<TLockedToken<CGenDescription>>
std::experimental::optional<TLockedToken<CGenDescription>>
CProjectileWeapon::CollisionOccured(EWeaponCollisionResponseTypes type, bool deflected, bool useTarget,
const zeus::CVector3f& pos, const zeus::CVector3f& normal,
const zeus::CVector3f& target)

View File

@ -45,7 +45,7 @@ class CProjectileWeapon
std::unique_ptr<CElementGen> xfc_APSMGen;
std::unique_ptr<CElementGen> x100_APS2Gen;
std::unique_ptr<CElementGen> x104_;
rstl::optional_object<TLockedToken<CModel>> x108_model;
std::experimental::optional<TLockedToken<CModel>> x108_model;
std::unique_ptr<CParticleSwoosh> x118_swoosh1;
std::unique_ptr<CParticleSwoosh> x11c_swoosh2;
std::unique_ptr<CParticleSwoosh> x120_swoosh3;
@ -70,16 +70,16 @@ public:
const zeus::CTransform& orient, const zeus::CVector3f& scale, s32);
virtual ~CProjectileWeapon() = default;
bool IsProjectileActive() const { return x124_24_active; }
rstl::optional_object<zeus::CAABox> GetBounds() const;
std::experimental::optional<zeus::CAABox> GetBounds() const;
const zeus::CVector3f& GetVelocity() const { return xb0_velocity; }
void SetVelocity(const zeus::CVector3f& vel) { xb0_velocity = vel; }
float GetMaxTurnRate() const { return xe0_maxTurnRate; }
float GetAudibleFallOff() const;
float GetAudibleRange() const;
rstl::optional_object<TLockedToken<CDecalDescription>>
std::experimental::optional<TLockedToken<CDecalDescription>>
GetDecalForCollision(EWeaponCollisionResponseTypes type) const;
u16 GetSoundIdForCollision(EWeaponCollisionResponseTypes type) const;
rstl::optional_object<TLockedToken<CGenDescription>>
std::experimental::optional<TLockedToken<CGenDescription>>
CollisionOccured(EWeaponCollisionResponseTypes type, bool deflected, bool useTarget, const zeus::CVector3f& pos,
const zeus::CVector3f& normal, const zeus::CVector3f& target);
TLockedToken<CWeaponDescription> GetWeaponDescription() const { return x4_weaponDesc; }

View File

@ -8,7 +8,7 @@ CTargetableProjectile::CTargetableProjectile(
const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage,
const CDamageInfo& damage2, TUniqueId uid, TAreaId aid, TUniqueId owner,
TUniqueId homingTarget, EProjectileAttrib attribs,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg)
: CEnergyProjectile(true, desc, type, xf, materials, damage, uid, aid, owner, homingTarget,
attribs | EProjectileAttrib::BigProjectile | EProjectileAttrib::PartialCharge |

View File

@ -14,7 +14,7 @@ public:
const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage,
const CDamageInfo& damage2, TUniqueId uid, TAreaId aid, TUniqueId owner,
TUniqueId homingTarget, EProjectileAttrib attribs,
const rstl::optional_object<TLockedToken<CGenDescription>>& visorParticle,
const std::experimental::optional<TLockedToken<CGenDescription>>& visorParticle,
u16 visorSfx, bool sendCollideMsg);
};

View File

@ -40,7 +40,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
xd0_thermalMag = params.x64_thermalMag;
xd8_nonLoopingSfxHandles.resize(2);
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_28_transformDirty = true;
xe4_29_actorLightsDirty = true;
xe4_31_lightsDirty = true;
xe5_27_useInSortedLists = true;
@ -349,7 +349,7 @@ const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f
return GetDamageVulnerability();
}
rstl::optional_object<zeus::CAABox> CActor::GetTouchBounds() const { return {}; }
std::experimental::optional<zeus::CAABox> CActor::GetTouchBounds() const { return {}; }
void CActor::Touch(CActor&, CStateManager&) {}
@ -542,7 +542,7 @@ void CActor::SetRotation(const zeus::CQuaternion &q)
{
x34_transform = q.toTransform(x34_transform.origin);
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_28_transformDirty = true;
xe4_29_actorLightsDirty = true;
}
@ -550,7 +550,7 @@ void CActor::SetTranslation(const zeus::CVector3f& tr)
{
x34_transform.origin = tr;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_28_transformDirty = true;
xe4_29_actorLightsDirty = true;
}
@ -558,7 +558,7 @@ void CActor::SetTransform(const zeus::CTransform& tr)
{
x34_transform = tr;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_28_transformDirty = true;
xe4_29_actorLightsDirty = true;
}

View File

@ -55,7 +55,7 @@ protected:
{
u8 xe4_24_nextNonLoopingSfxHandle : 3;
bool xe4_27_notInSortedLists : 1;
bool xe4_28_ : 1;
bool xe4_28_transformDirty : 1;
bool xe4_29_actorLightsDirty : 1;
bool xe4_30_outOfFrustum : 1;
bool xe4_31_lightsDirty : 1;
@ -108,7 +108,7 @@ public:
virtual void SetActive(bool active)
{
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_28_transformDirty = true;
xe4_29_actorLightsDirty = true;
xe7_29_actorActive = active;
CEntity::SetActive(active);
@ -122,7 +122,7 @@ public:
virtual const CDamageVulnerability* GetDamageVulnerability() const;
virtual const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&,
const CDamageInfo&) const;
virtual rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
virtual std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
virtual void Touch(CActor&, CStateManager&);
virtual zeus::CVector3f GetOrbitPosition(const CStateManager&) const;
virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) const;

View File

@ -1,5 +1,9 @@
#include "CExplosion.hpp"
#include "CStateManager.hpp"
#include "CGameLight.hpp"
#include "TCastTo.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{
@ -13,9 +17,9 @@ CExplosion::CExplosion(const TLockedToken<CGenDescription>& particle, TUniqueId
flags & 0x2 ? CElementGen::EOptionalSystemFlags::Two :
CElementGen::EOptionalSystemFlags::One);
xf0_particleDesc = particle.GetObj();
xf4_24_ = flags & 0x4;
xf4_24_renderThermalHot = flags & 0x4;
xf4_25_ = true;
xf4_26_ = flags & 0x8;
xf4_26_renderXray = flags & 0x8;
xe6_27_thermalVisorFlags = flags & 0x1 ? 1 : 2;
xe8_particleGen->SetGlobalTranslation(xf.origin);
xe8_particleGen->SetOrientation(xf.getRotation());
@ -27,4 +31,95 @@ void CExplosion::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CExplosion::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::Deleted)
{
if (xec_explosionLight != kInvalidUniqueId)
mgr.FreeScriptObject(xec_explosionLight);
}
else if (msg == EScriptObjectMessage::Registered)
{
if (xe8_particleGen->SystemHasLight())
{
xec_explosionLight = mgr.AllocateUniqueId();
mgr.AddObject(new CGameLight(xec_explosionLight, GetAreaIdAlways(), true, "ExplodePLight_" + x10_name, x34_transform,
GetUniqueId(), xe8_particleGen->GetLight(), 1, /*xf0_particleDesc*/ 0, 0.f));
}
}
CActor::AcceptScriptMsg(msg, sender, mgr);
if (xec_explosionLight != kInvalidUniqueId)
mgr.SendScriptMsgAlways(sender, xec_explosionLight, msg);
}
void CExplosion::Think(float dt, CStateManager& mgr)
{
if (xe4_28_transformDirty)
{
xe8_particleGen->SetGlobalTranslation(GetTranslation());
xe8_particleGen->SetGlobalOrientation(GetTransform().getRotation());
xe4_28_transformDirty = false;
}
xe8_particleGen->Update(dt);
if (xec_explosionLight != kInvalidUniqueId)
{
TCastToPtr<CGameLight> light = mgr.ObjectById(xec_explosionLight);
if (light && x30_24_active)
light->SetLight(xe8_particleGen->GetLight());
}
xf8_time += dt;
if (xf8_time > 15.f || xe8_particleGen->IsSystemDeletable())
mgr.FreeScriptObject(GetUniqueId());
}
void CExplosion::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
{
CActor::PreRender(mgr, frustum);
xe4_30_outOfFrustum = !xf4_25_ || !frustum.aabbFrustumTest(x9c_renderBounds);
}
void CExplosion::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const
{
if (xe4_30_outOfFrustum)
return;
if (!(xf4_24_renderThermalHot && mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot)
&& !(xf4_26_renderXray && mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay))
{
g_Renderer->AddParticleGen(*xe8_particleGen.get());
return;
}
EnsureRendered(mgr);
}
void CExplosion::Render(const CStateManager& mgr) const
{
if (mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot && xf4_24_renderThermalHot)
{
CElementGen::SetSubtractBlend(true);
CBooModel::SetRenderModelBlack(true);
xe8_particleGen->Render();
CBooModel::SetRenderModelBlack(false);
CElementGen::SetSubtractBlend(false);
return;
}
CElementGen::SetSubtractBlend(xf4_24_renderThermalHot);
CGraphics::SetFog(ERglFogMode::PerspLin, 0.f, 74.f, zeus::CColor::skBlack);
xe8_particleGen->Render();
mgr.SetupFogForArea(GetAreaIdAlways());
CElementGen::SetSubtractBlend(false);
}
bool CExplosion::CanRenderUnsorted(const CStateManager &) const
{
return false;
}
}

View File

@ -11,12 +11,12 @@ namespace urde
class CExplosion : public CEffect
{
std::unique_ptr<CElementGen> xe8_particleGen;
TUniqueId xec_ = kInvalidUniqueId;
TUniqueId xec_explosionLight = kInvalidUniqueId;
const CGenDescription* xf0_particleDesc;
bool xf4_24_:1;
bool xf4_24_renderThermalHot:1;
bool xf4_25_:1;
bool xf4_26_:1;
float xf8_ = 0.f;
bool xf4_26_renderXray:1;
float xf8_time = 0.f;
public:
CExplosion(const TLockedToken<CGenDescription>& particle, TUniqueId uid, bool active,
@ -24,6 +24,12 @@ public:
u32, const zeus::CVector3f& scale, const zeus::CColor& color);
void Accept(IVisitor&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void Think(float, CStateManager&);
void PreRender(CStateManager&, const zeus::CFrustum&);
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
void Render(const CStateManager&) const;
bool CanRenderUnsorted(const CStateManager&) const;
};
}

View File

@ -450,7 +450,7 @@ CGameArea::CGameArea(CInputStream& in, int idx, int mlvlVersion)
u32 dockCount = in.readUint32Big();
xcc_docks.reserve(dockCount);
for (u32 i=0 ; i<dockCount ; ++i)
xcc_docks.emplace_back(in, xc_transform);
xcc_docks.push_back({in, xc_transform});
ClearTokenList();
@ -501,6 +501,14 @@ CGameArea::~CGameArea()
while (!Invalidate(nullptr)) {}
}
bool CGameArea::IsFinishedOccluding() const
{
if (x12c_postConstructed->x10dc_occlusionState != EOcclusionState::Occluded)
return true;
return x12c_postConstructed->x1108_27_;
}
std::pair<std::unique_ptr<u8[]>, s32> CGameArea::IGetScriptingMemoryAlways() const
{
return GetScriptingMemoryAlways(*this);

View File

@ -374,7 +374,7 @@ public:
void SetAreaAttributes(const CScriptAreaAttributes* areaAttributes);
bool GetActive() const { return xf0_25_active; }
void SetActive(bool active) { xf0_25_active = active; }
CObjectList* GetAreaObjects() const { return GetPostConstructed()->x10c0_areaObjs.get(); }
CObjectList* GetAreaObjects() const { return GetPostConstructed() ? GetPostConstructed()->x10c0_areaObjs.get() : nullptr; }
CGameArea* GetNext() const { return x130_next; }

View File

@ -1058,7 +1058,7 @@ bool CPlayer::IsUnderBetaMetroidAttack(CStateManager& mgr) const
return false;
}
rstl::optional_object<zeus::CAABox> CPlayer::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CPlayer::GetTouchBounds() const
{
if (x2f8_morphBallState == EPlayerMorphBallState::Morphed)
{

View File

@ -461,7 +461,7 @@ public:
void Accept(IVisitor& visitor);
CHealthInfo* HealthInfo(CStateManager& mgr);
bool IsUnderBetaMetroidAttack(CStateManager& mgr) const;
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor& actor, CStateManager& mgr);
void DoPreThink(float dt, CStateManager& mgr);
void DoThink(float dt, CStateManager& mgr);

View File

@ -193,7 +193,7 @@ CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CV
return CActor::GetCollisionResponseType(v1, v2, wMode, w);
}
rstl::optional_object<zeus::CAABox> CScriptActor::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CScriptActor::GetTouchBounds() const
{
if (GetActive() && x68_material.HasMaterial(EMaterialTypes::Solid))
return {CPhysicsActor::GetBoundingBox()};

View File

@ -42,7 +42,7 @@ public:
zeus::CAABox GetSortingBounds(const CStateManager&) const;
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
const CWeaponMode&, EProjectileAttrib) const;
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);
const CDamageVulnerability* GetDamageVulnerability() const { return &x268_damageVulnerability; }
CHealthInfo* HealthInfo(CStateManager&) { return &x260_currentHealth; }

View File

@ -50,7 +50,7 @@ void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId oth
}
}
rstl::optional_object<zeus::CAABox> CScriptAiJumpPoint::GetTouchBounds() const { return xec_; }
std::experimental::optional<zeus::CAABox> CScriptAiJumpPoint::GetTouchBounds() const { return xec_; }
bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const
{

View File

@ -30,7 +30,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {}
void Render(const CStateManager&) const {}
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
bool GetInUse(TUniqueId uid) const;
};
}

View File

@ -43,7 +43,7 @@ void CScriptCameraPitchVolume::Think(float, CStateManager& mgr)
x13c_24_entered = false;
}
rstl::optional_object<zeus::CAABox> CScriptCameraPitchVolume::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CScriptCameraPitchVolume::GetTouchBounds() const
{
return {xe8_obbox.calculateAABox(zeus::CTransform::Identity())};
}

View File

@ -31,7 +31,7 @@ public:
void Accept(IVisitor& visitor);
void Think(float, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);
float GetUpPitch() const { return x124_upPitch; }
float GetDownPitch() const { return x128_downPitch; }

View File

@ -30,7 +30,7 @@ void CScriptCoverPoint::Think(float delta, CStateManager&)
x11c_timeLeft -= delta;
}
rstl::optional_object<zeus::CAABox> CScriptCoverPoint::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CScriptCoverPoint::GetTouchBounds() const
{
if (x100_touchBounds)
return x100_touchBounds;

View File

@ -227,7 +227,7 @@ void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr)
}
}
rstl::optional_object<zeus::CAABox> CScriptDamageableTrigger::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CScriptDamageableTrigger::GetTouchBounds() const
{
if (!x30_24_active || !x300_24_notOccluded)
return {};

View File

@ -62,7 +62,7 @@ public:
const CDamageVulnerability* GetDamageVulnerability() const { return &x174_dVuln; }
CHealthInfo* HealthInfo(CStateManager&) { return &x16c_hInfo; }
void Think(float, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
};
}

View File

@ -36,7 +36,7 @@ void CScriptDebris::Accept(IVisitor& visitor)
visitor.Visit(this);
}
rstl::optional_object<zeus::CAABox> CScriptDebris::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CScriptDebris::GetTouchBounds() const
{
return {};
}

View File

@ -40,7 +40,7 @@ public:
bool, bool, bool, bool);
void Accept(IVisitor& visitor);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void CollidedWith(TUniqueId uid, const CCollisionInfoList&, CStateManager&);
};

View File

@ -23,7 +23,7 @@ CMaterialList MakeDockMaterialList()
CScriptDock::CScriptDock(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CVector3f position, const zeus::CVector3f& extents, s32 dock, TAreaId area,
bool active, s32 dockReferenceCount, bool loadConnected)
: CPhysicsActor(uid, active, name, info, zeus::CTransform(zeus::CMatrix3f::skIdentityMatrix3f, position),
: CPhysicsActor(uid, true/*active*/, name, info, zeus::CTransform(zeus::CMatrix3f::skIdentityMatrix3f, position),
CModelData::CModelDataNull(), MakeDockMaterialList(), zeus::CAABox(-extents * 0.5f, extents * 0.5f),
SMoverData(1.f), CActorParameters::None(), 0.3f, 0.1f)
, x258_dockReferenceCount(dockReferenceCount)
@ -40,6 +40,7 @@ void CScriptDock::Accept(IVisitor& visitor)
void CScriptDock::Think(float dt, CStateManager& mgr)
{
x30_24_active = true;
if (!GetActive())
{
UpdateAreaActivateFlags(mgr);
@ -96,7 +97,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
case EScriptObjectMessage::Registered:
{
CGameArea* area = mgr.WorldNC()->GetArea(x260_area);
if (area->GetDockCount() <= x25c_dock)
if (area->GetDockCount() < x25c_dock)
return;
IGameArea::Dock* dock = area->DockNC(x25c_dock);
if (!dock->IsReferenced())
@ -147,6 +148,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
break;
case EScriptObjectMessage::Increment:
SetLoadConnected(mgr, true);
[[fallthrough]];
case EScriptObjectMessage::Decrement:
{
TAreaId aid = x260_area;
@ -155,7 +157,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
IGameArea::Dock* dock = mgr.WorldNC()->GetArea(x260_area)->DockNC(x25c_dock);
aid = dock->GetConnectedAreaId(dock->GetReferenceCount());
}
else if (aid == 0 || (mgr.GetWorld()->GetNumAreas() <= aid || !mgr.WorldNC()->GetArea(aid)->GetActive()))
else if (aid == 0 || (aid >= mgr.GetWorld()->GetNumAreas() || !mgr.WorldNC()->GetArea(aid)->GetActive()))
return;
CWorld::PropogateAreaChain(CGameArea::EOcclusionState(msg == EScriptObjectMessage::Increment),
mgr.WorldNC()->GetArea(aid), mgr.WorldNC());
@ -167,7 +169,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
}
}
rstl::optional_object<zeus::CAABox> CScriptDock::GetTouchBounds() const
std::experimental::optional<zeus::CAABox> CScriptDock::GetTouchBounds() const
{
if (x264_dockState == EDockState::Three)
return {};
@ -196,17 +198,17 @@ void CScriptDock::SetDockReference(CStateManager& mgr, s32 ref)
x268_24_dockReferenced = true;
}
s32 CScriptDock::GetDockReference(CStateManager& mgr) const
s32 CScriptDock::GetDockReference(const CStateManager& mgr) const
{
return mgr.GetWorld()->GetAreaAlways(x260_area)->GetDock(x25c_dock)->GetReferenceCount();
}
TAreaId CScriptDock::GetCurrentConnectedAreaId(const CStateManager& mgr) const
{
if (mgr.GetWorld()->GetNumAreas() < x260_area)
if (x260_area >= mgr.GetWorld()->GetNumAreas())
return kInvalidAreaId;
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x260_area);
if (area->GetDockCount() < x25c_dock)
if (x25c_dock >= area->GetDockCount())
return kInvalidAreaId;
const IGameArea::Dock* dock = area->GetDock(x25c_dock);

View File

@ -39,14 +39,14 @@ public:
void Accept(IVisitor& visitor);
void Think(float, CStateManager&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);
void CleanUp() {}
zeus::CPlane GetPlane(const CStateManager&) const;
TAreaId GetDestinationAreaId() const { return x260_area; }
TAreaId GetAreaId() const { return x260_area; }
s32 GetDockId() const { return x25c_dock; }
void SetDockReference(CStateManager& mgr, s32);
s32 GetDockReference(CStateManager& mgr) const;
s32 GetDockReference(const CStateManager& mgr) const;
TAreaId GetCurrentConnectedAreaId(const CStateManager&) const;
void UpdateAreaActivateFlags(CStateManager&);
bool HasPointCrossedDock(const CStateManager&, const zeus::CVector3f&) const;

View File

@ -7,7 +7,7 @@ namespace urde
{
CScriptDockAreaChange::CScriptDockAreaChange(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 w1,
bool active)
: CEntity(uid, info, active, name), x34_dockReference(w1)
: CEntity(uid, info, true/*active*/, name), x34_dockReference(w1)
{
}

View File

@ -11,6 +11,7 @@ class CScriptDockAreaChange : public CEntity
public:
CScriptDockAreaChange(TUniqueId, std::string_view, const CEntityInfo&, s32, bool);
void Think(float dt, CStateManager& mgr) { x30_24_active = true; CEntity::Think(dt, mgr); }
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
};

View File

@ -16,7 +16,7 @@ namespace urde
static CMaterialList MakeDoorMaterialList(bool open)
{
CMaterialList ret;
ret.Add(EMaterialTypes::Solid);
//ret.Add(EMaterialTypes::Solid);
ret.Add(EMaterialTypes::Immovable);
ret.Add(EMaterialTypes::Orbit);
if (!open)
@ -27,19 +27,24 @@ static CMaterialList MakeDoorMaterialList(bool open)
CScriptDoor::CScriptDoor(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms,
const zeus::CVector3f&, const zeus::CAABox& aabb, bool active,
bool open, bool b2, float, bool ballDoor)
const zeus::CVector3f& vec, const zeus::CAABox& aabb, bool active,
bool open, bool b2, float animLen, bool ballDoor)
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeDoorMaterialList(open),
aabb, SMoverData(1.f), actParms, 0.3f, 0.1f)
{
x2a8_29_ballDoor = ballDoor;
x258_animLen = animLen;
x2a8_24_ = false;
x2a8_25_ = open;
x2a8_26_useConservativeCameraDistance = open;
x2a8_26_isOpen = open;
x2a8_27_ = false;
x2a8_28_ = b2;
x2a8_27_ = true;
x2a8_29_ballDoor = ballDoor;
x2a8_30_ = false;
x264_ = GetBoundingBox();
x284_modelBounds = x64_modelData->GetBounds(xf.getRotation());
x29c_ = vec;
xe6_27_thermalVisorFlags = 1;
if (open)
SetDoorAnimation(EDoorAnimType::Open);
@ -60,24 +65,169 @@ zeus::CVector3f CScriptDoor::GetOrbitPosition(const CStateManager& /*mgr*/) cons
/* ORIGINAL 0-00 OFFSET: 8007E550 */
void CScriptDoor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager &mgr)
{
(void)mgr;
(void)uid;
(void)msg;
switch(msg)
{
case EScriptObjectMessage::Close:
{
if (!GetActive())
return;
if (x27c_partner1 != kInvalidUniqueId && x27c_partner1 != uid)
return;
if (x2a8_26_isOpen)
{
if (x27e_partner2 != kInvalidUniqueId)
{
if (CEntity* ent = mgr.ObjectById(x27e_partner2))
mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Close);
}
x2a8_26_isOpen = false;
SetDoorAnimation(EDoorAnimType::Close);
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId());
}
else if (x2a8_27_)
{
x2a8_27_ = false;
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
}
break;
}
case EScriptObjectMessage::Action:
{
if (x27c_partner1 != kInvalidUniqueId)
{
if (TCastToPtr<CScriptDoor> door = mgr.ObjectById(x27c_partner1))
{
if (x2a8_26_isOpen)
return;
x2a8_30_ = true;
mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close);
}
}
else if (x2a8_26_isOpen)
{
x2a8_30_ = true;
if (TCastToPtr<CScriptDoor> door = mgr.ObjectById(x27e_partner2))
{
mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close);
x2a8_30_ = true;
}
x2a8_26_isOpen = false;
SetDoorAnimation(EDoorAnimType::Close);
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId());
}
break;
}
case EScriptObjectMessage::Open:
{
if (!GetActive() || x2a8_26_isOpen)
return;
u32 doorCond = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid)) ? 2 : GetDoorOpenCondition(mgr);
switch(doorCond)
{
case 1:
x2a8_27_ = true;
x280_ = uid;
break;
case 2:
OpenDoor(uid, mgr);
break;
default:
x2a8_25_= false;
x2a8_24_ = true;
break;
}
break;
}
case EScriptObjectMessage::InitializedInArea:
{
for (const SConnection& conn : x20_conns)
{
if (conn.x4_msg == EScriptObjectMessage::Increment)
{
TUniqueId dock = mgr.GetIdForScript(conn.x8_objId);
if (TCastToConstPtr<CScriptDock>(mgr.GetObjectById(dock)))
x282_dockId = dock;
}
}
break;
}
case EScriptObjectMessage::SetToZero:
{
x2a8_28_ = true;
mgr.MapWorldInfo()->SetDoorVisited(mgr.GetEditorIdForUniqueId(GetUniqueId()), true);
break;
}
case EScriptObjectMessage::SetToMax:
{
x2a8_28_ = false;
break;
}
default:
CActor::AcceptScriptMsg(msg, uid, mgr);
}
}
void CScriptDoor::Think(float dt, CStateManager& mgr)
{
if (!GetActive())
return;
if (!x2a8_26_useConservativeCameraDistance)
if (!x2a8_26_isOpen && x25c_animTime < 0.5f)
x25c_animTime += dt;
if (x2a8_27_ && GetDoorOpenCondition(mgr) == 2)
{
if (x25c_ < 0.5f)
x25c_ += dt;
x2a8_27_ = false;
OpenDoor(x280_, mgr);
}
if (x2a8_24_)
{
x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId());
x2a8_28_ = false;
x2a8_24_ = false;
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::Decrement);
x25c_animTime = 0.f;
x2a8_30_ = false;
}
if (x2a8_26_isOpen && !x64_modelData->IsAnimating())
RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
else
{
if (x2a8_25_ && !x64_modelData->IsAnimating())
{
x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId());
x2a8_28_ = false;
x2a8_27_ = false;
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
}
if (GetScannableObjectInfo())
AddMaterial(/*EMaterialTypes::Solid, */EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
else
AddMaterial(/*EMaterialTypes::Solid, */EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, mgr);
}
if (x64_modelData->IsAnimating())
{
float f1 = x64_modelData->GetAnimationDuration(s32(x260_doorState));
float f0 = x258_animLen;
f0 = f1 / f0;
f1 = f0 * dt;
UpdateAnimation(f1, mgr, true);
}
xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan;
}
void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager &mgr)
void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager &mgr) const
{
if (!xe4_30_outOfFrustum)
CPhysicsActor::Render(mgr);
@ -86,9 +236,9 @@ void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager
/* ORIGINAL 0-00 OFFSET: 8007E0BC */
void CScriptDoor::ForceClosed(CStateManager & mgr)
{
if (x2a8_26_useConservativeCameraDistance)
if (x2a8_26_isOpen)
{
x2a8_26_useConservativeCameraDistance = false;
x2a8_26_isOpen = false;
x2a8_25_ = false;
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(x8_uid);
@ -97,7 +247,7 @@ void CScriptDoor::ForceClosed(CStateManager & mgr)
SetDoorAnimation(EDoorAnimType::Close);
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
x25c_ = 0.f;
x25c_animTime = 0.f;
x2a8_27_ = false;
x2a8_30_ = false;
}
@ -110,17 +260,19 @@ void CScriptDoor::ForceClosed(CStateManager & mgr)
}
/* ORIGINAL 0-00 OFFSET: 8007E1C4 */
bool CScriptDoor::IsConnectedToArea(const CStateManager& mgr, TAreaId area)
bool CScriptDoor::IsConnectedToArea(const CStateManager& mgr, TAreaId areaId)
{
const CScriptDock* dock = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
if (dock)
const CScriptDock* dockEnt = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
if (dockEnt)
{
if (dock->GetDestinationAreaId() == area)
if (dockEnt->GetAreaId() == areaId)
return true;
const CWorld* world = mgr.GetWorld();
const CGameArea* area = world->GetAreaAlways(dockEnt->GetAreaId());
const CGameArea::Dock* dock = area->GetDock(dockEnt->GetDockId());
if (dock->GetConnectedAreaId(dockEnt->GetDockReference(mgr)) == areaId)
return true;
/*
* TODO: Determine what's going on here
* CWorld* world = mgr.GetWorld();
*/
}
return false;
}
@ -130,36 +282,115 @@ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr)
{
TEditorId eid = mgr.GetEditorIdForUniqueId(uid);
mgr.MapWorldInfo()->SetDoorVisited(eid, true);
x2a8_26_isOpen = true;
x2a8_25_ = true;
x2a8_27_ = false;
const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid));
if (door)
x27c_partner = door->GetUniqueId();
if (const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid)))
x27c_partner1 = door->GetUniqueId();
SetDoorAnimation(EDoorAnimType::Open);
if (x27c_partner != kInvalidUniqueId)
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
else
{
if (x27c_partner1 == kInvalidUniqueId)
SendScriptMsgs(EScriptObjectState::Open, mgr, EScriptObjectMessage::None);
else
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
/* TODO: Finish this */
if (TCastToConstPtr<CScriptDock> dock1 = mgr.GetObjectById(x282_dockId))
{
for (CEntity* ent : mgr.GetPlatformAndDoorObjectList())
{
TCastToConstPtr<CScriptDoor> door = ent;
if (!door || door->GetUniqueId() == GetUniqueId())
continue;
if(TCastToConstPtr<CScriptDock> dock2 = mgr.GetObjectById(door->x282_dockId))
{
if (dock1->GetCurrentConnectedAreaId(mgr) == dock2->GetAreaId() && dock2->GetCurrentConnectedAreaId(mgr) == dock1->GetAreaId())
{
x27e_partner2 = door->GetUniqueId();
mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Open);
}
}
}
}
if (x27c_partner1 == kInvalidUniqueId && x27e_partner2 == kInvalidUniqueId)
{
for (const SConnection& conn : x20_conns)
{
if (conn.x4_msg != EScriptObjectMessage::Open)
continue;
if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)))
x27e_partner2 = door->GetUniqueId();
}
}
}
/* ORIGINAL 0-00 OFFSET: 8007ED4C */
u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr)
{
const CScriptDock* dock = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
const TCastToPtr<CScriptDock> dock = mgr.ObjectById(x282_dockId);
if (!dock)
return 2;
if (x25c_ < 0.05f)
if (x25c_animTime < 0.05f || x2a8_30_)
return 1;
/* TODO: Finish this */
return 0;
TAreaId destArea = dock->GetAreaId();
if (destArea < 0 || destArea >= mgr.GetWorld()->GetNumAreas())
return 0;
if (!mgr.GetWorld()->AreSkyNeedsMet())
return 1;
TAreaId connArea = mgr.GetWorld()->GetAreaAlways(
dock->GetAreaId())->GetDock(
dock->GetDockId())->GetConnectedAreaId(dock->GetDockReference(mgr));
if (connArea == kInvalidAreaId)
return 0;
const CWorld* world = mgr.GetWorld();
const CGameArea* area = world->GetAreaAlways(connArea);
if (!area->IsPostConstructed())
{
mgr.SendScriptMsg(dock, GetUniqueId(), EScriptObjectMessage::SetToMax);
return 1;
}
if (area->GetPostConstructed()->x113c_ != 0)
return 1;
for (CEntity* ent : mgr.GetPlatformAndDoorObjectList())
{
TCastToPtr<CScriptDoor> door(ent);
if (!door || door->GetUniqueId() == GetUniqueId())
continue;
if (door->GetAreaIdAlways() == GetAreaIdAlways() && door->x2a8_25_)
{
if (door->x282_dockId != kInvalidUniqueId)
return 1;
}
}
for (CGameArea::CConstChainIterator aliveArea = world->GetChainHead(EChain::Alive); aliveArea != CWorld::GetAliveAreasEnd(); ++aliveArea)
{
if (aliveArea->GetAreaId() == area->GetAreaId())
continue;
if (!aliveArea->IsFinishedOccluding())
return 1;
}
//if (area->TryTakingOutOfARAM())
{
if (world->GetMapWorld()->IsMapAreasStreaming())
return 1;
}
return 2;
}
/* ORIGINAL 0-00 OFFSET: 8007E9D0 */
@ -171,7 +402,7 @@ void CScriptDoor::SetDoorAnimation(CScriptDoor::EDoorAnimType type)
modelData->AnimationData()->SetAnimation(CAnimPlaybackParms(s32(type), -1, 1.f, true), false);
}
rstl::optional_object<zeus::CAABox> CScriptDoor::GetProjectileBounds() const
std::experimental::optional<zeus::CAABox> CScriptDoor::GetProjectileBounds() const
{
if (x2a8_28_)
return {{x284_modelBounds.min + GetTranslation(), x284_modelBounds.max + GetTranslation()}};

Some files were not shown because too many files have changed in this diff Show More