From f323638fb79dace69b10121770982bcb3996cc6f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 24 Mar 2020 21:16:27 -0400 Subject: [PATCH] CCollisionActor: Provide parameter names in interface where applicable Makes the interface more self-documenting at a glance and allows IDEs to do better parameter inspection at call sites. --- Runtime/Collision/CCollisionActor.cpp | 26 ++++++++++++------------ Runtime/Collision/CCollisionActor.hpp | 29 +++++++++++++++------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Runtime/Collision/CCollisionActor.cpp b/Runtime/Collision/CCollisionActor.cpp index 2bdfb8a9b..a8007ceca 100644 --- a/Runtime/Collision/CCollisionActor.cpp +++ b/Runtime/Collision/CCollisionActor.cpp @@ -13,13 +13,13 @@ constexpr CMaterialList skDefaultCollisionActorMaterials = CMaterialList(EMaterialTypes::Solid, EMaterialTypes::CollisionActor, EMaterialTypes::ScanPassthrough, EMaterialTypes::CameraPassthrough); -CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& extent, +CCollisionActor::CCollisionActor(TUniqueId uid, TAreaId areaId, TUniqueId owner, const zeus::CVector3f& extent, const zeus::CVector3f& center, bool active, float mass, std::string_view name) -: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList), +: CPhysicsActor(uid, active, "CollisionActor", CEntityInfo(areaId, CEntity::NullConnectionList), zeus::CTransform(), CModelData::CModelDataNull(), skDefaultCollisionActorMaterials, zeus::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f) , x258_primitiveType(EPrimitiveType::OBBTreeGroup) -, x25c_owner(uid2) +, x25c_owner(owner) , x260_boxSize(extent) , x26c_center(center) , x278_obbContainer(std::make_unique(extent, center)) @@ -32,13 +32,13 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, co {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::NoStaticCollision})); } -CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& boxSize, +CCollisionActor::CCollisionActor(TUniqueId uid, TAreaId areaId, TUniqueId owner, const zeus::CVector3f& boxSize, bool active, float mass, std::string_view name) -: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList), +: CPhysicsActor(uid, active, "CollisionActor", CEntityInfo(areaId, CEntity::NullConnectionList), zeus::CTransform(), CModelData::CModelDataNull(), skDefaultCollisionActorMaterials, zeus::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f) , x258_primitiveType(EPrimitiveType::AABox) -, x25c_owner(uid2) +, x25c_owner(owner) , x260_boxSize(boxSize) , x280_aaboxPrimitive( std::make_unique(zeus::CAABox(-0.5f * boxSize, 0.5f * boxSize), @@ -51,13 +51,13 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, co {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::NoStaticCollision})); } -CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, bool active, float radius, float mass, +CCollisionActor::CCollisionActor(TUniqueId uid, TAreaId areaId, TUniqueId owner, bool active, float radius, float mass, std::string_view name) -: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList), +: CPhysicsActor(uid, active, "CollisionActor", CEntityInfo(areaId, CEntity::NullConnectionList), zeus::CTransform(), CModelData::CModelDataNull(), skDefaultCollisionActorMaterials, zeus::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f) , x258_primitiveType(EPrimitiveType::Sphere) -, x25c_owner(uid2) +, x25c_owner(owner) , x284_spherePrimitive(std::make_unique( zeus::CSphere(zeus::skZero3f, radius), CMaterialList(EMaterialTypes::NoStaticCollision, EMaterialTypes::Solid))) , x288_sphereRadius(radius) { @@ -71,7 +71,7 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, bo void CCollisionActor::Accept(IVisitor& visitor) { visitor.Visit(this); } -void CCollisionActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { +void CCollisionActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) { switch (msg) { case EScriptObjectMessage::Falling: case EScriptObjectMessage::Registered: @@ -82,7 +82,7 @@ void CCollisionActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C case EScriptObjectMessage::Damage: case EScriptObjectMessage::InvulnDamage: { if (CEntity* ent = mgr.ObjectById(x25c_owner)) { - x2fc_lastTouched = uid; + x2fc_lastTouched = sender; mgr.SendScriptMsg(ent, GetUniqueId(), msg); } } break; @@ -91,7 +91,7 @@ void CCollisionActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C break; } - CActor::AcceptScriptMsg(msg, uid, mgr); + CActor::AcceptScriptMsg(msg, sender, mgr); } CHealthInfo* CCollisionActor::HealthInfo(CStateManager&) { return &x28c_healthInfo; } @@ -157,7 +157,7 @@ std::optional CCollisionActor::GetTouchBounds() const { return aabox; } -void CCollisionActor::OnScanStateChanged(CActor::EScanState state, CStateManager& mgr) { +void CCollisionActor::OnScanStateChanged(EScanState state, CStateManager& mgr) { TCastToPtr actor = mgr.ObjectById(x25c_owner); if (actor) actor->OnScanStateChanged(state, mgr); diff --git a/Runtime/Collision/CCollisionActor.hpp b/Runtime/Collision/CCollisionActor.hpp index 4b356f02b..09435e251 100644 --- a/Runtime/Collision/CCollisionActor.hpp +++ b/Runtime/Collision/CCollisionActor.hpp @@ -33,24 +33,27 @@ class CCollisionActor : public CPhysicsActor { zeus::CVector3f x304_extendedTouchBounds = zeus::skZero3f; public: - CCollisionActor(TUniqueId, TAreaId, TUniqueId, const zeus::CVector3f&, const zeus::CVector3f&, bool, float, + CCollisionActor(TUniqueId uid, TAreaId areaId, TUniqueId owner, const zeus::CVector3f& extent, + const zeus::CVector3f& center, bool active, float mass, std::string_view name); + CCollisionActor(TUniqueId uid, TAreaId areaId, TUniqueId owner, const zeus::CVector3f& boxSize, bool active, + float mass, std::string_view name); + CCollisionActor(TUniqueId uid, TAreaId areaId, TUniqueId owner, bool active, float radius, float mass, std::string_view name); - CCollisionActor(TUniqueId, TAreaId, TUniqueId, const zeus::CVector3f&, bool, float, std::string_view name); - CCollisionActor(TUniqueId, TAreaId, TUniqueId, bool, float, float, std::string_view name); void Accept(IVisitor& visitor) override; - void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - CHealthInfo* HealthInfo(CStateManager&) override; + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; + CHealthInfo* HealthInfo(CStateManager& mgr) override; const CDamageVulnerability* GetDamageVulnerability() const override; - const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&, - const CDamageInfo&) const override; - void OnScanStateChanged(EScanState, CStateManager&) override; + const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, + const CDamageInfo& dInfo) const override; + void OnScanStateChanged(EScanState state, CStateManager& mgr) override; - void Touch(CActor&, CStateManager&) override; - zeus::CVector3f GetOrbitPosition(const CStateManager&) const override; + void Touch(CActor& actor, CStateManager& mgr) override; + zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const override; const CCollisionPrimitive* GetCollisionPrimitive() const override; - EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, - const CWeaponMode&, EProjectileAttrib) const override; + EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, + const CWeaponMode& mode, + EProjectileAttrib attribute) const override; void SetWeaponCollisionResponseType(EWeaponCollisionResponseTypes type) { x300_responseType = type; } zeus::CTransform GetPrimitiveTransform() const override; std::optional GetTouchBounds() const override; @@ -58,7 +61,7 @@ public: const zeus::CVector3f& GetBoxSize() const { return x260_boxSize; } TUniqueId GetOwnerId() const { return x25c_owner; } TUniqueId GetLastTouchedObject() const { return x2fc_lastTouched; } - zeus::CVector3f GetScanObjectIndicatorPosition(const CStateManager&) const override; + zeus::CVector3f GetScanObjectIndicatorPosition(const CStateManager& mgr) const override; void SetExtendedTouchBounds(const zeus::CVector3f& boundExt) { x304_extendedTouchBounds = boundExt; } void SetSphereRadius(float radius); float GetSphereRadius() const { return x288_sphereRadius; }