From d9f58053561baa26d7a814605fd1e61417efe7c3 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 3 Feb 2017 15:32:15 -0800 Subject: [PATCH] Re-organize MP1 specific world objects --- Runtime/Character/CModelData.hpp | 2 + Runtime/Collision/CMaterialList.hpp | 6 +- Runtime/MP1/CMakeLists.txt | 11 ++- Runtime/MP1/World/CActorContraption.cpp | 15 ++++ Runtime/MP1/World/CActorContraption.hpp | 25 +++++++ Runtime/MP1/{ => World}/CBabygoth.cpp | 0 Runtime/MP1/{ => World}/CBabygoth.hpp | 0 Runtime/MP1/{ => World}/CBeetle.cpp | 0 Runtime/MP1/{ => World}/CBeetle.hpp | 0 Runtime/MP1/World/CMakeLists.txt | 10 +++ .../MP1/{ => World}/CMetroidPrimeRelay.cpp | 0 .../MP1/{ => World}/CMetroidPrimeRelay.hpp | 0 Runtime/MP1/{ => World}/CNewIntroBoss.cpp | 0 Runtime/MP1/{ => World}/CNewIntroBoss.hpp | 0 Runtime/MP1/{ => World}/CSpacePirate.cpp | 0 Runtime/MP1/{ => World}/CSpacePirate.hpp | 0 Runtime/MP1/{ => World}/CWarWasp.cpp | 0 Runtime/MP1/{ => World}/CWarWasp.hpp | 0 Runtime/MkCastTo.py | 2 +- Runtime/World/CActor.cpp | 19 ++++- Runtime/World/CActor.hpp | 4 ++ Runtime/World/CDamageVulnerability.hpp | 11 +++ Runtime/World/CScriptActor.cpp | 69 +++++++++++++++++-- Runtime/World/CScriptActor.hpp | 31 +++++++++ Runtime/World/ScriptLoader.cpp | 10 +-- 25 files changed, 193 insertions(+), 22 deletions(-) create mode 100644 Runtime/MP1/World/CActorContraption.cpp create mode 100644 Runtime/MP1/World/CActorContraption.hpp rename Runtime/MP1/{ => World}/CBabygoth.cpp (100%) rename Runtime/MP1/{ => World}/CBabygoth.hpp (100%) rename Runtime/MP1/{ => World}/CBeetle.cpp (100%) rename Runtime/MP1/{ => World}/CBeetle.hpp (100%) create mode 100644 Runtime/MP1/World/CMakeLists.txt rename Runtime/MP1/{ => World}/CMetroidPrimeRelay.cpp (100%) rename Runtime/MP1/{ => World}/CMetroidPrimeRelay.hpp (100%) rename Runtime/MP1/{ => World}/CNewIntroBoss.cpp (100%) rename Runtime/MP1/{ => World}/CNewIntroBoss.hpp (100%) rename Runtime/MP1/{ => World}/CSpacePirate.cpp (100%) rename Runtime/MP1/{ => World}/CSpacePirate.hpp (100%) rename Runtime/MP1/{ => World}/CWarWasp.cpp (100%) rename Runtime/MP1/{ => World}/CWarWasp.hpp (100%) diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index 510790af8..f866974a1 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -148,6 +148,8 @@ public: const zeus::CVector3f& GetScale() const { return x0_scale; } void SetScale(const zeus::CVector3f& scale) { x0_scale = scale; } + bool HasAnimData() const { return x10_animData != nullptr; } + bool HasNormalModel() const { return x1c_normalModel; } }; } diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index e6eeceee5..a56d93887 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -99,12 +99,12 @@ public: void Add(EMaterialTypes type) { - x0_list |= (1ull << u64(type)); + x0_list |= (1ull << u32(type)); } void Remove(EMaterialTypes type) { - x0_list &= ~(1ull << u64(type)); + x0_list &= ~(1ull << u32(type)); } void Remove(const CMaterialList& other) @@ -114,7 +114,7 @@ public: bool HasMaterial(EMaterialTypes type) const { - return (x0_list & (1ull << u64(type))) != 0; + return (x0_list & (1ull << u32(type))) != 0; } bool SharesMaterials(const CMaterialList& other) diff --git a/Runtime/MP1/CMakeLists.txt b/Runtime/MP1/CMakeLists.txt index cc0fd6aa2..925da93e9 100644 --- a/Runtime/MP1/CMakeLists.txt +++ b/Runtime/MP1/CMakeLists.txt @@ -1,4 +1,6 @@ include_directories(. ..) +add_subdirectory(World) + set(MP1_SOURCES CTweaks.hpp CTweaks.cpp CInGameTweakManager.hpp CInGameTweakManager.cpp @@ -10,18 +12,13 @@ set(MP1_SOURCES CFrontEndUI.hpp CFrontEndUI.cpp CPreFrontEnd.hpp CPreFrontEnd.cpp CSlideShow.hpp CSlideShow.cpp - CNewIntroBoss.hpp CNewIntroBoss.cpp - CBeetle.hpp CBeetle.cpp - CWarWasp.hpp CWarWasp.cpp - CSpacePirate.hpp CSpacePirate.cpp - CBabygoth.hpp CBabygoth.cpp - CMetroidPrimeRelay.hpp CMetroidPrimeRelay.cpp CSaveUI.hpp CSaveUI.cpp CMemoryCardDriver.hpp CMemoryCardDriver.cpp CQuitScreen.hpp CQuitScreen.cpp CCredits.hpp CCredits.cpp CStateSetterFlow.hpp CStateSetterFlow.cpp CAudioStateWin.hpp CAudioStateWin.cpp - MP1.hpp MP1.cpp) + MP1.hpp MP1.cpp + ${MP1_WORLD_SOURCES}) runtime_add_list(MP1 MP1_SOURCES) diff --git a/Runtime/MP1/World/CActorContraption.cpp b/Runtime/MP1/World/CActorContraption.cpp new file mode 100644 index 000000000..4dfbf0f2c --- /dev/null +++ b/Runtime/MP1/World/CActorContraption.cpp @@ -0,0 +1,15 @@ +#include "MP1/World/CActorContraption.hpp" + +namespace urde +{ + +MP1::CActorContraption::CActorContraption(TUniqueId uid, const std::string& name, const CEntityInfo& info, + const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& aabox, + const CMaterialList& matList, float f1, float f2, const CHealthInfo& hInfo, + const CDamageVulnerability& dVuln, const CActorParameters& aParams, + ResId part, const CDamageInfo& dInfo, bool active) +: CScriptActor(uid, name, info, xf, std::move(mData), aabox, f1, f2, matList, hInfo, dVuln, aParams, false, active, 0, + 0.f, false, false, false, false) +{ +} +} diff --git a/Runtime/MP1/World/CActorContraption.hpp b/Runtime/MP1/World/CActorContraption.hpp new file mode 100644 index 000000000..8d53f9b91 --- /dev/null +++ b/Runtime/MP1/World/CActorContraption.hpp @@ -0,0 +1,25 @@ +#ifndef __URDE_MP1_CACTORCONTRAPTION_HPP__ +#define __URDE_MP1_CACTORCONTRAPTION_HPP__ + +#include "World/CScriptActor.hpp" +#include "World/CDamageInfo.hpp" + +namespace urde +{ +namespace MP1 +{ +class CActorContraption : public CScriptActor +{ + /* AKA Why Zoid?!?!?!? */ + + TToken x300_; + CDamageInfo x30c_; +public: + CActorContraption(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, + const zeus::CAABox&, const CMaterialList&, float, float, const CHealthInfo&, + const CDamageVulnerability&, const CActorParameters&, ResId, const CDamageInfo&, bool); +}; +} +} + +#endif // __URDE_MP1_CACTORCONTRAPTION_HPP__ diff --git a/Runtime/MP1/CBabygoth.cpp b/Runtime/MP1/World/CBabygoth.cpp similarity index 100% rename from Runtime/MP1/CBabygoth.cpp rename to Runtime/MP1/World/CBabygoth.cpp diff --git a/Runtime/MP1/CBabygoth.hpp b/Runtime/MP1/World/CBabygoth.hpp similarity index 100% rename from Runtime/MP1/CBabygoth.hpp rename to Runtime/MP1/World/CBabygoth.hpp diff --git a/Runtime/MP1/CBeetle.cpp b/Runtime/MP1/World/CBeetle.cpp similarity index 100% rename from Runtime/MP1/CBeetle.cpp rename to Runtime/MP1/World/CBeetle.cpp diff --git a/Runtime/MP1/CBeetle.hpp b/Runtime/MP1/World/CBeetle.hpp similarity index 100% rename from Runtime/MP1/CBeetle.hpp rename to Runtime/MP1/World/CBeetle.hpp diff --git a/Runtime/MP1/World/CMakeLists.txt b/Runtime/MP1/World/CMakeLists.txt new file mode 100644 index 000000000..480430417 --- /dev/null +++ b/Runtime/MP1/World/CMakeLists.txt @@ -0,0 +1,10 @@ +set(MP1_WORLD_SOURCES + CNewIntroBoss.hpp CNewIntroBoss.cpp + CBeetle.hpp CBeetle.cpp + CWarWasp.hpp CWarWasp.cpp + CSpacePirate.hpp CSpacePirate.cpp + CBabygoth.hpp CBabygoth.cpp + CMetroidPrimeRelay.hpp CMetroidPrimeRelay.cpp + CActorContraption.hpp CActorContraption.cpp) + +runtime_add_list(World MP1_WORLD_SOURCES) diff --git a/Runtime/MP1/CMetroidPrimeRelay.cpp b/Runtime/MP1/World/CMetroidPrimeRelay.cpp similarity index 100% rename from Runtime/MP1/CMetroidPrimeRelay.cpp rename to Runtime/MP1/World/CMetroidPrimeRelay.cpp diff --git a/Runtime/MP1/CMetroidPrimeRelay.hpp b/Runtime/MP1/World/CMetroidPrimeRelay.hpp similarity index 100% rename from Runtime/MP1/CMetroidPrimeRelay.hpp rename to Runtime/MP1/World/CMetroidPrimeRelay.hpp diff --git a/Runtime/MP1/CNewIntroBoss.cpp b/Runtime/MP1/World/CNewIntroBoss.cpp similarity index 100% rename from Runtime/MP1/CNewIntroBoss.cpp rename to Runtime/MP1/World/CNewIntroBoss.cpp diff --git a/Runtime/MP1/CNewIntroBoss.hpp b/Runtime/MP1/World/CNewIntroBoss.hpp similarity index 100% rename from Runtime/MP1/CNewIntroBoss.hpp rename to Runtime/MP1/World/CNewIntroBoss.hpp diff --git a/Runtime/MP1/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp similarity index 100% rename from Runtime/MP1/CSpacePirate.cpp rename to Runtime/MP1/World/CSpacePirate.cpp diff --git a/Runtime/MP1/CSpacePirate.hpp b/Runtime/MP1/World/CSpacePirate.hpp similarity index 100% rename from Runtime/MP1/CSpacePirate.hpp rename to Runtime/MP1/World/CSpacePirate.hpp diff --git a/Runtime/MP1/CWarWasp.cpp b/Runtime/MP1/World/CWarWasp.cpp similarity index 100% rename from Runtime/MP1/CWarWasp.cpp rename to Runtime/MP1/World/CWarWasp.cpp diff --git a/Runtime/MP1/CWarWasp.hpp b/Runtime/MP1/World/CWarWasp.hpp similarity index 100% rename from Runtime/MP1/CWarWasp.hpp rename to Runtime/MP1/World/CWarWasp.hpp diff --git a/Runtime/MkCastTo.py b/Runtime/MkCastTo.py index 07475944d..2787930e6 100644 --- a/Runtime/MkCastTo.py +++ b/Runtime/MkCastTo.py @@ -25,7 +25,7 @@ CENTITY_TYPES = ( ('CGameProjectile', 'Weapon/CGameProjectile.hpp'), ('CHUDBillboardEffect', 'World/CHUDBillboardEffect.hpp'), Namespace('MP1'), - ('CMetroidPrimeRelay', 'MP1/CMetroidPrimeRelay.hpp', 'MP1'), + ('CMetroidPrimeRelay', 'MP1/World/CMetroidPrimeRelay.hpp', 'MP1'), EndNamespace(), ('CPathCamera', 'Camera/CPathCamera.hpp'), ('CAi', 'World/CAi.hpp'), diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 955c78b4f..06e467219 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -140,7 +140,7 @@ const zeus::CTransform CActor::GetLocatorTransform(const std::string& segName) c } EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, - CWeaponMode&, int) + CWeaponMode&, s32) { return EWeaponCollisionResponseTypes::Unknown13; } @@ -213,6 +213,23 @@ void CActor::AddMaterial(EMaterialTypes type, CStateManager& mgr) mgr.UpdateObjectInLists(*this); } +void CActor::CreateShadow(bool b) +{ + if (b) + { + _CreateShadow(); + if (!xe5_24_ && x94_simpleShadow) + xe5_25_ = true; + } + xe5_24_ = b; +} + +void CActor::_CreateShadow() +{ + if (!x94_simpleShadow && x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel())) + x94_simpleShadow.reset(new CSimpleShadow(1.f, 1.f, 20.f, 0.05f)); +} + void CActor::SetCallTouch(bool callTouch) { xe5_28_callTouch = callTouch; } bool CActor::GetCallTouch() const { return xe5_28_callTouch; } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index f598da642..5c844ce79 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -58,6 +58,8 @@ protected: bool xe4_28_ : 1; bool xe4_29_ : 1; bool xe4_30_ : 1; + bool xe5_24_ : 1; + bool xe5_25_ : 1; bool xe5_26_muted : 1; bool xe5_27_useInSortedLists : 1; bool xe5_28_callTouch : 1; @@ -69,6 +71,7 @@ protected: }; u32 dummy = 0; }; + void _CreateShadow(); public: enum class EFluidState @@ -131,6 +134,7 @@ public: void AddMaterial(EMaterialTypes, EMaterialTypes, CStateManager&); void AddMaterial(EMaterialTypes, CStateManager&); + void CreateShadow(bool); void SetCallTouch(bool callTouch); bool GetCallTouch() const; void SetUseInSortedList(bool use); diff --git a/Runtime/World/CDamageVulnerability.hpp b/Runtime/World/CDamageVulnerability.hpp index ac4efd9c1..8fc495155 100644 --- a/Runtime/World/CDamageVulnerability.hpp +++ b/Runtime/World/CDamageVulnerability.hpp @@ -109,6 +109,17 @@ public: } bool WeaponHurts(const CWeaponMode&, u32) const { return false; } + + EVulnerability GetVulnerability(const CWeaponMode& mode, u32 w) const + { + if (int(mode.GetType()) < int(EWeaponType::None) || int(mode.GetType()) > int(EWeaponType::Unused2)) + return EVulnerability::Reflect; + + if (!mode.IsInstantKill()) + return EVulnerability::Normal; + // TODO: Finish + return EVulnerability::Normal; + } }; } diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index 00603a6a2..580cf43df 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -1,20 +1,77 @@ #include "CScriptActor.hpp" +#include "CStateManager.hpp" +#include "CScriptTrigger.hpp" +#include "CDamageVulnerability.hpp" #include "TCastTo.hpp" namespace urde { CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, - CModelData&& mData, const zeus::CAABox& aabb, float a, float, const CMaterialList& matList, - const CHealthInfo&, const CDamageVulnerability&, const CActorParameters& actParms, bool, - bool active, u32, float, bool, bool, bool, bool) -: CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(a), actParms, 0.3f, 0.1f) + CModelData&& mData, const zeus::CAABox& aabb, float f1, float zMomentum, + const CMaterialList& matList, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, + const CActorParameters& actParms, bool looping, bool active, u32 w1, float f3, bool b2, + bool castsShadow, bool b4, bool b5) +: CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(f1), actParms, 0.3f, 0.1f) +, x258_initialHealth(hInfo) +, x260_currentHealth(hInfo) +, x268_damageVulnerability(dVuln) +, x2d8_(w1) +, x2dc_(f3) +, x2e2_24_(b2) +, x2e2_25_(false) +, x2e2_26_(true) +, x2e2_27_(std::fabs(f3 - 1.f) > 0.00001) +, x2e2_28_(false) +, x2e2_29_((x2e2_24_ && x2e2_25_ && x2d8_ != 0)) +, x2e2_30_(b4) +, x2e2_31_(b5) { + if (x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel()) && castsShadow) + CreateShadow(true); + + if (x64_modelData && x64_modelData->HasAnimData()) + x64_modelData->EnableLooping(looping); + + x150_momentum = zeus::CVector3f(0.f, 0.f, zMomentum); } -void CScriptActor::Accept(IVisitor& visitor) +void CScriptActor::Accept(IVisitor& visitor) { visitor.Visit(this); } + +void CScriptActor::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {} + +void CScriptActor::Think(float, CStateManager&) {} + +void CScriptActor::PreRender(const zeus::CFrustum&, const CStateManager&) {} + +zeus::CAABox CScriptActor::GetSortingBounds(const CStateManager& mgr) const { - visitor.Visit(this); + if (x2e0_ != kInvalidUniqueId) + { + TCastToConstPtr trigger(mgr.GetObjectById(x2e0_)); + if (trigger) + return trigger->GetTriggerBoundsWR(); + } + + return CActor::GetSortingBounds(mgr); } +EWeaponCollisionResponseTypes +CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, CWeaponMode& wMode, s32 w) +{ + const CDamageVulnerability* dVuln = GetDamageVulnerability(); + EVulnerability vuln = dVuln->GetVulnerability(wMode, 0); + return CActor::GetCollisionResponseType(v1, v2, wMode, w); +} + +rstl::optional_object CScriptActor::GetTouchBounds() const +{ + if (GetActive() && x68_material.HasMaterial(EMaterialTypes::Solid)) + return {CPhysicsActor::GetBoundingBox()}; + return {}; +} + +void CScriptActor::Touch(CActor&, CStateManager&) +{ +} } diff --git a/Runtime/World/CScriptActor.hpp b/Runtime/World/CScriptActor.hpp index df8cc421b..8aa7125bf 100644 --- a/Runtime/World/CScriptActor.hpp +++ b/Runtime/World/CScriptActor.hpp @@ -2,17 +2,48 @@ #define __URDE_CSCRIPTACTOR_HPP__ #include "CPhysicsActor.hpp" +#include "CHealthInfo.hpp" +#include "CDamageVulnerability.hpp" namespace urde { class CScriptActor : public CPhysicsActor { +protected: + CHealthInfo x258_initialHealth; + CHealthInfo x260_currentHealth; + CDamageVulnerability x268_damageVulnerability; + float x2d0_; + float x2d4_; + s32 x2d8_; + float x2dc_; + TUniqueId x2e0_ = kInvalidUniqueId; + bool x2e2_24_ : 1; + bool x2e2_25_ : 1; + bool x2e2_26_ : 1; + bool x2e2_27_ : 1; + bool x2e2_28_ : 1; + bool x2e2_29_ : 1; + bool x2e2_30_ : 1; + bool x2e2_31_ : 1; + bool x2e3_24_ : 1; + public: CScriptActor(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const zeus::CAABox& aabb, float, float, const CMaterialList& matList, const CHealthInfo&, const CDamageVulnerability&, const CActorParameters&, bool, bool, u32, float, bool, bool, bool, bool); void Accept(IVisitor& visitor); + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); + void Think(float, CStateManager&); + void PreRender(const zeus::CFrustum&, const CStateManager&); + zeus::CAABox GetSortingBounds(const CStateManager&) const; + EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, + CWeaponMode&, int); + rstl::optional_object GetTouchBounds() const; + void Touch(CActor&, CStateManager&); + const CDamageVulnerability* GetDamageVulnerability() { return &x268_damageVulnerability; } + CHealthInfo* HealthInfo() { return &x260_currentHealth; } }; } diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 7352a6676..7ebf85009 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -56,10 +56,11 @@ #include "CScriptCameraHintTrigger.hpp" #include "CScriptBeam.hpp" #include "Camera/CCinematicCamera.hpp" -#include "MP1/CNewIntroBoss.hpp" -#include "MP1/CBeetle.hpp" -#include "MP1/CWarWasp.hpp" -#include "MP1/CSpacePirate.hpp" +#include "MP1/World/CNewIntroBoss.hpp" +#include "MP1/World/CBeetle.hpp" +#include "MP1/World/CWarWasp.hpp" +#include "MP1/World/CSpacePirate.hpp" +#include "MP1/World/CActorContraption.hpp" #include "CScriptShadowProjector.hpp" #include "CScriptStreamedMusic.hpp" #include "CScriptRoomAcoustics.hpp" @@ -1996,6 +1997,7 @@ CEntity* ScriptLoader::Load(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadActorContraption(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + return nullptr; }