Skip to content

Commit

Permalink
Merge pull request #1732 from DarkflameUniverse/quickbuild
Browse files Browse the repository at this point in the history
fix: reduce networked traffic for QuickBuildComponent Serialization
  • Loading branch information
DarwinAnim8or authored Jan 17, 2025
2 parents dc602a9 + a0913ff commit b0d993d
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions dGame/dComponents/QuickBuildComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ void QuickBuildComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsIni
void QuickBuildComponent::Update(float deltaTime) {
SetActivator(GetActivator());

// Serialize the quickbuild every so often, fixes the odd bug where the quickbuild is not buildable
/*if (m_SoftTimer > 0.0f) {
m_SoftTimer -= deltaTime;
}
else {
m_SoftTimer = 5.0f;
Game::entityManager->SerializeEntity(m_Parent);
}*/

switch (m_State) {
case eQuickBuildState::OPEN: {
SpawnActivator();
Expand All @@ -125,11 +115,10 @@ void QuickBuildComponent::Update(float deltaTime) {

if (isSmashGroup) {
ModifyIncompleteTimer(deltaTime);
Game::entityManager->SerializeEntity(m_Parent);

// For reset times < 0 this has to be handled manually
if (m_TimeBeforeSmash > 0) {
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f && !m_ShowResetEffect) {
SetShowResetEffect(true);

Game::entityManager->SerializeEntity(m_Parent);
Expand All @@ -149,11 +138,10 @@ void QuickBuildComponent::Update(float deltaTime) {
}
case eQuickBuildState::COMPLETED: {
ModifyTimer(deltaTime);
Game::entityManager->SerializeEntity(m_Parent);

// For reset times < 0 this has to be handled manually
if (m_ResetTime > 0) {
if (m_Timer >= m_ResetTime - 4.0f) {
if (m_Timer >= m_ResetTime - 4.0f && !m_ShowResetEffect) {
SetShowResetEffect(true);

Game::entityManager->SerializeEntity(m_Parent);
Expand Down Expand Up @@ -210,11 +198,10 @@ void QuickBuildComponent::Update(float deltaTime) {
}
case eQuickBuildState::INCOMPLETE: {
ModifyIncompleteTimer(deltaTime);
Game::entityManager->SerializeEntity(m_Parent);

// For reset times < 0 this has to be handled manually
if (m_TimeBeforeSmash > 0) {
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f && !m_ShowResetEffect) {
SetShowResetEffect(true);

Game::entityManager->SerializeEntity(m_Parent);
Expand Down

0 comments on commit b0d993d

Please sign in to comment.