upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462903 additions and 495158 deletions

View File

@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
// Information about algorithmic stuff that can occur on both client + server
@@ -67,22 +67,41 @@
#include "cbase.h"
#include "env_wind_shared.h"
#include "soundenvelope.h"
#include "IEffects.h"
#include "engine/IEngineSound.h"
#include "sharedInterface.h"
#include "ieffects.h"
#include "engine/ienginesound.h"
#include "sharedinterface.h"
#include "renderparm.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#ifdef CLIENT_DLL
// Test concommand for wind/tree sway. Couldn't think of a better way to put it.
// Will move it out of this file when we figure out how the weather control will be implemented.
CON_COMMAND( cl_tree_sway_dir, "sets tree sway wind direction and strength" )
{
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
if ( args.ArgC() == 3 )
{
Vector windDir;
windDir.x = V_atof( args.Arg( 1 ) );
windDir.y = V_atof( args.Arg( 2 ) );
windDir.z = 0;
pRenderContext->SetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION, windDir );
}
}
#endif
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------
static Vector s_vecWindVelocity( 0, 0, 0 );
static CUtlLinkedList< CEnvWindShared * > s_windControllers;
CEnvWindShared::CEnvWindShared() : m_WindAveQueue(10), m_WindVariationQueue(10)
{
m_pWindSound = NULL;
s_windControllers.AddToTail( this );
}
CEnvWindShared::~CEnvWindShared()
@@ -91,6 +110,7 @@ CEnvWindShared::~CEnvWindShared()
{
CSoundEnvelopeController::GetController().Shutdown( m_pWindSound );
}
s_windControllers.FindAndRemove( this );
}
void CEnvWindShared::Init( int nEntIndex, int iRandomSeed, float flTime,
@@ -103,6 +123,8 @@ void CEnvWindShared::Init( int nEntIndex, int iRandomSeed, float flTime,
m_Stream.SetSeed( iRandomSeed );
m_WindVariationStream.SetSeed( iRandomSeed );
m_iWindDir = m_iInitialWindDir = iInitialWindYaw;
// Bound it for networking as a postive integer
m_iInitialWindDir = (int)( anglemod( m_iInitialWindDir ) );
m_flAveWindSpeed = m_flWindSpeed = m_flInitialWindSpeed = flInitialWindSpeed;
@@ -162,6 +184,31 @@ void CEnvWindShared::UpdateWindSound( float flTotalWindSpeed )
}
}
//-----------------------------------------------------------------------------
// Updates the swaying of trees
//-----------------------------------------------------------------------------
#define TREE_SWAY_UPDATE_TIME 2.0f
void CEnvWindShared::UpdateTreeSway( float flTime )
{
#ifdef CLIENT_DLL
while( flTime >= m_flSwayTime )
{
// Since the wind is constantly changing, but we need smooth values, we cache them off here.
m_PrevSwayVector = m_CurrentSwayVector;
m_CurrentSwayVector = m_currentWindVector;
m_flSwayTime += TREE_SWAY_UPDATE_TIME;
}
// Update vertex shader
float flPercentage = ( 1 - ( ( m_flSwayTime - flTime ) / TREE_SWAY_UPDATE_TIME ) );
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
// Dividing by 2 helps the numbers the shader is expecting stay in line with other expected game values.
Vector vecWind = Lerp( flPercentage, m_PrevSwayVector, m_CurrentSwayVector ) / 2;
pRenderContext->SetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION, vecWind );
#endif
}
//-----------------------------------------------------------------------------
// Updates the wind speed
@@ -179,6 +226,9 @@ float CEnvWindShared::WindThink( float flTime )
ComputeWindVariation( flTime );
// Update Tree Sway
UpdateTreeSway( flTime );
while (true)
{
// First, simulate up to the next switch time...
@@ -218,9 +268,9 @@ float CEnvWindShared::WindThink( float flTime )
// We're about to exit, let's set the wind velocity...
QAngle vecWindAngle( 0, m_iWindDir + m_flWindAngleVariation, 0 );
AngleVectors( vecWindAngle, &s_vecWindVelocity );
AngleVectors( vecWindAngle, &m_currentWindVector );
float flTotalWindSpeed = m_flWindSpeed * m_flWindSpeedVariation;
s_vecWindVelocity *= flTotalWindSpeed;
m_currentWindVector *= flTotalWindSpeed;
// If we reached a steady state, we don't need to be called until the switch time
// Otherwise, we should be called immediately
@@ -274,13 +324,48 @@ float CEnvWindShared::WindThink( float flTime )
//-----------------------------------------------------------------------------
// Method to reset windspeed..
// Method to reset wind speed..
//-----------------------------------------------------------------------------
void ResetWindspeed()
{
s_vecWindVelocity.Init( 0, 0, 0 );
FOR_EACH_LL( s_windControllers, it )
{
s_windControllers[it]->m_currentWindVector.Init( 0, 0, 0 );
}
}
//-----------------------------------------------------------------------------
// GetWindspeedAtTime was never finished to actually take time in to consideration. We don't need
// features that aren't written, but we do need to have multiple wind controllers on a map, so
// we need to find the one that is affecting the given location and return its speed.
//-----------------------------------------------------------------------------
Vector GetWindspeedAtLocation( const Vector &location )
{
FOR_EACH_LL( s_windControllers, it )
{
CEnvWindShared *thisWindController = s_windControllers[it];
float distance = (thisWindController->m_location - location).Length();
if( distance < thisWindController->m_windRadius )
{
// This location is within our area of influence, so return our computer wind vector
return thisWindController->m_currentWindVector;
}
}
FOR_EACH_LL( s_windControllers, it )
{
CEnvWindShared *thisWindController = s_windControllers[it];
if( thisWindController->m_windRadius == -1.0f )
{
// We do a second search for a global controller so you don't have to worry about order in the list.
return thisWindController->m_currentWindVector;
}
}
return Vector(0,0,0);// No wind
}
//-----------------------------------------------------------------------------
// Method to sample the windspeed at a particular time
@@ -289,5 +374,12 @@ void GetWindspeedAtTime( float flTime, Vector &vecVelocity )
{
// For now, ignore history and time.. fix later when we use wind to affect
// client-side prediction
VectorCopy( s_vecWindVelocity, vecVelocity );
if ( s_windControllers.Count() == 0 )
{
vecVelocity.Init( 0, 0, 0 );
}
else
{
VectorCopy( s_windControllers[ s_windControllers.Head() ]->m_currentWindVector, vecVelocity );
}
}