From 711c3e0d2c658490a7d6561492877a49d4a00119 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 29 Apr 2018 20:12:41 -0700 Subject: [PATCH] Remove rstl::optional_object, various cleanups, implement CExplosion and CScriptDoor --- Editor/main.cpp | 2 + Runtime/CStateManager.cpp | 17 +- Runtime/CStateManager.hpp | 1 + Runtime/Character/CAnimData.cpp | 8 +- Runtime/Character/CCharacterFactory.cpp | 2 +- Runtime/Character/CParticleDatabase.cpp | 8 +- Runtime/Character/CParticleGenInfo.cpp | 2 +- Runtime/Character/CParticleGenInfo.hpp | 4 +- Runtime/Collision/CAreaOctTree.hpp | 2 +- Runtime/Collision/CCollisionActor.cpp | 4 +- Runtime/Collision/CCollisionActor.hpp | 2 +- Runtime/Collision/CCollisionResponseData.cpp | 4 +- Runtime/Collision/CCollisionResponseData.hpp | 8 +- Runtime/GameGlobalObjects.cpp | 1 + Runtime/GameGlobalObjects.hpp | 1 + Runtime/Graphics/CSkinnedModel.cpp | 2 +- Runtime/MP1/CSamusHud.cpp | 4 +- Runtime/MP1/MP1.cpp | 40 ++- Runtime/MP1/MP1.hpp | 1 + Runtime/MP1/World/CBeetle.cpp | 2 +- Runtime/MP1/World/CBeetle.hpp | 2 +- Runtime/MP1/World/CMetroidPrimeProjectile.cpp | 2 +- Runtime/MP1/World/CMetroidPrimeProjectile.hpp | 2 +- Runtime/Particle/CElementGen.cpp | 5 +- Runtime/Particle/CElementGen.hpp | 2 +- Runtime/Particle/CParticleElectric.cpp | 2 +- Runtime/Particle/CParticleElectric.hpp | 2 +- Runtime/Particle/CParticleGen.hpp | 2 +- Runtime/Particle/CParticleSwoosh.cpp | 2 +- Runtime/Particle/CParticleSwoosh.hpp | 2 +- Runtime/RetroTypes.hpp | 4 +- Runtime/Weapon/CBeamInfo.hpp | 2 +- Runtime/Weapon/CBeamProjectile.cpp | 31 +- Runtime/Weapon/CBeamProjectile.hpp | 24 +- Runtime/Weapon/CEnergyProjectile.cpp | 2 +- Runtime/Weapon/CEnergyProjectile.hpp | 2 +- Runtime/Weapon/CGameProjectile.cpp | 2 +- Runtime/Weapon/CGameProjectile.hpp | 8 +- Runtime/Weapon/CProjectileWeapon.cpp | 6 +- Runtime/Weapon/CProjectileWeapon.hpp | 8 +- Runtime/Weapon/CTargetableProjectile.cpp | 2 +- Runtime/Weapon/CTargetableProjectile.hpp | 2 +- Runtime/World/CActor.cpp | 2 +- Runtime/World/CActor.hpp | 2 +- Runtime/World/CGameArea.cpp | 8 + Runtime/World/CPlayer.cpp | 2 +- Runtime/World/CPlayer.hpp | 2 +- Runtime/World/CScriptActor.cpp | 2 +- Runtime/World/CScriptActor.hpp | 2 +- Runtime/World/CScriptAiJumpPoint.cpp | 2 +- Runtime/World/CScriptAiJumpPoint.hpp | 2 +- Runtime/World/CScriptCameraPitchVolume.cpp | 2 +- Runtime/World/CScriptCameraPitchVolume.hpp | 2 +- Runtime/World/CScriptCoverPoint.cpp | 2 +- Runtime/World/CScriptDamageableTrigger.cpp | 2 +- Runtime/World/CScriptDamageableTrigger.hpp | 2 +- Runtime/World/CScriptDebris.cpp | 2 +- Runtime/World/CScriptDebris.hpp | 2 +- Runtime/World/CScriptDock.cpp | 4 +- Runtime/World/CScriptDock.hpp | 4 +- Runtime/World/CScriptDoor.cpp | 265 ++++++++++++++++-- Runtime/World/CScriptDoor.hpp | 6 +- Runtime/World/CScriptPlatform.cpp | 4 +- Runtime/World/CScriptPlatform.hpp | 6 +- Runtime/World/CScriptPointOfInterest.cpp | 2 +- Runtime/World/CScriptPointOfInterest.hpp | 2 +- Runtime/World/CScriptSpecialFunction.hpp | 2 +- .../CScriptSpiderBallAttractionSurface.cpp | 2 +- .../CScriptSpiderBallAttractionSurface.hpp | 2 +- Runtime/World/CScriptTrigger.cpp | 10 +- Runtime/World/CScriptTrigger.hpp | 2 +- Runtime/World/CScriptVisorGoo.cpp | 2 +- Runtime/World/CScriptVisorGoo.hpp | 2 +- Runtime/World/CWorld.cpp | 13 + Runtime/World/CWorld.hpp | 1 + Runtime/World/ScriptLoader.cpp | 4 +- Runtime/World/ScriptObjectSupport.hpp | 68 ++--- Runtime/rstl.hpp | 3 - hecl | 2 +- 79 files changed, 486 insertions(+), 189 deletions(-) diff --git a/Editor/main.cpp b/Editor/main.cpp index f0dd8e582..5177198e8 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -118,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); diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 15b25d993..6222772f8 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -49,6 +49,7 @@ #include "World/CScriptDoor.hpp" #include "Input/ControlMapper.hpp" #include "MP1/MP1.hpp" +#include "GameGlobalObjects.hpp" #include @@ -209,6 +210,12 @@ CStateManager::CStateManager(const std::weak_ptr& relayTracker, CGameCollision::InitCollision(); ControlMapper::ResetCommandFilters(); x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow"); + g_StateManager = this; +} + +CStateManager::~CStateManager() +{ + g_StateManager = nullptr; } void CStateManager::UpdateThermalVisor() @@ -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 bounds = a2.GetTouchBounds(); + std::experimental::optional 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 bounds = damagee.GetTouchBounds(); + std::experimental::optional bounds = damagee.GetTouchBounds(); if (!bounds) return false; @@ -2098,7 +2105,7 @@ void CStateManager::CrossTouchActors() CActor& actor = static_cast(*ent); if (!actor.GetActive() || !actor.GetCallTouch()) continue; - rstl::optional_object touchAABB = actor.GetTouchBounds(); + std::experimental::optional touchAABB = actor.GetTouchBounds(); if (!touchAABB) continue; @@ -2115,7 +2122,7 @@ void CStateManager::CrossTouchActors() if (!ent2) continue; - rstl::optional_object touchAABB2 = ent2->GetTouchBounds(); + std::experimental::optional touchAABB2 = ent2->GetTouchBounds(); if (!ent2->GetActive() || !touchAABB2) continue; @@ -2465,7 +2472,7 @@ void CStateManager::UpdateSortedLists() std::experimental::optional CStateManager::CalculateObjectBounds(const CActor& actor) { - rstl::optional_object bounds = actor.GetTouchBounds(); + std::experimental::optional bounds = actor.GetTouchBounds(); if (bounds) { zeus::CAABox aabb; diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 64aa18bd5..aade03aaa 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -245,6 +245,7 @@ public: const std::weak_ptr&, const std::weak_ptr&, const std::weak_ptr&); + ~CStateManager(); u32 GetInputFrameIdx() const { return x8d4_inputFrameIdx; } bool RenderLast(TUniqueId); diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 689e918b6..b8b53d8fb 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -45,7 +45,7 @@ CAnimData::CAnimData(CAssetId id, int defaultAnim, int charIdx, bool loop, const TLockedToken& layout, const TToken& model, - const rstl::optional_object>& iceModel, + const std::experimental::optional>& iceModel, const std::weak_ptr& ctx, const std::shared_ptr& animMgr, const std::shared_ptr& 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& morphEffect, + const std::experimental::optional& 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& morphEffect, + const std::experimental::optional& morphEffect, const float* morphMagnitudes) { if (!x220_30_poseBuilt) @@ -949,7 +949,7 @@ void CAnimData::SetInfraModel(const TLockedToken& model, const TLockedTo void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags, - const rstl::optional_object& morphEffect, + const std::experimental::optional& morphEffect, const float* morphMagnitudes) { model.Calculate(pose, drawFlags, morphEffect, morphMagnitudes); diff --git a/Runtime/Character/CCharacterFactory.cpp b/Runtime/Character/CCharacterFactory.cpp index 338a7f649..436ca9e12 100644 --- a/Runtime/Character/CCharacterFactory.cpp +++ b/Runtime/Character/CCharacterFactory.cpp @@ -124,7 +124,7 @@ CCharacterFactory::CreateCharacter(int charIdx, bool loop, const_cast(this)->x70_cacheResPool.GetObj ({FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); - rstl::optional_object> iceModel; + std::experimental::optional> iceModel; if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj diff --git a/Runtime/Character/CParticleDatabase.cpp b/Runtime/Character/CParticleDatabase.cpp index fef2617f0..9762f2a3c 100644 --- a/Runtime/Character/CParticleDatabase.cpp +++ b/Runtime/Character/CParticleDatabase.cpp @@ -263,7 +263,8 @@ void CParticleDatabase::AddToRendererClippedParticleGenMap(const std::mapGetBounds())) + 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(); + } } } diff --git a/Runtime/Character/CParticleGenInfo.cpp b/Runtime/Character/CParticleGenInfo.cpp index f823cc882..9c208e7fe 100644 --- a/Runtime/Character/CParticleGenInfo.cpp +++ b/Runtime/Character/CParticleGenInfo.cpp @@ -130,7 +130,7 @@ void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager& bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); } -rstl::optional_object CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); } +std::experimental::optional CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); } bool CParticleGenInfoGeneric::HasActiveParticles() const { return x84_system->GetParticleCount() != 0; } diff --git a/Runtime/Character/CParticleGenInfo.hpp b/Runtime/Character/CParticleGenInfo.hpp index 6daac1abd..e7d516384 100644 --- a/Runtime/Character/CParticleGenInfo.hpp +++ b/Runtime/Character/CParticleGenInfo.hpp @@ -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 GetBounds() const = 0; + virtual std::experimental::optional 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 GetBounds() const; + std::experimental::optional GetBounds() const; bool HasActiveParticles() const; void DestroyParticles(); bool HasLight() const; diff --git a/Runtime/Collision/CAreaOctTree.hpp b/Runtime/Collision/CAreaOctTree.hpp index 288a3267a..294940815 100644 --- a/Runtime/Collision/CAreaOctTree.hpp +++ b/Runtime/Collision/CAreaOctTree.hpp @@ -17,7 +17,7 @@ public: struct SRayResult { zeus::CPlane x0_plane; - rstl::optional_object x10_surface; + std::experimental::optional x10_surface; float x3c_t; }; diff --git a/Runtime/Collision/CCollisionActor.cpp b/Runtime/Collision/CCollisionActor.cpp index eefb2da0e..0a934e4d2 100644 --- a/Runtime/Collision/CCollisionActor.cpp +++ b/Runtime/Collision/CCollisionActor.cpp @@ -138,9 +138,9 @@ zeus::CTransform CCollisionActor::GetPrimitiveTransform() const return xf; } -rstl::optional_object CCollisionActor::GetTouchBounds() const +std::experimental::optional CCollisionActor::GetTouchBounds() const { - rstl::optional_object aabox; + std::experimental::optional aabox; if (x258_primitiveType == EPrimitiveType::OBBTreeGroup) aabox = {x27c_obbTreeGroupPrimitive->CalculateAABox(x34_transform)}; else if (x258_primitiveType == EPrimitiveType::AABox) diff --git a/Runtime/Collision/CCollisionActor.hpp b/Runtime/Collision/CCollisionActor.hpp index d231e06cf..75a3655c5 100644 --- a/Runtime/Collision/CCollisionActor.hpp +++ b/Runtime/Collision/CCollisionActor.hpp @@ -49,7 +49,7 @@ public: zeus::CVector3f GetOrbitPosition(const CStateManager &) const; const CCollisionPrimitive* GetCollisionPrimitive() const; zeus::CTransform GetPrimitiveTransform() const; - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void SetDamageVulnerability(const CDamageVulnerability& vuln); const zeus::CVector3f& GetBoxSize() const { return x260_boxSize; } TUniqueId GetOwnerId() const { return x25c_owner; } diff --git a/Runtime/Collision/CCollisionResponseData.cpp b/Runtime/Collision/CCollisionResponseData.cpp index 57acc9088..da79453aa 100644 --- a/Runtime/Collision/CCollisionResponseData.cpp +++ b/Runtime/Collision/CCollisionResponseData.cpp @@ -179,7 +179,7 @@ CCollisionResponseData::CCollisionResponseData(CInputStream& in, CSimplePool* re } } -const rstl::optional_object>& +const std::experimental::optional>& 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>& +const std::experimental::optional>& CCollisionResponseData::GetDecalDescription(EWeaponCollisionResponseTypes type) const { return x20_decals[u32(type)]; diff --git a/Runtime/Collision/CCollisionResponseData.hpp b/Runtime/Collision/CCollisionResponseData.hpp index a4d38a26e..b137c3e39 100644 --- a/Runtime/Collision/CCollisionResponseData.hpp +++ b/Runtime/Collision/CCollisionResponseData.hpp @@ -46,9 +46,9 @@ class CCollisionResponseData { static const EWeaponCollisionResponseTypes skWorldMaterialTable[32]; static const s32 kInvalidSFX; - std::vector>> x0_generators; + std::vector>> x0_generators; std::vector x10_sfx; - std::vector>> x20_decals; + std::vector>> 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>& GetParticleDescription(EWeaponCollisionResponseTypes) const; - const rstl::optional_object>& GetDecalDescription(EWeaponCollisionResponseTypes type) const; + const std::experimental::optional>& GetParticleDescription(EWeaponCollisionResponseTypes) const; + const std::experimental::optional>& GetDecalDescription(EWeaponCollisionResponseTypes type) const; s32 GetSoundEffectId(EWeaponCollisionResponseTypes) const; static EWeaponCollisionResponseTypes GetWorldCollisionResponseType(s32); static bool ResponseTypeIsEnemyShielded(EWeaponCollisionResponseTypes); diff --git a/Runtime/GameGlobalObjects.cpp b/Runtime/GameGlobalObjects.cpp index d6e250503..b01cdebb8 100644 --- a/Runtime/GameGlobalObjects.cpp +++ b/Runtime/GameGlobalObjects.cpp @@ -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; diff --git a/Runtime/GameGlobalObjects.hpp b/Runtime/GameGlobalObjects.hpp index 3995b0594..f1b616c7f 100644 --- a/Runtime/GameGlobalObjects.hpp +++ b/Runtime/GameGlobalObjects.hpp @@ -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; diff --git a/Runtime/Graphics/CSkinnedModel.cpp b/Runtime/Graphics/CSkinnedModel.cpp index 15f3f6f21..4ea8795e0 100644 --- a/Runtime/Graphics/CSkinnedModel.cpp +++ b/Runtime/Graphics/CSkinnedModel.cpp @@ -33,7 +33,7 @@ CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags, - const rstl::optional_object& morphEffect, + const std::experimental::optional& morphEffect, const float* morphMagnitudes) { if (morphEffect || g_PointGenFunc) diff --git a/Runtime/MP1/CSamusHud.cpp b/Runtime/MP1/CSamusHud.cpp index d80d0cb7d..40c4aef92 100644 --- a/Runtime/MP1/CSamusHud.cpp +++ b/Runtime/MP1/CSamusHud.cpp @@ -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 aabb = player.GetTouchBounds()) + if (std::experimental::optional 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 aabb = trigger->GetTouchBounds()) + if (std::experimental::optional aabb = trigger->GetTouchBounds()) { float dist = playerAABB.distanceBetween(*aabb); if (dist < threatDist) diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 0ffd3c202..b20e73008 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -54,7 +54,8 @@ #include "Audio/CMidiManager.hpp" #include "CDependencyGroup.hpp" #include "MP1OriginalIDs.hpp" - +#include "CStateManager.hpp" +#include "World/CPlayer.hpp" #include namespace hecl @@ -449,18 +450,6 @@ void CMain::EnsureWorldPakReady(CAssetId mlvl) void CMain::Give(hecl::Console* console, const std::vector& args) { - if (!hecl::com_developer->toBoolean()) - { - console->report(hecl::Console::Level::Info, "Cheats are only available in developer mode"); - return; - } - - if (!hecl::com_enableCheats->toBoolean()) - { - console->report(hecl::Console::Level::Info, "Cheats are not enabled"); - return; - } - if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState())) return; @@ -501,6 +490,28 @@ void CMain::Give(hecl::Console* console, const std::vector& args) } } +void CMain::Teleport(hecl::Console *, const std::vector& 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(); @@ -603,7 +614,8 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, m_cvarMgr = cvarMgr; m_console = std::make_unique(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)); + 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); diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 6f1971a66..1053a739f 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -329,6 +329,7 @@ public: m_doQuit = true; } void Give(hecl::Console*, const std::vector&); + void Teleport(hecl::Console*, const std::vector&); hecl::Console* Console() const { return m_console.get(); } }; diff --git a/Runtime/MP1/World/CBeetle.cpp b/Runtime/MP1/World/CBeetle.cpp index 4ce510a89..b6c1b6c64 100644 --- a/Runtime/MP1/World/CBeetle.cpp +++ b/Runtime/MP1/World/CBeetle.cpp @@ -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) + const CActorParameters& aParams, const std::experimental::optional) : CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, aParams, bool(flavor)) { diff --git a/Runtime/MP1/World/CBeetle.hpp b/Runtime/MP1/World/CBeetle.hpp index 8e91ec491..398662b9f 100644 --- a/Runtime/MP1/World/CBeetle.hpp +++ b/Runtime/MP1/World/CBeetle.hpp @@ -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); + const std::experimental::optional); void Accept(IVisitor &visitor); }; diff --git a/Runtime/MP1/World/CMetroidPrimeProjectile.cpp b/Runtime/MP1/World/CMetroidPrimeProjectile.cpp index 35bbab271..78c4a8dcc 100644 --- a/Runtime/MP1/World/CMetroidPrimeProjectile.cpp +++ b/Runtime/MP1/World/CMetroidPrimeProjectile.cpp @@ -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>& visorParticle, + const std::experimental::optional>& 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) diff --git a/Runtime/MP1/World/CMetroidPrimeProjectile.hpp b/Runtime/MP1/World/CMetroidPrimeProjectile.hpp index c4e99a92c..6e7df74cd 100644 --- a/Runtime/MP1/World/CMetroidPrimeProjectile.hpp +++ b/Runtime/MP1/World/CMetroidPrimeProjectile.hpp @@ -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>& visorParticle, + const std::experimental::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); }; diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 52bf256d9..c4278b556 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -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); @@ -1936,10 +1937,10 @@ bool CElementGen::IsSystemDeletable() const return false; } -rstl::optional_object CElementGen::GetBounds() const +std::experimental::optional CElementGen::GetBounds() const { if (GetParticleCountAll() == 0) - return {}; + return std::experimental::nullopt; else return {x2f0_systemBounds}; } diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index bcf79fab1..04dba8261 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -228,7 +228,7 @@ public: const zeus::CColor& GetModulationColor() const; float GetGeneratorRate() const { return x98_generatorRate; } bool IsSystemDeletable() const; - rstl::optional_object GetBounds() const; + std::experimental::optional GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleElectric.cpp b/Runtime/Particle/CParticleElectric.cpp index 1086f6105..d7a792d86 100644 --- a/Runtime/Particle/CParticleElectric.cpp +++ b/Runtime/Particle/CParticleElectric.cpp @@ -815,7 +815,7 @@ bool CParticleElectric::IsSystemDeletable() const return true; } -rstl::optional_object CParticleElectric::GetBounds() const +std::experimental::optional CParticleElectric::GetBounds() const { if (GetParticleCount() <= 0) return {}; diff --git a/Runtime/Particle/CParticleElectric.hpp b/Runtime/Particle/CParticleElectric.hpp index 7825dc68e..13cf4d618 100644 --- a/Runtime/Particle/CParticleElectric.hpp +++ b/Runtime/Particle/CParticleElectric.hpp @@ -127,7 +127,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - rstl::optional_object GetBounds() const; + std::experimental::optional GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleGen.hpp b/Runtime/Particle/CParticleGen.hpp index 66c0deb69..7b2f095c4 100644 --- a/Runtime/Particle/CParticleGen.hpp +++ b/Runtime/Particle/CParticleGen.hpp @@ -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 GetBounds() const=0; + virtual std::experimental::optional GetBounds() const=0; virtual u32 GetParticleCount() const=0; virtual bool SystemHasLight() const=0; virtual CLight GetLight() const=0; diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 4ac74e1ba..915d455ab 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -1150,7 +1150,7 @@ bool CParticleSwoosh::IsSystemDeletable() const return true; } -rstl::optional_object CParticleSwoosh::GetBounds() const +std::experimental::optional CParticleSwoosh::GetBounds() const { if (GetParticleCount() <= 1) { diff --git a/Runtime/Particle/CParticleSwoosh.hpp b/Runtime/Particle/CParticleSwoosh.hpp index 5d154cd0d..789abebc0 100644 --- a/Runtime/Particle/CParticleSwoosh.hpp +++ b/Runtime/Particle/CParticleSwoosh.hpp @@ -150,7 +150,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - rstl::optional_object GetBounds() const; + std::experimental::optional GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/RetroTypes.hpp b/Runtime/RetroTypes.hpp index fe74be8c5..a50b4c685 100644 --- a/Runtime/RetroTypes.hpp +++ b/Runtime/RetroTypes.hpp @@ -146,7 +146,7 @@ public: } } - rstl::optional_object GetAverage() const + std::experimental::optional GetAverage() const { if (this->empty()) return {}; @@ -154,7 +154,7 @@ public: return {urde::GetAverage(this->data(), this->size())}; } - rstl::optional_object GetEntry(int i) const + std::experimental::optional GetEntry(int i) const { if (i >= this->size()) return {}; diff --git a/Runtime/Weapon/CBeamInfo.hpp b/Runtime/Weapon/CBeamInfo.hpp index 3ac2e6463..19bf604c3 100644 --- a/Runtime/Weapon/CBeamInfo.hpp +++ b/Runtime/Weapon/CBeamInfo.hpp @@ -15,7 +15,7 @@ struct CBeamInfo CAssetId xc_; CAssetId x10_; CAssetId x14_; - u32 x18_; + s32 x18_; float x1c_; float x20_; float x24_; diff --git a/Runtime/Weapon/CBeamProjectile.cpp b/Runtime/Weapon/CBeamProjectile.cpp index 73cf61bf4..acfb0740f 100644 --- a/Runtime/Weapon/CBeamProjectile.cpp +++ b/Runtime/Weapon/CBeamProjectile.cpp @@ -5,37 +5,46 @@ namespace urde { CBeamProjectile::CBeamProjectile(const TToken& 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 CBeamProjectile::GetTouchBounds() const +std::experimental::optional 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) diff --git a/Runtime/Weapon/CBeamProjectile.hpp b/Runtime/Weapon/CBeamProjectile.hpp index e2fd9e95b..a6bc91494 100644 --- a/Runtime/Weapon/CBeamProjectile.hpp +++ b/Runtime/Weapon/CBeamProjectile.hpp @@ -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 x384_; + rstl::reserved_vector x400_; + bool x464_24_ : 1; + bool x464_25_ : 1; public: CBeamProjectile(const TToken& 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 GetTouchBounds() const; - void Touch(CActor&, CStateManager&); + std::experimental::optional GetTouchBounds() const; + void CalculateRenderBounds(); virtual void ResetBeam(CStateManager&, bool); virtual void UpdateFX(const zeus::CTransform&, float, CStateManager&); }; diff --git a/Runtime/Weapon/CEnergyProjectile.cpp b/Runtime/Weapon/CEnergyProjectile.cpp index ef60e4eb4..4b0c909f3 100644 --- a/Runtime/Weapon/CEnergyProjectile.cpp +++ b/Runtime/Weapon/CEnergyProjectile.cpp @@ -19,7 +19,7 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken>& visorParticle, + const std::experimental::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CGameProjectile(active, desc, "GameProjectile", type, xf, excludeMat, damage, uid, aid, owner, homingTarget, attribs, underwater, scale, visorParticle, visorSfx, sendCollideMsg), diff --git a/Runtime/Weapon/CEnergyProjectile.hpp b/Runtime/Weapon/CEnergyProjectile.hpp index 21237ca42..6d176fbe7 100644 --- a/Runtime/Weapon/CEnergyProjectile.hpp +++ b/Runtime/Weapon/CEnergyProjectile.hpp @@ -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>& visorParticle, + const std::experimental::optional>& 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); diff --git a/Runtime/Weapon/CGameProjectile.cpp b/Runtime/Weapon/CGameProjectile.cpp index 92439c5ec..431e06be7 100644 --- a/Runtime/Weapon/CGameProjectile.cpp +++ b/Runtime/Weapon/CGameProjectile.cpp @@ -18,7 +18,7 @@ CGameProjectile::CGameProjectile(bool active, const TToken& const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale, - const rstl::optional_object>& visorParticle, + const std::experimental::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CWeapon(uid, aid, active, owner, wType, name, xf, CMaterialFilter::MakeIncludeExclude( diff --git a/Runtime/Weapon/CGameProjectile.hpp b/Runtime/Weapon/CGameProjectile.hpp index 8a2141d5d..a33863e4f 100644 --- a/Runtime/Weapon/CGameProjectile.hpp +++ b/Runtime/Weapon/CGameProjectile.hpp @@ -18,9 +18,9 @@ class CWeaponDescription; class CProjectileTouchResult { TUniqueId x0_id; - rstl::optional_object x4_result; + std::experimental::optional x4_result; public: - CProjectileTouchResult(TUniqueId id, const rstl::optional_object& result) + CProjectileTouchResult(TUniqueId id, const std::experimental::optional& 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> x158_visorParticle; + std::experimental::optional> 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>& visorParticle, + const std::experimental::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); virtual void Accept(IVisitor &visitor); diff --git a/Runtime/Weapon/CProjectileWeapon.cpp b/Runtime/Weapon/CProjectileWeapon.cpp index 8c6c81cc0..d225d986b 100644 --- a/Runtime/Weapon/CProjectileWeapon.cpp +++ b/Runtime/Weapon/CProjectileWeapon.cpp @@ -91,7 +91,7 @@ zeus::CVector3f CProjectileWeapon::GetTranslation() const return x14_localToWorldXf * (x44_localXf * x8c_projOffset + x80_localOffset) + x74_worldOffset; } -rstl::optional_object CProjectileWeapon::GetBounds() const +std::experimental::optional 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> +std::experimental::optional> 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> +std::experimental::optional> CProjectileWeapon::CollisionOccured(EWeaponCollisionResponseTypes type, bool deflected, bool useTarget, const zeus::CVector3f& pos, const zeus::CVector3f& normal, const zeus::CVector3f& target) diff --git a/Runtime/Weapon/CProjectileWeapon.hpp b/Runtime/Weapon/CProjectileWeapon.hpp index 19541f60a..9224decd1 100644 --- a/Runtime/Weapon/CProjectileWeapon.hpp +++ b/Runtime/Weapon/CProjectileWeapon.hpp @@ -45,7 +45,7 @@ class CProjectileWeapon std::unique_ptr xfc_APSMGen; std::unique_ptr x100_APS2Gen; std::unique_ptr x104_; - rstl::optional_object> x108_model; + std::experimental::optional> x108_model; std::unique_ptr x118_swoosh1; std::unique_ptr x11c_swoosh2; std::unique_ptr 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 GetBounds() const; + std::experimental::optional 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> + std::experimental::optional> GetDecalForCollision(EWeaponCollisionResponseTypes type) const; u16 GetSoundIdForCollision(EWeaponCollisionResponseTypes type) const; - rstl::optional_object> + std::experimental::optional> CollisionOccured(EWeaponCollisionResponseTypes type, bool deflected, bool useTarget, const zeus::CVector3f& pos, const zeus::CVector3f& normal, const zeus::CVector3f& target); TLockedToken GetWeaponDescription() const { return x4_weaponDesc; } diff --git a/Runtime/Weapon/CTargetableProjectile.cpp b/Runtime/Weapon/CTargetableProjectile.cpp index 38613d3a2..3c358426f 100644 --- a/Runtime/Weapon/CTargetableProjectile.cpp +++ b/Runtime/Weapon/CTargetableProjectile.cpp @@ -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>& visorParticle, + const std::experimental::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CEnergyProjectile(true, desc, type, xf, materials, damage, uid, aid, owner, homingTarget, attribs | EProjectileAttrib::BigProjectile | EProjectileAttrib::PartialCharge | diff --git a/Runtime/Weapon/CTargetableProjectile.hpp b/Runtime/Weapon/CTargetableProjectile.hpp index 12f166b2b..2a8c3fff3 100644 --- a/Runtime/Weapon/CTargetableProjectile.hpp +++ b/Runtime/Weapon/CTargetableProjectile.hpp @@ -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>& visorParticle, + const std::experimental::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); }; diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index b849df8c5..3f9d1cbaa 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -349,7 +349,7 @@ const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f return GetDamageVulnerability(); } -rstl::optional_object CActor::GetTouchBounds() const { return {}; } +std::experimental::optional CActor::GetTouchBounds() const { return {}; } void CActor::Touch(CActor&, CStateManager&) {} diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 7ce23346e..46e90c9a2 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -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 GetTouchBounds() const; + virtual std::experimental::optional GetTouchBounds() const; virtual void Touch(CActor&, CStateManager&); virtual zeus::CVector3f GetOrbitPosition(const CStateManager&) const; virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) const; diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 6a49fa4e0..d1447b05c 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -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, s32> CGameArea::IGetScriptingMemoryAlways() const { return GetScriptingMemoryAlways(*this); diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 3beeb1399..0d6769063 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -1058,7 +1058,7 @@ bool CPlayer::IsUnderBetaMetroidAttack(CStateManager& mgr) const return false; } -rstl::optional_object CPlayer::GetTouchBounds() const +std::experimental::optional CPlayer::GetTouchBounds() const { if (x2f8_morphBallState == EPlayerMorphBallState::Morphed) { diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 2463f73a8..a777f49b5 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -461,7 +461,7 @@ public: void Accept(IVisitor& visitor); CHealthInfo* HealthInfo(CStateManager& mgr); bool IsUnderBetaMetroidAttack(CStateManager& mgr) const; - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor& actor, CStateManager& mgr); void DoPreThink(float dt, CStateManager& mgr); void DoThink(float dt, CStateManager& mgr); diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index 21673b8cb..0480a2e50 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -193,7 +193,7 @@ CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CV return CActor::GetCollisionResponseType(v1, v2, wMode, w); } -rstl::optional_object CScriptActor::GetTouchBounds() const +std::experimental::optional CScriptActor::GetTouchBounds() const { if (GetActive() && x68_material.HasMaterial(EMaterialTypes::Solid)) return {CPhysicsActor::GetBoundingBox()}; diff --git a/Runtime/World/CScriptActor.hpp b/Runtime/World/CScriptActor.hpp index f56e4072e..4a0a6303f 100644 --- a/Runtime/World/CScriptActor.hpp +++ b/Runtime/World/CScriptActor.hpp @@ -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 GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); const CDamageVulnerability* GetDamageVulnerability() const { return &x268_damageVulnerability; } CHealthInfo* HealthInfo(CStateManager&) { return &x260_currentHealth; } diff --git a/Runtime/World/CScriptAiJumpPoint.cpp b/Runtime/World/CScriptAiJumpPoint.cpp index b88976cf4..4aabf1c68 100644 --- a/Runtime/World/CScriptAiJumpPoint.cpp +++ b/Runtime/World/CScriptAiJumpPoint.cpp @@ -50,7 +50,7 @@ void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId oth } } -rstl::optional_object CScriptAiJumpPoint::GetTouchBounds() const { return xec_; } +std::experimental::optional CScriptAiJumpPoint::GetTouchBounds() const { return xec_; } bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const { diff --git a/Runtime/World/CScriptAiJumpPoint.hpp b/Runtime/World/CScriptAiJumpPoint.hpp index 5e7385af7..f69af899a 100644 --- a/Runtime/World/CScriptAiJumpPoint.hpp +++ b/Runtime/World/CScriptAiJumpPoint.hpp @@ -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 GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; bool GetInUse(TUniqueId uid) const; }; } diff --git a/Runtime/World/CScriptCameraPitchVolume.cpp b/Runtime/World/CScriptCameraPitchVolume.cpp index acaeb2662..14cacbd99 100644 --- a/Runtime/World/CScriptCameraPitchVolume.cpp +++ b/Runtime/World/CScriptCameraPitchVolume.cpp @@ -43,7 +43,7 @@ void CScriptCameraPitchVolume::Think(float, CStateManager& mgr) x13c_24_entered = false; } -rstl::optional_object CScriptCameraPitchVolume::GetTouchBounds() const +std::experimental::optional CScriptCameraPitchVolume::GetTouchBounds() const { return {xe8_obbox.calculateAABox(zeus::CTransform::Identity())}; } diff --git a/Runtime/World/CScriptCameraPitchVolume.hpp b/Runtime/World/CScriptCameraPitchVolume.hpp index 167504c0d..9d1d50c5b 100644 --- a/Runtime/World/CScriptCameraPitchVolume.hpp +++ b/Runtime/World/CScriptCameraPitchVolume.hpp @@ -31,7 +31,7 @@ public: void Accept(IVisitor& visitor); void Think(float, CStateManager&); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); float GetUpPitch() const { return x124_upPitch; } float GetDownPitch() const { return x128_downPitch; } diff --git a/Runtime/World/CScriptCoverPoint.cpp b/Runtime/World/CScriptCoverPoint.cpp index 2698cfedc..82ef7d984 100644 --- a/Runtime/World/CScriptCoverPoint.cpp +++ b/Runtime/World/CScriptCoverPoint.cpp @@ -30,7 +30,7 @@ void CScriptCoverPoint::Think(float delta, CStateManager&) x11c_timeLeft -= delta; } -rstl::optional_object CScriptCoverPoint::GetTouchBounds() const +std::experimental::optional CScriptCoverPoint::GetTouchBounds() const { if (x100_touchBounds) return x100_touchBounds; diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp index d140a2818..cd813c57a 100644 --- a/Runtime/World/CScriptDamageableTrigger.cpp +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -227,7 +227,7 @@ void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr) } } -rstl::optional_object CScriptDamageableTrigger::GetTouchBounds() const +std::experimental::optional CScriptDamageableTrigger::GetTouchBounds() const { if (!x30_24_active || !x300_24_notOccluded) return {}; diff --git a/Runtime/World/CScriptDamageableTrigger.hpp b/Runtime/World/CScriptDamageableTrigger.hpp index 5021682d0..527dc68d0 100644 --- a/Runtime/World/CScriptDamageableTrigger.hpp +++ b/Runtime/World/CScriptDamageableTrigger.hpp @@ -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 GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; }; } diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index 4a613df4b..da6f62ac7 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -36,7 +36,7 @@ void CScriptDebris::Accept(IVisitor& visitor) visitor.Visit(this); } -rstl::optional_object CScriptDebris::GetTouchBounds() const +std::experimental::optional CScriptDebris::GetTouchBounds() const { return {}; } diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index a3eb30a17..9c4c9da6a 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -40,7 +40,7 @@ public: bool, bool, bool, bool); void Accept(IVisitor& visitor); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void CollidedWith(TUniqueId uid, const CCollisionInfoList&, CStateManager&); }; diff --git a/Runtime/World/CScriptDock.cpp b/Runtime/World/CScriptDock.cpp index fba12be3f..4c52cc66d 100644 --- a/Runtime/World/CScriptDock.cpp +++ b/Runtime/World/CScriptDock.cpp @@ -167,7 +167,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat } } -rstl::optional_object CScriptDock::GetTouchBounds() const +std::experimental::optional CScriptDock::GetTouchBounds() const { if (x264_dockState == EDockState::Three) return {}; @@ -196,7 +196,7 @@ 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(); } diff --git a/Runtime/World/CScriptDock.hpp b/Runtime/World/CScriptDock.hpp index 20af24c91..582e5c498 100644 --- a/Runtime/World/CScriptDock.hpp +++ b/Runtime/World/CScriptDock.hpp @@ -39,14 +39,14 @@ public: void Accept(IVisitor& visitor); void Think(float, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); void CleanUp() {} zeus::CPlane GetPlane(const CStateManager&) const; TAreaId GetDestinationAreaId() 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; diff --git a/Runtime/World/CScriptDoor.cpp b/Runtime/World/CScriptDoor.cpp index 781d75a9c..6b8fc28e1 100644 --- a/Runtime/World/CScriptDoor.cpp +++ b/Runtime/World/CScriptDoor.cpp @@ -28,10 +28,11 @@ 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) + bool open, bool b2, float f1, bool ballDoor) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeDoorMaterialList(open), aabb, SMoverData(1.f), actParms, 0.3f, 0.1f) { + x258_ = f1; x2a8_29_ballDoor = ballDoor; x2a8_25_ = open; x2a8_26_useConservativeCameraDistance = open; @@ -60,11 +61,112 @@ 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 || uid != x27c_partner1) + return; + + if (x2a8_26_useConservativeCameraDistance) + { + if (x27e_partner2 != kInvalidUniqueId) + { + if (CEntity* ent = mgr.ObjectById(x27e_partner2)) + mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Close); + } + x2a8_26_useConservativeCameraDistance = 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 door = mgr.ObjectById(x27c_partner1)) + { + if (x2a8_26_useConservativeCameraDistance) + return; + x2a8_30_ = true; + mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close); + } + } + else if (x2a8_26_useConservativeCameraDistance) + { + x2a8_30_ = true; + if (TCastToPtr door = mgr.ObjectById(x27e_partner2)) + { + mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close); + x2a8_30_ = true; + } + x2a8_26_useConservativeCameraDistance = false; + SetDoorAnimation(EDoorAnimType::Close); + mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId()); + } + break; + } + case EScriptObjectMessage::Open: + { + if (!GetActive() || x2a8_26_useConservativeCameraDistance) + return; + + u32 doorCond = TCastToConstPtr(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(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()) @@ -75,6 +177,44 @@ void CScriptDoor::Think(float dt, CStateManager& mgr) if (x25c_ < 0.5f) x25c_ += dt; } + + if (x2a8_27_ && GetDoorOpenCondition(mgr) == 2) + { + 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); + x2a8_30_ = false; + x25c_ = 0.f; + } + + if (x2a8_26_useConservativeCameraDistance && 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()) + UpdateAnimation((x64_modelData->GetAnimationDuration(s32(x260_doorState)) / x258_) * dt, mgr, true); + + xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan; } void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager &mgr) @@ -110,17 +250,17 @@ 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(mgr.GetObjectById(x282_dockId)); if (dock) { - if (dock->GetDestinationAreaId() == area) + if (dock->GetDestinationAreaId() == areaId) + return true; + + const CGameArea* area = mgr.GetWorld()->GetAreaAlways(areaId); + if (area->GetDock(dock->GetDockId())->GetConnectedAreaId(dock->GetDockReference(mgr)) == areaId) return true; - /* - * TODO: Determine what's going on here - * CWorld* world = mgr.GetWorld(); - */ } return false; } @@ -130,36 +270,117 @@ void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr) { TEditorId eid = mgr.GetEditorIdForUniqueId(uid); mgr.MapWorldInfo()->SetDoorVisited(eid, true); + x2a8_26_useConservativeCameraDistance = true; + x2a8_25_ = true; + x2a8_27_ = false; const CScriptDoor* door = TCastToConstPtr(mgr.GetObjectById(uid)); if (door) - x27c_partner = door->GetUniqueId(); + 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 dock1 = mgr.GetObjectById(x282_dockId)) + { + for (CEntity* ent : mgr.GetPlatformAndDoorObjectList()) + { + TCastToConstPtr door = ent; + if (!door || door->GetUniqueId() == GetUniqueId()) + continue; + + if(TCastToConstPtr dock2 = mgr.GetObjectById(door->x282_dockId)) + { + if (dock1->GetCurrentConnectedAreaId(mgr) == dock2->GetDestinationAreaId() && dock2->GetCurrentConnectedAreaId(mgr) == dock1->GetDestinationAreaId()) + { + 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 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(mgr.GetObjectById(x282_dockId)); - + const TCastToPtr dock = mgr.ObjectById(x282_dockId); if (!dock) return 2; - if (x25c_ < 0.05f) + if (x25c_ < 0.05f || x2a8_30_) return 1; - /* TODO: Finish this */ - return 0; + TAreaId destArea = dock->GetDestinationAreaId(); + if (destArea < 0 || destArea > mgr.GetWorld()->GetNumAreas()) + return 0; + + if (!mgr.GetWorld()->AreSkyNeedsMet()) + return 1; + + TAreaId connArea = mgr.GetWorld()->GetAreaAlways( + dock->GetDestinationAreaId())->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 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 +392,7 @@ void CScriptDoor::SetDoorAnimation(CScriptDoor::EDoorAnimType type) modelData->AnimationData()->SetAnimation(CAnimPlaybackParms(s32(type), -1, 1.f, true), false); } -rstl::optional_object CScriptDoor::GetProjectileBounds() const +std::experimental::optional CScriptDoor::GetProjectileBounds() const { if (x2a8_28_) return {{x284_modelBounds.min + GetTranslation(), x284_modelBounds.max + GetTranslation()}}; diff --git a/Runtime/World/CScriptDoor.hpp b/Runtime/World/CScriptDoor.hpp index 2eec3b28e..e242e231f 100644 --- a/Runtime/World/CScriptDoor.hpp +++ b/Runtime/World/CScriptDoor.hpp @@ -17,10 +17,12 @@ public: Ready, }; + float x258_; float x25c_; EDoorAnimType x260_doorState = EDoorAnimType::Open; zeus::CAABox x264_; - TUniqueId x27c_partner = kInvalidUniqueId; + TUniqueId x27c_partner1 = kInvalidUniqueId; + TUniqueId x27e_partner2 = kInvalidUniqueId; TUniqueId x280_ = kInvalidUniqueId; TUniqueId x282_dockId = kInvalidUniqueId; zeus::CAABox x284_modelBounds; @@ -67,7 +69,7 @@ public: void OpenDoor(TUniqueId, CStateManager&); u32 GetDoorOpenCondition(CStateManager& mgr); void SetDoorAnimation(EDoorAnimType); - rstl::optional_object GetProjectileBounds() const; + std::experimental::optional GetProjectileBounds() const; }; } diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index 699521e8f..0b9d2f96d 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -20,7 +20,7 @@ CScriptPlatform::CScriptPlatform(TUniqueId uid, std::string_view name, const CEn const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float f1, bool, float f2, bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, - const rstl::optional_object>& dcln, + const std::experimental::optional>& dcln, bool, u32, u32) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(), aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f) @@ -38,7 +38,7 @@ CScriptPlatform::CScriptPlatform(TUniqueId uid, std::string_view name, const CEn void CScriptPlatform::Accept(IVisitor& visitor) { visitor.Visit(this); } -rstl::optional_object CScriptPlatform::GetTouchBounds() const +std::experimental::optional CScriptPlatform::GetTouchBounds() const { if (x314_treeGroup) return {x314_treeGroup->CalculateAABox(GetTransform())}; diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index dde77f554..674130769 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -34,7 +34,7 @@ class CScriptPlatform : public CPhysicsActor CHealthInfo x28c_; CHealthInfo x294_; CDamageVulnerability x29c_; - rstl::optional_object> x304_treeGroupContainer; + std::experimental::optional> x304_treeGroupContainer; std::unique_ptr x314_treeGroup; std::vector x318_riders; std::vector x328_slaves1; @@ -63,10 +63,10 @@ public: CScriptPlatform(TUniqueId, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float, bool, float, bool, const CHealthInfo& hInfo, const CDamageVulnerability& dInfo, - const rstl::optional_object>& dcln, bool, u32, u32); + const std::experimental::optional>& dcln, bool, u32, u32); void Accept(IVisitor& visitor); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; bool IsRider(TUniqueId id) const; bool IsSlave(TUniqueId id) const; std::vector& GetX328() { return x328_slaves1; } diff --git a/Runtime/World/CScriptPointOfInterest.cpp b/Runtime/World/CScriptPointOfInterest.cpp index 38b60f159..c384eaeb7 100644 --- a/Runtime/World/CScriptPointOfInterest.cpp +++ b/Runtime/World/CScriptPointOfInterest.cpp @@ -48,7 +48,7 @@ void CScriptPointOfInterest::CalculateRenderBounds() x9c_renderBounds = zeus::CAABox(x34_transform.origin - xe8_pointSize, x34_transform.origin + xe8_pointSize); } -rstl::optional_object CScriptPointOfInterest::GetTouchBounds() const +std::experimental::optional CScriptPointOfInterest::GetTouchBounds() const { return {zeus::CAABox{x34_transform.origin, x34_transform.origin}}; } diff --git a/Runtime/World/CScriptPointOfInterest.hpp b/Runtime/World/CScriptPointOfInterest.hpp index 7c51fa353..32374da91 100644 --- a/Runtime/World/CScriptPointOfInterest.hpp +++ b/Runtime/World/CScriptPointOfInterest.hpp @@ -20,7 +20,7 @@ public: void AddToRenderer(const zeus::CFrustum &, const CStateManager &) const; void Render(const CStateManager &) const; void CalculateRenderBounds(); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; }; } #endif // __URDE_CSCRIPTPOINTOFINTEREST_HPP__ diff --git a/Runtime/World/CScriptSpecialFunction.hpp b/Runtime/World/CScriptSpecialFunction.hpp index 818aeb272..47916ff67 100644 --- a/Runtime/World/CScriptSpecialFunction.hpp +++ b/Runtime/World/CScriptSpecialFunction.hpp @@ -91,7 +91,7 @@ private: CAssetId x1bc_; CAssetId x1c0_; CAssetId x1c4_; - rstl::optional_object x1c8_; + std::experimental::optional x1c8_; union { struct diff --git a/Runtime/World/CScriptSpiderBallAttractionSurface.cpp b/Runtime/World/CScriptSpiderBallAttractionSurface.cpp index 5ce95a2e5..7062910f9 100644 --- a/Runtime/World/CScriptSpiderBallAttractionSurface.cpp +++ b/Runtime/World/CScriptSpiderBallAttractionSurface.cpp @@ -29,7 +29,7 @@ void CScriptSpiderBallAttractionSurface::AcceptScriptMsg(EScriptObjectMessage ms CActor::AcceptScriptMsg(msg, sender, mgr); } -rstl::optional_object CScriptSpiderBallAttractionSurface::GetTouchBounds() const +std::experimental::optional CScriptSpiderBallAttractionSurface::GetTouchBounds() const { if (GetActive()) return {zeus::CAABox(xf4_aabb.min + GetTranslation(), xf4_aabb.max + GetTranslation())}; diff --git a/Runtime/World/CScriptSpiderBallAttractionSurface.hpp b/Runtime/World/CScriptSpiderBallAttractionSurface.hpp index 1391d96e5..6dcbbe87c 100644 --- a/Runtime/World/CScriptSpiderBallAttractionSurface.hpp +++ b/Runtime/World/CScriptSpiderBallAttractionSurface.hpp @@ -16,7 +16,7 @@ public: void Accept(IVisitor& visitor); void Think(float dt, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor& actor, CStateManager& mgr); const zeus::CVector3f& GetScale() const { return xe8_scale; } }; diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index c20a0374d..34e3d42de 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -218,7 +218,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) if ((x12c_flags & ETriggerFlags::DetectCamera) != ETriggerFlags::None) { InhabitantAdded(*cam, mgr); - //SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::Activate); + SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::Activate); } } } @@ -226,12 +226,12 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) if (sendInside) { - //SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::Activate); + SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::Activate); } if (sendExited) { - //SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::Activate); + SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::Activate); if (x148_27_deactivateOnExited) { mgr.SendScriptMsg(GetUniqueId(), mgr.GetEditorIdForUniqueId(GetUniqueId()), @@ -242,7 +242,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) std::list& CScriptTrigger::GetInhabitants() { return xe8_inhabitants; } -rstl::optional_object CScriptTrigger::GetTouchBounds() const +std::experimental::optional CScriptTrigger::GetTouchBounds() const { if (x30_24_active) return {GetTriggerBoundsWR()}; @@ -319,7 +319,7 @@ void CScriptTrigger::Touch(CActor& act, CStateManager& mgr) } } - //SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None); + SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None); if (x148_26_deactivateOnEntered) { diff --git a/Runtime/World/CScriptTrigger.hpp b/Runtime/World/CScriptTrigger.hpp index 9bd0c57c2..a7af902bd 100644 --- a/Runtime/World/CScriptTrigger.hpp +++ b/Runtime/World/CScriptTrigger.hpp @@ -82,7 +82,7 @@ public: CObjectTracker* FindObject(TUniqueId); void UpdateInhabitants(float, CStateManager&); std::list& GetInhabitants(); - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor &, CStateManager &); const zeus::CAABox& GetTriggerBoundsOR() const { return x130_bounds; } zeus::CAABox GetTriggerBoundsWR() const; diff --git a/Runtime/World/CScriptVisorGoo.cpp b/Runtime/World/CScriptVisorGoo.cpp index 70713e1a0..7edc5d521 100644 --- a/Runtime/World/CScriptVisorGoo.cpp +++ b/Runtime/World/CScriptVisorGoo.cpp @@ -129,7 +129,7 @@ void CScriptVisorGoo::Render(const CStateManager& mgr) const // Empty } -rstl::optional_object CScriptVisorGoo::GetTouchBounds() const +std::experimental::optional CScriptVisorGoo::GetTouchBounds() const { return {}; } diff --git a/Runtime/World/CScriptVisorGoo.hpp b/Runtime/World/CScriptVisorGoo.hpp index 5476a829e..4111abf7f 100644 --- a/Runtime/World/CScriptVisorGoo.hpp +++ b/Runtime/World/CScriptVisorGoo.hpp @@ -29,7 +29,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; void Render(const CStateManager&) const; - rstl::optional_object GetTouchBounds() const; + std::experimental::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); }; diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index e47b98c5d..8aa87817b 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -741,4 +741,17 @@ void CWorld::AddGlobalSound(const CSfxHandle& hnd) return; xc8_globalSfxHandles.push_back(hnd); } + +bool CWorld::AreSkyNeedsMet() const +{ + if (!x70_26_skyboxActive) + return true; + if (xb4_skyboxOverride && xb4_skyboxOverride->IsLoaded(0)) + return true; + if (xa4_skyboxWorldLoaded && xa4_skyboxWorldLoaded->IsLoaded(0)) + return true; + if (x94_skyboxWorld && x94_skyboxWorld->IsLoaded(0)) + return true; + return false; +} } diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index 4cecd2df0..9d8bb7129 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -207,6 +207,7 @@ public: bool HasGlobalSound(u16 id) const; void AddGlobalSound(const CSfxHandle& hnd); EEnvFxType GetNeededEnvFx() const { return xc4_neededFx; } + bool AreSkyNeedsMet() const; }; struct CWorldLayers diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index f9a85449f..58c4e5470 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -639,7 +639,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int pr zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), extent, centroid); FourCC dclnType = g_ResFactory->GetResourceTypeById(dclnId); - rstl::optional_object> dclnToken; + std::experimental::optional> dclnToken; if (dclnType) { dclnToken.emplace(g_SimplePool->GetObj({SBIG('DCLN'), dclnId})); @@ -1000,7 +1000,7 @@ CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int prop if (animType != SBIG('ANCS')) return nullptr; - rstl::optional_object abdomenRes; + std::experimental::optional abdomenRes; if (flavor == CPatterned::EFlavorType::One) abdomenRes.emplace(CStaticRes(abdomen, scale)); diff --git a/Runtime/World/ScriptObjectSupport.hpp b/Runtime/World/ScriptObjectSupport.hpp index 3463cba86..b35611488 100644 --- a/Runtime/World/ScriptObjectSupport.hpp +++ b/Runtime/World/ScriptObjectSupport.hpp @@ -140,40 +140,40 @@ enum class EScriptObjectType enum class EScriptObjectState { - Any = -1, - Active, - Arrived, - Closed, - Entered, - Exited, - Inactive, - Inside, - MaxReached, - Open, - Zero, - Attack, - UNKS1, - Retreat, - Patrol, - Dead, - CameraPath, - CameraTarget, - UNKS2, - Play, - UNKS3, - DeathRattle, - UNKS4, - Damage, - InvulnDamage, - UNKS5, - Modify, - ScanStart, - ScanProcessing, - ScanDone, - UnFrozen, - Default, - ReflectedDamage, - InheritBounds + Any = -1, + Active = 0, + Arrived = 1, + Closed = 2, + Entered = 3, + Exited = 4, + Inactive = 5, + Inside = 6, + MaxReached = 7, + Open = 8, + Zero = 9, + Attack = 10, + UNKS1 = 11, + Retreat = 12, + Patrol = 13, + Dead = 14, + CameraPath = 15, + CameraTarget = 16, + UNKS2 = 17, + Play = 18, + UNKS3 = 19, + DeathRattle = 20, + UNKS4 = 21, + Damage = 22, + InvulnDamage = 23, + UNKS5 = 24, + Modify = 25, + ScanStart = 26, + ScanProcessing = 27, + ScanDone = 28, + UnFrozen = 29, + Default = 30, + ReflectedDamage = 31, + InheritBounds = 32 }; enum class EScriptObjectMessage diff --git a/Runtime/rstl.hpp b/Runtime/rstl.hpp index 959e76aa4..534285974 100644 --- a/Runtime/rstl.hpp +++ b/Runtime/rstl.hpp @@ -15,9 +15,6 @@ namespace rstl static logvisor::Module Log("rstl"); #endif -template -using optional_object = std::experimental::optional; - /** * @brief Base vector backed by statically-allocated array */ diff --git a/hecl b/hecl index 2461e787a..71e620386 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 2461e787a92af6400b15ef110dc837918c39b4ce +Subproject commit 71e620386d46b4208968e0bb61d9687775359880