diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 47af41201..fe53c0876 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -172,7 +172,7 @@ CStateManager::CStateManager(const std::weak_ptr& relayTracker, x90c_loaderFuncs[int(EScriptObjectType::Seedling)] = ScriptLoader::LoadSeedling; x90c_loaderFuncs[int(EScriptObjectType::ThermalHeatFader)] = ScriptLoader::LoadThermalHeatFader; x90c_loaderFuncs[int(EScriptObjectType::Burrower)] = ScriptLoader::LoadBurrower; - x90c_loaderFuncs[int(EScriptObjectType::ScriptBeam)] = ScriptLoader::LoadScriptBeam; + x90c_loaderFuncs[int(EScriptObjectType::ScriptBeam)] = ScriptLoader::LoadBeam; x90c_loaderFuncs[int(EScriptObjectType::WorldLightFader)] = ScriptLoader::LoadWorldLightFader; x90c_loaderFuncs[int(EScriptObjectType::MetroidPrimeStage2)] = ScriptLoader::LoadMetroidPrimeStage2; x90c_loaderFuncs[int(EScriptObjectType::MetroidPrimeStage1)] = ScriptLoader::LoadMetroidPrimeStage1; diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index 478e403ec..011a998c6 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -23,11 +23,13 @@ enum class EMaterialTypes Thirten = 13, Fourteen = 14, Fifteen = 15, + Eighteen = 18, Nineteen = 19, TwentyOne = 21, ThirtyTwo = 32, ThirtyThree = 33, ThirtyFour = 34, + ThirtyFive = 35, ThirtySeven = 37, ThirtyEight = 38, ThirtyNine = 39, diff --git a/Runtime/Weapon/CBeamInfo.cpp b/Runtime/Weapon/CBeamInfo.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/Weapon/CBeamInfo.hpp b/Runtime/Weapon/CBeamInfo.hpp new file mode 100644 index 000000000..5c21d2f5c --- /dev/null +++ b/Runtime/Weapon/CBeamInfo.hpp @@ -0,0 +1,53 @@ +#ifndef __URDE_CBEAMINFO_HPP__ +#define __URDE_CBEAMINFO_HPP__ + +#include "RetroTypes.hpp" +#include "IOStreams.hpp" +#include "zeus/CColor.hpp" + +namespace urde +{ +struct CBeamInfo +{ + u32 x0_; + u32 x4_; + ResId x8_; + ResId xc_; + ResId x10_; + ResId x14_; + u32 x18_; + float x1c_; + float x20_; + float x24_; + float x28_; + float x2c_; + float x30_; + float x34_; + float x38_; + zeus::CColor x3c_; + zeus::CColor x40_; + + CBeamInfo(CInputStream& in) + : x0_(in.readUint32Big()) + , x4_(in.readUint32Big()) + , x8_(in.readUint32Big()) + , xc_(in.readUint32Big()) + , x10_(in.readUint32Big()) + , x14_(in.readUint32Big()) + , x18_(in.readFloatBig()) + , x1c_(in.readFloatBig()) + , x20_(in.readFloatBig()) + , x24_(in.readFloatBig()) + , x28_(in.readFloatBig()) + , x2c_(in.readFloatBig()) + , x30_(in.readFloatBig()) + , x34_(in.readFloatBig()) + , x38_(in.readFloatBig()) + , x3c_(zeus::CColor::ReadRGBABig(in)) + , x40_(zeus::CColor::ReadRGBABig(in)) + { + } +}; + +} +#endif // __URDE_CBEAMINFO_HPP__ diff --git a/Runtime/Weapon/CBeamProjectile.cpp b/Runtime/Weapon/CBeamProjectile.cpp new file mode 100644 index 000000000..1655038a7 --- /dev/null +++ b/Runtime/Weapon/CBeamProjectile.cpp @@ -0,0 +1,38 @@ +#include "Weapon/CBeamProjectile.hpp" + +namespace urde +{ + +CBeamProjectile::CBeamProjectile(const TToken& wDesc, const std::string& name, EWeaponType wType, + const zeus::CTransform& xf, int attribs, float f1, float f2, EMaterialTypes matType, + const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, TUniqueId uid, u32 w1, bool b1) +: CGameProjectile(false, wDesc, name, wType, xf, matType, dInfo, owner, aid, uid, kInvalidUniqueId, w1, false, + zeus::CVector3f::skOne, {}, -1, false) +{ +} + +void CBeamProjectile::Think(float, CStateManager &) +{ + +} + +rstl::optional_object CBeamProjectile::GetTouchBounds() const +{ + return {}; +} + +void CBeamProjectile::Touch(CActor &, CStateManager &) +{ + +} + +void CBeamProjectile::ResetBeam(CStateManager &, bool) +{ + +} + +void CBeamProjectile::UpdateFX(const zeus::CTransform &, float, CStateManager &) +{ + +} +} diff --git a/Runtime/Weapon/CBeamProjectile.hpp b/Runtime/Weapon/CBeamProjectile.hpp new file mode 100644 index 000000000..f1b705d41 --- /dev/null +++ b/Runtime/Weapon/CBeamProjectile.hpp @@ -0,0 +1,33 @@ +#ifndef __URDE_CBEAMPROJECTILE_HPP__ +#define __URDE_CBEAMPROJECTILE_HPP__ + +#include "Weapon/CGameProjectile.hpp" +namespace urde +{ +class CBeamProjectile : public CGameProjectile +{ +public: + CBeamProjectile(const TToken&, const std::string&, EWeaponType, const zeus::CTransform&, int, + float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool); + + float GetMaxRadius() const; + zeus::CVector3f GetSurfaceNormal() const; + void GetDamageType() const; + void GetCurrentPos() const; + void PointCache(); + void GetPointCache() const; + void CauseDamage(bool); + zeus::CVector3f GetBeamOrigin() const; + void GetInvMaxLength() const; + void GetCurrentLength(); + void GetMaxLength(); + s32 GetIntMaxLength(); + + void Think(float, CStateManager&); + rstl::optional_object GetTouchBounds() const; + void Touch(CActor&, CStateManager&); + virtual void ResetBeam(CStateManager&, bool); + virtual void UpdateFX(const zeus::CTransform&, float, CStateManager&); +}; +} +#endif // __URDE_CBEAMPROJECTILE_HPP__ diff --git a/Runtime/Weapon/CGameProjectile.cpp b/Runtime/Weapon/CGameProjectile.cpp new file mode 100644 index 000000000..d82338937 --- /dev/null +++ b/Runtime/Weapon/CGameProjectile.cpp @@ -0,0 +1,32 @@ +#include "Weapon/CGameProjectile.hpp" + +namespace urde +{ +CGameProjectile::CGameProjectile(bool active, const TToken&, const std::string& name, + EWeaponType wType, const zeus::CTransform& xf, EMaterialTypes matType, + const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, TUniqueId uid, TUniqueId, + u32 w1, bool b2, const zeus::CVector3f&, + const rstl::optional_object>&, s16, bool b3) +: CWeapon(owner, aid, uid, active, wType, name, xf, + CMaterialFilter( + CMaterialList(EMaterialTypes::Fifty, matType), + CMaterialList(EMaterialTypes::ThirtyFive, EMaterialTypes::Eighteen, matType, EMaterialTypes::Nineteen), + CMaterialFilter::EFilterType::Three), + CMaterialList(), dInfo, EProjectileAttrib(w1) | GetBeamAttribType(wType), CModelData::CModelDataNull()) +{ +} + +CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType) +{ + if (wType == EWeaponType::Ice) + return EProjectileAttrib::Ice; + else if (wType == EWeaponType::Wave) + return EProjectileAttrib::Wave; + else if (wType == EWeaponType::Plasma) + return EProjectileAttrib::Plasma; + else if (wType == EWeaponType::Phazon) + return EProjectileAttrib::Phazon; + + return EProjectileAttrib::None; +} +} diff --git a/Runtime/Weapon/CGameProjectile.hpp b/Runtime/Weapon/CGameProjectile.hpp new file mode 100644 index 000000000..6060fef76 --- /dev/null +++ b/Runtime/Weapon/CGameProjectile.hpp @@ -0,0 +1,26 @@ +#ifndef __URDE_CGAMEPROJECTILE_HPP__ +#define __URDE_CGAMEPROJECTILE_HPP__ + +#include "Collision/CMaterialList.hpp" +#include "Weapon/CWeaponMode.hpp" +#include "Weapon/CWeapon.hpp" +#include "World/CDamageInfo.hpp" +#include "RetroTypes.hpp" +#include "CToken.hpp" + +namespace urde +{ +class CGenDescription; +class CWeaponDescription; +class CGameProjectile : public CWeapon +{ +public: + CGameProjectile(bool, const TToken&, const std::string&, EWeaponType, const zeus::CTransform&, + EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool, + const zeus::CVector3f&, const rstl::optional_object>&, s16, bool); + + static EProjectileAttrib GetBeamAttribType(EWeaponType wType); +}; +} + +#endif // __URDE_CGAMEPROJECTILE_HPP__ diff --git a/Runtime/Weapon/CMakeLists.txt b/Runtime/Weapon/CMakeLists.txt index cf2412e5d..df6a4eb0c 100644 --- a/Runtime/Weapon/CMakeLists.txt +++ b/Runtime/Weapon/CMakeLists.txt @@ -1,4 +1,5 @@ set(WEAPON_SOURCES + WeaponCommon.hpp CWeaponMgr.hpp CWeaponMgr.cpp CGunController.hpp CGunController.cpp CGunMotion.hpp CGunMotion.cpp @@ -15,6 +16,11 @@ set(WEAPON_SOURCES CGSFreeLook.hpp CGSFreeLook.cpp CGSComboFire.hpp CGSComboFire.cpp CGSFidget.hpp CGSFidget.cpp - CFidget.hpp CFidget.cpp) + CFidget.hpp CFidget.cpp + CWeapon.hpp CWeapon.cpp + CGameProjectile.hpp CGameProjectile.cpp + CBeamProjectile.hpp CBeamProjectile.cpp + CBeamInfo.hpp CBeamInfo.cpp + CPlasmaProjectile.hpp CPlasmaProjectile.cpp) runtime_add_list(Weapon WEAPON_SOURCES) diff --git a/Runtime/Weapon/CPlasmaProjectile.cpp b/Runtime/Weapon/CPlasmaProjectile.cpp new file mode 100644 index 000000000..f42daad93 --- /dev/null +++ b/Runtime/Weapon/CPlasmaProjectile.cpp @@ -0,0 +1,13 @@ +#include "CPlasmaProjectile.hpp" + +namespace urde +{ + +CPlasmaProjectile::CPlasmaProjectile(const TToken& wDesc, const std::string& name, + EWeaponType wType, const CBeamInfo& bInfo, const zeus::CTransform& xf, + EMaterialTypes matType, const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, + TUniqueId uid, u32 w1, bool b1, u32 w2) +: CBeamProjectile(wDesc, name, wType, xf, bInfo.x18_, bInfo.x1c_, bInfo.x38_, matType, dInfo, owner, aid, uid, w2, b1) +{ +} +} diff --git a/Runtime/Weapon/CPlasmaProjectile.hpp b/Runtime/Weapon/CPlasmaProjectile.hpp new file mode 100644 index 000000000..d32680636 --- /dev/null +++ b/Runtime/Weapon/CPlasmaProjectile.hpp @@ -0,0 +1,19 @@ +#ifndef __URDE_CPLASMAPROJECTILE_HPP__ +#define __URDE_CPLASMAPROJECTILE_HPP__ + +#include "Weapon/CBeamProjectile.hpp" +#include "Weapon/CBeamInfo.hpp" +#include "World/CDamageInfo.hpp" + +namespace urde +{ +class CPlasmaProjectile : public CBeamProjectile +{ +public: + CPlasmaProjectile(const TToken&, const std::string&, EWeaponType, const CBeamInfo&, + const zeus::CTransform&, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, + bool, u32); +}; +} + +#endif // __URDE_CPLASMAPROJECTILE_HPP__ diff --git a/Runtime/Weapon/CWeapon.cpp b/Runtime/Weapon/CWeapon.cpp new file mode 100644 index 000000000..e29add246 --- /dev/null +++ b/Runtime/Weapon/CWeapon.cpp @@ -0,0 +1,14 @@ +#include "CWeapon.hpp" +#include "World/CActorParameters.hpp" + +namespace urde +{ + +CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId, EWeaponType, const std::string& name, + const zeus::CTransform& xf, const CMaterialFilter&, const CMaterialList& mList, const CDamageInfo&, + EProjectileAttrib, CModelData&& mData) +: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList, + CActorParameters::None(), kInvalidUniqueId) +{ +} +} diff --git a/Runtime/Weapon/CWeapon.hpp b/Runtime/Weapon/CWeapon.hpp new file mode 100644 index 000000000..3a21b0ec0 --- /dev/null +++ b/Runtime/Weapon/CWeapon.hpp @@ -0,0 +1,49 @@ +#ifndef __URDE_CWEAPON_HPP__ +#define __URDE_CWEAPON_HPP__ + +#include "World/CActor.hpp" +#include "Weapon/WeaponCommon.hpp" +#include "Collision/CMaterialFilter.hpp" + +namespace urde +{ +class CWeapon : public CActor +{ +public: + enum class EProjectileAttrib + { + None = 0, + Ice = (1 << 3), + Wave = (1 << 4), + Plasma = (1 << 5), + Phazon = (1 << 6) + }; + +private: +public: + CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&, + const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&); + + bool HasAttrib(EProjectileAttrib) const; + EProjectileAttrib GetAttribField() const; + const CMaterialFilter& GetFilter() const; + void SetFilter(const CMaterialFilter&); + TUniqueId GetOwnerId() const; + void SetOwnerId(TUniqueId); + EWeaponType GetType() const; + const CDamageInfo& GetDamageInfo() const; + CDamageInfo& DamageInfo(); + void SetDamageInfo(const CDamageInfo&); + + void Think(float, CStateManager &) {} + void Render(const CStateManager&) const {} + EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, + int) + { + return EWeaponCollisionResponseTypes::Default; + } + void FluidFXThink(EFluidState, CScriptWater&, CStateManager&) {} +}; +ENABLE_BITWISE_ENUM(CWeapon::EProjectileAttrib) +} +#endif // __URDE_CWEAPON_HPP__ diff --git a/Runtime/Weapon/CWeaponMgr.hpp b/Runtime/Weapon/CWeaponMgr.hpp index c9adedb37..a6aee0aeb 100644 --- a/Runtime/Weapon/CWeaponMgr.hpp +++ b/Runtime/Weapon/CWeaponMgr.hpp @@ -2,30 +2,11 @@ #define __URDE_CWEAPONMGR_HPP__ #include "RetroTypes.hpp" +#include "WeaponCommon.hpp" namespace urde { -enum class EWeaponType -{ - None = -1, - Power = 0, - Ice, - Wave, - Plasma, - Bomb, - PowerBomb, - Missile, - BoostBall, - Phazon, - AI, - PoisonWater, - Lava, - Hot, - Unused1, - Unused2 -}; - class CWeaponMgr { std::map> x0_weapons; diff --git a/Runtime/Weapon/CWeaponMode.cpp b/Runtime/Weapon/CWeaponMode.cpp index cccddb47a..c114fe708 100644 --- a/Runtime/Weapon/CWeaponMode.cpp +++ b/Runtime/Weapon/CWeaponMode.cpp @@ -7,6 +7,11 @@ CWeaponMode::CWeaponMode(EWeaponType type, bool, bool) { } +EWeaponType CWeaponMode::GetType() const +{ + return x0_weaponType; +} + CWeaponMode CWeaponMode::Invalid() { return CWeaponMode(EWeaponType::None, false, false); diff --git a/Runtime/Weapon/CWeaponMode.hpp b/Runtime/Weapon/CWeaponMode.hpp index b5882a6d1..c02795f5d 100644 --- a/Runtime/Weapon/CWeaponMode.hpp +++ b/Runtime/Weapon/CWeaponMode.hpp @@ -1,13 +1,13 @@ #ifndef __URDE_CWEAPONMODE_HPP__ #define __URDE_CWEAPONMODE_HPP__ -#include "CWeaponMgr.hpp" +#include "WeaponCommon.hpp" namespace urde { class CWeaponMode { - EWeaponType x0_weaponType; + EWeaponType x0_weaponType = EWeaponType::None; union { struct @@ -19,7 +19,8 @@ class CWeaponMode u8 dummy = 0; }; public: - CWeaponMode(EWeaponType, bool, bool); + CWeaponMode() = default; + CWeaponMode(EWeaponType, bool = false, bool = false); EWeaponType GetType() const; diff --git a/Runtime/Weapon/WeaponCommon.hpp b/Runtime/Weapon/WeaponCommon.hpp new file mode 100644 index 000000000..383912500 --- /dev/null +++ b/Runtime/Weapon/WeaponCommon.hpp @@ -0,0 +1,29 @@ +#ifndef __URDE_WEAPONCOMMON_HPP__ +#define __URDE_WEAPONCOMMON_HPP__ + +#include "RetroTypes.hpp" + +namespace urde +{ + +enum class EWeaponType +{ + None = -1, + Power = 0, + Ice, + Wave, + Plasma, + Bomb, + PowerBomb, + Missile, + BoostBall, + Phazon, + AI, + PoisonWater, + Lava, + Hot, + Unused1, + Unused2 +}; +} +#endif // __URDE_WEAPONCOMMON_HPP__ diff --git a/Runtime/World/CDamageInfo.hpp b/Runtime/World/CDamageInfo.hpp index 491f0b503..3731eb1cc 100644 --- a/Runtime/World/CDamageInfo.hpp +++ b/Runtime/World/CDamageInfo.hpp @@ -3,6 +3,7 @@ #include "RetroTypes.hpp" #include "Weapon/CWeaponMgr.hpp" +#include "Weapon/CWeaponMode.hpp" namespace urde { @@ -10,17 +11,7 @@ namespace urde class CDamageVulnerability; class CDamageInfo { - EWeaponType x0_type = EWeaponType::None; - union - { - struct - { - bool x4_24_ : 1; - bool x4_25_ : 1; - bool x4_26_ : 1; - }; - u8 _dummy = 0; - }; + CWeaponMode x0_weaponMode; float x8_damage; float xc_radiusDamage; float x10_radius; @@ -31,13 +22,21 @@ public: CDamageInfo(CInputStream& in) { in.readUint32Big(); - x0_type = EWeaponType(in.readUint32Big()); + x0_weaponMode = CWeaponMode(EWeaponType(in.readUint32Big())); x8_damage = in.readFloatBig(); xc_radiusDamage = x8_damage; x10_radius = in.readFloatBig(); x14_knockback = in.readFloatBig(); } + CDamageInfo(const CWeaponMode&, float damage, float radius, float knockback); + CDamageInfo(const CDamageInfo& other) = default; + const CWeaponMode& GetWeaponMode() const { return x0_weaponMode; } + float GetRadius() const { return x10_radius; } + void SetRadius(float r) { x10_radius = r; } + float GetKnockBackPower() const { return x14_knockback; } + float GetDamage() const { return x8_damage; } + void GetDamage(const CDamageVulnerability& dVuln); float GetRadiusDamage() const { return xc_radiusDamage; } float GetRadiusDamage(const CDamageVulnerability& dVuln); }; diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index 1b5d7444b..755cba432 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -69,6 +69,7 @@ set(WORLD_SOURCES CRepulsor.hpp CRepulsor.cpp CScriptCameraPitchVolume.hpp CScriptCameraPitchVolume.cpp CScriptCameraHintTrigger.hpp CScriptCameraHintTrigger.cpp + CScriptBeam.hpp CScriptBeam.cpp CGrappleParameters.hpp CActorParameters.hpp CLightParameters.hpp diff --git a/Runtime/World/CScriptBeam.cpp b/Runtime/World/CScriptBeam.cpp new file mode 100644 index 000000000..40c1fae10 --- /dev/null +++ b/Runtime/World/CScriptBeam.cpp @@ -0,0 +1,57 @@ +#include "CScriptBeam.hpp" +#include "CActorParameters.hpp" +#include "Particle/CWeaponDescription.hpp" +#include "Weapon/CPlasmaProjectile.hpp" +#include "CStateManager.hpp" + +namespace urde +{ + +CScriptBeam::CScriptBeam(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, + bool active, const TToken& weaponDesc, const CBeamInfo& bInfo, + const CDamageInfo& dInfo) +: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), + kInvalidUniqueId) +, xe8_weaponDescription(weaponDesc) +, xf4_beamInfo(bInfo) +, x138_damageInfo(dInfo) +{ +} + +void CScriptBeam::Think(float dt, CStateManager& mgr) +{ +#if 0 + CPlasmaProjectile* proj = static_cast(mgr.GetObjectById(x154_projectileId)); + if (proj) + { + if (proj->GetActive()) + proj->UpdateFx(x34_transform, dt, mgr); + } + else + x154_projectileId = kInvalidUniqueId; +#endif +} + +void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) +{ + if (msg == EScriptObjectMessage::Increment) + { + } + else if (msg == EScriptObjectMessage::Decrement) + { + } + else if (msg == EScriptObjectMessage::InternalMessage11) + { + x154_projectileId = mgr.AllocateUniqueId(); + mgr.AddObject(new CPlasmaProjectile(xe8_weaponDescription, x10_name + "-Projectile", + x138_damageInfo.GetWeaponMode().GetType(), xf4_beamInfo, x34_transform, + EMaterialTypes::ThirtyFive, x138_damageInfo, x8_uid, x4_areaId, + x154_projectileId, 8, false, 2)); + } + else if (msg == EScriptObjectMessage::InternalMessage12) + { + } + + CActor::AcceptScriptMsg(msg, objId, mgr); +} +} diff --git a/Runtime/World/CScriptBeam.hpp b/Runtime/World/CScriptBeam.hpp new file mode 100644 index 000000000..7a3e05e66 --- /dev/null +++ b/Runtime/World/CScriptBeam.hpp @@ -0,0 +1,25 @@ +#ifndef __URDE_CSCRIPTBEAM_HPP__ +#define __URDE_CSCRIPTBEAM_HPP__ + +#include "CActor.hpp" +#include "Weapon/CBeamInfo.hpp" +#include "CDamageInfo.hpp" + +namespace urde +{ +class CWeaponDescription; +class CScriptBeam : public CActor +{ + TCachedToken xe8_weaponDescription; + CBeamInfo xf4_beamInfo; + CDamageInfo x138_damageInfo; + TUniqueId x154_projectileId; +public: + CScriptBeam(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, bool, + const TToken&, const CBeamInfo&, const CDamageInfo&); + + void Think(float, CStateManager &); + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); +}; +} +#endif // __URDE_CSCRIPTBEAM_HPP__ diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index f433c6c99..6479a1c9d 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -17,7 +17,7 @@ public: }; private: - //TReservedAverage x2e0_; + TReservedAverage x2e0_; public: CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&, diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 1ca0fafa3..e4d5c7153 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -11,6 +11,7 @@ #include "CWorld.hpp" #include "Character/CModelData.hpp" #include "Collision/CMaterialList.hpp" +#include "Particle/CWeaponDescription.hpp" #include "CDamageInfo.hpp" #include "CScriptActor.hpp" #include "CScriptWaypoint.hpp" @@ -52,6 +53,7 @@ #include "CRepulsor.hpp" #include "CScriptCameraPitchVolume.hpp" #include "CScriptCameraHintTrigger.hpp" +#include "CScriptBeam.hpp" #include "Camera/CCinematicCamera.hpp" #include "MP1/CNewIntroBoss.hpp" #include "MP1/CBeetle.hpp" @@ -748,8 +750,8 @@ CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in, int prop if (propCount > 14) b10 = in.readBool(); - u32 flags = u32(b2) | u32(b3) << 1 | u32(b4) << 2 | u32(b5) << 3 | u32(b6) << 4 | - u32(b7) << 5 | u32(b8) << 6 | u32(b9) << 8; + u32 flags = u32(b2) | u32(b3) << 1 | u32(b4) << 2 | u32(b5) << 3 | u32(b6) << 4 | u32(b7) << 5 | u32(b8) << 6 | + u32(b9) << 8; return new CCinematicCamera(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, b1, f1, f2 / CCameraManager::Aspect(), CCameraManager::NearPlane(), CCameraManager::FarPlane(), @@ -1993,9 +1995,23 @@ CEntity* ScriptLoader::LoadBurrower(CStateManager& mgr, CInputStream& in, int pr return nullptr; } -CEntity* ScriptLoader::LoadScriptBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) +CEntity* ScriptLoader::LoadBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 7, "Beam")) + return nullptr; + + SActorHead aHead = LoadActorHead(in, mgr); + bool active = in.readBool(); + u32 weaponDescId = in.readUint32Big(); + if (!g_ResFactory->GetResourceTypeById(weaponDescId)) + return nullptr; + + CBeamInfo beamInfo(in); + CDamageInfo dInfo(in); + TToken weaponDesc = g_SimplePool->GetObj({SBIG('WPSC'), weaponDescId}); + + return new CScriptBeam(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform, active, + weaponDesc, beamInfo, dInfo); } CEntity* ScriptLoader::LoadWorldLightFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) diff --git a/Runtime/World/ScriptLoader.hpp b/Runtime/World/ScriptLoader.hpp index d1821d01b..cd74d4998 100644 --- a/Runtime/World/ScriptLoader.hpp +++ b/Runtime/World/ScriptLoader.hpp @@ -152,7 +152,7 @@ public: static CEntity* LoadSeedling(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadThermalHeatFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadBurrower(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); - static CEntity* LoadScriptBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); + static CEntity* LoadBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadWorldLightFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadMetroidPrimeStage2(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadMetroidPrimeStage1(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);