From 11a677c349b149b2f77184dc903e6bb17f8df69b Mon Sep 17 00:00:00 2001 From: Voids29 <99505279+Voids29@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:16:01 -0500 Subject: [PATCH] Added .vmt configurable horizontal texture scrolling to BuildingRescueLevel material proxy --- src/game/client/tf/c_tf_player.cpp | 39 +++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/game/client/tf/c_tf_player.cpp b/src/game/client/tf/c_tf_player.cpp index ca482d17d..0873ffe25 100644 --- a/src/game/client/tf/c_tf_player.cpp +++ b/src/game/client/tf/c_tf_player.cpp @@ -76,6 +76,9 @@ #include "netadr.h" #include "input.h" +// for rescue ranger +#include "materialsystem/imaterialproxy.h" + #include "gcsdk/gcclientsdk.h" #include "econ_gcmessages.h" #include "rtime.h" @@ -2289,12 +2292,31 @@ public: EXPOSE_INTERFACE( CProxyBenefactorLevel, IMaterialProxy, "BenefactorLevel" IMATERIAL_PROXY_INTERFACE_VERSION ); //----------------------------------------------------------------------------- -// Purpose: Used for scaling the oscilloscope on the Building Rescue Gun -// Flattens the Wave when the player has no energy +// Purpose: Used for scaling the oscilloscope on the Rescue Ranger +// Flattens the Wave when the player has insufficent energy to rescue buildings +// Wave has horizontal scrolling whose speed and direction can be controlled from material proxy //----------------------------------------------------------------------------- + class CProxyBuildingRescueLevel : public CResultProxy { public: +// Add this member (default to something safe) + float m_flScrollSpeed = -0.1f; + + virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues ) + { + // Call base init first if needed + if ( !CResultProxy::Init( pMaterial, pKeyValues ) ) + return false; + + // pKeyValues points to the { "screenScrollRate" "#" ... } subkey + if ( pKeyValues ) + { + m_flScrollSpeed = pKeyValues->GetFloat( "screenScrollRate", -0.1f ); // fallback if missing + } + + return true; + } void OnBind( void *pC_BaseEntity ) { Assert( m_pResult ); @@ -2338,6 +2360,17 @@ public: MatrixBuildTranslation( temp, center.x, center.y, 0.0f ); MatrixMultiply( temp, mat, mat ); + + float flScrollSpeed = m_flScrollSpeed; + + float scrollOffset = fmodf( gpGlobals->curtime * flScrollSpeed, 1.0f ); + if ( scrollOffset < 0.0f ) + scrollOffset += 1.0f; // [0,1) range for seamless loop + + // Apply horizontal scroll AFTER the existing scale/center operations + MatrixBuildTranslation( temp, scrollOffset, 0.0f, 0.0f ); + MatrixMultiply( temp, mat, mat ); + m_pResult->SetMatrixValue( mat ); if ( ToolsEnabled() ) @@ -2347,7 +2380,7 @@ public: } }; -EXPOSE_INTERFACE( CProxyBuildingRescueLevel, IMaterialProxy, "BuildingRescueLevel" IMATERIAL_PROXY_INTERFACE_VERSION ); +EXPOSE_INTERFACE(CProxyBuildingRescueLevel, IMaterialProxy, "BuildingRescueLevel" IMATERIAL_PROXY_INTERFACE_VERSION); //-----------------------------------------------------------------------------