Skip to content

Commit

Permalink
Allow setElementCollisionsEnabled for buildings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed May 11, 2024
1 parent 1f2c6e7 commit 453559c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Client/mods/deathmatch/logic/CClientBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ CClientBuilding::CClientBuilding(class CClientManager* pManager, ElementID ID, u
m_vPos(pos),
m_vRot(rot),
m_interior(interior),
m_pBuilding(nullptr)
m_pBuilding(nullptr),
m_bUsesCollision(true)
{
m_pManager = pManager;
SetTypeName("building");
Expand Down Expand Up @@ -88,6 +89,15 @@ void CClientBuilding::SetModel(uint16_t model)
}
}

void CClientBuilding::SetUsesCollision(bool state)
{
m_bUsesCollision = state;
if (m_pBuilding)
{
m_pBuilding->SetUsesCollision(state);
}
}

void CClientBuilding::Create()
{
if (m_pBuilding)
Expand All @@ -97,6 +107,11 @@ void CClientBuilding::Create()
ConvertZXYEulersToQuaternion(m_vRot, vRot4D);

m_pBuilding = g_pGame->GetPools()->GetBuildingsPool().AddBuilding(this, m_usModelId, &m_vPos, &vRot4D, m_interior);

if (m_bUsesCollision == false)
{
m_pBuilding->SetUsesCollision(m_bUsesCollision);
}
}

void CClientBuilding::Destroy()
Expand Down
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/CClientBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class CClientBuilding : public CClientEntity

eClientEntityType GetType() const noexcept { return CCLIENTBUILDING; }

void SetUsesCollision(bool state);

void Create();
void Destroy();
bool IsValid() const noexcept { return m_pBuilding != nullptr; };
Expand All @@ -62,4 +64,5 @@ class CClientBuilding : public CClientEntity
CVector m_vPos;
CVector m_vRot;
uint8_t m_interior;
bool m_bUsesCollision;
};
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3756,6 +3756,11 @@ bool CStaticFunctionDefinitions::SetElementCollisionsEnabled(CClientEntity& Enti
Ped.SetUsesCollision(bEnabled);
break;
}
case CCLIENTBUILDING:
{
static_cast<CClientBuilding&>(Entity).SetUsesCollision(bEnabled);
break;
}
default:
return false;
}
Expand Down

0 comments on commit 453559c

Please sign in to comment.