mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-30 05:59:20 +00:00
upload "kind" alien swarm
This commit is contained in:
+205
-44
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ====
|
||||
//
|
||||
// An entity that allows level designer control over the fog parameters.
|
||||
//
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "player.h"
|
||||
#include "world.h"
|
||||
#include "ndebugoverlay.h"
|
||||
#include "triggers.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@@ -44,22 +46,23 @@ BEGIN_DATADESC( CFogController )
|
||||
DEFINE_INPUTFUNC( FIELD_COLOR32, "SetColorSecondaryLerpTo", InputSetColorSecondaryLerpTo ),
|
||||
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetStartDistLerpTo", InputSetStartDistLerpTo ),
|
||||
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetEndDistLerpTo", InputSetEndDistLerpTo ),
|
||||
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetMaxDensityLerpTo", InputSetMaxDensityLerpTo ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "StartFogTransition", InputStartFogTransition ),
|
||||
|
||||
// Quiet classcheck
|
||||
//DEFINE_EMBEDDED( m_fog ),
|
||||
|
||||
DEFINE_KEYFIELD( m_bUseAngles, FIELD_BOOLEAN, "use_angles" ),
|
||||
DEFINE_KEYFIELD( m_fog.colorPrimary, FIELD_COLOR32, "fogcolor" ),
|
||||
DEFINE_KEYFIELD( m_fog.colorSecondary, FIELD_COLOR32, "fogcolor2" ),
|
||||
DEFINE_KEYFIELD( m_fog.dirPrimary, FIELD_VECTOR, "fogdir" ),
|
||||
DEFINE_KEYFIELD( m_fog.enable, FIELD_BOOLEAN, "fogenable" ),
|
||||
DEFINE_KEYFIELD( m_fog.blend, FIELD_BOOLEAN, "fogblend" ),
|
||||
DEFINE_KEYFIELD( m_fog.start, FIELD_FLOAT, "fogstart" ),
|
||||
DEFINE_KEYFIELD( m_fog.end, FIELD_FLOAT, "fogend" ),
|
||||
DEFINE_KEYFIELD( m_fog.maxdensity, FIELD_FLOAT, "fogmaxdensity" ),
|
||||
DEFINE_KEYFIELD( m_fog.farz, FIELD_FLOAT, "farz" ),
|
||||
DEFINE_KEYFIELD( m_fog.duration, FIELD_FLOAT, "foglerptime" ),
|
||||
DEFINE_KEYFIELD( m_bUseAngles, FIELD_BOOLEAN, "use_angles" ),
|
||||
DEFINE_KEYFIELD( m_fog.colorPrimary, FIELD_COLOR32, "fogcolor" ),
|
||||
DEFINE_KEYFIELD( m_fog.colorSecondary, FIELD_COLOR32, "fogcolor2" ),
|
||||
DEFINE_KEYFIELD( m_fog.dirPrimary, FIELD_VECTOR, "fogdir" ),
|
||||
DEFINE_KEYFIELD( m_fog.enable, FIELD_BOOLEAN, "fogenable" ),
|
||||
DEFINE_KEYFIELD( m_fog.blend, FIELD_BOOLEAN, "fogblend" ),
|
||||
DEFINE_KEYFIELD( m_fog.start, FIELD_FLOAT, "fogstart" ),
|
||||
DEFINE_KEYFIELD( m_fog.end, FIELD_FLOAT, "fogend" ),
|
||||
DEFINE_KEYFIELD( m_fog.maxdensity, FIELD_FLOAT, "fogmaxdensity" ),
|
||||
DEFINE_KEYFIELD( m_fog.farz, FIELD_FLOAT, "farz" ),
|
||||
DEFINE_KEYFIELD( m_fog.duration, FIELD_FLOAT, "foglerptime" ),
|
||||
DEFINE_KEYFIELD( m_fog.HDRColorScale, FIELD_FLOAT, "HDRColorScale" ),
|
||||
|
||||
DEFINE_THINKFUNC( SetLerpValues ),
|
||||
|
||||
@@ -70,6 +73,7 @@ BEGIN_DATADESC( CFogController )
|
||||
DEFINE_FIELD( m_fog.colorSecondaryLerpTo, FIELD_COLOR32 ),
|
||||
DEFINE_FIELD( m_fog.startLerpTo, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_fog.endLerpTo, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_fog.maxdensityLerpTo, FIELD_FLOAT ),
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
@@ -78,19 +82,22 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CFogController, DT_FogController )
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.enable ), 1, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.blend ), 1, SPROP_UNSIGNED ),
|
||||
SendPropVector( SENDINFO_STRUCTELEM(m_fog.dirPrimary), -1, SPROP_COORD),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorPrimary ), 32, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorSecondary ), 32, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorPrimary ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorSecondary ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.start ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.end ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.maxdensity ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.farz ), 0, SPROP_NOSCALE ),
|
||||
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorPrimaryLerpTo ), 32, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorSecondaryLerpTo ), 32, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorPrimaryLerpTo ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
|
||||
SendPropInt( SENDINFO_STRUCTELEM( m_fog.colorSecondaryLerpTo ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.startLerpTo ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.endLerpTo ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.maxdensityLerpTo ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.lerptime ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.duration ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO_STRUCTELEM( m_fog.HDRColorScale ), 0, SPROP_NOSCALE ),
|
||||
|
||||
END_SEND_TABLE()
|
||||
|
||||
CFogController::CFogController()
|
||||
@@ -98,6 +105,7 @@ CFogController::CFogController()
|
||||
// Make sure that old maps without fog fields don't get wacked out fog values.
|
||||
m_fog.enable = false;
|
||||
m_fog.maxdensity = 1.0f;
|
||||
m_fog.HDRColorScale = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -240,11 +248,11 @@ int CFogController::DrawDebugTextOverlays(void)
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
|
||||
Q_snprintf(tempstr,sizeof(tempstr),"Start: %3.0f",m_fog.start.Get());
|
||||
Q_snprintf(tempstr,sizeof(tempstr),"Start: %3.0f",m_fog.start.Get() );
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
|
||||
Q_snprintf(tempstr,sizeof(tempstr),"End : %3.0f",m_fog.end.Get());
|
||||
Q_snprintf(tempstr,sizeof(tempstr),"End : %3.0f",m_fog.end.Get() );
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
|
||||
@@ -273,14 +281,19 @@ int CFogController::DrawDebugTextOverlays(void)
|
||||
Q_snprintf(tempstr,sizeof(tempstr),"2) Blue : %i",color.b);
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
|
||||
Q_snprintf(tempstr,sizeof(tempstr),"HDR Color Scale: %0.3f",m_fog.HDRColorScale.Get() );
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
}
|
||||
return text_offset;
|
||||
}
|
||||
|
||||
#define FOG_CONTROLLER_COLORPRIMARY_LERP 1
|
||||
#define FOG_CONTROLLER_COLORSECONDARY_LERP 2
|
||||
#define FOG_CONTROLLER_START_LERP 4
|
||||
#define FOG_CONTROLLER_END_LERP 8
|
||||
#define FOG_CONTROLLER_COLORPRIMARY_LERP (1 << 0)
|
||||
#define FOG_CONTROLLER_COLORSECONDARY_LERP (1 << 1)
|
||||
#define FOG_CONTROLLER_START_LERP (1 << 2)
|
||||
#define FOG_CONTROLLER_END_LERP (1 << 3)
|
||||
#define FOG_CONTROLLER_MAXDENSITY_LERP (1 << 4)
|
||||
|
||||
void CFogController::InputSetColorLerpTo(inputdata_t &data)
|
||||
{
|
||||
@@ -306,6 +319,13 @@ void CFogController::InputSetEndDistLerpTo(inputdata_t &data)
|
||||
m_fog.endLerpTo = data.value.Float();
|
||||
}
|
||||
|
||||
void CFogController::InputSetMaxDensityLerpTo(inputdata_t &data)
|
||||
{
|
||||
m_iChangedVariables |= FOG_CONTROLLER_MAXDENSITY_LERP;
|
||||
m_fog.maxdensityLerpTo = data.value.Float();
|
||||
}
|
||||
|
||||
|
||||
void CFogController::InputStartFogTransition(inputdata_t &data)
|
||||
{
|
||||
SetThink( &CFogController::SetLerpValues );
|
||||
@@ -336,6 +356,11 @@ void CFogController::SetLerpValues( void )
|
||||
m_fog.end = m_fog.endLerpTo;
|
||||
}
|
||||
|
||||
if ( m_iChangedVariables & FOG_CONTROLLER_MAXDENSITY_LERP )
|
||||
{
|
||||
m_fog.maxdensity = m_fog.maxdensityLerpTo;
|
||||
}
|
||||
|
||||
m_iChangedVariables = 0;
|
||||
m_fog.lerptime = gpGlobals->curtime;
|
||||
}
|
||||
@@ -346,7 +371,43 @@ void CFogController::SetLerpValues( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFogSystem::LevelInitPreEntity( void )
|
||||
{
|
||||
m_pMasterController = NULL;
|
||||
m_hMasterController = NULL;
|
||||
ListenForGameEvent( "round_start" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Find the master controller. If no controller is
|
||||
// set as Master, use the first controller found.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFogSystem::InitMasterController( void )
|
||||
{
|
||||
CFogController *pFogController = NULL;
|
||||
do
|
||||
{
|
||||
pFogController = static_cast<CFogController*>( gEntList.FindEntityByClassname( pFogController, "env_fog_controller" ) );
|
||||
if ( pFogController )
|
||||
{
|
||||
if ( m_hMasterController.Get() == NULL )
|
||||
{
|
||||
m_hMasterController = pFogController;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( pFogController->IsMaster() )
|
||||
{
|
||||
m_hMasterController = pFogController;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ( pFogController );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: On a multiplayer map restart, re-find the master controller.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFogSystem::FireGameEvent( IGameEvent *pEvent )
|
||||
{
|
||||
InitMasterController();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -355,25 +416,7 @@ void CFogSystem::LevelInitPreEntity( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFogSystem::LevelInitPostEntity( void )
|
||||
{
|
||||
CFogController *pFogController = NULL;
|
||||
do
|
||||
{
|
||||
pFogController = static_cast<CFogController*>( gEntList.FindEntityByClassname( pFogController, "env_fog_controller" ) );
|
||||
if ( pFogController )
|
||||
{
|
||||
if ( m_pMasterController == NULL )
|
||||
{
|
||||
m_pMasterController = pFogController;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( pFogController->IsMaster() )
|
||||
{
|
||||
m_pMasterController = pFogController;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ( pFogController );
|
||||
InitMasterController();
|
||||
|
||||
// HACK: Singleplayer games don't get a call to CBasePlayer::Spawn on level transitions.
|
||||
// CBasePlayer::Activate is called before this is called so that's too soon to set up the fog controller.
|
||||
@@ -382,10 +425,128 @@ void CFogSystem::LevelInitPostEntity( void )
|
||||
if ( gpGlobals->maxClients == 1 )
|
||||
{
|
||||
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
||||
if ( pPlayer && ( pPlayer->m_Local.m_PlayerFog.m_hCtrl.Get() == NULL ) )
|
||||
if ( pPlayer && ( pPlayer->m_PlayerFog.m_hCtrl.Get() == NULL ) )
|
||||
{
|
||||
pPlayer->InitFogController();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
class CFogTrigger : public CBaseTrigger
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CFogTrigger, CBaseTrigger );
|
||||
DECLARE_DATADESC();
|
||||
|
||||
virtual void Spawn( void );
|
||||
virtual void StartTouch( CBaseEntity *other );
|
||||
virtual void EndTouch( CBaseEntity *other );
|
||||
|
||||
fogparams_t *GetFog( void )
|
||||
{
|
||||
return &m_fog;
|
||||
}
|
||||
|
||||
private:
|
||||
fogparams_t m_fog;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( trigger_fog, CFogTrigger );
|
||||
|
||||
BEGIN_DATADESC( CFogTrigger )
|
||||
|
||||
DEFINE_KEYFIELD( m_fog.colorPrimary, FIELD_COLOR32, "fogcolor" ),
|
||||
DEFINE_KEYFIELD( m_fog.colorSecondary, FIELD_COLOR32, "fogcolor2" ),
|
||||
DEFINE_KEYFIELD( m_fog.dirPrimary, FIELD_VECTOR, "fogdir" ),
|
||||
DEFINE_KEYFIELD( m_fog.enable, FIELD_BOOLEAN, "fogenable" ),
|
||||
DEFINE_KEYFIELD( m_fog.blend, FIELD_BOOLEAN, "fogblend" ),
|
||||
DEFINE_KEYFIELD( m_fog.start, FIELD_FLOAT, "fogstart" ),
|
||||
DEFINE_KEYFIELD( m_fog.end, FIELD_FLOAT, "fogend" ),
|
||||
DEFINE_KEYFIELD( m_fog.farz, FIELD_FLOAT, "farz" ),
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CFogTrigger::Spawn( void )
|
||||
{
|
||||
AddSpawnFlags( SF_TRIGGER_ALLOW_ALL );
|
||||
|
||||
BaseClass::Spawn();
|
||||
InitTrigger();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CFogTrigger::StartTouch( CBaseEntity *other )
|
||||
{
|
||||
if ( !PassesTriggerFilters( other ) )
|
||||
return;
|
||||
|
||||
BaseClass::StartTouch( other );
|
||||
|
||||
CBaseCombatCharacter *character = other->MyCombatCharacterPointer();
|
||||
if ( !character )
|
||||
return;
|
||||
|
||||
character->OnFogTriggerStartTouch( this );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CFogTrigger::EndTouch( CBaseEntity *other )
|
||||
{
|
||||
if ( !PassesTriggerFilters( other ) )
|
||||
return;
|
||||
|
||||
BaseClass::EndTouch( other );
|
||||
|
||||
CBaseCombatCharacter *character = other->MyCombatCharacterPointer();
|
||||
if ( !character )
|
||||
return;
|
||||
|
||||
character->OnFogTriggerEndTouch( this );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool GetWorldFogParams( CBaseCombatCharacter *character, fogparams_t &fog )
|
||||
{
|
||||
|
||||
fogparams_t *targetFog = NULL;
|
||||
if ( character && character->GetFogTrigger() )
|
||||
{
|
||||
CFogTrigger *trigger = dynamic_cast< CFogTrigger * >(character->GetFogTrigger());
|
||||
if ( trigger )
|
||||
{
|
||||
targetFog = trigger->GetFog();
|
||||
}
|
||||
}
|
||||
|
||||
if ( !targetFog && FogSystem()->GetMasterFogController() )
|
||||
{
|
||||
targetFog = &(FogSystem()->GetMasterFogController()->m_fog);
|
||||
}
|
||||
|
||||
if ( targetFog )
|
||||
{
|
||||
if ( *targetFog != fog )
|
||||
{
|
||||
fog = *targetFog;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fog.farz != -1 || fog.enable != false )
|
||||
{
|
||||
// No fog controller in this level. Use default fog parameters.
|
||||
fog.farz = -1;
|
||||
fog.enable = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user