Skip to content

Commit

Permalink
Merge branch 'master' into TheNormalnij/new_fun
Browse files Browse the repository at this point in the history
  • Loading branch information
Dutchman101 authored May 28, 2024
2 parents 3eafed9 + 5081111 commit 3128727
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
21 changes: 19 additions & 2 deletions Client/mods/deathmatch/logic/CClientBuilding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "StdInc.h"

CClientBuilding::CClientBuilding(class CClientManager* pManager, ElementID ID, uint16_t usModelId, const CVector &pos, const CVector &rot, uint8_t interior)
CClientBuilding::CClientBuilding(class CClientManager* pManager, ElementID ID, uint16_t usModelId, const CVector& pos, const CVector& rot, uint8_t interior)
: ClassInit(this),
CClientEntity(ID),
m_pBuildingManager(pManager->GetBuildingManager()),
Expand All @@ -19,6 +19,7 @@ CClientBuilding::CClientBuilding(class CClientManager* pManager, ElementID ID, u
m_vRot(rot),
m_interior(interior),
m_pBuilding(nullptr),
m_usesCollision(true),
m_pHighBuilding(nullptr),
m_pLowBuilding(nullptr)
{
Expand Down Expand Up @@ -91,7 +92,7 @@ void CClientBuilding::SetInterior(uint8_t ucInterior)
return;
m_interior = ucInterior;
Recreate();
}
}

void CClientBuilding::SetModel(uint16_t model)
{
Expand All @@ -102,6 +103,18 @@ void CClientBuilding::SetModel(uint16_t model)
}
}

void CClientBuilding::SetUsesCollision(bool state)
{
if (m_usesCollision == state)
return;

m_usesCollision = state;
if (m_pBuilding)
{
m_pBuilding->SetUsesCollision(state);
}
}

void CClientBuilding::Create()
{
if (m_pBuilding)
Expand All @@ -115,6 +128,10 @@ void CClientBuilding::Create()

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

if (!m_usesCollision)
{
m_pBuilding->SetUsesCollision(m_usesCollision);
}
if (m_pHighBuilding)
{
m_pHighBuilding->GetBuildingEntity()->SetLod(m_pBuilding);
Expand Down
9 changes: 6 additions & 3 deletions Client/mods/deathmatch/logic/CClientBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class CClientBuilding : public CClientEntity

eClientEntityType GetType() const { return CCLIENTBUILDING; }

void SetUsesCollision(bool state);

void Create();
void Destroy();

bool IsValid() const noexcept { return m_pBuilding != nullptr; };


Expand All @@ -52,9 +57,6 @@ class CClientBuilding : public CClientEntity


private:
void Create();
void Destroy();

CClientBuilding* GetHighLodBuilding() const { return m_pHighBuilding; };
void SetHighLodBuilding(CClientBuilding* pHighBuilding = nullptr) { m_pHighBuilding = pHighBuilding; };

Expand All @@ -72,6 +74,7 @@ class CClientBuilding : public CClientEntity
CVector m_vPos;
CVector m_vRot;
uint8_t m_interior;
bool m_usesCollision;

CClientBuilding* m_pHighBuilding;
CClientBuilding* m_pLowBuilding;
Expand Down
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 3128727

Please sign in to comment.