Added .vmt configurable horizontal texture scrolling to BuildingRescueLevel material proxy

This commit is contained in:
Voids29
2026-01-15 20:16:01 -05:00
committed by EricS-Valve
parent fd413c5fc7
commit 11a677c349

View File

@@ -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);
//-----------------------------------------------------------------------------