Skip to content

Commit

Permalink
re-set crafting material model every 5 seconds in the hope that playe…
Browse files Browse the repository at this point in the history
…rs will see the right model

in the expected case, this just costs a model name lookup, which shouldn't be noticeable
  • Loading branch information
BenLubar committed Dec 4, 2024
1 parent c7b2f2a commit 1371bbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/game/shared/swarm/rd_crafting_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ CRD_Crafting_Material_Pickup::CRD_Crafting_Material_Pickup() :
m_GlowObject{ this, glow_outline_color_crafting.GetColorAsVector(), 0.8f, true, true }
{
m_iLastMaterialType = RD_CRAFTING_MATERIAL_NONE;
m_flLastWorkaroundReset = 0.0f;
}

void CRD_Crafting_Material_Pickup::OnDataChanged( DataUpdateType_t updateType )
Expand Down Expand Up @@ -467,7 +468,7 @@ void CRD_Crafting_Material_Pickup::ClientThink()

int iCurrentPlayerIndex = pPlayer ? pPlayer->entindex() : 0;
RD_Crafting_Material_t iCurrentMaterial = iCurrentPlayerIndex ? m_MaterialAtLocation[iCurrentPlayerIndex - 1] : RD_CRAFTING_MATERIAL_NONE;
if ( m_iLastMaterialType != iCurrentMaterial )
if ( m_iLastMaterialType != iCurrentMaterial || m_flLastWorkaroundReset < gpGlobals->curtime - 5.0f )
{
const char *szModelName = g_RD_Crafting_Material_Info[iCurrentMaterial].m_szModelName;
if ( szModelName )
Expand Down Expand Up @@ -505,6 +506,7 @@ void CRD_Crafting_Material_Pickup::ClientThink()
}

m_iLastMaterialType = iCurrentMaterial;
m_flLastWorkaroundReset = gpGlobals->curtime;
}

if ( !IsEffectActive( EF_NODRAW ) )
Expand Down
1 change: 1 addition & 0 deletions src/game/shared/swarm/rd_crafting_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class CRD_Crafting_Material_Pickup :
bool NeedsLOSCheck() override { return false; }

RD_Crafting_Material_t m_iLastMaterialType;
float m_flLastWorkaroundReset;
CGlowObject m_GlowObject;
#else
void Precache() override;
Expand Down

0 comments on commit 1371bbe

Please sign in to comment.