mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-29 21:49:20 +00:00
upload "kind" alien swarm
This commit is contained in:
+170
-2
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Implements a screen shake effect that can also shake physics objects.
|
||||
//
|
||||
@@ -61,7 +61,8 @@ private:
|
||||
public:
|
||||
DECLARE_CLASS( CEnvShake, CPointEntity );
|
||||
|
||||
~CEnvShake( void );
|
||||
virtual ~CEnvShake( void );
|
||||
virtual void Precache( void );
|
||||
virtual void Spawn( void );
|
||||
virtual void OnRestore( void );
|
||||
|
||||
@@ -117,6 +118,7 @@ END_DATADESC()
|
||||
#define SF_SHAKE_ROPES 0x0010 // Shake ropes too.
|
||||
#define SF_SHAKE_NO_VIEW 0x0020 // DON'T shake the view (only ropes and/or physics objects)
|
||||
#define SF_SHAKE_NO_RUMBLE 0x0040 // DON'T Rumble the XBox Controller
|
||||
#define SF_TILT_EASE_INOUT 0x0080 // Ease in and out of the tilt
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -143,8 +145,15 @@ float CEnvShake::Radius(bool bPlayers)
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets default member values when spawning.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvShake::Precache()
|
||||
{
|
||||
BaseClass::Precache();
|
||||
CRopeKeyframe::PrecacheShakeRopes();
|
||||
}
|
||||
|
||||
void CEnvShake::Spawn( void )
|
||||
{
|
||||
Precache();
|
||||
SetSolid( SOLID_NONE );
|
||||
SetMoveType( MOVETYPE_NONE );
|
||||
|
||||
@@ -411,3 +420,162 @@ int CEnvShake::DrawDebugTextOverlays( void )
|
||||
static ConCommand shake("shake", CC_Shake, "Shake the screen.", FCVAR_CHEAT );
|
||||
|
||||
|
||||
// Tilt effect
|
||||
|
||||
class CEnvTilt : public CPointEntity
|
||||
{
|
||||
private:
|
||||
float m_Duration;
|
||||
float m_Radius; // radius of 0 means all players
|
||||
float m_TiltTime;
|
||||
float m_stopTime;
|
||||
|
||||
DECLARE_DATADESC();
|
||||
|
||||
public:
|
||||
DECLARE_CLASS( CEnvShake, CPointEntity );
|
||||
|
||||
virtual void Precache( void );
|
||||
virtual void Spawn( void );
|
||||
|
||||
QAngle TiltAngle( void );
|
||||
inline float Duration( void ) { return m_Duration; }
|
||||
float Radius( bool bPlayers = true );
|
||||
inline float TiltTime( void ) { return m_TiltTime; }
|
||||
inline void SetDuration( float duration ) { m_Duration = duration; }
|
||||
inline void SetRadius( float radius ) { m_Radius = radius; }
|
||||
|
||||
int DrawDebugTextOverlays(void);
|
||||
|
||||
// Input handlers
|
||||
void InputStartTilt( inputdata_t &inputdata );
|
||||
void InputStopTilt( inputdata_t &inputdata );
|
||||
|
||||
// Causes the camera/physics shakes to happen:
|
||||
void ApplyTilt( ShakeCommand_t command );
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( env_tilt, CEnvTilt );
|
||||
|
||||
BEGIN_DATADESC( CEnvTilt )
|
||||
|
||||
DEFINE_KEYFIELD( m_Duration, FIELD_FLOAT, "duration" ),
|
||||
DEFINE_KEYFIELD( m_Radius, FIELD_FLOAT, "radius" ),
|
||||
DEFINE_KEYFIELD( m_TiltTime, FIELD_TIME, "tilttime" ),
|
||||
DEFINE_FIELD( m_stopTime, FIELD_TIME ),
|
||||
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "StartTilt", InputStartTilt ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "StopTilt", InputStopTilt ),
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
|
||||
QAngle CEnvTilt::TiltAngle( void )
|
||||
{
|
||||
QAngle qTiltAngles = GetAbsAngles();
|
||||
qTiltAngles.y = 0.0f; // Tilting around the up axis makes no sense
|
||||
return qTiltAngles;
|
||||
}
|
||||
|
||||
|
||||
float CEnvTilt::Radius(bool bPlayers)
|
||||
{
|
||||
// The radius for players is zero if SF_SHAKE_EVERYONE is set
|
||||
if ( bPlayers && HasSpawnFlags(SF_SHAKE_EVERYONE))
|
||||
return 0;
|
||||
return m_Radius;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets default member values when spawning.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvTilt::Precache()
|
||||
{
|
||||
BaseClass::Precache();
|
||||
CRopeKeyframe::PrecacheShakeRopes();
|
||||
}
|
||||
|
||||
void CEnvTilt::Spawn( void )
|
||||
{
|
||||
Precache();
|
||||
SetSolid( SOLID_NONE );
|
||||
SetMoveType( MOVETYPE_NONE );
|
||||
|
||||
if ( GetSpawnFlags() & SF_SHAKE_EVERYONE )
|
||||
{
|
||||
m_Radius = 0;
|
||||
}
|
||||
|
||||
if ( HasSpawnFlags( SF_SHAKE_NO_VIEW ) && !HasSpawnFlags( SF_SHAKE_PHYSICS ) && !HasSpawnFlags( SF_SHAKE_ROPES ) )
|
||||
{
|
||||
DevWarning( "env_shake %s with \"Don't shake view\" spawnflag set without \"Shake physics\" or \"Shake ropes\" spawnflags set.", GetDebugName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvTilt::ApplyTilt( ShakeCommand_t command )
|
||||
{
|
||||
if ( !HasSpawnFlags( SF_SHAKE_NO_VIEW ) || !HasSpawnFlags( SF_SHAKE_NO_RUMBLE ) )
|
||||
{
|
||||
UTIL_ScreenTilt( GetAbsOrigin(), TiltAngle(), Duration(), Radius(), TiltTime(), command, (GetSpawnFlags() & SF_TILT_EASE_INOUT) != 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Input handler that starts the screen shake.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvTilt::InputStartTilt( inputdata_t &inputdata )
|
||||
{
|
||||
if ( HasSpawnFlags( SF_SHAKE_NO_RUMBLE ) )
|
||||
{
|
||||
ApplyTilt( SHAKE_START_NORUMBLE );
|
||||
}
|
||||
else if ( HasSpawnFlags( SF_SHAKE_NO_VIEW ) )
|
||||
{
|
||||
ApplyTilt( SHAKE_START_RUMBLEONLY );
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyTilt( SHAKE_START );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Input handler that stops the screen shake.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvTilt::InputStopTilt( inputdata_t &inputdata )
|
||||
{
|
||||
ApplyTilt( SHAKE_STOP );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw any debug text overlays
|
||||
// Returns current text offset from the top
|
||||
//-----------------------------------------------------------------------------
|
||||
int CEnvTilt::DrawDebugTextOverlays( void )
|
||||
{
|
||||
int text_offset = BaseClass::DrawDebugTextOverlays();
|
||||
|
||||
if (m_debugOverlays & OVERLAY_TEXT_BIT)
|
||||
{
|
||||
char tempstr[512];
|
||||
|
||||
// print duration
|
||||
Q_snprintf(tempstr,sizeof(tempstr)," duration: %f", m_Duration);
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
|
||||
// print radius
|
||||
Q_snprintf(tempstr,sizeof(tempstr)," radius: %f", m_Radius);
|
||||
EntityText(text_offset,tempstr,0);
|
||||
text_offset++;
|
||||
|
||||
}
|
||||
return text_offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user