Added "Disable flashlight" keyvalue/inputs inspired by Portal 2's

This commit is contained in:
Blixibon 2021-03-07 11:43:28 -06:00
parent bd3b9c3807
commit 15ae789b89
4 changed files with 32 additions and 0 deletions

View File

@ -578,6 +578,7 @@ BEGIN_RECV_TABLE_NOBASE(C_BaseEntity, DT_BaseEntity)
RecvPropInt(RECVINFO(m_clrRender)),
#ifdef MAPBASE
RecvPropInt(RECVINFO(m_iViewHideFlags)),
RecvPropBool(RECVINFO(m_bDisableFlashlight)),
#endif
RecvPropInt(RECVINFO(m_iTeamNum)),
RecvPropInt(RECVINFO(m_CollisionGroup)),
@ -1683,6 +1684,11 @@ bool C_BaseEntity::ShouldReceiveProjectedTextures( int flags )
if ( IsEffectActive( EF_NODRAW ) )
return false;
#ifdef MAPBASE
if ( m_bDisableFlashlight )
return false;
#endif
if( flags & SHADOW_FLAGS_FLASHLIGHT )
{
if ( GetRenderMode() > kRenderNormal && GetRenderColor().a == 0 )

View File

@ -1378,6 +1378,7 @@ public:
#ifdef MAPBASE
int m_iViewHideFlags;
bool m_bDisableFlashlight;
#endif
private:

View File

@ -284,6 +284,7 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CBaseEntity, DT_BaseEntity )
#ifdef MAPBASE
// Keep consistent with VIEW_ID_COUNT in viewrender.h
SendPropInt (SENDINFO(m_iViewHideFlags), 9, SPROP_UNSIGNED ),
SendPropBool (SENDINFO(m_bDisableFlashlight) ),
#endif
SendPropInt (SENDINFO(m_iTeamNum), TEAMNUM_NUM_BITS, 0),
SendPropInt (SENDINFO(m_CollisionGroup), 5, SPROP_UNSIGNED),
@ -1915,6 +1916,7 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity )
DEFINE_GLOBAL_KEYFIELD( m_nModelIndex, FIELD_SHORT, "modelindex" ),
#ifdef MAPBASE
DEFINE_KEYFIELD( m_iViewHideFlags, FIELD_INTEGER, "viewhideflags" ),
DEFINE_KEYFIELD( m_bDisableFlashlight, FIELD_BOOLEAN, "disableflashlight" ),
#endif
#if !defined( NO_ENTITY_PREDICTION )
// DEFINE_FIELD( m_PredictableID, CPredictableId ),
@ -2148,6 +2150,8 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity )
DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveEffects", InputRemoveEffects ),
DEFINE_INPUTFUNC( FIELD_VOID, "EnableDraw", InputDrawEntity ),
DEFINE_INPUTFUNC( FIELD_VOID, "DisableDraw", InputUndrawEntity ),
DEFINE_INPUTFUNC( FIELD_VOID, "EnableReceivingFlashlight", InputEnableReceivingFlashlight ),
DEFINE_INPUTFUNC( FIELD_VOID, "DisableReceivingFlashlight", InputDisableReceivingFlashlight ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "AddEFlags", InputAddEFlags ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "RemoveEFlags", InputRemoveEFlags ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "AddSolidFlags", InputAddSolidFlags ),
@ -8264,6 +8268,22 @@ void CBaseEntity::InputUndrawEntity( inputdata_t& inputdata )
AddEffects(EF_NODRAW);
}
//-----------------------------------------------------------------------------
// Purpose: Inspired by the Portal 2 input of the same name.
//-----------------------------------------------------------------------------
void CBaseEntity::InputEnableReceivingFlashlight( inputdata_t& inputdata )
{
m_bDisableFlashlight = false;
}
//-----------------------------------------------------------------------------
// Purpose: Inspired by the Portal 2 input of the same name.
//-----------------------------------------------------------------------------
void CBaseEntity::InputDisableReceivingFlashlight( inputdata_t& inputdata )
{
m_bDisableFlashlight = true;
}
//-----------------------------------------------------------------------------
// Purpose: Adds eflags.
//-----------------------------------------------------------------------------

View File

@ -762,6 +762,8 @@ public:
void InputRemoveEffects( inputdata_t &inputdata );
void InputDrawEntity( inputdata_t &inputdata );
void InputUndrawEntity( inputdata_t &inputdata );
void InputEnableReceivingFlashlight( inputdata_t &inputdata );
void InputDisableReceivingFlashlight( inputdata_t &inputdata );
void InputAddEFlags( inputdata_t &inputdata );
void InputRemoveEFlags( inputdata_t &inputdata );
void InputAddSolidFlags( inputdata_t &inputdata );
@ -928,6 +930,9 @@ public:
//
// This was partly inspired by Underhell's keyvalue that allows entities to only render in mirrors and cameras.
CNetworkVar( int, m_iViewHideFlags );
// Disables receiving projected textures. Based on a keyvalue from later Source games.
CNetworkVar( bool, m_bDisableFlashlight );
#endif
// was pev->rendercolor