7676#include " netadr.h"
7777#include " input.h"
7878
79+ // for rescue ranger
80+ #include " materialsystem/imaterialproxy.h"
81+
7982#include " gcsdk/gcclientsdk.h"
8083#include " econ_gcmessages.h"
8184#include " rtime.h"
@@ -2342,12 +2345,31 @@ class CProxyBenefactorLevel : public CResultProxy
23422345EXPOSE_INTERFACE ( CProxyBenefactorLevel, IMaterialProxy, " BenefactorLevel" IMATERIAL_PROXY_INTERFACE_VERSION );
23432346
23442347// -----------------------------------------------------------------------------
2345- // Purpose: Used for scaling the oscilloscope on the Building Rescue Gun
2346- // Flattens the Wave when the player has no energy
2348+ // Purpose: Used for scaling the oscilloscope on the Rescue Ranger
2349+ // Flattens the Wave when the player has insufficent energy to rescue buildings
2350+ // Wave has horizontal scrolling whose speed and direction can be controlled from material proxy
23472351// -----------------------------------------------------------------------------
2352+
23482353class CProxyBuildingRescueLevel : public CResultProxy
23492354{
23502355public:
2356+ // Add this member (default to something safe)
2357+ float m_flScrollSpeed = -0 .1f ;
2358+
2359+ virtual bool Init ( IMaterial *pMaterial, KeyValues *pKeyValues )
2360+ {
2361+ // Call base init first if needed
2362+ if ( !CResultProxy::Init ( pMaterial, pKeyValues ) )
2363+ return false ;
2364+
2365+ // pKeyValues points to the { "screenScrollRate" "#" ... } subkey
2366+ if ( pKeyValues )
2367+ {
2368+ m_flScrollSpeed = pKeyValues->GetFloat ( " screenScrollRate" , -0 .1f ); // fallback if missing
2369+ }
2370+
2371+ return true ;
2372+ }
23512373 void OnBind ( void *pC_BaseEntity )
23522374 {
23532375 Assert ( m_pResult );
@@ -2391,6 +2413,17 @@ class CProxyBuildingRescueLevel : public CResultProxy
23912413 MatrixBuildTranslation ( temp, center.x , center.y , 0 .0f );
23922414 MatrixMultiply ( temp, mat, mat );
23932415
2416+
2417+ float flScrollSpeed = m_flScrollSpeed;
2418+
2419+ float scrollOffset = fmodf ( gpGlobals->curtime * flScrollSpeed, 1 .0f );
2420+ if ( scrollOffset < 0 .0f )
2421+ scrollOffset += 1 .0f ; // [0,1) range for seamless loop
2422+
2423+ // Apply horizontal scroll AFTER the existing scale/center operations
2424+ MatrixBuildTranslation ( temp, scrollOffset, 0 .0f , 0 .0f );
2425+ MatrixMultiply ( temp, mat, mat );
2426+
23942427 m_pResult->SetMatrixValue ( mat );
23952428
23962429 if ( ToolsEnabled () )
@@ -2400,7 +2433,7 @@ class CProxyBuildingRescueLevel : public CResultProxy
24002433 }
24012434};
24022435
2403- EXPOSE_INTERFACE ( CProxyBuildingRescueLevel, IMaterialProxy, " BuildingRescueLevel" IMATERIAL_PROXY_INTERFACE_VERSION );
2436+ EXPOSE_INTERFACE (CProxyBuildingRescueLevel, IMaterialProxy, " BuildingRescueLevel" IMATERIAL_PROXY_INTERFACE_VERSION);
24042437
24052438
24062439// -----------------------------------------------------------------------------
0 commit comments