Fix line endings. WHAMMY.
This commit is contained in:
@@ -1,58 +1,58 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Drops particles where the entity was.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "entityparticletrail_shared.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Default values
|
||||
//-----------------------------------------------------------------------------
|
||||
EntityParticleTrailInfo_t::EntityParticleTrailInfo_t()
|
||||
{
|
||||
m_strMaterialName = NULL_STRING;
|
||||
m_flLifetime = 4.0f;
|
||||
m_flStartSize = 2.0f;
|
||||
m_flEndSize = 3.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Save/load
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
BEGIN_SIMPLE_DATADESC( EntityParticleTrailInfo_t )
|
||||
|
||||
DEFINE_KEYFIELD( m_strMaterialName, FIELD_STRING, "ParticleTrailMaterial" ),
|
||||
DEFINE_KEYFIELD( m_flLifetime, FIELD_FLOAT, "ParticleTrailLifetime" ),
|
||||
DEFINE_KEYFIELD( m_flStartSize, FIELD_FLOAT, "ParticleTrailStartSize" ),
|
||||
DEFINE_KEYFIELD( m_flEndSize, FIELD_FLOAT, "ParticleTrailEndSize" ),
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Networking
|
||||
//-----------------------------------------------------------------------------
|
||||
BEGIN_NETWORK_TABLE_NOBASE( EntityParticleTrailInfo_t, DT_EntityParticleTrailInfo )
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
RecvPropFloat( RECVINFO( m_flLifetime ) ),
|
||||
RecvPropFloat( RECVINFO( m_flStartSize ) ),
|
||||
RecvPropFloat( RECVINFO( m_flEndSize ) ),
|
||||
#else
|
||||
SendPropFloat( SENDINFO( m_flLifetime ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO( m_flStartSize ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO( m_flEndSize ), 0, SPROP_NOSCALE ),
|
||||
#endif
|
||||
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Drops particles where the entity was.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "entityparticletrail_shared.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Default values
|
||||
//-----------------------------------------------------------------------------
|
||||
EntityParticleTrailInfo_t::EntityParticleTrailInfo_t()
|
||||
{
|
||||
m_strMaterialName = NULL_STRING;
|
||||
m_flLifetime = 4.0f;
|
||||
m_flStartSize = 2.0f;
|
||||
m_flEndSize = 3.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Save/load
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
BEGIN_SIMPLE_DATADESC( EntityParticleTrailInfo_t )
|
||||
|
||||
DEFINE_KEYFIELD( m_strMaterialName, FIELD_STRING, "ParticleTrailMaterial" ),
|
||||
DEFINE_KEYFIELD( m_flLifetime, FIELD_FLOAT, "ParticleTrailLifetime" ),
|
||||
DEFINE_KEYFIELD( m_flStartSize, FIELD_FLOAT, "ParticleTrailStartSize" ),
|
||||
DEFINE_KEYFIELD( m_flEndSize, FIELD_FLOAT, "ParticleTrailEndSize" ),
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Networking
|
||||
//-----------------------------------------------------------------------------
|
||||
BEGIN_NETWORK_TABLE_NOBASE( EntityParticleTrailInfo_t, DT_EntityParticleTrailInfo )
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
RecvPropFloat( RECVINFO( m_flLifetime ) ),
|
||||
RecvPropFloat( RECVINFO( m_flStartSize ) ),
|
||||
RecvPropFloat( RECVINFO( m_flEndSize ) ),
|
||||
#else
|
||||
SendPropFloat( SENDINFO( m_flLifetime ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO( m_flStartSize ), 0, SPROP_NOSCALE ),
|
||||
SendPropFloat( SENDINFO( m_flEndSize ), 0, SPROP_NOSCALE ),
|
||||
#endif
|
||||
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAME_EVENT_LISTENER_H
|
||||
#define GAME_EVENT_LISTENER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "igameevents.h"
|
||||
extern IGameEventManager2 *gameeventmanager;
|
||||
|
||||
// A safer method than inheriting straight from IGameEventListener2.
|
||||
// Avoids requiring the user to remove themselves as listeners in
|
||||
// their deconstructor, and sets the serverside variable based on
|
||||
// our dll location.
|
||||
class CGameEventListener : public IGameEventListener2
|
||||
{
|
||||
public:
|
||||
CGameEventListener() : m_bRegisteredForEvents(false)
|
||||
{
|
||||
}
|
||||
|
||||
~CGameEventListener()
|
||||
{
|
||||
StopListeningForAllEvents();
|
||||
}
|
||||
|
||||
void ListenForGameEvent( const char *name )
|
||||
{
|
||||
m_bRegisteredForEvents = true;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
bool bServerSide = false;
|
||||
#else
|
||||
bool bServerSide = true;
|
||||
#endif
|
||||
if ( gameeventmanager )
|
||||
gameeventmanager->AddListener( this, name, bServerSide );
|
||||
}
|
||||
|
||||
void StopListeningForAllEvents()
|
||||
{
|
||||
// remove me from list
|
||||
if ( m_bRegisteredForEvents )
|
||||
{
|
||||
if ( gameeventmanager )
|
||||
gameeventmanager->RemoveListener( this );
|
||||
m_bRegisteredForEvents = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Intentionally abstract
|
||||
virtual void FireGameEvent( IGameEvent *event ) = 0;
|
||||
|
||||
private:
|
||||
|
||||
// Have we registered for any events?
|
||||
bool m_bRegisteredForEvents;
|
||||
};
|
||||
|
||||
#endif
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAME_EVENT_LISTENER_H
|
||||
#define GAME_EVENT_LISTENER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "igameevents.h"
|
||||
extern IGameEventManager2 *gameeventmanager;
|
||||
|
||||
// A safer method than inheriting straight from IGameEventListener2.
|
||||
// Avoids requiring the user to remove themselves as listeners in
|
||||
// their deconstructor, and sets the serverside variable based on
|
||||
// our dll location.
|
||||
class CGameEventListener : public IGameEventListener2
|
||||
{
|
||||
public:
|
||||
CGameEventListener() : m_bRegisteredForEvents(false)
|
||||
{
|
||||
}
|
||||
|
||||
~CGameEventListener()
|
||||
{
|
||||
StopListeningForAllEvents();
|
||||
}
|
||||
|
||||
void ListenForGameEvent( const char *name )
|
||||
{
|
||||
m_bRegisteredForEvents = true;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
bool bServerSide = false;
|
||||
#else
|
||||
bool bServerSide = true;
|
||||
#endif
|
||||
if ( gameeventmanager )
|
||||
gameeventmanager->AddListener( this, name, bServerSide );
|
||||
}
|
||||
|
||||
void StopListeningForAllEvents()
|
||||
{
|
||||
// remove me from list
|
||||
if ( m_bRegisteredForEvents )
|
||||
{
|
||||
if ( gameeventmanager )
|
||||
gameeventmanager->RemoveListener( this );
|
||||
m_bRegisteredForEvents = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Intentionally abstract
|
||||
virtual void FireGameEvent( IGameEvent *event ) = 0;
|
||||
|
||||
private:
|
||||
|
||||
// Have we registered for any events?
|
||||
bool m_bRegisteredForEvents;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+1524
-1524
File diff suppressed because it is too large
Load Diff
@@ -1,82 +1,82 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client-server neutral effects interface
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IEFFECTS_H
|
||||
#define IEFFECTS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basetypes.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include "interface.h"
|
||||
#include "ipredictionsystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShakeCommand_t;
|
||||
class Vector;
|
||||
class CGameTrace;
|
||||
typedef CGameTrace trace_t;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client-server neutral effects interface
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IEFFECTS_INTERFACE_VERSION "IEffects001"
|
||||
abstract_class IEffects : public IPredictionSystem
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Particle effects
|
||||
//
|
||||
virtual void Beam( const Vector &Start, const Vector &End, int nModelIndex,
|
||||
int nHaloIndex, unsigned char frameStart, unsigned char frameRate,
|
||||
float flLife, unsigned char width, unsigned char endWidth, unsigned char fadeLength,
|
||||
unsigned char noise, unsigned char red, unsigned char green,
|
||||
unsigned char blue, unsigned char brightness, unsigned char speed) = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Emits smoke sprites.
|
||||
// Input : origin - Where to emit the sprites.
|
||||
// scale - Sprite scale * 10.
|
||||
// framerate - Framerate at which to animate the smoke sprites.
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual void Smoke( const Vector &origin, int modelIndex, float scale, float framerate ) = 0;
|
||||
|
||||
virtual void Sparks( const Vector &position, int nMagnitude = 1, int nTrailLength = 1, const Vector *pvecDir = NULL ) = 0;
|
||||
|
||||
virtual void Dust( const Vector &pos, const Vector &dir, float size, float speed ) = 0;
|
||||
|
||||
virtual void MuzzleFlash( const Vector &vecOrigin, const QAngle &vecAngles, float flScale, int iType ) = 0;
|
||||
|
||||
// like ricochet, but no sound
|
||||
virtual void MetalSparks( const Vector &position, const Vector &direction ) = 0;
|
||||
|
||||
virtual void EnergySplash( const Vector &position, const Vector &direction, bool bExplosive = false ) = 0;
|
||||
|
||||
virtual void Ricochet( const Vector &position, const Vector &direction ) = 0;
|
||||
|
||||
// FIXME: Should these methods remain in this interface? Or go in some
|
||||
// other client-server neutral interface?
|
||||
virtual float Time() = 0;
|
||||
virtual bool IsServer() = 0;
|
||||
|
||||
// Used by the playback system to suppress sounds
|
||||
virtual void SuppressEffectsSounds( bool bSuppress ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client-server neutral effects interface accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
extern IEffects *g_pEffects;
|
||||
|
||||
|
||||
#endif // IEFFECTS_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client-server neutral effects interface
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IEFFECTS_H
|
||||
#define IEFFECTS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basetypes.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include "interface.h"
|
||||
#include "ipredictionsystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShakeCommand_t;
|
||||
class Vector;
|
||||
class CGameTrace;
|
||||
typedef CGameTrace trace_t;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client-server neutral effects interface
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IEFFECTS_INTERFACE_VERSION "IEffects001"
|
||||
abstract_class IEffects : public IPredictionSystem
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Particle effects
|
||||
//
|
||||
virtual void Beam( const Vector &Start, const Vector &End, int nModelIndex,
|
||||
int nHaloIndex, unsigned char frameStart, unsigned char frameRate,
|
||||
float flLife, unsigned char width, unsigned char endWidth, unsigned char fadeLength,
|
||||
unsigned char noise, unsigned char red, unsigned char green,
|
||||
unsigned char blue, unsigned char brightness, unsigned char speed) = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Emits smoke sprites.
|
||||
// Input : origin - Where to emit the sprites.
|
||||
// scale - Sprite scale * 10.
|
||||
// framerate - Framerate at which to animate the smoke sprites.
|
||||
//-----------------------------------------------------------------------------
|
||||
virtual void Smoke( const Vector &origin, int modelIndex, float scale, float framerate ) = 0;
|
||||
|
||||
virtual void Sparks( const Vector &position, int nMagnitude = 1, int nTrailLength = 1, const Vector *pvecDir = NULL ) = 0;
|
||||
|
||||
virtual void Dust( const Vector &pos, const Vector &dir, float size, float speed ) = 0;
|
||||
|
||||
virtual void MuzzleFlash( const Vector &vecOrigin, const QAngle &vecAngles, float flScale, int iType ) = 0;
|
||||
|
||||
// like ricochet, but no sound
|
||||
virtual void MetalSparks( const Vector &position, const Vector &direction ) = 0;
|
||||
|
||||
virtual void EnergySplash( const Vector &position, const Vector &direction, bool bExplosive = false ) = 0;
|
||||
|
||||
virtual void Ricochet( const Vector &position, const Vector &direction ) = 0;
|
||||
|
||||
// FIXME: Should these methods remain in this interface? Or go in some
|
||||
// other client-server neutral interface?
|
||||
virtual float Time() = 0;
|
||||
virtual bool IsServer() = 0;
|
||||
|
||||
// Used by the playback system to suppress sounds
|
||||
virtual void SuppressEffectsSounds( bool bSuppress ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Client-server neutral effects interface accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
extern IEffects *g_pEffects;
|
||||
|
||||
|
||||
#endif // IEFFECTS_H
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IVEHICLE_H
|
||||
#define IVEHICLE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "baseplayer_shared.h"
|
||||
|
||||
class CUserCmd;
|
||||
class IMoveHelper;
|
||||
class CMoveData;
|
||||
class CBaseCombatCharacter;
|
||||
|
||||
// This is used by the player to access vehicles. It's an interface so the
|
||||
// vehicles are not restricted in what they can derive from.
|
||||
abstract_class IVehicle
|
||||
{
|
||||
public:
|
||||
// Get and set the current driver. Use PassengerRole_t enum in shareddefs.h for adding passengers
|
||||
virtual CBaseCombatCharacter* GetPassenger( int nRole = VEHICLE_ROLE_DRIVER ) = 0;
|
||||
virtual int GetPassengerRole( CBaseCombatCharacter *pPassenger ) = 0;
|
||||
|
||||
// Where is the passenger seeing from?
|
||||
virtual void GetVehicleViewPosition( int nRole, Vector *pOrigin, QAngle *pAngles, float *pFOV = NULL ) = 0;
|
||||
|
||||
// Does the player use his normal weapons while in this mode?
|
||||
virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) = 0;
|
||||
|
||||
// Process movement
|
||||
virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move ) = 0;
|
||||
virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData ) = 0;
|
||||
virtual void FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move ) = 0;
|
||||
|
||||
// Process input
|
||||
virtual void ItemPostFrame( CBasePlayer *pPlayer ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // IVEHICLE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef IVEHICLE_H
|
||||
#define IVEHICLE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "baseplayer_shared.h"
|
||||
|
||||
class CUserCmd;
|
||||
class IMoveHelper;
|
||||
class CMoveData;
|
||||
class CBaseCombatCharacter;
|
||||
|
||||
// This is used by the player to access vehicles. It's an interface so the
|
||||
// vehicles are not restricted in what they can derive from.
|
||||
abstract_class IVehicle
|
||||
{
|
||||
public:
|
||||
// Get and set the current driver. Use PassengerRole_t enum in shareddefs.h for adding passengers
|
||||
virtual CBaseCombatCharacter* GetPassenger( int nRole = VEHICLE_ROLE_DRIVER ) = 0;
|
||||
virtual int GetPassengerRole( CBaseCombatCharacter *pPassenger ) = 0;
|
||||
|
||||
// Where is the passenger seeing from?
|
||||
virtual void GetVehicleViewPosition( int nRole, Vector *pOrigin, QAngle *pAngles, float *pFOV = NULL ) = 0;
|
||||
|
||||
// Does the player use his normal weapons while in this mode?
|
||||
virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) = 0;
|
||||
|
||||
// Process movement
|
||||
virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move ) = 0;
|
||||
virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData ) = 0;
|
||||
virtual void FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move ) = 0;
|
||||
|
||||
// Process input
|
||||
virtual void ItemPostFrame( CBasePlayer *pPlayer ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // IVEHICLE_H
|
||||
|
||||
@@ -1,217 +1,217 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "ModelSoundsCache.h"
|
||||
#include "studio.h"
|
||||
#include "eventlist.h"
|
||||
#include "scriptevent.h"
|
||||
|
||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||
|
||||
CStudioHdr *ModelSoundsCache_LoadModel( char const *filename );
|
||||
void ModelSoundsCache_PrecacheScriptSound( const char *soundname );
|
||||
void ModelSoundsCache_FinishModel( CStudioHdr *hdr );
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *hdr -
|
||||
// Output : static void
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VerifySequenceIndex( CStudioHdr *pstudiohdr );
|
||||
|
||||
// HACK: This must match the #define in cl_animevent.h in the client .dll code!!!
|
||||
#define CL_EVENT_SOUND 5004
|
||||
#define CL_EVENT_FOOTSTEP_LEFT 6004
|
||||
#define CL_EVENT_FOOTSTEP_RIGHT 6005
|
||||
#define CL_EVENT_MFOOTSTEP_LEFT 6006
|
||||
#define CL_EVENT_MFOOTSTEP_RIGHT 6007
|
||||
|
||||
|
||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||
|
||||
CModelSoundsCache::CModelSoundsCache()
|
||||
{
|
||||
}
|
||||
|
||||
CModelSoundsCache::CModelSoundsCache( const CModelSoundsCache& src )
|
||||
{
|
||||
sounds = src.sounds;
|
||||
}
|
||||
|
||||
char const *CModelSoundsCache::GetSoundName( int index )
|
||||
{
|
||||
return soundemitterbase->GetSoundName( sounds[ index ] );
|
||||
}
|
||||
|
||||
void CModelSoundsCache::Save( CUtlBuffer& buf )
|
||||
{
|
||||
buf.PutShort( sounds.Count() );
|
||||
|
||||
for ( int i = 0; i < sounds.Count(); ++i )
|
||||
{
|
||||
buf.PutString( GetSoundName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSoundsCache::Restore( CUtlBuffer& buf )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
unsigned short c;
|
||||
|
||||
c = (unsigned short)buf.GetShort();
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
char soundname[ 512 ];
|
||||
|
||||
buf.GetString( soundname, sizeof( soundname ) );
|
||||
|
||||
int idx = soundemitterbase->GetSoundIndex( soundname );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
Assert( idx <= 65535 );
|
||||
if ( sounds.Find( idx ) == sounds.InvalidIndex() )
|
||||
{
|
||||
sounds.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSoundsCache::Rebuild( char const *filename )
|
||||
{
|
||||
sounds.RemoveAll();
|
||||
|
||||
CStudioHdr *hdr = ModelSoundsCache_LoadModel( filename );
|
||||
|
||||
if ( hdr )
|
||||
{
|
||||
// Precache all sounds referenced in animation events
|
||||
BuildAnimationEventSoundList( hdr, sounds );
|
||||
ModelSoundsCache_FinishModel( hdr );
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSoundsCache::PrecacheSoundList()
|
||||
{
|
||||
for ( int i = 0; i < sounds.Count(); ++i )
|
||||
{
|
||||
ModelSoundsCache_PrecacheScriptSound( GetSoundName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Static method
|
||||
// Input : sounds -
|
||||
// *soundname -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModelSoundsCache::FindOrAddScriptSound( CUtlVector< unsigned short >& sounds, char const *soundname )
|
||||
{
|
||||
int soundindex = soundemitterbase->GetSoundIndex( soundname );
|
||||
if ( soundindex != -1 )
|
||||
{
|
||||
// Only add it once per model...
|
||||
if ( sounds.Find( soundindex ) == sounds.InvalidIndex() )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
sounds.AddToTail( soundindex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Static method
|
||||
// Input : *hdr -
|
||||
// sounds -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModelSoundsCache::BuildAnimationEventSoundList( CStudioHdr *hdr, CUtlVector< unsigned short >& sounds )
|
||||
{
|
||||
Assert( hdr );
|
||||
|
||||
// force animation event resolution!!!
|
||||
VerifySequenceIndex( hdr );
|
||||
|
||||
// Find all animation events which fire off sound script entries...
|
||||
for ( int iSeq=0; iSeq < hdr->GetNumSeq(); iSeq++ )
|
||||
{
|
||||
mstudioseqdesc_t *pSeq = &hdr->pSeqdesc( iSeq );
|
||||
|
||||
// Now read out all the sound events with their timing
|
||||
for ( int iEvent=0; iEvent < (int)pSeq->numevents; iEvent++ )
|
||||
{
|
||||
mstudioevent_t *pEvent = pSeq->pEvent( iEvent );
|
||||
|
||||
switch ( pEvent->event )
|
||||
{
|
||||
default:
|
||||
{
|
||||
if ( pEvent->type & AE_TYPE_NEWEVENTSYSTEM )
|
||||
{
|
||||
if ( pEvent->event == AE_SV_PLAYSOUND )
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Old-style client .dll animation event
|
||||
case CL_EVENT_SOUND:
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
break;
|
||||
case CL_EVENT_FOOTSTEP_LEFT:
|
||||
case CL_EVENT_FOOTSTEP_RIGHT:
|
||||
{
|
||||
char soundname[256];
|
||||
char const *options = pEvent->pszOptions();
|
||||
if ( !options || !options[0] )
|
||||
{
|
||||
options = "NPC_CombineS";
|
||||
}
|
||||
|
||||
Q_snprintf( soundname, 256, "%s.RunFootstepLeft", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
Q_snprintf( soundname, 256, "%s.RunFootstepRight", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
Q_snprintf( soundname, 256, "%s.FootstepLeft", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
Q_snprintf( soundname, 256, "%s.FootstepRight", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
}
|
||||
break;
|
||||
case AE_CL_PLAYSOUND:
|
||||
{
|
||||
if ( !( pEvent->type & AE_TYPE_CLIENT ) )
|
||||
break;
|
||||
|
||||
if ( pEvent->pszOptions()[0] )
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "-- Error --: empty soundname, .qc error on AE_CL_PLAYSOUND in model %s, sequence %s, animevent # %i\n",
|
||||
hdr->pszName(), pSeq->pszLabel(), iEvent+1 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SCRIPT_EVENT_SOUND:
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
break;
|
||||
|
||||
case SCRIPT_EVENT_SOUND_VOICE:
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "ModelSoundsCache.h"
|
||||
#include "studio.h"
|
||||
#include "eventlist.h"
|
||||
#include "scriptevent.h"
|
||||
|
||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||
|
||||
CStudioHdr *ModelSoundsCache_LoadModel( char const *filename );
|
||||
void ModelSoundsCache_PrecacheScriptSound( const char *soundname );
|
||||
void ModelSoundsCache_FinishModel( CStudioHdr *hdr );
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *hdr -
|
||||
// Output : static void
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VerifySequenceIndex( CStudioHdr *pstudiohdr );
|
||||
|
||||
// HACK: This must match the #define in cl_animevent.h in the client .dll code!!!
|
||||
#define CL_EVENT_SOUND 5004
|
||||
#define CL_EVENT_FOOTSTEP_LEFT 6004
|
||||
#define CL_EVENT_FOOTSTEP_RIGHT 6005
|
||||
#define CL_EVENT_MFOOTSTEP_LEFT 6006
|
||||
#define CL_EVENT_MFOOTSTEP_RIGHT 6007
|
||||
|
||||
|
||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||
|
||||
CModelSoundsCache::CModelSoundsCache()
|
||||
{
|
||||
}
|
||||
|
||||
CModelSoundsCache::CModelSoundsCache( const CModelSoundsCache& src )
|
||||
{
|
||||
sounds = src.sounds;
|
||||
}
|
||||
|
||||
char const *CModelSoundsCache::GetSoundName( int index )
|
||||
{
|
||||
return soundemitterbase->GetSoundName( sounds[ index ] );
|
||||
}
|
||||
|
||||
void CModelSoundsCache::Save( CUtlBuffer& buf )
|
||||
{
|
||||
buf.PutShort( sounds.Count() );
|
||||
|
||||
for ( int i = 0; i < sounds.Count(); ++i )
|
||||
{
|
||||
buf.PutString( GetSoundName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSoundsCache::Restore( CUtlBuffer& buf )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
unsigned short c;
|
||||
|
||||
c = (unsigned short)buf.GetShort();
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
char soundname[ 512 ];
|
||||
|
||||
buf.GetString( soundname, sizeof( soundname ) );
|
||||
|
||||
int idx = soundemitterbase->GetSoundIndex( soundname );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
Assert( idx <= 65535 );
|
||||
if ( sounds.Find( idx ) == sounds.InvalidIndex() )
|
||||
{
|
||||
sounds.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSoundsCache::Rebuild( char const *filename )
|
||||
{
|
||||
sounds.RemoveAll();
|
||||
|
||||
CStudioHdr *hdr = ModelSoundsCache_LoadModel( filename );
|
||||
|
||||
if ( hdr )
|
||||
{
|
||||
// Precache all sounds referenced in animation events
|
||||
BuildAnimationEventSoundList( hdr, sounds );
|
||||
ModelSoundsCache_FinishModel( hdr );
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSoundsCache::PrecacheSoundList()
|
||||
{
|
||||
for ( int i = 0; i < sounds.Count(); ++i )
|
||||
{
|
||||
ModelSoundsCache_PrecacheScriptSound( GetSoundName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Static method
|
||||
// Input : sounds -
|
||||
// *soundname -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModelSoundsCache::FindOrAddScriptSound( CUtlVector< unsigned short >& sounds, char const *soundname )
|
||||
{
|
||||
int soundindex = soundemitterbase->GetSoundIndex( soundname );
|
||||
if ( soundindex != -1 )
|
||||
{
|
||||
// Only add it once per model...
|
||||
if ( sounds.Find( soundindex ) == sounds.InvalidIndex() )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
sounds.AddToTail( soundindex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Static method
|
||||
// Input : *hdr -
|
||||
// sounds -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModelSoundsCache::BuildAnimationEventSoundList( CStudioHdr *hdr, CUtlVector< unsigned short >& sounds )
|
||||
{
|
||||
Assert( hdr );
|
||||
|
||||
// force animation event resolution!!!
|
||||
VerifySequenceIndex( hdr );
|
||||
|
||||
// Find all animation events which fire off sound script entries...
|
||||
for ( int iSeq=0; iSeq < hdr->GetNumSeq(); iSeq++ )
|
||||
{
|
||||
mstudioseqdesc_t *pSeq = &hdr->pSeqdesc( iSeq );
|
||||
|
||||
// Now read out all the sound events with their timing
|
||||
for ( int iEvent=0; iEvent < (int)pSeq->numevents; iEvent++ )
|
||||
{
|
||||
mstudioevent_t *pEvent = pSeq->pEvent( iEvent );
|
||||
|
||||
switch ( pEvent->event )
|
||||
{
|
||||
default:
|
||||
{
|
||||
if ( pEvent->type & AE_TYPE_NEWEVENTSYSTEM )
|
||||
{
|
||||
if ( pEvent->event == AE_SV_PLAYSOUND )
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Old-style client .dll animation event
|
||||
case CL_EVENT_SOUND:
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
break;
|
||||
case CL_EVENT_FOOTSTEP_LEFT:
|
||||
case CL_EVENT_FOOTSTEP_RIGHT:
|
||||
{
|
||||
char soundname[256];
|
||||
char const *options = pEvent->pszOptions();
|
||||
if ( !options || !options[0] )
|
||||
{
|
||||
options = "NPC_CombineS";
|
||||
}
|
||||
|
||||
Q_snprintf( soundname, 256, "%s.RunFootstepLeft", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
Q_snprintf( soundname, 256, "%s.RunFootstepRight", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
Q_snprintf( soundname, 256, "%s.FootstepLeft", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
Q_snprintf( soundname, 256, "%s.FootstepRight", options );
|
||||
FindOrAddScriptSound( sounds, soundname );
|
||||
}
|
||||
break;
|
||||
case AE_CL_PLAYSOUND:
|
||||
{
|
||||
if ( !( pEvent->type & AE_TYPE_CLIENT ) )
|
||||
break;
|
||||
|
||||
if ( pEvent->pszOptions()[0] )
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "-- Error --: empty soundname, .qc error on AE_CL_PLAYSOUND in model %s, sequence %s, animevent # %i\n",
|
||||
hdr->pszName(), pSeq->pszLabel(), iEvent+1 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SCRIPT_EVENT_SOUND:
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
break;
|
||||
|
||||
case SCRIPT_EVENT_SOUND_VOICE:
|
||||
{
|
||||
FindOrAddScriptSound( sounds, pEvent->pszOptions() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,42 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef MODELSOUNDSCACHE_H
|
||||
#define MODELSOUNDSCACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "UtlCachedFileData.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
|
||||
#define MODELSOUNDSCACHE_VERSION 5
|
||||
|
||||
class CStudioHdr;
|
||||
|
||||
#pragma pack(1)
|
||||
class CModelSoundsCache : public IBaseCacheInfo
|
||||
{
|
||||
public:
|
||||
CUtlVector< unsigned short > sounds;
|
||||
|
||||
CModelSoundsCache();
|
||||
CModelSoundsCache( const CModelSoundsCache& src );
|
||||
|
||||
void PrecacheSoundList();
|
||||
|
||||
virtual void Save( CUtlBuffer& buf );
|
||||
virtual void Restore( CUtlBuffer& buf );
|
||||
virtual void Rebuild( char const *filename );
|
||||
|
||||
static void FindOrAddScriptSound( CUtlVector< unsigned short >& sounds, char const *soundname );
|
||||
static void BuildAnimationEventSoundList( CStudioHdr *hdr, CUtlVector< unsigned short >& sounds );
|
||||
private:
|
||||
char const *GetSoundName( int index );
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#endif // MODELSOUNDSCACHE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef MODELSOUNDSCACHE_H
|
||||
#define MODELSOUNDSCACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "UtlCachedFileData.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
|
||||
#define MODELSOUNDSCACHE_VERSION 5
|
||||
|
||||
class CStudioHdr;
|
||||
|
||||
#pragma pack(1)
|
||||
class CModelSoundsCache : public IBaseCacheInfo
|
||||
{
|
||||
public:
|
||||
CUtlVector< unsigned short > sounds;
|
||||
|
||||
CModelSoundsCache();
|
||||
CModelSoundsCache( const CModelSoundsCache& src );
|
||||
|
||||
void PrecacheSoundList();
|
||||
|
||||
virtual void Save( CUtlBuffer& buf );
|
||||
virtual void Restore( CUtlBuffer& buf );
|
||||
virtual void Rebuild( char const *filename );
|
||||
|
||||
static void FindOrAddScriptSound( CUtlVector< unsigned short >& sounds, char const *soundname );
|
||||
static void BuildAnimationEventSoundList( CStudioHdr *hdr, CUtlVector< unsigned short >& sounds );
|
||||
private:
|
||||
char const *GetSoundName( int index );
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#endif // MODELSOUNDSCACHE_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,342 +1,342 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef MULTIPLAYERANIMSTATE_H
|
||||
#define MULTIPLAYERANIMSTATE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "convar.h"
|
||||
#include "basecombatweapon_shared.h"
|
||||
#include "iplayeranimstate.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
class C_BasePlayer;
|
||||
#define CPlayer C_BasePlayer
|
||||
#else
|
||||
class CBasePlayer;
|
||||
#endif
|
||||
|
||||
enum PlayerAnimEvent_t
|
||||
{
|
||||
PLAYERANIMEVENT_ATTACK_PRIMARY,
|
||||
PLAYERANIMEVENT_ATTACK_SECONDARY,
|
||||
PLAYERANIMEVENT_ATTACK_GRENADE,
|
||||
PLAYERANIMEVENT_RELOAD,
|
||||
PLAYERANIMEVENT_RELOAD_LOOP,
|
||||
PLAYERANIMEVENT_RELOAD_END,
|
||||
PLAYERANIMEVENT_JUMP,
|
||||
PLAYERANIMEVENT_SWIM,
|
||||
PLAYERANIMEVENT_DIE,
|
||||
PLAYERANIMEVENT_FLINCH_CHEST,
|
||||
PLAYERANIMEVENT_FLINCH_HEAD,
|
||||
PLAYERANIMEVENT_FLINCH_LEFTARM,
|
||||
PLAYERANIMEVENT_FLINCH_RIGHTARM,
|
||||
PLAYERANIMEVENT_FLINCH_LEFTLEG,
|
||||
PLAYERANIMEVENT_FLINCH_RIGHTLEG,
|
||||
PLAYERANIMEVENT_DOUBLEJUMP,
|
||||
|
||||
// Cancel.
|
||||
PLAYERANIMEVENT_CANCEL,
|
||||
PLAYERANIMEVENT_SPAWN,
|
||||
|
||||
// Snap to current yaw exactly
|
||||
PLAYERANIMEVENT_SNAP_YAW,
|
||||
|
||||
PLAYERANIMEVENT_CUSTOM, // Used to play specific activities
|
||||
PLAYERANIMEVENT_CUSTOM_GESTURE,
|
||||
PLAYERANIMEVENT_CUSTOM_SEQUENCE, // Used to play specific sequences
|
||||
PLAYERANIMEVENT_CUSTOM_GESTURE_SEQUENCE,
|
||||
|
||||
// TF Specific. Here until there's a derived game solution to this.
|
||||
PLAYERANIMEVENT_ATTACK_PRE,
|
||||
PLAYERANIMEVENT_ATTACK_POST,
|
||||
PLAYERANIMEVENT_GRENADE1_DRAW,
|
||||
PLAYERANIMEVENT_GRENADE2_DRAW,
|
||||
PLAYERANIMEVENT_GRENADE1_THROW,
|
||||
PLAYERANIMEVENT_GRENADE2_THROW,
|
||||
PLAYERANIMEVENT_VOICE_COMMAND_GESTURE,
|
||||
PLAYERANIMEVENT_DOUBLEJUMP_CROUCH,
|
||||
PLAYERANIMEVENT_STUN_BEGIN,
|
||||
PLAYERANIMEVENT_STUN_MIDDLE,
|
||||
PLAYERANIMEVENT_STUN_END,
|
||||
|
||||
PLAYERANIMEVENT_ATTACK_PRIMARY_SUPER,
|
||||
|
||||
PLAYERANIMEVENT_COUNT
|
||||
};
|
||||
|
||||
// Gesture Slots.
|
||||
enum
|
||||
{
|
||||
GESTURE_SLOT_ATTACK_AND_RELOAD,
|
||||
GESTURE_SLOT_GRENADE,
|
||||
GESTURE_SLOT_JUMP,
|
||||
GESTURE_SLOT_SWIM,
|
||||
GESTURE_SLOT_FLINCH,
|
||||
GESTURE_SLOT_VCD,
|
||||
GESTURE_SLOT_CUSTOM,
|
||||
|
||||
GESTURE_SLOT_COUNT,
|
||||
};
|
||||
|
||||
#define GESTURE_SLOT_INVALID -1
|
||||
|
||||
struct GestureSlot_t
|
||||
{
|
||||
int m_iGestureSlot;
|
||||
Activity m_iActivity;
|
||||
bool m_bAutoKill;
|
||||
bool m_bActive;
|
||||
CAnimationLayer *m_pAnimLayer;
|
||||
};
|
||||
|
||||
inline bool IsCustomPlayerAnimEvent( PlayerAnimEvent_t event )
|
||||
{
|
||||
return ( event == PLAYERANIMEVENT_CUSTOM ) || ( event == PLAYERANIMEVENT_CUSTOM_GESTURE ) ||
|
||||
( event == PLAYERANIMEVENT_CUSTOM_SEQUENCE ) || ( event == PLAYERANIMEVENT_CUSTOM_GESTURE_SEQUENCE );
|
||||
}
|
||||
|
||||
struct MultiPlayerPoseData_t
|
||||
{
|
||||
int m_iMoveX;
|
||||
int m_iMoveY;
|
||||
int m_iAimYaw;
|
||||
int m_iAimPitch;
|
||||
int m_iBodyHeight;
|
||||
int m_iMoveYaw;
|
||||
int m_iMoveScale;
|
||||
|
||||
float m_flEstimateYaw;
|
||||
float m_flLastAimTurnTime;
|
||||
|
||||
void Init()
|
||||
{
|
||||
m_iMoveX = 0;
|
||||
m_iMoveY = 0;
|
||||
m_iAimYaw = 0;
|
||||
m_iAimPitch = 0;
|
||||
m_iBodyHeight = 0;
|
||||
m_iMoveYaw = 0;
|
||||
m_iMoveScale = 0;
|
||||
m_flEstimateYaw = 0.0f;
|
||||
m_flLastAimTurnTime = 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
struct DebugPlayerAnimData_t
|
||||
{
|
||||
float m_flSpeed;
|
||||
float m_flAimPitch;
|
||||
float m_flAimYaw;
|
||||
float m_flBodyHeight;
|
||||
Vector2D m_vecMoveYaw;
|
||||
|
||||
void Init()
|
||||
{
|
||||
m_flSpeed = 0.0f;
|
||||
m_flAimPitch = 0.0f;
|
||||
m_flAimYaw = 0.0f;
|
||||
m_flBodyHeight = 0.0f;
|
||||
m_vecMoveYaw.Init();
|
||||
}
|
||||
};
|
||||
|
||||
struct MultiPlayerMovementData_t
|
||||
{
|
||||
// Set speeds to -1 if they are not used.
|
||||
float m_flWalkSpeed;
|
||||
float m_flRunSpeed;
|
||||
float m_flSprintSpeed;
|
||||
float m_flBodyYawRate;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Multi-Player Animation State
|
||||
//
|
||||
class CMultiPlayerAnimState
|
||||
{
|
||||
public:
|
||||
|
||||
DECLARE_CLASS_NOBASE( CMultiPlayerAnimState );
|
||||
|
||||
// Creation/Destruction
|
||||
CMultiPlayerAnimState() {}
|
||||
CMultiPlayerAnimState( CBasePlayer *pPlayer, MultiPlayerMovementData_t &movementData );
|
||||
virtual ~CMultiPlayerAnimState();
|
||||
|
||||
// This is called by both the client and the server in the same way to trigger events for
|
||||
// players firing, jumping, throwing grenades, etc.
|
||||
virtual void ClearAnimationState();
|
||||
virtual void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
|
||||
virtual Activity CalcMainActivity();
|
||||
virtual void Update( float eyeYaw, float eyePitch );
|
||||
virtual void Release( void );
|
||||
|
||||
const QAngle &GetRenderAngles();
|
||||
|
||||
virtual Activity TranslateActivity( Activity actDesired );
|
||||
|
||||
virtual void SetRunSpeed( float flSpeed ) { m_MovementData.m_flRunSpeed = flSpeed; }
|
||||
virtual void SetWalkSpeed( float flSpeed ) { m_MovementData.m_flWalkSpeed = flSpeed; }
|
||||
virtual void SetSprintSpeed( float flSpeed ) { m_MovementData.m_flSprintSpeed = flSpeed; }
|
||||
|
||||
// Debug
|
||||
virtual void ShowDebugInfo( void );
|
||||
virtual void DebugShowAnimState( int iStartLine );
|
||||
|
||||
Activity GetCurrentMainActivity( void ) { return m_eCurrentMainSequenceActivity; }
|
||||
|
||||
void OnNewModel( void );
|
||||
|
||||
// Gestures.
|
||||
void ResetGestureSlots( void );
|
||||
void ResetGestureSlot( int iGestureSlot );
|
||||
void AddVCDSequenceToGestureSlot( int iGestureSlot, int iGestureSequence, float flCycle = 0.0f, bool bAutoKill = true );
|
||||
CAnimationLayer* GetGestureSlotLayer( int iGestureSlot );
|
||||
bool IsGestureSlotActive( int iGestureSlot );
|
||||
|
||||
// Feet.
|
||||
bool m_bForceAimYaw;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void Init( CBasePlayer *pPlayer, MultiPlayerMovementData_t &movementData );
|
||||
CBasePlayer *GetBasePlayer( void ) { return m_pPlayer; }
|
||||
|
||||
// Allow inheriting classes to override SelectWeightedSequence
|
||||
virtual int SelectWeightedSequence( Activity activity ) { return GetBasePlayer()->SelectWeightedSequence( activity ); }
|
||||
virtual void RestartMainSequence();
|
||||
|
||||
virtual void GetOuterAbsVelocity( Vector& vel );
|
||||
float GetOuterXYSpeed();
|
||||
|
||||
virtual bool HandleJumping( Activity &idealActivity );
|
||||
virtual bool HandleDucking( Activity &idealActivity );
|
||||
virtual bool HandleMoving( Activity &idealActivity );
|
||||
virtual bool HandleSwimming( Activity &idealActivity );
|
||||
virtual bool HandleDying( Activity &idealActivity );
|
||||
|
||||
// Gesture Slots
|
||||
CUtlVector<GestureSlot_t> m_aGestureSlots;
|
||||
bool InitGestureSlots( void );
|
||||
void ShutdownGestureSlots( void );
|
||||
bool IsGestureSlotPlaying( int iGestureSlot, Activity iGestureActivity );
|
||||
void AddToGestureSlot( int iGestureSlot, Activity iGestureActivity, bool bAutoKill );
|
||||
virtual void RestartGesture( int iGestureSlot, Activity iGestureActivity, bool bAutoKill = true );
|
||||
void ComputeGestureSequence( CStudioHdr *pStudioHdr );
|
||||
void UpdateGestureLayer( CStudioHdr *pStudioHdr, GestureSlot_t *pGesture );
|
||||
void DebugGestureInfo( void );
|
||||
virtual float GetGesturePlaybackRate( void ) { return 1.0f; }
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void RunGestureSlotAnimEventsToCompletion( GestureSlot_t *pGesture );
|
||||
#endif
|
||||
|
||||
virtual void PlayFlinchGesture( Activity iActivity );
|
||||
|
||||
virtual float CalcMovementSpeed( bool *bIsMoving );
|
||||
virtual float CalcMovementPlaybackRate( bool *bIsMoving );
|
||||
|
||||
void DoMovementTest( CStudioHdr *pStudioHdr, float flX, float flY );
|
||||
void DoMovementTest( CStudioHdr *pStudioHdr );
|
||||
void GetMovementFlags( CStudioHdr *pStudioHdr );
|
||||
|
||||
// Pose parameters.
|
||||
bool SetupPoseParameters( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_AimPitch( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_AimYaw( CStudioHdr *pStudioHdr );
|
||||
void ComputePoseParam_BodyHeight( CStudioHdr *pStudioHdr );
|
||||
virtual void EstimateYaw( void );
|
||||
void ConvergeYawAngles( float flGoalYaw, float flYawRate, float flDeltaTime, float &flCurrentYaw );
|
||||
|
||||
virtual float GetCurrentMaxGroundSpeed();
|
||||
virtual void ComputeSequences( CStudioHdr *pStudioHdr );
|
||||
void ComputeMainSequence();
|
||||
void UpdateInterpolators();
|
||||
void ResetGroundSpeed( void );
|
||||
float GetInterpolatedGroundSpeed( void );
|
||||
|
||||
void ComputeFireSequence();
|
||||
void ComputeDeployedSequence();
|
||||
|
||||
virtual bool ShouldUpdateAnimState();
|
||||
|
||||
void DebugShowAnimStateForPlayer( bool bIsServer );
|
||||
void DebugShowEyeYaw( void );
|
||||
|
||||
// Client specific.
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
// Debug.
|
||||
void DebugShowActivity( Activity activity );
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
CBasePlayer *m_pPlayer;
|
||||
|
||||
QAngle m_angRender;
|
||||
|
||||
// Pose parameters.
|
||||
bool m_bPoseParameterInit;
|
||||
MultiPlayerPoseData_t m_PoseParameterData;
|
||||
DebugPlayerAnimData_t m_DebugAnimData;
|
||||
|
||||
bool m_bCurrentFeetYawInitialized;
|
||||
float m_flLastAnimationStateClearTime;
|
||||
|
||||
float m_flEyeYaw;
|
||||
float m_flEyePitch;
|
||||
float m_flGoalFeetYaw;
|
||||
float m_flCurrentFeetYaw;
|
||||
float m_flLastAimTurnTime;
|
||||
|
||||
MultiPlayerMovementData_t m_MovementData;
|
||||
|
||||
// Jumping.
|
||||
bool m_bJumping;
|
||||
float m_flJumpStartTime;
|
||||
bool m_bFirstJumpFrame;
|
||||
|
||||
// Swimming.
|
||||
bool m_bInSwim;
|
||||
bool m_bFirstSwimFrame;
|
||||
|
||||
// Dying
|
||||
bool m_bDying;
|
||||
bool m_bFirstDyingFrame;
|
||||
|
||||
// Last activity we've used on the lower body. Used to determine if animations should restart.
|
||||
Activity m_eCurrentMainSequenceActivity;
|
||||
|
||||
// Specific full-body sequence to play
|
||||
int m_nSpecificMainSequence;
|
||||
|
||||
// Weapon data.
|
||||
CHandle<CBaseCombatWeapon> m_hActiveWeapon;
|
||||
|
||||
// Ground speed interpolators.
|
||||
#ifdef CLIENT_DLL
|
||||
float m_flLastGroundSpeedUpdateTime;
|
||||
CInterpolatedVar<float> m_iv_flMaxGroundSpeed;
|
||||
#endif
|
||||
float m_flMaxGroundSpeed;
|
||||
|
||||
// movement playback options
|
||||
int m_nMovementSequence;
|
||||
LegAnimType_t m_LegAnimType;
|
||||
};
|
||||
|
||||
// If this is set, then the game code needs to make sure to send player animation events
|
||||
// to the local player if he's the one being watched.
|
||||
extern ConVar cl_showanimstate;
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef MULTIPLAYERANIMSTATE_H
|
||||
#define MULTIPLAYERANIMSTATE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "convar.h"
|
||||
#include "basecombatweapon_shared.h"
|
||||
#include "iplayeranimstate.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
class C_BasePlayer;
|
||||
#define CPlayer C_BasePlayer
|
||||
#else
|
||||
class CBasePlayer;
|
||||
#endif
|
||||
|
||||
enum PlayerAnimEvent_t
|
||||
{
|
||||
PLAYERANIMEVENT_ATTACK_PRIMARY,
|
||||
PLAYERANIMEVENT_ATTACK_SECONDARY,
|
||||
PLAYERANIMEVENT_ATTACK_GRENADE,
|
||||
PLAYERANIMEVENT_RELOAD,
|
||||
PLAYERANIMEVENT_RELOAD_LOOP,
|
||||
PLAYERANIMEVENT_RELOAD_END,
|
||||
PLAYERANIMEVENT_JUMP,
|
||||
PLAYERANIMEVENT_SWIM,
|
||||
PLAYERANIMEVENT_DIE,
|
||||
PLAYERANIMEVENT_FLINCH_CHEST,
|
||||
PLAYERANIMEVENT_FLINCH_HEAD,
|
||||
PLAYERANIMEVENT_FLINCH_LEFTARM,
|
||||
PLAYERANIMEVENT_FLINCH_RIGHTARM,
|
||||
PLAYERANIMEVENT_FLINCH_LEFTLEG,
|
||||
PLAYERANIMEVENT_FLINCH_RIGHTLEG,
|
||||
PLAYERANIMEVENT_DOUBLEJUMP,
|
||||
|
||||
// Cancel.
|
||||
PLAYERANIMEVENT_CANCEL,
|
||||
PLAYERANIMEVENT_SPAWN,
|
||||
|
||||
// Snap to current yaw exactly
|
||||
PLAYERANIMEVENT_SNAP_YAW,
|
||||
|
||||
PLAYERANIMEVENT_CUSTOM, // Used to play specific activities
|
||||
PLAYERANIMEVENT_CUSTOM_GESTURE,
|
||||
PLAYERANIMEVENT_CUSTOM_SEQUENCE, // Used to play specific sequences
|
||||
PLAYERANIMEVENT_CUSTOM_GESTURE_SEQUENCE,
|
||||
|
||||
// TF Specific. Here until there's a derived game solution to this.
|
||||
PLAYERANIMEVENT_ATTACK_PRE,
|
||||
PLAYERANIMEVENT_ATTACK_POST,
|
||||
PLAYERANIMEVENT_GRENADE1_DRAW,
|
||||
PLAYERANIMEVENT_GRENADE2_DRAW,
|
||||
PLAYERANIMEVENT_GRENADE1_THROW,
|
||||
PLAYERANIMEVENT_GRENADE2_THROW,
|
||||
PLAYERANIMEVENT_VOICE_COMMAND_GESTURE,
|
||||
PLAYERANIMEVENT_DOUBLEJUMP_CROUCH,
|
||||
PLAYERANIMEVENT_STUN_BEGIN,
|
||||
PLAYERANIMEVENT_STUN_MIDDLE,
|
||||
PLAYERANIMEVENT_STUN_END,
|
||||
|
||||
PLAYERANIMEVENT_ATTACK_PRIMARY_SUPER,
|
||||
|
||||
PLAYERANIMEVENT_COUNT
|
||||
};
|
||||
|
||||
// Gesture Slots.
|
||||
enum
|
||||
{
|
||||
GESTURE_SLOT_ATTACK_AND_RELOAD,
|
||||
GESTURE_SLOT_GRENADE,
|
||||
GESTURE_SLOT_JUMP,
|
||||
GESTURE_SLOT_SWIM,
|
||||
GESTURE_SLOT_FLINCH,
|
||||
GESTURE_SLOT_VCD,
|
||||
GESTURE_SLOT_CUSTOM,
|
||||
|
||||
GESTURE_SLOT_COUNT,
|
||||
};
|
||||
|
||||
#define GESTURE_SLOT_INVALID -1
|
||||
|
||||
struct GestureSlot_t
|
||||
{
|
||||
int m_iGestureSlot;
|
||||
Activity m_iActivity;
|
||||
bool m_bAutoKill;
|
||||
bool m_bActive;
|
||||
CAnimationLayer *m_pAnimLayer;
|
||||
};
|
||||
|
||||
inline bool IsCustomPlayerAnimEvent( PlayerAnimEvent_t event )
|
||||
{
|
||||
return ( event == PLAYERANIMEVENT_CUSTOM ) || ( event == PLAYERANIMEVENT_CUSTOM_GESTURE ) ||
|
||||
( event == PLAYERANIMEVENT_CUSTOM_SEQUENCE ) || ( event == PLAYERANIMEVENT_CUSTOM_GESTURE_SEQUENCE );
|
||||
}
|
||||
|
||||
struct MultiPlayerPoseData_t
|
||||
{
|
||||
int m_iMoveX;
|
||||
int m_iMoveY;
|
||||
int m_iAimYaw;
|
||||
int m_iAimPitch;
|
||||
int m_iBodyHeight;
|
||||
int m_iMoveYaw;
|
||||
int m_iMoveScale;
|
||||
|
||||
float m_flEstimateYaw;
|
||||
float m_flLastAimTurnTime;
|
||||
|
||||
void Init()
|
||||
{
|
||||
m_iMoveX = 0;
|
||||
m_iMoveY = 0;
|
||||
m_iAimYaw = 0;
|
||||
m_iAimPitch = 0;
|
||||
m_iBodyHeight = 0;
|
||||
m_iMoveYaw = 0;
|
||||
m_iMoveScale = 0;
|
||||
m_flEstimateYaw = 0.0f;
|
||||
m_flLastAimTurnTime = 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
struct DebugPlayerAnimData_t
|
||||
{
|
||||
float m_flSpeed;
|
||||
float m_flAimPitch;
|
||||
float m_flAimYaw;
|
||||
float m_flBodyHeight;
|
||||
Vector2D m_vecMoveYaw;
|
||||
|
||||
void Init()
|
||||
{
|
||||
m_flSpeed = 0.0f;
|
||||
m_flAimPitch = 0.0f;
|
||||
m_flAimYaw = 0.0f;
|
||||
m_flBodyHeight = 0.0f;
|
||||
m_vecMoveYaw.Init();
|
||||
}
|
||||
};
|
||||
|
||||
struct MultiPlayerMovementData_t
|
||||
{
|
||||
// Set speeds to -1 if they are not used.
|
||||
float m_flWalkSpeed;
|
||||
float m_flRunSpeed;
|
||||
float m_flSprintSpeed;
|
||||
float m_flBodyYawRate;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Multi-Player Animation State
|
||||
//
|
||||
class CMultiPlayerAnimState
|
||||
{
|
||||
public:
|
||||
|
||||
DECLARE_CLASS_NOBASE( CMultiPlayerAnimState );
|
||||
|
||||
// Creation/Destruction
|
||||
CMultiPlayerAnimState() {}
|
||||
CMultiPlayerAnimState( CBasePlayer *pPlayer, MultiPlayerMovementData_t &movementData );
|
||||
virtual ~CMultiPlayerAnimState();
|
||||
|
||||
// This is called by both the client and the server in the same way to trigger events for
|
||||
// players firing, jumping, throwing grenades, etc.
|
||||
virtual void ClearAnimationState();
|
||||
virtual void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
|
||||
virtual Activity CalcMainActivity();
|
||||
virtual void Update( float eyeYaw, float eyePitch );
|
||||
virtual void Release( void );
|
||||
|
||||
const QAngle &GetRenderAngles();
|
||||
|
||||
virtual Activity TranslateActivity( Activity actDesired );
|
||||
|
||||
virtual void SetRunSpeed( float flSpeed ) { m_MovementData.m_flRunSpeed = flSpeed; }
|
||||
virtual void SetWalkSpeed( float flSpeed ) { m_MovementData.m_flWalkSpeed = flSpeed; }
|
||||
virtual void SetSprintSpeed( float flSpeed ) { m_MovementData.m_flSprintSpeed = flSpeed; }
|
||||
|
||||
// Debug
|
||||
virtual void ShowDebugInfo( void );
|
||||
virtual void DebugShowAnimState( int iStartLine );
|
||||
|
||||
Activity GetCurrentMainActivity( void ) { return m_eCurrentMainSequenceActivity; }
|
||||
|
||||
void OnNewModel( void );
|
||||
|
||||
// Gestures.
|
||||
void ResetGestureSlots( void );
|
||||
void ResetGestureSlot( int iGestureSlot );
|
||||
void AddVCDSequenceToGestureSlot( int iGestureSlot, int iGestureSequence, float flCycle = 0.0f, bool bAutoKill = true );
|
||||
CAnimationLayer* GetGestureSlotLayer( int iGestureSlot );
|
||||
bool IsGestureSlotActive( int iGestureSlot );
|
||||
|
||||
// Feet.
|
||||
bool m_bForceAimYaw;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void Init( CBasePlayer *pPlayer, MultiPlayerMovementData_t &movementData );
|
||||
CBasePlayer *GetBasePlayer( void ) { return m_pPlayer; }
|
||||
|
||||
// Allow inheriting classes to override SelectWeightedSequence
|
||||
virtual int SelectWeightedSequence( Activity activity ) { return GetBasePlayer()->SelectWeightedSequence( activity ); }
|
||||
virtual void RestartMainSequence();
|
||||
|
||||
virtual void GetOuterAbsVelocity( Vector& vel );
|
||||
float GetOuterXYSpeed();
|
||||
|
||||
virtual bool HandleJumping( Activity &idealActivity );
|
||||
virtual bool HandleDucking( Activity &idealActivity );
|
||||
virtual bool HandleMoving( Activity &idealActivity );
|
||||
virtual bool HandleSwimming( Activity &idealActivity );
|
||||
virtual bool HandleDying( Activity &idealActivity );
|
||||
|
||||
// Gesture Slots
|
||||
CUtlVector<GestureSlot_t> m_aGestureSlots;
|
||||
bool InitGestureSlots( void );
|
||||
void ShutdownGestureSlots( void );
|
||||
bool IsGestureSlotPlaying( int iGestureSlot, Activity iGestureActivity );
|
||||
void AddToGestureSlot( int iGestureSlot, Activity iGestureActivity, bool bAutoKill );
|
||||
virtual void RestartGesture( int iGestureSlot, Activity iGestureActivity, bool bAutoKill = true );
|
||||
void ComputeGestureSequence( CStudioHdr *pStudioHdr );
|
||||
void UpdateGestureLayer( CStudioHdr *pStudioHdr, GestureSlot_t *pGesture );
|
||||
void DebugGestureInfo( void );
|
||||
virtual float GetGesturePlaybackRate( void ) { return 1.0f; }
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void RunGestureSlotAnimEventsToCompletion( GestureSlot_t *pGesture );
|
||||
#endif
|
||||
|
||||
virtual void PlayFlinchGesture( Activity iActivity );
|
||||
|
||||
virtual float CalcMovementSpeed( bool *bIsMoving );
|
||||
virtual float CalcMovementPlaybackRate( bool *bIsMoving );
|
||||
|
||||
void DoMovementTest( CStudioHdr *pStudioHdr, float flX, float flY );
|
||||
void DoMovementTest( CStudioHdr *pStudioHdr );
|
||||
void GetMovementFlags( CStudioHdr *pStudioHdr );
|
||||
|
||||
// Pose parameters.
|
||||
bool SetupPoseParameters( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_AimPitch( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_AimYaw( CStudioHdr *pStudioHdr );
|
||||
void ComputePoseParam_BodyHeight( CStudioHdr *pStudioHdr );
|
||||
virtual void EstimateYaw( void );
|
||||
void ConvergeYawAngles( float flGoalYaw, float flYawRate, float flDeltaTime, float &flCurrentYaw );
|
||||
|
||||
virtual float GetCurrentMaxGroundSpeed();
|
||||
virtual void ComputeSequences( CStudioHdr *pStudioHdr );
|
||||
void ComputeMainSequence();
|
||||
void UpdateInterpolators();
|
||||
void ResetGroundSpeed( void );
|
||||
float GetInterpolatedGroundSpeed( void );
|
||||
|
||||
void ComputeFireSequence();
|
||||
void ComputeDeployedSequence();
|
||||
|
||||
virtual bool ShouldUpdateAnimState();
|
||||
|
||||
void DebugShowAnimStateForPlayer( bool bIsServer );
|
||||
void DebugShowEyeYaw( void );
|
||||
|
||||
// Client specific.
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
// Debug.
|
||||
void DebugShowActivity( Activity activity );
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
CBasePlayer *m_pPlayer;
|
||||
|
||||
QAngle m_angRender;
|
||||
|
||||
// Pose parameters.
|
||||
bool m_bPoseParameterInit;
|
||||
MultiPlayerPoseData_t m_PoseParameterData;
|
||||
DebugPlayerAnimData_t m_DebugAnimData;
|
||||
|
||||
bool m_bCurrentFeetYawInitialized;
|
||||
float m_flLastAnimationStateClearTime;
|
||||
|
||||
float m_flEyeYaw;
|
||||
float m_flEyePitch;
|
||||
float m_flGoalFeetYaw;
|
||||
float m_flCurrentFeetYaw;
|
||||
float m_flLastAimTurnTime;
|
||||
|
||||
MultiPlayerMovementData_t m_MovementData;
|
||||
|
||||
// Jumping.
|
||||
bool m_bJumping;
|
||||
float m_flJumpStartTime;
|
||||
bool m_bFirstJumpFrame;
|
||||
|
||||
// Swimming.
|
||||
bool m_bInSwim;
|
||||
bool m_bFirstSwimFrame;
|
||||
|
||||
// Dying
|
||||
bool m_bDying;
|
||||
bool m_bFirstDyingFrame;
|
||||
|
||||
// Last activity we've used on the lower body. Used to determine if animations should restart.
|
||||
Activity m_eCurrentMainSequenceActivity;
|
||||
|
||||
// Specific full-body sequence to play
|
||||
int m_nSpecificMainSequence;
|
||||
|
||||
// Weapon data.
|
||||
CHandle<CBaseCombatWeapon> m_hActiveWeapon;
|
||||
|
||||
// Ground speed interpolators.
|
||||
#ifdef CLIENT_DLL
|
||||
float m_flLastGroundSpeedUpdateTime;
|
||||
CInterpolatedVar<float> m_iv_flMaxGroundSpeed;
|
||||
#endif
|
||||
float m_flMaxGroundSpeed;
|
||||
|
||||
// movement playback options
|
||||
int m_nMovementSequence;
|
||||
LegAnimType_t m_LegAnimType;
|
||||
};
|
||||
|
||||
// If this is set, then the game code needs to make sure to send player animation events
|
||||
// to the local player if he's the one being watched.
|
||||
extern ConVar cl_showanimstate;
|
||||
|
||||
#endif // DOD_PLAYERANIMSTATE_H
|
||||
+132
-132
@@ -1,132 +1,132 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "SceneCache.h"
|
||||
#include "choreoscene.h"
|
||||
#include "choreoevent.h"
|
||||
|
||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||
CChoreoScene *BlockingLoadScene( const char *filename );
|
||||
|
||||
CSceneCache::CSceneCache()
|
||||
{
|
||||
msecs = 0;
|
||||
}
|
||||
|
||||
CSceneCache::CSceneCache( const CSceneCache& src )
|
||||
{
|
||||
msecs = src.msecs;
|
||||
sounds = src.sounds;
|
||||
}
|
||||
|
||||
int CSceneCache::GetSoundCount() const
|
||||
{
|
||||
return sounds.Count();
|
||||
}
|
||||
|
||||
char const *CSceneCache::GetSoundName( int index )
|
||||
{
|
||||
return soundemitterbase->GetSoundName( sounds[ index ] );
|
||||
}
|
||||
|
||||
void CSceneCache::Save( CUtlBuffer& buf )
|
||||
{
|
||||
buf.PutUnsignedInt( msecs );
|
||||
|
||||
unsigned short c = GetSoundCount();
|
||||
buf.PutShort( c );
|
||||
|
||||
Assert( sounds.Count() <= 65536 );
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
buf.PutString( GetSoundName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CSceneCache::Restore( CUtlBuffer& buf )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
|
||||
msecs = buf.GetUnsignedInt();
|
||||
|
||||
unsigned short c = (unsigned short)buf.GetShort();
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
char soundname[ 512 ];
|
||||
buf.GetString( soundname, sizeof( soundname ) );
|
||||
|
||||
int idx = soundemitterbase->GetSoundIndex( soundname );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
Assert( idx <= 65535 );
|
||||
if ( sounds.Find( idx ) == sounds.InvalidIndex() )
|
||||
{
|
||||
sounds.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Static method
|
||||
// Input : *event -
|
||||
// soundlist -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSceneCache::PrecacheSceneEvent( CChoreoEvent *event, CUtlVector< unsigned short >& soundlist )
|
||||
{
|
||||
if ( !event || event->GetType() != CChoreoEvent::SPEAK )
|
||||
return;
|
||||
|
||||
int idx = soundemitterbase->GetSoundIndex( event->GetParameters() );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
Assert( idx <= 65535 );
|
||||
soundlist.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
|
||||
if ( event->GetCloseCaptionType() == CChoreoEvent::CC_MASTER )
|
||||
{
|
||||
char tok[ CChoreoEvent::MAX_CCTOKEN_STRING ];
|
||||
if ( event->GetPlaybackCloseCaptionToken( tok, sizeof( tok ) ) )
|
||||
{
|
||||
int idx = soundemitterbase->GetSoundIndex( tok );
|
||||
if ( idx != -1 && soundlist.Find( idx ) == soundlist.InvalidIndex() )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
Assert( idx <= 65535 );
|
||||
soundlist.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSceneCache::Rebuild( char const *filename )
|
||||
{
|
||||
msecs = 0;
|
||||
sounds.RemoveAll();
|
||||
|
||||
CChoreoScene *scene = BlockingLoadScene( filename );
|
||||
if ( scene )
|
||||
{
|
||||
// Walk all events looking for SPEAK events
|
||||
CChoreoEvent *event;
|
||||
int c = scene->GetNumEvents();
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
event = scene->GetEvent( i );
|
||||
PrecacheSceneEvent( event, sounds );
|
||||
}
|
||||
|
||||
// Update scene duration, too
|
||||
msecs = (int)( scene->FindStopTime() * 1000.0f + 0.5f );
|
||||
|
||||
delete scene;
|
||||
}
|
||||
}
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "SceneCache.h"
|
||||
#include "choreoscene.h"
|
||||
#include "choreoevent.h"
|
||||
|
||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||
CChoreoScene *BlockingLoadScene( const char *filename );
|
||||
|
||||
CSceneCache::CSceneCache()
|
||||
{
|
||||
msecs = 0;
|
||||
}
|
||||
|
||||
CSceneCache::CSceneCache( const CSceneCache& src )
|
||||
{
|
||||
msecs = src.msecs;
|
||||
sounds = src.sounds;
|
||||
}
|
||||
|
||||
int CSceneCache::GetSoundCount() const
|
||||
{
|
||||
return sounds.Count();
|
||||
}
|
||||
|
||||
char const *CSceneCache::GetSoundName( int index )
|
||||
{
|
||||
return soundemitterbase->GetSoundName( sounds[ index ] );
|
||||
}
|
||||
|
||||
void CSceneCache::Save( CUtlBuffer& buf )
|
||||
{
|
||||
buf.PutUnsignedInt( msecs );
|
||||
|
||||
unsigned short c = GetSoundCount();
|
||||
buf.PutShort( c );
|
||||
|
||||
Assert( sounds.Count() <= 65536 );
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
buf.PutString( GetSoundName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CSceneCache::Restore( CUtlBuffer& buf )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
|
||||
msecs = buf.GetUnsignedInt();
|
||||
|
||||
unsigned short c = (unsigned short)buf.GetShort();
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
char soundname[ 512 ];
|
||||
buf.GetString( soundname, sizeof( soundname ) );
|
||||
|
||||
int idx = soundemitterbase->GetSoundIndex( soundname );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
Assert( idx <= 65535 );
|
||||
if ( sounds.Find( idx ) == sounds.InvalidIndex() )
|
||||
{
|
||||
sounds.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Static method
|
||||
// Input : *event -
|
||||
// soundlist -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CSceneCache::PrecacheSceneEvent( CChoreoEvent *event, CUtlVector< unsigned short >& soundlist )
|
||||
{
|
||||
if ( !event || event->GetType() != CChoreoEvent::SPEAK )
|
||||
return;
|
||||
|
||||
int idx = soundemitterbase->GetSoundIndex( event->GetParameters() );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
Assert( idx <= 65535 );
|
||||
soundlist.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
|
||||
if ( event->GetCloseCaptionType() == CChoreoEvent::CC_MASTER )
|
||||
{
|
||||
char tok[ CChoreoEvent::MAX_CCTOKEN_STRING ];
|
||||
if ( event->GetPlaybackCloseCaptionToken( tok, sizeof( tok ) ) )
|
||||
{
|
||||
int idx = soundemitterbase->GetSoundIndex( tok );
|
||||
if ( idx != -1 && soundlist.Find( idx ) == soundlist.InvalidIndex() )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
Assert( idx <= 65535 );
|
||||
soundlist.AddToTail( (unsigned short)idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSceneCache::Rebuild( char const *filename )
|
||||
{
|
||||
msecs = 0;
|
||||
sounds.RemoveAll();
|
||||
|
||||
CChoreoScene *scene = BlockingLoadScene( filename );
|
||||
if ( scene )
|
||||
{
|
||||
// Walk all events looking for SPEAK events
|
||||
CChoreoEvent *event;
|
||||
int c = scene->GetNumEvents();
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
event = scene->GetEvent( i );
|
||||
PrecacheSceneEvent( event, sounds );
|
||||
}
|
||||
|
||||
// Update scene duration, too
|
||||
msecs = (int)( scene->FindStopTime() * 1000.0f + 0.5f );
|
||||
|
||||
delete scene;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef SCENECACHE_H
|
||||
#define SCENECACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "UtlCachedFileData.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
|
||||
#define SCENECACHE_VERSION 7
|
||||
|
||||
#pragma pack(1)
|
||||
class CSceneCache : public IBaseCacheInfo
|
||||
{
|
||||
public:
|
||||
unsigned int msecs;
|
||||
CUtlVector< unsigned short > sounds;
|
||||
|
||||
CSceneCache();
|
||||
CSceneCache( const CSceneCache& src );
|
||||
|
||||
int GetSoundCount() const;
|
||||
char const *GetSoundName( int index );
|
||||
|
||||
virtual void Save( CUtlBuffer& buf );
|
||||
virtual void Restore( CUtlBuffer& buf );
|
||||
virtual void Rebuild( char const *filename );
|
||||
|
||||
static unsigned int ComputeSoundScriptFileTimestampChecksum();
|
||||
static void PrecacheSceneEvent( CChoreoEvent *event, CUtlVector< unsigned short >& soundlist );
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#endif // SCENECACHE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef SCENECACHE_H
|
||||
#define SCENECACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "UtlCachedFileData.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
|
||||
#define SCENECACHE_VERSION 7
|
||||
|
||||
#pragma pack(1)
|
||||
class CSceneCache : public IBaseCacheInfo
|
||||
{
|
||||
public:
|
||||
unsigned int msecs;
|
||||
CUtlVector< unsigned short > sounds;
|
||||
|
||||
CSceneCache();
|
||||
CSceneCache( const CSceneCache& src );
|
||||
|
||||
int GetSoundCount() const;
|
||||
char const *GetSoundName( int index );
|
||||
|
||||
virtual void Save( CUtlBuffer& buf );
|
||||
virtual void Restore( CUtlBuffer& buf );
|
||||
virtual void Rebuild( char const *filename );
|
||||
|
||||
static unsigned int ComputeSoundScriptFileTimestampChecksum();
|
||||
static void PrecacheSceneEvent( CChoreoEvent *event, CUtlVector< unsigned short >& soundlist );
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#endif // SCENECACHE_H
|
||||
|
||||
@@ -1,83 +1,83 @@
|
||||
// SharedFunctorUtils.cpp
|
||||
// Useful functors
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "SharedFunctorUtils.h"
|
||||
#include "collisionutils.h"
|
||||
#ifdef CLIENT_DLL
|
||||
#include "ClientTerrorPlayer.h"
|
||||
#else
|
||||
#include "TerrorPlayer.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool AvoidActors::operator()( CBaseCombatCharacter *obj )
|
||||
{
|
||||
if ( !obj || ( obj == m_owner ) || ( obj->GetTeamNumber() != m_owner->GetTeamNumber() ) )
|
||||
return true;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( obj->IsDormant() )
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if ( obj->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
|
||||
return true;
|
||||
|
||||
CTerrorPlayer *player = ToTerrorPlayer( obj );
|
||||
if ( !player )
|
||||
return true;
|
||||
|
||||
if ( player->IsIncapacitatedRevivable() )
|
||||
return true;
|
||||
|
||||
if ( player->IsGhost() )
|
||||
return true;
|
||||
|
||||
Vector objOrigin = obj->GetAbsOrigin();
|
||||
Vector vObjMins = objOrigin + obj->WorldAlignMins();
|
||||
Vector vObjMaxs = objOrigin + obj->WorldAlignMaxs();
|
||||
Vector vOwnerMins = *m_dest + m_owner->WorldAlignMins();
|
||||
Vector vOwnerMaxs = *m_dest + m_owner->WorldAlignMaxs();
|
||||
if ( !IsBoxIntersectingBox( vOwnerMins, vOwnerMaxs, vObjMins, vObjMaxs ) )
|
||||
return true;
|
||||
|
||||
float objWidth = vObjMaxs.x - vObjMins.x;
|
||||
float ownerWidth = vOwnerMaxs.x - vOwnerMins.x;
|
||||
float idealDistance = (objWidth + ownerWidth) * 0.5f * m_scale;
|
||||
|
||||
Vector vDelta = objOrigin - *m_dest;
|
||||
vDelta.z = 0;
|
||||
float fDist = vDelta.NormalizeInPlace();
|
||||
if ( fDist > idealDistance )
|
||||
return true;
|
||||
|
||||
Vector rayOrigin = m_origin;
|
||||
Vector rayDelta = *m_dest - m_origin;
|
||||
Vector sphereCenter = objOrigin;
|
||||
float sphereRadius = idealDistance;
|
||||
rayOrigin.z = rayDelta.z = sphereCenter.z = 0.0f;
|
||||
float t1, t2;
|
||||
if ( IntersectRayWithSphere( rayOrigin, rayDelta, sphereCenter, sphereRadius, &t1, &t2 ) )
|
||||
{
|
||||
Vector sphereToDest = *m_dest - sphereCenter;
|
||||
sphereToDest.z = 0.0f;
|
||||
if ( !sphereToDest.IsZero() )
|
||||
{
|
||||
float radius = sphereToDest.NormalizeInPlace();
|
||||
sphereToDest *= (idealDistance - radius);
|
||||
*m_dest += sphereToDest;
|
||||
m_avoidedActors.AddToTail( obj );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// SharedFunctorUtils.cpp
|
||||
// Useful functors
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "SharedFunctorUtils.h"
|
||||
#include "collisionutils.h"
|
||||
#ifdef CLIENT_DLL
|
||||
#include "ClientTerrorPlayer.h"
|
||||
#else
|
||||
#include "TerrorPlayer.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool AvoidActors::operator()( CBaseCombatCharacter *obj )
|
||||
{
|
||||
if ( !obj || ( obj == m_owner ) || ( obj->GetTeamNumber() != m_owner->GetTeamNumber() ) )
|
||||
return true;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( obj->IsDormant() )
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if ( obj->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
|
||||
return true;
|
||||
|
||||
CTerrorPlayer *player = ToTerrorPlayer( obj );
|
||||
if ( !player )
|
||||
return true;
|
||||
|
||||
if ( player->IsIncapacitatedRevivable() )
|
||||
return true;
|
||||
|
||||
if ( player->IsGhost() )
|
||||
return true;
|
||||
|
||||
Vector objOrigin = obj->GetAbsOrigin();
|
||||
Vector vObjMins = objOrigin + obj->WorldAlignMins();
|
||||
Vector vObjMaxs = objOrigin + obj->WorldAlignMaxs();
|
||||
Vector vOwnerMins = *m_dest + m_owner->WorldAlignMins();
|
||||
Vector vOwnerMaxs = *m_dest + m_owner->WorldAlignMaxs();
|
||||
if ( !IsBoxIntersectingBox( vOwnerMins, vOwnerMaxs, vObjMins, vObjMaxs ) )
|
||||
return true;
|
||||
|
||||
float objWidth = vObjMaxs.x - vObjMins.x;
|
||||
float ownerWidth = vOwnerMaxs.x - vOwnerMins.x;
|
||||
float idealDistance = (objWidth + ownerWidth) * 0.5f * m_scale;
|
||||
|
||||
Vector vDelta = objOrigin - *m_dest;
|
||||
vDelta.z = 0;
|
||||
float fDist = vDelta.NormalizeInPlace();
|
||||
if ( fDist > idealDistance )
|
||||
return true;
|
||||
|
||||
Vector rayOrigin = m_origin;
|
||||
Vector rayDelta = *m_dest - m_origin;
|
||||
Vector sphereCenter = objOrigin;
|
||||
float sphereRadius = idealDistance;
|
||||
rayOrigin.z = rayDelta.z = sphereCenter.z = 0.0f;
|
||||
float t1, t2;
|
||||
if ( IntersectRayWithSphere( rayOrigin, rayDelta, sphereCenter, sphereRadius, &t1, &t2 ) )
|
||||
{
|
||||
Vector sphereToDest = *m_dest - sphereCenter;
|
||||
sphereToDest.z = 0.0f;
|
||||
if ( !sphereToDest.IsZero() )
|
||||
{
|
||||
float radius = sphereToDest.NormalizeInPlace();
|
||||
sphereToDest *= (idealDistance - radius);
|
||||
*m_dest += sphereToDest;
|
||||
m_avoidedActors.AddToTail( obj );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,156 +1,156 @@
|
||||
// SharedFunctorUtils.h
|
||||
// Useful functors for client and server
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* NOTE: The functors in this file should ideally be game-independant,
|
||||
* and work for any Source based game
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
#ifndef _SHARED_FUNCTOR_UTILS_H_
|
||||
#define _SHARED_FUNCTOR_UTILS_H_
|
||||
|
||||
#include "debugoverlay_shared.h"
|
||||
#include "vprof.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Finds visible player on given team that we are pointing at.
|
||||
* "team" can be TEAM_ANY
|
||||
* Use with ForEachPlayer()
|
||||
*/
|
||||
template < class PlayerType >
|
||||
class TargetScan
|
||||
{
|
||||
public:
|
||||
TargetScan( PlayerType *me, int team, float aimTolerance = 0.01f, float maxRange = 2000.0f, float closestPointTestDistance = 50.0f, bool debug = false )
|
||||
{
|
||||
m_me = me;
|
||||
AngleVectors( m_me->EyeAngles(), &m_viewForward );
|
||||
m_team = team;
|
||||
m_closeDot = 1.0f - aimTolerance;
|
||||
m_bestDot = m_closeDot;
|
||||
m_maxRange = maxRange;
|
||||
m_target = NULL;
|
||||
m_closestPointTestDistance = closestPointTestDistance;
|
||||
m_debug = debug;
|
||||
}
|
||||
|
||||
|
||||
virtual bool operator() ( PlayerType *them )
|
||||
{
|
||||
VPROF( "TargetScan()" );
|
||||
if ( them != m_me &&
|
||||
them->IsAlive() &&
|
||||
(m_team == TEAM_ANY || them->GetTeamNumber() == m_team) &&
|
||||
IsPotentialTarget( them ) )
|
||||
{
|
||||
// move the start point out for determining closestPos, to help with close-in checks (healing, etc)
|
||||
Vector closestPos;
|
||||
Vector start = m_me->EyePosition();
|
||||
Vector end = start + m_viewForward * m_closestPointTestDistance;
|
||||
Vector testPos;
|
||||
CalcClosestPointOnLineSegment( them->WorldSpaceCenter(), start, end, testPos );
|
||||
|
||||
start = them->GetAbsOrigin();
|
||||
end = start;
|
||||
end.z += them->CollisionProp()->OBBMaxs().z;
|
||||
CalcClosestPointOnLineSegment( testPos, start, end, closestPos );
|
||||
if ( m_debug )
|
||||
{
|
||||
NDebugOverlay::Cross3D( closestPos, 1, 255, 255, 255, true, -1.0f );
|
||||
NDebugOverlay::Line( end, start, 255, 0, 0, true, -1.0f );
|
||||
}
|
||||
|
||||
Vector to = closestPos - m_me->EyePosition();
|
||||
to.NormalizeInPlace();
|
||||
|
||||
Vector meRangePoint, themRangePoint;
|
||||
m_me->CollisionProp()->CalcNearestPoint( closestPos, &meRangePoint );
|
||||
them->CollisionProp()->CalcNearestPoint( meRangePoint, &themRangePoint );
|
||||
float range = meRangePoint.DistTo( themRangePoint );
|
||||
|
||||
if ( range > m_maxRange )
|
||||
{
|
||||
// too far away
|
||||
return true;
|
||||
}
|
||||
|
||||
float dot = ViewDot( to );
|
||||
if ( dot > m_closeDot )
|
||||
{
|
||||
// target is within angle cone, check visibility
|
||||
if ( IsTargetVisible( them ) )
|
||||
{
|
||||
if ( dot >= m_bestDot )
|
||||
{
|
||||
m_target = them;
|
||||
m_bestDot = dot;
|
||||
}
|
||||
|
||||
m_allTargets.AddToTail( them );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerType *GetTarget( void ) const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
const CUtlVector< PlayerType * > &GetAllTargets( void ) const
|
||||
{
|
||||
return m_allTargets;
|
||||
}
|
||||
|
||||
float GetTargetDot( void ) const
|
||||
{
|
||||
return m_bestDot;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Is the point in our FOV?
|
||||
*/
|
||||
virtual float ViewDot( const Vector &dir ) const
|
||||
{
|
||||
return DotProduct( m_viewForward, dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given actor a visible target?
|
||||
*/
|
||||
virtual bool IsTargetVisible( PlayerType *them ) const
|
||||
{
|
||||
// The default check is a straight-up IsAbleToSee
|
||||
return m_me->IsAbleToSee( them, CBaseCombatCharacter::DISREGARD_FOV ); // already have a dot product checking FOV
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given player a possible target at all?
|
||||
*/
|
||||
virtual bool IsPotentialTarget( PlayerType *them ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerType *m_me;
|
||||
Vector m_viewForward;
|
||||
int m_team;
|
||||
|
||||
float m_closeDot;
|
||||
float m_bestDot;
|
||||
float m_maxRange;
|
||||
float m_closestPointTestDistance;
|
||||
bool m_debug;
|
||||
|
||||
PlayerType *m_target;
|
||||
CUtlVector< PlayerType * > m_allTargets;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// SharedFunctorUtils.h
|
||||
// Useful functors for client and server
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* NOTE: The functors in this file should ideally be game-independant,
|
||||
* and work for any Source based game
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
#ifndef _SHARED_FUNCTOR_UTILS_H_
|
||||
#define _SHARED_FUNCTOR_UTILS_H_
|
||||
|
||||
#include "debugoverlay_shared.h"
|
||||
#include "vprof.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Finds visible player on given team that we are pointing at.
|
||||
* "team" can be TEAM_ANY
|
||||
* Use with ForEachPlayer()
|
||||
*/
|
||||
template < class PlayerType >
|
||||
class TargetScan
|
||||
{
|
||||
public:
|
||||
TargetScan( PlayerType *me, int team, float aimTolerance = 0.01f, float maxRange = 2000.0f, float closestPointTestDistance = 50.0f, bool debug = false )
|
||||
{
|
||||
m_me = me;
|
||||
AngleVectors( m_me->EyeAngles(), &m_viewForward );
|
||||
m_team = team;
|
||||
m_closeDot = 1.0f - aimTolerance;
|
||||
m_bestDot = m_closeDot;
|
||||
m_maxRange = maxRange;
|
||||
m_target = NULL;
|
||||
m_closestPointTestDistance = closestPointTestDistance;
|
||||
m_debug = debug;
|
||||
}
|
||||
|
||||
|
||||
virtual bool operator() ( PlayerType *them )
|
||||
{
|
||||
VPROF( "TargetScan()" );
|
||||
if ( them != m_me &&
|
||||
them->IsAlive() &&
|
||||
(m_team == TEAM_ANY || them->GetTeamNumber() == m_team) &&
|
||||
IsPotentialTarget( them ) )
|
||||
{
|
||||
// move the start point out for determining closestPos, to help with close-in checks (healing, etc)
|
||||
Vector closestPos;
|
||||
Vector start = m_me->EyePosition();
|
||||
Vector end = start + m_viewForward * m_closestPointTestDistance;
|
||||
Vector testPos;
|
||||
CalcClosestPointOnLineSegment( them->WorldSpaceCenter(), start, end, testPos );
|
||||
|
||||
start = them->GetAbsOrigin();
|
||||
end = start;
|
||||
end.z += them->CollisionProp()->OBBMaxs().z;
|
||||
CalcClosestPointOnLineSegment( testPos, start, end, closestPos );
|
||||
if ( m_debug )
|
||||
{
|
||||
NDebugOverlay::Cross3D( closestPos, 1, 255, 255, 255, true, -1.0f );
|
||||
NDebugOverlay::Line( end, start, 255, 0, 0, true, -1.0f );
|
||||
}
|
||||
|
||||
Vector to = closestPos - m_me->EyePosition();
|
||||
to.NormalizeInPlace();
|
||||
|
||||
Vector meRangePoint, themRangePoint;
|
||||
m_me->CollisionProp()->CalcNearestPoint( closestPos, &meRangePoint );
|
||||
them->CollisionProp()->CalcNearestPoint( meRangePoint, &themRangePoint );
|
||||
float range = meRangePoint.DistTo( themRangePoint );
|
||||
|
||||
if ( range > m_maxRange )
|
||||
{
|
||||
// too far away
|
||||
return true;
|
||||
}
|
||||
|
||||
float dot = ViewDot( to );
|
||||
if ( dot > m_closeDot )
|
||||
{
|
||||
// target is within angle cone, check visibility
|
||||
if ( IsTargetVisible( them ) )
|
||||
{
|
||||
if ( dot >= m_bestDot )
|
||||
{
|
||||
m_target = them;
|
||||
m_bestDot = dot;
|
||||
}
|
||||
|
||||
m_allTargets.AddToTail( them );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerType *GetTarget( void ) const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
const CUtlVector< PlayerType * > &GetAllTargets( void ) const
|
||||
{
|
||||
return m_allTargets;
|
||||
}
|
||||
|
||||
float GetTargetDot( void ) const
|
||||
{
|
||||
return m_bestDot;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Is the point in our FOV?
|
||||
*/
|
||||
virtual float ViewDot( const Vector &dir ) const
|
||||
{
|
||||
return DotProduct( m_viewForward, dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given actor a visible target?
|
||||
*/
|
||||
virtual bool IsTargetVisible( PlayerType *them ) const
|
||||
{
|
||||
// The default check is a straight-up IsAbleToSee
|
||||
return m_me->IsAbleToSee( them, CBaseCombatCharacter::DISREGARD_FOV ); // already have a dot product checking FOV
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given player a possible target at all?
|
||||
*/
|
||||
virtual bool IsPotentialTarget( PlayerType *them ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerType *m_me;
|
||||
Vector m_viewForward;
|
||||
int m_team;
|
||||
|
||||
float m_closeDot;
|
||||
float m_bestDot;
|
||||
float m_maxRange;
|
||||
float m_closestPointTestDistance;
|
||||
bool m_debug;
|
||||
|
||||
PlayerType *m_target;
|
||||
CUtlVector< PlayerType * > m_allTargets;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+1524
-1524
File diff suppressed because it is too large
Load Diff
+868
-868
File diff suppressed because it is too large
Load Diff
+297
-297
@@ -1,297 +1,297 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "predictable_entity.h"
|
||||
#include "baseentity_shared.h"
|
||||
|
||||
#define SF_SPRITE_STARTON 0x0001
|
||||
#define SF_SPRITE_ONCE 0x0002
|
||||
#define SF_SPRITE_TEMPORARY 0x8000
|
||||
|
||||
class CBasePlayer;
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CSprite C_Sprite
|
||||
#define CSpriteOriented C_SpriteOriented
|
||||
#include "c_pixel_visibility.h"
|
||||
class CEngineSprite;
|
||||
|
||||
class C_SpriteRenderer
|
||||
{
|
||||
public:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sprite orientations
|
||||
// WARNING! Change these in common/MaterialSystem/Sprite.cpp if you change them here!
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef enum
|
||||
{
|
||||
SPR_VP_PARALLEL_UPRIGHT = 0,
|
||||
SPR_FACING_UPRIGHT = 1,
|
||||
SPR_VP_PARALLEL = 2,
|
||||
SPR_ORIENTED = 3,
|
||||
SPR_VP_PARALLEL_ORIENTED = 4
|
||||
} SPRITETYPE;
|
||||
|
||||
// Determine sprite orientation
|
||||
static void GetSpriteAxes( SPRITETYPE type,
|
||||
const Vector& origin,
|
||||
const QAngle& angles,
|
||||
Vector& forward,
|
||||
Vector& right,
|
||||
Vector& up );
|
||||
|
||||
// Sprites can alter blending amount
|
||||
virtual float GlowBlend( CEngineSprite *psprite, const Vector& entorigin, int rendermode, int renderfx, int alpha, float *scale );
|
||||
|
||||
// Draws tempent as a sprite
|
||||
int DrawSprite(
|
||||
IClientEntity *entity,
|
||||
const model_t *model,
|
||||
const Vector& origin,
|
||||
const QAngle& angles,
|
||||
float frame,
|
||||
IClientEntity *attachedto,
|
||||
int attachmentindex,
|
||||
int rendermode,
|
||||
int renderfx,
|
||||
int alpha,
|
||||
int r,
|
||||
int g,
|
||||
int b,
|
||||
float scale,
|
||||
float flHDRColorScale = 1.0f
|
||||
);
|
||||
|
||||
protected:
|
||||
pixelvis_handle_t m_queryHandle;
|
||||
float m_flGlowProxySize;
|
||||
float m_flHDRColorScale;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class CSprite : public CBaseEntity
|
||||
#if defined( CLIENT_DLL )
|
||||
, public C_SpriteRenderer
|
||||
#endif
|
||||
{
|
||||
DECLARE_CLASS( CSprite, CBaseEntity );
|
||||
public:
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
CSprite();
|
||||
virtual void SetModel( const char *szModelName );
|
||||
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
virtual void ComputeWorldSpaceSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs );
|
||||
|
||||
void SetGlowProxySize( float flSize ) { m_flGlowProxySize = flSize; }
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
|
||||
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
virtual int UpdateTransmitState( void );
|
||||
|
||||
void SetAsTemporary( void ) { AddSpawnFlags( SF_SPRITE_TEMPORARY ); }
|
||||
bool IsTemporary( void ) { return ( HasSpawnFlags( SF_SPRITE_TEMPORARY ) ); }
|
||||
|
||||
int ObjectCaps( void )
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if ( IsTemporary() )
|
||||
{
|
||||
flags = FCAP_DONT_SAVE;
|
||||
}
|
||||
|
||||
return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
|
||||
void OnRestore();
|
||||
#endif
|
||||
|
||||
void AnimateThink( void );
|
||||
void ExpandThink( void );
|
||||
void Animate( float frames );
|
||||
void Expand( float scaleSpeed, float fadeSpeed );
|
||||
void SpriteInit( const char *pSpriteName, const Vector &origin );
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
// Input handlers
|
||||
void InputHideSprite( inputdata_t &inputdata );
|
||||
void InputShowSprite( inputdata_t &inputdata );
|
||||
void InputToggleSprite( inputdata_t &inputdata );
|
||||
void InputColorRedValue( inputdata_t &inputdata );
|
||||
void InputColorBlueValue( inputdata_t &inputdata );
|
||||
void InputColorGreenValue( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
inline void SetAttachment( CBaseEntity *pEntity, int attachment )
|
||||
{
|
||||
if ( pEntity )
|
||||
{
|
||||
m_hAttachedToEntity = pEntity;
|
||||
m_nAttachment = attachment;
|
||||
FollowEntity( pEntity );
|
||||
}
|
||||
}
|
||||
|
||||
void TurnOff( void );
|
||||
void TurnOn( void );
|
||||
bool IsOn() { return !IsEffectActive( EF_NODRAW ); }
|
||||
|
||||
inline float Frames( void ) { return m_flMaxFrame; }
|
||||
inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx )
|
||||
{
|
||||
SetRenderMode( (RenderMode_t)rendermode );
|
||||
SetColor( r, g, b );
|
||||
SetBrightness( a );
|
||||
m_nRenderFX = fx;
|
||||
}
|
||||
inline void SetTexture( int spriteIndex ) { SetModelIndex( spriteIndex ); }
|
||||
inline void SetColor( int r, int g, int b ) { SetRenderColor( r, g, b, GetRenderColor().a ); }
|
||||
|
||||
void SetBrightness( int brightness, float duration = 0.0f );
|
||||
void SetScale( float scale, float duration = 0.0f );
|
||||
void SetSpriteScale( float scale );
|
||||
void EnableWorldSpaceScale( bool bEnable );
|
||||
|
||||
float GetScale( void ) { return m_flSpriteScale; }
|
||||
int GetBrightness( void ) { return m_nBrightness; }
|
||||
float GetHDRColorScale( void ) { return m_flHDRColorScale; }
|
||||
|
||||
inline void FadeAndDie( float duration )
|
||||
{
|
||||
SetBrightness( 0, duration );
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
m_flDieTime = gpGlobals->curtime + duration;
|
||||
SetNextThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
inline void AnimateAndDie( float framerate )
|
||||
{
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
m_flSpriteFramerate = framerate;
|
||||
m_flDieTime = gpGlobals->curtime + (m_flMaxFrame / m_flSpriteFramerate);
|
||||
SetNextThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
inline void AnimateForTime( float framerate, float time )
|
||||
{
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
m_flSpriteFramerate = framerate;
|
||||
m_flDieTime = gpGlobals->curtime + time;
|
||||
SetNextThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
// FIXME: This completely blows.
|
||||
// Surely there's gotta be a better way.
|
||||
void FadeOutFromSpawn( )
|
||||
{
|
||||
SetThink(&CSprite::BeginFadeOutThink);
|
||||
SetNextThink( gpGlobals->curtime + 0.01f );
|
||||
}
|
||||
|
||||
void BeginFadeOutThink( )
|
||||
{
|
||||
FadeAndDie( 0.25f );
|
||||
}
|
||||
|
||||
void AnimateUntilDead( void );
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
|
||||
static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, bool animate );
|
||||
#endif
|
||||
static CSprite *SpriteCreatePredictable( const char *module, int line, const char *pSpriteName, const Vector &origin, bool animate );
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
virtual float GetRenderScale( void );
|
||||
virtual int GetRenderBrightness( void );
|
||||
|
||||
virtual int DrawModel( int flags );
|
||||
virtual const Vector& GetRenderOrigin();
|
||||
virtual void GetRenderBounds( Vector &vecMins, Vector &vecMaxs );
|
||||
virtual float GlowBlend( CEngineSprite *psprite, const Vector& entorigin, int rendermode, int renderfx, int alpha, float *scale );
|
||||
virtual void GetToolRecordingState( KeyValues *msg );
|
||||
|
||||
// Only supported in TF2 right now
|
||||
#if defined( INVASION_CLIENT_DLL )
|
||||
virtual bool ShouldPredict( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void ClientThink( void );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
#endif
|
||||
public:
|
||||
CNetworkHandle( CBaseEntity, m_hAttachedToEntity );
|
||||
CNetworkVar( int, m_nAttachment );
|
||||
CNetworkVar( float, m_flSpriteFramerate );
|
||||
CNetworkVar( float, m_flFrame );
|
||||
#ifdef PORTAL
|
||||
CNetworkVar( bool, m_bDrawInMainRender );
|
||||
CNetworkVar( bool, m_bDrawInPortalRender );
|
||||
#endif
|
||||
|
||||
float m_flDieTime;
|
||||
|
||||
private:
|
||||
|
||||
CNetworkVar( int, m_nBrightness );
|
||||
CNetworkVar( float, m_flBrightnessTime );
|
||||
|
||||
CNetworkVar( float, m_flSpriteScale );
|
||||
CNetworkVar( float, m_flScaleTime );
|
||||
CNetworkVar( bool, m_bWorldSpaceScale );
|
||||
CNetworkVar( float, m_flGlowProxySize );
|
||||
CNetworkVar( float, m_flHDRColorScale );
|
||||
|
||||
float m_flLastTime;
|
||||
float m_flMaxFrame;
|
||||
|
||||
float m_flStartScale;
|
||||
float m_flDestScale; //Destination scale
|
||||
float m_flScaleTimeStart; //Real time for start of scale
|
||||
int m_nStartBrightness;
|
||||
int m_nDestBrightness; //Destination brightness
|
||||
float m_flBrightnessTimeStart;//Real time for brightness
|
||||
};
|
||||
|
||||
|
||||
class CSpriteOriented : public CSprite
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CSpriteOriented, CSprite );
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_SERVERCLASS();
|
||||
void Spawn( void );
|
||||
#else
|
||||
DECLARE_CLIENTCLASS();
|
||||
virtual bool IsTransparent( void );
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Macro to wrap creation
|
||||
#define SPRITE_CREATE_PREDICTABLE( name, origin, animate ) \
|
||||
CSprite::SpriteCreatePredictable( __FILE__, __LINE__, name, origin, animate )
|
||||
|
||||
#endif // SPRITE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "predictable_entity.h"
|
||||
#include "baseentity_shared.h"
|
||||
|
||||
#define SF_SPRITE_STARTON 0x0001
|
||||
#define SF_SPRITE_ONCE 0x0002
|
||||
#define SF_SPRITE_TEMPORARY 0x8000
|
||||
|
||||
class CBasePlayer;
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CSprite C_Sprite
|
||||
#define CSpriteOriented C_SpriteOriented
|
||||
#include "c_pixel_visibility.h"
|
||||
class CEngineSprite;
|
||||
|
||||
class C_SpriteRenderer
|
||||
{
|
||||
public:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sprite orientations
|
||||
// WARNING! Change these in common/MaterialSystem/Sprite.cpp if you change them here!
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef enum
|
||||
{
|
||||
SPR_VP_PARALLEL_UPRIGHT = 0,
|
||||
SPR_FACING_UPRIGHT = 1,
|
||||
SPR_VP_PARALLEL = 2,
|
||||
SPR_ORIENTED = 3,
|
||||
SPR_VP_PARALLEL_ORIENTED = 4
|
||||
} SPRITETYPE;
|
||||
|
||||
// Determine sprite orientation
|
||||
static void GetSpriteAxes( SPRITETYPE type,
|
||||
const Vector& origin,
|
||||
const QAngle& angles,
|
||||
Vector& forward,
|
||||
Vector& right,
|
||||
Vector& up );
|
||||
|
||||
// Sprites can alter blending amount
|
||||
virtual float GlowBlend( CEngineSprite *psprite, const Vector& entorigin, int rendermode, int renderfx, int alpha, float *scale );
|
||||
|
||||
// Draws tempent as a sprite
|
||||
int DrawSprite(
|
||||
IClientEntity *entity,
|
||||
const model_t *model,
|
||||
const Vector& origin,
|
||||
const QAngle& angles,
|
||||
float frame,
|
||||
IClientEntity *attachedto,
|
||||
int attachmentindex,
|
||||
int rendermode,
|
||||
int renderfx,
|
||||
int alpha,
|
||||
int r,
|
||||
int g,
|
||||
int b,
|
||||
float scale,
|
||||
float flHDRColorScale = 1.0f
|
||||
);
|
||||
|
||||
protected:
|
||||
pixelvis_handle_t m_queryHandle;
|
||||
float m_flGlowProxySize;
|
||||
float m_flHDRColorScale;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class CSprite : public CBaseEntity
|
||||
#if defined( CLIENT_DLL )
|
||||
, public C_SpriteRenderer
|
||||
#endif
|
||||
{
|
||||
DECLARE_CLASS( CSprite, CBaseEntity );
|
||||
public:
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
CSprite();
|
||||
virtual void SetModel( const char *szModelName );
|
||||
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
virtual void ComputeWorldSpaceSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs );
|
||||
|
||||
void SetGlowProxySize( float flSize ) { m_flGlowProxySize = flSize; }
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
|
||||
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
virtual int UpdateTransmitState( void );
|
||||
|
||||
void SetAsTemporary( void ) { AddSpawnFlags( SF_SPRITE_TEMPORARY ); }
|
||||
bool IsTemporary( void ) { return ( HasSpawnFlags( SF_SPRITE_TEMPORARY ) ); }
|
||||
|
||||
int ObjectCaps( void )
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if ( IsTemporary() )
|
||||
{
|
||||
flags = FCAP_DONT_SAVE;
|
||||
}
|
||||
|
||||
return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
|
||||
void OnRestore();
|
||||
#endif
|
||||
|
||||
void AnimateThink( void );
|
||||
void ExpandThink( void );
|
||||
void Animate( float frames );
|
||||
void Expand( float scaleSpeed, float fadeSpeed );
|
||||
void SpriteInit( const char *pSpriteName, const Vector &origin );
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
// Input handlers
|
||||
void InputHideSprite( inputdata_t &inputdata );
|
||||
void InputShowSprite( inputdata_t &inputdata );
|
||||
void InputToggleSprite( inputdata_t &inputdata );
|
||||
void InputColorRedValue( inputdata_t &inputdata );
|
||||
void InputColorBlueValue( inputdata_t &inputdata );
|
||||
void InputColorGreenValue( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
inline void SetAttachment( CBaseEntity *pEntity, int attachment )
|
||||
{
|
||||
if ( pEntity )
|
||||
{
|
||||
m_hAttachedToEntity = pEntity;
|
||||
m_nAttachment = attachment;
|
||||
FollowEntity( pEntity );
|
||||
}
|
||||
}
|
||||
|
||||
void TurnOff( void );
|
||||
void TurnOn( void );
|
||||
bool IsOn() { return !IsEffectActive( EF_NODRAW ); }
|
||||
|
||||
inline float Frames( void ) { return m_flMaxFrame; }
|
||||
inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx )
|
||||
{
|
||||
SetRenderMode( (RenderMode_t)rendermode );
|
||||
SetColor( r, g, b );
|
||||
SetBrightness( a );
|
||||
m_nRenderFX = fx;
|
||||
}
|
||||
inline void SetTexture( int spriteIndex ) { SetModelIndex( spriteIndex ); }
|
||||
inline void SetColor( int r, int g, int b ) { SetRenderColor( r, g, b, GetRenderColor().a ); }
|
||||
|
||||
void SetBrightness( int brightness, float duration = 0.0f );
|
||||
void SetScale( float scale, float duration = 0.0f );
|
||||
void SetSpriteScale( float scale );
|
||||
void EnableWorldSpaceScale( bool bEnable );
|
||||
|
||||
float GetScale( void ) { return m_flSpriteScale; }
|
||||
int GetBrightness( void ) { return m_nBrightness; }
|
||||
float GetHDRColorScale( void ) { return m_flHDRColorScale; }
|
||||
|
||||
inline void FadeAndDie( float duration )
|
||||
{
|
||||
SetBrightness( 0, duration );
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
m_flDieTime = gpGlobals->curtime + duration;
|
||||
SetNextThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
inline void AnimateAndDie( float framerate )
|
||||
{
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
m_flSpriteFramerate = framerate;
|
||||
m_flDieTime = gpGlobals->curtime + (m_flMaxFrame / m_flSpriteFramerate);
|
||||
SetNextThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
inline void AnimateForTime( float framerate, float time )
|
||||
{
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
m_flSpriteFramerate = framerate;
|
||||
m_flDieTime = gpGlobals->curtime + time;
|
||||
SetNextThink( gpGlobals->curtime );
|
||||
}
|
||||
|
||||
// FIXME: This completely blows.
|
||||
// Surely there's gotta be a better way.
|
||||
void FadeOutFromSpawn( )
|
||||
{
|
||||
SetThink(&CSprite::BeginFadeOutThink);
|
||||
SetNextThink( gpGlobals->curtime + 0.01f );
|
||||
}
|
||||
|
||||
void BeginFadeOutThink( )
|
||||
{
|
||||
FadeAndDie( 0.25f );
|
||||
}
|
||||
|
||||
void AnimateUntilDead( void );
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
|
||||
static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, bool animate );
|
||||
#endif
|
||||
static CSprite *SpriteCreatePredictable( const char *module, int line, const char *pSpriteName, const Vector &origin, bool animate );
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
virtual float GetRenderScale( void );
|
||||
virtual int GetRenderBrightness( void );
|
||||
|
||||
virtual int DrawModel( int flags );
|
||||
virtual const Vector& GetRenderOrigin();
|
||||
virtual void GetRenderBounds( Vector &vecMins, Vector &vecMaxs );
|
||||
virtual float GlowBlend( CEngineSprite *psprite, const Vector& entorigin, int rendermode, int renderfx, int alpha, float *scale );
|
||||
virtual void GetToolRecordingState( KeyValues *msg );
|
||||
|
||||
// Only supported in TF2 right now
|
||||
#if defined( INVASION_CLIENT_DLL )
|
||||
virtual bool ShouldPredict( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void ClientThink( void );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
#endif
|
||||
public:
|
||||
CNetworkHandle( CBaseEntity, m_hAttachedToEntity );
|
||||
CNetworkVar( int, m_nAttachment );
|
||||
CNetworkVar( float, m_flSpriteFramerate );
|
||||
CNetworkVar( float, m_flFrame );
|
||||
#ifdef PORTAL
|
||||
CNetworkVar( bool, m_bDrawInMainRender );
|
||||
CNetworkVar( bool, m_bDrawInPortalRender );
|
||||
#endif
|
||||
|
||||
float m_flDieTime;
|
||||
|
||||
private:
|
||||
|
||||
CNetworkVar( int, m_nBrightness );
|
||||
CNetworkVar( float, m_flBrightnessTime );
|
||||
|
||||
CNetworkVar( float, m_flSpriteScale );
|
||||
CNetworkVar( float, m_flScaleTime );
|
||||
CNetworkVar( bool, m_bWorldSpaceScale );
|
||||
CNetworkVar( float, m_flGlowProxySize );
|
||||
CNetworkVar( float, m_flHDRColorScale );
|
||||
|
||||
float m_flLastTime;
|
||||
float m_flMaxFrame;
|
||||
|
||||
float m_flStartScale;
|
||||
float m_flDestScale; //Destination scale
|
||||
float m_flScaleTimeStart; //Real time for start of scale
|
||||
int m_nStartBrightness;
|
||||
int m_nDestBrightness; //Destination brightness
|
||||
float m_flBrightnessTimeStart;//Real time for brightness
|
||||
};
|
||||
|
||||
|
||||
class CSpriteOriented : public CSprite
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CSpriteOriented, CSprite );
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_SERVERCLASS();
|
||||
void Spawn( void );
|
||||
#else
|
||||
DECLARE_CLIENTCLASS();
|
||||
virtual bool IsTransparent( void );
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Macro to wrap creation
|
||||
#define SPRITE_CREATE_PREDICTABLE( name, origin, animate ) \
|
||||
CSprite::SpriteCreatePredictable( __FILE__, __LINE__, name, origin, animate )
|
||||
|
||||
#endif // SPRITE_H
|
||||
|
||||
+662
-662
File diff suppressed because it is too large
Load Diff
+119
-119
@@ -1,119 +1,119 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SPRITETRAIL_H
|
||||
#define SPRITETRAIL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "Sprite.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CSpriteTrail C_SpriteTrail
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sprite trail
|
||||
//-----------------------------------------------------------------------------
|
||||
struct TrailPoint_t
|
||||
{
|
||||
DECLARE_SIMPLE_DATADESC();
|
||||
|
||||
Vector m_vecScreenPos;
|
||||
float m_flDieTime;
|
||||
float m_flTexCoord;
|
||||
float m_flWidthVariance;
|
||||
};
|
||||
|
||||
class CSpriteTrail : public CSprite
|
||||
{
|
||||
DECLARE_CLASS( CSpriteTrail, CSprite );
|
||||
DECLARE_DATADESC();
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
|
||||
public:
|
||||
CSpriteTrail( void );
|
||||
|
||||
// Sets parameters of the sprite trail
|
||||
void SetLifeTime( float time );
|
||||
void SetStartWidth( float flStartWidth );
|
||||
void SetEndWidth( float flEndWidth );
|
||||
void SetStartWidthVariance( float flStartWidthVariance );
|
||||
void SetTextureResolution( float flTexelsPerInch );
|
||||
void SetMinFadeLength( float flMinFadeLength );
|
||||
void SetSkybox( const Vector &vecSkyboxOrigin, float flSkyboxScale );
|
||||
|
||||
// Is the trail in the skybox?
|
||||
bool IsInSkybox() const;
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void SetTransmit( bool bTransmit = true ) { m_bDrawForMoveParent = bTransmit; }
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
// Client only code
|
||||
virtual int DrawModel( int flags );
|
||||
virtual const Vector &GetRenderOrigin( void );
|
||||
virtual const QAngle &GetRenderAngles( void );
|
||||
|
||||
// On data update
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void GetRenderBounds( Vector& mins, Vector& maxs );
|
||||
virtual void ClientThink();
|
||||
|
||||
virtual bool ValidateEntityAttachedToPlayer( bool &bShouldRetry );
|
||||
|
||||
#else
|
||||
// Server only code
|
||||
|
||||
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
static CSpriteTrail *SpriteTrailCreate( const char *pSpriteName, const Vector &origin, bool animate );
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if defined( CLIENT_DLL )
|
||||
enum
|
||||
{
|
||||
// NOTE: # of points max must be a power of two!
|
||||
MAX_SPRITE_TRAIL_POINTS = 64,
|
||||
MAX_SPRITE_TRAIL_MASK = 0x3F,
|
||||
};
|
||||
|
||||
TrailPoint_t *GetTrailPoint( int n );
|
||||
void UpdateTrail( void );
|
||||
void ComputeScreenPosition( Vector *pScreenPos );
|
||||
void ConvertSkybox();
|
||||
void UpdateBoundingBox( void );
|
||||
|
||||
TrailPoint_t m_vecSteps[MAX_SPRITE_TRAIL_POINTS];
|
||||
int m_nFirstStep;
|
||||
int m_nStepCount;
|
||||
float m_flUpdateTime;
|
||||
Vector m_vecPrevSkyboxOrigin;
|
||||
float m_flPrevSkyboxScale;
|
||||
Vector m_vecRenderMins;
|
||||
Vector m_vecRenderMaxs;
|
||||
#endif
|
||||
|
||||
CNetworkVar( float, m_flLifeTime ); // Amount of time before a new trail segment fades away
|
||||
CNetworkVar( float, m_flStartWidth ); // The starting scale
|
||||
CNetworkVar( float, m_flEndWidth ); // The ending scale
|
||||
CNetworkVar( float, m_flStartWidthVariance ); // The starting scale
|
||||
CNetworkVar( float, m_flTextureRes ); // Texture resolution along the trail
|
||||
CNetworkVar( float, m_flMinFadeLength ); // The end of the trail must fade out for this many units
|
||||
CNetworkVector( m_vecSkyboxOrigin ); // What's our skybox origin?
|
||||
CNetworkVar( float, m_flSkyboxScale ); // What's our skybox scale?
|
||||
|
||||
string_t m_iszSpriteName;
|
||||
bool m_bAnimate;
|
||||
bool m_bDrawForMoveParent;
|
||||
};
|
||||
|
||||
#endif // SPRITETRAIL_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SPRITETRAIL_H
|
||||
#define SPRITETRAIL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "Sprite.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CSpriteTrail C_SpriteTrail
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sprite trail
|
||||
//-----------------------------------------------------------------------------
|
||||
struct TrailPoint_t
|
||||
{
|
||||
DECLARE_SIMPLE_DATADESC();
|
||||
|
||||
Vector m_vecScreenPos;
|
||||
float m_flDieTime;
|
||||
float m_flTexCoord;
|
||||
float m_flWidthVariance;
|
||||
};
|
||||
|
||||
class CSpriteTrail : public CSprite
|
||||
{
|
||||
DECLARE_CLASS( CSpriteTrail, CSprite );
|
||||
DECLARE_DATADESC();
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
|
||||
public:
|
||||
CSpriteTrail( void );
|
||||
|
||||
// Sets parameters of the sprite trail
|
||||
void SetLifeTime( float time );
|
||||
void SetStartWidth( float flStartWidth );
|
||||
void SetEndWidth( float flEndWidth );
|
||||
void SetStartWidthVariance( float flStartWidthVariance );
|
||||
void SetTextureResolution( float flTexelsPerInch );
|
||||
void SetMinFadeLength( float flMinFadeLength );
|
||||
void SetSkybox( const Vector &vecSkyboxOrigin, float flSkyboxScale );
|
||||
|
||||
// Is the trail in the skybox?
|
||||
bool IsInSkybox() const;
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void SetTransmit( bool bTransmit = true ) { m_bDrawForMoveParent = bTransmit; }
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
// Client only code
|
||||
virtual int DrawModel( int flags );
|
||||
virtual const Vector &GetRenderOrigin( void );
|
||||
virtual const QAngle &GetRenderAngles( void );
|
||||
|
||||
// On data update
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void GetRenderBounds( Vector& mins, Vector& maxs );
|
||||
virtual void ClientThink();
|
||||
|
||||
virtual bool ValidateEntityAttachedToPlayer( bool &bShouldRetry );
|
||||
|
||||
#else
|
||||
// Server only code
|
||||
|
||||
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
static CSpriteTrail *SpriteTrailCreate( const char *pSpriteName, const Vector &origin, bool animate );
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if defined( CLIENT_DLL )
|
||||
enum
|
||||
{
|
||||
// NOTE: # of points max must be a power of two!
|
||||
MAX_SPRITE_TRAIL_POINTS = 64,
|
||||
MAX_SPRITE_TRAIL_MASK = 0x3F,
|
||||
};
|
||||
|
||||
TrailPoint_t *GetTrailPoint( int n );
|
||||
void UpdateTrail( void );
|
||||
void ComputeScreenPosition( Vector *pScreenPos );
|
||||
void ConvertSkybox();
|
||||
void UpdateBoundingBox( void );
|
||||
|
||||
TrailPoint_t m_vecSteps[MAX_SPRITE_TRAIL_POINTS];
|
||||
int m_nFirstStep;
|
||||
int m_nStepCount;
|
||||
float m_flUpdateTime;
|
||||
Vector m_vecPrevSkyboxOrigin;
|
||||
float m_flPrevSkyboxScale;
|
||||
Vector m_vecRenderMins;
|
||||
Vector m_vecRenderMaxs;
|
||||
#endif
|
||||
|
||||
CNetworkVar( float, m_flLifeTime ); // Amount of time before a new trail segment fades away
|
||||
CNetworkVar( float, m_flStartWidth ); // The starting scale
|
||||
CNetworkVar( float, m_flEndWidth ); // The ending scale
|
||||
CNetworkVar( float, m_flStartWidthVariance ); // The starting scale
|
||||
CNetworkVar( float, m_flTextureRes ); // Texture resolution along the trail
|
||||
CNetworkVar( float, m_flMinFadeLength ); // The end of the trail must fade out for this many units
|
||||
CNetworkVector( m_vecSkyboxOrigin ); // What's our skybox origin?
|
||||
CNetworkVar( float, m_flSkyboxScale ); // What's our skybox scale?
|
||||
|
||||
string_t m_iszSpriteName;
|
||||
bool m_bAnimate;
|
||||
bool m_bDrawForMoveParent;
|
||||
};
|
||||
|
||||
#endif // SPRITETRAIL_H
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
#include "isaverestore.h"
|
||||
#include "saverestore_utlvector.h"
|
||||
#include "achievement_saverestore.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
#include "utlmap.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static short ACHIEVEMENT_SAVE_RESTORE_VERSION = 2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CAchievementSaveRestoreBlockHandler : public CDefSaveRestoreBlockHandler
|
||||
{
|
||||
public:
|
||||
const char *GetBlockName()
|
||||
{
|
||||
return "Achievement";
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void Save( ISave *pSave )
|
||||
{
|
||||
CAchievementMgr *pAchievementMgr = dynamic_cast<CAchievementMgr *>( engine->GetAchievementMgr() );
|
||||
if ( !pAchievementMgr )
|
||||
return;
|
||||
|
||||
// save global achievement mgr state to separate file if there have been any changes, so in case of a crash
|
||||
// the global state is consistent with last save game
|
||||
pAchievementMgr->SaveGlobalStateIfDirty( pSave->IsAsync() );
|
||||
|
||||
pSave->StartBlock( "Achievements" );
|
||||
int iTotalAchievements = pAchievementMgr->GetAchievementCount();
|
||||
short nSaveCount = 0;
|
||||
// count how many achievements should be saved.
|
||||
for ( int i = 0; i < iTotalAchievements; i++ )
|
||||
{
|
||||
IAchievement *pAchievement = pAchievementMgr->GetAchievementByIndex( i );
|
||||
if ( pAchievement->ShouldSaveWithGame() )
|
||||
{
|
||||
nSaveCount++;
|
||||
}
|
||||
}
|
||||
// Write # of saved achievements
|
||||
pSave->WriteShort( &nSaveCount );
|
||||
// Write out each achievement
|
||||
for ( int i = 0; i < iTotalAchievements; i++ )
|
||||
{
|
||||
IAchievement *pAchievement = pAchievementMgr->GetAchievementByIndex( i );
|
||||
if ( pAchievement->ShouldSaveWithGame() )
|
||||
{
|
||||
CBaseAchievement *pBaseAchievement = dynamic_cast< CBaseAchievement * >( pAchievement );
|
||||
if ( pBaseAchievement )
|
||||
{
|
||||
short iAchievementID = (short) pBaseAchievement->GetAchievementID();
|
||||
// write the achievement ID
|
||||
pSave->WriteShort( &iAchievementID );
|
||||
// write the achievement data
|
||||
pSave->WriteAll( pBaseAchievement, pBaseAchievement->GetDataDescMap() );
|
||||
}
|
||||
}
|
||||
}
|
||||
pSave->EndBlock();
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void WriteSaveHeaders( ISave *pSave )
|
||||
{
|
||||
pSave->WriteShort( &ACHIEVEMENT_SAVE_RESTORE_VERSION );
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void ReadRestoreHeaders( IRestore *pRestore )
|
||||
{
|
||||
// No reason why any future version shouldn't try to retain backward compatability. The default here is to not do so.
|
||||
short version;
|
||||
pRestore->ReadShort( &version );
|
||||
// only load if version matches and if we are loading a game, not a transition
|
||||
m_fDoLoad = ( ( version == ACHIEVEMENT_SAVE_RESTORE_VERSION ) &&
|
||||
( ( MapLoad_LoadGame == gpGlobals->eLoadType ) || ( MapLoad_NewGame == gpGlobals->eLoadType ) )
|
||||
);
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void Restore( IRestore *pRestore, bool createPlayers )
|
||||
{
|
||||
CAchievementMgr *pAchievementMgr = dynamic_cast<CAchievementMgr *>( engine->GetAchievementMgr() );
|
||||
if ( !pAchievementMgr )
|
||||
return;
|
||||
|
||||
if ( m_fDoLoad )
|
||||
{
|
||||
pAchievementMgr->PreRestoreSavedGame();
|
||||
|
||||
pRestore->StartBlock();
|
||||
// read # of achievements
|
||||
int nSavedAchievements = pRestore->ReadShort();
|
||||
|
||||
while ( nSavedAchievements-- )
|
||||
{
|
||||
// read achievement ID
|
||||
int iAchievementID = pRestore->ReadShort();
|
||||
// find the corresponding achievement object
|
||||
CBaseAchievement *pAchievement = pAchievementMgr->GetAchievementByID( iAchievementID );
|
||||
Assert( pAchievement ); // It's a bug if we don't understand this achievement
|
||||
if ( pAchievement )
|
||||
{
|
||||
// read achievement data
|
||||
pRestore->ReadAll( pAchievement, pAchievement->GetDataDescMap() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we don't recognize the achievement for some reason, read and discard the data and keep going
|
||||
CBaseAchievement ignored;
|
||||
pRestore->ReadAll( &ignored, ignored.GetDataDescMap() );
|
||||
}
|
||||
}
|
||||
pRestore->EndBlock();
|
||||
|
||||
pAchievementMgr->PostRestoreSavedGame();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_fDoLoad;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CAchievementSaveRestoreBlockHandler g_AchievementSaveRestoreBlockHandler;
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
ISaveRestoreBlockHandler *GetAchievementSaveRestoreBlockHandler()
|
||||
{
|
||||
return &g_AchievementSaveRestoreBlockHandler;
|
||||
}
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
#include "isaverestore.h"
|
||||
#include "saverestore_utlvector.h"
|
||||
#include "achievement_saverestore.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
#include "utlmap.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static short ACHIEVEMENT_SAVE_RESTORE_VERSION = 2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CAchievementSaveRestoreBlockHandler : public CDefSaveRestoreBlockHandler
|
||||
{
|
||||
public:
|
||||
const char *GetBlockName()
|
||||
{
|
||||
return "Achievement";
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void Save( ISave *pSave )
|
||||
{
|
||||
CAchievementMgr *pAchievementMgr = dynamic_cast<CAchievementMgr *>( engine->GetAchievementMgr() );
|
||||
if ( !pAchievementMgr )
|
||||
return;
|
||||
|
||||
// save global achievement mgr state to separate file if there have been any changes, so in case of a crash
|
||||
// the global state is consistent with last save game
|
||||
pAchievementMgr->SaveGlobalStateIfDirty( pSave->IsAsync() );
|
||||
|
||||
pSave->StartBlock( "Achievements" );
|
||||
int iTotalAchievements = pAchievementMgr->GetAchievementCount();
|
||||
short nSaveCount = 0;
|
||||
// count how many achievements should be saved.
|
||||
for ( int i = 0; i < iTotalAchievements; i++ )
|
||||
{
|
||||
IAchievement *pAchievement = pAchievementMgr->GetAchievementByIndex( i );
|
||||
if ( pAchievement->ShouldSaveWithGame() )
|
||||
{
|
||||
nSaveCount++;
|
||||
}
|
||||
}
|
||||
// Write # of saved achievements
|
||||
pSave->WriteShort( &nSaveCount );
|
||||
// Write out each achievement
|
||||
for ( int i = 0; i < iTotalAchievements; i++ )
|
||||
{
|
||||
IAchievement *pAchievement = pAchievementMgr->GetAchievementByIndex( i );
|
||||
if ( pAchievement->ShouldSaveWithGame() )
|
||||
{
|
||||
CBaseAchievement *pBaseAchievement = dynamic_cast< CBaseAchievement * >( pAchievement );
|
||||
if ( pBaseAchievement )
|
||||
{
|
||||
short iAchievementID = (short) pBaseAchievement->GetAchievementID();
|
||||
// write the achievement ID
|
||||
pSave->WriteShort( &iAchievementID );
|
||||
// write the achievement data
|
||||
pSave->WriteAll( pBaseAchievement, pBaseAchievement->GetDataDescMap() );
|
||||
}
|
||||
}
|
||||
}
|
||||
pSave->EndBlock();
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void WriteSaveHeaders( ISave *pSave )
|
||||
{
|
||||
pSave->WriteShort( &ACHIEVEMENT_SAVE_RESTORE_VERSION );
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void ReadRestoreHeaders( IRestore *pRestore )
|
||||
{
|
||||
// No reason why any future version shouldn't try to retain backward compatability. The default here is to not do so.
|
||||
short version;
|
||||
pRestore->ReadShort( &version );
|
||||
// only load if version matches and if we are loading a game, not a transition
|
||||
m_fDoLoad = ( ( version == ACHIEVEMENT_SAVE_RESTORE_VERSION ) &&
|
||||
( ( MapLoad_LoadGame == gpGlobals->eLoadType ) || ( MapLoad_NewGame == gpGlobals->eLoadType ) )
|
||||
);
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void Restore( IRestore *pRestore, bool createPlayers )
|
||||
{
|
||||
CAchievementMgr *pAchievementMgr = dynamic_cast<CAchievementMgr *>( engine->GetAchievementMgr() );
|
||||
if ( !pAchievementMgr )
|
||||
return;
|
||||
|
||||
if ( m_fDoLoad )
|
||||
{
|
||||
pAchievementMgr->PreRestoreSavedGame();
|
||||
|
||||
pRestore->StartBlock();
|
||||
// read # of achievements
|
||||
int nSavedAchievements = pRestore->ReadShort();
|
||||
|
||||
while ( nSavedAchievements-- )
|
||||
{
|
||||
// read achievement ID
|
||||
int iAchievementID = pRestore->ReadShort();
|
||||
// find the corresponding achievement object
|
||||
CBaseAchievement *pAchievement = pAchievementMgr->GetAchievementByID( iAchievementID );
|
||||
Assert( pAchievement ); // It's a bug if we don't understand this achievement
|
||||
if ( pAchievement )
|
||||
{
|
||||
// read achievement data
|
||||
pRestore->ReadAll( pAchievement, pAchievement->GetDataDescMap() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we don't recognize the achievement for some reason, read and discard the data and keep going
|
||||
CBaseAchievement ignored;
|
||||
pRestore->ReadAll( &ignored, ignored.GetDataDescMap() );
|
||||
}
|
||||
}
|
||||
pRestore->EndBlock();
|
||||
|
||||
pAchievementMgr->PostRestoreSavedGame();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_fDoLoad;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CAchievementSaveRestoreBlockHandler g_AchievementSaveRestoreBlockHandler;
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
ISaveRestoreBlockHandler *GetAchievementSaveRestoreBlockHandler()
|
||||
{
|
||||
return &g_AchievementSaveRestoreBlockHandler;
|
||||
}
|
||||
|
||||
|
||||
#endif // GAME_DLL
|
||||
@@ -1,17 +1,17 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACHIEVEMENT_SAVERESTORE_H
|
||||
#define ACHIEVEMENT_SAVERESTORE_H
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
ISaveRestoreBlockHandler *GetAchievementSaveRestoreBlockHandler();
|
||||
|
||||
#endif // ACHIEVEMENT_SAVERESTORE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACHIEVEMENT_SAVERESTORE_H
|
||||
#define ACHIEVEMENT_SAVERESTORE_H
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
ISaveRestoreBlockHandler *GetAchievementSaveRestoreBlockHandler();
|
||||
|
||||
#endif // ACHIEVEMENT_SAVERESTORE_H
|
||||
|
||||
+2074
-2074
File diff suppressed because it is too large
Load Diff
+183
-183
@@ -1,183 +1,183 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ACHIEVEMENTMGR_H
|
||||
#define ACHIEVEMENTMGR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
#include "baseachievement.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "hl2orange.spa.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "utlmap.h"
|
||||
#ifndef NO_STEAM
|
||||
#include "steam/steam_api.h"
|
||||
#endif
|
||||
|
||||
#define THINK_CLEAR -1
|
||||
|
||||
class CAchievementMgr : public CAutoGameSystemPerFrame, public CGameEventListener, public IAchievementMgr
|
||||
{
|
||||
public:
|
||||
//=============================================================================
|
||||
// HPE_BEGIN
|
||||
// [dwenger] Steam Cloud Support
|
||||
//=============================================================================
|
||||
|
||||
enum SteamCloudPersisting
|
||||
{
|
||||
SteamCloudPersist_Off = 0,
|
||||
SteamCloudPersist_On,
|
||||
};
|
||||
|
||||
CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_Off );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
virtual bool Init();
|
||||
virtual void PostInit();
|
||||
virtual void Shutdown();
|
||||
virtual void LevelInitPreEntity();
|
||||
virtual void LevelShutdownPreEntity();
|
||||
virtual void InitializeAchievements();
|
||||
virtual void Update( float frametime );
|
||||
#ifdef GAME_DLL
|
||||
virtual void FrameUpdatePostEntityThink();
|
||||
#endif
|
||||
|
||||
void OnMapEvent( const char *pchEventName );
|
||||
|
||||
// Interfaces exported to other dlls for achievement list queries
|
||||
IAchievement* GetAchievementByIndex( int index );
|
||||
int GetAchievementCount();
|
||||
|
||||
CBaseAchievement *GetAchievementByID( int iAchievementID );
|
||||
CUtlMap<int, CBaseAchievement *> &GetAchievements() { return m_mapAchievement; }
|
||||
|
||||
CBaseAchievement *GetAchievementByName( const char *pchName );
|
||||
bool HasAchieved( const char *pchName );
|
||||
|
||||
void UploadUserData();
|
||||
void DownloadUserData();
|
||||
void SaveGlobalState( bool bAsync = false );
|
||||
void LoadGlobalState();
|
||||
void SaveGlobalStateIfDirty( bool bAsync = false );
|
||||
void EnsureGlobalStateLoaded();
|
||||
void AwardAchievement( int iAchievementID );
|
||||
void UpdateAchievement( int iAchievementID, int nData );
|
||||
void PreRestoreSavedGame();
|
||||
void PostRestoreSavedGame();
|
||||
void ResetAchievements();
|
||||
void ResetAchievement( int iAchievementID );
|
||||
void PrintAchievementStatus();
|
||||
float GetLastClassChangeTime() { return m_flLastClassChangeTime; }
|
||||
float GetTeamplayStartTime() { return m_flTeamplayStartTime; }
|
||||
int GetMiniroundsCompleted() { return m_iMiniroundsCompleted; }
|
||||
const char *GetMapName() { return m_szMap; }
|
||||
void OnAchievementEvent( int iAchievementID, int iCount = 1 );
|
||||
|
||||
void CheckMetaAchievements( void );
|
||||
|
||||
void SetDirty( bool bDirty )
|
||||
{
|
||||
if (bDirty)
|
||||
{
|
||||
m_bGlobalStateDirty = true;
|
||||
m_bSteamDataDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
bool CheckAchievementsEnabled();
|
||||
bool LoggedIntoSteam()
|
||||
{
|
||||
#if !defined(NO_STEAM)
|
||||
return ( steamapicontext->SteamUser() && steamapicontext->SteamUserStats() && steamapicontext->SteamUser()->BLoggedOn() );
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
float GetTimeLastUpload() { return m_flTimeLastSaved; } // time we last uploaded to Steam
|
||||
|
||||
bool WereCheatsEverOn( void ) { return m_bCheatsEverOn; }
|
||||
|
||||
#if !defined(NO_STEAM)
|
||||
STEAM_CALLBACK( CAchievementMgr, Steam_OnUserStatsReceived, UserStatsReceived_t, m_CallbackUserStatsReceived );
|
||||
STEAM_CALLBACK( CAchievementMgr, Steam_OnUserStatsStored, UserStatsStored_t, m_CallbackUserStatsStored );
|
||||
#endif
|
||||
|
||||
void SetAchievementThink( CBaseAchievement *pAchievement, float flThinkTime );
|
||||
|
||||
private:
|
||||
void FireGameEvent( IGameEvent *event );
|
||||
void OnKillEvent( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event );
|
||||
void ResetAchievement_Internal( CBaseAchievement *pAchievement );
|
||||
void UpdateStateFromSteam_Internal();
|
||||
|
||||
CUtlMap<int, CBaseAchievement *> m_mapAchievement; // map of all achievements
|
||||
CUtlVector<CBaseAchievement *> m_vecAchievement; // vector of all achievements for accessing by index
|
||||
CUtlVector<CBaseAchievement *> m_vecKillEventListeners; // vector of achievements that are listening for kill events
|
||||
CUtlVector<CBaseAchievement *> m_vecMapEventListeners; // vector of achievements that are listening for map events
|
||||
CUtlVector<CBaseAchievement *> m_vecComponentListeners; // vector of achievements that are listening for components that make up an achievement
|
||||
CUtlMap<int, CAchievement_AchievedCount *> m_mapMetaAchievement; // map of CAchievement_AchievedCount
|
||||
|
||||
struct achievementthink_t
|
||||
{
|
||||
float m_flThinkTime;
|
||||
CBaseAchievement *pAchievement;
|
||||
};
|
||||
CUtlVector<achievementthink_t> m_vecThinkListeners; // vector of achievements that are actively thinking
|
||||
|
||||
float m_flLevelInitTime;
|
||||
|
||||
float m_flLastClassChangeTime; // Time when player last changed class
|
||||
float m_flTeamplayStartTime; // Time when player joined a non-spectating team. Not updated if she switches game teams; cleared if she joins spectator
|
||||
float m_iMiniroundsCompleted; // # of minirounds played since game start (for maps that have minirounds)
|
||||
char m_szMap[MAX_PATH]; // file base of map name, cached since we access it frequently in this form
|
||||
bool m_bGlobalStateDirty; // do we have interesting state changes that needs to be saved?
|
||||
bool m_bSteamDataDirty; // do we have changes to upload to Steamworks?
|
||||
bool m_bGlobalStateLoaded; // have we loaded global state
|
||||
bool m_bCheatsEverOn; // have cheats ever been turned on in this level
|
||||
float m_flTimeLastSaved; // last time we uploaded to Steam
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN
|
||||
// [dwenger] Steam Cloud Support
|
||||
//=============================================================================
|
||||
|
||||
bool m_bPersistToSteamCloud; // true = persist data to steam cloud
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
CUtlVector<int> m_AchievementsAwarded;
|
||||
};
|
||||
|
||||
// helper functions
|
||||
const char *GetModelName( CBaseEntity *pBaseEntity );
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
bool CalcPlayersOnFriendsList( int iMinPlayers );
|
||||
bool CalcHasNumClanPlayers( int iClanTeammates );
|
||||
int CalcPlayerCount();
|
||||
int CalcTeammateCount();
|
||||
#endif // CLIENT
|
||||
|
||||
class IMatchmaking;
|
||||
extern ConVar cc_achievement_debug;
|
||||
extern IMatchmaking *matchmaking;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void MsgFunc_AchievementEvent( bf_read &msg );
|
||||
#endif // CLIENT_DLL
|
||||
#endif // ACHIEVEMENTMGR_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ACHIEVEMENTMGR_H
|
||||
#define ACHIEVEMENTMGR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
#include "baseachievement.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "hl2orange.spa.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "utlmap.h"
|
||||
#ifndef NO_STEAM
|
||||
#include "steam/steam_api.h"
|
||||
#endif
|
||||
|
||||
#define THINK_CLEAR -1
|
||||
|
||||
class CAchievementMgr : public CAutoGameSystemPerFrame, public CGameEventListener, public IAchievementMgr
|
||||
{
|
||||
public:
|
||||
//=============================================================================
|
||||
// HPE_BEGIN
|
||||
// [dwenger] Steam Cloud Support
|
||||
//=============================================================================
|
||||
|
||||
enum SteamCloudPersisting
|
||||
{
|
||||
SteamCloudPersist_Off = 0,
|
||||
SteamCloudPersist_On,
|
||||
};
|
||||
|
||||
CAchievementMgr( SteamCloudPersisting ePersistToSteamCloud = SteamCloudPersist_Off );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
virtual bool Init();
|
||||
virtual void PostInit();
|
||||
virtual void Shutdown();
|
||||
virtual void LevelInitPreEntity();
|
||||
virtual void LevelShutdownPreEntity();
|
||||
virtual void InitializeAchievements();
|
||||
virtual void Update( float frametime );
|
||||
#ifdef GAME_DLL
|
||||
virtual void FrameUpdatePostEntityThink();
|
||||
#endif
|
||||
|
||||
void OnMapEvent( const char *pchEventName );
|
||||
|
||||
// Interfaces exported to other dlls for achievement list queries
|
||||
IAchievement* GetAchievementByIndex( int index );
|
||||
int GetAchievementCount();
|
||||
|
||||
CBaseAchievement *GetAchievementByID( int iAchievementID );
|
||||
CUtlMap<int, CBaseAchievement *> &GetAchievements() { return m_mapAchievement; }
|
||||
|
||||
CBaseAchievement *GetAchievementByName( const char *pchName );
|
||||
bool HasAchieved( const char *pchName );
|
||||
|
||||
void UploadUserData();
|
||||
void DownloadUserData();
|
||||
void SaveGlobalState( bool bAsync = false );
|
||||
void LoadGlobalState();
|
||||
void SaveGlobalStateIfDirty( bool bAsync = false );
|
||||
void EnsureGlobalStateLoaded();
|
||||
void AwardAchievement( int iAchievementID );
|
||||
void UpdateAchievement( int iAchievementID, int nData );
|
||||
void PreRestoreSavedGame();
|
||||
void PostRestoreSavedGame();
|
||||
void ResetAchievements();
|
||||
void ResetAchievement( int iAchievementID );
|
||||
void PrintAchievementStatus();
|
||||
float GetLastClassChangeTime() { return m_flLastClassChangeTime; }
|
||||
float GetTeamplayStartTime() { return m_flTeamplayStartTime; }
|
||||
int GetMiniroundsCompleted() { return m_iMiniroundsCompleted; }
|
||||
const char *GetMapName() { return m_szMap; }
|
||||
void OnAchievementEvent( int iAchievementID, int iCount = 1 );
|
||||
|
||||
void CheckMetaAchievements( void );
|
||||
|
||||
void SetDirty( bool bDirty )
|
||||
{
|
||||
if (bDirty)
|
||||
{
|
||||
m_bGlobalStateDirty = true;
|
||||
m_bSteamDataDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
bool CheckAchievementsEnabled();
|
||||
bool LoggedIntoSteam()
|
||||
{
|
||||
#if !defined(NO_STEAM)
|
||||
return ( steamapicontext->SteamUser() && steamapicontext->SteamUserStats() && steamapicontext->SteamUser()->BLoggedOn() );
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
float GetTimeLastUpload() { return m_flTimeLastSaved; } // time we last uploaded to Steam
|
||||
|
||||
bool WereCheatsEverOn( void ) { return m_bCheatsEverOn; }
|
||||
|
||||
#if !defined(NO_STEAM)
|
||||
STEAM_CALLBACK( CAchievementMgr, Steam_OnUserStatsReceived, UserStatsReceived_t, m_CallbackUserStatsReceived );
|
||||
STEAM_CALLBACK( CAchievementMgr, Steam_OnUserStatsStored, UserStatsStored_t, m_CallbackUserStatsStored );
|
||||
#endif
|
||||
|
||||
void SetAchievementThink( CBaseAchievement *pAchievement, float flThinkTime );
|
||||
|
||||
private:
|
||||
void FireGameEvent( IGameEvent *event );
|
||||
void OnKillEvent( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event );
|
||||
void ResetAchievement_Internal( CBaseAchievement *pAchievement );
|
||||
void UpdateStateFromSteam_Internal();
|
||||
|
||||
CUtlMap<int, CBaseAchievement *> m_mapAchievement; // map of all achievements
|
||||
CUtlVector<CBaseAchievement *> m_vecAchievement; // vector of all achievements for accessing by index
|
||||
CUtlVector<CBaseAchievement *> m_vecKillEventListeners; // vector of achievements that are listening for kill events
|
||||
CUtlVector<CBaseAchievement *> m_vecMapEventListeners; // vector of achievements that are listening for map events
|
||||
CUtlVector<CBaseAchievement *> m_vecComponentListeners; // vector of achievements that are listening for components that make up an achievement
|
||||
CUtlMap<int, CAchievement_AchievedCount *> m_mapMetaAchievement; // map of CAchievement_AchievedCount
|
||||
|
||||
struct achievementthink_t
|
||||
{
|
||||
float m_flThinkTime;
|
||||
CBaseAchievement *pAchievement;
|
||||
};
|
||||
CUtlVector<achievementthink_t> m_vecThinkListeners; // vector of achievements that are actively thinking
|
||||
|
||||
float m_flLevelInitTime;
|
||||
|
||||
float m_flLastClassChangeTime; // Time when player last changed class
|
||||
float m_flTeamplayStartTime; // Time when player joined a non-spectating team. Not updated if she switches game teams; cleared if she joins spectator
|
||||
float m_iMiniroundsCompleted; // # of minirounds played since game start (for maps that have minirounds)
|
||||
char m_szMap[MAX_PATH]; // file base of map name, cached since we access it frequently in this form
|
||||
bool m_bGlobalStateDirty; // do we have interesting state changes that needs to be saved?
|
||||
bool m_bSteamDataDirty; // do we have changes to upload to Steamworks?
|
||||
bool m_bGlobalStateLoaded; // have we loaded global state
|
||||
bool m_bCheatsEverOn; // have cheats ever been turned on in this level
|
||||
float m_flTimeLastSaved; // last time we uploaded to Steam
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN
|
||||
// [dwenger] Steam Cloud Support
|
||||
//=============================================================================
|
||||
|
||||
bool m_bPersistToSteamCloud; // true = persist data to steam cloud
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
CUtlVector<int> m_AchievementsAwarded;
|
||||
};
|
||||
|
||||
// helper functions
|
||||
const char *GetModelName( CBaseEntity *pBaseEntity );
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
bool CalcPlayersOnFriendsList( int iMinPlayers );
|
||||
bool CalcHasNumClanPlayers( int iClanTeammates );
|
||||
int CalcPlayerCount();
|
||||
int CalcTeammateCount();
|
||||
#endif // CLIENT
|
||||
|
||||
class IMatchmaking;
|
||||
extern ConVar cc_achievement_debug;
|
||||
extern IMatchmaking *matchmaking;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void MsgFunc_AchievementEvent( bf_read &msg );
|
||||
#endif // CLIENT_DLL
|
||||
#endif // ACHIEVEMENTMGR_H
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
#define ACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
#include "vgui/ISurface.h"
|
||||
|
||||
class AchievementsAndStatsInterface
|
||||
{
|
||||
public:
|
||||
AchievementsAndStatsInterface() { }
|
||||
|
||||
virtual void CreatePanel( vgui::Panel* pParent ) {}
|
||||
virtual void DisplayPanel() {}
|
||||
virtual void ReleasePanel() {}
|
||||
virtual int GetAchievementsPanelMinWidth( void ) const { return 0; }
|
||||
|
||||
protected:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Positions a dialog on screen.
|
||||
//-----------------------------------------------------------------------------
|
||||
void PositionDialog(vgui::PHandle dlg)
|
||||
{
|
||||
if (!dlg.Get())
|
||||
return;
|
||||
|
||||
int x, y, ww, wt, wide, tall;
|
||||
vgui::surface()->GetWorkspaceBounds( x, y, ww, wt );
|
||||
dlg->GetSize(wide, tall);
|
||||
|
||||
// Center it, keeping requested size
|
||||
dlg->SetPos(x + ((ww - wide) / 2), y + ((wt - tall) / 2));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // ACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
#define ACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
#include "vgui/ISurface.h"
|
||||
|
||||
class AchievementsAndStatsInterface
|
||||
{
|
||||
public:
|
||||
AchievementsAndStatsInterface() { }
|
||||
|
||||
virtual void CreatePanel( vgui::Panel* pParent ) {}
|
||||
virtual void DisplayPanel() {}
|
||||
virtual void ReleasePanel() {}
|
||||
virtual int GetAchievementsPanelMinWidth( void ) const { return 0; }
|
||||
|
||||
protected:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Positions a dialog on screen.
|
||||
//-----------------------------------------------------------------------------
|
||||
void PositionDialog(vgui::PHandle dlg)
|
||||
{
|
||||
if (!dlg.Get())
|
||||
return;
|
||||
|
||||
int x, y, ww, wt, wide, tall;
|
||||
vgui::surface()->GetWorkspaceBounds( x, y, ww, wt );
|
||||
dlg->GetSize(wide, tall);
|
||||
|
||||
// Center it, keeping requested size
|
||||
dlg->SetPos(x + ((ww - wide) / 2), y + ((wt - tall) / 2));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // ACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
|
||||
@@ -1,253 +1,253 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
// this gets compiled in for HL2 + Ep(X) only
|
||||
#if ( defined( HL2_DLL ) || defined( HL2_EPISODIC ) ) && ( !defined ( PORTAL ) )
|
||||
|
||||
#include "baseachievement.h"
|
||||
#include "prop_combine_ball.h"
|
||||
#include "combine_mine.h"
|
||||
#include "basegrenade_shared.h"
|
||||
#include "basehlcombatweapon_shared.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
class CAchievementHLXKillWithPhysicsObjects : public CBaseAchievement
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_physics" );
|
||||
SetGoal( 30 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
int iDamageBits = event->GetInt( "damagebits" );
|
||||
// was victim killed with crushing damage?
|
||||
if ( iDamageBits & DMG_CRUSH )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithPhysicsObjects, ACHIEVEMENT_HLX_KILL_ENEMIES_WITHPHYSICS, "HLX_KILL_ENEMIES_WITHPHYSICS", 5 );
|
||||
|
||||
class CAchievementHLXKillWithHopper : public CBaseAchievement
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetAttackerFilter( "combine_mine" );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// If we get here, a combine mine has killed a player enemy. Now check and see if the player planted it
|
||||
CBounceBomb *pBounceBomb = dynamic_cast<CBounceBomb *>( pAttacker );
|
||||
if ( pBounceBomb && pBounceBomb->IsPlayerPlaced() )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithHopper, ACHIEVEMENT_HLX_KILL_ENEMY_WITHHOPPERMINE, "HLX_KILL_ENEMY_WITHHOPPERMINE", 5 );
|
||||
|
||||
class CAchievementHLXKillWithManhack : public CBaseAchievement
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "npc_manhack" );
|
||||
SetGoal( 5 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in HL2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "hl2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// We've already filtered to only get called when a player enemy gets killed with a manhack. Now just check for the
|
||||
// case of player smashing manhack into something, in which case the manhack is both the victim and inflictor.
|
||||
// If that's not the case, this is a player kill w/manhack.
|
||||
if ( pVictim != pInflictor )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithManhack, ACHIEVEMENT_HLX_KILL_ENEMIES_WITHMANHACK, "HLX_KILL_ENEMIES_WITHMANHACK", 5 );
|
||||
|
||||
class CAchievementHLXKillSoldierWithOwnGrenade : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "npc_grenade_frag" );
|
||||
SetVictimFilter( "npc_combine_s" );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
CBaseGrenade *pGrenade = dynamic_cast<CBaseGrenade *>( pInflictor );
|
||||
if ( pGrenade )
|
||||
{
|
||||
CBaseEntity *pThrower = pGrenade->GetThrower();
|
||||
CBaseEntity *pOriginalThrower = pGrenade->GetOriginalThrower();
|
||||
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
||||
// check if player was most recent thrower, but the victim was the original thrower
|
||||
if ( ( pPlayer == pThrower ) && ( pOriginalThrower == pVictim ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillSoldierWithOwnGrenade, ACHIEVEMENT_HLX_KILL_SOLDIER_WITHHISGRENADE, "HLX_KILL_SOLDIER_WITHHISGRENADE", 10 );
|
||||
|
||||
class CAchievementHLXKillWithOneEnergyBall : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_combine_ball" );
|
||||
SetGoal( 1 );
|
||||
m_pLastInflictor = NULL;
|
||||
m_iLocalCount = 0;
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep1 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "episodic" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// to count # of kills with same energy ball, keep track of previous inflictor
|
||||
if ( m_pLastInflictor != NULL && pInflictor != m_pLastInflictor )
|
||||
{
|
||||
// new inflictor, start the count over at 1
|
||||
m_iLocalCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// same inflictor, keep counting
|
||||
m_iLocalCount++;
|
||||
if ( 5 == m_iLocalCount )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
// keep track of last inflictor
|
||||
m_pLastInflictor = pInflictor;
|
||||
}
|
||||
CBaseEntity *m_pLastInflictor;
|
||||
int m_iLocalCount;
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithOneEnergyBall, ACHIEVEMENT_HLX_KILL_ENEMIES_WITHONEENERGYBALL, "HLX_KILL_ENEMIES_WITHONEENERGYBALL", 5 );
|
||||
|
||||
class CAchievementHLXKillEliteSoldierWithOwnEnergyBall : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_combine_ball" );
|
||||
SetVictimFilter( "npc_combine_s" );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "episodic" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
CPropCombineBall *pBall = dynamic_cast<CPropCombineBall *>( pInflictor );
|
||||
if ( pBall )
|
||||
{
|
||||
// determine original owner of this ball
|
||||
CBaseEntity *pOriginalOwner = pBall->GetOriginalOwner();
|
||||
// see if original owner is the victim
|
||||
if ( pOriginalOwner && ( pOriginalOwner == pVictim ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillEliteSoldierWithOwnEnergyBall, ACHIEVEMENT_HLX_KILL_ELITESOLDIER_WITHHISENERGYBALL, "HLX_KILL_ELITESOLDIER_WITHHISENERGYBALL", 10 );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Counts the accumulated # of primary and secondary attacks from all
|
||||
// weapons (except grav gun). If bBulletOnly is true, only counts
|
||||
// attacks with ammo that does bullet damage.
|
||||
//-----------------------------------------------------------------------------
|
||||
int CalcPlayerAttacks( bool bBulletOnly )
|
||||
{
|
||||
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
||||
CAmmoDef *pAmmoDef = GetAmmoDef();
|
||||
if ( !pPlayer || !pAmmoDef )
|
||||
return 0;
|
||||
|
||||
int iTotalAttacks = 0;
|
||||
int iWeapons = pPlayer->WeaponCount();
|
||||
for ( int i = 0; i < iWeapons; i++ )
|
||||
{
|
||||
CBaseHLCombatWeapon *pWeapon = dynamic_cast<CBaseHLCombatWeapon *>( pPlayer->GetWeapon( i ) );
|
||||
if ( pWeapon )
|
||||
{
|
||||
// add primary attacks if we were asked for all attacks, or only if it uses bullet ammo if we were asked to count bullet attacks
|
||||
if ( !bBulletOnly || ( pAmmoDef->m_AmmoType[pWeapon->GetPrimaryAmmoType()].nDamageType == DMG_BULLET ) )
|
||||
{
|
||||
iTotalAttacks += pWeapon->m_iPrimaryAttacks;
|
||||
}
|
||||
// add secondary attacks if we were asked for all attacks, or only if it uses bullet ammo if we were asked to count bullet attacks
|
||||
if ( !bBulletOnly || ( pAmmoDef->m_AmmoType[pWeapon->GetSecondaryAmmoType()].nDamageType == DMG_BULLET ) )
|
||||
{
|
||||
iTotalAttacks += pWeapon->m_iSecondaryAttacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
return iTotalAttacks;
|
||||
}
|
||||
|
||||
#endif // ( defined( HL2_DLL ) || defined( HL2_EPISODIC ) ) && ( !defined ( PORTAL ) )
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
// this gets compiled in for HL2 + Ep(X) only
|
||||
#if ( defined( HL2_DLL ) || defined( HL2_EPISODIC ) ) && ( !defined ( PORTAL ) )
|
||||
|
||||
#include "baseachievement.h"
|
||||
#include "prop_combine_ball.h"
|
||||
#include "combine_mine.h"
|
||||
#include "basegrenade_shared.h"
|
||||
#include "basehlcombatweapon_shared.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
class CAchievementHLXKillWithPhysicsObjects : public CBaseAchievement
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_physics" );
|
||||
SetGoal( 30 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
int iDamageBits = event->GetInt( "damagebits" );
|
||||
// was victim killed with crushing damage?
|
||||
if ( iDamageBits & DMG_CRUSH )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithPhysicsObjects, ACHIEVEMENT_HLX_KILL_ENEMIES_WITHPHYSICS, "HLX_KILL_ENEMIES_WITHPHYSICS", 5 );
|
||||
|
||||
class CAchievementHLXKillWithHopper : public CBaseAchievement
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetAttackerFilter( "combine_mine" );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// If we get here, a combine mine has killed a player enemy. Now check and see if the player planted it
|
||||
CBounceBomb *pBounceBomb = dynamic_cast<CBounceBomb *>( pAttacker );
|
||||
if ( pBounceBomb && pBounceBomb->IsPlayerPlaced() )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithHopper, ACHIEVEMENT_HLX_KILL_ENEMY_WITHHOPPERMINE, "HLX_KILL_ENEMY_WITHHOPPERMINE", 5 );
|
||||
|
||||
class CAchievementHLXKillWithManhack : public CBaseAchievement
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "npc_manhack" );
|
||||
SetGoal( 5 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in HL2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "hl2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// We've already filtered to only get called when a player enemy gets killed with a manhack. Now just check for the
|
||||
// case of player smashing manhack into something, in which case the manhack is both the victim and inflictor.
|
||||
// If that's not the case, this is a player kill w/manhack.
|
||||
if ( pVictim != pInflictor )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithManhack, ACHIEVEMENT_HLX_KILL_ENEMIES_WITHMANHACK, "HLX_KILL_ENEMIES_WITHMANHACK", 5 );
|
||||
|
||||
class CAchievementHLXKillSoldierWithOwnGrenade : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "npc_grenade_frag" );
|
||||
SetVictimFilter( "npc_combine_s" );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
CBaseGrenade *pGrenade = dynamic_cast<CBaseGrenade *>( pInflictor );
|
||||
if ( pGrenade )
|
||||
{
|
||||
CBaseEntity *pThrower = pGrenade->GetThrower();
|
||||
CBaseEntity *pOriginalThrower = pGrenade->GetOriginalThrower();
|
||||
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
||||
// check if player was most recent thrower, but the victim was the original thrower
|
||||
if ( ( pPlayer == pThrower ) && ( pOriginalThrower == pVictim ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillSoldierWithOwnGrenade, ACHIEVEMENT_HLX_KILL_SOLDIER_WITHHISGRENADE, "HLX_KILL_SOLDIER_WITHHISGRENADE", 10 );
|
||||
|
||||
class CAchievementHLXKillWithOneEnergyBall : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_combine_ball" );
|
||||
SetGoal( 1 );
|
||||
m_pLastInflictor = NULL;
|
||||
m_iLocalCount = 0;
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep1 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "episodic" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// to count # of kills with same energy ball, keep track of previous inflictor
|
||||
if ( m_pLastInflictor != NULL && pInflictor != m_pLastInflictor )
|
||||
{
|
||||
// new inflictor, start the count over at 1
|
||||
m_iLocalCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// same inflictor, keep counting
|
||||
m_iLocalCount++;
|
||||
if ( 5 == m_iLocalCount )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
// keep track of last inflictor
|
||||
m_pLastInflictor = pInflictor;
|
||||
}
|
||||
CBaseEntity *m_pLastInflictor;
|
||||
int m_iLocalCount;
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillWithOneEnergyBall, ACHIEVEMENT_HLX_KILL_ENEMIES_WITHONEENERGYBALL, "HLX_KILL_ENEMIES_WITHONEENERGYBALL", 5 );
|
||||
|
||||
class CAchievementHLXKillEliteSoldierWithOwnEnergyBall : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_combine_ball" );
|
||||
SetVictimFilter( "npc_combine_s" );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across HLX for X360.)
|
||||
SetGameDirFilter( "episodic" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
CPropCombineBall *pBall = dynamic_cast<CPropCombineBall *>( pInflictor );
|
||||
if ( pBall )
|
||||
{
|
||||
// determine original owner of this ball
|
||||
CBaseEntity *pOriginalOwner = pBall->GetOriginalOwner();
|
||||
// see if original owner is the victim
|
||||
if ( pOriginalOwner && ( pOriginalOwner == pVictim ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementHLXKillEliteSoldierWithOwnEnergyBall, ACHIEVEMENT_HLX_KILL_ELITESOLDIER_WITHHISENERGYBALL, "HLX_KILL_ELITESOLDIER_WITHHISENERGYBALL", 10 );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Counts the accumulated # of primary and secondary attacks from all
|
||||
// weapons (except grav gun). If bBulletOnly is true, only counts
|
||||
// attacks with ammo that does bullet damage.
|
||||
//-----------------------------------------------------------------------------
|
||||
int CalcPlayerAttacks( bool bBulletOnly )
|
||||
{
|
||||
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
||||
CAmmoDef *pAmmoDef = GetAmmoDef();
|
||||
if ( !pPlayer || !pAmmoDef )
|
||||
return 0;
|
||||
|
||||
int iTotalAttacks = 0;
|
||||
int iWeapons = pPlayer->WeaponCount();
|
||||
for ( int i = 0; i < iWeapons; i++ )
|
||||
{
|
||||
CBaseHLCombatWeapon *pWeapon = dynamic_cast<CBaseHLCombatWeapon *>( pPlayer->GetWeapon( i ) );
|
||||
if ( pWeapon )
|
||||
{
|
||||
// add primary attacks if we were asked for all attacks, or only if it uses bullet ammo if we were asked to count bullet attacks
|
||||
if ( !bBulletOnly || ( pAmmoDef->m_AmmoType[pWeapon->GetPrimaryAmmoType()].nDamageType == DMG_BULLET ) )
|
||||
{
|
||||
iTotalAttacks += pWeapon->m_iPrimaryAttacks;
|
||||
}
|
||||
// add secondary attacks if we were asked for all attacks, or only if it uses bullet ammo if we were asked to count bullet attacks
|
||||
if ( !bBulletOnly || ( pAmmoDef->m_AmmoType[pWeapon->GetSecondaryAmmoType()].nDamageType == DMG_BULLET ) )
|
||||
{
|
||||
iTotalAttacks += pWeapon->m_iSecondaryAttacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
return iTotalAttacks;
|
||||
}
|
||||
|
||||
#endif // ( defined( HL2_DLL ) || defined( HL2_EPISODIC ) ) && ( !defined ( PORTAL ) )
|
||||
|
||||
#endif // GAME_DLL
|
||||
+2417
-2417
File diff suppressed because it is too large
Load Diff
+100
-100
@@ -1,100 +1,100 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACTIVITYLIST_H
|
||||
#define ACTIVITYLIST_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
|
||||
typedef struct activityentry_s activityentry_t;
|
||||
|
||||
class CActivityRemap
|
||||
{
|
||||
public:
|
||||
|
||||
CActivityRemap()
|
||||
{
|
||||
pExtraBlock = NULL;
|
||||
}
|
||||
|
||||
void SetExtraKeyValueBlock ( KeyValues *pKVBlock )
|
||||
{
|
||||
pExtraBlock = pKVBlock;
|
||||
}
|
||||
|
||||
KeyValues *GetExtraKeyValueBlock ( void ) { return pExtraBlock; }
|
||||
|
||||
Activity activity;
|
||||
Activity mappedActivity;
|
||||
|
||||
private:
|
||||
|
||||
KeyValues *pExtraBlock;
|
||||
};
|
||||
|
||||
|
||||
class CActivityRemapCache
|
||||
{
|
||||
public:
|
||||
|
||||
CActivityRemapCache()
|
||||
{
|
||||
}
|
||||
|
||||
CActivityRemapCache( const CActivityRemapCache& src )
|
||||
{
|
||||
int c = src.m_cachedActivityRemaps.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
m_cachedActivityRemaps.AddToTail( src.m_cachedActivityRemaps[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
CActivityRemapCache& operator = ( const CActivityRemapCache& src )
|
||||
{
|
||||
if ( this == &src )
|
||||
return *this;
|
||||
|
||||
int c = src.m_cachedActivityRemaps.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
m_cachedActivityRemaps.AddToTail( src.m_cachedActivityRemaps[ i ] );
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlVector< CActivityRemap > m_cachedActivityRemaps;
|
||||
};
|
||||
|
||||
void UTIL_LoadActivityRemapFile( const char *filename, const char *section, CUtlVector <CActivityRemap> &entries );
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
extern void ActivityList_Init( void );
|
||||
extern void ActivityList_Free( void );
|
||||
extern bool ActivityList_RegisterSharedActivity( const char *pszActivityName, int iActivityIndex );
|
||||
extern Activity ActivityList_RegisterPrivateActivity( const char *pszActivityName );
|
||||
extern int ActivityList_IndexForName( const char *pszActivityName );
|
||||
extern const char *ActivityList_NameForIndex( int iActivityIndex );
|
||||
extern int ActivityList_HighestIndex();
|
||||
|
||||
// This macro guarantees that the names of each activity and the constant used to
|
||||
// reference it in the code are identical.
|
||||
#define REGISTER_SHARED_ACTIVITY( _n ) ActivityList_RegisterSharedActivity(#_n, _n);
|
||||
#define REGISTER_PRIVATE_ACTIVITY( _n ) _n = ActivityList_RegisterPrivateActivity( #_n );
|
||||
|
||||
// Implemented in shared code
|
||||
extern void ActivityList_RegisterSharedActivities( void );
|
||||
|
||||
class ISaveRestoreOps;
|
||||
extern ISaveRestoreOps* ActivityDataOps();
|
||||
|
||||
#endif // ACTIVITYLIST_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACTIVITYLIST_H
|
||||
#define ACTIVITYLIST_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
|
||||
typedef struct activityentry_s activityentry_t;
|
||||
|
||||
class CActivityRemap
|
||||
{
|
||||
public:
|
||||
|
||||
CActivityRemap()
|
||||
{
|
||||
pExtraBlock = NULL;
|
||||
}
|
||||
|
||||
void SetExtraKeyValueBlock ( KeyValues *pKVBlock )
|
||||
{
|
||||
pExtraBlock = pKVBlock;
|
||||
}
|
||||
|
||||
KeyValues *GetExtraKeyValueBlock ( void ) { return pExtraBlock; }
|
||||
|
||||
Activity activity;
|
||||
Activity mappedActivity;
|
||||
|
||||
private:
|
||||
|
||||
KeyValues *pExtraBlock;
|
||||
};
|
||||
|
||||
|
||||
class CActivityRemapCache
|
||||
{
|
||||
public:
|
||||
|
||||
CActivityRemapCache()
|
||||
{
|
||||
}
|
||||
|
||||
CActivityRemapCache( const CActivityRemapCache& src )
|
||||
{
|
||||
int c = src.m_cachedActivityRemaps.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
m_cachedActivityRemaps.AddToTail( src.m_cachedActivityRemaps[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
CActivityRemapCache& operator = ( const CActivityRemapCache& src )
|
||||
{
|
||||
if ( this == &src )
|
||||
return *this;
|
||||
|
||||
int c = src.m_cachedActivityRemaps.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
m_cachedActivityRemaps.AddToTail( src.m_cachedActivityRemaps[ i ] );
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlVector< CActivityRemap > m_cachedActivityRemaps;
|
||||
};
|
||||
|
||||
void UTIL_LoadActivityRemapFile( const char *filename, const char *section, CUtlVector <CActivityRemap> &entries );
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
extern void ActivityList_Init( void );
|
||||
extern void ActivityList_Free( void );
|
||||
extern bool ActivityList_RegisterSharedActivity( const char *pszActivityName, int iActivityIndex );
|
||||
extern Activity ActivityList_RegisterPrivateActivity( const char *pszActivityName );
|
||||
extern int ActivityList_IndexForName( const char *pszActivityName );
|
||||
extern const char *ActivityList_NameForIndex( int iActivityIndex );
|
||||
extern int ActivityList_HighestIndex();
|
||||
|
||||
// This macro guarantees that the names of each activity and the constant used to
|
||||
// reference it in the code are identical.
|
||||
#define REGISTER_SHARED_ACTIVITY( _n ) ActivityList_RegisterSharedActivity(#_n, _n);
|
||||
#define REGISTER_PRIVATE_ACTIVITY( _n ) _n = ActivityList_RegisterPrivateActivity( #_n );
|
||||
|
||||
// Implemented in shared code
|
||||
extern void ActivityList_RegisterSharedActivities( void );
|
||||
|
||||
class ISaveRestoreOps;
|
||||
extern ISaveRestoreOps* ActivityDataOps();
|
||||
|
||||
#endif // ACTIVITYLIST_H
|
||||
|
||||
+2111
-2111
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,64 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef AI_DEBUG_SHARED_H
|
||||
#define AI_DEBUG_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "tier0/vprof.h"
|
||||
|
||||
|
||||
// This uses VPROF to profile
|
||||
//#define VPROF_AI 1
|
||||
|
||||
|
||||
#ifdef VPROF_AI
|
||||
inline void AI_TraceLine( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask,
|
||||
const IHandleEntity *ignore, int collisionGroup, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceLine" );
|
||||
UTIL_TraceLine( vecAbsStart, vecAbsEnd, mask, ignore, collisionGroup, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceLine( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask,
|
||||
ITraceFilter *pFilter, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceLine" );
|
||||
UTIL_TraceLine( vecAbsStart, vecAbsEnd, mask, pFilter, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceHull( const Vector &vecAbsStart, const Vector &vecAbsEnd, const Vector &hullMin,
|
||||
const Vector &hullMax, unsigned int mask, const IHandleEntity *ignore,
|
||||
int collisionGroup, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceHull" );
|
||||
UTIL_TraceHull( vecAbsStart, vecAbsEnd, hullMin, hullMax, mask, ignore, collisionGroup, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceHull( const Vector &vecAbsStart, const Vector &vecAbsEnd, const Vector &hullMin,
|
||||
const Vector &hullMax, unsigned int mask, ITraceFilter *pFilter, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceHull" );
|
||||
UTIL_TraceHull( vecAbsStart, vecAbsEnd, hullMin, hullMax, mask, pFilter, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceEntity( CBaseEntity *pEntity, const Vector &vecAbsStart, const Vector &vecAbsEnd, unsigned int mask, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceEntity" );
|
||||
UTIL_TraceEntity( pEntity, vecAbsStart, vecAbsEnd, mask, ptr );
|
||||
}
|
||||
|
||||
#else
|
||||
#define AI_TraceLine UTIL_TraceLine
|
||||
#define AI_TraceHull UTIL_TraceHull
|
||||
#define AI_TraceEntity UTIL_TraceEntity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // AI_DEBUG_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef AI_DEBUG_SHARED_H
|
||||
#define AI_DEBUG_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "tier0/vprof.h"
|
||||
|
||||
|
||||
// This uses VPROF to profile
|
||||
//#define VPROF_AI 1
|
||||
|
||||
|
||||
#ifdef VPROF_AI
|
||||
inline void AI_TraceLine( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask,
|
||||
const IHandleEntity *ignore, int collisionGroup, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceLine" );
|
||||
UTIL_TraceLine( vecAbsStart, vecAbsEnd, mask, ignore, collisionGroup, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceLine( const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask,
|
||||
ITraceFilter *pFilter, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceLine" );
|
||||
UTIL_TraceLine( vecAbsStart, vecAbsEnd, mask, pFilter, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceHull( const Vector &vecAbsStart, const Vector &vecAbsEnd, const Vector &hullMin,
|
||||
const Vector &hullMax, unsigned int mask, const IHandleEntity *ignore,
|
||||
int collisionGroup, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceHull" );
|
||||
UTIL_TraceHull( vecAbsStart, vecAbsEnd, hullMin, hullMax, mask, ignore, collisionGroup, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceHull( const Vector &vecAbsStart, const Vector &vecAbsEnd, const Vector &hullMin,
|
||||
const Vector &hullMax, unsigned int mask, ITraceFilter *pFilter, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceHull" );
|
||||
UTIL_TraceHull( vecAbsStart, vecAbsEnd, hullMin, hullMax, mask, pFilter, ptr );
|
||||
}
|
||||
|
||||
inline void AI_TraceEntity( CBaseEntity *pEntity, const Vector &vecAbsStart, const Vector &vecAbsEnd, unsigned int mask, trace_t *ptr )
|
||||
{
|
||||
VPROF( "AI_TraceEntity" );
|
||||
UTIL_TraceEntity( pEntity, vecAbsStart, vecAbsEnd, mask, ptr );
|
||||
}
|
||||
|
||||
#else
|
||||
#define AI_TraceLine UTIL_TraceLine
|
||||
#define AI_TraceHull UTIL_TraceHull
|
||||
#define AI_TraceEntity UTIL_TraceEntity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // AI_DEBUG_SHARED_H
|
||||
|
||||
+295
-295
@@ -1,295 +1,295 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base combat character with no AI
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return a pointer to the Ammo at the Index passed in
|
||||
//-----------------------------------------------------------------------------
|
||||
Ammo_t *CAmmoDef::GetAmmoOfIndex(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex >= m_nAmmoIndex )
|
||||
return NULL;
|
||||
|
||||
return &m_AmmoType[ nAmmoIndex ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::Index(const char *psz)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!psz)
|
||||
return -1;
|
||||
|
||||
for (i = 1; i < m_nAmmoIndex; i++)
|
||||
{
|
||||
if (stricmp( psz, m_AmmoType[i].pName ) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::PlrDamage(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
if ( m_AmmoType[nAmmoIndex].pPlrDmg == USE_CVAR )
|
||||
{
|
||||
if ( m_AmmoType[nAmmoIndex].pPlrDmgCVar )
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pPlrDmgCVar->GetFloat();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pPlrDmg;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::NPCDamage(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
if ( m_AmmoType[nAmmoIndex].pNPCDmg == USE_CVAR )
|
||||
{
|
||||
if ( m_AmmoType[nAmmoIndex].pNPCDmgCVar )
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pNPCDmgCVar->GetFloat();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pNPCDmg;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::MaxCarry(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
if ( m_AmmoType[nAmmoIndex].pMaxCarry == USE_CVAR )
|
||||
{
|
||||
if ( m_AmmoType[nAmmoIndex].pMaxCarryCVar )
|
||||
return m_AmmoType[nAmmoIndex].pMaxCarryCVar->GetFloat();
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pMaxCarry;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::DamageType(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nDamageType;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::Flags(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nFlags;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::MinSplashSize(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 4;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nMinSplashSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::MaxSplashSize(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 8;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nMaxSplashSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::TracerType(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].eTracerType;
|
||||
}
|
||||
|
||||
float CAmmoDef::DamageForce(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].physicsForceImpulse;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Create an Ammo type with the name, decal, and tracer.
|
||||
// Does not increment m_nAmmoIndex because the functions below do so and
|
||||
// are the only entry point.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType, int nFlags, int minSplashSize, int maxSplashSize )
|
||||
{
|
||||
if (m_nAmmoIndex == MAX_AMMO_TYPES)
|
||||
return false;
|
||||
|
||||
int len = strlen(name);
|
||||
m_AmmoType[m_nAmmoIndex].pName = new char[len+1];
|
||||
Q_strncpy(m_AmmoType[m_nAmmoIndex].pName, name,len+1);
|
||||
m_AmmoType[m_nAmmoIndex].nDamageType = damageType;
|
||||
m_AmmoType[m_nAmmoIndex].eTracerType = tracerType;
|
||||
m_AmmoType[m_nAmmoIndex].nMinSplashSize = minSplashSize;
|
||||
m_AmmoType[m_nAmmoIndex].nMaxSplashSize = maxSplashSize;
|
||||
m_AmmoType[m_nAmmoIndex].nFlags = nFlags;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add an ammo type with it's damage & carrying capability specified via cvars
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType,
|
||||
char const* plr_cvar, char const* npc_cvar, char const* carry_cvar,
|
||||
float physicsForceImpulse, int nFlags, int minSplashSize, int maxSplashSize)
|
||||
{
|
||||
if ( AddAmmoType( name, damageType, tracerType, nFlags, minSplashSize, maxSplashSize ) == false )
|
||||
return;
|
||||
|
||||
if (plr_cvar)
|
||||
{
|
||||
m_AmmoType[m_nAmmoIndex].pPlrDmgCVar = cvar->FindVar(plr_cvar);
|
||||
if (!m_AmmoType[m_nAmmoIndex].pPlrDmgCVar)
|
||||
{
|
||||
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,plr_cvar);
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].pPlrDmg = USE_CVAR;
|
||||
}
|
||||
if (npc_cvar)
|
||||
{
|
||||
m_AmmoType[m_nAmmoIndex].pNPCDmgCVar = cvar->FindVar(npc_cvar);
|
||||
if (!m_AmmoType[m_nAmmoIndex].pNPCDmgCVar)
|
||||
{
|
||||
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,npc_cvar);
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].pNPCDmg = USE_CVAR;
|
||||
}
|
||||
if (carry_cvar)
|
||||
{
|
||||
m_AmmoType[m_nAmmoIndex].pMaxCarryCVar= cvar->FindVar(carry_cvar);
|
||||
if (!m_AmmoType[m_nAmmoIndex].pMaxCarryCVar)
|
||||
{
|
||||
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,carry_cvar);
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].pMaxCarry = USE_CVAR;
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].physicsForceImpulse = physicsForceImpulse;
|
||||
m_nAmmoIndex++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add an ammo type with it's damage & carrying capability specified via integers
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType,
|
||||
int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse,
|
||||
int nFlags, int minSplashSize, int maxSplashSize )
|
||||
{
|
||||
if ( AddAmmoType( name, damageType, tracerType, nFlags, minSplashSize, maxSplashSize ) == false )
|
||||
return;
|
||||
|
||||
m_AmmoType[m_nAmmoIndex].pPlrDmg = plr_dmg;
|
||||
m_AmmoType[m_nAmmoIndex].pNPCDmg = npc_dmg;
|
||||
m_AmmoType[m_nAmmoIndex].pMaxCarry = carry;
|
||||
m_AmmoType[m_nAmmoIndex].physicsForceImpulse = physicsForceImpulse;
|
||||
|
||||
m_nAmmoIndex++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
CAmmoDef::CAmmoDef(void)
|
||||
{
|
||||
// Start with an index of 1. Client assumes 0 is an invalid ammo type
|
||||
m_nAmmoIndex = 1;
|
||||
memset( m_AmmoType, 0, sizeof( m_AmmoType ) );
|
||||
}
|
||||
|
||||
CAmmoDef::~CAmmoDef( void )
|
||||
{
|
||||
for ( int i = 1; i < MAX_AMMO_TYPES; i++ )
|
||||
{
|
||||
delete[] m_AmmoType[ i ].pName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base combat character with no AI
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return a pointer to the Ammo at the Index passed in
|
||||
//-----------------------------------------------------------------------------
|
||||
Ammo_t *CAmmoDef::GetAmmoOfIndex(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex >= m_nAmmoIndex )
|
||||
return NULL;
|
||||
|
||||
return &m_AmmoType[ nAmmoIndex ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::Index(const char *psz)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!psz)
|
||||
return -1;
|
||||
|
||||
for (i = 1; i < m_nAmmoIndex; i++)
|
||||
{
|
||||
if (stricmp( psz, m_AmmoType[i].pName ) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::PlrDamage(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
if ( m_AmmoType[nAmmoIndex].pPlrDmg == USE_CVAR )
|
||||
{
|
||||
if ( m_AmmoType[nAmmoIndex].pPlrDmgCVar )
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pPlrDmgCVar->GetFloat();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pPlrDmg;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::NPCDamage(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
if ( m_AmmoType[nAmmoIndex].pNPCDmg == USE_CVAR )
|
||||
{
|
||||
if ( m_AmmoType[nAmmoIndex].pNPCDmgCVar )
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pNPCDmgCVar->GetFloat();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pNPCDmg;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::MaxCarry(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
if ( m_AmmoType[nAmmoIndex].pMaxCarry == USE_CVAR )
|
||||
{
|
||||
if ( m_AmmoType[nAmmoIndex].pMaxCarryCVar )
|
||||
return m_AmmoType[nAmmoIndex].pMaxCarryCVar->GetFloat();
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_AmmoType[nAmmoIndex].pMaxCarry;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::DamageType(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nDamageType;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::Flags(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nFlags;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::MinSplashSize(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 4;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nMinSplashSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::MaxSplashSize(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 8;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].nMaxSplashSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAmmoDef::TracerType(int nAmmoIndex)
|
||||
{
|
||||
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].eTracerType;
|
||||
}
|
||||
|
||||
float CAmmoDef::DamageForce(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return 0;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].physicsForceImpulse;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Create an Ammo type with the name, decal, and tracer.
|
||||
// Does not increment m_nAmmoIndex because the functions below do so and
|
||||
// are the only entry point.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType, int nFlags, int minSplashSize, int maxSplashSize )
|
||||
{
|
||||
if (m_nAmmoIndex == MAX_AMMO_TYPES)
|
||||
return false;
|
||||
|
||||
int len = strlen(name);
|
||||
m_AmmoType[m_nAmmoIndex].pName = new char[len+1];
|
||||
Q_strncpy(m_AmmoType[m_nAmmoIndex].pName, name,len+1);
|
||||
m_AmmoType[m_nAmmoIndex].nDamageType = damageType;
|
||||
m_AmmoType[m_nAmmoIndex].eTracerType = tracerType;
|
||||
m_AmmoType[m_nAmmoIndex].nMinSplashSize = minSplashSize;
|
||||
m_AmmoType[m_nAmmoIndex].nMaxSplashSize = maxSplashSize;
|
||||
m_AmmoType[m_nAmmoIndex].nFlags = nFlags;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add an ammo type with it's damage & carrying capability specified via cvars
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType,
|
||||
char const* plr_cvar, char const* npc_cvar, char const* carry_cvar,
|
||||
float physicsForceImpulse, int nFlags, int minSplashSize, int maxSplashSize)
|
||||
{
|
||||
if ( AddAmmoType( name, damageType, tracerType, nFlags, minSplashSize, maxSplashSize ) == false )
|
||||
return;
|
||||
|
||||
if (plr_cvar)
|
||||
{
|
||||
m_AmmoType[m_nAmmoIndex].pPlrDmgCVar = cvar->FindVar(plr_cvar);
|
||||
if (!m_AmmoType[m_nAmmoIndex].pPlrDmgCVar)
|
||||
{
|
||||
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,plr_cvar);
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].pPlrDmg = USE_CVAR;
|
||||
}
|
||||
if (npc_cvar)
|
||||
{
|
||||
m_AmmoType[m_nAmmoIndex].pNPCDmgCVar = cvar->FindVar(npc_cvar);
|
||||
if (!m_AmmoType[m_nAmmoIndex].pNPCDmgCVar)
|
||||
{
|
||||
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,npc_cvar);
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].pNPCDmg = USE_CVAR;
|
||||
}
|
||||
if (carry_cvar)
|
||||
{
|
||||
m_AmmoType[m_nAmmoIndex].pMaxCarryCVar= cvar->FindVar(carry_cvar);
|
||||
if (!m_AmmoType[m_nAmmoIndex].pMaxCarryCVar)
|
||||
{
|
||||
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,carry_cvar);
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].pMaxCarry = USE_CVAR;
|
||||
}
|
||||
m_AmmoType[m_nAmmoIndex].physicsForceImpulse = physicsForceImpulse;
|
||||
m_nAmmoIndex++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add an ammo type with it's damage & carrying capability specified via integers
|
||||
//-----------------------------------------------------------------------------
|
||||
void CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType,
|
||||
int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse,
|
||||
int nFlags, int minSplashSize, int maxSplashSize )
|
||||
{
|
||||
if ( AddAmmoType( name, damageType, tracerType, nFlags, minSplashSize, maxSplashSize ) == false )
|
||||
return;
|
||||
|
||||
m_AmmoType[m_nAmmoIndex].pPlrDmg = plr_dmg;
|
||||
m_AmmoType[m_nAmmoIndex].pNPCDmg = npc_dmg;
|
||||
m_AmmoType[m_nAmmoIndex].pMaxCarry = carry;
|
||||
m_AmmoType[m_nAmmoIndex].physicsForceImpulse = physicsForceImpulse;
|
||||
|
||||
m_nAmmoIndex++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
CAmmoDef::CAmmoDef(void)
|
||||
{
|
||||
// Start with an index of 1. Client assumes 0 is an invalid ammo type
|
||||
m_nAmmoIndex = 1;
|
||||
memset( m_AmmoType, 0, sizeof( m_AmmoType ) );
|
||||
}
|
||||
|
||||
CAmmoDef::~CAmmoDef( void )
|
||||
{
|
||||
for ( int i = 1; i < MAX_AMMO_TYPES; i++ )
|
||||
{
|
||||
delete[] m_AmmoType[ i ].pName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+103
-103
@@ -1,103 +1,103 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Holds defintion for game ammo types
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef AI_AMMODEF_H
|
||||
#define AI_AMMODEF_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class ConVar;
|
||||
|
||||
struct Ammo_t
|
||||
{
|
||||
char *pName;
|
||||
int nDamageType;
|
||||
int eTracerType;
|
||||
float physicsForceImpulse;
|
||||
int nMinSplashSize;
|
||||
int nMaxSplashSize;
|
||||
|
||||
int nFlags;
|
||||
|
||||
// Values for player/NPC damage and carrying capability
|
||||
// If the integers are set, they override the CVars
|
||||
int pPlrDmg; // CVar for player damage amount
|
||||
int pNPCDmg; // CVar for NPC damage amount
|
||||
int pMaxCarry; // CVar for maximum number can carry
|
||||
const ConVar* pPlrDmgCVar; // CVar for player damage amount
|
||||
const ConVar* pNPCDmgCVar; // CVar for NPC damage amount
|
||||
const ConVar* pMaxCarryCVar; // CVar for maximum number can carry
|
||||
};
|
||||
|
||||
// Used to tell AmmoDef to use the cvars, not the integers
|
||||
#define USE_CVAR -1
|
||||
// Ammo is infinite
|
||||
#define INFINITE_AMMO -2
|
||||
|
||||
enum AmmoTracer_t
|
||||
{
|
||||
TRACER_NONE,
|
||||
TRACER_LINE,
|
||||
TRACER_RAIL,
|
||||
TRACER_BEAM,
|
||||
TRACER_LINE_AND_WHIZ,
|
||||
};
|
||||
|
||||
enum AmmoFlags_t
|
||||
{
|
||||
AMMO_FORCE_DROP_IF_CARRIED = 0x1,
|
||||
AMMO_INTERPRET_PLRDAMAGE_AS_DAMAGE_TO_PLAYER = 0x2,
|
||||
};
|
||||
|
||||
|
||||
#include "shareddefs.h"
|
||||
|
||||
//=============================================================================
|
||||
// >> CAmmoDef
|
||||
//=============================================================================
|
||||
class CAmmoDef
|
||||
{
|
||||
|
||||
public:
|
||||
int m_nAmmoIndex;
|
||||
|
||||
Ammo_t m_AmmoType[MAX_AMMO_TYPES];
|
||||
|
||||
Ammo_t *GetAmmoOfIndex(int nAmmoIndex);
|
||||
int Index(const char *psz);
|
||||
int PlrDamage(int nAmmoIndex);
|
||||
int NPCDamage(int nAmmoIndex);
|
||||
int MaxCarry(int nAmmoIndex);
|
||||
int DamageType(int nAmmoIndex);
|
||||
int TracerType(int nAmmoIndex);
|
||||
float DamageForce(int nAmmoIndex);
|
||||
int MinSplashSize(int nAmmoIndex);
|
||||
int MaxSplashSize(int nAmmoIndex);
|
||||
int Flags(int nAmmoIndex);
|
||||
|
||||
void AddAmmoType(char const* name, int damageType, int tracerType, int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
|
||||
void AddAmmoType(char const* name, int damageType, int tracerType, char const* plr_cvar, char const* npc_var, char const* carry_cvar, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
|
||||
|
||||
CAmmoDef(void);
|
||||
virtual ~CAmmoDef( void );
|
||||
|
||||
private:
|
||||
bool AddAmmoType(char const* name, int damageType, int tracerType, int nFlags, int minSplashSize, int maxSplashSize );
|
||||
};
|
||||
|
||||
|
||||
// Get the global ammodef object. This is usually implemented in each mod's game rules file somewhere,
|
||||
// so the mod can setup custom ammo types.
|
||||
CAmmoDef* GetAmmoDef();
|
||||
|
||||
|
||||
#endif // AI_AMMODEF_H
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Holds defintion for game ammo types
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef AI_AMMODEF_H
|
||||
#define AI_AMMODEF_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class ConVar;
|
||||
|
||||
struct Ammo_t
|
||||
{
|
||||
char *pName;
|
||||
int nDamageType;
|
||||
int eTracerType;
|
||||
float physicsForceImpulse;
|
||||
int nMinSplashSize;
|
||||
int nMaxSplashSize;
|
||||
|
||||
int nFlags;
|
||||
|
||||
// Values for player/NPC damage and carrying capability
|
||||
// If the integers are set, they override the CVars
|
||||
int pPlrDmg; // CVar for player damage amount
|
||||
int pNPCDmg; // CVar for NPC damage amount
|
||||
int pMaxCarry; // CVar for maximum number can carry
|
||||
const ConVar* pPlrDmgCVar; // CVar for player damage amount
|
||||
const ConVar* pNPCDmgCVar; // CVar for NPC damage amount
|
||||
const ConVar* pMaxCarryCVar; // CVar for maximum number can carry
|
||||
};
|
||||
|
||||
// Used to tell AmmoDef to use the cvars, not the integers
|
||||
#define USE_CVAR -1
|
||||
// Ammo is infinite
|
||||
#define INFINITE_AMMO -2
|
||||
|
||||
enum AmmoTracer_t
|
||||
{
|
||||
TRACER_NONE,
|
||||
TRACER_LINE,
|
||||
TRACER_RAIL,
|
||||
TRACER_BEAM,
|
||||
TRACER_LINE_AND_WHIZ,
|
||||
};
|
||||
|
||||
enum AmmoFlags_t
|
||||
{
|
||||
AMMO_FORCE_DROP_IF_CARRIED = 0x1,
|
||||
AMMO_INTERPRET_PLRDAMAGE_AS_DAMAGE_TO_PLAYER = 0x2,
|
||||
};
|
||||
|
||||
|
||||
#include "shareddefs.h"
|
||||
|
||||
//=============================================================================
|
||||
// >> CAmmoDef
|
||||
//=============================================================================
|
||||
class CAmmoDef
|
||||
{
|
||||
|
||||
public:
|
||||
int m_nAmmoIndex;
|
||||
|
||||
Ammo_t m_AmmoType[MAX_AMMO_TYPES];
|
||||
|
||||
Ammo_t *GetAmmoOfIndex(int nAmmoIndex);
|
||||
int Index(const char *psz);
|
||||
int PlrDamage(int nAmmoIndex);
|
||||
int NPCDamage(int nAmmoIndex);
|
||||
int MaxCarry(int nAmmoIndex);
|
||||
int DamageType(int nAmmoIndex);
|
||||
int TracerType(int nAmmoIndex);
|
||||
float DamageForce(int nAmmoIndex);
|
||||
int MinSplashSize(int nAmmoIndex);
|
||||
int MaxSplashSize(int nAmmoIndex);
|
||||
int Flags(int nAmmoIndex);
|
||||
|
||||
void AddAmmoType(char const* name, int damageType, int tracerType, int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
|
||||
void AddAmmoType(char const* name, int damageType, int tracerType, char const* plr_cvar, char const* npc_var, char const* carry_cvar, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
|
||||
|
||||
CAmmoDef(void);
|
||||
virtual ~CAmmoDef( void );
|
||||
|
||||
private:
|
||||
bool AddAmmoType(char const* name, int damageType, int tracerType, int nFlags, int minSplashSize, int maxSplashSize );
|
||||
};
|
||||
|
||||
|
||||
// Get the global ammodef object. This is usually implemented in each mod's game rules file somewhere,
|
||||
// so the mod can setup custom ammo types.
|
||||
CAmmoDef* GetAmmoDef();
|
||||
|
||||
|
||||
#endif // AI_AMMODEF_H
|
||||
|
||||
|
||||
+971
-971
File diff suppressed because it is too large
Load Diff
@@ -1,65 +1,65 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef ANIMATION_H
|
||||
#define ANIMATION_H
|
||||
|
||||
#define ACTIVITY_NOT_AVAILABLE -1
|
||||
|
||||
struct animevent_t;
|
||||
struct studiohdr_t;
|
||||
class CStudioHdr;
|
||||
struct mstudioseqdesc_t;
|
||||
|
||||
int ExtractBbox( CStudioHdr *pstudiohdr, int sequence, Vector& mins, Vector& maxs );
|
||||
|
||||
void IndexModelSequences( CStudioHdr *pstudiohdr );
|
||||
void ResetActivityIndexes( CStudioHdr *pstudiohdr );
|
||||
void VerifySequenceIndex( CStudioHdr *pstudiohdr );
|
||||
int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence = -1 );
|
||||
int SelectHeaviestSequence( CStudioHdr *pstudiohdr, int activity );
|
||||
void SetEventIndexForSequence( mstudioseqdesc_t &seqdesc );
|
||||
void BuildAllAnimationEventIndexes( CStudioHdr *pstudiohdr );
|
||||
void ResetEventIndexes( CStudioHdr *pstudiohdr );
|
||||
|
||||
void GetEyePosition( CStudioHdr *pstudiohdr, Vector &vecEyePosition );
|
||||
|
||||
int LookupActivity( CStudioHdr *pstudiohdr, const char *label );
|
||||
int LookupSequence( CStudioHdr *pstudiohdr, const char *label );
|
||||
|
||||
#define NOMOTION 99999
|
||||
void GetSequenceLinearMotion( CStudioHdr *pstudiohdr, int iSequence, const float poseParameter[], Vector *pVec );
|
||||
|
||||
const char *GetSequenceName( CStudioHdr *pstudiohdr, int sequence );
|
||||
const char *GetSequenceActivityName( CStudioHdr *pstudiohdr, int iSequence );
|
||||
|
||||
int GetSequenceFlags( CStudioHdr *pstudiohdr, int sequence );
|
||||
int GetAnimationEvent( CStudioHdr *pstudiohdr, int sequence, animevent_t *pNPCEvent, float flStart, float flEnd, int index );
|
||||
bool HasAnimationEventOfType( CStudioHdr *pstudiohdr, int sequence, int type );
|
||||
|
||||
int FindTransitionSequence( CStudioHdr *pstudiohdr, int iCurrentSequence, int iGoalSequence, int *piDir );
|
||||
bool GotoSequence( CStudioHdr *pstudiohdr, int iCurrentSequence, float flCurrentCycle, float flCurrentRate, int iGoalSequence, int &nNextSequence, float &flNextCycle, int &iNextDir );
|
||||
|
||||
void SetBodygroup( CStudioHdr *pstudiohdr, int& body, int iGroup, int iValue );
|
||||
int GetBodygroup( CStudioHdr *pstudiohdr, int body, int iGroup );
|
||||
|
||||
const char *GetBodygroupName( CStudioHdr *pstudiohdr, int iGroup );
|
||||
int FindBodygroupByName( CStudioHdr *pstudiohdr, const char *name );
|
||||
int GetBodygroupCount( CStudioHdr *pstudiohdr, int iGroup );
|
||||
int GetNumBodyGroups( CStudioHdr *pstudiohdr );
|
||||
|
||||
int GetSequenceActivity( CStudioHdr *pstudiohdr, int sequence, int *pweight = NULL );
|
||||
|
||||
void GetAttachmentLocalSpace( CStudioHdr *pstudiohdr, int attachIndex, matrix3x4_t &pLocalToWorld );
|
||||
|
||||
float SetBlending( CStudioHdr *pstudiohdr, int sequence, int *pblendings, int iBlender, float flValue );
|
||||
|
||||
int FindHitboxSetByName( CStudioHdr *pstudiohdr, const char *name );
|
||||
const char *GetHitboxSetName( CStudioHdr *pstudiohdr, int setnumber );
|
||||
int GetHitboxSetCount( CStudioHdr *pstudiohdr );
|
||||
|
||||
#endif //ANIMATION_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifndef ANIMATION_H
|
||||
#define ANIMATION_H
|
||||
|
||||
#define ACTIVITY_NOT_AVAILABLE -1
|
||||
|
||||
struct animevent_t;
|
||||
struct studiohdr_t;
|
||||
class CStudioHdr;
|
||||
struct mstudioseqdesc_t;
|
||||
|
||||
int ExtractBbox( CStudioHdr *pstudiohdr, int sequence, Vector& mins, Vector& maxs );
|
||||
|
||||
void IndexModelSequences( CStudioHdr *pstudiohdr );
|
||||
void ResetActivityIndexes( CStudioHdr *pstudiohdr );
|
||||
void VerifySequenceIndex( CStudioHdr *pstudiohdr );
|
||||
int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence = -1 );
|
||||
int SelectHeaviestSequence( CStudioHdr *pstudiohdr, int activity );
|
||||
void SetEventIndexForSequence( mstudioseqdesc_t &seqdesc );
|
||||
void BuildAllAnimationEventIndexes( CStudioHdr *pstudiohdr );
|
||||
void ResetEventIndexes( CStudioHdr *pstudiohdr );
|
||||
|
||||
void GetEyePosition( CStudioHdr *pstudiohdr, Vector &vecEyePosition );
|
||||
|
||||
int LookupActivity( CStudioHdr *pstudiohdr, const char *label );
|
||||
int LookupSequence( CStudioHdr *pstudiohdr, const char *label );
|
||||
|
||||
#define NOMOTION 99999
|
||||
void GetSequenceLinearMotion( CStudioHdr *pstudiohdr, int iSequence, const float poseParameter[], Vector *pVec );
|
||||
|
||||
const char *GetSequenceName( CStudioHdr *pstudiohdr, int sequence );
|
||||
const char *GetSequenceActivityName( CStudioHdr *pstudiohdr, int iSequence );
|
||||
|
||||
int GetSequenceFlags( CStudioHdr *pstudiohdr, int sequence );
|
||||
int GetAnimationEvent( CStudioHdr *pstudiohdr, int sequence, animevent_t *pNPCEvent, float flStart, float flEnd, int index );
|
||||
bool HasAnimationEventOfType( CStudioHdr *pstudiohdr, int sequence, int type );
|
||||
|
||||
int FindTransitionSequence( CStudioHdr *pstudiohdr, int iCurrentSequence, int iGoalSequence, int *piDir );
|
||||
bool GotoSequence( CStudioHdr *pstudiohdr, int iCurrentSequence, float flCurrentCycle, float flCurrentRate, int iGoalSequence, int &nNextSequence, float &flNextCycle, int &iNextDir );
|
||||
|
||||
void SetBodygroup( CStudioHdr *pstudiohdr, int& body, int iGroup, int iValue );
|
||||
int GetBodygroup( CStudioHdr *pstudiohdr, int body, int iGroup );
|
||||
|
||||
const char *GetBodygroupName( CStudioHdr *pstudiohdr, int iGroup );
|
||||
int FindBodygroupByName( CStudioHdr *pstudiohdr, const char *name );
|
||||
int GetBodygroupCount( CStudioHdr *pstudiohdr, int iGroup );
|
||||
int GetNumBodyGroups( CStudioHdr *pstudiohdr );
|
||||
|
||||
int GetSequenceActivity( CStudioHdr *pstudiohdr, int sequence, int *pweight = NULL );
|
||||
|
||||
void GetAttachmentLocalSpace( CStudioHdr *pstudiohdr, int attachIndex, matrix3x4_t &pLocalToWorld );
|
||||
|
||||
float SetBlending( CStudioHdr *pstudiohdr, int sequence, int *pblendings, int iBlender, float flValue );
|
||||
|
||||
int FindHitboxSetByName( CStudioHdr *pstudiohdr, const char *name );
|
||||
const char *GetHitboxSetName( CStudioHdr *pstudiohdr, int setnumber );
|
||||
int GetHitboxSetCount( CStudioHdr *pstudiohdr );
|
||||
|
||||
#endif //ANIMATION_H
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef APPARENT_VELOCITY_HELPER_H
|
||||
#define APPARENT_VELOCITY_HELPER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
inline float CalcDistance( float x, float y )
|
||||
{
|
||||
return x - y;
|
||||
}
|
||||
|
||||
inline float CalcDistance( const Vector &a, const Vector &b )
|
||||
{
|
||||
return a.DistTo( b );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
class CDefaultCalcDistance
|
||||
{
|
||||
public:
|
||||
static inline float CalcDistance( const T &a, const T &b )
|
||||
{
|
||||
return ::CalcDistance( a, b );
|
||||
}
|
||||
};
|
||||
|
||||
class CCalcDistance2D
|
||||
{
|
||||
public:
|
||||
static inline float CalcDistance( const Vector &a, const Vector &b )
|
||||
{
|
||||
return (a-b).Length2D();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class T, class Functor=CDefaultCalcDistance<T> >
|
||||
class CApparentVelocity
|
||||
{
|
||||
public:
|
||||
CApparentVelocity()
|
||||
{
|
||||
m_LastTime = -1;
|
||||
}
|
||||
|
||||
float AddSample( float time, T value )
|
||||
{
|
||||
float flRet = 0;
|
||||
if ( m_LastTime != -1 )
|
||||
{
|
||||
flRet = Functor::CalcDistance(value, m_LastValue) / (time - m_LastTime);
|
||||
}
|
||||
|
||||
m_LastTime = time;
|
||||
m_LastValue = value;
|
||||
|
||||
return flRet;
|
||||
}
|
||||
|
||||
private:
|
||||
T m_LastValue;
|
||||
float m_LastTime;
|
||||
};
|
||||
|
||||
|
||||
#endif // APPARENT_VELOCITY_HELPER_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef APPARENT_VELOCITY_HELPER_H
|
||||
#define APPARENT_VELOCITY_HELPER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
inline float CalcDistance( float x, float y )
|
||||
{
|
||||
return x - y;
|
||||
}
|
||||
|
||||
inline float CalcDistance( const Vector &a, const Vector &b )
|
||||
{
|
||||
return a.DistTo( b );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
class CDefaultCalcDistance
|
||||
{
|
||||
public:
|
||||
static inline float CalcDistance( const T &a, const T &b )
|
||||
{
|
||||
return ::CalcDistance( a, b );
|
||||
}
|
||||
};
|
||||
|
||||
class CCalcDistance2D
|
||||
{
|
||||
public:
|
||||
static inline float CalcDistance( const Vector &a, const Vector &b )
|
||||
{
|
||||
return (a-b).Length2D();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class T, class Functor=CDefaultCalcDistance<T> >
|
||||
class CApparentVelocity
|
||||
{
|
||||
public:
|
||||
CApparentVelocity()
|
||||
{
|
||||
m_LastTime = -1;
|
||||
}
|
||||
|
||||
float AddSample( float time, T value )
|
||||
{
|
||||
float flRet = 0;
|
||||
if ( m_LastTime != -1 )
|
||||
{
|
||||
flRet = Functor::CalcDistance(value, m_LastValue) / (time - m_LastTime);
|
||||
}
|
||||
|
||||
m_LastTime = time;
|
||||
m_LastValue = value;
|
||||
|
||||
return flRet;
|
||||
}
|
||||
|
||||
private:
|
||||
T m_LastValue;
|
||||
float m_LastTime;
|
||||
};
|
||||
|
||||
|
||||
#endif // APPARENT_VELOCITY_HELPER_H
|
||||
|
||||
+1079
-1079
File diff suppressed because it is too large
Load Diff
@@ -1,287 +1,287 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASE_PLAYERANIMSTATE_H
|
||||
#define BASE_PLAYERANIMSTATE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "iplayeranimstate.h"
|
||||
#include "studio.h"
|
||||
#include "sequence_Transitioner.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
class C_BaseAnimatingOverlay;
|
||||
#define CBaseAnimatingOverlay C_BaseAnimatingOverlay
|
||||
#else
|
||||
class CBaseAnimatingOverlay;
|
||||
#endif
|
||||
|
||||
// If a guy is moving slower than this, then he's considered to not be moving
|
||||
// (so he goes to his idle animation at full playback rate rather than his walk
|
||||
// animation at low playback rate).
|
||||
#define MOVING_MINIMUM_SPEED 0.5f
|
||||
|
||||
|
||||
#define MAIN_IDLE_SEQUENCE_LAYER 0 // For 8-way blended models, this layer blends an idle on top of the run/walk animation to simulate a 9-way blend.
|
||||
// For 9-way blended models, we don't use this layer.
|
||||
|
||||
#define AIMSEQUENCE_LAYER 1 // Aim sequence uses layers 0 and 1 for the weapon idle animation (needs 2 layers so it can blend).
|
||||
#define NUM_AIMSEQUENCE_LAYERS 4 // Then it uses layers 2 and 3 to blend in the weapon run/walk/crouchwalk animation.
|
||||
|
||||
|
||||
// Everyone who derives from CBasePlayerAnimState gets to fill in this info
|
||||
// to drive how the animation state is generated.
|
||||
class CModAnimConfig
|
||||
{
|
||||
public:
|
||||
// This tells how far the upper body can rotate left and right. If he begins to rotate
|
||||
// past this, it'll turn his feet to face his upper body.
|
||||
float m_flMaxBodyYawDegrees;
|
||||
|
||||
// How do the legs animate?
|
||||
LegAnimType_t m_LegAnimType;
|
||||
|
||||
// Use aim sequences? (CS hostages don't).
|
||||
bool m_bUseAimSequences;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------ //
|
||||
// CBasePlayerAnimState declaration.
|
||||
// ------------------------------------------------------------------------------------------------ //
|
||||
|
||||
abstract_class CBasePlayerAnimState : virtual public IPlayerAnimState
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_NOBASE( CBasePlayerAnimState );
|
||||
|
||||
enum
|
||||
{
|
||||
TURN_NONE = 0,
|
||||
TURN_LEFT,
|
||||
TURN_RIGHT
|
||||
};
|
||||
|
||||
CBasePlayerAnimState();
|
||||
virtual ~CBasePlayerAnimState();
|
||||
|
||||
void Init( CBaseAnimatingOverlay *pPlayer, const CModAnimConfig &config );
|
||||
virtual void Release();
|
||||
|
||||
// Update() and DoAnimationEvent() together maintain the entire player's animation state.
|
||||
//
|
||||
// Update() maintains the the lower body animation (the player's m_nSequence)
|
||||
// and the upper body overlay based on the player's velocity and look direction.
|
||||
//
|
||||
// It also modulates these based on events triggered by DoAnimationEvent.
|
||||
virtual void Update( float eyeYaw, float eyePitch );
|
||||
|
||||
// This is called by the client when a new player enters the PVS to clear any events
|
||||
// the dormant version of the entity may have been playing.
|
||||
virtual void ClearAnimationState();
|
||||
|
||||
// This is called every frame to prepare the animation layers to be filled with data
|
||||
// since we reconstruct them every frame (in case they get stomped by the networking
|
||||
// or anything else).
|
||||
virtual void ClearAnimationLayers();
|
||||
|
||||
// The client uses this to figure out what angles to render the entity with (since as the guy turns,
|
||||
// it will change his body_yaw pose parameter before changing his rendered angle).
|
||||
virtual const QAngle& GetRenderAngles();
|
||||
|
||||
|
||||
// Overrideables.
|
||||
public:
|
||||
|
||||
virtual bool ShouldUpdateAnimState();
|
||||
|
||||
// This is called near the start of each frame.
|
||||
// The base class figures out the main sequence and the aim sequence, and derived
|
||||
// classes can overlay whatever other animations they want.
|
||||
virtual void ComputeSequences( CStudioHdr *pStudioHdr );
|
||||
|
||||
// This is called to figure out what the main activity is. The mod-specific class
|
||||
// overrides this to handle events like jumping, firing, etc.
|
||||
virtual Activity CalcMainActivity() = 0;
|
||||
|
||||
// This is called to calculate the aim layer sequence. It usually figures out the
|
||||
// animation prefixes and suffixes and calls CalcSequenceIndex().
|
||||
virtual int CalcAimLayerSequence( float *flCycle, float *flAimSequenceWeight, bool bForceIdle ) = 0;
|
||||
|
||||
// This lets server-controlled idle sequences to play unchanged on the client
|
||||
virtual bool ShouldChangeSequences( void ) const;
|
||||
|
||||
// If this returns true, then it will blend the current aim layer sequence with an idle aim layer
|
||||
// sequence based on how fast the character is moving, so it doesn't play the upper-body run at
|
||||
// full speed if he's moving really slowly.
|
||||
//
|
||||
// We return false on this for animations that don't have blends, like reloads.
|
||||
virtual bool ShouldBlendAimSequenceToIdle();
|
||||
|
||||
// For the body left/right rotation, some models use a pose parameter and some use a bone controller.
|
||||
virtual float SetOuterBodyYaw( float flValue );
|
||||
|
||||
// Return true if the player is allowed to move.
|
||||
virtual bool CanThePlayerMove();
|
||||
|
||||
// This is called every frame to see what the maximum speed the player can move is.
|
||||
// It is used to determine where to put the move_x/move_y pose parameters or to
|
||||
// determine the animation playback rate, based on the player's movement speed.
|
||||
// The return value from here is interpolated so the playback rate or pose params don't move sharply.
|
||||
virtual float GetCurrentMaxGroundSpeed() = 0;
|
||||
|
||||
// Display Con_NPrint output about the animation state. This is called if
|
||||
// we're on the client and if cl_showanimstate holds the current entity's index.
|
||||
void DebugShowAnimStateFull( int iStartLine );
|
||||
|
||||
virtual void DebugShowAnimState( int iStartLine );
|
||||
void AnimStatePrintf( int iLine, PRINTF_FORMAT_STRING const char *pMsg, ... );
|
||||
void AnimStateLog( PRINTF_FORMAT_STRING const char *pMsg, ... );
|
||||
|
||||
// Calculate the playback rate for movement layer
|
||||
virtual float CalcMovementPlaybackRate( bool *bIsMoving );
|
||||
|
||||
// Allow inheriting classes to translate their desired activity, while keeping all
|
||||
// internal ACT comparisons using the base activity
|
||||
virtual Activity TranslateActivity( Activity actDesired ) { return actDesired; }
|
||||
|
||||
// Allow inheriting classes to override SelectWeightedSequence
|
||||
virtual int SelectWeightedSequence( Activity activity );
|
||||
|
||||
public:
|
||||
|
||||
void GetPoseParameters( CStudioHdr *pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM] );
|
||||
|
||||
CBaseAnimatingOverlay *GetOuter() const;
|
||||
|
||||
void RestartMainSequence();
|
||||
|
||||
|
||||
// Helpers for the derived classes to use.
|
||||
protected:
|
||||
|
||||
// Sets up the string you specify, looks for that sequence and returns the index.
|
||||
// Complains in the console and returns 0 if it can't find it.
|
||||
virtual int CalcSequenceIndex( PRINTF_FORMAT_STRING const char *pBaseName, ... );
|
||||
|
||||
Activity GetCurrentMainSequenceActivity() const;
|
||||
|
||||
void GetOuterAbsVelocity( Vector& vel ) const;
|
||||
float GetOuterXYSpeed() const;
|
||||
|
||||
// How long has it been since we cleared the animation state?
|
||||
float TimeSinceLastAnimationStateClear() const;
|
||||
|
||||
float GetEyeYaw() const { return m_flEyeYaw; }
|
||||
|
||||
protected:
|
||||
|
||||
CModAnimConfig m_AnimConfig;
|
||||
CBaseAnimatingOverlay *m_pOuter;
|
||||
|
||||
protected:
|
||||
int ConvergeAngles( float goal,float maxrate, float maxgap, float dt, float& current );
|
||||
virtual void ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_BodyPitch( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_BodyYaw();
|
||||
|
||||
virtual void ResetGroundSpeed( void );
|
||||
|
||||
protected:
|
||||
// The player's eye yaw and pitch angles.
|
||||
float m_flEyeYaw;
|
||||
float m_flEyePitch;
|
||||
|
||||
// The following variables are used for tweaking the yaw of the upper body when standing still and
|
||||
// making sure that it smoothly blends in and out once the player starts moving
|
||||
// Direction feet were facing when we stopped moving
|
||||
float m_flGoalFeetYaw;
|
||||
|
||||
float m_flCurrentFeetYaw;
|
||||
bool m_bCurrentFeetYawInitialized;
|
||||
|
||||
float m_flCurrentTorsoYaw;
|
||||
|
||||
// To check if they are rotating in place
|
||||
float m_flLastYaw;
|
||||
|
||||
// Time when we stopped moving
|
||||
float m_flLastTurnTime;
|
||||
|
||||
// One of the above enums
|
||||
int m_nTurningInPlace;
|
||||
|
||||
QAngle m_angRender;
|
||||
|
||||
private:
|
||||
|
||||
// Update the prone state machine.
|
||||
void UpdateProneState();
|
||||
|
||||
// Get the string that's appended to animation names for the player's current weapon.
|
||||
const char* GetWeaponSuffix();
|
||||
|
||||
Activity BodyYawTranslateActivity( Activity activity );
|
||||
|
||||
void SetOuterPoseParameter( int iParam, float flValue );
|
||||
|
||||
|
||||
void EstimateYaw();
|
||||
|
||||
void ComputeMainSequence();
|
||||
void ComputeAimSequence();
|
||||
|
||||
void ComputePlaybackRate();
|
||||
|
||||
void UpdateInterpolators();
|
||||
float GetInterpolatedGroundSpeed();
|
||||
|
||||
private:
|
||||
|
||||
float m_flMaxGroundSpeed;
|
||||
|
||||
float m_flLastAnimationStateClearTime;
|
||||
|
||||
// If he's using 8-way blending, then we blend to this idle
|
||||
int m_iCurrent8WayIdleSequence;
|
||||
int m_iCurrent8WayCrouchIdleSequence;
|
||||
|
||||
// Last activity we've used on the lower body. Used to determine if animations should restart.
|
||||
Activity m_eCurrentMainSequenceActivity;
|
||||
|
||||
float m_flGaitYaw;
|
||||
float m_flStoredCycle;
|
||||
|
||||
Vector2D m_vLastMovePose;
|
||||
|
||||
void UpdateAimSequenceLayers(
|
||||
float flCycle,
|
||||
int iFirstLayer,
|
||||
bool bForceIdle,
|
||||
CSequenceTransitioner *pTransitioner,
|
||||
float flWeightScale
|
||||
);
|
||||
|
||||
void OptimizeLayerWeights( int iFirstLayer, int nLayers );
|
||||
|
||||
// This gives us smooth transitions between aim anim sequences on the client.
|
||||
CSequenceTransitioner m_IdleSequenceTransitioner;
|
||||
CSequenceTransitioner m_SequenceTransitioner;
|
||||
};
|
||||
|
||||
extern float g_flLastBodyPitch, g_flLastBodyYaw, m_flLastMoveYaw;
|
||||
|
||||
|
||||
inline Activity CBasePlayerAnimState::GetCurrentMainSequenceActivity() const
|
||||
{
|
||||
return m_eCurrentMainSequenceActivity;
|
||||
}
|
||||
|
||||
|
||||
#endif // BASE_PLAYERANIMSTATE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASE_PLAYERANIMSTATE_H
|
||||
#define BASE_PLAYERANIMSTATE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "iplayeranimstate.h"
|
||||
#include "studio.h"
|
||||
#include "sequence_Transitioner.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
class C_BaseAnimatingOverlay;
|
||||
#define CBaseAnimatingOverlay C_BaseAnimatingOverlay
|
||||
#else
|
||||
class CBaseAnimatingOverlay;
|
||||
#endif
|
||||
|
||||
// If a guy is moving slower than this, then he's considered to not be moving
|
||||
// (so he goes to his idle animation at full playback rate rather than his walk
|
||||
// animation at low playback rate).
|
||||
#define MOVING_MINIMUM_SPEED 0.5f
|
||||
|
||||
|
||||
#define MAIN_IDLE_SEQUENCE_LAYER 0 // For 8-way blended models, this layer blends an idle on top of the run/walk animation to simulate a 9-way blend.
|
||||
// For 9-way blended models, we don't use this layer.
|
||||
|
||||
#define AIMSEQUENCE_LAYER 1 // Aim sequence uses layers 0 and 1 for the weapon idle animation (needs 2 layers so it can blend).
|
||||
#define NUM_AIMSEQUENCE_LAYERS 4 // Then it uses layers 2 and 3 to blend in the weapon run/walk/crouchwalk animation.
|
||||
|
||||
|
||||
// Everyone who derives from CBasePlayerAnimState gets to fill in this info
|
||||
// to drive how the animation state is generated.
|
||||
class CModAnimConfig
|
||||
{
|
||||
public:
|
||||
// This tells how far the upper body can rotate left and right. If he begins to rotate
|
||||
// past this, it'll turn his feet to face his upper body.
|
||||
float m_flMaxBodyYawDegrees;
|
||||
|
||||
// How do the legs animate?
|
||||
LegAnimType_t m_LegAnimType;
|
||||
|
||||
// Use aim sequences? (CS hostages don't).
|
||||
bool m_bUseAimSequences;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------ //
|
||||
// CBasePlayerAnimState declaration.
|
||||
// ------------------------------------------------------------------------------------------------ //
|
||||
|
||||
abstract_class CBasePlayerAnimState : virtual public IPlayerAnimState
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_NOBASE( CBasePlayerAnimState );
|
||||
|
||||
enum
|
||||
{
|
||||
TURN_NONE = 0,
|
||||
TURN_LEFT,
|
||||
TURN_RIGHT
|
||||
};
|
||||
|
||||
CBasePlayerAnimState();
|
||||
virtual ~CBasePlayerAnimState();
|
||||
|
||||
void Init( CBaseAnimatingOverlay *pPlayer, const CModAnimConfig &config );
|
||||
virtual void Release();
|
||||
|
||||
// Update() and DoAnimationEvent() together maintain the entire player's animation state.
|
||||
//
|
||||
// Update() maintains the the lower body animation (the player's m_nSequence)
|
||||
// and the upper body overlay based on the player's velocity and look direction.
|
||||
//
|
||||
// It also modulates these based on events triggered by DoAnimationEvent.
|
||||
virtual void Update( float eyeYaw, float eyePitch );
|
||||
|
||||
// This is called by the client when a new player enters the PVS to clear any events
|
||||
// the dormant version of the entity may have been playing.
|
||||
virtual void ClearAnimationState();
|
||||
|
||||
// This is called every frame to prepare the animation layers to be filled with data
|
||||
// since we reconstruct them every frame (in case they get stomped by the networking
|
||||
// or anything else).
|
||||
virtual void ClearAnimationLayers();
|
||||
|
||||
// The client uses this to figure out what angles to render the entity with (since as the guy turns,
|
||||
// it will change his body_yaw pose parameter before changing his rendered angle).
|
||||
virtual const QAngle& GetRenderAngles();
|
||||
|
||||
|
||||
// Overrideables.
|
||||
public:
|
||||
|
||||
virtual bool ShouldUpdateAnimState();
|
||||
|
||||
// This is called near the start of each frame.
|
||||
// The base class figures out the main sequence and the aim sequence, and derived
|
||||
// classes can overlay whatever other animations they want.
|
||||
virtual void ComputeSequences( CStudioHdr *pStudioHdr );
|
||||
|
||||
// This is called to figure out what the main activity is. The mod-specific class
|
||||
// overrides this to handle events like jumping, firing, etc.
|
||||
virtual Activity CalcMainActivity() = 0;
|
||||
|
||||
// This is called to calculate the aim layer sequence. It usually figures out the
|
||||
// animation prefixes and suffixes and calls CalcSequenceIndex().
|
||||
virtual int CalcAimLayerSequence( float *flCycle, float *flAimSequenceWeight, bool bForceIdle ) = 0;
|
||||
|
||||
// This lets server-controlled idle sequences to play unchanged on the client
|
||||
virtual bool ShouldChangeSequences( void ) const;
|
||||
|
||||
// If this returns true, then it will blend the current aim layer sequence with an idle aim layer
|
||||
// sequence based on how fast the character is moving, so it doesn't play the upper-body run at
|
||||
// full speed if he's moving really slowly.
|
||||
//
|
||||
// We return false on this for animations that don't have blends, like reloads.
|
||||
virtual bool ShouldBlendAimSequenceToIdle();
|
||||
|
||||
// For the body left/right rotation, some models use a pose parameter and some use a bone controller.
|
||||
virtual float SetOuterBodyYaw( float flValue );
|
||||
|
||||
// Return true if the player is allowed to move.
|
||||
virtual bool CanThePlayerMove();
|
||||
|
||||
// This is called every frame to see what the maximum speed the player can move is.
|
||||
// It is used to determine where to put the move_x/move_y pose parameters or to
|
||||
// determine the animation playback rate, based on the player's movement speed.
|
||||
// The return value from here is interpolated so the playback rate or pose params don't move sharply.
|
||||
virtual float GetCurrentMaxGroundSpeed() = 0;
|
||||
|
||||
// Display Con_NPrint output about the animation state. This is called if
|
||||
// we're on the client and if cl_showanimstate holds the current entity's index.
|
||||
void DebugShowAnimStateFull( int iStartLine );
|
||||
|
||||
virtual void DebugShowAnimState( int iStartLine );
|
||||
void AnimStatePrintf( int iLine, PRINTF_FORMAT_STRING const char *pMsg, ... );
|
||||
void AnimStateLog( PRINTF_FORMAT_STRING const char *pMsg, ... );
|
||||
|
||||
// Calculate the playback rate for movement layer
|
||||
virtual float CalcMovementPlaybackRate( bool *bIsMoving );
|
||||
|
||||
// Allow inheriting classes to translate their desired activity, while keeping all
|
||||
// internal ACT comparisons using the base activity
|
||||
virtual Activity TranslateActivity( Activity actDesired ) { return actDesired; }
|
||||
|
||||
// Allow inheriting classes to override SelectWeightedSequence
|
||||
virtual int SelectWeightedSequence( Activity activity );
|
||||
|
||||
public:
|
||||
|
||||
void GetPoseParameters( CStudioHdr *pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM] );
|
||||
|
||||
CBaseAnimatingOverlay *GetOuter() const;
|
||||
|
||||
void RestartMainSequence();
|
||||
|
||||
|
||||
// Helpers for the derived classes to use.
|
||||
protected:
|
||||
|
||||
// Sets up the string you specify, looks for that sequence and returns the index.
|
||||
// Complains in the console and returns 0 if it can't find it.
|
||||
virtual int CalcSequenceIndex( PRINTF_FORMAT_STRING const char *pBaseName, ... );
|
||||
|
||||
Activity GetCurrentMainSequenceActivity() const;
|
||||
|
||||
void GetOuterAbsVelocity( Vector& vel ) const;
|
||||
float GetOuterXYSpeed() const;
|
||||
|
||||
// How long has it been since we cleared the animation state?
|
||||
float TimeSinceLastAnimationStateClear() const;
|
||||
|
||||
float GetEyeYaw() const { return m_flEyeYaw; }
|
||||
|
||||
protected:
|
||||
|
||||
CModAnimConfig m_AnimConfig;
|
||||
CBaseAnimatingOverlay *m_pOuter;
|
||||
|
||||
protected:
|
||||
int ConvergeAngles( float goal,float maxrate, float maxgap, float dt, float& current );
|
||||
virtual void ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_BodyPitch( CStudioHdr *pStudioHdr );
|
||||
virtual void ComputePoseParam_BodyYaw();
|
||||
|
||||
virtual void ResetGroundSpeed( void );
|
||||
|
||||
protected:
|
||||
// The player's eye yaw and pitch angles.
|
||||
float m_flEyeYaw;
|
||||
float m_flEyePitch;
|
||||
|
||||
// The following variables are used for tweaking the yaw of the upper body when standing still and
|
||||
// making sure that it smoothly blends in and out once the player starts moving
|
||||
// Direction feet were facing when we stopped moving
|
||||
float m_flGoalFeetYaw;
|
||||
|
||||
float m_flCurrentFeetYaw;
|
||||
bool m_bCurrentFeetYawInitialized;
|
||||
|
||||
float m_flCurrentTorsoYaw;
|
||||
|
||||
// To check if they are rotating in place
|
||||
float m_flLastYaw;
|
||||
|
||||
// Time when we stopped moving
|
||||
float m_flLastTurnTime;
|
||||
|
||||
// One of the above enums
|
||||
int m_nTurningInPlace;
|
||||
|
||||
QAngle m_angRender;
|
||||
|
||||
private:
|
||||
|
||||
// Update the prone state machine.
|
||||
void UpdateProneState();
|
||||
|
||||
// Get the string that's appended to animation names for the player's current weapon.
|
||||
const char* GetWeaponSuffix();
|
||||
|
||||
Activity BodyYawTranslateActivity( Activity activity );
|
||||
|
||||
void SetOuterPoseParameter( int iParam, float flValue );
|
||||
|
||||
|
||||
void EstimateYaw();
|
||||
|
||||
void ComputeMainSequence();
|
||||
void ComputeAimSequence();
|
||||
|
||||
void ComputePlaybackRate();
|
||||
|
||||
void UpdateInterpolators();
|
||||
float GetInterpolatedGroundSpeed();
|
||||
|
||||
private:
|
||||
|
||||
float m_flMaxGroundSpeed;
|
||||
|
||||
float m_flLastAnimationStateClearTime;
|
||||
|
||||
// If he's using 8-way blending, then we blend to this idle
|
||||
int m_iCurrent8WayIdleSequence;
|
||||
int m_iCurrent8WayCrouchIdleSequence;
|
||||
|
||||
// Last activity we've used on the lower body. Used to determine if animations should restart.
|
||||
Activity m_eCurrentMainSequenceActivity;
|
||||
|
||||
float m_flGaitYaw;
|
||||
float m_flStoredCycle;
|
||||
|
||||
Vector2D m_vLastMovePose;
|
||||
|
||||
void UpdateAimSequenceLayers(
|
||||
float flCycle,
|
||||
int iFirstLayer,
|
||||
bool bForceIdle,
|
||||
CSequenceTransitioner *pTransitioner,
|
||||
float flWeightScale
|
||||
);
|
||||
|
||||
void OptimizeLayerWeights( int iFirstLayer, int nLayers );
|
||||
|
||||
// This gives us smooth transitions between aim anim sequences on the client.
|
||||
CSequenceTransitioner m_IdleSequenceTransitioner;
|
||||
CSequenceTransitioner m_SequenceTransitioner;
|
||||
};
|
||||
|
||||
extern float g_flLastBodyPitch, g_flLastBodyYaw, m_flLastMoveYaw;
|
||||
|
||||
|
||||
inline Activity CBasePlayerAnimState::GetCurrentMainSequenceActivity() const
|
||||
{
|
||||
return m_eCurrentMainSequenceActivity;
|
||||
}
|
||||
|
||||
|
||||
#endif // BASE_PLAYERANIMSTATE_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,267 +1,267 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BASEACHIEVEMENT_H
|
||||
#define BASEACHIEVEMENT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "GameEventListener.h"
|
||||
#include "hl2orange.spa.h"
|
||||
#include "iachievementmgr.h"
|
||||
|
||||
class CAchievementMgr;
|
||||
|
||||
//
|
||||
// Base class for achievements
|
||||
//
|
||||
|
||||
class CBaseAchievement : public CGameEventListener, public IAchievement
|
||||
{
|
||||
DECLARE_CLASS_NOBASE( CBaseAchievement );
|
||||
public:
|
||||
CBaseAchievement();
|
||||
virtual ~CBaseAchievement();
|
||||
virtual void Init() {}
|
||||
virtual void ListenForEvents() {};
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event );
|
||||
|
||||
int GetAchievementID() { return m_iAchievementID; }
|
||||
void SetAchievementID( int iAchievementID ) { m_iAchievementID = iAchievementID; }
|
||||
void SetName( const char *pszName ) { m_pszName = pszName; }
|
||||
const char *GetName() { return m_pszName; }
|
||||
const char *GetStat() { return m_pszStat?m_pszStat:GetName(); }
|
||||
void SetFlags( int iFlags );
|
||||
int GetFlags() { return m_iFlags; }
|
||||
void SetGoal( int iGoal ) { m_iGoal = iGoal; }
|
||||
int GetGoal() { return m_iGoal; }
|
||||
void SetGameDirFilter( const char *pGameDir );
|
||||
bool HasComponents() { return ( m_iFlags & ACH_HAS_COMPONENTS ) > 0; }
|
||||
void SetPointValue( int iPointValue ) { m_iPointValue = iPointValue; }
|
||||
int GetPointValue() { return m_iPointValue; }
|
||||
bool ShouldHideUntilAchieved() { return m_bHideUntilAchieved; }
|
||||
void SetHideUntilAchieved( bool bHide ) { m_bHideUntilAchieved = bHide; }
|
||||
void SetStoreProgressInSteam( bool bStoreProgressInSteam ) { m_bStoreProgressInSteam = bStoreProgressInSteam; }
|
||||
bool StoreProgressInSteam() { return m_bStoreProgressInSteam; }
|
||||
virtual bool ShouldShowProgressNotification() { return true; }
|
||||
virtual void OnPlayerStatsUpdate() {}
|
||||
|
||||
virtual bool ShouldSaveWithGame();
|
||||
bool ShouldSaveGlobal();
|
||||
virtual void PreRestoreSavedGame();
|
||||
virtual void PostRestoreSavedGame();
|
||||
void SetCount( int iCount ) { m_iCount = iCount; }
|
||||
int GetCount() { return m_iCount; }
|
||||
void SetProgressShown( int iProgressShown ) { m_iProgressShown = iProgressShown; }
|
||||
int GetProgressShown() { return m_iProgressShown; }
|
||||
virtual bool IsAchieved() { return m_bAchieved; }
|
||||
virtual bool IsActive();
|
||||
virtual bool LocalPlayerCanEarn( void ) { return true; }
|
||||
void SetAchieved( bool bAchieved ) { m_bAchieved = bAchieved; }
|
||||
virtual bool IsMetaAchievement() { return false; }
|
||||
virtual bool AlwaysListen() { return false; }
|
||||
virtual bool AlwaysEnabled() { return false; }
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [pfreese] Notification method for derived classes
|
||||
//=============================================================================
|
||||
|
||||
virtual void OnAchieved() {}
|
||||
uint32 GetUnlockTime() const { return m_uUnlockTime; }
|
||||
void SetUnlockTime( uint32 unlockTime ) { m_uUnlockTime = unlockTime; }
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
uint64 GetComponentBits() { return m_iComponentBits; }
|
||||
void SetComponentBits( uint64 iComponentBits );
|
||||
void OnComponentEvent( const char *pchComponentName );
|
||||
void EnsureComponentBitSetAndEvaluate( int iBitNumber );
|
||||
void EvaluateIsAlreadyAchieved();
|
||||
virtual void OnMapEvent( const char *pEventName );
|
||||
virtual void PrintAdditionalStatus() {} // for debugging, achievements may report additional status in achievement_status concmd
|
||||
virtual void OnSteamUserStatsStored() {}
|
||||
virtual void UpdateAchievement( int nData ) {}
|
||||
virtual bool ShouldShowOnHUD() { return m_bShowOnHUD; }
|
||||
virtual void SetShowOnHUD( bool bShow );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [pfreese] Serialization methods
|
||||
//=============================================================================
|
||||
|
||||
virtual void GetSettings( KeyValues* pNodeOut ); // serialize
|
||||
virtual void ApplySettings( /* const */ KeyValues* pNodeIn ); // unserialize
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
virtual void Think( void ) { return; }
|
||||
|
||||
protected:
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
virtual void FireGameEvent_Internal( IGameEvent *event ) {};
|
||||
void SetVictimFilter( const char *pClassName );
|
||||
void SetAttackerFilter( const char *pClassName );
|
||||
void SetInflictorFilter( const char *pClassName );
|
||||
void SetInflictorEntityNameFilter( const char *pEntityName );
|
||||
void SetMapNameFilter( const char *pMapName );
|
||||
void SetComponentPrefix( const char *pPrefix );
|
||||
void IncrementCount( int iOptIncrement = 0 );
|
||||
void EvaluateNewAchievement();
|
||||
void AwardAchievement();
|
||||
void ShowProgressNotification();
|
||||
void HandleProgressUpdate();
|
||||
virtual void CalcProgressMsgIncrement();
|
||||
void SetNextThink( float flThinkTime );
|
||||
void ClearThink( void );
|
||||
void SetStat( const char* pStatName ) { m_pszStat = pStatName; }
|
||||
|
||||
const char *m_pszName; // name of this achievement
|
||||
const char *m_pszStat; // stat this achievement uses
|
||||
int m_iAchievementID; // ID of this achievement
|
||||
int m_iFlags; // ACH_* flags for this achievement
|
||||
int m_iGoal; // goal # of steps to award this achievement
|
||||
int m_iProgressMsgIncrement; // after how many steps show we show a progress notification
|
||||
int m_iProgressMsgMinimum; // the minimum progress needed before showing progress notification
|
||||
int m_iPointValue; // # of points this achievement is worth (currently only used for XBox Live)
|
||||
bool m_bHideUntilAchieved; // should this achievement be hidden until achieved?
|
||||
bool m_bStoreProgressInSteam; // should incremental progress be stored in Steam. A counter with same name as achievement must be set up in Steam.
|
||||
const char *m_pInflictorClassNameFilter; // if non-NULL, inflictor class name to filter with
|
||||
const char *m_pInflictorEntityNameFilter; // if non-NULL, inflictor entity name to filter with
|
||||
const char *m_pVictimClassNameFilter; // if non-NULL, victim class name to filter with
|
||||
const char *m_pAttackerClassNameFilter; // if non-NULL, attacker class name to filter with
|
||||
const char *m_pMapNameFilter; // if non-NULL, map name to filter with
|
||||
const char *m_pGameDirFilter; // if non-NULL, game dir name to filter with
|
||||
|
||||
const char **m_pszComponentNames;
|
||||
int m_iNumComponents;
|
||||
const char *m_pszComponentPrefix;
|
||||
int m_iComponentPrefixLen;
|
||||
bool m_bAchieved; // is this achievement achieved
|
||||
uint32 m_uUnlockTime; // time_t that this achievement was unlocked (0 if before Steamworks unlock time support)
|
||||
int m_iCount; // # of steps satisfied toward this achievement (only valid if not achieved)
|
||||
int m_iProgressShown; // # of progress msgs we've shown
|
||||
uint64 m_iComponentBits; // bitfield of components achieved
|
||||
CAchievementMgr *m_pAchievementMgr; // our achievement manager
|
||||
bool m_bShowOnHUD; // if set, the player wants this achievement pinned to the HUD
|
||||
|
||||
friend class CAchievementMgr;
|
||||
public:
|
||||
DECLARE_DATADESC();
|
||||
};
|
||||
|
||||
class CFailableAchievement : public CBaseAchievement
|
||||
{
|
||||
DECLARE_CLASS( CFailableAchievement, CBaseAchievement );
|
||||
public:
|
||||
CFailableAchievement();
|
||||
void SetFailed();
|
||||
|
||||
virtual bool ShouldSaveWithGame();
|
||||
virtual void PreRestoreSavedGame();
|
||||
virtual void PostRestoreSavedGame();
|
||||
virtual bool IsAchieved() { return !m_bFailed && BaseClass::IsAchieved(); }
|
||||
virtual bool IsActive() { return m_bActivated && !m_bFailed && BaseClass::IsActive(); }
|
||||
bool IsFailed() { return m_bFailed; }
|
||||
|
||||
virtual void OnMapEvent( const char *pEventName );
|
||||
virtual void OnActivationEvent() { Activate(); }
|
||||
virtual void OnEvaluationEvent();
|
||||
virtual const char *GetActivationEventName() =0;
|
||||
virtual const char *GetEvaluationEventName() =0;
|
||||
|
||||
protected:
|
||||
void Activate();
|
||||
|
||||
bool m_bActivated; // are we activated? (If there is a map event that turns us on, has that happened)
|
||||
bool m_bFailed; // has this achievement failed
|
||||
|
||||
public:
|
||||
DECLARE_DATADESC();
|
||||
};
|
||||
|
||||
class CMapAchievement : public CBaseAchievement
|
||||
{
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_SAVE_GLOBAL );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
class CAchievement_AchievedCount : public CBaseAchievement
|
||||
{
|
||||
public:
|
||||
void Init();
|
||||
virtual void OnSteamUserStatsStored( void );
|
||||
virtual bool IsMetaAchievement() { return true; }
|
||||
|
||||
int GetLowRange() { return m_iLowRange; }
|
||||
int GetHighRange() { return m_iHighRange; }
|
||||
int GetNumRequired() { return m_iNumRequired; }
|
||||
|
||||
protected:
|
||||
void SetAchievementsRequired( int iNumRequired, int iLowRange, int iHighRange );
|
||||
|
||||
private:
|
||||
int m_iNumRequired;
|
||||
int m_iLowRange;
|
||||
int m_iHighRange;
|
||||
};
|
||||
|
||||
//
|
||||
// Helper class for achievement creation
|
||||
//
|
||||
|
||||
typedef CBaseAchievement* (*achievementCreateFunc) (void);
|
||||
class CBaseAchievementHelper
|
||||
{
|
||||
public:
|
||||
CBaseAchievementHelper( achievementCreateFunc createFunc )
|
||||
{
|
||||
m_pfnCreate = createFunc;
|
||||
m_pNext = s_pFirst;
|
||||
s_pFirst = this;
|
||||
}
|
||||
achievementCreateFunc m_pfnCreate;
|
||||
CBaseAchievementHelper *m_pNext;
|
||||
static CBaseAchievementHelper *s_pFirst;
|
||||
};
|
||||
|
||||
#define DECLARE_ACHIEVEMENT_( className, achievementID, achievementName, gameDirFilter, iPointValue, bHidden ) \
|
||||
static CBaseAchievement *Create_##className( void ) \
|
||||
{ \
|
||||
CBaseAchievement *pAchievement = new className( ); \
|
||||
pAchievement->SetAchievementID( achievementID ); \
|
||||
pAchievement->SetName( achievementName ); \
|
||||
pAchievement->SetPointValue( iPointValue ); \
|
||||
pAchievement->SetHideUntilAchieved( bHidden ); \
|
||||
if ( gameDirFilter ) pAchievement->SetGameDirFilter( gameDirFilter ); \
|
||||
return pAchievement; \
|
||||
}; \
|
||||
static CBaseAchievementHelper g_##className##_Helper( Create_##className );
|
||||
|
||||
#define DECLARE_ACHIEVEMENT( className, achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_ACHIEVEMENT_( className, achievementID, achievementName, NULL, iPointValue, false )
|
||||
|
||||
#define DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, gameDirFilter, iPointValue, bHidden ) \
|
||||
class CAchievement##achievementID : public CMapAchievement {}; \
|
||||
DECLARE_ACHIEVEMENT_( CAchievement##achievementID, achievementID, achievementName, gameDirFilter, iPointValue, bHidden ) \
|
||||
|
||||
#define DECLARE_MAP_EVENT_ACHIEVEMENT( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, NULL, iPointValue, false )
|
||||
|
||||
#define DECLARE_MAP_EVENT_ACHIEVEMENT_HIDDEN( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, NULL, iPointValue, true )
|
||||
|
||||
#endif // BASEACHIEVEMENT_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BASEACHIEVEMENT_H
|
||||
#define BASEACHIEVEMENT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "GameEventListener.h"
|
||||
#include "hl2orange.spa.h"
|
||||
#include "iachievementmgr.h"
|
||||
|
||||
class CAchievementMgr;
|
||||
|
||||
//
|
||||
// Base class for achievements
|
||||
//
|
||||
|
||||
class CBaseAchievement : public CGameEventListener, public IAchievement
|
||||
{
|
||||
DECLARE_CLASS_NOBASE( CBaseAchievement );
|
||||
public:
|
||||
CBaseAchievement();
|
||||
virtual ~CBaseAchievement();
|
||||
virtual void Init() {}
|
||||
virtual void ListenForEvents() {};
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event );
|
||||
|
||||
int GetAchievementID() { return m_iAchievementID; }
|
||||
void SetAchievementID( int iAchievementID ) { m_iAchievementID = iAchievementID; }
|
||||
void SetName( const char *pszName ) { m_pszName = pszName; }
|
||||
const char *GetName() { return m_pszName; }
|
||||
const char *GetStat() { return m_pszStat?m_pszStat:GetName(); }
|
||||
void SetFlags( int iFlags );
|
||||
int GetFlags() { return m_iFlags; }
|
||||
void SetGoal( int iGoal ) { m_iGoal = iGoal; }
|
||||
int GetGoal() { return m_iGoal; }
|
||||
void SetGameDirFilter( const char *pGameDir );
|
||||
bool HasComponents() { return ( m_iFlags & ACH_HAS_COMPONENTS ) > 0; }
|
||||
void SetPointValue( int iPointValue ) { m_iPointValue = iPointValue; }
|
||||
int GetPointValue() { return m_iPointValue; }
|
||||
bool ShouldHideUntilAchieved() { return m_bHideUntilAchieved; }
|
||||
void SetHideUntilAchieved( bool bHide ) { m_bHideUntilAchieved = bHide; }
|
||||
void SetStoreProgressInSteam( bool bStoreProgressInSteam ) { m_bStoreProgressInSteam = bStoreProgressInSteam; }
|
||||
bool StoreProgressInSteam() { return m_bStoreProgressInSteam; }
|
||||
virtual bool ShouldShowProgressNotification() { return true; }
|
||||
virtual void OnPlayerStatsUpdate() {}
|
||||
|
||||
virtual bool ShouldSaveWithGame();
|
||||
bool ShouldSaveGlobal();
|
||||
virtual void PreRestoreSavedGame();
|
||||
virtual void PostRestoreSavedGame();
|
||||
void SetCount( int iCount ) { m_iCount = iCount; }
|
||||
int GetCount() { return m_iCount; }
|
||||
void SetProgressShown( int iProgressShown ) { m_iProgressShown = iProgressShown; }
|
||||
int GetProgressShown() { return m_iProgressShown; }
|
||||
virtual bool IsAchieved() { return m_bAchieved; }
|
||||
virtual bool IsActive();
|
||||
virtual bool LocalPlayerCanEarn( void ) { return true; }
|
||||
void SetAchieved( bool bAchieved ) { m_bAchieved = bAchieved; }
|
||||
virtual bool IsMetaAchievement() { return false; }
|
||||
virtual bool AlwaysListen() { return false; }
|
||||
virtual bool AlwaysEnabled() { return false; }
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [pfreese] Notification method for derived classes
|
||||
//=============================================================================
|
||||
|
||||
virtual void OnAchieved() {}
|
||||
uint32 GetUnlockTime() const { return m_uUnlockTime; }
|
||||
void SetUnlockTime( uint32 unlockTime ) { m_uUnlockTime = unlockTime; }
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
uint64 GetComponentBits() { return m_iComponentBits; }
|
||||
void SetComponentBits( uint64 iComponentBits );
|
||||
void OnComponentEvent( const char *pchComponentName );
|
||||
void EnsureComponentBitSetAndEvaluate( int iBitNumber );
|
||||
void EvaluateIsAlreadyAchieved();
|
||||
virtual void OnMapEvent( const char *pEventName );
|
||||
virtual void PrintAdditionalStatus() {} // for debugging, achievements may report additional status in achievement_status concmd
|
||||
virtual void OnSteamUserStatsStored() {}
|
||||
virtual void UpdateAchievement( int nData ) {}
|
||||
virtual bool ShouldShowOnHUD() { return m_bShowOnHUD; }
|
||||
virtual void SetShowOnHUD( bool bShow );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [pfreese] Serialization methods
|
||||
//=============================================================================
|
||||
|
||||
virtual void GetSettings( KeyValues* pNodeOut ); // serialize
|
||||
virtual void ApplySettings( /* const */ KeyValues* pNodeIn ); // unserialize
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
virtual void Think( void ) { return; }
|
||||
|
||||
protected:
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
virtual void FireGameEvent_Internal( IGameEvent *event ) {};
|
||||
void SetVictimFilter( const char *pClassName );
|
||||
void SetAttackerFilter( const char *pClassName );
|
||||
void SetInflictorFilter( const char *pClassName );
|
||||
void SetInflictorEntityNameFilter( const char *pEntityName );
|
||||
void SetMapNameFilter( const char *pMapName );
|
||||
void SetComponentPrefix( const char *pPrefix );
|
||||
void IncrementCount( int iOptIncrement = 0 );
|
||||
void EvaluateNewAchievement();
|
||||
void AwardAchievement();
|
||||
void ShowProgressNotification();
|
||||
void HandleProgressUpdate();
|
||||
virtual void CalcProgressMsgIncrement();
|
||||
void SetNextThink( float flThinkTime );
|
||||
void ClearThink( void );
|
||||
void SetStat( const char* pStatName ) { m_pszStat = pStatName; }
|
||||
|
||||
const char *m_pszName; // name of this achievement
|
||||
const char *m_pszStat; // stat this achievement uses
|
||||
int m_iAchievementID; // ID of this achievement
|
||||
int m_iFlags; // ACH_* flags for this achievement
|
||||
int m_iGoal; // goal # of steps to award this achievement
|
||||
int m_iProgressMsgIncrement; // after how many steps show we show a progress notification
|
||||
int m_iProgressMsgMinimum; // the minimum progress needed before showing progress notification
|
||||
int m_iPointValue; // # of points this achievement is worth (currently only used for XBox Live)
|
||||
bool m_bHideUntilAchieved; // should this achievement be hidden until achieved?
|
||||
bool m_bStoreProgressInSteam; // should incremental progress be stored in Steam. A counter with same name as achievement must be set up in Steam.
|
||||
const char *m_pInflictorClassNameFilter; // if non-NULL, inflictor class name to filter with
|
||||
const char *m_pInflictorEntityNameFilter; // if non-NULL, inflictor entity name to filter with
|
||||
const char *m_pVictimClassNameFilter; // if non-NULL, victim class name to filter with
|
||||
const char *m_pAttackerClassNameFilter; // if non-NULL, attacker class name to filter with
|
||||
const char *m_pMapNameFilter; // if non-NULL, map name to filter with
|
||||
const char *m_pGameDirFilter; // if non-NULL, game dir name to filter with
|
||||
|
||||
const char **m_pszComponentNames;
|
||||
int m_iNumComponents;
|
||||
const char *m_pszComponentPrefix;
|
||||
int m_iComponentPrefixLen;
|
||||
bool m_bAchieved; // is this achievement achieved
|
||||
uint32 m_uUnlockTime; // time_t that this achievement was unlocked (0 if before Steamworks unlock time support)
|
||||
int m_iCount; // # of steps satisfied toward this achievement (only valid if not achieved)
|
||||
int m_iProgressShown; // # of progress msgs we've shown
|
||||
uint64 m_iComponentBits; // bitfield of components achieved
|
||||
CAchievementMgr *m_pAchievementMgr; // our achievement manager
|
||||
bool m_bShowOnHUD; // if set, the player wants this achievement pinned to the HUD
|
||||
|
||||
friend class CAchievementMgr;
|
||||
public:
|
||||
DECLARE_DATADESC();
|
||||
};
|
||||
|
||||
class CFailableAchievement : public CBaseAchievement
|
||||
{
|
||||
DECLARE_CLASS( CFailableAchievement, CBaseAchievement );
|
||||
public:
|
||||
CFailableAchievement();
|
||||
void SetFailed();
|
||||
|
||||
virtual bool ShouldSaveWithGame();
|
||||
virtual void PreRestoreSavedGame();
|
||||
virtual void PostRestoreSavedGame();
|
||||
virtual bool IsAchieved() { return !m_bFailed && BaseClass::IsAchieved(); }
|
||||
virtual bool IsActive() { return m_bActivated && !m_bFailed && BaseClass::IsActive(); }
|
||||
bool IsFailed() { return m_bFailed; }
|
||||
|
||||
virtual void OnMapEvent( const char *pEventName );
|
||||
virtual void OnActivationEvent() { Activate(); }
|
||||
virtual void OnEvaluationEvent();
|
||||
virtual const char *GetActivationEventName() =0;
|
||||
virtual const char *GetEvaluationEventName() =0;
|
||||
|
||||
protected:
|
||||
void Activate();
|
||||
|
||||
bool m_bActivated; // are we activated? (If there is a map event that turns us on, has that happened)
|
||||
bool m_bFailed; // has this achievement failed
|
||||
|
||||
public:
|
||||
DECLARE_DATADESC();
|
||||
};
|
||||
|
||||
class CMapAchievement : public CBaseAchievement
|
||||
{
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_SAVE_GLOBAL );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
class CAchievement_AchievedCount : public CBaseAchievement
|
||||
{
|
||||
public:
|
||||
void Init();
|
||||
virtual void OnSteamUserStatsStored( void );
|
||||
virtual bool IsMetaAchievement() { return true; }
|
||||
|
||||
int GetLowRange() { return m_iLowRange; }
|
||||
int GetHighRange() { return m_iHighRange; }
|
||||
int GetNumRequired() { return m_iNumRequired; }
|
||||
|
||||
protected:
|
||||
void SetAchievementsRequired( int iNumRequired, int iLowRange, int iHighRange );
|
||||
|
||||
private:
|
||||
int m_iNumRequired;
|
||||
int m_iLowRange;
|
||||
int m_iHighRange;
|
||||
};
|
||||
|
||||
//
|
||||
// Helper class for achievement creation
|
||||
//
|
||||
|
||||
typedef CBaseAchievement* (*achievementCreateFunc) (void);
|
||||
class CBaseAchievementHelper
|
||||
{
|
||||
public:
|
||||
CBaseAchievementHelper( achievementCreateFunc createFunc )
|
||||
{
|
||||
m_pfnCreate = createFunc;
|
||||
m_pNext = s_pFirst;
|
||||
s_pFirst = this;
|
||||
}
|
||||
achievementCreateFunc m_pfnCreate;
|
||||
CBaseAchievementHelper *m_pNext;
|
||||
static CBaseAchievementHelper *s_pFirst;
|
||||
};
|
||||
|
||||
#define DECLARE_ACHIEVEMENT_( className, achievementID, achievementName, gameDirFilter, iPointValue, bHidden ) \
|
||||
static CBaseAchievement *Create_##className( void ) \
|
||||
{ \
|
||||
CBaseAchievement *pAchievement = new className( ); \
|
||||
pAchievement->SetAchievementID( achievementID ); \
|
||||
pAchievement->SetName( achievementName ); \
|
||||
pAchievement->SetPointValue( iPointValue ); \
|
||||
pAchievement->SetHideUntilAchieved( bHidden ); \
|
||||
if ( gameDirFilter ) pAchievement->SetGameDirFilter( gameDirFilter ); \
|
||||
return pAchievement; \
|
||||
}; \
|
||||
static CBaseAchievementHelper g_##className##_Helper( Create_##className );
|
||||
|
||||
#define DECLARE_ACHIEVEMENT( className, achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_ACHIEVEMENT_( className, achievementID, achievementName, NULL, iPointValue, false )
|
||||
|
||||
#define DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, gameDirFilter, iPointValue, bHidden ) \
|
||||
class CAchievement##achievementID : public CMapAchievement {}; \
|
||||
DECLARE_ACHIEVEMENT_( CAchievement##achievementID, achievementID, achievementName, gameDirFilter, iPointValue, bHidden ) \
|
||||
|
||||
#define DECLARE_MAP_EVENT_ACHIEVEMENT( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, NULL, iPointValue, false )
|
||||
|
||||
#define DECLARE_MAP_EVENT_ACHIEVEMENT_HIDDEN( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, NULL, iPointValue, true )
|
||||
|
||||
#endif // BASEACHIEVEMENT_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2558
-2558
File diff suppressed because it is too large
Load Diff
@@ -1,310 +1,310 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEENTITY_SHARED_H
|
||||
#define BASEENTITY_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
extern ConVar hl2_episodic;
|
||||
|
||||
// Simple shared header file for common base entities
|
||||
|
||||
// entity capabilities
|
||||
// These are caps bits to indicate what an object's capabilities (currently used for +USE, save/restore and level transitions)
|
||||
#define FCAP_MUST_SPAWN 0x00000001 // Spawn after restore
|
||||
#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions
|
||||
// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!!
|
||||
#define FCAP_FORCE_TRANSITION 0x00000004 // ALWAYS goes across transitions
|
||||
#define FCAP_NOTIFY_ON_TRANSITION 0x00000008 // Entity will receive Inside/Outside transition inputs when a transition occurs
|
||||
|
||||
#define FCAP_IMPULSE_USE 0x00000010 // can be used by the player
|
||||
#define FCAP_CONTINUOUS_USE 0x00000020 // can be used by the player
|
||||
#define FCAP_ONOFF_USE 0x00000040 // can be used by the player
|
||||
#define FCAP_DIRECTIONAL_USE 0x00000080 // Player sends +/- 1 when using (currently only tracktrains)
|
||||
// NOTE: Normally +USE only works in direct line of sight. Add these caps for additional searches
|
||||
#define FCAP_USE_ONGROUND 0x00000100
|
||||
#define FCAP_USE_IN_RADIUS 0x00000200
|
||||
#define FCAP_SAVE_NON_NETWORKABLE 0x00000400
|
||||
|
||||
#define FCAP_MASTER 0x10000000 // Can be used to "master" other entities (like multisource)
|
||||
#define FCAP_WCEDIT_POSITION 0x40000000 // Can change position and update Hammer in edit mode
|
||||
#define FCAP_DONT_SAVE 0x80000000 // Don't save this
|
||||
|
||||
|
||||
// How many bits are used to transmit parent attachment indices?
|
||||
#define NUM_PARENTATTACHMENT_BITS 6
|
||||
|
||||
// Maximum number of vphysics objects per entity
|
||||
#define VPHYSICS_MAX_OBJECT_LIST_COUNT 1024
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// For invalidate physics recursive
|
||||
//-----------------------------------------------------------------------------
|
||||
enum InvalidatePhysicsBits_t
|
||||
{
|
||||
POSITION_CHANGED = 0x1,
|
||||
ANGLES_CHANGED = 0x2,
|
||||
VELOCITY_CHANGED = 0x4,
|
||||
ANIMATION_CHANGED = 0x8,
|
||||
};
|
||||
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#include "c_baseentity.h"
|
||||
#include "c_baseanimating.h"
|
||||
#else
|
||||
#include "baseentity.h"
|
||||
|
||||
#ifdef HL2_EPISODIC
|
||||
#include "info_darknessmode_lightsource.h"
|
||||
#endif // HL2_EPISODIC
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( NO_ENTITY_PREDICTION )
|
||||
// CBaseEntity inlines
|
||||
inline bool CBaseEntity::IsPlayerSimulated( void ) const
|
||||
{
|
||||
return m_bIsPlayerSimulated;
|
||||
}
|
||||
|
||||
inline CBasePlayer *CBaseEntity::GetSimulatingPlayer( void )
|
||||
{
|
||||
return m_hPlayerSimulationOwner;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline MoveType_t CBaseEntity::GetMoveType() const
|
||||
{
|
||||
return (MoveType_t)(unsigned char)m_MoveType;
|
||||
}
|
||||
|
||||
inline MoveCollide_t CBaseEntity::GetMoveCollide() const
|
||||
{
|
||||
return (MoveCollide_t)(unsigned char)m_MoveCollide;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Collision group accessors
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int CBaseEntity::GetCollisionGroup() const
|
||||
{
|
||||
return m_CollisionGroup;
|
||||
}
|
||||
|
||||
inline int CBaseEntity::GetFlags( void ) const
|
||||
{
|
||||
return m_fFlags;
|
||||
}
|
||||
|
||||
inline bool CBaseEntity::IsAlive( void )
|
||||
{
|
||||
return m_lifeState == LIFE_ALIVE;
|
||||
}
|
||||
|
||||
inline CBaseEntity *CBaseEntity::GetOwnerEntity() const
|
||||
{
|
||||
return m_hOwnerEntity.Get();
|
||||
}
|
||||
|
||||
inline CBaseEntity *CBaseEntity::GetEffectEntity() const
|
||||
{
|
||||
return m_hEffectEntity.Get();
|
||||
}
|
||||
|
||||
inline int CBaseEntity::GetPredictionRandomSeed( void )
|
||||
{
|
||||
return m_nPredictionRandomSeed;
|
||||
}
|
||||
|
||||
inline CBasePlayer *CBaseEntity::GetPredictionPlayer( void )
|
||||
{
|
||||
return m_pPredictionPlayer;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetPredictionPlayer( CBasePlayer *player )
|
||||
{
|
||||
m_pPredictionPlayer = player;
|
||||
}
|
||||
|
||||
|
||||
inline bool CBaseEntity::IsSimulatedEveryTick() const
|
||||
{
|
||||
return m_bSimulatedEveryTick;
|
||||
}
|
||||
|
||||
inline bool CBaseEntity::IsAnimatedEveryTick() const
|
||||
{
|
||||
return m_bAnimatedEveryTick;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetSimulatedEveryTick( bool sim )
|
||||
{
|
||||
if ( m_bSimulatedEveryTick != sim )
|
||||
{
|
||||
m_bSimulatedEveryTick = sim;
|
||||
#ifdef CLIENT_DLL
|
||||
Interp_UpdateInterpolationAmounts( GetVarMapping() );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetAnimatedEveryTick( bool anim )
|
||||
{
|
||||
if ( m_bAnimatedEveryTick != anim )
|
||||
{
|
||||
m_bAnimatedEveryTick = anim;
|
||||
#ifdef CLIENT_DLL
|
||||
Interp_UpdateInterpolationAmounts( GetVarMapping() );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline float CBaseEntity::GetAnimTime() const
|
||||
{
|
||||
return m_flAnimTime;
|
||||
}
|
||||
|
||||
inline float CBaseEntity::GetSimulationTime() const
|
||||
{
|
||||
return m_flSimulationTime;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetAnimTime( float at )
|
||||
{
|
||||
m_flAnimTime = at;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetSimulationTime( float st )
|
||||
{
|
||||
m_flSimulationTime = st;
|
||||
}
|
||||
|
||||
inline int CBaseEntity::GetEffects( void ) const
|
||||
{
|
||||
return m_fEffects;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::RemoveEffects( int nEffects )
|
||||
{
|
||||
#if !defined( CLIENT_DLL )
|
||||
#ifdef HL2_EPISODIC
|
||||
if ( nEffects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) )
|
||||
{
|
||||
// Hack for now, to avoid player emitting radius with his flashlight
|
||||
if ( !IsPlayer() )
|
||||
{
|
||||
RemoveEntityFromDarknessCheck( this );
|
||||
}
|
||||
}
|
||||
#endif // HL2_EPISODIC
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
m_fEffects &= ~nEffects;
|
||||
if ( nEffects & EF_NODRAW )
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
NetworkProp()->MarkPVSInformationDirty();
|
||||
DispatchUpdateTransmitState();
|
||||
#else
|
||||
UpdateVisibility();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void CBaseEntity::ClearEffects( void )
|
||||
{
|
||||
#if !defined( CLIENT_DLL )
|
||||
#ifdef HL2_EPISODIC
|
||||
if ( m_fEffects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) )
|
||||
{
|
||||
// Hack for now, to avoid player emitting radius with his flashlight
|
||||
if ( !IsPlayer() )
|
||||
{
|
||||
RemoveEntityFromDarknessCheck( this );
|
||||
}
|
||||
}
|
||||
#endif // HL2_EPISODIC
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
m_fEffects = 0;
|
||||
#ifndef CLIENT_DLL
|
||||
DispatchUpdateTransmitState();
|
||||
#else
|
||||
UpdateVisibility();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool CBaseEntity::IsEffectActive( int nEffects ) const
|
||||
{
|
||||
return (m_fEffects & nEffects) != 0;
|
||||
}
|
||||
|
||||
// Shared EntityMessage between game and client .dlls
|
||||
#define BASEENTITY_MSG_REMOVE_DECALS 1
|
||||
|
||||
extern float k_flMaxEntityPosCoord;
|
||||
extern float k_flMaxEntityEulerAngle;
|
||||
extern float k_flMaxEntitySpeed;
|
||||
extern float k_flMaxEntitySpinRate;
|
||||
|
||||
inline bool IsEntityCoordinateReasonable ( const vec_t c )
|
||||
{
|
||||
float r = k_flMaxEntityPosCoord;
|
||||
return c > -r && c < r;
|
||||
}
|
||||
|
||||
inline bool IsEntityPositionReasonable( const Vector &v )
|
||||
{
|
||||
float r = k_flMaxEntityPosCoord;
|
||||
return
|
||||
v.x > -r && v.x < r &&
|
||||
v.y > -r && v.y < r &&
|
||||
v.z > -r && v.z < r;
|
||||
}
|
||||
|
||||
// Returns:
|
||||
// -1 - velocity is really, REALLY bad and probably should be rejected.
|
||||
// 0 - velocity was suspicious and clamped.
|
||||
// 1 - velocity was OK and not modified
|
||||
extern int CheckEntityVelocity( Vector &v );
|
||||
|
||||
inline bool IsEntityQAngleReasonable( const QAngle &q )
|
||||
{
|
||||
float r = k_flMaxEntityEulerAngle;
|
||||
return
|
||||
q.x > -r && q.x < r &&
|
||||
q.y > -r && q.y < r &&
|
||||
q.z > -r && q.z < r;
|
||||
}
|
||||
|
||||
// Angular velocity in exponential map form
|
||||
inline bool IsEntityAngularVelocityReasonable( const Vector &q )
|
||||
{
|
||||
float r = k_flMaxEntitySpinRate;
|
||||
return
|
||||
q.x > -r && q.x < r &&
|
||||
q.y > -r && q.y < r &&
|
||||
q.z > -r && q.z < r;
|
||||
}
|
||||
|
||||
// Angular velocity of each Euler angle.
|
||||
inline bool IsEntityQAngleVelReasonable( const QAngle &q )
|
||||
{
|
||||
float r = k_flMaxEntitySpinRate;
|
||||
return
|
||||
q.x > -r && q.x < r &&
|
||||
q.y > -r && q.y < r &&
|
||||
q.z > -r && q.z < r;
|
||||
}
|
||||
|
||||
extern bool CheckEmitReasonablePhysicsSpew();
|
||||
|
||||
#endif // BASEENTITY_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEENTITY_SHARED_H
|
||||
#define BASEENTITY_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
extern ConVar hl2_episodic;
|
||||
|
||||
// Simple shared header file for common base entities
|
||||
|
||||
// entity capabilities
|
||||
// These are caps bits to indicate what an object's capabilities (currently used for +USE, save/restore and level transitions)
|
||||
#define FCAP_MUST_SPAWN 0x00000001 // Spawn after restore
|
||||
#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions
|
||||
// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!!
|
||||
#define FCAP_FORCE_TRANSITION 0x00000004 // ALWAYS goes across transitions
|
||||
#define FCAP_NOTIFY_ON_TRANSITION 0x00000008 // Entity will receive Inside/Outside transition inputs when a transition occurs
|
||||
|
||||
#define FCAP_IMPULSE_USE 0x00000010 // can be used by the player
|
||||
#define FCAP_CONTINUOUS_USE 0x00000020 // can be used by the player
|
||||
#define FCAP_ONOFF_USE 0x00000040 // can be used by the player
|
||||
#define FCAP_DIRECTIONAL_USE 0x00000080 // Player sends +/- 1 when using (currently only tracktrains)
|
||||
// NOTE: Normally +USE only works in direct line of sight. Add these caps for additional searches
|
||||
#define FCAP_USE_ONGROUND 0x00000100
|
||||
#define FCAP_USE_IN_RADIUS 0x00000200
|
||||
#define FCAP_SAVE_NON_NETWORKABLE 0x00000400
|
||||
|
||||
#define FCAP_MASTER 0x10000000 // Can be used to "master" other entities (like multisource)
|
||||
#define FCAP_WCEDIT_POSITION 0x40000000 // Can change position and update Hammer in edit mode
|
||||
#define FCAP_DONT_SAVE 0x80000000 // Don't save this
|
||||
|
||||
|
||||
// How many bits are used to transmit parent attachment indices?
|
||||
#define NUM_PARENTATTACHMENT_BITS 6
|
||||
|
||||
// Maximum number of vphysics objects per entity
|
||||
#define VPHYSICS_MAX_OBJECT_LIST_COUNT 1024
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// For invalidate physics recursive
|
||||
//-----------------------------------------------------------------------------
|
||||
enum InvalidatePhysicsBits_t
|
||||
{
|
||||
POSITION_CHANGED = 0x1,
|
||||
ANGLES_CHANGED = 0x2,
|
||||
VELOCITY_CHANGED = 0x4,
|
||||
ANIMATION_CHANGED = 0x8,
|
||||
};
|
||||
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#include "c_baseentity.h"
|
||||
#include "c_baseanimating.h"
|
||||
#else
|
||||
#include "baseentity.h"
|
||||
|
||||
#ifdef HL2_EPISODIC
|
||||
#include "info_darknessmode_lightsource.h"
|
||||
#endif // HL2_EPISODIC
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( NO_ENTITY_PREDICTION )
|
||||
// CBaseEntity inlines
|
||||
inline bool CBaseEntity::IsPlayerSimulated( void ) const
|
||||
{
|
||||
return m_bIsPlayerSimulated;
|
||||
}
|
||||
|
||||
inline CBasePlayer *CBaseEntity::GetSimulatingPlayer( void )
|
||||
{
|
||||
return m_hPlayerSimulationOwner;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline MoveType_t CBaseEntity::GetMoveType() const
|
||||
{
|
||||
return (MoveType_t)(unsigned char)m_MoveType;
|
||||
}
|
||||
|
||||
inline MoveCollide_t CBaseEntity::GetMoveCollide() const
|
||||
{
|
||||
return (MoveCollide_t)(unsigned char)m_MoveCollide;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Collision group accessors
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int CBaseEntity::GetCollisionGroup() const
|
||||
{
|
||||
return m_CollisionGroup;
|
||||
}
|
||||
|
||||
inline int CBaseEntity::GetFlags( void ) const
|
||||
{
|
||||
return m_fFlags;
|
||||
}
|
||||
|
||||
inline bool CBaseEntity::IsAlive( void )
|
||||
{
|
||||
return m_lifeState == LIFE_ALIVE;
|
||||
}
|
||||
|
||||
inline CBaseEntity *CBaseEntity::GetOwnerEntity() const
|
||||
{
|
||||
return m_hOwnerEntity.Get();
|
||||
}
|
||||
|
||||
inline CBaseEntity *CBaseEntity::GetEffectEntity() const
|
||||
{
|
||||
return m_hEffectEntity.Get();
|
||||
}
|
||||
|
||||
inline int CBaseEntity::GetPredictionRandomSeed( void )
|
||||
{
|
||||
return m_nPredictionRandomSeed;
|
||||
}
|
||||
|
||||
inline CBasePlayer *CBaseEntity::GetPredictionPlayer( void )
|
||||
{
|
||||
return m_pPredictionPlayer;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetPredictionPlayer( CBasePlayer *player )
|
||||
{
|
||||
m_pPredictionPlayer = player;
|
||||
}
|
||||
|
||||
|
||||
inline bool CBaseEntity::IsSimulatedEveryTick() const
|
||||
{
|
||||
return m_bSimulatedEveryTick;
|
||||
}
|
||||
|
||||
inline bool CBaseEntity::IsAnimatedEveryTick() const
|
||||
{
|
||||
return m_bAnimatedEveryTick;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetSimulatedEveryTick( bool sim )
|
||||
{
|
||||
if ( m_bSimulatedEveryTick != sim )
|
||||
{
|
||||
m_bSimulatedEveryTick = sim;
|
||||
#ifdef CLIENT_DLL
|
||||
Interp_UpdateInterpolationAmounts( GetVarMapping() );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetAnimatedEveryTick( bool anim )
|
||||
{
|
||||
if ( m_bAnimatedEveryTick != anim )
|
||||
{
|
||||
m_bAnimatedEveryTick = anim;
|
||||
#ifdef CLIENT_DLL
|
||||
Interp_UpdateInterpolationAmounts( GetVarMapping() );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline float CBaseEntity::GetAnimTime() const
|
||||
{
|
||||
return m_flAnimTime;
|
||||
}
|
||||
|
||||
inline float CBaseEntity::GetSimulationTime() const
|
||||
{
|
||||
return m_flSimulationTime;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetAnimTime( float at )
|
||||
{
|
||||
m_flAnimTime = at;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::SetSimulationTime( float st )
|
||||
{
|
||||
m_flSimulationTime = st;
|
||||
}
|
||||
|
||||
inline int CBaseEntity::GetEffects( void ) const
|
||||
{
|
||||
return m_fEffects;
|
||||
}
|
||||
|
||||
inline void CBaseEntity::RemoveEffects( int nEffects )
|
||||
{
|
||||
#if !defined( CLIENT_DLL )
|
||||
#ifdef HL2_EPISODIC
|
||||
if ( nEffects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) )
|
||||
{
|
||||
// Hack for now, to avoid player emitting radius with his flashlight
|
||||
if ( !IsPlayer() )
|
||||
{
|
||||
RemoveEntityFromDarknessCheck( this );
|
||||
}
|
||||
}
|
||||
#endif // HL2_EPISODIC
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
m_fEffects &= ~nEffects;
|
||||
if ( nEffects & EF_NODRAW )
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
NetworkProp()->MarkPVSInformationDirty();
|
||||
DispatchUpdateTransmitState();
|
||||
#else
|
||||
UpdateVisibility();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void CBaseEntity::ClearEffects( void )
|
||||
{
|
||||
#if !defined( CLIENT_DLL )
|
||||
#ifdef HL2_EPISODIC
|
||||
if ( m_fEffects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) )
|
||||
{
|
||||
// Hack for now, to avoid player emitting radius with his flashlight
|
||||
if ( !IsPlayer() )
|
||||
{
|
||||
RemoveEntityFromDarknessCheck( this );
|
||||
}
|
||||
}
|
||||
#endif // HL2_EPISODIC
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
m_fEffects = 0;
|
||||
#ifndef CLIENT_DLL
|
||||
DispatchUpdateTransmitState();
|
||||
#else
|
||||
UpdateVisibility();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool CBaseEntity::IsEffectActive( int nEffects ) const
|
||||
{
|
||||
return (m_fEffects & nEffects) != 0;
|
||||
}
|
||||
|
||||
// Shared EntityMessage between game and client .dlls
|
||||
#define BASEENTITY_MSG_REMOVE_DECALS 1
|
||||
|
||||
extern float k_flMaxEntityPosCoord;
|
||||
extern float k_flMaxEntityEulerAngle;
|
||||
extern float k_flMaxEntitySpeed;
|
||||
extern float k_flMaxEntitySpinRate;
|
||||
|
||||
inline bool IsEntityCoordinateReasonable ( const vec_t c )
|
||||
{
|
||||
float r = k_flMaxEntityPosCoord;
|
||||
return c > -r && c < r;
|
||||
}
|
||||
|
||||
inline bool IsEntityPositionReasonable( const Vector &v )
|
||||
{
|
||||
float r = k_flMaxEntityPosCoord;
|
||||
return
|
||||
v.x > -r && v.x < r &&
|
||||
v.y > -r && v.y < r &&
|
||||
v.z > -r && v.z < r;
|
||||
}
|
||||
|
||||
// Returns:
|
||||
// -1 - velocity is really, REALLY bad and probably should be rejected.
|
||||
// 0 - velocity was suspicious and clamped.
|
||||
// 1 - velocity was OK and not modified
|
||||
extern int CheckEntityVelocity( Vector &v );
|
||||
|
||||
inline bool IsEntityQAngleReasonable( const QAngle &q )
|
||||
{
|
||||
float r = k_flMaxEntityEulerAngle;
|
||||
return
|
||||
q.x > -r && q.x < r &&
|
||||
q.y > -r && q.y < r &&
|
||||
q.z > -r && q.z < r;
|
||||
}
|
||||
|
||||
// Angular velocity in exponential map form
|
||||
inline bool IsEntityAngularVelocityReasonable( const Vector &q )
|
||||
{
|
||||
float r = k_flMaxEntitySpinRate;
|
||||
return
|
||||
q.x > -r && q.x < r &&
|
||||
q.y > -r && q.y < r &&
|
||||
q.z > -r && q.z < r;
|
||||
}
|
||||
|
||||
// Angular velocity of each Euler angle.
|
||||
inline bool IsEntityQAngleVelReasonable( const QAngle &q )
|
||||
{
|
||||
float r = k_flMaxEntitySpinRate;
|
||||
return
|
||||
q.x > -r && q.x < r &&
|
||||
q.y > -r && q.y < r &&
|
||||
q.z > -r && q.z < r;
|
||||
}
|
||||
|
||||
extern bool CheckEmitReasonablePhysicsSpew();
|
||||
|
||||
#endif // BASEENTITY_SHARED_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,138 +1,138 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEGRENADE_SHARED_H
|
||||
#define BASEGRENADE_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
|
||||
#define CBaseGrenade C_BaseGrenade
|
||||
|
||||
#include "c_basecombatcharacter.h"
|
||||
|
||||
#else
|
||||
|
||||
#include "basecombatcharacter.h"
|
||||
#include "player_pickup.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define BASEGRENADE_EXPLOSION_VOLUME 1024
|
||||
|
||||
class CTakeDamageInfo;
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
class CBaseGrenade : public CBaseAnimating, public CDefaultPlayerPickupVPhysics
|
||||
#else
|
||||
class CBaseGrenade : public CBaseAnimating
|
||||
#endif
|
||||
{
|
||||
DECLARE_CLASS( CBaseGrenade, CBaseAnimating );
|
||||
public:
|
||||
|
||||
CBaseGrenade(void);
|
||||
~CBaseGrenade(void);
|
||||
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
#endif
|
||||
|
||||
virtual void Precache( void );
|
||||
|
||||
virtual void Explode( trace_t *pTrace, int bitsDamageType );
|
||||
void Smoke( void );
|
||||
|
||||
void BounceTouch( CBaseEntity *pOther );
|
||||
void SlideTouch( CBaseEntity *pOther );
|
||||
void ExplodeTouch( CBaseEntity *pOther );
|
||||
void DangerSoundThink( void );
|
||||
void PreDetonate( void );
|
||||
virtual void Detonate( void );
|
||||
void DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void TumbleThink( void );
|
||||
|
||||
virtual Vector GetBlastForce() { return vec3_origin; }
|
||||
|
||||
virtual void BounceSound( void );
|
||||
virtual int BloodColor( void ) { return DONT_BLEED; }
|
||||
virtual void Event_Killed( const CTakeDamageInfo &info );
|
||||
|
||||
virtual float GetShakeAmplitude( void ) { return 25.0; }
|
||||
virtual float GetShakeRadius( void ) { return 750.0; }
|
||||
|
||||
// Damage accessors.
|
||||
virtual float GetDamage()
|
||||
{
|
||||
return m_flDamage;
|
||||
}
|
||||
virtual float GetDamageRadius()
|
||||
{
|
||||
return m_DmgRadius;
|
||||
}
|
||||
|
||||
virtual void SetDamage(float flDamage)
|
||||
{
|
||||
m_flDamage = flDamage;
|
||||
}
|
||||
|
||||
virtual void SetDamageRadius(float flDamageRadius)
|
||||
{
|
||||
m_DmgRadius = flDamageRadius;
|
||||
}
|
||||
|
||||
// Bounce sound accessors.
|
||||
void SetBounceSound( const char *pszBounceSound )
|
||||
{
|
||||
m_iszBounceSound = MAKE_STRING( pszBounceSound );
|
||||
}
|
||||
|
||||
CBaseCombatCharacter *GetThrower( void );
|
||||
void SetThrower( CBaseCombatCharacter *pThrower );
|
||||
CBaseEntity *GetOriginalThrower() { return m_hOriginalThrower; }
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
// Allow +USE pickup
|
||||
int ObjectCaps()
|
||||
{
|
||||
return (BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_USE_IN_RADIUS);
|
||||
}
|
||||
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
#endif
|
||||
|
||||
public:
|
||||
IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_vecVelocity );
|
||||
IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_fFlags );
|
||||
|
||||
bool m_bHasWarnedAI; // whether or not this grenade has issued its DANGER sound to the world sound list yet.
|
||||
CNetworkVar( bool, m_bIsLive ); // Is this grenade live, or can it be picked up?
|
||||
CNetworkVar( float, m_DmgRadius ); // How far do I do damage?
|
||||
CNetworkVar( float, m_flNextAttack );
|
||||
float m_flDetonateTime; // Time at which to detonate.
|
||||
float m_flWarnAITime; // Time at which to warn the AI
|
||||
|
||||
protected:
|
||||
|
||||
CNetworkVar( float, m_flDamage ); // Damage to inflict.
|
||||
string_t m_iszBounceSound; // The sound to make on bouncing. If not NULL, overrides the BounceSound() function.
|
||||
|
||||
private:
|
||||
CNetworkHandle( CBaseEntity, m_hThrower ); // Who threw this grenade
|
||||
EHANDLE m_hOriginalThrower; // Who was the original thrower of this grenade
|
||||
|
||||
CBaseGrenade( const CBaseGrenade & ); // not defined, not accessible
|
||||
|
||||
};
|
||||
|
||||
#endif // BASEGRENADE_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEGRENADE_SHARED_H
|
||||
#define BASEGRENADE_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
|
||||
#define CBaseGrenade C_BaseGrenade
|
||||
|
||||
#include "c_basecombatcharacter.h"
|
||||
|
||||
#else
|
||||
|
||||
#include "basecombatcharacter.h"
|
||||
#include "player_pickup.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define BASEGRENADE_EXPLOSION_VOLUME 1024
|
||||
|
||||
class CTakeDamageInfo;
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
class CBaseGrenade : public CBaseAnimating, public CDefaultPlayerPickupVPhysics
|
||||
#else
|
||||
class CBaseGrenade : public CBaseAnimating
|
||||
#endif
|
||||
{
|
||||
DECLARE_CLASS( CBaseGrenade, CBaseAnimating );
|
||||
public:
|
||||
|
||||
CBaseGrenade(void);
|
||||
~CBaseGrenade(void);
|
||||
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
#endif
|
||||
|
||||
virtual void Precache( void );
|
||||
|
||||
virtual void Explode( trace_t *pTrace, int bitsDamageType );
|
||||
void Smoke( void );
|
||||
|
||||
void BounceTouch( CBaseEntity *pOther );
|
||||
void SlideTouch( CBaseEntity *pOther );
|
||||
void ExplodeTouch( CBaseEntity *pOther );
|
||||
void DangerSoundThink( void );
|
||||
void PreDetonate( void );
|
||||
virtual void Detonate( void );
|
||||
void DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void TumbleThink( void );
|
||||
|
||||
virtual Vector GetBlastForce() { return vec3_origin; }
|
||||
|
||||
virtual void BounceSound( void );
|
||||
virtual int BloodColor( void ) { return DONT_BLEED; }
|
||||
virtual void Event_Killed( const CTakeDamageInfo &info );
|
||||
|
||||
virtual float GetShakeAmplitude( void ) { return 25.0; }
|
||||
virtual float GetShakeRadius( void ) { return 750.0; }
|
||||
|
||||
// Damage accessors.
|
||||
virtual float GetDamage()
|
||||
{
|
||||
return m_flDamage;
|
||||
}
|
||||
virtual float GetDamageRadius()
|
||||
{
|
||||
return m_DmgRadius;
|
||||
}
|
||||
|
||||
virtual void SetDamage(float flDamage)
|
||||
{
|
||||
m_flDamage = flDamage;
|
||||
}
|
||||
|
||||
virtual void SetDamageRadius(float flDamageRadius)
|
||||
{
|
||||
m_DmgRadius = flDamageRadius;
|
||||
}
|
||||
|
||||
// Bounce sound accessors.
|
||||
void SetBounceSound( const char *pszBounceSound )
|
||||
{
|
||||
m_iszBounceSound = MAKE_STRING( pszBounceSound );
|
||||
}
|
||||
|
||||
CBaseCombatCharacter *GetThrower( void );
|
||||
void SetThrower( CBaseCombatCharacter *pThrower );
|
||||
CBaseEntity *GetOriginalThrower() { return m_hOriginalThrower; }
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
// Allow +USE pickup
|
||||
int ObjectCaps()
|
||||
{
|
||||
return (BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_USE_IN_RADIUS);
|
||||
}
|
||||
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
#endif
|
||||
|
||||
public:
|
||||
IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_vecVelocity );
|
||||
IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_fFlags );
|
||||
|
||||
bool m_bHasWarnedAI; // whether or not this grenade has issued its DANGER sound to the world sound list yet.
|
||||
CNetworkVar( bool, m_bIsLive ); // Is this grenade live, or can it be picked up?
|
||||
CNetworkVar( float, m_DmgRadius ); // How far do I do damage?
|
||||
CNetworkVar( float, m_flNextAttack );
|
||||
float m_flDetonateTime; // Time at which to detonate.
|
||||
float m_flWarnAITime; // Time at which to warn the AI
|
||||
|
||||
protected:
|
||||
|
||||
CNetworkVar( float, m_flDamage ); // Damage to inflict.
|
||||
string_t m_iszBounceSound; // The sound to make on bouncing. If not NULL, overrides the BounceSound() function.
|
||||
|
||||
private:
|
||||
CNetworkHandle( CBaseEntity, m_hThrower ); // Who threw this grenade
|
||||
EHANDLE m_hOriginalThrower; // Who was the original thrower of this grenade
|
||||
|
||||
CBaseGrenade( const CBaseGrenade & ); // not defined, not accessible
|
||||
|
||||
};
|
||||
|
||||
#endif // BASEGRENADE_SHARED_H
|
||||
|
||||
@@ -1,115 +1,115 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "baseparticleentity.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "toolframework_client.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
IMPLEMENT_NETWORKCLASS_ALIASED( BaseParticleEntity, DT_BaseParticleEntity )
|
||||
|
||||
BEGIN_NETWORK_TABLE( CBaseParticleEntity, DT_BaseParticleEntity )
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
BEGIN_PREDICTION_DATA( CBaseParticleEntity )
|
||||
END_PREDICTION_DATA()
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
REGISTER_EFFECT( CBaseParticleEntity );
|
||||
#endif
|
||||
|
||||
CBaseParticleEntity::CBaseParticleEntity( void )
|
||||
{
|
||||
#if defined( CLIENT_DLL )
|
||||
m_bSimulate = true;
|
||||
m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
CBaseParticleEntity::~CBaseParticleEntity( void )
|
||||
{
|
||||
#if defined( CLIENT_DLL )
|
||||
if ( ToolsEnabled() && ( m_nToolParticleEffectId != TOOLPARTICLESYSTEMID_INVALID ) && clienttools->IsInRecordingMode() )
|
||||
{
|
||||
KeyValues *msg = new KeyValues( "ParticleSystem_Destroy" );
|
||||
msg->SetInt( "id", m_nToolParticleEffectId );
|
||||
m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
int CBaseParticleEntity::UpdateTransmitState( void )
|
||||
{
|
||||
if ( IsEffectActive( EF_NODRAW ) )
|
||||
return SetTransmitState( FL_EDICT_DONTSEND );
|
||||
|
||||
if ( IsEFlagSet( EFL_IN_SKYBOX ) )
|
||||
return SetTransmitState( FL_EDICT_ALWAYS );
|
||||
|
||||
// cull against PVS
|
||||
return SetTransmitState( FL_EDICT_PVSCHECK );
|
||||
}
|
||||
#endif
|
||||
|
||||
void CBaseParticleEntity::Activate()
|
||||
{
|
||||
#if !defined( CLIENT_DLL )
|
||||
BaseClass::Activate();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CBaseParticleEntity::Think()
|
||||
{
|
||||
Remove( );
|
||||
}
|
||||
|
||||
|
||||
void CBaseParticleEntity::FollowEntity(CBaseEntity *pEntity)
|
||||
{
|
||||
BaseClass::FollowEntity( pEntity );
|
||||
SetLocalOrigin( vec3_origin );
|
||||
}
|
||||
|
||||
|
||||
void CBaseParticleEntity::SetLifetime(float lifetime)
|
||||
{
|
||||
if(lifetime == -1)
|
||||
SetNextThink( TICK_NEVER_THINK );
|
||||
else
|
||||
SetNextThink( gpGlobals->curtime + lifetime );
|
||||
}
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
const Vector &CBaseParticleEntity::GetSortOrigin()
|
||||
{
|
||||
// By default, we do the cheaper behavior of getting the root parent's abs origin, so we don't have to
|
||||
// setup any bones along the way. If this screws anything up, we can always make it an option.
|
||||
return GetRootMoveParent()->GetAbsOrigin();
|
||||
}
|
||||
|
||||
void CBaseParticleEntity::SimulateParticles( CParticleSimulateIterator *pIterator )
|
||||
{
|
||||
// If you derive from CBaseParticleEntity, you must implement simulation and rendering.
|
||||
Assert( false );
|
||||
}
|
||||
|
||||
void CBaseParticleEntity::RenderParticles( CParticleRenderIterator *pIterator )
|
||||
{
|
||||
// If you derive from CBaseParticleEntity, you must implement simulation and rendering.
|
||||
Assert( false );
|
||||
}
|
||||
|
||||
#endif
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "baseparticleentity.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "toolframework_client.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
IMPLEMENT_NETWORKCLASS_ALIASED( BaseParticleEntity, DT_BaseParticleEntity )
|
||||
|
||||
BEGIN_NETWORK_TABLE( CBaseParticleEntity, DT_BaseParticleEntity )
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
BEGIN_PREDICTION_DATA( CBaseParticleEntity )
|
||||
END_PREDICTION_DATA()
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
REGISTER_EFFECT( CBaseParticleEntity );
|
||||
#endif
|
||||
|
||||
CBaseParticleEntity::CBaseParticleEntity( void )
|
||||
{
|
||||
#if defined( CLIENT_DLL )
|
||||
m_bSimulate = true;
|
||||
m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
CBaseParticleEntity::~CBaseParticleEntity( void )
|
||||
{
|
||||
#if defined( CLIENT_DLL )
|
||||
if ( ToolsEnabled() && ( m_nToolParticleEffectId != TOOLPARTICLESYSTEMID_INVALID ) && clienttools->IsInRecordingMode() )
|
||||
{
|
||||
KeyValues *msg = new KeyValues( "ParticleSystem_Destroy" );
|
||||
msg->SetInt( "id", m_nToolParticleEffectId );
|
||||
m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
int CBaseParticleEntity::UpdateTransmitState( void )
|
||||
{
|
||||
if ( IsEffectActive( EF_NODRAW ) )
|
||||
return SetTransmitState( FL_EDICT_DONTSEND );
|
||||
|
||||
if ( IsEFlagSet( EFL_IN_SKYBOX ) )
|
||||
return SetTransmitState( FL_EDICT_ALWAYS );
|
||||
|
||||
// cull against PVS
|
||||
return SetTransmitState( FL_EDICT_PVSCHECK );
|
||||
}
|
||||
#endif
|
||||
|
||||
void CBaseParticleEntity::Activate()
|
||||
{
|
||||
#if !defined( CLIENT_DLL )
|
||||
BaseClass::Activate();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CBaseParticleEntity::Think()
|
||||
{
|
||||
Remove( );
|
||||
}
|
||||
|
||||
|
||||
void CBaseParticleEntity::FollowEntity(CBaseEntity *pEntity)
|
||||
{
|
||||
BaseClass::FollowEntity( pEntity );
|
||||
SetLocalOrigin( vec3_origin );
|
||||
}
|
||||
|
||||
|
||||
void CBaseParticleEntity::SetLifetime(float lifetime)
|
||||
{
|
||||
if(lifetime == -1)
|
||||
SetNextThink( TICK_NEVER_THINK );
|
||||
else
|
||||
SetNextThink( gpGlobals->curtime + lifetime );
|
||||
}
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
const Vector &CBaseParticleEntity::GetSortOrigin()
|
||||
{
|
||||
// By default, we do the cheaper behavior of getting the root parent's abs origin, so we don't have to
|
||||
// setup any bones along the way. If this screws anything up, we can always make it an option.
|
||||
return GetRootMoveParent()->GetAbsOrigin();
|
||||
}
|
||||
|
||||
void CBaseParticleEntity::SimulateParticles( CParticleSimulateIterator *pIterator )
|
||||
{
|
||||
// If you derive from CBaseParticleEntity, you must implement simulation and rendering.
|
||||
Assert( false );
|
||||
}
|
||||
|
||||
void CBaseParticleEntity::RenderParticles( CParticleRenderIterator *pIterator )
|
||||
{
|
||||
// If you derive from CBaseParticleEntity, you must implement simulation and rendering.
|
||||
Assert( false );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,100 +1,100 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
// Particle system entities can derive from this to handle some of the mundane
|
||||
// functionality of hooking into the engine's entity system.
|
||||
|
||||
#ifndef PARTICLE_BASEEFFECT_H
|
||||
#define PARTICLE_BASEEFFECT_H
|
||||
|
||||
#include "predictable_entity.h"
|
||||
#include "baseentity_shared.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBaseParticleEntity C_BaseParticleEntity
|
||||
|
||||
#include "particlemgr.h"
|
||||
|
||||
#endif
|
||||
|
||||
class CBaseParticleEntity : public CBaseEntity
|
||||
#if defined( CLIENT_DLL )
|
||||
, public IParticleEffect
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CBaseParticleEntity, CBaseEntity );
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
CBaseParticleEntity();
|
||||
virtual ~CBaseParticleEntity();
|
||||
|
||||
// CBaseEntity overrides.
|
||||
public:
|
||||
#if !defined( CLIENT_DLL )
|
||||
virtual int UpdateTransmitState( void );
|
||||
#else
|
||||
// Default IParticleEffect overrides.
|
||||
public:
|
||||
|
||||
virtual bool ShouldSimulate() const { return m_bSimulate; }
|
||||
virtual void SetShouldSimulate( bool bSim ) { m_bSimulate = bSim; }
|
||||
|
||||
virtual void SimulateParticles( CParticleSimulateIterator *pIterator );
|
||||
virtual void RenderParticles( CParticleRenderIterator *pIterator );
|
||||
virtual const Vector & GetSortOrigin();
|
||||
public:
|
||||
CParticleEffectBinding m_ParticleEffect;
|
||||
#endif
|
||||
|
||||
virtual void Activate();
|
||||
virtual void Think();
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
// NOTE: Ths enclosed particle effect binding will do all the drawing
|
||||
virtual bool ShouldDraw() { return false; }
|
||||
|
||||
int AllocateToolParticleEffectId();
|
||||
int GetToolParticleEffectId() const;
|
||||
|
||||
private:
|
||||
int m_nToolParticleEffectId;
|
||||
bool m_bSimulate;
|
||||
#endif
|
||||
|
||||
public:
|
||||
void FollowEntity(CBaseEntity *pEntity);
|
||||
|
||||
// UTIL_Remove will be called after the specified amount of time.
|
||||
// If you pass in -1, the entity will never go away automatically.
|
||||
void SetLifetime(float lifetime);
|
||||
|
||||
private:
|
||||
CBaseParticleEntity( const CBaseParticleEntity & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
|
||||
inline int CBaseParticleEntity::GetToolParticleEffectId() const
|
||||
{
|
||||
return m_nToolParticleEffectId;
|
||||
}
|
||||
|
||||
inline int CBaseParticleEntity::AllocateToolParticleEffectId()
|
||||
{
|
||||
m_nToolParticleEffectId = ParticleMgr()->AllocateToolParticleEffectId();
|
||||
return m_nToolParticleEffectId;
|
||||
}
|
||||
|
||||
#endif // CLIENT_DLL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
// Particle system entities can derive from this to handle some of the mundane
|
||||
// functionality of hooking into the engine's entity system.
|
||||
|
||||
#ifndef PARTICLE_BASEEFFECT_H
|
||||
#define PARTICLE_BASEEFFECT_H
|
||||
|
||||
#include "predictable_entity.h"
|
||||
#include "baseentity_shared.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBaseParticleEntity C_BaseParticleEntity
|
||||
|
||||
#include "particlemgr.h"
|
||||
|
||||
#endif
|
||||
|
||||
class CBaseParticleEntity : public CBaseEntity
|
||||
#if defined( CLIENT_DLL )
|
||||
, public IParticleEffect
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CBaseParticleEntity, CBaseEntity );
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
CBaseParticleEntity();
|
||||
virtual ~CBaseParticleEntity();
|
||||
|
||||
// CBaseEntity overrides.
|
||||
public:
|
||||
#if !defined( CLIENT_DLL )
|
||||
virtual int UpdateTransmitState( void );
|
||||
#else
|
||||
// Default IParticleEffect overrides.
|
||||
public:
|
||||
|
||||
virtual bool ShouldSimulate() const { return m_bSimulate; }
|
||||
virtual void SetShouldSimulate( bool bSim ) { m_bSimulate = bSim; }
|
||||
|
||||
virtual void SimulateParticles( CParticleSimulateIterator *pIterator );
|
||||
virtual void RenderParticles( CParticleRenderIterator *pIterator );
|
||||
virtual const Vector & GetSortOrigin();
|
||||
public:
|
||||
CParticleEffectBinding m_ParticleEffect;
|
||||
#endif
|
||||
|
||||
virtual void Activate();
|
||||
virtual void Think();
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
// NOTE: Ths enclosed particle effect binding will do all the drawing
|
||||
virtual bool ShouldDraw() { return false; }
|
||||
|
||||
int AllocateToolParticleEffectId();
|
||||
int GetToolParticleEffectId() const;
|
||||
|
||||
private:
|
||||
int m_nToolParticleEffectId;
|
||||
bool m_bSimulate;
|
||||
#endif
|
||||
|
||||
public:
|
||||
void FollowEntity(CBaseEntity *pEntity);
|
||||
|
||||
// UTIL_Remove will be called after the specified amount of time.
|
||||
// If you pass in -1, the entity will never go away automatically.
|
||||
void SetLifetime(float lifetime);
|
||||
|
||||
private:
|
||||
CBaseParticleEntity( const CBaseParticleEntity & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
|
||||
inline int CBaseParticleEntity::GetToolParticleEffectId() const
|
||||
{
|
||||
return m_nToolParticleEffectId;
|
||||
}
|
||||
|
||||
inline int CBaseParticleEntity::AllocateToolParticleEffectId()
|
||||
{
|
||||
m_nToolParticleEffectId = ParticleMgr()->AllocateToolParticleEffectId();
|
||||
return m_nToolParticleEffectId;
|
||||
}
|
||||
|
||||
#endif // CLIENT_DLL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+2084
-2084
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,64 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEPLAYER_SHARED_H
|
||||
#define BASEPLAYER_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// PlayerUse defines
|
||||
#define PLAYER_USE_RADIUS 80.f
|
||||
#define CONE_45_DEGREES 0.707f
|
||||
#define CONE_15_DEGREES 0.9659258f
|
||||
#define CONE_90_DEGREES 0
|
||||
|
||||
#define TRAIN_ACTIVE 0x80
|
||||
#define TRAIN_NEW 0xc0
|
||||
#define TRAIN_OFF 0x00
|
||||
#define TRAIN_NEUTRAL 0x01
|
||||
#define TRAIN_SLOW 0x02
|
||||
#define TRAIN_MEDIUM 0x03
|
||||
#define TRAIN_FAST 0x04
|
||||
#define TRAIN_BACK 0x05
|
||||
|
||||
// entity messages
|
||||
#define PLAY_PLAYER_JINGLE 1
|
||||
#define UPDATE_PLAYER_RADAR 2
|
||||
|
||||
#define DEATH_ANIMATION_TIME 3.0f
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector m_vecAutoAimDir; // The direction autoaim wishes to point.
|
||||
Vector m_vecAutoAimPoint; // The point (world space) that autoaim is aiming at.
|
||||
EHANDLE m_hAutoAimEntity; // The entity that autoaim is aiming at.
|
||||
bool m_bAutoAimAssisting; // If this is true, autoaim is aiming at the target. If false, the player is naturally aiming.
|
||||
bool m_bOnTargetNatural;
|
||||
float m_fScale;
|
||||
float m_fMaxDist;
|
||||
} autoaim_params_t;
|
||||
|
||||
enum stepsoundtimes_t
|
||||
{
|
||||
STEPSOUNDTIME_NORMAL = 0,
|
||||
STEPSOUNDTIME_ON_LADDER,
|
||||
STEPSOUNDTIME_WATER_KNEE,
|
||||
STEPSOUNDTIME_WATER_FOOT,
|
||||
};
|
||||
|
||||
void CopySoundNameWithModifierToken( char *pchDest, const char *pchSource, int nMaxLenInChars, const char *pchToken );
|
||||
|
||||
// Shared header file for players
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBasePlayer C_BasePlayer
|
||||
#include "c_baseplayer.h"
|
||||
#else
|
||||
#include "player.h"
|
||||
#endif
|
||||
|
||||
#endif // BASEPLAYER_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEPLAYER_SHARED_H
|
||||
#define BASEPLAYER_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// PlayerUse defines
|
||||
#define PLAYER_USE_RADIUS 80.f
|
||||
#define CONE_45_DEGREES 0.707f
|
||||
#define CONE_15_DEGREES 0.9659258f
|
||||
#define CONE_90_DEGREES 0
|
||||
|
||||
#define TRAIN_ACTIVE 0x80
|
||||
#define TRAIN_NEW 0xc0
|
||||
#define TRAIN_OFF 0x00
|
||||
#define TRAIN_NEUTRAL 0x01
|
||||
#define TRAIN_SLOW 0x02
|
||||
#define TRAIN_MEDIUM 0x03
|
||||
#define TRAIN_FAST 0x04
|
||||
#define TRAIN_BACK 0x05
|
||||
|
||||
// entity messages
|
||||
#define PLAY_PLAYER_JINGLE 1
|
||||
#define UPDATE_PLAYER_RADAR 2
|
||||
|
||||
#define DEATH_ANIMATION_TIME 3.0f
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector m_vecAutoAimDir; // The direction autoaim wishes to point.
|
||||
Vector m_vecAutoAimPoint; // The point (world space) that autoaim is aiming at.
|
||||
EHANDLE m_hAutoAimEntity; // The entity that autoaim is aiming at.
|
||||
bool m_bAutoAimAssisting; // If this is true, autoaim is aiming at the target. If false, the player is naturally aiming.
|
||||
bool m_bOnTargetNatural;
|
||||
float m_fScale;
|
||||
float m_fMaxDist;
|
||||
} autoaim_params_t;
|
||||
|
||||
enum stepsoundtimes_t
|
||||
{
|
||||
STEPSOUNDTIME_NORMAL = 0,
|
||||
STEPSOUNDTIME_ON_LADDER,
|
||||
STEPSOUNDTIME_WATER_KNEE,
|
||||
STEPSOUNDTIME_WATER_FOOT,
|
||||
};
|
||||
|
||||
void CopySoundNameWithModifierToken( char *pchDest, const char *pchSource, int nMaxLenInChars, const char *pchToken );
|
||||
|
||||
// Shared header file for players
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBasePlayer C_BasePlayer
|
||||
#include "c_baseplayer.h"
|
||||
#else
|
||||
#include "player.h"
|
||||
#endif
|
||||
|
||||
#endif // BASEPLAYER_SHARED_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,210 +1,210 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEVIEWMODEL_SHARED_H
|
||||
#define BASEVIEWMODEL_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "predictable_entity.h"
|
||||
#include "utlvector.h"
|
||||
#include "baseplayer_shared.h"
|
||||
#include "shared_classnames.h"
|
||||
#include "econ/ihasowner.h"
|
||||
|
||||
class CBaseCombatWeapon;
|
||||
class CBaseCombatCharacter;
|
||||
class CVGuiScreen;
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBaseViewModel C_BaseViewModel
|
||||
#define CBaseCombatWeapon C_BaseCombatWeapon
|
||||
#endif
|
||||
|
||||
#define VIEWMODEL_INDEX_BITS 1
|
||||
|
||||
class CBaseViewModel : public CBaseAnimating, public IHasOwner
|
||||
{
|
||||
DECLARE_CLASS( CBaseViewModel, CBaseAnimating );
|
||||
public:
|
||||
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
#endif
|
||||
|
||||
CBaseViewModel( void );
|
||||
~CBaseViewModel( void );
|
||||
|
||||
|
||||
bool IsViewable(void) { return false; }
|
||||
|
||||
virtual void UpdateOnRemove( void );
|
||||
|
||||
// Weapon client handling
|
||||
virtual void SendViewModelMatchingSequence( int sequence );
|
||||
virtual void SetWeaponModel( const char *pszModelname, CBaseCombatWeapon *weapon );
|
||||
|
||||
virtual void CalcViewModelLag( Vector& origin, QAngle& angles, QAngle& original_angles );
|
||||
virtual void CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition,
|
||||
const QAngle& eyeAngles );
|
||||
virtual void AddViewModelBob( CBasePlayer *owner, Vector& eyePosition, QAngle& eyeAngles ) {};
|
||||
|
||||
// Initializes the viewmodel for use
|
||||
void SetOwner( CBaseEntity *pEntity );
|
||||
void SetIndex( int nIndex );
|
||||
// Returns which viewmodel it is
|
||||
int ViewModelIndex( ) const;
|
||||
|
||||
virtual void Precache( void );
|
||||
|
||||
virtual void Spawn( void );
|
||||
|
||||
virtual CBaseEntity *GetOwner( void ) { return m_hOwner; };
|
||||
|
||||
virtual void AddEffects( int nEffects );
|
||||
virtual void RemoveEffects( int nEffects );
|
||||
|
||||
void SpawnControlPanels();
|
||||
void DestroyControlPanels();
|
||||
void SetControlPanelsActive( bool bState );
|
||||
void ShowControlPanells( bool show );
|
||||
|
||||
virtual CBaseCombatWeapon *GetOwningWeapon( void );
|
||||
|
||||
virtual CBaseEntity *GetOwnerViaInterface( void ) { return GetOwner(); }
|
||||
|
||||
virtual bool IsSelfAnimating()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector m_vecLastFacing;
|
||||
|
||||
// Only support prediction in TF2 for now
|
||||
#if defined( INVASION_DLL ) || defined( INVASION_CLIENT_DLL )
|
||||
// All predicted weapons need to implement and return true
|
||||
virtual bool IsPredicted( void ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
virtual int UpdateTransmitState( void );
|
||||
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
virtual void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
|
||||
#else
|
||||
|
||||
virtual RenderGroup_t GetRenderGroup();
|
||||
|
||||
// Only supported in TF2 right now
|
||||
#if defined( INVASION_CLIENT_DLL )
|
||||
|
||||
virtual bool ShouldPredict( void )
|
||||
{
|
||||
if ( GetOwner() && GetOwner() == C_BasePlayer::GetLocalPlayer() )
|
||||
return true;
|
||||
|
||||
return BaseClass::ShouldPredict();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
|
||||
virtual bool Interpolate( float currentTime );
|
||||
|
||||
bool ShouldFlipViewModel();
|
||||
void UpdateAnimationParity( void );
|
||||
|
||||
virtual void ApplyBoneMatrixTransform( matrix3x4_t& transform );
|
||||
|
||||
virtual bool ShouldDraw();
|
||||
virtual int DrawModel( int flags );
|
||||
virtual int InternalDrawModel( int flags );
|
||||
int DrawOverriddenViewmodel( int flags );
|
||||
virtual int GetFxBlend( void );
|
||||
virtual bool IsTransparent( void );
|
||||
virtual bool UsesPowerOfTwoFrameBufferTexture( void );
|
||||
|
||||
// Should this object cast shadows?
|
||||
virtual ShadowType_t ShadowCastType() { return SHADOWS_NONE; }
|
||||
|
||||
// Should this object receive shadows?
|
||||
virtual bool ShouldReceiveProjectedTextures( int flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add entity to visible view models list?
|
||||
virtual void AddEntity( void );
|
||||
|
||||
virtual void GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS]);
|
||||
|
||||
// See C_StudioModel's definition of this.
|
||||
virtual void UncorrectViewModelAttachment( Vector &vOrigin );
|
||||
|
||||
// (inherited from C_BaseAnimating)
|
||||
virtual void FormatViewModelAttachment( int nAttachment, matrix3x4_t &attachmentToWorld );
|
||||
virtual bool IsViewModel() const;
|
||||
|
||||
CBaseCombatWeapon *GetWeapon() const { return m_hWeapon.Get(); }
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
virtual bool ShouldResetSequenceOnNewModel( void ) { return false; }
|
||||
|
||||
// Attachments
|
||||
virtual int LookupAttachment( const char *pAttachmentName );
|
||||
virtual bool GetAttachment( int number, matrix3x4_t &matrix );
|
||||
virtual bool GetAttachment( int number, Vector &origin );
|
||||
virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
|
||||
virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
|
||||
#endif
|
||||
|
||||
private:
|
||||
CBaseViewModel( const CBaseViewModel & ); // not defined, not accessible
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
CNetworkVar( int, m_nViewModelIndex ); // Which viewmodel is it?
|
||||
CNetworkHandle( CBaseEntity, m_hOwner ); // Player or AI carrying this weapon
|
||||
|
||||
// soonest time Update will call WeaponIdle
|
||||
float m_flTimeWeaponIdle;
|
||||
|
||||
Activity m_Activity;
|
||||
|
||||
// Used to force restart on client, only needs a few bits
|
||||
CNetworkVar( int, m_nAnimationParity );
|
||||
|
||||
// Weapon art
|
||||
string_t m_sVMName; // View model of this weapon
|
||||
string_t m_sAnimationPrefix; // Prefix of the animations that should be used by the player carrying this weapon
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
int m_nOldAnimationParity;
|
||||
#endif
|
||||
|
||||
|
||||
typedef CHandle< CBaseCombatWeapon > CBaseCombatWeaponHandle;
|
||||
CNetworkVar( CBaseCombatWeaponHandle, m_hWeapon );
|
||||
|
||||
// Control panel
|
||||
typedef CHandle<CVGuiScreen> ScreenHandle_t;
|
||||
CUtlVector<ScreenHandle_t> m_hScreens;
|
||||
};
|
||||
|
||||
#endif // BASEVIEWMODEL_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEVIEWMODEL_SHARED_H
|
||||
#define BASEVIEWMODEL_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "predictable_entity.h"
|
||||
#include "utlvector.h"
|
||||
#include "baseplayer_shared.h"
|
||||
#include "shared_classnames.h"
|
||||
#include "econ/ihasowner.h"
|
||||
|
||||
class CBaseCombatWeapon;
|
||||
class CBaseCombatCharacter;
|
||||
class CVGuiScreen;
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBaseViewModel C_BaseViewModel
|
||||
#define CBaseCombatWeapon C_BaseCombatWeapon
|
||||
#endif
|
||||
|
||||
#define VIEWMODEL_INDEX_BITS 1
|
||||
|
||||
class CBaseViewModel : public CBaseAnimating, public IHasOwner
|
||||
{
|
||||
DECLARE_CLASS( CBaseViewModel, CBaseAnimating );
|
||||
public:
|
||||
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
#endif
|
||||
|
||||
CBaseViewModel( void );
|
||||
~CBaseViewModel( void );
|
||||
|
||||
|
||||
bool IsViewable(void) { return false; }
|
||||
|
||||
virtual void UpdateOnRemove( void );
|
||||
|
||||
// Weapon client handling
|
||||
virtual void SendViewModelMatchingSequence( int sequence );
|
||||
virtual void SetWeaponModel( const char *pszModelname, CBaseCombatWeapon *weapon );
|
||||
|
||||
virtual void CalcViewModelLag( Vector& origin, QAngle& angles, QAngle& original_angles );
|
||||
virtual void CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition,
|
||||
const QAngle& eyeAngles );
|
||||
virtual void AddViewModelBob( CBasePlayer *owner, Vector& eyePosition, QAngle& eyeAngles ) {};
|
||||
|
||||
// Initializes the viewmodel for use
|
||||
void SetOwner( CBaseEntity *pEntity );
|
||||
void SetIndex( int nIndex );
|
||||
// Returns which viewmodel it is
|
||||
int ViewModelIndex( ) const;
|
||||
|
||||
virtual void Precache( void );
|
||||
|
||||
virtual void Spawn( void );
|
||||
|
||||
virtual CBaseEntity *GetOwner( void ) { return m_hOwner; };
|
||||
|
||||
virtual void AddEffects( int nEffects );
|
||||
virtual void RemoveEffects( int nEffects );
|
||||
|
||||
void SpawnControlPanels();
|
||||
void DestroyControlPanels();
|
||||
void SetControlPanelsActive( bool bState );
|
||||
void ShowControlPanells( bool show );
|
||||
|
||||
virtual CBaseCombatWeapon *GetOwningWeapon( void );
|
||||
|
||||
virtual CBaseEntity *GetOwnerViaInterface( void ) { return GetOwner(); }
|
||||
|
||||
virtual bool IsSelfAnimating()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector m_vecLastFacing;
|
||||
|
||||
// Only support prediction in TF2 for now
|
||||
#if defined( INVASION_DLL ) || defined( INVASION_CLIENT_DLL )
|
||||
// All predicted weapons need to implement and return true
|
||||
virtual bool IsPredicted( void ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
virtual int UpdateTransmitState( void );
|
||||
virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
virtual void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
|
||||
#else
|
||||
|
||||
virtual RenderGroup_t GetRenderGroup();
|
||||
|
||||
// Only supported in TF2 right now
|
||||
#if defined( INVASION_CLIENT_DLL )
|
||||
|
||||
virtual bool ShouldPredict( void )
|
||||
{
|
||||
if ( GetOwner() && GetOwner() == C_BasePlayer::GetLocalPlayer() )
|
||||
return true;
|
||||
|
||||
return BaseClass::ShouldPredict();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
|
||||
virtual bool Interpolate( float currentTime );
|
||||
|
||||
bool ShouldFlipViewModel();
|
||||
void UpdateAnimationParity( void );
|
||||
|
||||
virtual void ApplyBoneMatrixTransform( matrix3x4_t& transform );
|
||||
|
||||
virtual bool ShouldDraw();
|
||||
virtual int DrawModel( int flags );
|
||||
virtual int InternalDrawModel( int flags );
|
||||
int DrawOverriddenViewmodel( int flags );
|
||||
virtual int GetFxBlend( void );
|
||||
virtual bool IsTransparent( void );
|
||||
virtual bool UsesPowerOfTwoFrameBufferTexture( void );
|
||||
|
||||
// Should this object cast shadows?
|
||||
virtual ShadowType_t ShadowCastType() { return SHADOWS_NONE; }
|
||||
|
||||
// Should this object receive shadows?
|
||||
virtual bool ShouldReceiveProjectedTextures( int flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add entity to visible view models list?
|
||||
virtual void AddEntity( void );
|
||||
|
||||
virtual void GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS]);
|
||||
|
||||
// See C_StudioModel's definition of this.
|
||||
virtual void UncorrectViewModelAttachment( Vector &vOrigin );
|
||||
|
||||
// (inherited from C_BaseAnimating)
|
||||
virtual void FormatViewModelAttachment( int nAttachment, matrix3x4_t &attachmentToWorld );
|
||||
virtual bool IsViewModel() const;
|
||||
|
||||
CBaseCombatWeapon *GetWeapon() const { return m_hWeapon.Get(); }
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
virtual bool ShouldResetSequenceOnNewModel( void ) { return false; }
|
||||
|
||||
// Attachments
|
||||
virtual int LookupAttachment( const char *pAttachmentName );
|
||||
virtual bool GetAttachment( int number, matrix3x4_t &matrix );
|
||||
virtual bool GetAttachment( int number, Vector &origin );
|
||||
virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
|
||||
virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
|
||||
#endif
|
||||
|
||||
private:
|
||||
CBaseViewModel( const CBaseViewModel & ); // not defined, not accessible
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
CNetworkVar( int, m_nViewModelIndex ); // Which viewmodel is it?
|
||||
CNetworkHandle( CBaseEntity, m_hOwner ); // Player or AI carrying this weapon
|
||||
|
||||
// soonest time Update will call WeaponIdle
|
||||
float m_flTimeWeaponIdle;
|
||||
|
||||
Activity m_Activity;
|
||||
|
||||
// Used to force restart on client, only needs a few bits
|
||||
CNetworkVar( int, m_nAnimationParity );
|
||||
|
||||
// Weapon art
|
||||
string_t m_sVMName; // View model of this weapon
|
||||
string_t m_sAnimationPrefix; // Prefix of the animations that should be used by the player carrying this weapon
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
int m_nOldAnimationParity;
|
||||
#endif
|
||||
|
||||
|
||||
typedef CHandle< CBaseCombatWeapon > CBaseCombatWeaponHandle;
|
||||
CNetworkVar( CBaseCombatWeaponHandle, m_hWeapon );
|
||||
|
||||
// Control panel
|
||||
typedef CHandle<CVGuiScreen> ScreenHandle_t;
|
||||
CUtlVector<ScreenHandle_t> m_hScreens;
|
||||
};
|
||||
|
||||
#endif // BASEVIEWMODEL_SHARED_H
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if !defined( BEAM_FLAGS_H )
|
||||
#define BEAM_FLAGS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FBEAM_STARTENTITY = 0x00000001,
|
||||
FBEAM_ENDENTITY = 0x00000002,
|
||||
FBEAM_FADEIN = 0x00000004,
|
||||
FBEAM_FADEOUT = 0x00000008,
|
||||
FBEAM_SINENOISE = 0x00000010,
|
||||
FBEAM_SOLID = 0x00000020,
|
||||
FBEAM_SHADEIN = 0x00000040,
|
||||
FBEAM_SHADEOUT = 0x00000080,
|
||||
FBEAM_ONLYNOISEONCE = 0x00000100, // Only calculate our noise once
|
||||
FBEAM_NOTILE = 0x00000200,
|
||||
FBEAM_USE_HITBOXES = 0x00000400, // Attachment indices represent hitbox indices instead when this is set.
|
||||
FBEAM_STARTVISIBLE = 0x00000800, // Has this client actually seen this beam's start entity yet?
|
||||
FBEAM_ENDVISIBLE = 0x00001000, // Has this client actually seen this beam's end entity yet?
|
||||
FBEAM_ISACTIVE = 0x00002000,
|
||||
FBEAM_FOREVER = 0x00004000,
|
||||
FBEAM_HALOBEAM = 0x00008000, // When drawing a beam with a halo, don't ignore the segments and endwidth
|
||||
FBEAM_REVERSED = 0x00010000,
|
||||
NUM_BEAM_FLAGS = 17 // KEEP THIS UPDATED!
|
||||
};
|
||||
|
||||
#endif // BEAM_FLAGS_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#if !defined( BEAM_FLAGS_H )
|
||||
#define BEAM_FLAGS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FBEAM_STARTENTITY = 0x00000001,
|
||||
FBEAM_ENDENTITY = 0x00000002,
|
||||
FBEAM_FADEIN = 0x00000004,
|
||||
FBEAM_FADEOUT = 0x00000008,
|
||||
FBEAM_SINENOISE = 0x00000010,
|
||||
FBEAM_SOLID = 0x00000020,
|
||||
FBEAM_SHADEIN = 0x00000040,
|
||||
FBEAM_SHADEOUT = 0x00000080,
|
||||
FBEAM_ONLYNOISEONCE = 0x00000100, // Only calculate our noise once
|
||||
FBEAM_NOTILE = 0x00000200,
|
||||
FBEAM_USE_HITBOXES = 0x00000400, // Attachment indices represent hitbox indices instead when this is set.
|
||||
FBEAM_STARTVISIBLE = 0x00000800, // Has this client actually seen this beam's start entity yet?
|
||||
FBEAM_ENDVISIBLE = 0x00001000, // Has this client actually seen this beam's end entity yet?
|
||||
FBEAM_ISACTIVE = 0x00002000,
|
||||
FBEAM_FOREVER = 0x00004000,
|
||||
FBEAM_HALOBEAM = 0x00008000, // When drawing a beam with a halo, don't ignore the segments and endwidth
|
||||
FBEAM_REVERSED = 0x00010000,
|
||||
NUM_BEAM_FLAGS = 17 // KEEP THIS UPDATED!
|
||||
};
|
||||
|
||||
#endif // BEAM_FLAGS_H
|
||||
|
||||
+1201
-1201
File diff suppressed because it is too large
Load Diff
+476
-476
@@ -1,476 +1,476 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BEAM_H
|
||||
#define BEAM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "baseentity_shared.h"
|
||||
#include "baseplayer_shared.h"
|
||||
#if !defined( CLIENT_DLL )
|
||||
#include "entityoutput.h"
|
||||
#endif
|
||||
|
||||
#include "beam_flags.h"
|
||||
|
||||
#define MAX_BEAM_WIDTH 102.3f
|
||||
#define MAX_BEAM_SCROLLSPEED 100.0f
|
||||
#define MAX_BEAM_NOISEAMPLITUDE 64
|
||||
|
||||
#define SF_BEAM_STARTON 0x0001
|
||||
#define SF_BEAM_TOGGLE 0x0002
|
||||
#define SF_BEAM_RANDOM 0x0004
|
||||
#define SF_BEAM_RING 0x0008
|
||||
#define SF_BEAM_SPARKSTART 0x0010
|
||||
#define SF_BEAM_SPARKEND 0x0020
|
||||
#define SF_BEAM_DECALS 0x0040
|
||||
#define SF_BEAM_SHADEIN 0x0080
|
||||
#define SF_BEAM_SHADEOUT 0x0100
|
||||
#define SF_BEAM_TAPEROUT 0x0200 // Tapers to zero
|
||||
#define SF_BEAM_TEMPORARY 0x8000
|
||||
|
||||
#define ATTACHMENT_INDEX_BITS 5
|
||||
#define ATTACHMENT_INDEX_MASK ((1 << ATTACHMENT_INDEX_BITS) - 1)
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBeam C_Beam
|
||||
#include "c_pixel_visibility.h"
|
||||
#endif
|
||||
|
||||
class CBeam : public CBaseEntity
|
||||
{
|
||||
DECLARE_CLASS( CBeam, CBaseEntity );
|
||||
public:
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
#endif
|
||||
|
||||
CBeam();
|
||||
|
||||
virtual void SetModel( const char *szModelName );
|
||||
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
#if !defined( CLIENT_DLL )
|
||||
int ObjectCaps( void );
|
||||
void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
|
||||
int UpdateTransmitState( void );
|
||||
int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
#endif
|
||||
|
||||
virtual int DrawDebugTextOverlays(void);
|
||||
|
||||
// These functions are here to show the way beams are encoded as entities.
|
||||
// Encoding beams as entities simplifies their management in the client/server architecture
|
||||
void SetType( int type );
|
||||
void SetBeamFlags( int flags );
|
||||
void SetBeamFlag( int flag );
|
||||
|
||||
// NOTE: Start + End Pos are specified in *relative* coordinates
|
||||
void SetStartPos( const Vector &pos );
|
||||
void SetEndPos( const Vector &pos );
|
||||
|
||||
// This will change things so the abs position matches the requested spot
|
||||
void SetAbsStartPos( const Vector &pos );
|
||||
void SetAbsEndPos( const Vector &pos );
|
||||
|
||||
const Vector &GetAbsStartPos( void ) const;
|
||||
const Vector &GetAbsEndPos( void ) const;
|
||||
|
||||
void SetStartEntity( CBaseEntity *pEntity );
|
||||
void SetEndEntity( CBaseEntity *pEntity );
|
||||
|
||||
void SetStartAttachment( int attachment );
|
||||
void SetEndAttachment( int attachment );
|
||||
|
||||
void SetTexture( int spriteIndex );
|
||||
void SetHaloTexture( int spriteIndex );
|
||||
void SetHaloScale( float haloScale );
|
||||
void SetWidth( float width );
|
||||
void SetEndWidth( float endWidth );
|
||||
void SetFadeLength( float fadeLength );
|
||||
void SetNoise( float amplitude );
|
||||
void SetColor( int r, int g, int b );
|
||||
void SetBrightness( int brightness );
|
||||
void SetFrame( float frame );
|
||||
void SetScrollRate( int speed );
|
||||
void SetFireTime( float flFireTime );
|
||||
void SetFrameRate( float flFrameRate ) { m_flFrameRate = flFrameRate; }
|
||||
|
||||
void SetMinDXLevel( int nMinDXLevel ) { m_nMinDXLevel = nMinDXLevel; }
|
||||
|
||||
void TurnOn( void );
|
||||
void TurnOff( void );
|
||||
|
||||
int GetType( void ) const;
|
||||
int GetBeamFlags( void ) const;
|
||||
CBaseEntity* GetStartEntityPtr( void ) const;
|
||||
int GetStartEntity( void ) const;
|
||||
CBaseEntity* GetEndEntityPtr( void ) const;
|
||||
int GetEndEntity( void ) const;
|
||||
int GetStartAttachment() const;
|
||||
int GetEndAttachment() const;
|
||||
|
||||
virtual const Vector &WorldSpaceCenter( void ) const;
|
||||
|
||||
int GetTexture( void );
|
||||
float GetWidth( void ) const;
|
||||
float GetEndWidth( void ) const;
|
||||
float GetFadeLength( void ) const;
|
||||
float GetNoise( void ) const;
|
||||
int GetBrightness( void ) const;
|
||||
float GetFrame( void ) const;
|
||||
float GetScrollRate( void ) const;
|
||||
float GetHDRColorScale( void ) const;
|
||||
void SetHDRColorScale( float flScale ) { m_flHDRColorScale = flScale; }
|
||||
|
||||
|
||||
// Call after you change start/end positions
|
||||
void RelinkBeam( void );
|
||||
|
||||
void DoSparks( const Vector &start, const Vector &end );
|
||||
CBaseEntity *RandomTargetname( const char *szName );
|
||||
void BeamDamage( trace_t *ptr );
|
||||
// Init after BeamCreate()
|
||||
void BeamInit( const char *pSpriteName, float width );
|
||||
void PointsInit( const Vector &start, const Vector &end );
|
||||
void PointEntInit( const Vector &start, CBaseEntity *pEndEntity );
|
||||
void EntsInit( CBaseEntity *pStartEntity, CBaseEntity *pEndEntity );
|
||||
void LaserInit( CBaseEntity *pStartEntity, CBaseEntity *pEndEntity );
|
||||
void HoseInit( const Vector &start, const Vector &direction );
|
||||
void SplineInit( int nNumEnts, CBaseEntity** pEntList, int *attachment );
|
||||
|
||||
// Input handlers
|
||||
|
||||
static CBeam *BeamCreate( const char *pSpriteName, float width );
|
||||
static CBeam *BeamCreatePredictable( const char *module, int line, bool persist, const char *pSpriteName, float width, CBasePlayer *pOwner );
|
||||
|
||||
void LiveForTime( float time );
|
||||
void BeamDamageInstant( trace_t *ptr, float damage );
|
||||
|
||||
// Only supported in TF2 right now
|
||||
#if defined( INVASION_CLIENT_DLL )
|
||||
virtual bool ShouldPredict( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual const char *GetDecalName( void ) { return "BigShot"; }
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
// IClientEntity overrides.
|
||||
public:
|
||||
virtual int DrawModel( int flags );
|
||||
virtual bool IsTransparent( void );
|
||||
virtual bool ShouldDraw();
|
||||
virtual bool IgnoresZBuffer( void ) const { return true; }
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
virtual bool OnPredictedEntityRemove( bool isbeingremoved, C_BaseEntity *predicted );
|
||||
|
||||
// Add beam to visible entities list?
|
||||
virtual void AddEntity( void );
|
||||
virtual bool ShouldReceiveProjectedTextures( int flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Beam Data Elements
|
||||
private:
|
||||
// Computes the bounding box of a beam local to the origin of the beam
|
||||
void ComputeBounds( Vector& mins, Vector& maxs );
|
||||
|
||||
friend void RecvProxy_Beam_ScrollSpeed( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
friend class CViewRenderBeams;
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
CNetworkVar( float, m_flFrameRate );
|
||||
CNetworkVar( float, m_flHDRColorScale );
|
||||
float m_flFireTime;
|
||||
float m_flDamage; // Damage per second to touchers.
|
||||
CNetworkVar( int, m_nNumBeamEnts );
|
||||
#if defined( CLIENT_DLL )
|
||||
pixelvis_handle_t m_queryHandleHalo;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if !defined( CLIENT_DLL )
|
||||
void InputNoise( inputdata_t &inputdata );
|
||||
void InputWidth( inputdata_t &inputdata );
|
||||
void InputColorRedValue( inputdata_t &inputdata );
|
||||
void InputColorBlueValue( inputdata_t &inputdata );
|
||||
void InputColorGreenValue( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
// Beam Data Elements
|
||||
CNetworkVar( int, m_nHaloIndex );
|
||||
CNetworkVar( int, m_nBeamType );
|
||||
CNetworkVar( int, m_nBeamFlags );
|
||||
CNetworkArray( EHANDLE, m_hAttachEntity, MAX_BEAM_ENTS );
|
||||
CNetworkArray( int, m_nAttachIndex, MAX_BEAM_ENTS );
|
||||
CNetworkVar( float, m_fWidth );
|
||||
CNetworkVar( float, m_fEndWidth );
|
||||
CNetworkVar( float, m_fFadeLength );
|
||||
CNetworkVar( float, m_fHaloScale );
|
||||
CNetworkVar( float, m_fAmplitude );
|
||||
CNetworkVar( float, m_fStartFrame );
|
||||
CNetworkVar( float, m_fSpeed );
|
||||
CNetworkVar( int, m_nMinDXLevel );
|
||||
CNetworkVar( float, m_flFrame );
|
||||
|
||||
CNetworkVector( m_vecEndPos );
|
||||
|
||||
EHANDLE m_hEndEntity;
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
int m_nDissolveType;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#ifdef PORTAL
|
||||
CNetworkVar( bool, m_bDrawInMainRender );
|
||||
CNetworkVar( bool, m_bDrawInPortalRender );
|
||||
#endif //#ifdef PORTAL
|
||||
};
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inline methods
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int CBeam::ObjectCaps( void )
|
||||
{
|
||||
int flags = 0;
|
||||
if ( HasSpawnFlags( SF_BEAM_TEMPORARY ) )
|
||||
flags = FCAP_DONT_SAVE;
|
||||
return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void CBeam::SetFireTime( float flFireTime )
|
||||
{
|
||||
m_flFireTime = flFireTime;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// NOTE: Start + End Pos are specified in *relative* coordinates
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CBeam::SetStartPos( const Vector &pos )
|
||||
{
|
||||
#if defined( CLIENT_DLL )
|
||||
SetNetworkOrigin( pos );
|
||||
#endif
|
||||
SetLocalOrigin( pos );
|
||||
}
|
||||
|
||||
inline void CBeam::SetEndPos( const Vector &pos )
|
||||
{
|
||||
m_vecEndPos = pos;
|
||||
}
|
||||
|
||||
// center point of beam
|
||||
inline const Vector &CBeam::WorldSpaceCenter( void ) const
|
||||
{
|
||||
Vector &vecResult = AllocTempVector();
|
||||
VectorAdd( GetAbsStartPos(), GetAbsEndPos(), vecResult );
|
||||
vecResult *= 0.5f;
|
||||
return vecResult;
|
||||
}
|
||||
|
||||
inline void CBeam::SetStartAttachment( int attachment )
|
||||
{
|
||||
Assert( (attachment & ~ATTACHMENT_INDEX_MASK) == 0 );
|
||||
m_nAttachIndex.Set( 0, attachment );
|
||||
}
|
||||
|
||||
inline void CBeam::SetEndAttachment( int attachment )
|
||||
{
|
||||
Assert( (attachment & ~ATTACHMENT_INDEX_MASK) == 0 );
|
||||
m_nAttachIndex.Set( m_nNumBeamEnts-1, attachment );
|
||||
}
|
||||
|
||||
inline void CBeam::SetTexture( int spriteIndex )
|
||||
{
|
||||
SetModelIndex( spriteIndex );
|
||||
}
|
||||
|
||||
inline void CBeam::SetHaloTexture( int spriteIndex )
|
||||
{
|
||||
m_nHaloIndex = spriteIndex;
|
||||
}
|
||||
|
||||
inline void CBeam::SetHaloScale( float haloScale )
|
||||
{
|
||||
m_fHaloScale = haloScale;
|
||||
}
|
||||
|
||||
inline void CBeam::SetWidth( float width )
|
||||
{
|
||||
Assert( width <= MAX_BEAM_WIDTH );
|
||||
m_fWidth = MIN( MAX_BEAM_WIDTH, width );
|
||||
}
|
||||
|
||||
inline void CBeam::SetEndWidth( float endWidth )
|
||||
{
|
||||
Assert( endWidth <= MAX_BEAM_WIDTH );
|
||||
m_fEndWidth = MIN( MAX_BEAM_WIDTH, endWidth );
|
||||
}
|
||||
|
||||
inline void CBeam::SetFadeLength( float fadeLength )
|
||||
{
|
||||
m_fFadeLength = fadeLength;
|
||||
}
|
||||
|
||||
inline void CBeam::SetNoise( float amplitude )
|
||||
{
|
||||
m_fAmplitude = amplitude;
|
||||
}
|
||||
|
||||
inline void CBeam::SetColor( int r, int g, int b )
|
||||
{
|
||||
SetRenderColor( r, g, b, GetRenderColor().a );
|
||||
}
|
||||
|
||||
inline void CBeam::SetBrightness( int brightness )
|
||||
{
|
||||
SetRenderColorA( brightness );
|
||||
}
|
||||
|
||||
inline void CBeam::SetFrame( float frame )
|
||||
{
|
||||
m_fStartFrame = frame;
|
||||
}
|
||||
|
||||
inline void CBeam::SetScrollRate( int speed )
|
||||
{
|
||||
m_fSpeed = speed;
|
||||
}
|
||||
|
||||
inline CBaseEntity* CBeam::GetStartEntityPtr( void ) const
|
||||
{
|
||||
return m_hAttachEntity[0].Get();
|
||||
}
|
||||
|
||||
inline int CBeam::GetStartEntity( void ) const
|
||||
{
|
||||
CBaseEntity *pEntity = m_hAttachEntity[0].Get();
|
||||
return pEntity ? pEntity->entindex() : 0;
|
||||
}
|
||||
|
||||
inline CBaseEntity* CBeam::GetEndEntityPtr( void ) const
|
||||
{
|
||||
return m_hAttachEntity[1].Get();
|
||||
}
|
||||
|
||||
inline int CBeam::GetEndEntity( void ) const
|
||||
{
|
||||
CBaseEntity *pEntity = m_hAttachEntity[m_nNumBeamEnts-1].Get();
|
||||
return pEntity ? pEntity->entindex() : 0;
|
||||
}
|
||||
|
||||
inline int CBeam::GetStartAttachment() const
|
||||
{
|
||||
return m_nAttachIndex[0] & ATTACHMENT_INDEX_MASK;
|
||||
}
|
||||
|
||||
inline int CBeam::GetEndAttachment() const
|
||||
{
|
||||
return m_nAttachIndex[m_nNumBeamEnts-1] & ATTACHMENT_INDEX_MASK;
|
||||
}
|
||||
|
||||
inline int CBeam::GetTexture( void )
|
||||
{
|
||||
return GetModelIndex();
|
||||
}
|
||||
|
||||
inline float CBeam::GetWidth( void ) const
|
||||
{
|
||||
return m_fWidth;
|
||||
}
|
||||
|
||||
inline float CBeam::GetEndWidth( void ) const
|
||||
{
|
||||
return m_fEndWidth;
|
||||
}
|
||||
|
||||
inline float CBeam::GetFadeLength( void ) const
|
||||
{
|
||||
return m_fFadeLength;
|
||||
}
|
||||
|
||||
inline float CBeam::GetNoise( void ) const
|
||||
{
|
||||
return m_fAmplitude;
|
||||
}
|
||||
|
||||
inline int CBeam::GetBrightness( void ) const
|
||||
{
|
||||
return GetRenderColor().a;
|
||||
}
|
||||
|
||||
inline float CBeam::GetFrame( void ) const
|
||||
{
|
||||
return m_fStartFrame;
|
||||
}
|
||||
|
||||
inline float CBeam::GetScrollRate( void ) const
|
||||
{
|
||||
return m_fSpeed;
|
||||
}
|
||||
|
||||
inline float CBeam::GetHDRColorScale( void ) const
|
||||
{
|
||||
return m_flHDRColorScale;
|
||||
}
|
||||
|
||||
inline void CBeam::LiveForTime( float time )
|
||||
{
|
||||
SetThink(&CBeam::SUB_Remove);
|
||||
SetNextThink( gpGlobals->curtime + time );
|
||||
}
|
||||
|
||||
inline void CBeam::BeamDamageInstant( trace_t *ptr, float damage )
|
||||
{
|
||||
m_flDamage = damage;
|
||||
m_flFireTime = gpGlobals->curtime - 1;
|
||||
BeamDamage(ptr);
|
||||
}
|
||||
|
||||
bool IsStaticPointEntity( CBaseEntity *pEnt );
|
||||
|
||||
// Macro to wrap creation
|
||||
#define BEAM_CREATE_PREDICTABLE( name, width, player ) \
|
||||
CBeam::BeamCreatePredictable( __FILE__, __LINE__, false, name, width, player )
|
||||
|
||||
#define BEAM_CREATE_PREDICTABLE_PERSIST( name, width, player ) \
|
||||
CBeam::BeamCreatePredictable( __FILE__, __LINE__, true, name, width, player )
|
||||
|
||||
// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12)
|
||||
#define BEAMENT_ENTITY(x) ((x)&0xFFF)
|
||||
#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF)
|
||||
|
||||
|
||||
// Beam types, encoded as a byte
|
||||
enum
|
||||
{
|
||||
BEAM_POINTS = 0,
|
||||
BEAM_ENTPOINT,
|
||||
BEAM_ENTS,
|
||||
BEAM_HOSE,
|
||||
BEAM_SPLINE,
|
||||
BEAM_LASER,
|
||||
NUM_BEAM_TYPES
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAM_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BEAM_H
|
||||
#define BEAM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "baseentity_shared.h"
|
||||
#include "baseplayer_shared.h"
|
||||
#if !defined( CLIENT_DLL )
|
||||
#include "entityoutput.h"
|
||||
#endif
|
||||
|
||||
#include "beam_flags.h"
|
||||
|
||||
#define MAX_BEAM_WIDTH 102.3f
|
||||
#define MAX_BEAM_SCROLLSPEED 100.0f
|
||||
#define MAX_BEAM_NOISEAMPLITUDE 64
|
||||
|
||||
#define SF_BEAM_STARTON 0x0001
|
||||
#define SF_BEAM_TOGGLE 0x0002
|
||||
#define SF_BEAM_RANDOM 0x0004
|
||||
#define SF_BEAM_RING 0x0008
|
||||
#define SF_BEAM_SPARKSTART 0x0010
|
||||
#define SF_BEAM_SPARKEND 0x0020
|
||||
#define SF_BEAM_DECALS 0x0040
|
||||
#define SF_BEAM_SHADEIN 0x0080
|
||||
#define SF_BEAM_SHADEOUT 0x0100
|
||||
#define SF_BEAM_TAPEROUT 0x0200 // Tapers to zero
|
||||
#define SF_BEAM_TEMPORARY 0x8000
|
||||
|
||||
#define ATTACHMENT_INDEX_BITS 5
|
||||
#define ATTACHMENT_INDEX_MASK ((1 << ATTACHMENT_INDEX_BITS) - 1)
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBeam C_Beam
|
||||
#include "c_pixel_visibility.h"
|
||||
#endif
|
||||
|
||||
class CBeam : public CBaseEntity
|
||||
{
|
||||
DECLARE_CLASS( CBeam, CBaseEntity );
|
||||
public:
|
||||
DECLARE_NETWORKCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
#if !defined( CLIENT_DLL )
|
||||
DECLARE_DATADESC();
|
||||
#endif
|
||||
|
||||
CBeam();
|
||||
|
||||
virtual void SetModel( const char *szModelName );
|
||||
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
#if !defined( CLIENT_DLL )
|
||||
int ObjectCaps( void );
|
||||
void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
|
||||
int UpdateTransmitState( void );
|
||||
int ShouldTransmit( const CCheckTransmitInfo *pInfo );
|
||||
#endif
|
||||
|
||||
virtual int DrawDebugTextOverlays(void);
|
||||
|
||||
// These functions are here to show the way beams are encoded as entities.
|
||||
// Encoding beams as entities simplifies their management in the client/server architecture
|
||||
void SetType( int type );
|
||||
void SetBeamFlags( int flags );
|
||||
void SetBeamFlag( int flag );
|
||||
|
||||
// NOTE: Start + End Pos are specified in *relative* coordinates
|
||||
void SetStartPos( const Vector &pos );
|
||||
void SetEndPos( const Vector &pos );
|
||||
|
||||
// This will change things so the abs position matches the requested spot
|
||||
void SetAbsStartPos( const Vector &pos );
|
||||
void SetAbsEndPos( const Vector &pos );
|
||||
|
||||
const Vector &GetAbsStartPos( void ) const;
|
||||
const Vector &GetAbsEndPos( void ) const;
|
||||
|
||||
void SetStartEntity( CBaseEntity *pEntity );
|
||||
void SetEndEntity( CBaseEntity *pEntity );
|
||||
|
||||
void SetStartAttachment( int attachment );
|
||||
void SetEndAttachment( int attachment );
|
||||
|
||||
void SetTexture( int spriteIndex );
|
||||
void SetHaloTexture( int spriteIndex );
|
||||
void SetHaloScale( float haloScale );
|
||||
void SetWidth( float width );
|
||||
void SetEndWidth( float endWidth );
|
||||
void SetFadeLength( float fadeLength );
|
||||
void SetNoise( float amplitude );
|
||||
void SetColor( int r, int g, int b );
|
||||
void SetBrightness( int brightness );
|
||||
void SetFrame( float frame );
|
||||
void SetScrollRate( int speed );
|
||||
void SetFireTime( float flFireTime );
|
||||
void SetFrameRate( float flFrameRate ) { m_flFrameRate = flFrameRate; }
|
||||
|
||||
void SetMinDXLevel( int nMinDXLevel ) { m_nMinDXLevel = nMinDXLevel; }
|
||||
|
||||
void TurnOn( void );
|
||||
void TurnOff( void );
|
||||
|
||||
int GetType( void ) const;
|
||||
int GetBeamFlags( void ) const;
|
||||
CBaseEntity* GetStartEntityPtr( void ) const;
|
||||
int GetStartEntity( void ) const;
|
||||
CBaseEntity* GetEndEntityPtr( void ) const;
|
||||
int GetEndEntity( void ) const;
|
||||
int GetStartAttachment() const;
|
||||
int GetEndAttachment() const;
|
||||
|
||||
virtual const Vector &WorldSpaceCenter( void ) const;
|
||||
|
||||
int GetTexture( void );
|
||||
float GetWidth( void ) const;
|
||||
float GetEndWidth( void ) const;
|
||||
float GetFadeLength( void ) const;
|
||||
float GetNoise( void ) const;
|
||||
int GetBrightness( void ) const;
|
||||
float GetFrame( void ) const;
|
||||
float GetScrollRate( void ) const;
|
||||
float GetHDRColorScale( void ) const;
|
||||
void SetHDRColorScale( float flScale ) { m_flHDRColorScale = flScale; }
|
||||
|
||||
|
||||
// Call after you change start/end positions
|
||||
void RelinkBeam( void );
|
||||
|
||||
void DoSparks( const Vector &start, const Vector &end );
|
||||
CBaseEntity *RandomTargetname( const char *szName );
|
||||
void BeamDamage( trace_t *ptr );
|
||||
// Init after BeamCreate()
|
||||
void BeamInit( const char *pSpriteName, float width );
|
||||
void PointsInit( const Vector &start, const Vector &end );
|
||||
void PointEntInit( const Vector &start, CBaseEntity *pEndEntity );
|
||||
void EntsInit( CBaseEntity *pStartEntity, CBaseEntity *pEndEntity );
|
||||
void LaserInit( CBaseEntity *pStartEntity, CBaseEntity *pEndEntity );
|
||||
void HoseInit( const Vector &start, const Vector &direction );
|
||||
void SplineInit( int nNumEnts, CBaseEntity** pEntList, int *attachment );
|
||||
|
||||
// Input handlers
|
||||
|
||||
static CBeam *BeamCreate( const char *pSpriteName, float width );
|
||||
static CBeam *BeamCreatePredictable( const char *module, int line, bool persist, const char *pSpriteName, float width, CBasePlayer *pOwner );
|
||||
|
||||
void LiveForTime( float time );
|
||||
void BeamDamageInstant( trace_t *ptr, float damage );
|
||||
|
||||
// Only supported in TF2 right now
|
||||
#if defined( INVASION_CLIENT_DLL )
|
||||
virtual bool ShouldPredict( void )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual const char *GetDecalName( void ) { return "BigShot"; }
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
// IClientEntity overrides.
|
||||
public:
|
||||
virtual int DrawModel( int flags );
|
||||
virtual bool IsTransparent( void );
|
||||
virtual bool ShouldDraw();
|
||||
virtual bool IgnoresZBuffer( void ) const { return true; }
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
virtual bool OnPredictedEntityRemove( bool isbeingremoved, C_BaseEntity *predicted );
|
||||
|
||||
// Add beam to visible entities list?
|
||||
virtual void AddEntity( void );
|
||||
virtual bool ShouldReceiveProjectedTextures( int flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Beam Data Elements
|
||||
private:
|
||||
// Computes the bounding box of a beam local to the origin of the beam
|
||||
void ComputeBounds( Vector& mins, Vector& maxs );
|
||||
|
||||
friend void RecvProxy_Beam_ScrollSpeed( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
friend class CViewRenderBeams;
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
CNetworkVar( float, m_flFrameRate );
|
||||
CNetworkVar( float, m_flHDRColorScale );
|
||||
float m_flFireTime;
|
||||
float m_flDamage; // Damage per second to touchers.
|
||||
CNetworkVar( int, m_nNumBeamEnts );
|
||||
#if defined( CLIENT_DLL )
|
||||
pixelvis_handle_t m_queryHandleHalo;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if !defined( CLIENT_DLL )
|
||||
void InputNoise( inputdata_t &inputdata );
|
||||
void InputWidth( inputdata_t &inputdata );
|
||||
void InputColorRedValue( inputdata_t &inputdata );
|
||||
void InputColorBlueValue( inputdata_t &inputdata );
|
||||
void InputColorGreenValue( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
// Beam Data Elements
|
||||
CNetworkVar( int, m_nHaloIndex );
|
||||
CNetworkVar( int, m_nBeamType );
|
||||
CNetworkVar( int, m_nBeamFlags );
|
||||
CNetworkArray( EHANDLE, m_hAttachEntity, MAX_BEAM_ENTS );
|
||||
CNetworkArray( int, m_nAttachIndex, MAX_BEAM_ENTS );
|
||||
CNetworkVar( float, m_fWidth );
|
||||
CNetworkVar( float, m_fEndWidth );
|
||||
CNetworkVar( float, m_fFadeLength );
|
||||
CNetworkVar( float, m_fHaloScale );
|
||||
CNetworkVar( float, m_fAmplitude );
|
||||
CNetworkVar( float, m_fStartFrame );
|
||||
CNetworkVar( float, m_fSpeed );
|
||||
CNetworkVar( int, m_nMinDXLevel );
|
||||
CNetworkVar( float, m_flFrame );
|
||||
|
||||
CNetworkVector( m_vecEndPos );
|
||||
|
||||
EHANDLE m_hEndEntity;
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
int m_nDissolveType;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#ifdef PORTAL
|
||||
CNetworkVar( bool, m_bDrawInMainRender );
|
||||
CNetworkVar( bool, m_bDrawInPortalRender );
|
||||
#endif //#ifdef PORTAL
|
||||
};
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inline methods
|
||||
//-----------------------------------------------------------------------------
|
||||
inline int CBeam::ObjectCaps( void )
|
||||
{
|
||||
int flags = 0;
|
||||
if ( HasSpawnFlags( SF_BEAM_TEMPORARY ) )
|
||||
flags = FCAP_DONT_SAVE;
|
||||
return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void CBeam::SetFireTime( float flFireTime )
|
||||
{
|
||||
m_flFireTime = flFireTime;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// NOTE: Start + End Pos are specified in *relative* coordinates
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void CBeam::SetStartPos( const Vector &pos )
|
||||
{
|
||||
#if defined( CLIENT_DLL )
|
||||
SetNetworkOrigin( pos );
|
||||
#endif
|
||||
SetLocalOrigin( pos );
|
||||
}
|
||||
|
||||
inline void CBeam::SetEndPos( const Vector &pos )
|
||||
{
|
||||
m_vecEndPos = pos;
|
||||
}
|
||||
|
||||
// center point of beam
|
||||
inline const Vector &CBeam::WorldSpaceCenter( void ) const
|
||||
{
|
||||
Vector &vecResult = AllocTempVector();
|
||||
VectorAdd( GetAbsStartPos(), GetAbsEndPos(), vecResult );
|
||||
vecResult *= 0.5f;
|
||||
return vecResult;
|
||||
}
|
||||
|
||||
inline void CBeam::SetStartAttachment( int attachment )
|
||||
{
|
||||
Assert( (attachment & ~ATTACHMENT_INDEX_MASK) == 0 );
|
||||
m_nAttachIndex.Set( 0, attachment );
|
||||
}
|
||||
|
||||
inline void CBeam::SetEndAttachment( int attachment )
|
||||
{
|
||||
Assert( (attachment & ~ATTACHMENT_INDEX_MASK) == 0 );
|
||||
m_nAttachIndex.Set( m_nNumBeamEnts-1, attachment );
|
||||
}
|
||||
|
||||
inline void CBeam::SetTexture( int spriteIndex )
|
||||
{
|
||||
SetModelIndex( spriteIndex );
|
||||
}
|
||||
|
||||
inline void CBeam::SetHaloTexture( int spriteIndex )
|
||||
{
|
||||
m_nHaloIndex = spriteIndex;
|
||||
}
|
||||
|
||||
inline void CBeam::SetHaloScale( float haloScale )
|
||||
{
|
||||
m_fHaloScale = haloScale;
|
||||
}
|
||||
|
||||
inline void CBeam::SetWidth( float width )
|
||||
{
|
||||
Assert( width <= MAX_BEAM_WIDTH );
|
||||
m_fWidth = MIN( MAX_BEAM_WIDTH, width );
|
||||
}
|
||||
|
||||
inline void CBeam::SetEndWidth( float endWidth )
|
||||
{
|
||||
Assert( endWidth <= MAX_BEAM_WIDTH );
|
||||
m_fEndWidth = MIN( MAX_BEAM_WIDTH, endWidth );
|
||||
}
|
||||
|
||||
inline void CBeam::SetFadeLength( float fadeLength )
|
||||
{
|
||||
m_fFadeLength = fadeLength;
|
||||
}
|
||||
|
||||
inline void CBeam::SetNoise( float amplitude )
|
||||
{
|
||||
m_fAmplitude = amplitude;
|
||||
}
|
||||
|
||||
inline void CBeam::SetColor( int r, int g, int b )
|
||||
{
|
||||
SetRenderColor( r, g, b, GetRenderColor().a );
|
||||
}
|
||||
|
||||
inline void CBeam::SetBrightness( int brightness )
|
||||
{
|
||||
SetRenderColorA( brightness );
|
||||
}
|
||||
|
||||
inline void CBeam::SetFrame( float frame )
|
||||
{
|
||||
m_fStartFrame = frame;
|
||||
}
|
||||
|
||||
inline void CBeam::SetScrollRate( int speed )
|
||||
{
|
||||
m_fSpeed = speed;
|
||||
}
|
||||
|
||||
inline CBaseEntity* CBeam::GetStartEntityPtr( void ) const
|
||||
{
|
||||
return m_hAttachEntity[0].Get();
|
||||
}
|
||||
|
||||
inline int CBeam::GetStartEntity( void ) const
|
||||
{
|
||||
CBaseEntity *pEntity = m_hAttachEntity[0].Get();
|
||||
return pEntity ? pEntity->entindex() : 0;
|
||||
}
|
||||
|
||||
inline CBaseEntity* CBeam::GetEndEntityPtr( void ) const
|
||||
{
|
||||
return m_hAttachEntity[1].Get();
|
||||
}
|
||||
|
||||
inline int CBeam::GetEndEntity( void ) const
|
||||
{
|
||||
CBaseEntity *pEntity = m_hAttachEntity[m_nNumBeamEnts-1].Get();
|
||||
return pEntity ? pEntity->entindex() : 0;
|
||||
}
|
||||
|
||||
inline int CBeam::GetStartAttachment() const
|
||||
{
|
||||
return m_nAttachIndex[0] & ATTACHMENT_INDEX_MASK;
|
||||
}
|
||||
|
||||
inline int CBeam::GetEndAttachment() const
|
||||
{
|
||||
return m_nAttachIndex[m_nNumBeamEnts-1] & ATTACHMENT_INDEX_MASK;
|
||||
}
|
||||
|
||||
inline int CBeam::GetTexture( void )
|
||||
{
|
||||
return GetModelIndex();
|
||||
}
|
||||
|
||||
inline float CBeam::GetWidth( void ) const
|
||||
{
|
||||
return m_fWidth;
|
||||
}
|
||||
|
||||
inline float CBeam::GetEndWidth( void ) const
|
||||
{
|
||||
return m_fEndWidth;
|
||||
}
|
||||
|
||||
inline float CBeam::GetFadeLength( void ) const
|
||||
{
|
||||
return m_fFadeLength;
|
||||
}
|
||||
|
||||
inline float CBeam::GetNoise( void ) const
|
||||
{
|
||||
return m_fAmplitude;
|
||||
}
|
||||
|
||||
inline int CBeam::GetBrightness( void ) const
|
||||
{
|
||||
return GetRenderColor().a;
|
||||
}
|
||||
|
||||
inline float CBeam::GetFrame( void ) const
|
||||
{
|
||||
return m_fStartFrame;
|
||||
}
|
||||
|
||||
inline float CBeam::GetScrollRate( void ) const
|
||||
{
|
||||
return m_fSpeed;
|
||||
}
|
||||
|
||||
inline float CBeam::GetHDRColorScale( void ) const
|
||||
{
|
||||
return m_flHDRColorScale;
|
||||
}
|
||||
|
||||
inline void CBeam::LiveForTime( float time )
|
||||
{
|
||||
SetThink(&CBeam::SUB_Remove);
|
||||
SetNextThink( gpGlobals->curtime + time );
|
||||
}
|
||||
|
||||
inline void CBeam::BeamDamageInstant( trace_t *ptr, float damage )
|
||||
{
|
||||
m_flDamage = damage;
|
||||
m_flFireTime = gpGlobals->curtime - 1;
|
||||
BeamDamage(ptr);
|
||||
}
|
||||
|
||||
bool IsStaticPointEntity( CBaseEntity *pEnt );
|
||||
|
||||
// Macro to wrap creation
|
||||
#define BEAM_CREATE_PREDICTABLE( name, width, player ) \
|
||||
CBeam::BeamCreatePredictable( __FILE__, __LINE__, false, name, width, player )
|
||||
|
||||
#define BEAM_CREATE_PREDICTABLE_PERSIST( name, width, player ) \
|
||||
CBeam::BeamCreatePredictable( __FILE__, __LINE__, true, name, width, player )
|
||||
|
||||
// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12)
|
||||
#define BEAMENT_ENTITY(x) ((x)&0xFFF)
|
||||
#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF)
|
||||
|
||||
|
||||
// Beam types, encoded as a byte
|
||||
enum
|
||||
{
|
||||
BEAM_POINTS = 0,
|
||||
BEAM_ENTPOINT,
|
||||
BEAM_ENTS,
|
||||
BEAM_HOSE,
|
||||
BEAM_SPLINE,
|
||||
BEAM_LASER,
|
||||
NUM_BEAM_TYPES
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAM_H
|
||||
|
||||
@@ -1,230 +1,230 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cam_thirdperson.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static Vector CAM_HULL_MIN(-CAM_HULL_OFFSET,-CAM_HULL_OFFSET,-CAM_HULL_OFFSET);
|
||||
static Vector CAM_HULL_MAX( CAM_HULL_OFFSET, CAM_HULL_OFFSET, CAM_HULL_OFFSET);
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
#include "input.h"
|
||||
|
||||
|
||||
extern const ConVar *sv_cheats;
|
||||
|
||||
extern ConVar cam_idealdist;
|
||||
extern ConVar cam_idealdistright;
|
||||
extern ConVar cam_idealdistup;
|
||||
|
||||
void CAM_ToThirdPerson(void);
|
||||
void CAM_ToFirstPerson(void);
|
||||
|
||||
void ToggleThirdPerson( bool bValue )
|
||||
{
|
||||
if ( bValue == true )
|
||||
{
|
||||
CAM_ToThirdPerson();
|
||||
}
|
||||
else
|
||||
{
|
||||
CAM_ToFirstPerson();
|
||||
}
|
||||
}
|
||||
|
||||
void ThirdPersonChange( IConVar *pConVar, const char *pOldValue, float flOldValue )
|
||||
{
|
||||
ConVarRef var( pConVar );
|
||||
|
||||
ToggleThirdPerson( var.GetBool() );
|
||||
}
|
||||
|
||||
ConVar cl_thirdperson( "cl_thirdperson", "0", FCVAR_NOT_CONNECTED | FCVAR_USERINFO | FCVAR_ARCHIVE | FCVAR_DEVELOPMENTONLY, "Enables/Disables third person", ThirdPersonChange );
|
||||
|
||||
#endif
|
||||
|
||||
CThirdPersonManager::CThirdPersonManager( void )
|
||||
{
|
||||
}
|
||||
|
||||
void CThirdPersonManager::Init( void )
|
||||
{
|
||||
m_bOverrideThirdPerson = false;
|
||||
m_bForced = false;
|
||||
m_flUpFraction = 0.0f;
|
||||
m_flFraction = 1.0f;
|
||||
|
||||
m_flUpLerpTime = 0.0f;
|
||||
m_flLerpTime = 0.0f;
|
||||
|
||||
m_flUpOffset = CAMERA_UP_OFFSET;
|
||||
|
||||
if ( input )
|
||||
{
|
||||
input->CAM_SetCameraThirdData( NULL, vec3_angle );
|
||||
}
|
||||
}
|
||||
|
||||
void CThirdPersonManager::Update( void )
|
||||
{
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( !sv_cheats )
|
||||
{
|
||||
sv_cheats = cvar->FindVar( "sv_cheats" );
|
||||
}
|
||||
|
||||
// If cheats have been disabled, pull us back out of third-person view.
|
||||
if ( sv_cheats && !sv_cheats->GetBool() && GameRules() && GameRules()->AllowThirdPersonCamera() == false )
|
||||
{
|
||||
if ( (bool)input->CAM_IsThirdPerson() == true )
|
||||
{
|
||||
input->CAM_ToFirstPerson();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( IsOverridingThirdPerson() == false )
|
||||
{
|
||||
if ( (bool)input->CAM_IsThirdPerson() != ( cl_thirdperson.GetBool() || m_bForced ) && GameRules() && GameRules()->AllowThirdPersonCamera() == true )
|
||||
{
|
||||
ToggleThirdPerson( m_bForced || cl_thirdperson.GetBool() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Vector CThirdPersonManager::GetDesiredCameraOffset( void )
|
||||
{
|
||||
if ( IsOverridingThirdPerson() == true )
|
||||
{
|
||||
return Vector( cam_idealdist.GetFloat(), cam_idealdistright.GetFloat(), cam_idealdistup.GetFloat() );
|
||||
}
|
||||
|
||||
return m_vecDesiredCameraOffset;
|
||||
}
|
||||
|
||||
Vector CThirdPersonManager::GetFinalCameraOffset( void )
|
||||
{
|
||||
Vector vDesired = GetDesiredCameraOffset();
|
||||
|
||||
if ( m_flUpFraction != 1.0f )
|
||||
{
|
||||
vDesired.z += m_flUpOffset;
|
||||
}
|
||||
|
||||
return vDesired;
|
||||
|
||||
}
|
||||
|
||||
Vector CThirdPersonManager::GetDistanceFraction( void )
|
||||
{
|
||||
if ( IsOverridingThirdPerson() == true )
|
||||
{
|
||||
return Vector( m_flTargetFraction, m_flTargetFraction, m_flTargetFraction );
|
||||
}
|
||||
|
||||
float flFraction = m_flFraction;
|
||||
float flUpFraction = m_flUpFraction;
|
||||
|
||||
float flFrac = RemapValClamped( gpGlobals->curtime - m_flLerpTime, 0, CAMERA_OFFSET_LERP_TIME, 0, 1 );
|
||||
|
||||
flFraction = Lerp( flFrac, m_flFraction, m_flTargetFraction );
|
||||
|
||||
if ( flFrac == 1.0f )
|
||||
{
|
||||
m_flFraction = m_flTargetFraction;
|
||||
}
|
||||
|
||||
flFrac = RemapValClamped( gpGlobals->curtime - m_flUpLerpTime, 0, CAMERA_UP_OFFSET_LERP_TIME, 0, 1 );
|
||||
|
||||
flUpFraction = 1.0f - Lerp( flFrac, m_flUpFraction, m_flTargetUpFraction );
|
||||
|
||||
if ( flFrac == 1.0f )
|
||||
{
|
||||
m_flUpFraction = m_flTargetUpFraction;
|
||||
}
|
||||
|
||||
return Vector( flFraction, flFraction, flUpFraction );
|
||||
}
|
||||
|
||||
void CThirdPersonManager::PositionCamera( CBasePlayer *pPlayer, QAngle angles )
|
||||
{
|
||||
if ( pPlayer )
|
||||
{
|
||||
trace_t trace;
|
||||
|
||||
Vector camForward, camRight, camUp;
|
||||
|
||||
// find our player's origin, and from there, the eye position
|
||||
Vector origin = pPlayer->GetLocalOrigin();
|
||||
origin += pPlayer->GetViewOffset();
|
||||
|
||||
AngleVectors( angles, &camForward, &camRight, &camUp );
|
||||
|
||||
Vector endPos = origin;
|
||||
|
||||
Vector vecCamOffset = endPos + (camForward * - GetDesiredCameraOffset()[DIST_FORWARD]) + (camRight * GetDesiredCameraOffset()[ DIST_RIGHT ]) + (camUp * GetDesiredCameraOffset()[ DIST_UP ] );
|
||||
|
||||
// use our previously #defined hull to collision trace
|
||||
CTraceFilterSimple traceFilter( pPlayer, COLLISION_GROUP_NONE );
|
||||
UTIL_TraceHull( endPos, vecCamOffset, CAM_HULL_MIN, CAM_HULL_MAX, MASK_SOLID & ~CONTENTS_MONSTER, &traceFilter, &trace );
|
||||
|
||||
if ( trace.fraction != m_flTargetFraction )
|
||||
{
|
||||
m_flLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
m_flTargetFraction = trace.fraction;
|
||||
m_flTargetUpFraction = 1.0f;
|
||||
|
||||
//If we're getting closer to a wall snap the fraction right away.
|
||||
if ( m_flTargetFraction < m_flFraction )
|
||||
{
|
||||
m_flFraction = m_flTargetFraction;
|
||||
m_flLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
|
||||
// move the camera closer if it hit something
|
||||
if( trace.fraction < 1.0 )
|
||||
{
|
||||
m_vecCameraOffset[ DIST ] *= trace.fraction;
|
||||
|
||||
UTIL_TraceHull( endPos, endPos + (camForward * - GetDesiredCameraOffset()[DIST_FORWARD]), CAM_HULL_MIN, CAM_HULL_MAX, MASK_SOLID & ~CONTENTS_MONSTER, &traceFilter, &trace );
|
||||
|
||||
if ( trace.fraction != 1.0f )
|
||||
{
|
||||
if ( trace.fraction != m_flTargetUpFraction )
|
||||
{
|
||||
m_flUpLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
m_flTargetUpFraction = trace.fraction;
|
||||
|
||||
if ( m_flTargetUpFraction < m_flUpFraction )
|
||||
{
|
||||
m_flUpFraction = trace.fraction;
|
||||
m_flUpLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CThirdPersonManager::WantToUseGameThirdPerson( void )
|
||||
{
|
||||
return cl_thirdperson.GetBool() && GameRules() && GameRules()->AllowThirdPersonCamera() && IsOverridingThirdPerson() == false;
|
||||
}
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "cam_thirdperson.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static Vector CAM_HULL_MIN(-CAM_HULL_OFFSET,-CAM_HULL_OFFSET,-CAM_HULL_OFFSET);
|
||||
static Vector CAM_HULL_MAX( CAM_HULL_OFFSET, CAM_HULL_OFFSET, CAM_HULL_OFFSET);
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
#include "input.h"
|
||||
|
||||
|
||||
extern const ConVar *sv_cheats;
|
||||
|
||||
extern ConVar cam_idealdist;
|
||||
extern ConVar cam_idealdistright;
|
||||
extern ConVar cam_idealdistup;
|
||||
|
||||
void CAM_ToThirdPerson(void);
|
||||
void CAM_ToFirstPerson(void);
|
||||
|
||||
void ToggleThirdPerson( bool bValue )
|
||||
{
|
||||
if ( bValue == true )
|
||||
{
|
||||
CAM_ToThirdPerson();
|
||||
}
|
||||
else
|
||||
{
|
||||
CAM_ToFirstPerson();
|
||||
}
|
||||
}
|
||||
|
||||
void ThirdPersonChange( IConVar *pConVar, const char *pOldValue, float flOldValue )
|
||||
{
|
||||
ConVarRef var( pConVar );
|
||||
|
||||
ToggleThirdPerson( var.GetBool() );
|
||||
}
|
||||
|
||||
ConVar cl_thirdperson( "cl_thirdperson", "0", FCVAR_NOT_CONNECTED | FCVAR_USERINFO | FCVAR_ARCHIVE | FCVAR_DEVELOPMENTONLY, "Enables/Disables third person", ThirdPersonChange );
|
||||
|
||||
#endif
|
||||
|
||||
CThirdPersonManager::CThirdPersonManager( void )
|
||||
{
|
||||
}
|
||||
|
||||
void CThirdPersonManager::Init( void )
|
||||
{
|
||||
m_bOverrideThirdPerson = false;
|
||||
m_bForced = false;
|
||||
m_flUpFraction = 0.0f;
|
||||
m_flFraction = 1.0f;
|
||||
|
||||
m_flUpLerpTime = 0.0f;
|
||||
m_flLerpTime = 0.0f;
|
||||
|
||||
m_flUpOffset = CAMERA_UP_OFFSET;
|
||||
|
||||
if ( input )
|
||||
{
|
||||
input->CAM_SetCameraThirdData( NULL, vec3_angle );
|
||||
}
|
||||
}
|
||||
|
||||
void CThirdPersonManager::Update( void )
|
||||
{
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( !sv_cheats )
|
||||
{
|
||||
sv_cheats = cvar->FindVar( "sv_cheats" );
|
||||
}
|
||||
|
||||
// If cheats have been disabled, pull us back out of third-person view.
|
||||
if ( sv_cheats && !sv_cheats->GetBool() && GameRules() && GameRules()->AllowThirdPersonCamera() == false )
|
||||
{
|
||||
if ( (bool)input->CAM_IsThirdPerson() == true )
|
||||
{
|
||||
input->CAM_ToFirstPerson();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( IsOverridingThirdPerson() == false )
|
||||
{
|
||||
if ( (bool)input->CAM_IsThirdPerson() != ( cl_thirdperson.GetBool() || m_bForced ) && GameRules() && GameRules()->AllowThirdPersonCamera() == true )
|
||||
{
|
||||
ToggleThirdPerson( m_bForced || cl_thirdperson.GetBool() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Vector CThirdPersonManager::GetDesiredCameraOffset( void )
|
||||
{
|
||||
if ( IsOverridingThirdPerson() == true )
|
||||
{
|
||||
return Vector( cam_idealdist.GetFloat(), cam_idealdistright.GetFloat(), cam_idealdistup.GetFloat() );
|
||||
}
|
||||
|
||||
return m_vecDesiredCameraOffset;
|
||||
}
|
||||
|
||||
Vector CThirdPersonManager::GetFinalCameraOffset( void )
|
||||
{
|
||||
Vector vDesired = GetDesiredCameraOffset();
|
||||
|
||||
if ( m_flUpFraction != 1.0f )
|
||||
{
|
||||
vDesired.z += m_flUpOffset;
|
||||
}
|
||||
|
||||
return vDesired;
|
||||
|
||||
}
|
||||
|
||||
Vector CThirdPersonManager::GetDistanceFraction( void )
|
||||
{
|
||||
if ( IsOverridingThirdPerson() == true )
|
||||
{
|
||||
return Vector( m_flTargetFraction, m_flTargetFraction, m_flTargetFraction );
|
||||
}
|
||||
|
||||
float flFraction = m_flFraction;
|
||||
float flUpFraction = m_flUpFraction;
|
||||
|
||||
float flFrac = RemapValClamped( gpGlobals->curtime - m_flLerpTime, 0, CAMERA_OFFSET_LERP_TIME, 0, 1 );
|
||||
|
||||
flFraction = Lerp( flFrac, m_flFraction, m_flTargetFraction );
|
||||
|
||||
if ( flFrac == 1.0f )
|
||||
{
|
||||
m_flFraction = m_flTargetFraction;
|
||||
}
|
||||
|
||||
flFrac = RemapValClamped( gpGlobals->curtime - m_flUpLerpTime, 0, CAMERA_UP_OFFSET_LERP_TIME, 0, 1 );
|
||||
|
||||
flUpFraction = 1.0f - Lerp( flFrac, m_flUpFraction, m_flTargetUpFraction );
|
||||
|
||||
if ( flFrac == 1.0f )
|
||||
{
|
||||
m_flUpFraction = m_flTargetUpFraction;
|
||||
}
|
||||
|
||||
return Vector( flFraction, flFraction, flUpFraction );
|
||||
}
|
||||
|
||||
void CThirdPersonManager::PositionCamera( CBasePlayer *pPlayer, QAngle angles )
|
||||
{
|
||||
if ( pPlayer )
|
||||
{
|
||||
trace_t trace;
|
||||
|
||||
Vector camForward, camRight, camUp;
|
||||
|
||||
// find our player's origin, and from there, the eye position
|
||||
Vector origin = pPlayer->GetLocalOrigin();
|
||||
origin += pPlayer->GetViewOffset();
|
||||
|
||||
AngleVectors( angles, &camForward, &camRight, &camUp );
|
||||
|
||||
Vector endPos = origin;
|
||||
|
||||
Vector vecCamOffset = endPos + (camForward * - GetDesiredCameraOffset()[DIST_FORWARD]) + (camRight * GetDesiredCameraOffset()[ DIST_RIGHT ]) + (camUp * GetDesiredCameraOffset()[ DIST_UP ] );
|
||||
|
||||
// use our previously #defined hull to collision trace
|
||||
CTraceFilterSimple traceFilter( pPlayer, COLLISION_GROUP_NONE );
|
||||
UTIL_TraceHull( endPos, vecCamOffset, CAM_HULL_MIN, CAM_HULL_MAX, MASK_SOLID & ~CONTENTS_MONSTER, &traceFilter, &trace );
|
||||
|
||||
if ( trace.fraction != m_flTargetFraction )
|
||||
{
|
||||
m_flLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
m_flTargetFraction = trace.fraction;
|
||||
m_flTargetUpFraction = 1.0f;
|
||||
|
||||
//If we're getting closer to a wall snap the fraction right away.
|
||||
if ( m_flTargetFraction < m_flFraction )
|
||||
{
|
||||
m_flFraction = m_flTargetFraction;
|
||||
m_flLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
|
||||
// move the camera closer if it hit something
|
||||
if( trace.fraction < 1.0 )
|
||||
{
|
||||
m_vecCameraOffset[ DIST ] *= trace.fraction;
|
||||
|
||||
UTIL_TraceHull( endPos, endPos + (camForward * - GetDesiredCameraOffset()[DIST_FORWARD]), CAM_HULL_MIN, CAM_HULL_MAX, MASK_SOLID & ~CONTENTS_MONSTER, &traceFilter, &trace );
|
||||
|
||||
if ( trace.fraction != 1.0f )
|
||||
{
|
||||
if ( trace.fraction != m_flTargetUpFraction )
|
||||
{
|
||||
m_flUpLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
|
||||
m_flTargetUpFraction = trace.fraction;
|
||||
|
||||
if ( m_flTargetUpFraction < m_flUpFraction )
|
||||
{
|
||||
m_flUpFraction = trace.fraction;
|
||||
m_flUpLerpTime = gpGlobals->curtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CThirdPersonManager::WantToUseGameThirdPerson( void )
|
||||
{
|
||||
return cl_thirdperson.GetBool() && GameRules() && GameRules()->AllowThirdPersonCamera() && IsOverridingThirdPerson() == false;
|
||||
}
|
||||
|
||||
|
||||
CThirdPersonManager g_ThirdPersonManager;
|
||||
@@ -1,108 +1,108 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CAM_THIRDPERSON_H
|
||||
#define CAM_THIRDPERSON_H
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "c_baseplayer.h"
|
||||
#else
|
||||
#include "baseplayer.h"
|
||||
#endif
|
||||
|
||||
#define DIST_FORWARD 0
|
||||
#define DIST_RIGHT 1
|
||||
#define DIST_UP 2
|
||||
|
||||
//-------------------------------------------------- Constants
|
||||
|
||||
#define CAM_MIN_DIST 30.0
|
||||
#define CAM_ANGLE_MOVE .5
|
||||
#define MAX_ANGLE_DIFF 10.0
|
||||
#define PITCH_MAX 90.0
|
||||
#define PITCH_MIN 0
|
||||
#define YAW_MAX 135.0
|
||||
#define YAW_MIN -135.0
|
||||
#define DIST 2
|
||||
#define CAM_HULL_OFFSET 14.0 // the size of the bounding hull used for collision checking
|
||||
|
||||
#define CAMERA_UP_OFFSET 25.0f
|
||||
#define CAMERA_OFFSET_LERP_TIME 0.5f
|
||||
#define CAMERA_UP_OFFSET_LERP_TIME 0.25f
|
||||
|
||||
class CThirdPersonManager
|
||||
{
|
||||
public:
|
||||
|
||||
CThirdPersonManager();
|
||||
void SetCameraOffsetAngles( Vector vecOffset ) { m_vecCameraOffset = vecOffset; }
|
||||
Vector GetCameraOffsetAngles( void ) { return m_vecCameraOffset; }
|
||||
|
||||
void SetDesiredCameraOffset( Vector vecOffset ) { m_vecDesiredCameraOffset = vecOffset; }
|
||||
Vector GetDesiredCameraOffset( void );
|
||||
|
||||
Vector GetFinalCameraOffset( void );
|
||||
|
||||
void SetCameraOrigin( Vector vecOffset ) { m_vecCameraOrigin = vecOffset; }
|
||||
Vector GetCameraOrigin( void ) { return m_vecCameraOrigin; }
|
||||
|
||||
void Update( void );
|
||||
|
||||
void PositionCamera( CBasePlayer *pPlayer, QAngle angles );
|
||||
|
||||
void UseCameraOffsets( bool bUse ) { m_bUseCameraOffsets = bUse; }
|
||||
bool UsingCameraOffsets( void ) { return m_bUseCameraOffsets; }
|
||||
|
||||
QAngle GetCameraViewAngles( void ) { return m_ViewAngles; }
|
||||
|
||||
Vector GetDistanceFraction( void );
|
||||
|
||||
bool WantToUseGameThirdPerson( void );
|
||||
|
||||
void SetOverridingThirdPerson( bool bOverride ) { m_bOverrideThirdPerson = bOverride; }
|
||||
bool IsOverridingThirdPerson( void ) { return m_bOverrideThirdPerson; }
|
||||
|
||||
void Init( void );
|
||||
|
||||
void SetForcedThirdPerson( bool bForced ) { m_bForced = bForced; }
|
||||
bool GetForcedThirdPerson() const { return m_bForced; }
|
||||
|
||||
private:
|
||||
|
||||
// What is the current camera offset from the view origin?
|
||||
Vector m_vecCameraOffset;
|
||||
// Distances from the center
|
||||
Vector m_vecDesiredCameraOffset;
|
||||
|
||||
Vector m_vecCameraOrigin;
|
||||
|
||||
bool m_bUseCameraOffsets;
|
||||
|
||||
QAngle m_ViewAngles;
|
||||
|
||||
float m_flFraction;
|
||||
float m_flUpFraction;
|
||||
|
||||
float m_flTargetFraction;
|
||||
float m_flTargetUpFraction;
|
||||
|
||||
bool m_bOverrideThirdPerson;
|
||||
|
||||
bool m_bForced;
|
||||
|
||||
float m_flUpOffset;
|
||||
|
||||
float m_flLerpTime;
|
||||
float m_flUpLerpTime;
|
||||
};
|
||||
|
||||
extern CThirdPersonManager g_ThirdPersonManager;
|
||||
|
||||
#endif // CAM_THIRDPERSON_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CAM_THIRDPERSON_H
|
||||
#define CAM_THIRDPERSON_H
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "c_baseplayer.h"
|
||||
#else
|
||||
#include "baseplayer.h"
|
||||
#endif
|
||||
|
||||
#define DIST_FORWARD 0
|
||||
#define DIST_RIGHT 1
|
||||
#define DIST_UP 2
|
||||
|
||||
//-------------------------------------------------- Constants
|
||||
|
||||
#define CAM_MIN_DIST 30.0
|
||||
#define CAM_ANGLE_MOVE .5
|
||||
#define MAX_ANGLE_DIFF 10.0
|
||||
#define PITCH_MAX 90.0
|
||||
#define PITCH_MIN 0
|
||||
#define YAW_MAX 135.0
|
||||
#define YAW_MIN -135.0
|
||||
#define DIST 2
|
||||
#define CAM_HULL_OFFSET 14.0 // the size of the bounding hull used for collision checking
|
||||
|
||||
#define CAMERA_UP_OFFSET 25.0f
|
||||
#define CAMERA_OFFSET_LERP_TIME 0.5f
|
||||
#define CAMERA_UP_OFFSET_LERP_TIME 0.25f
|
||||
|
||||
class CThirdPersonManager
|
||||
{
|
||||
public:
|
||||
|
||||
CThirdPersonManager();
|
||||
void SetCameraOffsetAngles( Vector vecOffset ) { m_vecCameraOffset = vecOffset; }
|
||||
Vector GetCameraOffsetAngles( void ) { return m_vecCameraOffset; }
|
||||
|
||||
void SetDesiredCameraOffset( Vector vecOffset ) { m_vecDesiredCameraOffset = vecOffset; }
|
||||
Vector GetDesiredCameraOffset( void );
|
||||
|
||||
Vector GetFinalCameraOffset( void );
|
||||
|
||||
void SetCameraOrigin( Vector vecOffset ) { m_vecCameraOrigin = vecOffset; }
|
||||
Vector GetCameraOrigin( void ) { return m_vecCameraOrigin; }
|
||||
|
||||
void Update( void );
|
||||
|
||||
void PositionCamera( CBasePlayer *pPlayer, QAngle angles );
|
||||
|
||||
void UseCameraOffsets( bool bUse ) { m_bUseCameraOffsets = bUse; }
|
||||
bool UsingCameraOffsets( void ) { return m_bUseCameraOffsets; }
|
||||
|
||||
QAngle GetCameraViewAngles( void ) { return m_ViewAngles; }
|
||||
|
||||
Vector GetDistanceFraction( void );
|
||||
|
||||
bool WantToUseGameThirdPerson( void );
|
||||
|
||||
void SetOverridingThirdPerson( bool bOverride ) { m_bOverrideThirdPerson = bOverride; }
|
||||
bool IsOverridingThirdPerson( void ) { return m_bOverrideThirdPerson; }
|
||||
|
||||
void Init( void );
|
||||
|
||||
void SetForcedThirdPerson( bool bForced ) { m_bForced = bForced; }
|
||||
bool GetForcedThirdPerson() const { return m_bForced; }
|
||||
|
||||
private:
|
||||
|
||||
// What is the current camera offset from the view origin?
|
||||
Vector m_vecCameraOffset;
|
||||
// Distances from the center
|
||||
Vector m_vecDesiredCameraOffset;
|
||||
|
||||
Vector m_vecCameraOrigin;
|
||||
|
||||
bool m_bUseCameraOffsets;
|
||||
|
||||
QAngle m_ViewAngles;
|
||||
|
||||
float m_flFraction;
|
||||
float m_flUpFraction;
|
||||
|
||||
float m_flTargetFraction;
|
||||
float m_flTargetUpFraction;
|
||||
|
||||
bool m_bOverrideThirdPerson;
|
||||
|
||||
bool m_bForced;
|
||||
|
||||
float m_flUpOffset;
|
||||
|
||||
float m_flLerpTime;
|
||||
float m_flUpLerpTime;
|
||||
};
|
||||
|
||||
extern CThirdPersonManager g_ThirdPersonManager;
|
||||
|
||||
#endif // CAM_THIRDPERSON_H
|
||||
|
||||
+294
-294
@@ -1,294 +1,294 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "choreoactor.h"
|
||||
#include "choreochannel.h"
|
||||
#include "choreoscene.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor::CChoreoActor( void )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor::CChoreoActor( const char *name )
|
||||
{
|
||||
Init();
|
||||
SetName( name );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: // Assignment
|
||||
// Input : src -
|
||||
// Output : CChoreoActor&
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor& CChoreoActor::operator=( const CChoreoActor& src )
|
||||
{
|
||||
m_bActive = src.m_bActive;
|
||||
|
||||
Q_strncpy( m_szName, src.m_szName, sizeof( m_szName ) );
|
||||
Q_strncpy( m_szFacePoserModelName, src.m_szFacePoserModelName, sizeof( m_szFacePoserModelName ) );
|
||||
|
||||
for ( int i = 0; i < src.m_Channels.Size(); i++ )
|
||||
{
|
||||
CChoreoChannel *c = src.m_Channels[ i ];
|
||||
CChoreoChannel *newChannel = new CChoreoChannel();
|
||||
newChannel->SetActor( this );
|
||||
*newChannel = *c;
|
||||
AddChannel( newChannel );
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::Init( void )
|
||||
{
|
||||
m_szName[ 0 ] = 0;
|
||||
m_szFacePoserModelName[ 0 ] = 0;
|
||||
m_bActive = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SetName( const char *name )
|
||||
{
|
||||
assert( strlen( name ) < MAX_ACTOR_NAME );
|
||||
Q_strncpy( m_szName, name, sizeof( m_szName ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CChoreoActor::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoActor::GetNumChannels( void )
|
||||
{
|
||||
return m_Channels.Size();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : channel -
|
||||
// Output : CChoreoChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoChannel *CChoreoActor::GetChannel( int channel )
|
||||
{
|
||||
if ( channel < 0 || channel >= m_Channels.Size() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_Channels[ channel ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::AddChannel( CChoreoChannel *channel )
|
||||
{
|
||||
m_Channels.AddToTail( channel );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::RemoveChannel( CChoreoChannel *channel )
|
||||
{
|
||||
int idx = FindChannelIndex( channel );
|
||||
if ( idx == -1 )
|
||||
return;
|
||||
|
||||
m_Channels.Remove( idx );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::RemoveAllChannels()
|
||||
{
|
||||
m_Channels.RemoveAll();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : c1 -
|
||||
// c2 -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SwapChannels( int c1, int c2 )
|
||||
{
|
||||
CChoreoChannel *temp;
|
||||
|
||||
temp = m_Channels[ c1 ];
|
||||
m_Channels[ c1 ] = m_Channels[ c2 ];
|
||||
m_Channels[ c2 ] = temp;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoActor::FindChannelIndex( CChoreoChannel *channel )
|
||||
{
|
||||
for ( int i = 0; i < m_Channels.Size(); i++ )
|
||||
{
|
||||
if ( channel == m_Channels[ i ] )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SetFacePoserModelName( const char *name )
|
||||
{
|
||||
Q_strncpy( m_szFacePoserModelName, name, sizeof( m_szFacePoserModelName ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CChoreoActor::GetFacePoserModelName( void ) const
|
||||
{
|
||||
return m_szFacePoserModelName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : active -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SetActive( bool active )
|
||||
{
|
||||
m_bActive = active;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CChoreoActor::GetActive( void ) const
|
||||
{
|
||||
return m_bActive;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::MarkForSaveAll( bool mark )
|
||||
{
|
||||
SetMarkedForSave( mark );
|
||||
|
||||
int c = GetNumChannels();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = GetChannel( i );
|
||||
channel->MarkForSaveAll( mark );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
// Output : CChoreoChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoChannel *CChoreoActor::FindChannel( const char *name )
|
||||
{
|
||||
int c = GetNumChannels();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = GetChannel( i );
|
||||
if ( !Q_stricmp( channel->GetName(), name ) )
|
||||
return channel;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CChoreoActor::SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool )
|
||||
{
|
||||
buf.PutShort( pStringPool->FindOrAddString( GetName() ) );
|
||||
|
||||
int c = GetNumChannels();
|
||||
Assert( c <= 255 );
|
||||
buf.PutUnsignedChar( c );
|
||||
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = GetChannel( i );
|
||||
Assert( channel );
|
||||
channel->SaveToBuffer( buf, pScene, pStringPool );
|
||||
}
|
||||
|
||||
/*
|
||||
if ( Q_strlen( a->GetFacePoserModelName() ) > 0 )
|
||||
{
|
||||
FilePrintf( buf, level + 1, "faceposermodel \"%s\"\n", a->GetFacePoserModelName() );
|
||||
}
|
||||
*/
|
||||
buf.PutChar( GetActive() ? 1 : 0 );
|
||||
}
|
||||
|
||||
bool CChoreoActor::RestoreFromBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool )
|
||||
{
|
||||
char sz[ 256 ];
|
||||
pStringPool->GetString( buf.GetShort(), sz, sizeof( sz ) );
|
||||
|
||||
SetName( sz );
|
||||
|
||||
int i;
|
||||
int c = buf.GetUnsignedChar();
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = pScene->AllocChannel();
|
||||
Assert( channel );
|
||||
if ( channel->RestoreFromBuffer( buf, pScene, this, pStringPool ) )
|
||||
{
|
||||
AddChannel( channel );
|
||||
channel->SetActor( this );
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SetActive( buf.GetChar() == 1 ? true : false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "choreoactor.h"
|
||||
#include "choreochannel.h"
|
||||
#include "choreoscene.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor::CChoreoActor( void )
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor::CChoreoActor( const char *name )
|
||||
{
|
||||
Init();
|
||||
SetName( name );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: // Assignment
|
||||
// Input : src -
|
||||
// Output : CChoreoActor&
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor& CChoreoActor::operator=( const CChoreoActor& src )
|
||||
{
|
||||
m_bActive = src.m_bActive;
|
||||
|
||||
Q_strncpy( m_szName, src.m_szName, sizeof( m_szName ) );
|
||||
Q_strncpy( m_szFacePoserModelName, src.m_szFacePoserModelName, sizeof( m_szFacePoserModelName ) );
|
||||
|
||||
for ( int i = 0; i < src.m_Channels.Size(); i++ )
|
||||
{
|
||||
CChoreoChannel *c = src.m_Channels[ i ];
|
||||
CChoreoChannel *newChannel = new CChoreoChannel();
|
||||
newChannel->SetActor( this );
|
||||
*newChannel = *c;
|
||||
AddChannel( newChannel );
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::Init( void )
|
||||
{
|
||||
m_szName[ 0 ] = 0;
|
||||
m_szFacePoserModelName[ 0 ] = 0;
|
||||
m_bActive = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SetName( const char *name )
|
||||
{
|
||||
assert( strlen( name ) < MAX_ACTOR_NAME );
|
||||
Q_strncpy( m_szName, name, sizeof( m_szName ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CChoreoActor::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoActor::GetNumChannels( void )
|
||||
{
|
||||
return m_Channels.Size();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : channel -
|
||||
// Output : CChoreoChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoChannel *CChoreoActor::GetChannel( int channel )
|
||||
{
|
||||
if ( channel < 0 || channel >= m_Channels.Size() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_Channels[ channel ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::AddChannel( CChoreoChannel *channel )
|
||||
{
|
||||
m_Channels.AddToTail( channel );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::RemoveChannel( CChoreoChannel *channel )
|
||||
{
|
||||
int idx = FindChannelIndex( channel );
|
||||
if ( idx == -1 )
|
||||
return;
|
||||
|
||||
m_Channels.Remove( idx );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::RemoveAllChannels()
|
||||
{
|
||||
m_Channels.RemoveAll();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : c1 -
|
||||
// c2 -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SwapChannels( int c1, int c2 )
|
||||
{
|
||||
CChoreoChannel *temp;
|
||||
|
||||
temp = m_Channels[ c1 ];
|
||||
m_Channels[ c1 ] = m_Channels[ c2 ];
|
||||
m_Channels[ c2 ] = temp;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoActor::FindChannelIndex( CChoreoChannel *channel )
|
||||
{
|
||||
for ( int i = 0; i < m_Channels.Size(); i++ )
|
||||
{
|
||||
if ( channel == m_Channels[ i ] )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SetFacePoserModelName( const char *name )
|
||||
{
|
||||
Q_strncpy( m_szFacePoserModelName, name, sizeof( m_szFacePoserModelName ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CChoreoActor::GetFacePoserModelName( void ) const
|
||||
{
|
||||
return m_szFacePoserModelName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : active -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::SetActive( bool active )
|
||||
{
|
||||
m_bActive = active;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CChoreoActor::GetActive( void ) const
|
||||
{
|
||||
return m_bActive;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActor::MarkForSaveAll( bool mark )
|
||||
{
|
||||
SetMarkedForSave( mark );
|
||||
|
||||
int c = GetNumChannels();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = GetChannel( i );
|
||||
channel->MarkForSaveAll( mark );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
// Output : CChoreoChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoChannel *CChoreoActor::FindChannel( const char *name )
|
||||
{
|
||||
int c = GetNumChannels();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = GetChannel( i );
|
||||
if ( !Q_stricmp( channel->GetName(), name ) )
|
||||
return channel;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CChoreoActor::SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool )
|
||||
{
|
||||
buf.PutShort( pStringPool->FindOrAddString( GetName() ) );
|
||||
|
||||
int c = GetNumChannels();
|
||||
Assert( c <= 255 );
|
||||
buf.PutUnsignedChar( c );
|
||||
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = GetChannel( i );
|
||||
Assert( channel );
|
||||
channel->SaveToBuffer( buf, pScene, pStringPool );
|
||||
}
|
||||
|
||||
/*
|
||||
if ( Q_strlen( a->GetFacePoserModelName() ) > 0 )
|
||||
{
|
||||
FilePrintf( buf, level + 1, "faceposermodel \"%s\"\n", a->GetFacePoserModelName() );
|
||||
}
|
||||
*/
|
||||
buf.PutChar( GetActive() ? 1 : 0 );
|
||||
}
|
||||
|
||||
bool CChoreoActor::RestoreFromBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool )
|
||||
{
|
||||
char sz[ 256 ];
|
||||
pStringPool->GetString( buf.GetShort(), sz, sizeof( sz ) );
|
||||
|
||||
SetName( sz );
|
||||
|
||||
int i;
|
||||
int c = buf.GetUnsignedChar();
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
CChoreoChannel *channel = pScene->AllocChannel();
|
||||
Assert( channel );
|
||||
if ( channel->RestoreFromBuffer( buf, pScene, this, pStringPool ) )
|
||||
{
|
||||
AddChannel( channel );
|
||||
channel->SetActor( this );
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SetActive( buf.GetChar() == 1 ? true : false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOACTOR_H
|
||||
#define CHOREOACTOR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
class CChoreoChannel;
|
||||
class CChoreoScene;
|
||||
class CUtlBuffer;
|
||||
class IChoreoStringPool;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The actor is the atomic element of a scene
|
||||
// A scene can have one or more actors, who have multiple events on one or
|
||||
// more channels
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoActor
|
||||
{
|
||||
public:
|
||||
|
||||
// Construction
|
||||
CChoreoActor( void );
|
||||
CChoreoActor( const char *name );
|
||||
// Assignment
|
||||
CChoreoActor& operator = ( const CChoreoActor& src );
|
||||
|
||||
// Serialization
|
||||
void SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool );
|
||||
|
||||
// Accessors
|
||||
void SetName( const char *name );
|
||||
const char *GetName( void );
|
||||
|
||||
// Iteration
|
||||
int GetNumChannels( void );
|
||||
CChoreoChannel *GetChannel( int channel );
|
||||
|
||||
CChoreoChannel *FindChannel( const char *name );
|
||||
|
||||
// Manipulate children
|
||||
void AddChannel( CChoreoChannel *channel );
|
||||
void RemoveChannel( CChoreoChannel *channel );
|
||||
int FindChannelIndex( CChoreoChannel *channel );
|
||||
void SwapChannels( int c1, int c2 );
|
||||
void RemoveAllChannels();
|
||||
|
||||
void SetFacePoserModelName( const char *name );
|
||||
char const *GetFacePoserModelName( void ) const;
|
||||
|
||||
void SetActive( bool active );
|
||||
bool GetActive( void ) const;
|
||||
|
||||
bool IsMarkedForSave() const { return m_bMarkedForSave; }
|
||||
void SetMarkedForSave( bool mark ) { m_bMarkedForSave = mark; }
|
||||
|
||||
void MarkForSaveAll( bool mark );
|
||||
|
||||
private:
|
||||
// Clear structure out
|
||||
void Init( void );
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_ACTOR_NAME = 128,
|
||||
MAX_FACEPOSER_MODEL_NAME = 128
|
||||
};
|
||||
|
||||
char m_szName[ MAX_ACTOR_NAME ];
|
||||
char m_szFacePoserModelName[ MAX_FACEPOSER_MODEL_NAME ];
|
||||
|
||||
// Children
|
||||
CUtlVector < CChoreoChannel * > m_Channels;
|
||||
|
||||
bool m_bActive;
|
||||
|
||||
// Purely for save/load
|
||||
bool m_bMarkedForSave;
|
||||
};
|
||||
|
||||
#endif // CHOREOACTOR_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOACTOR_H
|
||||
#define CHOREOACTOR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
class CChoreoChannel;
|
||||
class CChoreoScene;
|
||||
class CUtlBuffer;
|
||||
class IChoreoStringPool;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The actor is the atomic element of a scene
|
||||
// A scene can have one or more actors, who have multiple events on one or
|
||||
// more channels
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoActor
|
||||
{
|
||||
public:
|
||||
|
||||
// Construction
|
||||
CChoreoActor( void );
|
||||
CChoreoActor( const char *name );
|
||||
// Assignment
|
||||
CChoreoActor& operator = ( const CChoreoActor& src );
|
||||
|
||||
// Serialization
|
||||
void SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool );
|
||||
|
||||
// Accessors
|
||||
void SetName( const char *name );
|
||||
const char *GetName( void );
|
||||
|
||||
// Iteration
|
||||
int GetNumChannels( void );
|
||||
CChoreoChannel *GetChannel( int channel );
|
||||
|
||||
CChoreoChannel *FindChannel( const char *name );
|
||||
|
||||
// Manipulate children
|
||||
void AddChannel( CChoreoChannel *channel );
|
||||
void RemoveChannel( CChoreoChannel *channel );
|
||||
int FindChannelIndex( CChoreoChannel *channel );
|
||||
void SwapChannels( int c1, int c2 );
|
||||
void RemoveAllChannels();
|
||||
|
||||
void SetFacePoserModelName( const char *name );
|
||||
char const *GetFacePoserModelName( void ) const;
|
||||
|
||||
void SetActive( bool active );
|
||||
bool GetActive( void ) const;
|
||||
|
||||
bool IsMarkedForSave() const { return m_bMarkedForSave; }
|
||||
void SetMarkedForSave( bool mark ) { m_bMarkedForSave = mark; }
|
||||
|
||||
void MarkForSaveAll( bool mark );
|
||||
|
||||
private:
|
||||
// Clear structure out
|
||||
void Init( void );
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_ACTOR_NAME = 128,
|
||||
MAX_FACEPOSER_MODEL_NAME = 128
|
||||
};
|
||||
|
||||
char m_szName[ MAX_ACTOR_NAME ];
|
||||
char m_szFacePoserModelName[ MAX_FACEPOSER_MODEL_NAME ];
|
||||
|
||||
// Children
|
||||
CUtlVector < CChoreoChannel * > m_Channels;
|
||||
|
||||
bool m_bActive;
|
||||
|
||||
// Purely for save/load
|
||||
bool m_bMarkedForSave;
|
||||
};
|
||||
|
||||
#endif // CHOREOACTOR_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,95 +1,95 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOREOCHANNEL_H
|
||||
#define CHOREOCHANNEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utlrbtree.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoActor;
|
||||
class CChoreoScene;
|
||||
class CUtlBuffer;
|
||||
class IChoreoStringPool;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A channel is owned by an actor and contains zero or more events
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoChannel
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
CChoreoChannel( void );
|
||||
CChoreoChannel( const char *name );
|
||||
|
||||
// Assignment
|
||||
CChoreoChannel& operator=(const CChoreoChannel& src );
|
||||
|
||||
// Serialization
|
||||
void SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBuffer( CUtlBuffer& buf, CChoreoScene *pScene, CChoreoActor *pActor, IChoreoStringPool *pStringPool );
|
||||
|
||||
// Accessors
|
||||
void SetName( const char *name );
|
||||
const char *GetName( void );
|
||||
|
||||
// Iterate children
|
||||
int GetNumEvents( void );
|
||||
CChoreoEvent *GetEvent( int event );
|
||||
|
||||
// Manipulate children
|
||||
void AddEvent( CChoreoEvent *event );
|
||||
void RemoveEvent( CChoreoEvent *event );
|
||||
int FindEventIndex( CChoreoEvent *event );
|
||||
void RemoveAllEvents();
|
||||
|
||||
CChoreoActor *GetActor( void );
|
||||
void SetActor( CChoreoActor *actor );
|
||||
|
||||
void SetActive( bool active );
|
||||
bool GetActive( void ) const;
|
||||
|
||||
// Compute true start/end times for gesture events in this channel, factoring in "null" gestures as needed
|
||||
void ReconcileGestureTimes();
|
||||
// Compute master/slave, count, endtime info for close captioning data
|
||||
void ReconcileCloseCaption();
|
||||
|
||||
bool IsMarkedForSave() const { return m_bMarkedForSave; }
|
||||
void SetMarkedForSave( bool mark ) { m_bMarkedForSave = mark; }
|
||||
|
||||
void MarkForSaveAll( bool mark );
|
||||
|
||||
bool GetSortedCombinedEventList( char const *cctoken, CUtlRBTree< CChoreoEvent * >& sorted );
|
||||
|
||||
private:
|
||||
// Initialize fields
|
||||
void Init( void );
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_CHANNEL_NAME = 128,
|
||||
};
|
||||
|
||||
CChoreoActor *m_pActor;
|
||||
|
||||
// Channels are just named
|
||||
char m_szName[ MAX_CHANNEL_NAME ];
|
||||
|
||||
// All of the events for this channel
|
||||
CUtlVector < CChoreoEvent * > m_Events;
|
||||
|
||||
bool m_bActive;
|
||||
|
||||
// Purely for save/load
|
||||
bool m_bMarkedForSave;
|
||||
};
|
||||
|
||||
#endif // CHOREOCHANNEL_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOREOCHANNEL_H
|
||||
#define CHOREOCHANNEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utlrbtree.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoActor;
|
||||
class CChoreoScene;
|
||||
class CUtlBuffer;
|
||||
class IChoreoStringPool;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A channel is owned by an actor and contains zero or more events
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoChannel
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
CChoreoChannel( void );
|
||||
CChoreoChannel( const char *name );
|
||||
|
||||
// Assignment
|
||||
CChoreoChannel& operator=(const CChoreoChannel& src );
|
||||
|
||||
// Serialization
|
||||
void SaveToBuffer( CUtlBuffer& buf, CChoreoScene *pScene, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBuffer( CUtlBuffer& buf, CChoreoScene *pScene, CChoreoActor *pActor, IChoreoStringPool *pStringPool );
|
||||
|
||||
// Accessors
|
||||
void SetName( const char *name );
|
||||
const char *GetName( void );
|
||||
|
||||
// Iterate children
|
||||
int GetNumEvents( void );
|
||||
CChoreoEvent *GetEvent( int event );
|
||||
|
||||
// Manipulate children
|
||||
void AddEvent( CChoreoEvent *event );
|
||||
void RemoveEvent( CChoreoEvent *event );
|
||||
int FindEventIndex( CChoreoEvent *event );
|
||||
void RemoveAllEvents();
|
||||
|
||||
CChoreoActor *GetActor( void );
|
||||
void SetActor( CChoreoActor *actor );
|
||||
|
||||
void SetActive( bool active );
|
||||
bool GetActive( void ) const;
|
||||
|
||||
// Compute true start/end times for gesture events in this channel, factoring in "null" gestures as needed
|
||||
void ReconcileGestureTimes();
|
||||
// Compute master/slave, count, endtime info for close captioning data
|
||||
void ReconcileCloseCaption();
|
||||
|
||||
bool IsMarkedForSave() const { return m_bMarkedForSave; }
|
||||
void SetMarkedForSave( bool mark ) { m_bMarkedForSave = mark; }
|
||||
|
||||
void MarkForSaveAll( bool mark );
|
||||
|
||||
bool GetSortedCombinedEventList( char const *cctoken, CUtlRBTree< CChoreoEvent * >& sorted );
|
||||
|
||||
private:
|
||||
// Initialize fields
|
||||
void Init( void );
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_CHANNEL_NAME = 128,
|
||||
};
|
||||
|
||||
CChoreoActor *m_pActor;
|
||||
|
||||
// Channels are just named
|
||||
char m_szName[ MAX_CHANNEL_NAME ];
|
||||
|
||||
// All of the events for this channel
|
||||
CUtlVector < CChoreoEvent * > m_Events;
|
||||
|
||||
bool m_bActive;
|
||||
|
||||
// Purely for save/load
|
||||
bool m_bMarkedForSave;
|
||||
};
|
||||
|
||||
#endif // CHOREOCHANNEL_H
|
||||
|
||||
+4514
-4514
File diff suppressed because it is too large
Load Diff
+708
-708
File diff suppressed because it is too large
Load Diff
+3848
-3848
File diff suppressed because it is too large
Load Diff
+406
-406
@@ -1,406 +1,406 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOREOSCENE_H
|
||||
#define CHOREOSCENE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoChannel;
|
||||
class CChoreoActor;
|
||||
class IChoreoEventCallback;
|
||||
class CEventRelativeTag;
|
||||
class CUtlBuffer;
|
||||
class CFlexAnimationTrack;
|
||||
class ISceneTokenProcessor;
|
||||
class IChoreoStringPool;
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utldict.h"
|
||||
#include "bitvec.h"
|
||||
#include "expressionsample.h"
|
||||
#include "choreoevent.h"
|
||||
|
||||
#define DEFAULT_SCENE_FPS 60
|
||||
#define MIN_SCENE_FPS 10
|
||||
#define MAX_SCENE_FPS 240
|
||||
|
||||
#define SCENE_BINARY_TAG MAKEID( 'b', 'v', 'c', 'd' )
|
||||
#define SCENE_BINARY_VERSION 0x04
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Container for choreographed scene of events for actors
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoScene : public ICurveDataAccessor
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
PROCESSING_TYPE_IGNORE = 0,
|
||||
PROCESSING_TYPE_START,
|
||||
PROCESSING_TYPE_START_RESUMECONDITION,
|
||||
PROCESSING_TYPE_CONTINUE,
|
||||
PROCESSING_TYPE_STOP,
|
||||
} PROCESSING_TYPE;
|
||||
|
||||
struct ActiveList
|
||||
{
|
||||
PROCESSING_TYPE pt;
|
||||
CChoreoEvent *e;
|
||||
};
|
||||
|
||||
public:
|
||||
// Construction
|
||||
CChoreoScene( IChoreoEventCallback *callback );
|
||||
~CChoreoScene( void );
|
||||
|
||||
// Assignment
|
||||
CChoreoScene& operator=(const CChoreoScene& src );
|
||||
|
||||
// ICurveDataAccessor methods
|
||||
virtual float GetDuration() { return FindStopTime(); };
|
||||
virtual bool CurveHasEndTime();
|
||||
virtual int GetDefaultCurveType();
|
||||
|
||||
// Binary serialization
|
||||
bool SaveBinary( char const *pszBinaryFileName, char const *pPathID, unsigned int nTextVersionCRC, IChoreoStringPool *pStringPool );
|
||||
void SaveToBinaryBuffer( CUtlBuffer& buf, unsigned int nTextVersionCRC, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBinaryBuffer( CUtlBuffer& buf, char const *filename, IChoreoStringPool *pStringPool );
|
||||
static bool GetCRCFromBinaryBuffer( CUtlBuffer& buf, unsigned int& crc );
|
||||
|
||||
// We do some things differently while restoring from a save.
|
||||
inline void SetRestoring( bool bRestoring );
|
||||
inline bool IsRestoring();
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_SCENE_FILENAME = 128,
|
||||
};
|
||||
|
||||
// Event callback handler
|
||||
void SetEventCallbackInterface( IChoreoEventCallback *callback );
|
||||
|
||||
// Loading
|
||||
bool ParseFromBuffer( char const *pFilename, ISceneTokenProcessor *tokenizer );
|
||||
void SetPrintFunc( void ( *pfn )( PRINTF_FORMAT_STRING const char *fmt, ... ) );
|
||||
|
||||
// Saving
|
||||
bool SaveToFile( const char *filename );
|
||||
bool ExportMarkedToFile( const char *filename );
|
||||
void MarkForSaveAll( bool mark );
|
||||
|
||||
// Merges two .vcd's together, returns true if any data was merged
|
||||
bool Merge( CChoreoScene *other );
|
||||
|
||||
static void FileSaveFlexAnimationTrack( CUtlBuffer& buf, int level, CFlexAnimationTrack *track, int nDefaultCurveType );
|
||||
static void FileSaveFlexAnimations( CUtlBuffer& buf, int level, CChoreoEvent *e );
|
||||
static void FileSaveRamp( CUtlBuffer& buf, int level, CChoreoEvent *e );
|
||||
void FileSaveSceneRamp( CUtlBuffer& buf, int level );
|
||||
static void FileSaveScaleSettings( CUtlBuffer& buf, int level, CChoreoScene *scene );
|
||||
|
||||
static void ParseFlexAnimations( ISceneTokenProcessor *tokenizer, CChoreoEvent *e, bool removeold = true );
|
||||
static void ParseRamp( ISceneTokenProcessor *tokenizer, CChoreoEvent *e );
|
||||
static void ParseSceneRamp( ISceneTokenProcessor *tokenizer, CChoreoScene *scene );
|
||||
static void ParseScaleSettings( ISceneTokenProcessor *tokenizer, CChoreoScene *scene );
|
||||
static void ParseEdgeInfo( ISceneTokenProcessor *tokenizer, EdgeInfo_t *edgeinfo );
|
||||
|
||||
// Debugging
|
||||
void SceneMsg( PRINTF_FORMAT_STRING const char *pFormat, ... );
|
||||
void Print( void );
|
||||
|
||||
// Sound system needs to have sounds pre-queued by this much time
|
||||
void SetSoundFileStartupLatency( float time );
|
||||
|
||||
// Simulation
|
||||
void Think( float curtime );
|
||||
float LoopThink( float curtime );
|
||||
void ProcessActiveListEntry( ActiveList *entry );
|
||||
// Retrieves time in simulation
|
||||
float GetTime( void );
|
||||
// Retrieves start/stop time for looped/debug scene
|
||||
void GetSceneTimes( float& start, float& end );
|
||||
|
||||
void SetTime( float t );
|
||||
void LoopToTime( float t );
|
||||
|
||||
// Has simulation finished
|
||||
bool SimulationFinished( void );
|
||||
// Reset simulation
|
||||
void ResetSimulation( bool forward = true, float starttime = 0.0f, float endtime = 0.0f );
|
||||
// Find time at which last simulation event is triggered
|
||||
float FindStopTime( void );
|
||||
|
||||
void ResumeSimulation( void );
|
||||
|
||||
// Have all the pause events happened
|
||||
bool CheckEventCompletion( void );
|
||||
|
||||
// Find named actor in scene data
|
||||
CChoreoActor *FindActor( const char *name );
|
||||
// Remove actor from scene
|
||||
void RemoveActor( CChoreoActor *actor );
|
||||
// Find index for actor
|
||||
int FindActorIndex( CChoreoActor *actor );
|
||||
|
||||
// Swap actors in the data
|
||||
void SwapActors( int a1, int a2 );
|
||||
|
||||
// General data access
|
||||
int GetNumEvents( void );
|
||||
CChoreoEvent *GetEvent( int event );
|
||||
|
||||
int GetNumActors( void );
|
||||
CChoreoActor *GetActor( int actor );
|
||||
|
||||
int GetNumChannels( void );
|
||||
CChoreoChannel *GetChannel( int channel );
|
||||
|
||||
// Object allocation/destruction
|
||||
void DeleteReferencedObjects( CChoreoActor *actor );
|
||||
void DeleteReferencedObjects( CChoreoChannel *channel );
|
||||
void DeleteReferencedObjects( CChoreoEvent *event );
|
||||
|
||||
CChoreoActor *AllocActor( void );
|
||||
CChoreoChannel *AllocChannel( void );
|
||||
CChoreoEvent *AllocEvent( void );
|
||||
|
||||
void AddEventToScene( CChoreoEvent *event );
|
||||
void AddActorToScene( CChoreoActor *actor );
|
||||
void AddChannelToScene( CChoreoChannel *channel );
|
||||
|
||||
// Fixup simulation times for channel gestures
|
||||
void ReconcileGestureTimes( void );
|
||||
|
||||
// Go through all elements and update relative tags, removing any orphaned
|
||||
// tags and updating the timestamp of normal tags
|
||||
void ReconcileTags( void );
|
||||
CEventRelativeTag *FindTagByName( const char *wavname, const char *name );
|
||||
CChoreoEvent *FindTargetingEvent( const char *wavname, const char *name );
|
||||
|
||||
// Used by UI to provide target actor names
|
||||
char const *GetMapname( void );
|
||||
void SetMapname( const char *name );
|
||||
|
||||
void ExportEvents( const char *filename, CUtlVector< CChoreoEvent * >& events );
|
||||
void ImportEvents( ISceneTokenProcessor *tokenizer, CChoreoActor *actor, CChoreoChannel *channel );
|
||||
|
||||
// Subscene support
|
||||
void SetSubScene( bool sub );
|
||||
bool IsSubScene( void ) const;
|
||||
|
||||
int GetSceneFPS( void ) const;
|
||||
void SetSceneFPS( int fps );
|
||||
bool IsUsingFrameSnap( void ) const;
|
||||
void SetUsingFrameSnap( bool snap );
|
||||
|
||||
float SnapTime( float t );
|
||||
|
||||
int GetSceneRampCount( void ) { return m_SceneRamp.GetCount(); };
|
||||
CExpressionSample *GetSceneRamp( int index ) { return m_SceneRamp.Get( index ); };
|
||||
CExpressionSample *AddSceneRamp( float time, float value, bool selected ) { return m_SceneRamp.Add( time, value, selected ); };
|
||||
void DeleteSceneRamp( int index ) { m_SceneRamp.Delete( index ); };
|
||||
void ClearSceneRamp( void ) { m_SceneRamp.Clear(); };
|
||||
void ResortSceneRamp( void ) { m_SceneRamp.Resort( this ); };
|
||||
|
||||
CCurveData *GetSceneRamp( void ) { return &m_SceneRamp; };
|
||||
|
||||
|
||||
// Global intensity for scene
|
||||
float GetSceneRampIntensity( float time ) { return m_SceneRamp.GetIntensity( this, time ); }
|
||||
|
||||
int GetTimeZoom( char const *tool );
|
||||
void SetTimeZoom( char const *tool, int tz );
|
||||
int TimeZoomFirst();
|
||||
int TimeZoomNext( int i );
|
||||
int TimeZoomInvalid() const;
|
||||
char const *TimeZoomName( int i );
|
||||
|
||||
void ReconcileCloseCaption();
|
||||
|
||||
char const *GetFilename() const;
|
||||
void SetFileName( char const *fn );
|
||||
|
||||
bool GetPlayingSoundName( char *pchBuff, int iBuffLength );
|
||||
bool HasUnplayedSpeech();
|
||||
bool HasFlexAnimation();
|
||||
void SetBackground( bool bIsBackground );
|
||||
bool IsBackground( void );
|
||||
|
||||
void ClearPauseEventDependencies();
|
||||
|
||||
bool HasEventsOfType( CChoreoEvent::EVENTTYPE type ) const;
|
||||
void RemoveEventsExceptTypes( int* typeList, int count );
|
||||
|
||||
void IgnorePhonemes( bool bIgnore );
|
||||
bool ShouldIgnorePhonemes() const;
|
||||
|
||||
// This is set by the engine to signify that we're not modifying the data and
|
||||
// therefore we can precompute the end time
|
||||
static bool s_bEditingDisabled;
|
||||
|
||||
private:
|
||||
|
||||
// Simulation stuff
|
||||
enum
|
||||
{
|
||||
IN_RANGE = 0,
|
||||
BEFORE_RANGE,
|
||||
AFTER_RANGE
|
||||
};
|
||||
|
||||
int IsTimeInRange( float t, float starttime, float endtime );
|
||||
|
||||
static bool EventLess( const CChoreoScene::ActiveList &al0, const CChoreoScene::ActiveList &al1 );
|
||||
|
||||
int EventThink( CChoreoEvent *e,
|
||||
float frame_start_time,
|
||||
float frame_end_time,
|
||||
bool playing_forward, PROCESSING_TYPE& disposition );
|
||||
|
||||
// Prints to debug console, etc
|
||||
void choreoprintf( int level, PRINTF_FORMAT_STRING const char *fmt, ... );
|
||||
|
||||
// Initialize scene
|
||||
void Init( IChoreoEventCallback *callback );
|
||||
|
||||
float FindAdjustedStartTime( void );
|
||||
float FindAdjustedEndTime( void );
|
||||
|
||||
CChoreoEvent *FindPauseBetweenTimes( float starttime, float endtime );
|
||||
|
||||
// Parse scenes from token buffer
|
||||
CChoreoEvent *ParseEvent( CChoreoActor *actor, CChoreoChannel *channel );
|
||||
CChoreoChannel *ParseChannel( CChoreoActor *actor );
|
||||
CChoreoActor *ParseActor( void );
|
||||
|
||||
void ParseFPS( void );
|
||||
void ParseSnap( void );
|
||||
void ParseIgnorePhonemes( void );
|
||||
|
||||
// Map file for retrieving named objects
|
||||
void ParseMapname( void );
|
||||
// When previewing actor in hlfaceposer, this is the model to associate
|
||||
void ParseFacePoserModel( CChoreoActor *actor );
|
||||
|
||||
// Print to printfunc
|
||||
void PrintEvent( int level, CChoreoEvent *e );
|
||||
void PrintChannel( int level, CChoreoChannel *c );
|
||||
void PrintActor( int level, CChoreoActor *a );
|
||||
|
||||
// File I/O
|
||||
public:
|
||||
static void FilePrintf( CUtlBuffer& buf, int level, PRINTF_FORMAT_STRING const char *fmt, ... );
|
||||
private:
|
||||
void FileSaveEvent( CUtlBuffer& buf, int level, CChoreoEvent *e );
|
||||
void FileSaveChannel( CUtlBuffer& buf, int level, CChoreoChannel *c );
|
||||
void FileSaveActor( CUtlBuffer& buf, int level, CChoreoActor *a );
|
||||
void FileSaveHeader( CUtlBuffer& buf );
|
||||
|
||||
// Object destruction
|
||||
void DestroyActor( CChoreoActor *actor );
|
||||
void DestroyChannel( CChoreoChannel *channel );
|
||||
void DestroyEvent( CChoreoEvent *event );
|
||||
|
||||
|
||||
void AddPauseEventDependency( CChoreoEvent *pauseEvent, CChoreoEvent *suppressed );
|
||||
|
||||
void InternalDetermineEventTypes();
|
||||
|
||||
// Global object storage
|
||||
CUtlVector < CChoreoEvent * > m_Events;
|
||||
CUtlVector < CChoreoActor * > m_Actors;
|
||||
CUtlVector < CChoreoChannel * > m_Channels;
|
||||
|
||||
// These are just pointers, the actual objects are in m_Events
|
||||
CUtlVector < CChoreoEvent * > m_ResumeConditions;
|
||||
// These are just pointers, the actual objects are in m_Events
|
||||
CUtlVector < CChoreoEvent * > m_ActiveResumeConditions;
|
||||
// These are just pointers, the actual objects are in m_Events
|
||||
CUtlVector < CChoreoEvent * > m_PauseEvents;
|
||||
|
||||
// Current simulation time
|
||||
float m_flCurrentTime;
|
||||
|
||||
float m_flStartTime;
|
||||
float m_flEndTime;
|
||||
|
||||
float m_flEarliestTime;
|
||||
float m_flLatestTime;
|
||||
int m_nActiveEvents;
|
||||
|
||||
// Wave file playback needs to issue play commands a bit ahead of time
|
||||
// in order to hit exact marks
|
||||
float m_flSoundSystemLatency;
|
||||
|
||||
// Scene's linger a bit after finishing to let blends reset themselves
|
||||
float m_flLastActiveTime;
|
||||
|
||||
// Print callback function
|
||||
void ( *m_pfnPrint )( PRINTF_FORMAT_STRING const char *fmt, ... );
|
||||
|
||||
IChoreoEventCallback *m_pIChoreoEventCallback;
|
||||
|
||||
ISceneTokenProcessor *m_pTokenizer;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_MAPNAME = 128
|
||||
};
|
||||
|
||||
char m_szMapname[ MAX_MAPNAME ];
|
||||
|
||||
int m_nSceneFPS;
|
||||
|
||||
CCurveData m_SceneRamp;
|
||||
|
||||
CUtlDict< int, int > m_TimeZoomLookup;
|
||||
char m_szFileName[ MAX_SCENE_FILENAME ];
|
||||
|
||||
CBitVec< CChoreoEvent::NUM_TYPES > m_bitvecHasEventOfType;
|
||||
|
||||
// tag to suppress vcd when others are playing
|
||||
bool m_bIsBackground : 1;
|
||||
bool m_bIgnorePhonemes : 1;
|
||||
bool m_bSubScene : 1;
|
||||
bool m_bUseFrameSnap : 1;
|
||||
bool m_bRestoring : 1;
|
||||
|
||||
int m_nLastPauseEvent;
|
||||
// This only gets updated if it's loaded from a buffer which means we're not in an editor
|
||||
float m_flPrecomputedStopTime;
|
||||
};
|
||||
|
||||
|
||||
bool CChoreoScene::IsRestoring()
|
||||
{
|
||||
return m_bRestoring;
|
||||
}
|
||||
|
||||
|
||||
void CChoreoScene::SetRestoring( bool bRestoring )
|
||||
{
|
||||
m_bRestoring = bRestoring;
|
||||
}
|
||||
|
||||
|
||||
abstract_class IChoreoStringPool
|
||||
{
|
||||
public:
|
||||
virtual short FindOrAddString( const char *pString ) = 0;
|
||||
virtual bool GetString( short stringId, char *buff, int buffSize ) = 0;
|
||||
};
|
||||
|
||||
CChoreoScene *ChoreoLoadScene(
|
||||
char const *filename,
|
||||
IChoreoEventCallback *callback,
|
||||
ISceneTokenProcessor *tokenizer,
|
||||
void ( *pfn ) ( PRINTF_FORMAT_STRING const char *fmt, ... ) );
|
||||
|
||||
bool IsBufferBinaryVCD( char *pBuffer, int bufferSize );
|
||||
|
||||
#endif // CHOREOSCENE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOREOSCENE_H
|
||||
#define CHOREOSCENE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoChannel;
|
||||
class CChoreoActor;
|
||||
class IChoreoEventCallback;
|
||||
class CEventRelativeTag;
|
||||
class CUtlBuffer;
|
||||
class CFlexAnimationTrack;
|
||||
class ISceneTokenProcessor;
|
||||
class IChoreoStringPool;
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utldict.h"
|
||||
#include "bitvec.h"
|
||||
#include "expressionsample.h"
|
||||
#include "choreoevent.h"
|
||||
|
||||
#define DEFAULT_SCENE_FPS 60
|
||||
#define MIN_SCENE_FPS 10
|
||||
#define MAX_SCENE_FPS 240
|
||||
|
||||
#define SCENE_BINARY_TAG MAKEID( 'b', 'v', 'c', 'd' )
|
||||
#define SCENE_BINARY_VERSION 0x04
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Container for choreographed scene of events for actors
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoScene : public ICurveDataAccessor
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
PROCESSING_TYPE_IGNORE = 0,
|
||||
PROCESSING_TYPE_START,
|
||||
PROCESSING_TYPE_START_RESUMECONDITION,
|
||||
PROCESSING_TYPE_CONTINUE,
|
||||
PROCESSING_TYPE_STOP,
|
||||
} PROCESSING_TYPE;
|
||||
|
||||
struct ActiveList
|
||||
{
|
||||
PROCESSING_TYPE pt;
|
||||
CChoreoEvent *e;
|
||||
};
|
||||
|
||||
public:
|
||||
// Construction
|
||||
CChoreoScene( IChoreoEventCallback *callback );
|
||||
~CChoreoScene( void );
|
||||
|
||||
// Assignment
|
||||
CChoreoScene& operator=(const CChoreoScene& src );
|
||||
|
||||
// ICurveDataAccessor methods
|
||||
virtual float GetDuration() { return FindStopTime(); };
|
||||
virtual bool CurveHasEndTime();
|
||||
virtual int GetDefaultCurveType();
|
||||
|
||||
// Binary serialization
|
||||
bool SaveBinary( char const *pszBinaryFileName, char const *pPathID, unsigned int nTextVersionCRC, IChoreoStringPool *pStringPool );
|
||||
void SaveToBinaryBuffer( CUtlBuffer& buf, unsigned int nTextVersionCRC, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBinaryBuffer( CUtlBuffer& buf, char const *filename, IChoreoStringPool *pStringPool );
|
||||
static bool GetCRCFromBinaryBuffer( CUtlBuffer& buf, unsigned int& crc );
|
||||
|
||||
// We do some things differently while restoring from a save.
|
||||
inline void SetRestoring( bool bRestoring );
|
||||
inline bool IsRestoring();
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_SCENE_FILENAME = 128,
|
||||
};
|
||||
|
||||
// Event callback handler
|
||||
void SetEventCallbackInterface( IChoreoEventCallback *callback );
|
||||
|
||||
// Loading
|
||||
bool ParseFromBuffer( char const *pFilename, ISceneTokenProcessor *tokenizer );
|
||||
void SetPrintFunc( void ( *pfn )( PRINTF_FORMAT_STRING const char *fmt, ... ) );
|
||||
|
||||
// Saving
|
||||
bool SaveToFile( const char *filename );
|
||||
bool ExportMarkedToFile( const char *filename );
|
||||
void MarkForSaveAll( bool mark );
|
||||
|
||||
// Merges two .vcd's together, returns true if any data was merged
|
||||
bool Merge( CChoreoScene *other );
|
||||
|
||||
static void FileSaveFlexAnimationTrack( CUtlBuffer& buf, int level, CFlexAnimationTrack *track, int nDefaultCurveType );
|
||||
static void FileSaveFlexAnimations( CUtlBuffer& buf, int level, CChoreoEvent *e );
|
||||
static void FileSaveRamp( CUtlBuffer& buf, int level, CChoreoEvent *e );
|
||||
void FileSaveSceneRamp( CUtlBuffer& buf, int level );
|
||||
static void FileSaveScaleSettings( CUtlBuffer& buf, int level, CChoreoScene *scene );
|
||||
|
||||
static void ParseFlexAnimations( ISceneTokenProcessor *tokenizer, CChoreoEvent *e, bool removeold = true );
|
||||
static void ParseRamp( ISceneTokenProcessor *tokenizer, CChoreoEvent *e );
|
||||
static void ParseSceneRamp( ISceneTokenProcessor *tokenizer, CChoreoScene *scene );
|
||||
static void ParseScaleSettings( ISceneTokenProcessor *tokenizer, CChoreoScene *scene );
|
||||
static void ParseEdgeInfo( ISceneTokenProcessor *tokenizer, EdgeInfo_t *edgeinfo );
|
||||
|
||||
// Debugging
|
||||
void SceneMsg( PRINTF_FORMAT_STRING const char *pFormat, ... );
|
||||
void Print( void );
|
||||
|
||||
// Sound system needs to have sounds pre-queued by this much time
|
||||
void SetSoundFileStartupLatency( float time );
|
||||
|
||||
// Simulation
|
||||
void Think( float curtime );
|
||||
float LoopThink( float curtime );
|
||||
void ProcessActiveListEntry( ActiveList *entry );
|
||||
// Retrieves time in simulation
|
||||
float GetTime( void );
|
||||
// Retrieves start/stop time for looped/debug scene
|
||||
void GetSceneTimes( float& start, float& end );
|
||||
|
||||
void SetTime( float t );
|
||||
void LoopToTime( float t );
|
||||
|
||||
// Has simulation finished
|
||||
bool SimulationFinished( void );
|
||||
// Reset simulation
|
||||
void ResetSimulation( bool forward = true, float starttime = 0.0f, float endtime = 0.0f );
|
||||
// Find time at which last simulation event is triggered
|
||||
float FindStopTime( void );
|
||||
|
||||
void ResumeSimulation( void );
|
||||
|
||||
// Have all the pause events happened
|
||||
bool CheckEventCompletion( void );
|
||||
|
||||
// Find named actor in scene data
|
||||
CChoreoActor *FindActor( const char *name );
|
||||
// Remove actor from scene
|
||||
void RemoveActor( CChoreoActor *actor );
|
||||
// Find index for actor
|
||||
int FindActorIndex( CChoreoActor *actor );
|
||||
|
||||
// Swap actors in the data
|
||||
void SwapActors( int a1, int a2 );
|
||||
|
||||
// General data access
|
||||
int GetNumEvents( void );
|
||||
CChoreoEvent *GetEvent( int event );
|
||||
|
||||
int GetNumActors( void );
|
||||
CChoreoActor *GetActor( int actor );
|
||||
|
||||
int GetNumChannels( void );
|
||||
CChoreoChannel *GetChannel( int channel );
|
||||
|
||||
// Object allocation/destruction
|
||||
void DeleteReferencedObjects( CChoreoActor *actor );
|
||||
void DeleteReferencedObjects( CChoreoChannel *channel );
|
||||
void DeleteReferencedObjects( CChoreoEvent *event );
|
||||
|
||||
CChoreoActor *AllocActor( void );
|
||||
CChoreoChannel *AllocChannel( void );
|
||||
CChoreoEvent *AllocEvent( void );
|
||||
|
||||
void AddEventToScene( CChoreoEvent *event );
|
||||
void AddActorToScene( CChoreoActor *actor );
|
||||
void AddChannelToScene( CChoreoChannel *channel );
|
||||
|
||||
// Fixup simulation times for channel gestures
|
||||
void ReconcileGestureTimes( void );
|
||||
|
||||
// Go through all elements and update relative tags, removing any orphaned
|
||||
// tags and updating the timestamp of normal tags
|
||||
void ReconcileTags( void );
|
||||
CEventRelativeTag *FindTagByName( const char *wavname, const char *name );
|
||||
CChoreoEvent *FindTargetingEvent( const char *wavname, const char *name );
|
||||
|
||||
// Used by UI to provide target actor names
|
||||
char const *GetMapname( void );
|
||||
void SetMapname( const char *name );
|
||||
|
||||
void ExportEvents( const char *filename, CUtlVector< CChoreoEvent * >& events );
|
||||
void ImportEvents( ISceneTokenProcessor *tokenizer, CChoreoActor *actor, CChoreoChannel *channel );
|
||||
|
||||
// Subscene support
|
||||
void SetSubScene( bool sub );
|
||||
bool IsSubScene( void ) const;
|
||||
|
||||
int GetSceneFPS( void ) const;
|
||||
void SetSceneFPS( int fps );
|
||||
bool IsUsingFrameSnap( void ) const;
|
||||
void SetUsingFrameSnap( bool snap );
|
||||
|
||||
float SnapTime( float t );
|
||||
|
||||
int GetSceneRampCount( void ) { return m_SceneRamp.GetCount(); };
|
||||
CExpressionSample *GetSceneRamp( int index ) { return m_SceneRamp.Get( index ); };
|
||||
CExpressionSample *AddSceneRamp( float time, float value, bool selected ) { return m_SceneRamp.Add( time, value, selected ); };
|
||||
void DeleteSceneRamp( int index ) { m_SceneRamp.Delete( index ); };
|
||||
void ClearSceneRamp( void ) { m_SceneRamp.Clear(); };
|
||||
void ResortSceneRamp( void ) { m_SceneRamp.Resort( this ); };
|
||||
|
||||
CCurveData *GetSceneRamp( void ) { return &m_SceneRamp; };
|
||||
|
||||
|
||||
// Global intensity for scene
|
||||
float GetSceneRampIntensity( float time ) { return m_SceneRamp.GetIntensity( this, time ); }
|
||||
|
||||
int GetTimeZoom( char const *tool );
|
||||
void SetTimeZoom( char const *tool, int tz );
|
||||
int TimeZoomFirst();
|
||||
int TimeZoomNext( int i );
|
||||
int TimeZoomInvalid() const;
|
||||
char const *TimeZoomName( int i );
|
||||
|
||||
void ReconcileCloseCaption();
|
||||
|
||||
char const *GetFilename() const;
|
||||
void SetFileName( char const *fn );
|
||||
|
||||
bool GetPlayingSoundName( char *pchBuff, int iBuffLength );
|
||||
bool HasUnplayedSpeech();
|
||||
bool HasFlexAnimation();
|
||||
void SetBackground( bool bIsBackground );
|
||||
bool IsBackground( void );
|
||||
|
||||
void ClearPauseEventDependencies();
|
||||
|
||||
bool HasEventsOfType( CChoreoEvent::EVENTTYPE type ) const;
|
||||
void RemoveEventsExceptTypes( int* typeList, int count );
|
||||
|
||||
void IgnorePhonemes( bool bIgnore );
|
||||
bool ShouldIgnorePhonemes() const;
|
||||
|
||||
// This is set by the engine to signify that we're not modifying the data and
|
||||
// therefore we can precompute the end time
|
||||
static bool s_bEditingDisabled;
|
||||
|
||||
private:
|
||||
|
||||
// Simulation stuff
|
||||
enum
|
||||
{
|
||||
IN_RANGE = 0,
|
||||
BEFORE_RANGE,
|
||||
AFTER_RANGE
|
||||
};
|
||||
|
||||
int IsTimeInRange( float t, float starttime, float endtime );
|
||||
|
||||
static bool EventLess( const CChoreoScene::ActiveList &al0, const CChoreoScene::ActiveList &al1 );
|
||||
|
||||
int EventThink( CChoreoEvent *e,
|
||||
float frame_start_time,
|
||||
float frame_end_time,
|
||||
bool playing_forward, PROCESSING_TYPE& disposition );
|
||||
|
||||
// Prints to debug console, etc
|
||||
void choreoprintf( int level, PRINTF_FORMAT_STRING const char *fmt, ... );
|
||||
|
||||
// Initialize scene
|
||||
void Init( IChoreoEventCallback *callback );
|
||||
|
||||
float FindAdjustedStartTime( void );
|
||||
float FindAdjustedEndTime( void );
|
||||
|
||||
CChoreoEvent *FindPauseBetweenTimes( float starttime, float endtime );
|
||||
|
||||
// Parse scenes from token buffer
|
||||
CChoreoEvent *ParseEvent( CChoreoActor *actor, CChoreoChannel *channel );
|
||||
CChoreoChannel *ParseChannel( CChoreoActor *actor );
|
||||
CChoreoActor *ParseActor( void );
|
||||
|
||||
void ParseFPS( void );
|
||||
void ParseSnap( void );
|
||||
void ParseIgnorePhonemes( void );
|
||||
|
||||
// Map file for retrieving named objects
|
||||
void ParseMapname( void );
|
||||
// When previewing actor in hlfaceposer, this is the model to associate
|
||||
void ParseFacePoserModel( CChoreoActor *actor );
|
||||
|
||||
// Print to printfunc
|
||||
void PrintEvent( int level, CChoreoEvent *e );
|
||||
void PrintChannel( int level, CChoreoChannel *c );
|
||||
void PrintActor( int level, CChoreoActor *a );
|
||||
|
||||
// File I/O
|
||||
public:
|
||||
static void FilePrintf( CUtlBuffer& buf, int level, PRINTF_FORMAT_STRING const char *fmt, ... );
|
||||
private:
|
||||
void FileSaveEvent( CUtlBuffer& buf, int level, CChoreoEvent *e );
|
||||
void FileSaveChannel( CUtlBuffer& buf, int level, CChoreoChannel *c );
|
||||
void FileSaveActor( CUtlBuffer& buf, int level, CChoreoActor *a );
|
||||
void FileSaveHeader( CUtlBuffer& buf );
|
||||
|
||||
// Object destruction
|
||||
void DestroyActor( CChoreoActor *actor );
|
||||
void DestroyChannel( CChoreoChannel *channel );
|
||||
void DestroyEvent( CChoreoEvent *event );
|
||||
|
||||
|
||||
void AddPauseEventDependency( CChoreoEvent *pauseEvent, CChoreoEvent *suppressed );
|
||||
|
||||
void InternalDetermineEventTypes();
|
||||
|
||||
// Global object storage
|
||||
CUtlVector < CChoreoEvent * > m_Events;
|
||||
CUtlVector < CChoreoActor * > m_Actors;
|
||||
CUtlVector < CChoreoChannel * > m_Channels;
|
||||
|
||||
// These are just pointers, the actual objects are in m_Events
|
||||
CUtlVector < CChoreoEvent * > m_ResumeConditions;
|
||||
// These are just pointers, the actual objects are in m_Events
|
||||
CUtlVector < CChoreoEvent * > m_ActiveResumeConditions;
|
||||
// These are just pointers, the actual objects are in m_Events
|
||||
CUtlVector < CChoreoEvent * > m_PauseEvents;
|
||||
|
||||
// Current simulation time
|
||||
float m_flCurrentTime;
|
||||
|
||||
float m_flStartTime;
|
||||
float m_flEndTime;
|
||||
|
||||
float m_flEarliestTime;
|
||||
float m_flLatestTime;
|
||||
int m_nActiveEvents;
|
||||
|
||||
// Wave file playback needs to issue play commands a bit ahead of time
|
||||
// in order to hit exact marks
|
||||
float m_flSoundSystemLatency;
|
||||
|
||||
// Scene's linger a bit after finishing to let blends reset themselves
|
||||
float m_flLastActiveTime;
|
||||
|
||||
// Print callback function
|
||||
void ( *m_pfnPrint )( PRINTF_FORMAT_STRING const char *fmt, ... );
|
||||
|
||||
IChoreoEventCallback *m_pIChoreoEventCallback;
|
||||
|
||||
ISceneTokenProcessor *m_pTokenizer;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_MAPNAME = 128
|
||||
};
|
||||
|
||||
char m_szMapname[ MAX_MAPNAME ];
|
||||
|
||||
int m_nSceneFPS;
|
||||
|
||||
CCurveData m_SceneRamp;
|
||||
|
||||
CUtlDict< int, int > m_TimeZoomLookup;
|
||||
char m_szFileName[ MAX_SCENE_FILENAME ];
|
||||
|
||||
CBitVec< CChoreoEvent::NUM_TYPES > m_bitvecHasEventOfType;
|
||||
|
||||
// tag to suppress vcd when others are playing
|
||||
bool m_bIsBackground : 1;
|
||||
bool m_bIgnorePhonemes : 1;
|
||||
bool m_bSubScene : 1;
|
||||
bool m_bUseFrameSnap : 1;
|
||||
bool m_bRestoring : 1;
|
||||
|
||||
int m_nLastPauseEvent;
|
||||
// This only gets updated if it's loaded from a buffer which means we're not in an editor
|
||||
float m_flPrecomputedStopTime;
|
||||
};
|
||||
|
||||
|
||||
bool CChoreoScene::IsRestoring()
|
||||
{
|
||||
return m_bRestoring;
|
||||
}
|
||||
|
||||
|
||||
void CChoreoScene::SetRestoring( bool bRestoring )
|
||||
{
|
||||
m_bRestoring = bRestoring;
|
||||
}
|
||||
|
||||
|
||||
abstract_class IChoreoStringPool
|
||||
{
|
||||
public:
|
||||
virtual short FindOrAddString( const char *pString ) = 0;
|
||||
virtual bool GetString( short stringId, char *buff, int buffSize ) = 0;
|
||||
};
|
||||
|
||||
CChoreoScene *ChoreoLoadScene(
|
||||
char const *filename,
|
||||
IChoreoEventCallback *callback,
|
||||
ISceneTokenProcessor *tokenizer,
|
||||
void ( *pfn ) ( PRINTF_FORMAT_STRING const char *fmt, ... ) );
|
||||
|
||||
bool IsBufferBinaryVCD( char *pBuffer, int bufferSize );
|
||||
|
||||
#endif // CHOREOSCENE_H
|
||||
|
||||
+1422
-1422
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,80 +1,80 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "cs_achievements_and_stats_interface.h"
|
||||
#include "baseachievement.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "hl2orange.spa.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "utlmap.h"
|
||||
#include "steam/steam_api.h"
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "../client/cstrike/VGUI/achievement_stats_summary.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/IPanel.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
|
||||
|
||||
#if defined(CSTRIKE_DLL) && defined(CLIENT_DLL)
|
||||
|
||||
CSAchievementsAndStatsInterface::CSAchievementsAndStatsInterface() : AchievementsAndStatsInterface()
|
||||
{
|
||||
m_pAchievementAndStatsSummary = NULL;
|
||||
|
||||
g_pAchievementsAndStatsInterface = this;
|
||||
}
|
||||
|
||||
void CSAchievementsAndStatsInterface::CreatePanel( vgui::Panel* pParent )
|
||||
{
|
||||
// Create achievement & stats dialog if not already created
|
||||
if ( !m_pAchievementAndStatsSummary )
|
||||
{
|
||||
m_pAchievementAndStatsSummary = new CAchievementAndStatsSummary(NULL);
|
||||
}
|
||||
|
||||
if ( m_pAchievementAndStatsSummary )
|
||||
{
|
||||
m_pAchievementAndStatsSummary->SetParent(pParent);
|
||||
}
|
||||
}
|
||||
|
||||
void CSAchievementsAndStatsInterface::DisplayPanel()
|
||||
{
|
||||
// Position & show dialog
|
||||
PositionDialog(m_pAchievementAndStatsSummary);
|
||||
m_pAchievementAndStatsSummary->Activate();
|
||||
|
||||
//Make sure the top of the page appears on the screen (for video modes such as 1280x720).
|
||||
int x, y;
|
||||
m_pAchievementAndStatsSummary->GetPos( x, y );
|
||||
if ( y < 0 )
|
||||
{
|
||||
m_pAchievementAndStatsSummary->SetPos( x, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CSAchievementsAndStatsInterface::ReleasePanel()
|
||||
{
|
||||
// Make sure the BasePanel doesn't try to delete this, because it doesn't really own it.
|
||||
if ( m_pAchievementAndStatsSummary )
|
||||
{
|
||||
m_pAchievementAndStatsSummary->SetParent((vgui::Panel*)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "cs_achievements_and_stats_interface.h"
|
||||
#include "baseachievement.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "hl2orange.spa.h"
|
||||
#include "iachievementmgr.h"
|
||||
#include "utlmap.h"
|
||||
#include "steam/steam_api.h"
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "../client/cstrike/VGUI/achievement_stats_summary.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/IPanel.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
|
||||
|
||||
#if defined(CSTRIKE_DLL) && defined(CLIENT_DLL)
|
||||
|
||||
CSAchievementsAndStatsInterface::CSAchievementsAndStatsInterface() : AchievementsAndStatsInterface()
|
||||
{
|
||||
m_pAchievementAndStatsSummary = NULL;
|
||||
|
||||
g_pAchievementsAndStatsInterface = this;
|
||||
}
|
||||
|
||||
void CSAchievementsAndStatsInterface::CreatePanel( vgui::Panel* pParent )
|
||||
{
|
||||
// Create achievement & stats dialog if not already created
|
||||
if ( !m_pAchievementAndStatsSummary )
|
||||
{
|
||||
m_pAchievementAndStatsSummary = new CAchievementAndStatsSummary(NULL);
|
||||
}
|
||||
|
||||
if ( m_pAchievementAndStatsSummary )
|
||||
{
|
||||
m_pAchievementAndStatsSummary->SetParent(pParent);
|
||||
}
|
||||
}
|
||||
|
||||
void CSAchievementsAndStatsInterface::DisplayPanel()
|
||||
{
|
||||
// Position & show dialog
|
||||
PositionDialog(m_pAchievementAndStatsSummary);
|
||||
m_pAchievementAndStatsSummary->Activate();
|
||||
|
||||
//Make sure the top of the page appears on the screen (for video modes such as 1280x720).
|
||||
int x, y;
|
||||
m_pAchievementAndStatsSummary->GetPos( x, y );
|
||||
if ( y < 0 )
|
||||
{
|
||||
m_pAchievementAndStatsSummary->SetPos( x, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CSAchievementsAndStatsInterface::ReleasePanel()
|
||||
{
|
||||
// Make sure the BasePanel doesn't try to delete this, because it doesn't really own it.
|
||||
if ( m_pAchievementAndStatsSummary )
|
||||
{
|
||||
m_pAchievementAndStatsSummary->SetParent((vgui::Panel*)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CSACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
#define CSACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "achievements_and_stats_interface.h"
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "../client/cstrike/VGUI/achievement_stats_summary.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/IPanel.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
|
||||
|
||||
#if defined(CSTRIKE_DLL) && defined(CLIENT_DLL)
|
||||
|
||||
class CSAchievementsAndStatsInterface : public AchievementsAndStatsInterface
|
||||
{
|
||||
public:
|
||||
CSAchievementsAndStatsInterface();
|
||||
|
||||
virtual void CreatePanel( vgui::Panel* pParent );
|
||||
virtual void DisplayPanel();
|
||||
virtual void ReleasePanel();
|
||||
virtual int GetAchievementsPanelMinWidth( void ) const { return cAchievementsDialogMinWidth; }
|
||||
|
||||
protected:
|
||||
vgui::DHANDLE<vgui::Frame> m_pAchievementAndStatsSummary;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CSACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CSACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
#define CSACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "achievements_and_stats_interface.h"
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
|
||||
#include "cs_gamestats_shared.h"
|
||||
#include "../client/cstrike/VGUI/achievement_stats_summary.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/IPanel.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
|
||||
|
||||
#if defined(CSTRIKE_DLL) && defined(CLIENT_DLL)
|
||||
|
||||
class CSAchievementsAndStatsInterface : public AchievementsAndStatsInterface
|
||||
{
|
||||
public:
|
||||
CSAchievementsAndStatsInterface();
|
||||
|
||||
virtual void CreatePanel( vgui::Panel* pParent );
|
||||
virtual void DisplayPanel();
|
||||
virtual void ReleasePanel();
|
||||
virtual int GetAchievementsPanelMinWidth( void ) const { return cAchievementsDialogMinWidth; }
|
||||
|
||||
protected:
|
||||
vgui::DHANDLE<vgui::Frame> m_pAchievementAndStatsSummary;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CSACHIEVEMENTSANDSTATSINTERFACE_H
|
||||
|
||||
+166
-166
@@ -1,166 +1,166 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "death_pose.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
void GetRagdollCurSequenceWithDeathPose( C_BaseAnimating *entity, matrix3x4_t *curBones, float flTime, int activity, int frame )
|
||||
{
|
||||
// blow the cached prev bones
|
||||
entity->InvalidateBoneCache();
|
||||
|
||||
Vector vPrevOrigin = entity->GetAbsOrigin();
|
||||
|
||||
entity->Interpolate( flTime );
|
||||
|
||||
if ( activity != ACT_INVALID )
|
||||
{
|
||||
Vector vNewOrigin = entity->GetAbsOrigin();
|
||||
Vector vDirection = vNewOrigin - vPrevOrigin;
|
||||
|
||||
float flVelocity = VectorNormalize( vDirection );
|
||||
|
||||
Vector vAdjustedOrigin = vNewOrigin + vDirection * ( ( flVelocity * flVelocity ) * gpGlobals->frametime );
|
||||
|
||||
int iTempSequence = entity->GetSequence();
|
||||
float flTempCycle = entity->GetCycle();
|
||||
|
||||
entity->SetSequence( activity );
|
||||
|
||||
entity->SetCycle( (float)frame / MAX_DEATHPOSE_FRAMES );
|
||||
|
||||
entity->SetAbsOrigin( vAdjustedOrigin );
|
||||
|
||||
// Now do the current bone setup
|
||||
entity->SetupBones( curBones, MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, flTime );
|
||||
|
||||
entity->SetAbsOrigin( vNewOrigin );
|
||||
|
||||
// blow the cached prev bones
|
||||
entity->InvalidateBoneCache();
|
||||
|
||||
entity->SetSequence( iTempSequence );
|
||||
entity->SetCycle( flTempCycle );
|
||||
|
||||
entity->Interpolate( gpGlobals->curtime );
|
||||
|
||||
entity->SetupBones( NULL, -1, BONE_USED_BY_ANYTHING, gpGlobals->curtime );
|
||||
}
|
||||
else
|
||||
{
|
||||
entity->SetupBones( curBones, MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, flTime );
|
||||
|
||||
// blow the cached prev bones
|
||||
entity->InvalidateBoneCache();
|
||||
|
||||
entity->SetupBones( NULL, -1, BONE_USED_BY_ANYTHING, flTime );
|
||||
}
|
||||
}
|
||||
|
||||
#else // !CLIENT_DLL
|
||||
|
||||
Activity GetDeathPoseActivity( CBaseAnimating *entity, const CTakeDamageInfo &info )
|
||||
{
|
||||
if ( !entity )
|
||||
{
|
||||
return ACT_INVALID;
|
||||
}
|
||||
|
||||
Activity aActivity;
|
||||
|
||||
Vector vForward, vRight;
|
||||
entity->GetVectors( &vForward, &vRight, NULL );
|
||||
|
||||
Vector vDir = -info.GetDamageForce();
|
||||
VectorNormalize( vDir );
|
||||
|
||||
float flDotForward = DotProduct( vForward, vDir );
|
||||
float flDotRight = DotProduct( vRight, vDir );
|
||||
|
||||
bool bNegativeForward = false;
|
||||
bool bNegativeRight = false;
|
||||
|
||||
if ( flDotForward < 0.0f )
|
||||
{
|
||||
bNegativeForward = true;
|
||||
flDotForward = flDotForward * -1;
|
||||
}
|
||||
|
||||
if ( flDotRight < 0.0f )
|
||||
{
|
||||
bNegativeRight = true;
|
||||
flDotRight = flDotRight * -1;
|
||||
}
|
||||
|
||||
if ( flDotRight > flDotForward )
|
||||
{
|
||||
if ( bNegativeRight == true )
|
||||
aActivity = ACT_DIE_LEFTSIDE;
|
||||
else
|
||||
aActivity = ACT_DIE_RIGHTSIDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( bNegativeForward == true )
|
||||
aActivity = ACT_DIE_BACKSIDE;
|
||||
else
|
||||
aActivity = ACT_DIE_FRONTSIDE;
|
||||
}
|
||||
|
||||
return aActivity;
|
||||
}
|
||||
|
||||
void SelectDeathPoseActivityAndFrame( CBaseAnimating *entity, const CTakeDamageInfo &info, int hitgroup, Activity& activity, int& frame )
|
||||
{
|
||||
activity = ACT_INVALID;
|
||||
frame = 0;
|
||||
|
||||
if ( !entity->GetModelPtr() )
|
||||
return;
|
||||
|
||||
activity = GetDeathPoseActivity( entity, info );
|
||||
frame = DEATH_FRAME_HEAD;
|
||||
|
||||
switch( hitgroup )
|
||||
{
|
||||
//Do normal ragdoll stuff if no specific hitgroup was hit.
|
||||
case HITGROUP_GENERIC:
|
||||
default:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
case HITGROUP_HEAD:
|
||||
{
|
||||
frame = DEATH_FRAME_HEAD;
|
||||
break;
|
||||
}
|
||||
case HITGROUP_LEFTARM:
|
||||
frame = DEATH_FRAME_LEFTARM;
|
||||
break;
|
||||
|
||||
case HITGROUP_RIGHTARM:
|
||||
frame = DEATH_FRAME_RIGHTARM;
|
||||
break;
|
||||
|
||||
case HITGROUP_CHEST:
|
||||
case HITGROUP_STOMACH:
|
||||
frame = DEATH_FRAME_STOMACH;
|
||||
break;
|
||||
|
||||
case HITGROUP_LEFTLEG:
|
||||
frame = DEATH_FRAME_LEFTLEG;
|
||||
break;
|
||||
|
||||
case HITGROUP_RIGHTLEG:
|
||||
frame = DEATH_FRAME_RIGHTLEG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !CLIENT_DLL
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
#include "death_pose.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
void GetRagdollCurSequenceWithDeathPose( C_BaseAnimating *entity, matrix3x4_t *curBones, float flTime, int activity, int frame )
|
||||
{
|
||||
// blow the cached prev bones
|
||||
entity->InvalidateBoneCache();
|
||||
|
||||
Vector vPrevOrigin = entity->GetAbsOrigin();
|
||||
|
||||
entity->Interpolate( flTime );
|
||||
|
||||
if ( activity != ACT_INVALID )
|
||||
{
|
||||
Vector vNewOrigin = entity->GetAbsOrigin();
|
||||
Vector vDirection = vNewOrigin - vPrevOrigin;
|
||||
|
||||
float flVelocity = VectorNormalize( vDirection );
|
||||
|
||||
Vector vAdjustedOrigin = vNewOrigin + vDirection * ( ( flVelocity * flVelocity ) * gpGlobals->frametime );
|
||||
|
||||
int iTempSequence = entity->GetSequence();
|
||||
float flTempCycle = entity->GetCycle();
|
||||
|
||||
entity->SetSequence( activity );
|
||||
|
||||
entity->SetCycle( (float)frame / MAX_DEATHPOSE_FRAMES );
|
||||
|
||||
entity->SetAbsOrigin( vAdjustedOrigin );
|
||||
|
||||
// Now do the current bone setup
|
||||
entity->SetupBones( curBones, MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, flTime );
|
||||
|
||||
entity->SetAbsOrigin( vNewOrigin );
|
||||
|
||||
// blow the cached prev bones
|
||||
entity->InvalidateBoneCache();
|
||||
|
||||
entity->SetSequence( iTempSequence );
|
||||
entity->SetCycle( flTempCycle );
|
||||
|
||||
entity->Interpolate( gpGlobals->curtime );
|
||||
|
||||
entity->SetupBones( NULL, -1, BONE_USED_BY_ANYTHING, gpGlobals->curtime );
|
||||
}
|
||||
else
|
||||
{
|
||||
entity->SetupBones( curBones, MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, flTime );
|
||||
|
||||
// blow the cached prev bones
|
||||
entity->InvalidateBoneCache();
|
||||
|
||||
entity->SetupBones( NULL, -1, BONE_USED_BY_ANYTHING, flTime );
|
||||
}
|
||||
}
|
||||
|
||||
#else // !CLIENT_DLL
|
||||
|
||||
Activity GetDeathPoseActivity( CBaseAnimating *entity, const CTakeDamageInfo &info )
|
||||
{
|
||||
if ( !entity )
|
||||
{
|
||||
return ACT_INVALID;
|
||||
}
|
||||
|
||||
Activity aActivity;
|
||||
|
||||
Vector vForward, vRight;
|
||||
entity->GetVectors( &vForward, &vRight, NULL );
|
||||
|
||||
Vector vDir = -info.GetDamageForce();
|
||||
VectorNormalize( vDir );
|
||||
|
||||
float flDotForward = DotProduct( vForward, vDir );
|
||||
float flDotRight = DotProduct( vRight, vDir );
|
||||
|
||||
bool bNegativeForward = false;
|
||||
bool bNegativeRight = false;
|
||||
|
||||
if ( flDotForward < 0.0f )
|
||||
{
|
||||
bNegativeForward = true;
|
||||
flDotForward = flDotForward * -1;
|
||||
}
|
||||
|
||||
if ( flDotRight < 0.0f )
|
||||
{
|
||||
bNegativeRight = true;
|
||||
flDotRight = flDotRight * -1;
|
||||
}
|
||||
|
||||
if ( flDotRight > flDotForward )
|
||||
{
|
||||
if ( bNegativeRight == true )
|
||||
aActivity = ACT_DIE_LEFTSIDE;
|
||||
else
|
||||
aActivity = ACT_DIE_RIGHTSIDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( bNegativeForward == true )
|
||||
aActivity = ACT_DIE_BACKSIDE;
|
||||
else
|
||||
aActivity = ACT_DIE_FRONTSIDE;
|
||||
}
|
||||
|
||||
return aActivity;
|
||||
}
|
||||
|
||||
void SelectDeathPoseActivityAndFrame( CBaseAnimating *entity, const CTakeDamageInfo &info, int hitgroup, Activity& activity, int& frame )
|
||||
{
|
||||
activity = ACT_INVALID;
|
||||
frame = 0;
|
||||
|
||||
if ( !entity->GetModelPtr() )
|
||||
return;
|
||||
|
||||
activity = GetDeathPoseActivity( entity, info );
|
||||
frame = DEATH_FRAME_HEAD;
|
||||
|
||||
switch( hitgroup )
|
||||
{
|
||||
//Do normal ragdoll stuff if no specific hitgroup was hit.
|
||||
case HITGROUP_GENERIC:
|
||||
default:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
case HITGROUP_HEAD:
|
||||
{
|
||||
frame = DEATH_FRAME_HEAD;
|
||||
break;
|
||||
}
|
||||
case HITGROUP_LEFTARM:
|
||||
frame = DEATH_FRAME_LEFTARM;
|
||||
break;
|
||||
|
||||
case HITGROUP_RIGHTARM:
|
||||
frame = DEATH_FRAME_RIGHTARM;
|
||||
break;
|
||||
|
||||
case HITGROUP_CHEST:
|
||||
case HITGROUP_STOMACH:
|
||||
frame = DEATH_FRAME_STOMACH;
|
||||
break;
|
||||
|
||||
case HITGROUP_LEFTLEG:
|
||||
frame = DEATH_FRAME_LEFTLEG;
|
||||
break;
|
||||
|
||||
case HITGROUP_RIGHTLEG:
|
||||
frame = DEATH_FRAME_RIGHTLEG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef DEATH_POSE_H
|
||||
#define DEATH_POSE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
DEATH_FRAME_HEAD = 1,
|
||||
DEATH_FRAME_STOMACH,
|
||||
DEATH_FRAME_LEFTARM,
|
||||
DEATH_FRAME_RIGHTARM,
|
||||
DEATH_FRAME_LEFTLEG,
|
||||
DEATH_FRAME_RIGHTLEG,
|
||||
MAX_DEATHPOSE_FRAMES = DEATH_FRAME_RIGHTLEG
|
||||
};
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
void GetRagdollCurSequenceWithDeathPose( C_BaseAnimating *entity, matrix3x4_t *curBones, float flTime, int activity, int frame );
|
||||
|
||||
#else // !CLIENT_DLL
|
||||
|
||||
/// Calculates death pose activity and frame
|
||||
void SelectDeathPoseActivityAndFrame( CBaseAnimating *entity, const CTakeDamageInfo &info, int hitgroup, Activity& activity, int& frame );
|
||||
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
#endif // DEATH_POSE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef DEATH_POSE_H
|
||||
#define DEATH_POSE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
DEATH_FRAME_HEAD = 1,
|
||||
DEATH_FRAME_STOMACH,
|
||||
DEATH_FRAME_LEFTARM,
|
||||
DEATH_FRAME_RIGHTARM,
|
||||
DEATH_FRAME_LEFTLEG,
|
||||
DEATH_FRAME_RIGHTLEG,
|
||||
MAX_DEATHPOSE_FRAMES = DEATH_FRAME_RIGHTLEG
|
||||
};
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
void GetRagdollCurSequenceWithDeathPose( C_BaseAnimating *entity, matrix3x4_t *curBones, float flTime, int activity, int frame );
|
||||
|
||||
#else // !CLIENT_DLL
|
||||
|
||||
/// Calculates death pose activity and frame
|
||||
void SelectDeathPoseActivityAndFrame( CBaseAnimating *entity, const CTakeDamageInfo &info, int hitgroup, Activity& activity, int& frame );
|
||||
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
#endif // DEATH_POSE_H
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cbase.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
#include "mathlib/mathlib.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//=============================================================================
|
||||
// NDebugOverlay
|
||||
//=============================================================================
|
||||
namespace NDebugOverlay
|
||||
{
|
||||
void Box(const Vector &origin, const Vector &mins, const Vector &maxs, int r, int g, int b, int a, float flDuration) {}
|
||||
void BoxDirection(const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &forward, int r, int g, int b, int a, float flDuration) {}
|
||||
void BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float flDuration) {}
|
||||
void SweptBox(const Vector& start, const Vector& end, const Vector& mins, const Vector& maxs, const QAngle & angles, int r, int g, int b, int a, float flDuration) {}
|
||||
void EntityBounds( const CBaseEntity *pEntity, int r, int g, int b, int a, float flDuration ) {}
|
||||
void Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration ) {}
|
||||
void EntityText( int entityID, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255) {}
|
||||
void EntityTextAtPosition( const Vector &origin, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255) {}
|
||||
void Grid( const Vector &vPosition ) {}
|
||||
void Text( const Vector &origin, const char *text, bool bViewCheck, float flDuration ) {}
|
||||
void ScreenText( float fXpos, float fYpos, const char *text, int r, int g, int b, int a, float flDuration) {}
|
||||
void Cross3D(const Vector &position, const Vector &mins, const Vector &maxs, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Cross3D(const Vector &position, float size, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Cross3DOriented( const Vector &position, const QAngle &angles, float size, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Cross3DOriented( const matrix3x4_t &m, float size, int c, bool noDepthTest, float flDuration ) {}
|
||||
void DrawOverlayLines(void){}
|
||||
void DrawTickMarkedLine(const Vector &startPos, const Vector &endPos, float tickDist, int tickTextDist, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void DrawGroundCrossHairOverlay() {}
|
||||
void HorzArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration) {}
|
||||
void YawArrow( const Vector &startPos, float yaw, float length, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration) {}
|
||||
void VertArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration) {}
|
||||
};
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cbase.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
#include "mathlib/mathlib.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//=============================================================================
|
||||
// NDebugOverlay
|
||||
//=============================================================================
|
||||
namespace NDebugOverlay
|
||||
{
|
||||
void Box(const Vector &origin, const Vector &mins, const Vector &maxs, int r, int g, int b, int a, float flDuration) {}
|
||||
void BoxDirection(const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &forward, int r, int g, int b, int a, float flDuration) {}
|
||||
void BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float flDuration) {}
|
||||
void SweptBox(const Vector& start, const Vector& end, const Vector& mins, const Vector& maxs, const QAngle & angles, int r, int g, int b, int a, float flDuration) {}
|
||||
void EntityBounds( const CBaseEntity *pEntity, int r, int g, int b, int a, float flDuration ) {}
|
||||
void Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration ) {}
|
||||
void EntityText( int entityID, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255) {}
|
||||
void EntityTextAtPosition( const Vector &origin, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255) {}
|
||||
void Grid( const Vector &vPosition ) {}
|
||||
void Text( const Vector &origin, const char *text, bool bViewCheck, float flDuration ) {}
|
||||
void ScreenText( float fXpos, float fYpos, const char *text, int r, int g, int b, int a, float flDuration) {}
|
||||
void Cross3D(const Vector &position, const Vector &mins, const Vector &maxs, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Cross3D(const Vector &position, float size, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Cross3DOriented( const Vector &position, const QAngle &angles, float size, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void Cross3DOriented( const matrix3x4_t &m, float size, int c, bool noDepthTest, float flDuration ) {}
|
||||
void DrawOverlayLines(void){}
|
||||
void DrawTickMarkedLine(const Vector &startPos, const Vector &endPos, float tickDist, int tickTextDist, int r, int g, int b, bool noDepthTest, float flDuration ) {}
|
||||
void DrawGroundCrossHairOverlay() {}
|
||||
void HorzArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration) {}
|
||||
void YawArrow( const Vector &startPos, float yaw, float length, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration) {}
|
||||
void VertArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration) {}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,51 +1,51 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef DEBUGOVERLAY_SHARED_H
|
||||
#define DEBUGOVERLAY_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
//=============================================================================
|
||||
// NDebugOverlay
|
||||
//=============================================================================
|
||||
namespace NDebugOverlay
|
||||
{
|
||||
void Box(const Vector &origin, const Vector &mins, const Vector &maxs, int r, int g, int b, int a, float flDuration);
|
||||
void BoxDirection(const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &forward, int r, int g, int b, int a, float flDuration);
|
||||
void BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float flDuration);
|
||||
void SweptBox(const Vector& start, const Vector& end, const Vector& mins, const Vector& maxs, const QAngle & angles, int r, int g, int b, int a, float flDuration);
|
||||
void EntityBounds( const CBaseEntity *pEntity, int r, int g, int b, int a, float flDuration );
|
||||
void Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration );
|
||||
void EntityText( int entityID, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255);
|
||||
void EntityTextAtPosition( const Vector &origin, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255);
|
||||
void Grid( const Vector &vPosition );
|
||||
void Text( const Vector &origin, const char *text, bool bViewCheck, float flDuration );
|
||||
void ScreenText( float fXpos, float fYpos, const char *text, int r, int g, int b, int a, float flDuration);
|
||||
void Cross3D(const Vector &position, const Vector &mins, const Vector &maxs, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Cross3D(const Vector &position, float size, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Cross3DOriented( const Vector &position, const QAngle &angles, float size, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Cross3DOriented( const matrix3x4_t &m, float size, int c, bool noDepthTest, float flDuration );
|
||||
void DrawOverlayLines(void);
|
||||
void DrawTickMarkedLine(const Vector &startPos, const Vector &endPos, float tickDist, int tickTextDist, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void DrawGroundCrossHairOverlay();
|
||||
void HorzArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
|
||||
void YawArrow( const Vector &startPos, float yaw, float length, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
|
||||
void VertArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
|
||||
void Axis( const Vector &position, const QAngle &angles, float size, bool noDepthTest, float flDuration );
|
||||
void Sphere( const Vector ¢er, float radius, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Circle( const Vector &position, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
void Circle( const Vector &position, const QAngle &angles, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
void Circle( const Vector &position, const Vector &xAxis, const Vector &yAxis, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
void Sphere( const Vector &position, const QAngle &angles, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
};
|
||||
|
||||
#endif // DEBUGOVERLAY_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef DEBUGOVERLAY_SHARED_H
|
||||
#define DEBUGOVERLAY_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
//=============================================================================
|
||||
// NDebugOverlay
|
||||
//=============================================================================
|
||||
namespace NDebugOverlay
|
||||
{
|
||||
void Box(const Vector &origin, const Vector &mins, const Vector &maxs, int r, int g, int b, int a, float flDuration);
|
||||
void BoxDirection(const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &forward, int r, int g, int b, int a, float flDuration);
|
||||
void BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float flDuration);
|
||||
void SweptBox(const Vector& start, const Vector& end, const Vector& mins, const Vector& maxs, const QAngle & angles, int r, int g, int b, int a, float flDuration);
|
||||
void EntityBounds( const CBaseEntity *pEntity, int r, int g, int b, int a, float flDuration );
|
||||
void Line( const Vector &origin, const Vector &target, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Triangle( const Vector &p1, const Vector &p2, const Vector &p3, int r, int g, int b, int a, bool noDepthTest, float duration );
|
||||
void EntityText( int entityID, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255);
|
||||
void EntityTextAtPosition( const Vector &origin, int text_offset, const char *text, float flDuration, int r = 255, int g = 255, int b = 255, int a = 255);
|
||||
void Grid( const Vector &vPosition );
|
||||
void Text( const Vector &origin, const char *text, bool bViewCheck, float flDuration );
|
||||
void ScreenText( float fXpos, float fYpos, const char *text, int r, int g, int b, int a, float flDuration);
|
||||
void Cross3D(const Vector &position, const Vector &mins, const Vector &maxs, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Cross3D(const Vector &position, float size, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Cross3DOriented( const Vector &position, const QAngle &angles, float size, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Cross3DOriented( const matrix3x4_t &m, float size, int c, bool noDepthTest, float flDuration );
|
||||
void DrawOverlayLines(void);
|
||||
void DrawTickMarkedLine(const Vector &startPos, const Vector &endPos, float tickDist, int tickTextDist, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void DrawGroundCrossHairOverlay();
|
||||
void HorzArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
|
||||
void YawArrow( const Vector &startPos, float yaw, float length, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
|
||||
void VertArrow( const Vector &startPos, const Vector &endPos, float width, int r, int g, int b, int a, bool noDepthTest, float flDuration);
|
||||
void Axis( const Vector &position, const QAngle &angles, float size, bool noDepthTest, float flDuration );
|
||||
void Sphere( const Vector ¢er, float radius, int r, int g, int b, bool noDepthTest, float flDuration );
|
||||
void Circle( const Vector &position, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
void Circle( const Vector &position, const QAngle &angles, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
void Circle( const Vector &position, const Vector &xAxis, const Vector &yAxis, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
void Sphere( const Vector &position, const QAngle &angles, float radius, int r, int g, int b, int a, bool bNoDepthTest, float flDuration );
|
||||
};
|
||||
|
||||
#endif // DEBUGOVERLAY_SHARED_H
|
||||
|
||||
+345
-345
@@ -1,345 +1,345 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "decals.h"
|
||||
#include "igamesystem.h"
|
||||
#include "utlsymbol.h"
|
||||
#include "utldict.h"
|
||||
#include "KeyValues.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "iefx.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define DECAL_LIST_FILE "scripts/decals_subrect.txt"
|
||||
//#define DECAL_LIST_FILE "scripts/decals.txt"
|
||||
#define TRANSLATION_DATA_SECTION "TranslationData"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDecalEmitterSystem : public IDecalEmitterSystem, public CAutoGameSystem
|
||||
{
|
||||
public:
|
||||
CDecalEmitterSystem( char const *name ) : CAutoGameSystem( name )
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Init();
|
||||
virtual void Shutdown();
|
||||
virtual void LevelInitPreEntity();
|
||||
|
||||
// Public interface
|
||||
virtual int GetDecalIndexForName( char const *decalname );
|
||||
virtual const char *GetDecalNameForIndex( int nIndex );
|
||||
virtual char const *TranslateDecalForGameMaterial( char const *decalName, unsigned char gamematerial );
|
||||
|
||||
private:
|
||||
char const *ImpactDecalForGameMaterial( int gamematerial );
|
||||
void LoadDecalsFromScript( char const *filename );
|
||||
void Clear();
|
||||
|
||||
struct DecalListEntry
|
||||
{
|
||||
DecalListEntry()
|
||||
{
|
||||
name = UTL_INVAL_SYMBOL;
|
||||
precache_index = -1;
|
||||
weight = 1.0f;
|
||||
}
|
||||
|
||||
CUtlSymbol name;
|
||||
int precache_index;
|
||||
float weight;
|
||||
};
|
||||
|
||||
struct DecalEntry
|
||||
{
|
||||
DecalEntry()
|
||||
{
|
||||
}
|
||||
|
||||
DecalEntry( const DecalEntry& src )
|
||||
{
|
||||
int c = src.indices.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
indices.AddToTail( src.indices[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
DecalEntry& operator = ( const DecalEntry& src )
|
||||
{
|
||||
if ( this == &src )
|
||||
return *this;
|
||||
|
||||
int c = src.indices.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
indices.AddToTail( src.indices[ i ] );
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlVector< int > indices;
|
||||
};
|
||||
|
||||
CUtlVector< DecalListEntry > m_AllDecals;
|
||||
CUtlDict< DecalEntry, int > m_Decals;
|
||||
CUtlSymbolTable m_DecalFileNames;
|
||||
CUtlDict< int, int > m_GameMaterialTranslation;
|
||||
};
|
||||
|
||||
static CDecalEmitterSystem g_DecalSystem( "CDecalEmitterSystem" );
|
||||
IDecalEmitterSystem *decalsystem = &g_DecalSystem;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *decalname -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CDecalEmitterSystem::GetDecalIndexForName( char const *decalname )
|
||||
{
|
||||
if ( !decalname || !decalname[ 0 ] )
|
||||
return -1;
|
||||
|
||||
int idx = m_Decals.Find( decalname );
|
||||
if ( idx == m_Decals.InvalidIndex() )
|
||||
return -1;
|
||||
|
||||
DecalEntry *e = &m_Decals[ idx ];
|
||||
Assert( e );
|
||||
int count = e->indices.Count();
|
||||
if ( count <= 0 )
|
||||
return -1;
|
||||
|
||||
float totalweight = 0.0f;
|
||||
int slot = 0;
|
||||
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
int idx = e->indices[ i ];
|
||||
DecalListEntry *item = &m_AllDecals[ idx ];
|
||||
Assert( item );
|
||||
|
||||
if ( !totalweight )
|
||||
{
|
||||
slot = idx;
|
||||
}
|
||||
|
||||
// Always assume very first slot will match
|
||||
totalweight += item->weight;
|
||||
if ( !totalweight || random->RandomFloat(0,totalweight) < item->weight )
|
||||
{
|
||||
slot = idx;
|
||||
}
|
||||
}
|
||||
|
||||
return m_AllDecals[ slot ].precache_index;
|
||||
}
|
||||
|
||||
const char *CDecalEmitterSystem::GetDecalNameForIndex( int nIndex )
|
||||
{
|
||||
for ( int nDecal = 0; nDecal < m_AllDecals.Count(); ++nDecal )
|
||||
{
|
||||
if ( m_AllDecals[ nDecal ].precache_index == nIndex )
|
||||
{
|
||||
return m_DecalFileNames.String( m_AllDecals[ nDecal ].name );
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CDecalEmitterSystem::Init()
|
||||
{
|
||||
LoadDecalsFromScript( DECAL_LIST_FILE );
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::LevelInitPreEntity()
|
||||
{
|
||||
// Precache all entries
|
||||
int c = m_AllDecals.Count();
|
||||
for ( int i = 0 ; i < c; i++ )
|
||||
{
|
||||
DecalListEntry& e = m_AllDecals[ i ];
|
||||
#if defined( CLIENT_DLL )
|
||||
e.precache_index = effects->Draw_DecalIndexFromName( (char *)m_DecalFileNames.String( e.name ) );
|
||||
#else
|
||||
e.precache_index = engine->PrecacheDecal( m_DecalFileNames.String( e.name ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::LoadDecalsFromScript( char const *filename )
|
||||
{
|
||||
KeyValues *kv = new KeyValues( filename );
|
||||
Assert( kv );
|
||||
if ( kv )
|
||||
{
|
||||
KeyValues *translation = NULL;
|
||||
#ifndef _XBOX
|
||||
if ( kv->LoadFromFile( filesystem, filename ) )
|
||||
#else
|
||||
if ( kv->LoadFromFile( filesystem, filename, "GAME" ) )
|
||||
#endif
|
||||
{
|
||||
KeyValues *p = kv;
|
||||
while ( p )
|
||||
{
|
||||
if ( p->GetFirstSubKey() )
|
||||
{
|
||||
char const *keyname = p->GetName();
|
||||
|
||||
if ( !Q_stricmp( keyname, TRANSLATION_DATA_SECTION ) )
|
||||
{
|
||||
translation = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
DecalEntry entry;
|
||||
|
||||
for ( KeyValues *sub = p->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
|
||||
DecalListEntry decal;
|
||||
decal.precache_index = -1;
|
||||
decal.name = m_DecalFileNames.AddString( sub->GetName() );
|
||||
decal.weight = sub->GetFloat();
|
||||
|
||||
// Add to global list
|
||||
int idx = m_AllDecals.AddToTail( decal );
|
||||
|
||||
// Add index only to local list
|
||||
entry.indices.AddToTail( idx );
|
||||
}
|
||||
|
||||
// Add entry to main dictionary
|
||||
m_Decals.Insert( keyname, entry );
|
||||
}
|
||||
}
|
||||
p = p->GetNextKey();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Unable to load '%s'\n", filename );
|
||||
}
|
||||
|
||||
if ( !translation )
|
||||
{
|
||||
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Script '%s' missing section '%s'\n",
|
||||
filename,
|
||||
TRANSLATION_DATA_SECTION );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now parse game material to entry translation table
|
||||
for ( KeyValues *sub = translation->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
|
||||
{
|
||||
// Don't add NULL string to list
|
||||
if ( !Q_stricmp( sub->GetString(), "" ) )
|
||||
continue;
|
||||
|
||||
int idx = m_Decals.Find( sub->GetString() );
|
||||
if ( idx != m_Decals.InvalidIndex() )
|
||||
{
|
||||
m_GameMaterialTranslation.Insert( sub->GetName(), idx );
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Translation for game material type '%s' references unknown decal '%s'\n",
|
||||
sub->GetName(), sub->GetString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kv->deleteThis();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : gamematerial -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *CDecalEmitterSystem::ImpactDecalForGameMaterial( int gamematerial )
|
||||
{
|
||||
char gm[ 2 ];
|
||||
gm[0] = (char)gamematerial;
|
||||
gm[1] = 0;
|
||||
|
||||
int idx = m_GameMaterialTranslation.Find( gm );
|
||||
if ( idx == m_GameMaterialTranslation.InvalidIndex() )
|
||||
return NULL;
|
||||
|
||||
return m_Decals.GetElementName( m_GameMaterialTranslation.Element(idx) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::Shutdown()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::Clear()
|
||||
{
|
||||
m_DecalFileNames.RemoveAll();
|
||||
m_Decals.Purge();
|
||||
m_AllDecals.Purge();
|
||||
m_GameMaterialTranslation.Purge();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *decalName -
|
||||
// gamematerial -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *CDecalEmitterSystem::TranslateDecalForGameMaterial( char const *decalName, unsigned char gamematerial )
|
||||
{
|
||||
if ( gamematerial == CHAR_TEX_CONCRETE )
|
||||
return decalName;
|
||||
|
||||
if ( !Q_stricmp( decalName, "Impact.Concrete" ) )
|
||||
{
|
||||
if ( gamematerial == '-' )
|
||||
return "";
|
||||
|
||||
char const *d = ImpactDecalForGameMaterial( gamematerial );
|
||||
if ( d )
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
return decalName;
|
||||
}
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "decals.h"
|
||||
#include "igamesystem.h"
|
||||
#include "utlsymbol.h"
|
||||
#include "utldict.h"
|
||||
#include "KeyValues.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "iefx.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#define DECAL_LIST_FILE "scripts/decals_subrect.txt"
|
||||
//#define DECAL_LIST_FILE "scripts/decals.txt"
|
||||
#define TRANSLATION_DATA_SECTION "TranslationData"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDecalEmitterSystem : public IDecalEmitterSystem, public CAutoGameSystem
|
||||
{
|
||||
public:
|
||||
CDecalEmitterSystem( char const *name ) : CAutoGameSystem( name )
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Init();
|
||||
virtual void Shutdown();
|
||||
virtual void LevelInitPreEntity();
|
||||
|
||||
// Public interface
|
||||
virtual int GetDecalIndexForName( char const *decalname );
|
||||
virtual const char *GetDecalNameForIndex( int nIndex );
|
||||
virtual char const *TranslateDecalForGameMaterial( char const *decalName, unsigned char gamematerial );
|
||||
|
||||
private:
|
||||
char const *ImpactDecalForGameMaterial( int gamematerial );
|
||||
void LoadDecalsFromScript( char const *filename );
|
||||
void Clear();
|
||||
|
||||
struct DecalListEntry
|
||||
{
|
||||
DecalListEntry()
|
||||
{
|
||||
name = UTL_INVAL_SYMBOL;
|
||||
precache_index = -1;
|
||||
weight = 1.0f;
|
||||
}
|
||||
|
||||
CUtlSymbol name;
|
||||
int precache_index;
|
||||
float weight;
|
||||
};
|
||||
|
||||
struct DecalEntry
|
||||
{
|
||||
DecalEntry()
|
||||
{
|
||||
}
|
||||
|
||||
DecalEntry( const DecalEntry& src )
|
||||
{
|
||||
int c = src.indices.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
indices.AddToTail( src.indices[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
DecalEntry& operator = ( const DecalEntry& src )
|
||||
{
|
||||
if ( this == &src )
|
||||
return *this;
|
||||
|
||||
int c = src.indices.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
indices.AddToTail( src.indices[ i ] );
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CUtlVector< int > indices;
|
||||
};
|
||||
|
||||
CUtlVector< DecalListEntry > m_AllDecals;
|
||||
CUtlDict< DecalEntry, int > m_Decals;
|
||||
CUtlSymbolTable m_DecalFileNames;
|
||||
CUtlDict< int, int > m_GameMaterialTranslation;
|
||||
};
|
||||
|
||||
static CDecalEmitterSystem g_DecalSystem( "CDecalEmitterSystem" );
|
||||
IDecalEmitterSystem *decalsystem = &g_DecalSystem;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *decalname -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CDecalEmitterSystem::GetDecalIndexForName( char const *decalname )
|
||||
{
|
||||
if ( !decalname || !decalname[ 0 ] )
|
||||
return -1;
|
||||
|
||||
int idx = m_Decals.Find( decalname );
|
||||
if ( idx == m_Decals.InvalidIndex() )
|
||||
return -1;
|
||||
|
||||
DecalEntry *e = &m_Decals[ idx ];
|
||||
Assert( e );
|
||||
int count = e->indices.Count();
|
||||
if ( count <= 0 )
|
||||
return -1;
|
||||
|
||||
float totalweight = 0.0f;
|
||||
int slot = 0;
|
||||
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
int idx = e->indices[ i ];
|
||||
DecalListEntry *item = &m_AllDecals[ idx ];
|
||||
Assert( item );
|
||||
|
||||
if ( !totalweight )
|
||||
{
|
||||
slot = idx;
|
||||
}
|
||||
|
||||
// Always assume very first slot will match
|
||||
totalweight += item->weight;
|
||||
if ( !totalweight || random->RandomFloat(0,totalweight) < item->weight )
|
||||
{
|
||||
slot = idx;
|
||||
}
|
||||
}
|
||||
|
||||
return m_AllDecals[ slot ].precache_index;
|
||||
}
|
||||
|
||||
const char *CDecalEmitterSystem::GetDecalNameForIndex( int nIndex )
|
||||
{
|
||||
for ( int nDecal = 0; nDecal < m_AllDecals.Count(); ++nDecal )
|
||||
{
|
||||
if ( m_AllDecals[ nDecal ].precache_index == nIndex )
|
||||
{
|
||||
return m_DecalFileNames.String( m_AllDecals[ nDecal ].name );
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CDecalEmitterSystem::Init()
|
||||
{
|
||||
LoadDecalsFromScript( DECAL_LIST_FILE );
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::LevelInitPreEntity()
|
||||
{
|
||||
// Precache all entries
|
||||
int c = m_AllDecals.Count();
|
||||
for ( int i = 0 ; i < c; i++ )
|
||||
{
|
||||
DecalListEntry& e = m_AllDecals[ i ];
|
||||
#if defined( CLIENT_DLL )
|
||||
e.precache_index = effects->Draw_DecalIndexFromName( (char *)m_DecalFileNames.String( e.name ) );
|
||||
#else
|
||||
e.precache_index = engine->PrecacheDecal( m_DecalFileNames.String( e.name ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::LoadDecalsFromScript( char const *filename )
|
||||
{
|
||||
KeyValues *kv = new KeyValues( filename );
|
||||
Assert( kv );
|
||||
if ( kv )
|
||||
{
|
||||
KeyValues *translation = NULL;
|
||||
#ifndef _XBOX
|
||||
if ( kv->LoadFromFile( filesystem, filename ) )
|
||||
#else
|
||||
if ( kv->LoadFromFile( filesystem, filename, "GAME" ) )
|
||||
#endif
|
||||
{
|
||||
KeyValues *p = kv;
|
||||
while ( p )
|
||||
{
|
||||
if ( p->GetFirstSubKey() )
|
||||
{
|
||||
char const *keyname = p->GetName();
|
||||
|
||||
if ( !Q_stricmp( keyname, TRANSLATION_DATA_SECTION ) )
|
||||
{
|
||||
translation = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
DecalEntry entry;
|
||||
|
||||
for ( KeyValues *sub = p->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
|
||||
DecalListEntry decal;
|
||||
decal.precache_index = -1;
|
||||
decal.name = m_DecalFileNames.AddString( sub->GetName() );
|
||||
decal.weight = sub->GetFloat();
|
||||
|
||||
// Add to global list
|
||||
int idx = m_AllDecals.AddToTail( decal );
|
||||
|
||||
// Add index only to local list
|
||||
entry.indices.AddToTail( idx );
|
||||
}
|
||||
|
||||
// Add entry to main dictionary
|
||||
m_Decals.Insert( keyname, entry );
|
||||
}
|
||||
}
|
||||
p = p->GetNextKey();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Unable to load '%s'\n", filename );
|
||||
}
|
||||
|
||||
if ( !translation )
|
||||
{
|
||||
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Script '%s' missing section '%s'\n",
|
||||
filename,
|
||||
TRANSLATION_DATA_SECTION );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now parse game material to entry translation table
|
||||
for ( KeyValues *sub = translation->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
|
||||
{
|
||||
// Don't add NULL string to list
|
||||
if ( !Q_stricmp( sub->GetString(), "" ) )
|
||||
continue;
|
||||
|
||||
int idx = m_Decals.Find( sub->GetString() );
|
||||
if ( idx != m_Decals.InvalidIndex() )
|
||||
{
|
||||
m_GameMaterialTranslation.Insert( sub->GetName(), idx );
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Translation for game material type '%s' references unknown decal '%s'\n",
|
||||
sub->GetName(), sub->GetString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kv->deleteThis();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : gamematerial -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *CDecalEmitterSystem::ImpactDecalForGameMaterial( int gamematerial )
|
||||
{
|
||||
char gm[ 2 ];
|
||||
gm[0] = (char)gamematerial;
|
||||
gm[1] = 0;
|
||||
|
||||
int idx = m_GameMaterialTranslation.Find( gm );
|
||||
if ( idx == m_GameMaterialTranslation.InvalidIndex() )
|
||||
return NULL;
|
||||
|
||||
return m_Decals.GetElementName( m_GameMaterialTranslation.Element(idx) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::Shutdown()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CDecalEmitterSystem::Clear()
|
||||
{
|
||||
m_DecalFileNames.RemoveAll();
|
||||
m_Decals.Purge();
|
||||
m_AllDecals.Purge();
|
||||
m_GameMaterialTranslation.Purge();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *decalName -
|
||||
// gamematerial -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *CDecalEmitterSystem::TranslateDecalForGameMaterial( char const *decalName, unsigned char gamematerial )
|
||||
{
|
||||
if ( gamematerial == CHAR_TEX_CONCRETE )
|
||||
return decalName;
|
||||
|
||||
if ( !Q_stricmp( decalName, "Impact.Concrete" ) )
|
||||
{
|
||||
if ( gamematerial == '-' )
|
||||
return "";
|
||||
|
||||
char const *d = ImpactDecalForGameMaterial( gamematerial );
|
||||
if ( d )
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
return decalName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+52
-52
@@ -1,52 +1,52 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef DECALS_H
|
||||
#define DECALS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// NOTE: If you add a tex type, be sure to modify the s_pImpactEffect
|
||||
// array in fx_impact.cpp to get an effect when that surface is shot.
|
||||
#define CHAR_TEX_ANTLION 'A'
|
||||
#define CHAR_TEX_BLOODYFLESH 'B'
|
||||
#define CHAR_TEX_CONCRETE 'C'
|
||||
#define CHAR_TEX_DIRT 'D'
|
||||
#define CHAR_TEX_EGGSHELL 'E' ///< the egg sacs in the tunnels in ep2.
|
||||
#define CHAR_TEX_FLESH 'F'
|
||||
#define CHAR_TEX_GRATE 'G'
|
||||
#define CHAR_TEX_ALIENFLESH 'H'
|
||||
#define CHAR_TEX_CLIP 'I'
|
||||
//#define CHAR_TEX_UNUSED 'J'
|
||||
//#define CHAR_TEX_UNUSED 'K'
|
||||
#define CHAR_TEX_PLASTIC 'L'
|
||||
#define CHAR_TEX_METAL 'M'
|
||||
#define CHAR_TEX_SAND 'N'
|
||||
#define CHAR_TEX_FOLIAGE 'O'
|
||||
#define CHAR_TEX_COMPUTER 'P'
|
||||
//#define CHAR_TEX_UNUSED 'Q'
|
||||
//#define CHAR_TEX_UNUSED 'R'
|
||||
#define CHAR_TEX_SLOSH 'S'
|
||||
#define CHAR_TEX_TILE 'T'
|
||||
//#define CHAR_TEX_UNUSED 'U'
|
||||
#define CHAR_TEX_VENT 'V'
|
||||
#define CHAR_TEX_WOOD 'W'
|
||||
//#define CHAR_TEX_UNUSED 'X'
|
||||
#define CHAR_TEX_GLASS 'Y'
|
||||
#define CHAR_TEX_WARPSHIELD 'Z' ///< wierd-looking jello effect for advisor shield.
|
||||
|
||||
abstract_class IDecalEmitterSystem
|
||||
{
|
||||
public:
|
||||
virtual int GetDecalIndexForName( char const *decalname ) = 0;
|
||||
virtual const char *GetDecalNameForIndex( int nIndex ) = 0;
|
||||
virtual char const *TranslateDecalForGameMaterial( char const *decalName, unsigned char gamematerial ) = 0;
|
||||
};
|
||||
|
||||
extern IDecalEmitterSystem *decalsystem;
|
||||
|
||||
#endif // DECALS_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef DECALS_H
|
||||
#define DECALS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// NOTE: If you add a tex type, be sure to modify the s_pImpactEffect
|
||||
// array in fx_impact.cpp to get an effect when that surface is shot.
|
||||
#define CHAR_TEX_ANTLION 'A'
|
||||
#define CHAR_TEX_BLOODYFLESH 'B'
|
||||
#define CHAR_TEX_CONCRETE 'C'
|
||||
#define CHAR_TEX_DIRT 'D'
|
||||
#define CHAR_TEX_EGGSHELL 'E' ///< the egg sacs in the tunnels in ep2.
|
||||
#define CHAR_TEX_FLESH 'F'
|
||||
#define CHAR_TEX_GRATE 'G'
|
||||
#define CHAR_TEX_ALIENFLESH 'H'
|
||||
#define CHAR_TEX_CLIP 'I'
|
||||
//#define CHAR_TEX_UNUSED 'J'
|
||||
//#define CHAR_TEX_UNUSED 'K'
|
||||
#define CHAR_TEX_PLASTIC 'L'
|
||||
#define CHAR_TEX_METAL 'M'
|
||||
#define CHAR_TEX_SAND 'N'
|
||||
#define CHAR_TEX_FOLIAGE 'O'
|
||||
#define CHAR_TEX_COMPUTER 'P'
|
||||
//#define CHAR_TEX_UNUSED 'Q'
|
||||
//#define CHAR_TEX_UNUSED 'R'
|
||||
#define CHAR_TEX_SLOSH 'S'
|
||||
#define CHAR_TEX_TILE 'T'
|
||||
//#define CHAR_TEX_UNUSED 'U'
|
||||
#define CHAR_TEX_VENT 'V'
|
||||
#define CHAR_TEX_WOOD 'W'
|
||||
//#define CHAR_TEX_UNUSED 'X'
|
||||
#define CHAR_TEX_GLASS 'Y'
|
||||
#define CHAR_TEX_WARPSHIELD 'Z' ///< wierd-looking jello effect for advisor shield.
|
||||
|
||||
abstract_class IDecalEmitterSystem
|
||||
{
|
||||
public:
|
||||
virtual int GetDecalIndexForName( char const *decalname ) = 0;
|
||||
virtual const char *GetDecalNameForIndex( int nIndex ) = 0;
|
||||
virtual char const *TranslateDecalForGameMaterial( char const *decalName, unsigned char gamematerial ) = 0;
|
||||
};
|
||||
|
||||
extern IDecalEmitterSystem *decalsystem;
|
||||
|
||||
#endif // DECALS_H
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef IHASOWNER_H
|
||||
#define IHASOWNER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CBaseEntity;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Allows an entity to access its owner regardless of entity type
|
||||
//-----------------------------------------------------------------------------
|
||||
class IHasOwner
|
||||
{
|
||||
public:
|
||||
virtual CBaseEntity *GetOwnerViaInterface( void ) = 0;
|
||||
};
|
||||
|
||||
#endif // IHASOWNER_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef IHASOWNER_H
|
||||
#define IHASOWNER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CBaseEntity;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Allows an entity to access its owner regardless of entity type
|
||||
//-----------------------------------------------------------------------------
|
||||
class IHasOwner
|
||||
{
|
||||
public:
|
||||
virtual CBaseEntity *GetOwnerViaInterface( void ) = 0;
|
||||
};
|
||||
|
||||
#endif // IHASOWNER_H
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EFFECT_COLOR_TABLES_H
|
||||
#define EFFECT_COLOR_TABLES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
struct colorentry_t
|
||||
{
|
||||
unsigned char index;
|
||||
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
};
|
||||
|
||||
#define COLOR_TABLE_SIZE(ct) sizeof(ct)/sizeof(colorentry_t)
|
||||
|
||||
// Commander mode indicators (HL2)
|
||||
enum
|
||||
{
|
||||
COMMAND_POINT_RED = 0,
|
||||
COMMAND_POINT_BLUE,
|
||||
COMMAND_POINT_GREEN,
|
||||
COMMAND_POINT_YELLOW,
|
||||
};
|
||||
|
||||
// Commander mode table
|
||||
static colorentry_t commandercolors[] =
|
||||
{
|
||||
{ COMMAND_POINT_RED, 1.0, 0.0, 0.0 },
|
||||
{ COMMAND_POINT_BLUE, 0.0, 0.0, 1.0 },
|
||||
{ COMMAND_POINT_GREEN, 0.0, 1.0, 0.0 },
|
||||
{ COMMAND_POINT_YELLOW, 1.0, 1.0, 0.0 },
|
||||
};
|
||||
|
||||
static colorentry_t bloodcolors[] =
|
||||
{
|
||||
{ BLOOD_COLOR_RED, 72, 0, 0 },
|
||||
{ BLOOD_COLOR_YELLOW, 195, 195, 0 },
|
||||
{ BLOOD_COLOR_MECH, 20, 20, 20 },
|
||||
};
|
||||
|
||||
#endif // EFFECT_COLOR_TABLES_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EFFECT_COLOR_TABLES_H
|
||||
#define EFFECT_COLOR_TABLES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
struct colorentry_t
|
||||
{
|
||||
unsigned char index;
|
||||
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
};
|
||||
|
||||
#define COLOR_TABLE_SIZE(ct) sizeof(ct)/sizeof(colorentry_t)
|
||||
|
||||
// Commander mode indicators (HL2)
|
||||
enum
|
||||
{
|
||||
COMMAND_POINT_RED = 0,
|
||||
COMMAND_POINT_BLUE,
|
||||
COMMAND_POINT_GREEN,
|
||||
COMMAND_POINT_YELLOW,
|
||||
};
|
||||
|
||||
// Commander mode table
|
||||
static colorentry_t commandercolors[] =
|
||||
{
|
||||
{ COMMAND_POINT_RED, 1.0, 0.0, 0.0 },
|
||||
{ COMMAND_POINT_BLUE, 0.0, 0.0, 1.0 },
|
||||
{ COMMAND_POINT_GREEN, 0.0, 1.0, 0.0 },
|
||||
{ COMMAND_POINT_YELLOW, 1.0, 1.0, 0.0 },
|
||||
};
|
||||
|
||||
static colorentry_t bloodcolors[] =
|
||||
{
|
||||
{ BLOOD_COLOR_RED, 72, 0, 0 },
|
||||
{ BLOOD_COLOR_YELLOW, 195, 195, 0 },
|
||||
{ BLOOD_COLOR_MECH, 20, 20, 20 },
|
||||
};
|
||||
|
||||
#endif // EFFECT_COLOR_TABLES_H
|
||||
|
||||
@@ -1,175 +1,175 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "effect_dispatch_data.h"
|
||||
#include "coordsize.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "cliententitylist.h"
|
||||
#endif
|
||||
|
||||
#include "qlimits.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
#define SUBINCH_PRECISION 3
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
#include "dt_recv.h"
|
||||
|
||||
static void RecvProxy_EntIndex( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
int nEntIndex = pData->m_Value.m_Int;
|
||||
((CEffectData*)pStruct)->m_hEntity = (nEntIndex < 0) ? INVALID_EHANDLE_INDEX : ClientEntityList().EntIndexToHandle( nEntIndex );
|
||||
}
|
||||
|
||||
BEGIN_RECV_TABLE_NOBASE( CEffectData, DT_EffectData )
|
||||
|
||||
RecvPropFloat( RECVINFO( m_vOrigin[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vOrigin[1] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vOrigin[2] ) ),
|
||||
|
||||
RecvPropFloat( RECVINFO( m_vStart[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vStart[1] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vStart[2] ) ),
|
||||
|
||||
RecvPropQAngles( RECVINFO( m_vAngles ) ),
|
||||
|
||||
RecvPropVector( RECVINFO( m_vNormal ) ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_fFlags ) ),
|
||||
RecvPropFloat( RECVINFO( m_flMagnitude ) ),
|
||||
RecvPropFloat( RECVINFO( m_flScale ) ),
|
||||
RecvPropInt( RECVINFO( m_nAttachmentIndex ) ),
|
||||
RecvPropIntWithMinusOneFlag( RECVINFO( m_nSurfaceProp ), RecvProxy_ShortSubOne ),
|
||||
RecvPropInt( RECVINFO( m_iEffectName ) ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_nMaterial ) ),
|
||||
RecvPropInt( RECVINFO( m_nDamageType ) ),
|
||||
RecvPropInt( RECVINFO( m_nHitBox ) ),
|
||||
|
||||
RecvPropInt( "entindex", 0, SIZEOF_IGNORE, 0, RecvProxy_EntIndex ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_nColor ) ),
|
||||
|
||||
RecvPropFloat( RECVINFO( m_flRadius ) ),
|
||||
|
||||
RecvPropBool( RECVINFO( m_bCustomColors ) ),
|
||||
RecvPropVector( RECVINFO( m_CustomColors.m_vecColor1 ) ),
|
||||
RecvPropVector( RECVINFO( m_CustomColors.m_vecColor2 ) ),
|
||||
|
||||
RecvPropBool( RECVINFO( m_bControlPoint1 ) ),
|
||||
RecvPropInt( RECVINFO( m_ControlPoint1.m_eParticleAttachment ) ),
|
||||
RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[1] ) ),
|
||||
RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[2] ) ),
|
||||
|
||||
END_RECV_TABLE()
|
||||
|
||||
#else
|
||||
|
||||
#include "dt_send.h"
|
||||
|
||||
BEGIN_SEND_TABLE_NOBASE( CEffectData, DT_EffectData )
|
||||
|
||||
// Everything uses _NOCHECK here since this is not an entity and we don't need
|
||||
// the functionality of CNetworkVars.
|
||||
|
||||
// Get half-inch precision here.
|
||||
#ifdef HL2_DLL
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[0] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[1] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[2] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[0] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[1] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[2] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
#else
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[0] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[1] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[2] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[0] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[1] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[2] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
#endif
|
||||
SendPropQAngles( SENDINFO_NOCHECK( m_vAngles ), 7 ),
|
||||
|
||||
#if defined( TF_DLL )
|
||||
SendPropVector( SENDINFO_NOCHECK( m_vNormal ), 6, 0, -1.0f, 1.0f ),
|
||||
#else
|
||||
SendPropVector( SENDINFO_NOCHECK( m_vNormal ), 0, SPROP_NORMAL ),
|
||||
#endif
|
||||
|
||||
SendPropInt( SENDINFO_NOCHECK( m_fFlags ), MAX_EFFECT_FLAG_BITS, SPROP_UNSIGNED ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_flMagnitude ), 12, SPROP_ROUNDDOWN, 0.0f, 1023.0f ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_flScale ), 0, SPROP_NOSCALE ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nAttachmentIndex ), 5, SPROP_UNSIGNED ),
|
||||
SendPropIntWithMinusOneFlag( SENDINFO_NOCHECK( m_nSurfaceProp ), 8, SendProxy_ShortAddOne ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_iEffectName ), MAX_EFFECT_DISPATCH_STRING_BITS, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nMaterial ), MAX_MODEL_INDEX_BITS, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nDamageType ), 32, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nHitBox ), 11, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropInt( SENDINFO_NAME( m_nEntIndex, entindex ), MAX_EDICT_BITS, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nColor ), 8, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_flRadius ), 10, SPROP_ROUNDDOWN, 0.0f, 1023.0f ),
|
||||
|
||||
SendPropBool( SENDINFO_NOCHECK( m_bCustomColors) ),
|
||||
SendPropVector( SENDINFO_NOCHECK( m_CustomColors.m_vecColor1 ), 8, 0, 0, 1 ),
|
||||
SendPropVector( SENDINFO_NOCHECK( m_CustomColors.m_vecColor2 ), 8, 0, 0, 1 ),
|
||||
|
||||
SendPropBool( SENDINFO_NOCHECK( m_bControlPoint1) ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_ControlPoint1.m_eParticleAttachment ), 5, SPROP_UNSIGNED ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_ControlPoint1.m_vecOffset[0] ), -1, SPROP_COORD ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_ControlPoint1.m_vecOffset[1] ), -1, SPROP_COORD ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_ControlPoint1.m_vecOffset[2] ), -1, SPROP_COORD ),
|
||||
|
||||
END_SEND_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
IClientRenderable *CEffectData::GetRenderable() const
|
||||
{
|
||||
return ClientEntityList().GetClientRenderableFromHandle( m_hEntity );
|
||||
}
|
||||
|
||||
C_BaseEntity *CEffectData::GetEntity() const
|
||||
{
|
||||
return ClientEntityList().GetBaseEntityFromHandle( m_hEntity );
|
||||
}
|
||||
|
||||
int CEffectData::entindex() const
|
||||
{
|
||||
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( m_hEntity );
|
||||
return pEnt ? pEnt->entindex() : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
bool g_bSuppressParticleEffects = false;
|
||||
|
||||
bool SuppressingParticleEffects()
|
||||
{
|
||||
return g_bSuppressParticleEffects;
|
||||
}
|
||||
|
||||
void SuppressParticleEffects( bool bSuppress )
|
||||
{
|
||||
g_bSuppressParticleEffects = bSuppress;
|
||||
}
|
||||
|
||||
#endif
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "effect_dispatch_data.h"
|
||||
#include "coordsize.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#include "cliententitylist.h"
|
||||
#endif
|
||||
|
||||
#include "qlimits.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
#define SUBINCH_PRECISION 3
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
#include "dt_recv.h"
|
||||
|
||||
static void RecvProxy_EntIndex( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
int nEntIndex = pData->m_Value.m_Int;
|
||||
((CEffectData*)pStruct)->m_hEntity = (nEntIndex < 0) ? INVALID_EHANDLE_INDEX : ClientEntityList().EntIndexToHandle( nEntIndex );
|
||||
}
|
||||
|
||||
BEGIN_RECV_TABLE_NOBASE( CEffectData, DT_EffectData )
|
||||
|
||||
RecvPropFloat( RECVINFO( m_vOrigin[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vOrigin[1] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vOrigin[2] ) ),
|
||||
|
||||
RecvPropFloat( RECVINFO( m_vStart[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vStart[1] ) ),
|
||||
RecvPropFloat( RECVINFO( m_vStart[2] ) ),
|
||||
|
||||
RecvPropQAngles( RECVINFO( m_vAngles ) ),
|
||||
|
||||
RecvPropVector( RECVINFO( m_vNormal ) ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_fFlags ) ),
|
||||
RecvPropFloat( RECVINFO( m_flMagnitude ) ),
|
||||
RecvPropFloat( RECVINFO( m_flScale ) ),
|
||||
RecvPropInt( RECVINFO( m_nAttachmentIndex ) ),
|
||||
RecvPropIntWithMinusOneFlag( RECVINFO( m_nSurfaceProp ), RecvProxy_ShortSubOne ),
|
||||
RecvPropInt( RECVINFO( m_iEffectName ) ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_nMaterial ) ),
|
||||
RecvPropInt( RECVINFO( m_nDamageType ) ),
|
||||
RecvPropInt( RECVINFO( m_nHitBox ) ),
|
||||
|
||||
RecvPropInt( "entindex", 0, SIZEOF_IGNORE, 0, RecvProxy_EntIndex ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_nColor ) ),
|
||||
|
||||
RecvPropFloat( RECVINFO( m_flRadius ) ),
|
||||
|
||||
RecvPropBool( RECVINFO( m_bCustomColors ) ),
|
||||
RecvPropVector( RECVINFO( m_CustomColors.m_vecColor1 ) ),
|
||||
RecvPropVector( RECVINFO( m_CustomColors.m_vecColor2 ) ),
|
||||
|
||||
RecvPropBool( RECVINFO( m_bControlPoint1 ) ),
|
||||
RecvPropInt( RECVINFO( m_ControlPoint1.m_eParticleAttachment ) ),
|
||||
RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[0] ) ),
|
||||
RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[1] ) ),
|
||||
RecvPropFloat( RECVINFO( m_ControlPoint1.m_vecOffset[2] ) ),
|
||||
|
||||
END_RECV_TABLE()
|
||||
|
||||
#else
|
||||
|
||||
#include "dt_send.h"
|
||||
|
||||
BEGIN_SEND_TABLE_NOBASE( CEffectData, DT_EffectData )
|
||||
|
||||
// Everything uses _NOCHECK here since this is not an entity and we don't need
|
||||
// the functionality of CNetworkVars.
|
||||
|
||||
// Get half-inch precision here.
|
||||
#ifdef HL2_DLL
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[0] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[1] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[2] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[0] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[1] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[2] ), COORD_INTEGER_BITS+SUBINCH_PRECISION, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
|
||||
#else
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[0] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[1] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vOrigin[2] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[0] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[1] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_vStart[2] ), -1, SPROP_COORD_MP_INTEGRAL ),
|
||||
#endif
|
||||
SendPropQAngles( SENDINFO_NOCHECK( m_vAngles ), 7 ),
|
||||
|
||||
#if defined( TF_DLL )
|
||||
SendPropVector( SENDINFO_NOCHECK( m_vNormal ), 6, 0, -1.0f, 1.0f ),
|
||||
#else
|
||||
SendPropVector( SENDINFO_NOCHECK( m_vNormal ), 0, SPROP_NORMAL ),
|
||||
#endif
|
||||
|
||||
SendPropInt( SENDINFO_NOCHECK( m_fFlags ), MAX_EFFECT_FLAG_BITS, SPROP_UNSIGNED ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_flMagnitude ), 12, SPROP_ROUNDDOWN, 0.0f, 1023.0f ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_flScale ), 0, SPROP_NOSCALE ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nAttachmentIndex ), 5, SPROP_UNSIGNED ),
|
||||
SendPropIntWithMinusOneFlag( SENDINFO_NOCHECK( m_nSurfaceProp ), 8, SendProxy_ShortAddOne ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_iEffectName ), MAX_EFFECT_DISPATCH_STRING_BITS, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nMaterial ), MAX_MODEL_INDEX_BITS, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nDamageType ), 32, SPROP_UNSIGNED ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nHitBox ), 11, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropInt( SENDINFO_NAME( m_nEntIndex, entindex ), MAX_EDICT_BITS, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropInt( SENDINFO_NOCHECK( m_nColor ), 8, SPROP_UNSIGNED ),
|
||||
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_flRadius ), 10, SPROP_ROUNDDOWN, 0.0f, 1023.0f ),
|
||||
|
||||
SendPropBool( SENDINFO_NOCHECK( m_bCustomColors) ),
|
||||
SendPropVector( SENDINFO_NOCHECK( m_CustomColors.m_vecColor1 ), 8, 0, 0, 1 ),
|
||||
SendPropVector( SENDINFO_NOCHECK( m_CustomColors.m_vecColor2 ), 8, 0, 0, 1 ),
|
||||
|
||||
SendPropBool( SENDINFO_NOCHECK( m_bControlPoint1) ),
|
||||
SendPropInt( SENDINFO_NOCHECK( m_ControlPoint1.m_eParticleAttachment ), 5, SPROP_UNSIGNED ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_ControlPoint1.m_vecOffset[0] ), -1, SPROP_COORD ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_ControlPoint1.m_vecOffset[1] ), -1, SPROP_COORD ),
|
||||
SendPropFloat( SENDINFO_NOCHECK( m_ControlPoint1.m_vecOffset[2] ), -1, SPROP_COORD ),
|
||||
|
||||
END_SEND_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
IClientRenderable *CEffectData::GetRenderable() const
|
||||
{
|
||||
return ClientEntityList().GetClientRenderableFromHandle( m_hEntity );
|
||||
}
|
||||
|
||||
C_BaseEntity *CEffectData::GetEntity() const
|
||||
{
|
||||
return ClientEntityList().GetBaseEntityFromHandle( m_hEntity );
|
||||
}
|
||||
|
||||
int CEffectData::entindex() const
|
||||
{
|
||||
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( m_hEntity );
|
||||
return pEnt ? pEnt->entindex() : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
bool g_bSuppressParticleEffects = false;
|
||||
|
||||
bool SuppressingParticleEffects()
|
||||
{
|
||||
return g_bSuppressParticleEffects;
|
||||
}
|
||||
|
||||
void SuppressParticleEffects( bool bSuppress )
|
||||
{
|
||||
g_bSuppressParticleEffects = bSuppress;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,139 +1,139 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef EFFECT_DISPATCH_DATA_H
|
||||
#define EFFECT_DISPATCH_DATA_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "particle_parse.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
#include "dt_recv.h"
|
||||
#include "client_class.h"
|
||||
|
||||
EXTERN_RECV_TABLE( DT_EffectData );
|
||||
|
||||
#else
|
||||
|
||||
#include "dt_send.h"
|
||||
#include "server_class.h"
|
||||
|
||||
EXTERN_SEND_TABLE( DT_EffectData );
|
||||
|
||||
#endif
|
||||
|
||||
// NOTE: These flags are specifically *not* networked; so it's placed above the max effect flag bits
|
||||
#define EFFECTDATA_NO_RECORD 0x80000000
|
||||
|
||||
#define MAX_EFFECT_FLAG_BITS 8
|
||||
|
||||
#define CUSTOM_COLOR_CP1 9
|
||||
#define CUSTOM_COLOR_CP2 10
|
||||
|
||||
// This is the class that holds whatever data we're sending down to the client to make the effect.
|
||||
class CEffectData
|
||||
{
|
||||
public:
|
||||
Vector m_vOrigin;
|
||||
Vector m_vStart;
|
||||
Vector m_vNormal;
|
||||
QAngle m_vAngles;
|
||||
int m_fFlags;
|
||||
#ifdef CLIENT_DLL
|
||||
ClientEntityHandle_t m_hEntity;
|
||||
#else
|
||||
int m_nEntIndex;
|
||||
#endif
|
||||
float m_flScale;
|
||||
float m_flMagnitude;
|
||||
float m_flRadius;
|
||||
int m_nAttachmentIndex;
|
||||
short m_nSurfaceProp;
|
||||
|
||||
// Some TF2 specific things
|
||||
int m_nMaterial;
|
||||
int m_nDamageType;
|
||||
int m_nHitBox;
|
||||
|
||||
unsigned char m_nColor;
|
||||
|
||||
// Color customizability
|
||||
bool m_bCustomColors;
|
||||
te_tf_particle_effects_colors_t m_CustomColors;
|
||||
|
||||
bool m_bControlPoint1;
|
||||
te_tf_particle_effects_control_point_t m_ControlPoint1;
|
||||
|
||||
// Don't mess with stuff below here. DispatchEffect handles all of this.
|
||||
public:
|
||||
CEffectData()
|
||||
{
|
||||
m_vOrigin.Init();
|
||||
m_vStart.Init();
|
||||
m_vNormal.Init();
|
||||
m_vAngles.Init();
|
||||
|
||||
m_fFlags = 0;
|
||||
#ifdef CLIENT_DLL
|
||||
m_hEntity = INVALID_EHANDLE_INDEX;
|
||||
#else
|
||||
m_nEntIndex = 0;
|
||||
#endif
|
||||
m_flScale = 1.f;
|
||||
m_nAttachmentIndex = 0;
|
||||
m_nSurfaceProp = 0;
|
||||
|
||||
m_flMagnitude = 0.0f;
|
||||
m_flRadius = 0.0f;
|
||||
|
||||
m_nMaterial = 0;
|
||||
m_nDamageType = 0;
|
||||
m_nHitBox = 0;
|
||||
|
||||
m_nColor = 0;
|
||||
|
||||
m_bCustomColors = false;
|
||||
m_CustomColors.m_vecColor1.Init();
|
||||
m_CustomColors.m_vecColor2.Init();
|
||||
|
||||
m_bControlPoint1 = false;
|
||||
m_ControlPoint1.m_eParticleAttachment = PATTACH_ABSORIGIN;
|
||||
m_ControlPoint1.m_vecOffset.Init();
|
||||
}
|
||||
|
||||
int GetEffectNameIndex() { return m_iEffectName; }
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
IClientRenderable *GetRenderable() const;
|
||||
C_BaseEntity *GetEntity() const;
|
||||
int entindex() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
DECLARE_CLIENTCLASS_NOBASE()
|
||||
#else
|
||||
DECLARE_SERVERCLASS_NOBASE()
|
||||
#endif
|
||||
|
||||
int m_iEffectName; // Entry in the EffectDispatch network string table. The is automatically handled by DispatchEffect().
|
||||
};
|
||||
|
||||
|
||||
#define MAX_EFFECT_DISPATCH_STRING_BITS 10
|
||||
#define MAX_EFFECT_DISPATCH_STRINGS ( 1 << MAX_EFFECT_DISPATCH_STRING_BITS )
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
bool SuppressingParticleEffects();
|
||||
void SuppressParticleEffects( bool bSuppress );
|
||||
#endif
|
||||
|
||||
#endif // EFFECT_DISPATCH_DATA_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef EFFECT_DISPATCH_DATA_H
|
||||
#define EFFECT_DISPATCH_DATA_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "particle_parse.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
||||
#include "dt_recv.h"
|
||||
#include "client_class.h"
|
||||
|
||||
EXTERN_RECV_TABLE( DT_EffectData );
|
||||
|
||||
#else
|
||||
|
||||
#include "dt_send.h"
|
||||
#include "server_class.h"
|
||||
|
||||
EXTERN_SEND_TABLE( DT_EffectData );
|
||||
|
||||
#endif
|
||||
|
||||
// NOTE: These flags are specifically *not* networked; so it's placed above the max effect flag bits
|
||||
#define EFFECTDATA_NO_RECORD 0x80000000
|
||||
|
||||
#define MAX_EFFECT_FLAG_BITS 8
|
||||
|
||||
#define CUSTOM_COLOR_CP1 9
|
||||
#define CUSTOM_COLOR_CP2 10
|
||||
|
||||
// This is the class that holds whatever data we're sending down to the client to make the effect.
|
||||
class CEffectData
|
||||
{
|
||||
public:
|
||||
Vector m_vOrigin;
|
||||
Vector m_vStart;
|
||||
Vector m_vNormal;
|
||||
QAngle m_vAngles;
|
||||
int m_fFlags;
|
||||
#ifdef CLIENT_DLL
|
||||
ClientEntityHandle_t m_hEntity;
|
||||
#else
|
||||
int m_nEntIndex;
|
||||
#endif
|
||||
float m_flScale;
|
||||
float m_flMagnitude;
|
||||
float m_flRadius;
|
||||
int m_nAttachmentIndex;
|
||||
short m_nSurfaceProp;
|
||||
|
||||
// Some TF2 specific things
|
||||
int m_nMaterial;
|
||||
int m_nDamageType;
|
||||
int m_nHitBox;
|
||||
|
||||
unsigned char m_nColor;
|
||||
|
||||
// Color customizability
|
||||
bool m_bCustomColors;
|
||||
te_tf_particle_effects_colors_t m_CustomColors;
|
||||
|
||||
bool m_bControlPoint1;
|
||||
te_tf_particle_effects_control_point_t m_ControlPoint1;
|
||||
|
||||
// Don't mess with stuff below here. DispatchEffect handles all of this.
|
||||
public:
|
||||
CEffectData()
|
||||
{
|
||||
m_vOrigin.Init();
|
||||
m_vStart.Init();
|
||||
m_vNormal.Init();
|
||||
m_vAngles.Init();
|
||||
|
||||
m_fFlags = 0;
|
||||
#ifdef CLIENT_DLL
|
||||
m_hEntity = INVALID_EHANDLE_INDEX;
|
||||
#else
|
||||
m_nEntIndex = 0;
|
||||
#endif
|
||||
m_flScale = 1.f;
|
||||
m_nAttachmentIndex = 0;
|
||||
m_nSurfaceProp = 0;
|
||||
|
||||
m_flMagnitude = 0.0f;
|
||||
m_flRadius = 0.0f;
|
||||
|
||||
m_nMaterial = 0;
|
||||
m_nDamageType = 0;
|
||||
m_nHitBox = 0;
|
||||
|
||||
m_nColor = 0;
|
||||
|
||||
m_bCustomColors = false;
|
||||
m_CustomColors.m_vecColor1.Init();
|
||||
m_CustomColors.m_vecColor2.Init();
|
||||
|
||||
m_bControlPoint1 = false;
|
||||
m_ControlPoint1.m_eParticleAttachment = PATTACH_ABSORIGIN;
|
||||
m_ControlPoint1.m_vecOffset.Init();
|
||||
}
|
||||
|
||||
int GetEffectNameIndex() { return m_iEffectName; }
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
IClientRenderable *GetRenderable() const;
|
||||
C_BaseEntity *GetEntity() const;
|
||||
int entindex() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
DECLARE_CLIENTCLASS_NOBASE()
|
||||
#else
|
||||
DECLARE_SERVERCLASS_NOBASE()
|
||||
#endif
|
||||
|
||||
int m_iEffectName; // Entry in the EffectDispatch network string table. The is automatically handled by DispatchEffect().
|
||||
};
|
||||
|
||||
|
||||
#define MAX_EFFECT_DISPATCH_STRING_BITS 10
|
||||
#define MAX_EFFECT_DISPATCH_STRINGS ( 1 << MAX_EFFECT_DISPATCH_STRING_BITS )
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
bool SuppressingParticleEffects();
|
||||
void SuppressParticleEffects( bool bSuppress );
|
||||
#endif
|
||||
|
||||
#endif // EFFECT_DISPATCH_DATA_H
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This module implements functions to support ehandles.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#if defined( GAME_DLL )
|
||||
|
||||
#include "entitylist.h"
|
||||
|
||||
|
||||
void DebugCheckEHandleAccess( void *pEnt )
|
||||
{
|
||||
extern bool g_bDisableEhandleAccess;
|
||||
|
||||
if ( g_bDisableEhandleAccess )
|
||||
{
|
||||
Msg( "Access of EHANDLE/CHandle for class %s:%p in destructor!\n",
|
||||
STRING(((CBaseEntity*)pEnt)->m_iClassname ), pEnt );
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This module implements functions to support ehandles.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#if defined( GAME_DLL )
|
||||
|
||||
#include "entitylist.h"
|
||||
|
||||
|
||||
void DebugCheckEHandleAccess( void *pEnt )
|
||||
{
|
||||
extern bool g_bDisableEhandleAccess;
|
||||
|
||||
if ( g_bDisableEhandleAccess )
|
||||
{
|
||||
Msg( "Access of EHANDLE/CHandle for class %s:%p in destructor!\n",
|
||||
STRING(((CBaseEntity*)pEnt)->m_iClassname ), pEnt );
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+169
-169
@@ -1,169 +1,169 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EHANDLE_H
|
||||
#define EHANDLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( _DEBUG ) && defined( GAME_DLL )
|
||||
#include "tier0/dbg.h"
|
||||
#include "cbase.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "basehandle.h"
|
||||
#include "entitylist_base.h"
|
||||
|
||||
|
||||
class IHandleEntity;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// Game-code CBaseHandle implementation.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
inline IHandleEntity* CBaseHandle::Get() const
|
||||
{
|
||||
extern CBaseEntityList *g_pEntityList;
|
||||
return g_pEntityList->LookupEntity( *this );
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// CHandle.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
template< class T >
|
||||
class CHandle : public CBaseHandle
|
||||
{
|
||||
public:
|
||||
|
||||
CHandle();
|
||||
CHandle( int iEntry, int iSerialNumber );
|
||||
CHandle( const CBaseHandle &handle );
|
||||
CHandle( T *pVal );
|
||||
|
||||
// The index should have come from a call to ToInt(). If it hasn't, you're in trouble.
|
||||
static CHandle<T> FromIndex( int index );
|
||||
|
||||
T* Get() const;
|
||||
void Set( const T* pVal );
|
||||
|
||||
operator T*();
|
||||
operator T*() const;
|
||||
|
||||
bool operator !() const;
|
||||
bool operator==( T *val ) const;
|
||||
bool operator!=( T *val ) const;
|
||||
const CBaseHandle& operator=( const T *val );
|
||||
|
||||
T* operator->() const;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// Inlines.
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle( int iEntry, int iSerialNumber )
|
||||
{
|
||||
Init( iEntry, iSerialNumber );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle( const CBaseHandle &handle )
|
||||
: CBaseHandle( handle )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle( T *pObj )
|
||||
{
|
||||
Term();
|
||||
Set( pObj );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline CHandle<T> CHandle<T>::FromIndex( int index )
|
||||
{
|
||||
CHandle<T> ret;
|
||||
ret.m_Index = index;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T* CHandle<T>::Get() const
|
||||
{
|
||||
return (T*)CBaseHandle::Get();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline CHandle<T>::operator T *()
|
||||
{
|
||||
return Get( );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline CHandle<T>::operator T *() const
|
||||
{
|
||||
return Get( );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool CHandle<T>::operator !() const
|
||||
{
|
||||
return !Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool CHandle<T>::operator==( T *val ) const
|
||||
{
|
||||
return Get() == val;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool CHandle<T>::operator!=( T *val ) const
|
||||
{
|
||||
return Get() != val;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void CHandle<T>::Set( const T* pVal )
|
||||
{
|
||||
CBaseHandle::Set( reinterpret_cast<const IHandleEntity*>(pVal) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const CBaseHandle& CHandle<T>::operator=( const T *val )
|
||||
{
|
||||
Set( val );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* CHandle<T>::operator -> () const
|
||||
{
|
||||
return Get();
|
||||
}
|
||||
|
||||
|
||||
#endif // EHANDLE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EHANDLE_H
|
||||
#define EHANDLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( _DEBUG ) && defined( GAME_DLL )
|
||||
#include "tier0/dbg.h"
|
||||
#include "cbase.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "basehandle.h"
|
||||
#include "entitylist_base.h"
|
||||
|
||||
|
||||
class IHandleEntity;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// Game-code CBaseHandle implementation.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
inline IHandleEntity* CBaseHandle::Get() const
|
||||
{
|
||||
extern CBaseEntityList *g_pEntityList;
|
||||
return g_pEntityList->LookupEntity( *this );
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// CHandle.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
template< class T >
|
||||
class CHandle : public CBaseHandle
|
||||
{
|
||||
public:
|
||||
|
||||
CHandle();
|
||||
CHandle( int iEntry, int iSerialNumber );
|
||||
CHandle( const CBaseHandle &handle );
|
||||
CHandle( T *pVal );
|
||||
|
||||
// The index should have come from a call to ToInt(). If it hasn't, you're in trouble.
|
||||
static CHandle<T> FromIndex( int index );
|
||||
|
||||
T* Get() const;
|
||||
void Set( const T* pVal );
|
||||
|
||||
operator T*();
|
||||
operator T*() const;
|
||||
|
||||
bool operator !() const;
|
||||
bool operator==( T *val ) const;
|
||||
bool operator!=( T *val ) const;
|
||||
const CBaseHandle& operator=( const T *val );
|
||||
|
||||
T* operator->() const;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// Inlines.
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle( int iEntry, int iSerialNumber )
|
||||
{
|
||||
Init( iEntry, iSerialNumber );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle( const CBaseHandle &handle )
|
||||
: CBaseHandle( handle )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
CHandle<T>::CHandle( T *pObj )
|
||||
{
|
||||
Term();
|
||||
Set( pObj );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline CHandle<T> CHandle<T>::FromIndex( int index )
|
||||
{
|
||||
CHandle<T> ret;
|
||||
ret.m_Index = index;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T* CHandle<T>::Get() const
|
||||
{
|
||||
return (T*)CBaseHandle::Get();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline CHandle<T>::operator T *()
|
||||
{
|
||||
return Get( );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline CHandle<T>::operator T *() const
|
||||
{
|
||||
return Get( );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool CHandle<T>::operator !() const
|
||||
{
|
||||
return !Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool CHandle<T>::operator==( T *val ) const
|
||||
{
|
||||
return Get() == val;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool CHandle<T>::operator!=( T *val ) const
|
||||
{
|
||||
return Get() != val;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void CHandle<T>::Set( const T* pVal )
|
||||
{
|
||||
CBaseHandle::Set( reinterpret_cast<const IHandleEntity*>(pVal) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const CBaseHandle& CHandle<T>::operator=( const T *val )
|
||||
{
|
||||
Set( val );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* CHandle<T>::operator -> () const
|
||||
{
|
||||
return Get();
|
||||
}
|
||||
|
||||
|
||||
#endif // EHANDLE_H
|
||||
|
||||
@@ -1,126 +1,126 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYDATAINSTANTIATOR_H
|
||||
#define ENTITYDATAINSTANTIATOR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "utlhash.h"
|
||||
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// This is the hash key type, but it could just as easily be and int or void *
|
||||
class CBaseEntity;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IEntityDataInstantiator
|
||||
{
|
||||
public:
|
||||
virtual ~IEntityDataInstantiator() {};
|
||||
|
||||
virtual void *GetDataObject( const CBaseEntity *instance ) = 0;
|
||||
virtual void *CreateDataObject( const CBaseEntity *instance ) = 0;
|
||||
virtual void DestroyDataObject( const CBaseEntity *instance ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T>
|
||||
class CEntityDataInstantiator : public IEntityDataInstantiator
|
||||
{
|
||||
public:
|
||||
CEntityDataInstantiator() :
|
||||
m_HashTable( 64, 0, 0, CompareFunc, KeyFunc )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void *GetDataObject( const CBaseEntity *instance )
|
||||
{
|
||||
UtlHashHandle_t handle;
|
||||
HashEntry entry;
|
||||
entry.key = instance;
|
||||
handle = m_HashTable.Find( entry );
|
||||
|
||||
if ( handle != m_HashTable.InvalidHandle() )
|
||||
{
|
||||
return (void *)m_HashTable[ handle ].data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual void *CreateDataObject( const CBaseEntity *instance )
|
||||
{
|
||||
UtlHashHandle_t handle;
|
||||
HashEntry entry;
|
||||
entry.key = instance;
|
||||
handle = m_HashTable.Find( entry );
|
||||
|
||||
// Create it if not already present
|
||||
if ( handle == m_HashTable.InvalidHandle() )
|
||||
{
|
||||
handle = m_HashTable.Insert( entry );
|
||||
Assert( handle != m_HashTable.InvalidHandle() );
|
||||
m_HashTable[ handle ].data = new T;
|
||||
|
||||
// FIXME: We'll have to remove this if any objects we instance have vtables!!!
|
||||
Q_memset( m_HashTable[ handle ].data, 0, sizeof( T ) );
|
||||
}
|
||||
|
||||
return (void *)m_HashTable[ handle ].data;
|
||||
}
|
||||
|
||||
virtual void DestroyDataObject( const CBaseEntity *instance )
|
||||
{
|
||||
UtlHashHandle_t handle;
|
||||
HashEntry entry;
|
||||
entry.key = instance;
|
||||
handle = m_HashTable.Find( entry );
|
||||
|
||||
if ( handle != m_HashTable.InvalidHandle() )
|
||||
{
|
||||
delete m_HashTable[ handle ].data;
|
||||
m_HashTable.Remove( handle );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct HashEntry
|
||||
{
|
||||
HashEntry()
|
||||
{
|
||||
key = NULL;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
const CBaseEntity *key;
|
||||
T *data;
|
||||
};
|
||||
|
||||
static bool CompareFunc( const HashEntry &src1, const HashEntry &src2 )
|
||||
{
|
||||
return ( src1.key == src2.key );
|
||||
}
|
||||
|
||||
|
||||
static unsigned int KeyFunc( const HashEntry &src )
|
||||
{
|
||||
// Shift right to get rid of alignment bits and border the struct on a 16 byte boundary
|
||||
return (unsigned int)src.key;
|
||||
}
|
||||
|
||||
CUtlHash< HashEntry > m_HashTable;
|
||||
};
|
||||
|
||||
#include "tier0/memdbgoff.h"
|
||||
|
||||
#endif // ENTITYDATAINSTANTIATOR_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYDATAINSTANTIATOR_H
|
||||
#define ENTITYDATAINSTANTIATOR_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "utlhash.h"
|
||||
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// This is the hash key type, but it could just as easily be and int or void *
|
||||
class CBaseEntity;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IEntityDataInstantiator
|
||||
{
|
||||
public:
|
||||
virtual ~IEntityDataInstantiator() {};
|
||||
|
||||
virtual void *GetDataObject( const CBaseEntity *instance ) = 0;
|
||||
virtual void *CreateDataObject( const CBaseEntity *instance ) = 0;
|
||||
virtual void DestroyDataObject( const CBaseEntity *instance ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T>
|
||||
class CEntityDataInstantiator : public IEntityDataInstantiator
|
||||
{
|
||||
public:
|
||||
CEntityDataInstantiator() :
|
||||
m_HashTable( 64, 0, 0, CompareFunc, KeyFunc )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void *GetDataObject( const CBaseEntity *instance )
|
||||
{
|
||||
UtlHashHandle_t handle;
|
||||
HashEntry entry;
|
||||
entry.key = instance;
|
||||
handle = m_HashTable.Find( entry );
|
||||
|
||||
if ( handle != m_HashTable.InvalidHandle() )
|
||||
{
|
||||
return (void *)m_HashTable[ handle ].data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual void *CreateDataObject( const CBaseEntity *instance )
|
||||
{
|
||||
UtlHashHandle_t handle;
|
||||
HashEntry entry;
|
||||
entry.key = instance;
|
||||
handle = m_HashTable.Find( entry );
|
||||
|
||||
// Create it if not already present
|
||||
if ( handle == m_HashTable.InvalidHandle() )
|
||||
{
|
||||
handle = m_HashTable.Insert( entry );
|
||||
Assert( handle != m_HashTable.InvalidHandle() );
|
||||
m_HashTable[ handle ].data = new T;
|
||||
|
||||
// FIXME: We'll have to remove this if any objects we instance have vtables!!!
|
||||
Q_memset( m_HashTable[ handle ].data, 0, sizeof( T ) );
|
||||
}
|
||||
|
||||
return (void *)m_HashTable[ handle ].data;
|
||||
}
|
||||
|
||||
virtual void DestroyDataObject( const CBaseEntity *instance )
|
||||
{
|
||||
UtlHashHandle_t handle;
|
||||
HashEntry entry;
|
||||
entry.key = instance;
|
||||
handle = m_HashTable.Find( entry );
|
||||
|
||||
if ( handle != m_HashTable.InvalidHandle() )
|
||||
{
|
||||
delete m_HashTable[ handle ].data;
|
||||
m_HashTable.Remove( handle );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct HashEntry
|
||||
{
|
||||
HashEntry()
|
||||
{
|
||||
key = NULL;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
const CBaseEntity *key;
|
||||
T *data;
|
||||
};
|
||||
|
||||
static bool CompareFunc( const HashEntry &src1, const HashEntry &src2 )
|
||||
{
|
||||
return ( src1.key == src2.key );
|
||||
}
|
||||
|
||||
|
||||
static unsigned int KeyFunc( const HashEntry &src )
|
||||
{
|
||||
// Shift right to get rid of alignment bits and border the struct on a 16 byte boundary
|
||||
return (unsigned int)src.key;
|
||||
}
|
||||
|
||||
CUtlHash< HashEntry > m_HashTable;
|
||||
};
|
||||
|
||||
#include "tier0/memdbgoff.h"
|
||||
|
||||
#endif // ENTITYDATAINSTANTIATOR_H
|
||||
|
||||
@@ -1,273 +1,273 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "entitylist_base.h"
|
||||
#include "ihandleentity.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
enum
|
||||
{
|
||||
SERIAL_MASK = 0x7fff // the max value of a serial number, rolls back to 0 when it hits this limit
|
||||
};
|
||||
|
||||
void CEntInfo::ClearLinks()
|
||||
{
|
||||
m_pPrev = m_pNext = this;
|
||||
}
|
||||
|
||||
CBaseEntityList::CEntInfoList::CEntInfoList()
|
||||
{
|
||||
m_pHead = NULL;
|
||||
m_pTail = NULL;
|
||||
}
|
||||
|
||||
// NOTE: Cut from UtlFixedLinkedList<>, UNDONE: Find a way to share this code
|
||||
void CBaseEntityList::CEntInfoList::LinkBefore( CEntInfo *pBefore, CEntInfo *pElement )
|
||||
{
|
||||
Assert( pElement );
|
||||
|
||||
// Unlink it if it's in the list at the moment
|
||||
Unlink(pElement);
|
||||
|
||||
// The element *after* our newly linked one is the one we linked before.
|
||||
pElement->m_pNext = pBefore;
|
||||
|
||||
if (pBefore == NULL)
|
||||
{
|
||||
// In this case, we're linking to the end of the list, so reset the tail
|
||||
pElement->m_pPrev = m_pTail;
|
||||
m_pTail = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here, we're not linking to the end. Set the prev pointer to point to
|
||||
// the element we're linking.
|
||||
Assert( IsInList(pBefore) );
|
||||
pElement->m_pPrev = pBefore->m_pPrev;
|
||||
pBefore->m_pPrev = pElement;
|
||||
}
|
||||
|
||||
// Reset the head if we linked to the head of the list
|
||||
if (pElement->m_pPrev == NULL)
|
||||
{
|
||||
m_pHead = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
pElement->m_pPrev->m_pNext = pElement;
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseEntityList::CEntInfoList::LinkAfter( CEntInfo *pAfter, CEntInfo *pElement )
|
||||
{
|
||||
Assert( pElement );
|
||||
|
||||
// Unlink it if it's in the list at the moment
|
||||
if ( IsInList(pElement) )
|
||||
Unlink(pElement);
|
||||
|
||||
// The element *before* our newly linked one is the one we linked after
|
||||
pElement->m_pPrev = pAfter;
|
||||
if (pAfter == NULL)
|
||||
{
|
||||
// In this case, we're linking to the head of the list, reset the head
|
||||
pElement->m_pNext = m_pHead;
|
||||
m_pHead = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here, we're not linking to the end. Set the next pointer to point to
|
||||
// the element we're linking.
|
||||
Assert( IsInList(pAfter) );
|
||||
pElement->m_pNext = pAfter->m_pNext;
|
||||
pAfter->m_pNext = pElement;
|
||||
}
|
||||
|
||||
// Reset the tail if we linked to the tail of the list
|
||||
if (pElement->m_pNext == NULL )
|
||||
{
|
||||
m_pTail = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
pElement->m_pNext->m_pPrev = pElement;
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseEntityList::CEntInfoList::Unlink( CEntInfo *pElement )
|
||||
{
|
||||
if (IsInList(pElement))
|
||||
{
|
||||
// If we're the first guy, reset the head
|
||||
// otherwise, make our previous node's next pointer = our next
|
||||
if ( pElement->m_pPrev )
|
||||
{
|
||||
pElement->m_pPrev->m_pNext = pElement->m_pNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pHead = pElement->m_pNext;
|
||||
}
|
||||
|
||||
// If we're the last guy, reset the tail
|
||||
// otherwise, make our next node's prev pointer = our prev
|
||||
if ( pElement->m_pNext )
|
||||
{
|
||||
pElement->m_pNext->m_pPrev = pElement->m_pPrev;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTail = pElement->m_pPrev;
|
||||
}
|
||||
|
||||
// This marks this node as not in the list,
|
||||
// but not in the free list either
|
||||
pElement->ClearLinks();
|
||||
}
|
||||
}
|
||||
|
||||
bool CBaseEntityList::CEntInfoList::IsInList( CEntInfo *pElement )
|
||||
{
|
||||
return pElement->m_pPrev != pElement;
|
||||
}
|
||||
|
||||
CBaseEntityList::CBaseEntityList()
|
||||
{
|
||||
// These are not in any list (yet)
|
||||
int i;
|
||||
for ( i = 0; i < NUM_ENT_ENTRIES; i++ )
|
||||
{
|
||||
m_EntPtrArray[i].ClearLinks();
|
||||
m_EntPtrArray[i].m_SerialNumber = (rand()& SERIAL_MASK); // generate random starting serial number
|
||||
m_EntPtrArray[i].m_pEntity = NULL;
|
||||
}
|
||||
|
||||
// make a free list of the non-networkable entities
|
||||
// Initially, all the slots are free.
|
||||
for ( i=MAX_EDICTS+1; i < NUM_ENT_ENTRIES; i++ )
|
||||
{
|
||||
CEntInfo *pList = &m_EntPtrArray[i];
|
||||
m_freeNonNetworkableList.AddToTail( pList );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBaseEntityList::~CBaseEntityList()
|
||||
{
|
||||
CEntInfo *pList = m_activeList.Head();
|
||||
|
||||
while ( pList )
|
||||
{
|
||||
CEntInfo *pNext = pList->m_pNext;
|
||||
RemoveEntityAtSlot( GetEntInfoIndex( pList ) );
|
||||
pList = pNext;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBaseHandle CBaseEntityList::AddNetworkableEntity( IHandleEntity *pEnt, int index, int iForcedSerialNum )
|
||||
{
|
||||
Assert( index >= 0 && index < MAX_EDICTS );
|
||||
return AddEntityAtSlot( pEnt, index, iForcedSerialNum );
|
||||
}
|
||||
|
||||
|
||||
CBaseHandle CBaseEntityList::AddNonNetworkableEntity( IHandleEntity *pEnt )
|
||||
{
|
||||
// Find a slot for it.
|
||||
CEntInfo *pSlot = m_freeNonNetworkableList.Head();
|
||||
if ( !pSlot )
|
||||
{
|
||||
Warning( "CBaseEntityList::AddNonNetworkableEntity: no free slots!\n" );
|
||||
AssertMsg( 0, ( "CBaseEntityList::AddNonNetworkableEntity: no free slots!\n" ) );
|
||||
return CBaseHandle();
|
||||
}
|
||||
|
||||
// Move from the free list into the allocated list.
|
||||
m_freeNonNetworkableList.Unlink( pSlot );
|
||||
int iSlot = GetEntInfoIndex( pSlot );
|
||||
|
||||
return AddEntityAtSlot( pEnt, iSlot, -1 );
|
||||
}
|
||||
|
||||
|
||||
void CBaseEntityList::RemoveEntity( CBaseHandle handle )
|
||||
{
|
||||
RemoveEntityAtSlot( handle.GetEntryIndex() );
|
||||
}
|
||||
|
||||
|
||||
CBaseHandle CBaseEntityList::AddEntityAtSlot( IHandleEntity *pEnt, int iSlot, int iForcedSerialNum )
|
||||
{
|
||||
// Init the CSerialEntity.
|
||||
CEntInfo *pSlot = &m_EntPtrArray[iSlot];
|
||||
Assert( pSlot->m_pEntity == NULL );
|
||||
pSlot->m_pEntity = pEnt;
|
||||
|
||||
// Force the serial number (client-only)?
|
||||
if ( iForcedSerialNum != -1 )
|
||||
{
|
||||
pSlot->m_SerialNumber = iForcedSerialNum;
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
// Only the client should force the serial numbers.
|
||||
Assert( false );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Update our list of active entities.
|
||||
m_activeList.AddToTail( pSlot );
|
||||
CBaseHandle retVal( iSlot, pSlot->m_SerialNumber );
|
||||
|
||||
// Tell the entity to store its handle.
|
||||
pEnt->SetRefEHandle( retVal );
|
||||
|
||||
// Notify any derived class.
|
||||
OnAddEntity( pEnt, retVal );
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
void CBaseEntityList::RemoveEntityAtSlot( int iSlot )
|
||||
{
|
||||
Assert( iSlot >= 0 && iSlot < NUM_ENT_ENTRIES );
|
||||
|
||||
CEntInfo *pInfo = &m_EntPtrArray[iSlot];
|
||||
|
||||
if ( pInfo->m_pEntity )
|
||||
{
|
||||
pInfo->m_pEntity->SetRefEHandle( INVALID_EHANDLE_INDEX );
|
||||
|
||||
// Notify the derived class that we're about to remove this entity.
|
||||
OnRemoveEntity( pInfo->m_pEntity, CBaseHandle( iSlot, pInfo->m_SerialNumber ) );
|
||||
|
||||
// Increment the serial # so ehandles go invalid.
|
||||
pInfo->m_pEntity = NULL;
|
||||
pInfo->m_SerialNumber = ( pInfo->m_SerialNumber+1)& SERIAL_MASK;
|
||||
|
||||
m_activeList.Unlink( pInfo );
|
||||
|
||||
// Add the slot back to the free list if it's a non-networkable entity.
|
||||
if ( iSlot >= MAX_EDICTS )
|
||||
{
|
||||
m_freeNonNetworkableList.AddToTail( pInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBaseEntityList::OnAddEntity( IHandleEntity *pEnt, CBaseHandle handle )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBaseEntityList::OnRemoveEntity( IHandleEntity *pEnt, CBaseHandle handle )
|
||||
{
|
||||
}
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "entitylist_base.h"
|
||||
#include "ihandleentity.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
enum
|
||||
{
|
||||
SERIAL_MASK = 0x7fff // the max value of a serial number, rolls back to 0 when it hits this limit
|
||||
};
|
||||
|
||||
void CEntInfo::ClearLinks()
|
||||
{
|
||||
m_pPrev = m_pNext = this;
|
||||
}
|
||||
|
||||
CBaseEntityList::CEntInfoList::CEntInfoList()
|
||||
{
|
||||
m_pHead = NULL;
|
||||
m_pTail = NULL;
|
||||
}
|
||||
|
||||
// NOTE: Cut from UtlFixedLinkedList<>, UNDONE: Find a way to share this code
|
||||
void CBaseEntityList::CEntInfoList::LinkBefore( CEntInfo *pBefore, CEntInfo *pElement )
|
||||
{
|
||||
Assert( pElement );
|
||||
|
||||
// Unlink it if it's in the list at the moment
|
||||
Unlink(pElement);
|
||||
|
||||
// The element *after* our newly linked one is the one we linked before.
|
||||
pElement->m_pNext = pBefore;
|
||||
|
||||
if (pBefore == NULL)
|
||||
{
|
||||
// In this case, we're linking to the end of the list, so reset the tail
|
||||
pElement->m_pPrev = m_pTail;
|
||||
m_pTail = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here, we're not linking to the end. Set the prev pointer to point to
|
||||
// the element we're linking.
|
||||
Assert( IsInList(pBefore) );
|
||||
pElement->m_pPrev = pBefore->m_pPrev;
|
||||
pBefore->m_pPrev = pElement;
|
||||
}
|
||||
|
||||
// Reset the head if we linked to the head of the list
|
||||
if (pElement->m_pPrev == NULL)
|
||||
{
|
||||
m_pHead = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
pElement->m_pPrev->m_pNext = pElement;
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseEntityList::CEntInfoList::LinkAfter( CEntInfo *pAfter, CEntInfo *pElement )
|
||||
{
|
||||
Assert( pElement );
|
||||
|
||||
// Unlink it if it's in the list at the moment
|
||||
if ( IsInList(pElement) )
|
||||
Unlink(pElement);
|
||||
|
||||
// The element *before* our newly linked one is the one we linked after
|
||||
pElement->m_pPrev = pAfter;
|
||||
if (pAfter == NULL)
|
||||
{
|
||||
// In this case, we're linking to the head of the list, reset the head
|
||||
pElement->m_pNext = m_pHead;
|
||||
m_pHead = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here, we're not linking to the end. Set the next pointer to point to
|
||||
// the element we're linking.
|
||||
Assert( IsInList(pAfter) );
|
||||
pElement->m_pNext = pAfter->m_pNext;
|
||||
pAfter->m_pNext = pElement;
|
||||
}
|
||||
|
||||
// Reset the tail if we linked to the tail of the list
|
||||
if (pElement->m_pNext == NULL )
|
||||
{
|
||||
m_pTail = pElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
pElement->m_pNext->m_pPrev = pElement;
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseEntityList::CEntInfoList::Unlink( CEntInfo *pElement )
|
||||
{
|
||||
if (IsInList(pElement))
|
||||
{
|
||||
// If we're the first guy, reset the head
|
||||
// otherwise, make our previous node's next pointer = our next
|
||||
if ( pElement->m_pPrev )
|
||||
{
|
||||
pElement->m_pPrev->m_pNext = pElement->m_pNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pHead = pElement->m_pNext;
|
||||
}
|
||||
|
||||
// If we're the last guy, reset the tail
|
||||
// otherwise, make our next node's prev pointer = our prev
|
||||
if ( pElement->m_pNext )
|
||||
{
|
||||
pElement->m_pNext->m_pPrev = pElement->m_pPrev;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTail = pElement->m_pPrev;
|
||||
}
|
||||
|
||||
// This marks this node as not in the list,
|
||||
// but not in the free list either
|
||||
pElement->ClearLinks();
|
||||
}
|
||||
}
|
||||
|
||||
bool CBaseEntityList::CEntInfoList::IsInList( CEntInfo *pElement )
|
||||
{
|
||||
return pElement->m_pPrev != pElement;
|
||||
}
|
||||
|
||||
CBaseEntityList::CBaseEntityList()
|
||||
{
|
||||
// These are not in any list (yet)
|
||||
int i;
|
||||
for ( i = 0; i < NUM_ENT_ENTRIES; i++ )
|
||||
{
|
||||
m_EntPtrArray[i].ClearLinks();
|
||||
m_EntPtrArray[i].m_SerialNumber = (rand()& SERIAL_MASK); // generate random starting serial number
|
||||
m_EntPtrArray[i].m_pEntity = NULL;
|
||||
}
|
||||
|
||||
// make a free list of the non-networkable entities
|
||||
// Initially, all the slots are free.
|
||||
for ( i=MAX_EDICTS+1; i < NUM_ENT_ENTRIES; i++ )
|
||||
{
|
||||
CEntInfo *pList = &m_EntPtrArray[i];
|
||||
m_freeNonNetworkableList.AddToTail( pList );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBaseEntityList::~CBaseEntityList()
|
||||
{
|
||||
CEntInfo *pList = m_activeList.Head();
|
||||
|
||||
while ( pList )
|
||||
{
|
||||
CEntInfo *pNext = pList->m_pNext;
|
||||
RemoveEntityAtSlot( GetEntInfoIndex( pList ) );
|
||||
pList = pNext;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBaseHandle CBaseEntityList::AddNetworkableEntity( IHandleEntity *pEnt, int index, int iForcedSerialNum )
|
||||
{
|
||||
Assert( index >= 0 && index < MAX_EDICTS );
|
||||
return AddEntityAtSlot( pEnt, index, iForcedSerialNum );
|
||||
}
|
||||
|
||||
|
||||
CBaseHandle CBaseEntityList::AddNonNetworkableEntity( IHandleEntity *pEnt )
|
||||
{
|
||||
// Find a slot for it.
|
||||
CEntInfo *pSlot = m_freeNonNetworkableList.Head();
|
||||
if ( !pSlot )
|
||||
{
|
||||
Warning( "CBaseEntityList::AddNonNetworkableEntity: no free slots!\n" );
|
||||
AssertMsg( 0, ( "CBaseEntityList::AddNonNetworkableEntity: no free slots!\n" ) );
|
||||
return CBaseHandle();
|
||||
}
|
||||
|
||||
// Move from the free list into the allocated list.
|
||||
m_freeNonNetworkableList.Unlink( pSlot );
|
||||
int iSlot = GetEntInfoIndex( pSlot );
|
||||
|
||||
return AddEntityAtSlot( pEnt, iSlot, -1 );
|
||||
}
|
||||
|
||||
|
||||
void CBaseEntityList::RemoveEntity( CBaseHandle handle )
|
||||
{
|
||||
RemoveEntityAtSlot( handle.GetEntryIndex() );
|
||||
}
|
||||
|
||||
|
||||
CBaseHandle CBaseEntityList::AddEntityAtSlot( IHandleEntity *pEnt, int iSlot, int iForcedSerialNum )
|
||||
{
|
||||
// Init the CSerialEntity.
|
||||
CEntInfo *pSlot = &m_EntPtrArray[iSlot];
|
||||
Assert( pSlot->m_pEntity == NULL );
|
||||
pSlot->m_pEntity = pEnt;
|
||||
|
||||
// Force the serial number (client-only)?
|
||||
if ( iForcedSerialNum != -1 )
|
||||
{
|
||||
pSlot->m_SerialNumber = iForcedSerialNum;
|
||||
|
||||
#if !defined( CLIENT_DLL )
|
||||
// Only the client should force the serial numbers.
|
||||
Assert( false );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Update our list of active entities.
|
||||
m_activeList.AddToTail( pSlot );
|
||||
CBaseHandle retVal( iSlot, pSlot->m_SerialNumber );
|
||||
|
||||
// Tell the entity to store its handle.
|
||||
pEnt->SetRefEHandle( retVal );
|
||||
|
||||
// Notify any derived class.
|
||||
OnAddEntity( pEnt, retVal );
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
void CBaseEntityList::RemoveEntityAtSlot( int iSlot )
|
||||
{
|
||||
Assert( iSlot >= 0 && iSlot < NUM_ENT_ENTRIES );
|
||||
|
||||
CEntInfo *pInfo = &m_EntPtrArray[iSlot];
|
||||
|
||||
if ( pInfo->m_pEntity )
|
||||
{
|
||||
pInfo->m_pEntity->SetRefEHandle( INVALID_EHANDLE_INDEX );
|
||||
|
||||
// Notify the derived class that we're about to remove this entity.
|
||||
OnRemoveEntity( pInfo->m_pEntity, CBaseHandle( iSlot, pInfo->m_SerialNumber ) );
|
||||
|
||||
// Increment the serial # so ehandles go invalid.
|
||||
pInfo->m_pEntity = NULL;
|
||||
pInfo->m_SerialNumber = ( pInfo->m_SerialNumber+1)& SERIAL_MASK;
|
||||
|
||||
m_activeList.Unlink( pInfo );
|
||||
|
||||
// Add the slot back to the free list if it's a non-networkable entity.
|
||||
if ( iSlot >= MAX_EDICTS )
|
||||
{
|
||||
m_freeNonNetworkableList.AddToTail( pInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBaseEntityList::OnAddEntity( IHandleEntity *pEnt, CBaseHandle handle )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBaseEntityList::OnRemoveEntity( IHandleEntity *pEnt, CBaseHandle handle )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,209 +1,209 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYLIST_BASE_H
|
||||
#define ENTITYLIST_BASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "basehandle.h"
|
||||
#include "utllinkedlist.h"
|
||||
#include "ihandleentity.h"
|
||||
|
||||
|
||||
class CEntInfo
|
||||
{
|
||||
public:
|
||||
IHandleEntity *m_pEntity;
|
||||
int m_SerialNumber;
|
||||
CEntInfo *m_pPrev;
|
||||
CEntInfo *m_pNext;
|
||||
|
||||
void ClearLinks();
|
||||
};
|
||||
|
||||
|
||||
class CBaseEntityList
|
||||
{
|
||||
public:
|
||||
CBaseEntityList();
|
||||
~CBaseEntityList();
|
||||
|
||||
// Add and remove entities. iForcedSerialNum should only be used on the client. The server
|
||||
// gets to dictate what the networkable serial numbers are on the client so it can send
|
||||
// ehandles over and they work.
|
||||
CBaseHandle AddNetworkableEntity( IHandleEntity *pEnt, int index, int iForcedSerialNum = -1 );
|
||||
CBaseHandle AddNonNetworkableEntity( IHandleEntity *pEnt );
|
||||
void RemoveEntity( CBaseHandle handle );
|
||||
|
||||
// Get an ehandle from a networkable entity's index (note: if there is no entity in that slot,
|
||||
// then the ehandle will be invalid and produce NULL).
|
||||
CBaseHandle GetNetworkableHandle( int iEntity ) const;
|
||||
|
||||
// ehandles use this in their Get() function to produce a pointer to the entity.
|
||||
IHandleEntity* LookupEntity( const CBaseHandle &handle ) const;
|
||||
IHandleEntity* LookupEntityByNetworkIndex( int edictIndex ) const;
|
||||
|
||||
// Use these to iterate over all the entities.
|
||||
CBaseHandle FirstHandle() const;
|
||||
CBaseHandle NextHandle( CBaseHandle hEnt ) const;
|
||||
static CBaseHandle InvalidHandle();
|
||||
|
||||
const CEntInfo *FirstEntInfo() const;
|
||||
const CEntInfo *NextEntInfo( const CEntInfo *pInfo ) const;
|
||||
const CEntInfo *GetEntInfoPtr( const CBaseHandle &hEnt ) const;
|
||||
const CEntInfo *GetEntInfoPtrByIndex( int index ) const;
|
||||
|
||||
// Overridables.
|
||||
protected:
|
||||
|
||||
// These are notifications to the derived class. It can cache info here if it wants.
|
||||
virtual void OnAddEntity( IHandleEntity *pEnt, CBaseHandle handle );
|
||||
|
||||
// It is safe to delete the entity here. We won't be accessing the pointer after
|
||||
// calling OnRemoveEntity.
|
||||
virtual void OnRemoveEntity( IHandleEntity *pEnt, CBaseHandle handle );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CBaseHandle AddEntityAtSlot( IHandleEntity *pEnt, int iSlot, int iForcedSerialNum );
|
||||
void RemoveEntityAtSlot( int iSlot );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
class CEntInfoList
|
||||
{
|
||||
public:
|
||||
CEntInfoList();
|
||||
|
||||
const CEntInfo *Head() const { return m_pHead; }
|
||||
const CEntInfo *Tail() const { return m_pTail; }
|
||||
CEntInfo *Head() { return m_pHead; }
|
||||
CEntInfo *Tail() { return m_pTail; }
|
||||
void AddToHead( CEntInfo *pElement ) { LinkAfter( NULL, pElement ); }
|
||||
void AddToTail( CEntInfo *pElement ) { LinkBefore( NULL, pElement ); }
|
||||
|
||||
void LinkBefore( CEntInfo *pBefore, CEntInfo *pElement );
|
||||
void LinkAfter( CEntInfo *pBefore, CEntInfo *pElement );
|
||||
void Unlink( CEntInfo *pElement );
|
||||
bool IsInList( CEntInfo *pElement );
|
||||
|
||||
private:
|
||||
CEntInfo *m_pHead;
|
||||
CEntInfo *m_pTail;
|
||||
};
|
||||
|
||||
int GetEntInfoIndex( const CEntInfo *pEntInfo ) const;
|
||||
|
||||
|
||||
// The first MAX_EDICTS entities are networkable. The rest are client-only or server-only.
|
||||
CEntInfo m_EntPtrArray[NUM_ENT_ENTRIES];
|
||||
CEntInfoList m_activeList;
|
||||
CEntInfoList m_freeNonNetworkableList;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------ //
|
||||
// Inlines.
|
||||
// ------------------------------------------------------------------------------------ //
|
||||
|
||||
inline int CBaseEntityList::GetEntInfoIndex( const CEntInfo *pEntInfo ) const
|
||||
{
|
||||
Assert( pEntInfo );
|
||||
int index = (int)(pEntInfo - m_EntPtrArray);
|
||||
Assert( index >= 0 && index < NUM_ENT_ENTRIES );
|
||||
return index;
|
||||
}
|
||||
|
||||
inline CBaseHandle CBaseEntityList::GetNetworkableHandle( int iEntity ) const
|
||||
{
|
||||
Assert( iEntity >= 0 && iEntity < MAX_EDICTS );
|
||||
if ( m_EntPtrArray[iEntity].m_pEntity )
|
||||
return CBaseHandle( iEntity, m_EntPtrArray[iEntity].m_SerialNumber );
|
||||
else
|
||||
return CBaseHandle();
|
||||
}
|
||||
|
||||
|
||||
inline IHandleEntity* CBaseEntityList::LookupEntity( const CBaseHandle &handle ) const
|
||||
{
|
||||
if ( handle.m_Index == INVALID_EHANDLE_INDEX )
|
||||
return NULL;
|
||||
|
||||
const CEntInfo *pInfo = &m_EntPtrArray[ handle.GetEntryIndex() ];
|
||||
if ( pInfo->m_SerialNumber == handle.GetSerialNumber() )
|
||||
return (IHandleEntity*)pInfo->m_pEntity;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
inline IHandleEntity* CBaseEntityList::LookupEntityByNetworkIndex( int edictIndex ) const
|
||||
{
|
||||
// (Legacy support).
|
||||
if ( edictIndex < 0 )
|
||||
return NULL;
|
||||
|
||||
Assert( edictIndex < NUM_ENT_ENTRIES );
|
||||
return (IHandleEntity*)m_EntPtrArray[edictIndex].m_pEntity;
|
||||
}
|
||||
|
||||
|
||||
inline CBaseHandle CBaseEntityList::FirstHandle() const
|
||||
{
|
||||
if ( !m_activeList.Head() )
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
|
||||
int index = GetEntInfoIndex( m_activeList.Head() );
|
||||
return CBaseHandle( index, m_EntPtrArray[index].m_SerialNumber );
|
||||
}
|
||||
|
||||
inline CBaseHandle CBaseEntityList::NextHandle( CBaseHandle hEnt ) const
|
||||
{
|
||||
int iSlot = hEnt.GetEntryIndex();
|
||||
CEntInfo *pNext = m_EntPtrArray[iSlot].m_pNext;
|
||||
if ( !pNext )
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
|
||||
int index = GetEntInfoIndex( pNext );
|
||||
|
||||
return CBaseHandle( index, m_EntPtrArray[index].m_SerialNumber );
|
||||
}
|
||||
|
||||
inline CBaseHandle CBaseEntityList::InvalidHandle()
|
||||
{
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::FirstEntInfo() const
|
||||
{
|
||||
return m_activeList.Head();
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::NextEntInfo( const CEntInfo *pInfo ) const
|
||||
{
|
||||
return pInfo->m_pNext;
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::GetEntInfoPtr( const CBaseHandle &hEnt ) const
|
||||
{
|
||||
int iSlot = hEnt.GetEntryIndex();
|
||||
return &m_EntPtrArray[iSlot];
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::GetEntInfoPtrByIndex( int index ) const
|
||||
{
|
||||
return &m_EntPtrArray[index];
|
||||
}
|
||||
|
||||
extern CBaseEntityList *g_pEntityList;
|
||||
|
||||
#endif // ENTITYLIST_BASE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYLIST_BASE_H
|
||||
#define ENTITYLIST_BASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "basehandle.h"
|
||||
#include "utllinkedlist.h"
|
||||
#include "ihandleentity.h"
|
||||
|
||||
|
||||
class CEntInfo
|
||||
{
|
||||
public:
|
||||
IHandleEntity *m_pEntity;
|
||||
int m_SerialNumber;
|
||||
CEntInfo *m_pPrev;
|
||||
CEntInfo *m_pNext;
|
||||
|
||||
void ClearLinks();
|
||||
};
|
||||
|
||||
|
||||
class CBaseEntityList
|
||||
{
|
||||
public:
|
||||
CBaseEntityList();
|
||||
~CBaseEntityList();
|
||||
|
||||
// Add and remove entities. iForcedSerialNum should only be used on the client. The server
|
||||
// gets to dictate what the networkable serial numbers are on the client so it can send
|
||||
// ehandles over and they work.
|
||||
CBaseHandle AddNetworkableEntity( IHandleEntity *pEnt, int index, int iForcedSerialNum = -1 );
|
||||
CBaseHandle AddNonNetworkableEntity( IHandleEntity *pEnt );
|
||||
void RemoveEntity( CBaseHandle handle );
|
||||
|
||||
// Get an ehandle from a networkable entity's index (note: if there is no entity in that slot,
|
||||
// then the ehandle will be invalid and produce NULL).
|
||||
CBaseHandle GetNetworkableHandle( int iEntity ) const;
|
||||
|
||||
// ehandles use this in their Get() function to produce a pointer to the entity.
|
||||
IHandleEntity* LookupEntity( const CBaseHandle &handle ) const;
|
||||
IHandleEntity* LookupEntityByNetworkIndex( int edictIndex ) const;
|
||||
|
||||
// Use these to iterate over all the entities.
|
||||
CBaseHandle FirstHandle() const;
|
||||
CBaseHandle NextHandle( CBaseHandle hEnt ) const;
|
||||
static CBaseHandle InvalidHandle();
|
||||
|
||||
const CEntInfo *FirstEntInfo() const;
|
||||
const CEntInfo *NextEntInfo( const CEntInfo *pInfo ) const;
|
||||
const CEntInfo *GetEntInfoPtr( const CBaseHandle &hEnt ) const;
|
||||
const CEntInfo *GetEntInfoPtrByIndex( int index ) const;
|
||||
|
||||
// Overridables.
|
||||
protected:
|
||||
|
||||
// These are notifications to the derived class. It can cache info here if it wants.
|
||||
virtual void OnAddEntity( IHandleEntity *pEnt, CBaseHandle handle );
|
||||
|
||||
// It is safe to delete the entity here. We won't be accessing the pointer after
|
||||
// calling OnRemoveEntity.
|
||||
virtual void OnRemoveEntity( IHandleEntity *pEnt, CBaseHandle handle );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CBaseHandle AddEntityAtSlot( IHandleEntity *pEnt, int iSlot, int iForcedSerialNum );
|
||||
void RemoveEntityAtSlot( int iSlot );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
class CEntInfoList
|
||||
{
|
||||
public:
|
||||
CEntInfoList();
|
||||
|
||||
const CEntInfo *Head() const { return m_pHead; }
|
||||
const CEntInfo *Tail() const { return m_pTail; }
|
||||
CEntInfo *Head() { return m_pHead; }
|
||||
CEntInfo *Tail() { return m_pTail; }
|
||||
void AddToHead( CEntInfo *pElement ) { LinkAfter( NULL, pElement ); }
|
||||
void AddToTail( CEntInfo *pElement ) { LinkBefore( NULL, pElement ); }
|
||||
|
||||
void LinkBefore( CEntInfo *pBefore, CEntInfo *pElement );
|
||||
void LinkAfter( CEntInfo *pBefore, CEntInfo *pElement );
|
||||
void Unlink( CEntInfo *pElement );
|
||||
bool IsInList( CEntInfo *pElement );
|
||||
|
||||
private:
|
||||
CEntInfo *m_pHead;
|
||||
CEntInfo *m_pTail;
|
||||
};
|
||||
|
||||
int GetEntInfoIndex( const CEntInfo *pEntInfo ) const;
|
||||
|
||||
|
||||
// The first MAX_EDICTS entities are networkable. The rest are client-only or server-only.
|
||||
CEntInfo m_EntPtrArray[NUM_ENT_ENTRIES];
|
||||
CEntInfoList m_activeList;
|
||||
CEntInfoList m_freeNonNetworkableList;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------ //
|
||||
// Inlines.
|
||||
// ------------------------------------------------------------------------------------ //
|
||||
|
||||
inline int CBaseEntityList::GetEntInfoIndex( const CEntInfo *pEntInfo ) const
|
||||
{
|
||||
Assert( pEntInfo );
|
||||
int index = (int)(pEntInfo - m_EntPtrArray);
|
||||
Assert( index >= 0 && index < NUM_ENT_ENTRIES );
|
||||
return index;
|
||||
}
|
||||
|
||||
inline CBaseHandle CBaseEntityList::GetNetworkableHandle( int iEntity ) const
|
||||
{
|
||||
Assert( iEntity >= 0 && iEntity < MAX_EDICTS );
|
||||
if ( m_EntPtrArray[iEntity].m_pEntity )
|
||||
return CBaseHandle( iEntity, m_EntPtrArray[iEntity].m_SerialNumber );
|
||||
else
|
||||
return CBaseHandle();
|
||||
}
|
||||
|
||||
|
||||
inline IHandleEntity* CBaseEntityList::LookupEntity( const CBaseHandle &handle ) const
|
||||
{
|
||||
if ( handle.m_Index == INVALID_EHANDLE_INDEX )
|
||||
return NULL;
|
||||
|
||||
const CEntInfo *pInfo = &m_EntPtrArray[ handle.GetEntryIndex() ];
|
||||
if ( pInfo->m_SerialNumber == handle.GetSerialNumber() )
|
||||
return (IHandleEntity*)pInfo->m_pEntity;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
inline IHandleEntity* CBaseEntityList::LookupEntityByNetworkIndex( int edictIndex ) const
|
||||
{
|
||||
// (Legacy support).
|
||||
if ( edictIndex < 0 )
|
||||
return NULL;
|
||||
|
||||
Assert( edictIndex < NUM_ENT_ENTRIES );
|
||||
return (IHandleEntity*)m_EntPtrArray[edictIndex].m_pEntity;
|
||||
}
|
||||
|
||||
|
||||
inline CBaseHandle CBaseEntityList::FirstHandle() const
|
||||
{
|
||||
if ( !m_activeList.Head() )
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
|
||||
int index = GetEntInfoIndex( m_activeList.Head() );
|
||||
return CBaseHandle( index, m_EntPtrArray[index].m_SerialNumber );
|
||||
}
|
||||
|
||||
inline CBaseHandle CBaseEntityList::NextHandle( CBaseHandle hEnt ) const
|
||||
{
|
||||
int iSlot = hEnt.GetEntryIndex();
|
||||
CEntInfo *pNext = m_EntPtrArray[iSlot].m_pNext;
|
||||
if ( !pNext )
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
|
||||
int index = GetEntInfoIndex( pNext );
|
||||
|
||||
return CBaseHandle( index, m_EntPtrArray[index].m_SerialNumber );
|
||||
}
|
||||
|
||||
inline CBaseHandle CBaseEntityList::InvalidHandle()
|
||||
{
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::FirstEntInfo() const
|
||||
{
|
||||
return m_activeList.Head();
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::NextEntInfo( const CEntInfo *pInfo ) const
|
||||
{
|
||||
return pInfo->m_pNext;
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::GetEntInfoPtr( const CBaseHandle &hEnt ) const
|
||||
{
|
||||
int iSlot = hEnt.GetEntryIndex();
|
||||
return &m_EntPtrArray[iSlot];
|
||||
}
|
||||
|
||||
inline const CEntInfo *CBaseEntityList::GetEntInfoPtrByIndex( int index ) const
|
||||
{
|
||||
return &m_EntPtrArray[index];
|
||||
}
|
||||
|
||||
extern CBaseEntityList *g_pEntityList;
|
||||
|
||||
#endif // ENTITYLIST_BASE_H
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYPARTICLETRAIL_SHARED_H
|
||||
#define ENTITYPARTICLETRAIL_SHARED_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// For networking this bad boy
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef CLIENT_DLL
|
||||
EXTERN_RECV_TABLE( DT_EntityParticleTrailInfo );
|
||||
#else
|
||||
EXTERN_SEND_TABLE( DT_EntityParticleTrailInfo );
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Particle trail info
|
||||
//-----------------------------------------------------------------------------
|
||||
struct EntityParticleTrailInfo_t
|
||||
{
|
||||
EntityParticleTrailInfo_t();
|
||||
|
||||
DECLARE_CLASS_NOBASE( EntityParticleTrailInfo_t );
|
||||
DECLARE_SIMPLE_DATADESC();
|
||||
DECLARE_EMBEDDED_NETWORKVAR();
|
||||
|
||||
string_t m_strMaterialName;
|
||||
CNetworkVar( float, m_flLifetime );
|
||||
CNetworkVar( float, m_flStartSize );
|
||||
CNetworkVar( float, m_flEndSize );
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // ENTITYPARTICLETRAIL_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYPARTICLETRAIL_SHARED_H
|
||||
#define ENTITYPARTICLETRAIL_SHARED_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// For networking this bad boy
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef CLIENT_DLL
|
||||
EXTERN_RECV_TABLE( DT_EntityParticleTrailInfo );
|
||||
#else
|
||||
EXTERN_SEND_TABLE( DT_EntityParticleTrailInfo );
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Particle trail info
|
||||
//-----------------------------------------------------------------------------
|
||||
struct EntityParticleTrailInfo_t
|
||||
{
|
||||
EntityParticleTrailInfo_t();
|
||||
|
||||
DECLARE_CLASS_NOBASE( EntityParticleTrailInfo_t );
|
||||
DECLARE_SIMPLE_DATADESC();
|
||||
DECLARE_EMBEDDED_NETWORKVAR();
|
||||
|
||||
string_t m_strMaterialName;
|
||||
CNetworkVar( float, m_flLifetime );
|
||||
CNetworkVar( float, m_flStartSize );
|
||||
CNetworkVar( float, m_flEndSize );
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // ENTITYPARTICLETRAIL_SHARED_H
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "env_detail_controller.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
LINK_ENTITY_TO_CLASS(env_detail_controller, CEnvDetailController);
|
||||
|
||||
IMPLEMENT_NETWORKCLASS_ALIASED( EnvDetailController, DT_DetailController )
|
||||
|
||||
BEGIN_NETWORK_TABLE_NOBASE( CEnvDetailController, DT_DetailController )
|
||||
#ifdef CLIENT_DLL
|
||||
RecvPropFloat( RECVINFO( m_flFadeStartDist ) ),
|
||||
RecvPropFloat( RECVINFO( m_flFadeEndDist ) ),
|
||||
#else
|
||||
SendPropFloat( SENDINFO( m_flFadeStartDist ) ),
|
||||
SendPropFloat( SENDINFO( m_flFadeEndDist ) ),
|
||||
#endif
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
static CEnvDetailController *s_detailController = NULL;
|
||||
CEnvDetailController * GetDetailController()
|
||||
{
|
||||
return s_detailController;
|
||||
}
|
||||
|
||||
CEnvDetailController::CEnvDetailController()
|
||||
{
|
||||
s_detailController = this;
|
||||
}
|
||||
|
||||
CEnvDetailController::~CEnvDetailController()
|
||||
{
|
||||
if ( s_detailController == this )
|
||||
{
|
||||
s_detailController = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
int CEnvDetailController::UpdateTransmitState()
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
// ALWAYS transmit to all clients.
|
||||
return SetTransmitState( FL_EDICT_ALWAYS );
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
bool CEnvDetailController::KeyValue( const char *szKeyName, const char *szValue )
|
||||
{
|
||||
if (FStrEq(szKeyName, "fademindist"))
|
||||
{
|
||||
m_flFadeStartDist = atof(szValue);
|
||||
}
|
||||
else if (FStrEq(szKeyName, "fademaxdist"))
|
||||
{
|
||||
m_flFadeEndDist = atof(szValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // !CLIENT_DLL
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "env_detail_controller.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
LINK_ENTITY_TO_CLASS(env_detail_controller, CEnvDetailController);
|
||||
|
||||
IMPLEMENT_NETWORKCLASS_ALIASED( EnvDetailController, DT_DetailController )
|
||||
|
||||
BEGIN_NETWORK_TABLE_NOBASE( CEnvDetailController, DT_DetailController )
|
||||
#ifdef CLIENT_DLL
|
||||
RecvPropFloat( RECVINFO( m_flFadeStartDist ) ),
|
||||
RecvPropFloat( RECVINFO( m_flFadeEndDist ) ),
|
||||
#else
|
||||
SendPropFloat( SENDINFO( m_flFadeStartDist ) ),
|
||||
SendPropFloat( SENDINFO( m_flFadeEndDist ) ),
|
||||
#endif
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
static CEnvDetailController *s_detailController = NULL;
|
||||
CEnvDetailController * GetDetailController()
|
||||
{
|
||||
return s_detailController;
|
||||
}
|
||||
|
||||
CEnvDetailController::CEnvDetailController()
|
||||
{
|
||||
s_detailController = this;
|
||||
}
|
||||
|
||||
CEnvDetailController::~CEnvDetailController()
|
||||
{
|
||||
if ( s_detailController == this )
|
||||
{
|
||||
s_detailController = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
int CEnvDetailController::UpdateTransmitState()
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
// ALWAYS transmit to all clients.
|
||||
return SetTransmitState( FL_EDICT_ALWAYS );
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
bool CEnvDetailController::KeyValue( const char *szKeyName, const char *szValue )
|
||||
{
|
||||
if (FStrEq(szKeyName, "fademindist"))
|
||||
{
|
||||
m_flFadeStartDist = atof(szValue);
|
||||
}
|
||||
else if (FStrEq(szKeyName, "fademaxdist"))
|
||||
{
|
||||
m_flFadeEndDist = atof(szValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#define CEnvDetailController C_EnvDetailController
|
||||
#endif // CLIENT_DLL
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implementation of the class that controls detail prop fade distances
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEnvDetailController : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CEnvDetailController, CBaseEntity );
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
CEnvDetailController();
|
||||
virtual ~CEnvDetailController();
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
virtual bool KeyValue( const char *szKeyName, const char *szValue );
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
CNetworkVar( float, m_flFadeStartDist );
|
||||
CNetworkVar( float, m_flFadeEndDist );
|
||||
|
||||
// ALWAYS transmit to all clients.
|
||||
virtual int UpdateTransmitState( void );
|
||||
};
|
||||
|
||||
CEnvDetailController * GetDetailController();
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#define CEnvDetailController C_EnvDetailController
|
||||
#endif // CLIENT_DLL
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implementation of the class that controls detail prop fade distances
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEnvDetailController : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CEnvDetailController, CBaseEntity );
|
||||
DECLARE_NETWORKCLASS();
|
||||
|
||||
CEnvDetailController();
|
||||
virtual ~CEnvDetailController();
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
virtual bool KeyValue( const char *szKeyName, const char *szValue );
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
CNetworkVar( float, m_flFadeStartDist );
|
||||
CNetworkVar( float, m_flFadeEndDist );
|
||||
|
||||
// ALWAYS transmit to all clients.
|
||||
virtual int UpdateTransmitState( void );
|
||||
};
|
||||
|
||||
CEnvDetailController * GetDetailController();
|
||||
|
||||
@@ -1,399 +1,399 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "env_meteor_shared.h"
|
||||
#include "mapdata_shared.h"
|
||||
#include "sharedInterface.h"
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Meteor Functions.
|
||||
//
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
CEnvMeteorShared::CEnvMeteorShared()
|
||||
{
|
||||
m_nID = 0;
|
||||
m_vecStartPosition.Init();
|
||||
m_vecDirection.Init();
|
||||
m_flSpeed = 0.0f;
|
||||
m_flDamageRadius = 0.0f;
|
||||
m_flStartTime = METEOR_INVALID_TIME;
|
||||
m_flPassiveTime = METEOR_INVALID_TIME;
|
||||
m_flWorldEnterTime = METEOR_INVALID_TIME;
|
||||
m_flWorldExitTime = METEOR_INVALID_TIME;
|
||||
m_nLocation = METEOR_LOCATION_INVALID;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::Init( int nID, float flStartTime, float flPassiveTime,
|
||||
const Vector &vecStartPosition,
|
||||
const Vector &vecDirection, float flSpeed, float flDamageRadius,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs )
|
||||
{
|
||||
// Setup initial parametric state.
|
||||
m_nID = nID;
|
||||
VectorCopy( vecStartPosition, m_vecStartPosition );
|
||||
VectorCopy( vecStartPosition, m_vecPos );
|
||||
VectorCopy( vecDirection, m_vecDirection );
|
||||
m_flSpeed = flSpeed;
|
||||
m_flDamageRadius = flDamageRadius;
|
||||
m_flStartTime = flPassiveTime + flStartTime;
|
||||
m_flPassiveTime = flPassiveTime;
|
||||
m_flPosTime = m_flStartTime;
|
||||
|
||||
// Calculate the enter/exit times.
|
||||
CalcEnterAndExitTimes( vecTriggerMins, vecTriggerMaxs );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::GetPositionAtTime( float flTime, Vector &vecPosition )
|
||||
{
|
||||
float flDeltaTime = flTime - m_flPosTime;
|
||||
Vector vecVelocity( m_vecDirection.x * m_flSpeed, m_vecDirection.y * m_flSpeed, m_vecDirection.z * m_flSpeed );
|
||||
VectorMA( m_vecPos, flDeltaTime, vecVelocity, vecPosition );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::ConvertFromSkyboxToWorld( void )
|
||||
{
|
||||
// The new start position is the position at which the meteor enters
|
||||
// the skybox.
|
||||
Vector vecSkyboxOrigin;
|
||||
g_pMapData->Get3DSkyboxOrigin( vecSkyboxOrigin );
|
||||
float flSkyboxScale = g_pMapData->Get3DSkyboxScale();
|
||||
|
||||
m_vecPos += ( m_flSpeed * m_vecDirection ) * ( m_flWorldEnterTime - m_flStartTime );
|
||||
m_vecPos -= vecSkyboxOrigin;
|
||||
m_vecPos *= flSkyboxScale;
|
||||
|
||||
// Scale the speed.
|
||||
m_flSpeed *= flSkyboxScale;
|
||||
|
||||
// Reset the start time.
|
||||
m_flPosTime = m_flWorldEnterTime;
|
||||
|
||||
// Set the location to world.
|
||||
m_nLocation = METEOR_LOCATION_WORLD;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::ConvertFromWorldToSkybox( void )
|
||||
{
|
||||
// Scale the speed.
|
||||
float flSkyboxScale = g_pMapData->Get3DSkyboxScale();
|
||||
m_flSpeed /= flSkyboxScale;
|
||||
|
||||
float flDeltaTime = m_flWorldExitTime - m_flStartTime;
|
||||
Vector vecVelocity( m_vecDirection.x * m_flSpeed, m_vecDirection.y * m_flSpeed, m_vecDirection.z * m_flSpeed );
|
||||
VectorMA( m_vecStartPosition, flDeltaTime, vecVelocity, m_vecPos );
|
||||
|
||||
// Reset the start time.
|
||||
m_flPosTime = m_flWorldExitTime;
|
||||
|
||||
// Set the location to skybox.
|
||||
m_nLocation = METEOR_LOCATION_SKYBOX;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CEnvMeteorShared::IsInSkybox( float flTime )
|
||||
{
|
||||
// Check to see if we are always in the skybox!
|
||||
if ( m_flWorldEnterTime == METEOR_INVALID_TIME )
|
||||
return true;
|
||||
|
||||
return ( ( flTime < m_flWorldEnterTime ) || ( flTime > m_flWorldExitTime ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CEnvMeteorShared::IsPassive( float flTime )
|
||||
{
|
||||
return ( flTime < m_flPassiveTime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CEnvMeteorShared::WillTransition( void )
|
||||
{
|
||||
return ( m_flWorldEnterTime == METEOR_INVALID_TIME );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
float CEnvMeteorShared::GetDamageRadius( void )
|
||||
{
|
||||
return m_flDamageRadius;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::CalcEnterAndExitTimes( const Vector &vecTriggerMins,
|
||||
const Vector &vecTriggerMaxs )
|
||||
{
|
||||
#define METEOR_TRIGGER_EPSILON 0.001f
|
||||
|
||||
// Initialize the enter/exit fractions.
|
||||
float flEnterFrac = 0.0f;
|
||||
float flExitFrac = 1.0f;
|
||||
|
||||
// Create an arbitrarily large end position.
|
||||
Vector vecEndPosition;
|
||||
VectorMA( m_vecStartPosition, 32000.0f, m_vecDirection, vecEndPosition );
|
||||
|
||||
float flFrac, flDistStart, flDistEnd;
|
||||
for( int iAxis = 0; iAxis < 3; iAxis++ )
|
||||
{
|
||||
// Negative Axis
|
||||
flDistStart = -m_vecStartPosition[iAxis] + vecTriggerMins[iAxis];
|
||||
flDistEnd = -vecEndPosition[iAxis] + vecTriggerMins[iAxis];
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd < 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart - METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if ( flFrac > flEnterFrac ) { flEnterFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart < 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart + METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if( flFrac < flExitFrac ) { flExitFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
return;
|
||||
|
||||
// Positive Axis
|
||||
flDistStart = m_vecStartPosition[iAxis] - vecTriggerMaxs[iAxis];
|
||||
flDistEnd = vecEndPosition[iAxis] - vecTriggerMaxs[iAxis];
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd < 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart - METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if ( flFrac > flEnterFrac ) { flEnterFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart < 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart + METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if( flFrac < flExitFrac ) { flExitFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for intersection.
|
||||
if ( flExitFrac >= flEnterFrac )
|
||||
{
|
||||
// Check to see if we start in the world or the skybox!
|
||||
if ( flEnterFrac == 0.0f )
|
||||
{
|
||||
m_nLocation = METEOR_LOCATION_WORLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nLocation = METEOR_LOCATION_SKYBOX;
|
||||
}
|
||||
|
||||
// Calculate the enter/exit times.
|
||||
Vector vecEnterPoint, vecExitPoint, vecDeltaPosition;
|
||||
VectorSubtract( vecEndPosition, m_vecStartPosition, vecDeltaPosition );
|
||||
VectorScale( vecDeltaPosition, flEnterFrac, vecEnterPoint );
|
||||
VectorScale( vecDeltaPosition, flExitFrac, vecExitPoint );
|
||||
|
||||
m_flWorldEnterTime = vecEnterPoint.Length() / m_flSpeed;
|
||||
m_flWorldExitTime = vecExitPoint.Length() / m_flSpeed;
|
||||
m_flWorldEnterTime += m_flStartTime;
|
||||
m_flWorldExitTime += m_flStartTime;
|
||||
}
|
||||
|
||||
#undef METEOR_TRIGGER_EPSILON
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Meteor Spawner Functions.
|
||||
//
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
CEnvMeteorSpawnerShared::CEnvMeteorSpawnerShared()
|
||||
{
|
||||
m_pFactory = NULL;
|
||||
m_nMeteorCount = 0;
|
||||
|
||||
m_flStartTime = 0.0f;
|
||||
m_nRandomSeed = 0;
|
||||
|
||||
m_iMeteorType = -1;
|
||||
m_flMeteorDamageRadius = 0.0f;
|
||||
m_bSkybox = true;
|
||||
|
||||
m_flMinSpawnTime = 0.0f;
|
||||
m_flMaxSpawnTime = 0.0f;
|
||||
m_nMinSpawnCount = 0;
|
||||
m_nMaxSpawnCount = 0;
|
||||
m_vecMinBounds.Init();
|
||||
m_vecMaxBounds.Init();
|
||||
m_flMinSpeed = 0.0f;
|
||||
m_flMaxSpeed = 0.0f;
|
||||
|
||||
m_flNextSpawnTime = 0.0f;
|
||||
|
||||
m_vecTriggerMins.Init();
|
||||
m_vecTriggerMaxs.Init();
|
||||
m_vecTriggerCenter.Init();
|
||||
|
||||
// Debug!
|
||||
m_nRandomCallCount = 0;
|
||||
|
||||
m_aTargets.Purge();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorSpawnerShared::Init( IMeteorFactory *pFactory, int nRandomSeed, float flTime,
|
||||
const Vector &vecMinBounds, const Vector &vecMaxBounds,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs )
|
||||
{
|
||||
// Factory.
|
||||
m_pFactory = pFactory;
|
||||
|
||||
// Setup the random number stream.
|
||||
m_nRandomSeed = nRandomSeed;
|
||||
m_NumberStream.SetSeed( nRandomSeed );
|
||||
|
||||
// Start time.
|
||||
m_flStartTime = flTime;
|
||||
|
||||
// Copy the spawner bounds.
|
||||
m_vecMinBounds = vecMinBounds;
|
||||
m_vecMaxBounds = vecMaxBounds;
|
||||
|
||||
// Copy the trigger bounds.
|
||||
m_vecTriggerMins = vecTriggerMins;
|
||||
m_vecTriggerMaxs = vecTriggerMaxs;
|
||||
|
||||
// Get the center of the trigger bounds.
|
||||
m_vecTriggerCenter = ( m_vecTriggerMins + m_vecTriggerMaxs ) * 0.5f;
|
||||
|
||||
// Setup spawn time.
|
||||
m_flNextSpawnTime = m_flStartTime + m_flMaxSpawnTime;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
int CEnvMeteorSpawnerShared::GetRandomInt( int nMin, int nMax )
|
||||
{
|
||||
m_nRandomCallCount++;
|
||||
return m_NumberStream.RandomInt( nMin, nMax );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
float CEnvMeteorSpawnerShared::GetRandomFloat( float flMin, float flMax )
|
||||
{
|
||||
m_nRandomCallCount++;
|
||||
return m_NumberStream.RandomFloat( flMin, flMax );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
float CEnvMeteorSpawnerShared::MeteorThink( float flTime )
|
||||
{
|
||||
// Check for spawn.
|
||||
if ( flTime < m_flNextSpawnTime )
|
||||
return m_flNextSpawnTime;
|
||||
|
||||
while ( m_flNextSpawnTime < flTime )
|
||||
{
|
||||
// Get a random number of meteors to spawn and spawn them.
|
||||
int nMeteorCount = GetRandomInt( m_nMinSpawnCount, m_nMaxSpawnCount );
|
||||
for ( int iMeteor = 0; iMeteor < nMeteorCount; iMeteor++ )
|
||||
{
|
||||
// Increment the number of meteors created (starting with 1).
|
||||
m_nMeteorCount++;
|
||||
|
||||
// Get a random meteor position.
|
||||
Vector meteorOrigin( GetRandomFloat( m_vecMinBounds.GetX(), m_vecMaxBounds.GetX() ) /* x */,
|
||||
GetRandomFloat( m_vecMinBounds.GetY(), m_vecMaxBounds.GetY() ) /* y */,
|
||||
GetRandomFloat( m_vecMinBounds.GetZ(), m_vecMaxBounds.GetZ() ) /* z */ );
|
||||
|
||||
// Calculate the direction of the meteor based on "targets."
|
||||
Vector vecDirection( 0.0f, 0.0f, -1.0f );
|
||||
if ( m_aTargets.Count() > 0 )
|
||||
{
|
||||
float flFreq = 1.0f / m_aTargets.Count();
|
||||
float flFreqAccum = flFreq;
|
||||
|
||||
int iTarget;
|
||||
for( iTarget = 0; iTarget < m_aTargets.Count(); ++iTarget )
|
||||
{
|
||||
float flRandom = GetRandomFloat( 0.0f, 1.0f );
|
||||
if ( flRandom < flFreqAccum )
|
||||
break;
|
||||
|
||||
flFreqAccum += flFreq;
|
||||
}
|
||||
|
||||
// Should ever be here!
|
||||
if ( iTarget == m_aTargets.Count() )
|
||||
{
|
||||
iTarget--;
|
||||
}
|
||||
|
||||
// Just set it to the first target for now!!!
|
||||
// NOTE: Will randomly generate from list of targets when more than 1 in
|
||||
// the future.
|
||||
|
||||
// Move the meteor into the "world."
|
||||
Vector vecPositionInWorld;
|
||||
Vector vecSkyboxOrigin;
|
||||
g_pMapData->Get3DSkyboxOrigin( vecSkyboxOrigin );
|
||||
vecPositionInWorld = ( meteorOrigin - vecSkyboxOrigin );
|
||||
vecPositionInWorld *= g_pMapData->Get3DSkyboxScale();
|
||||
|
||||
Vector vecTargetPos = m_aTargets[iTarget].m_vecPosition;
|
||||
vecTargetPos.x += GetRandomFloat( -m_aTargets[iTarget].m_flRadius, m_aTargets[iTarget].m_flRadius );
|
||||
vecTargetPos.y += GetRandomFloat( -m_aTargets[iTarget].m_flRadius, m_aTargets[iTarget].m_flRadius );
|
||||
vecTargetPos.z += GetRandomFloat( -m_aTargets[iTarget].m_flRadius, m_aTargets[iTarget].m_flRadius );
|
||||
|
||||
vecDirection = vecTargetPos - vecPositionInWorld;
|
||||
VectorNormalize( vecDirection );
|
||||
}
|
||||
|
||||
// Pass in the randomized position, randomized speed, and start time.
|
||||
m_pFactory->CreateMeteor( m_nMeteorCount, m_iMeteorType, meteorOrigin,
|
||||
vecDirection /* direction */,
|
||||
GetRandomFloat( m_flMinSpeed, m_flMaxSpeed ) /* speed */,
|
||||
m_flNextSpawnTime, m_flMeteorDamageRadius,
|
||||
m_vecTriggerMins, m_vecTriggerMaxs );
|
||||
}
|
||||
|
||||
// Set next spawn time.
|
||||
m_flNextSpawnTime += GetRandomFloat( m_flMinSpawnTime, m_flMaxSpawnTime );
|
||||
}
|
||||
|
||||
// Return the next spawn time.
|
||||
return ( m_flNextSpawnTime - gpGlobals->curtime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorSpawnerShared::AddToTargetList( const Vector &vecPosition, float flRadius )
|
||||
{
|
||||
int iTarget = m_aTargets.AddToTail();
|
||||
m_aTargets[iTarget].m_vecPosition = vecPosition;
|
||||
m_aTargets[iTarget].m_flRadius = flRadius;
|
||||
}
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "env_meteor_shared.h"
|
||||
#include "mapdata_shared.h"
|
||||
#include "sharedInterface.h"
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Meteor Functions.
|
||||
//
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
CEnvMeteorShared::CEnvMeteorShared()
|
||||
{
|
||||
m_nID = 0;
|
||||
m_vecStartPosition.Init();
|
||||
m_vecDirection.Init();
|
||||
m_flSpeed = 0.0f;
|
||||
m_flDamageRadius = 0.0f;
|
||||
m_flStartTime = METEOR_INVALID_TIME;
|
||||
m_flPassiveTime = METEOR_INVALID_TIME;
|
||||
m_flWorldEnterTime = METEOR_INVALID_TIME;
|
||||
m_flWorldExitTime = METEOR_INVALID_TIME;
|
||||
m_nLocation = METEOR_LOCATION_INVALID;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::Init( int nID, float flStartTime, float flPassiveTime,
|
||||
const Vector &vecStartPosition,
|
||||
const Vector &vecDirection, float flSpeed, float flDamageRadius,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs )
|
||||
{
|
||||
// Setup initial parametric state.
|
||||
m_nID = nID;
|
||||
VectorCopy( vecStartPosition, m_vecStartPosition );
|
||||
VectorCopy( vecStartPosition, m_vecPos );
|
||||
VectorCopy( vecDirection, m_vecDirection );
|
||||
m_flSpeed = flSpeed;
|
||||
m_flDamageRadius = flDamageRadius;
|
||||
m_flStartTime = flPassiveTime + flStartTime;
|
||||
m_flPassiveTime = flPassiveTime;
|
||||
m_flPosTime = m_flStartTime;
|
||||
|
||||
// Calculate the enter/exit times.
|
||||
CalcEnterAndExitTimes( vecTriggerMins, vecTriggerMaxs );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::GetPositionAtTime( float flTime, Vector &vecPosition )
|
||||
{
|
||||
float flDeltaTime = flTime - m_flPosTime;
|
||||
Vector vecVelocity( m_vecDirection.x * m_flSpeed, m_vecDirection.y * m_flSpeed, m_vecDirection.z * m_flSpeed );
|
||||
VectorMA( m_vecPos, flDeltaTime, vecVelocity, vecPosition );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::ConvertFromSkyboxToWorld( void )
|
||||
{
|
||||
// The new start position is the position at which the meteor enters
|
||||
// the skybox.
|
||||
Vector vecSkyboxOrigin;
|
||||
g_pMapData->Get3DSkyboxOrigin( vecSkyboxOrigin );
|
||||
float flSkyboxScale = g_pMapData->Get3DSkyboxScale();
|
||||
|
||||
m_vecPos += ( m_flSpeed * m_vecDirection ) * ( m_flWorldEnterTime - m_flStartTime );
|
||||
m_vecPos -= vecSkyboxOrigin;
|
||||
m_vecPos *= flSkyboxScale;
|
||||
|
||||
// Scale the speed.
|
||||
m_flSpeed *= flSkyboxScale;
|
||||
|
||||
// Reset the start time.
|
||||
m_flPosTime = m_flWorldEnterTime;
|
||||
|
||||
// Set the location to world.
|
||||
m_nLocation = METEOR_LOCATION_WORLD;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::ConvertFromWorldToSkybox( void )
|
||||
{
|
||||
// Scale the speed.
|
||||
float flSkyboxScale = g_pMapData->Get3DSkyboxScale();
|
||||
m_flSpeed /= flSkyboxScale;
|
||||
|
||||
float flDeltaTime = m_flWorldExitTime - m_flStartTime;
|
||||
Vector vecVelocity( m_vecDirection.x * m_flSpeed, m_vecDirection.y * m_flSpeed, m_vecDirection.z * m_flSpeed );
|
||||
VectorMA( m_vecStartPosition, flDeltaTime, vecVelocity, m_vecPos );
|
||||
|
||||
// Reset the start time.
|
||||
m_flPosTime = m_flWorldExitTime;
|
||||
|
||||
// Set the location to skybox.
|
||||
m_nLocation = METEOR_LOCATION_SKYBOX;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CEnvMeteorShared::IsInSkybox( float flTime )
|
||||
{
|
||||
// Check to see if we are always in the skybox!
|
||||
if ( m_flWorldEnterTime == METEOR_INVALID_TIME )
|
||||
return true;
|
||||
|
||||
return ( ( flTime < m_flWorldEnterTime ) || ( flTime > m_flWorldExitTime ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CEnvMeteorShared::IsPassive( float flTime )
|
||||
{
|
||||
return ( flTime < m_flPassiveTime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CEnvMeteorShared::WillTransition( void )
|
||||
{
|
||||
return ( m_flWorldEnterTime == METEOR_INVALID_TIME );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
float CEnvMeteorShared::GetDamageRadius( void )
|
||||
{
|
||||
return m_flDamageRadius;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorShared::CalcEnterAndExitTimes( const Vector &vecTriggerMins,
|
||||
const Vector &vecTriggerMaxs )
|
||||
{
|
||||
#define METEOR_TRIGGER_EPSILON 0.001f
|
||||
|
||||
// Initialize the enter/exit fractions.
|
||||
float flEnterFrac = 0.0f;
|
||||
float flExitFrac = 1.0f;
|
||||
|
||||
// Create an arbitrarily large end position.
|
||||
Vector vecEndPosition;
|
||||
VectorMA( m_vecStartPosition, 32000.0f, m_vecDirection, vecEndPosition );
|
||||
|
||||
float flFrac, flDistStart, flDistEnd;
|
||||
for( int iAxis = 0; iAxis < 3; iAxis++ )
|
||||
{
|
||||
// Negative Axis
|
||||
flDistStart = -m_vecStartPosition[iAxis] + vecTriggerMins[iAxis];
|
||||
flDistEnd = -vecEndPosition[iAxis] + vecTriggerMins[iAxis];
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd < 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart - METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if ( flFrac > flEnterFrac ) { flEnterFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart < 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart + METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if( flFrac < flExitFrac ) { flExitFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
return;
|
||||
|
||||
// Positive Axis
|
||||
flDistStart = m_vecStartPosition[iAxis] - vecTriggerMaxs[iAxis];
|
||||
flDistEnd = vecEndPosition[iAxis] - vecTriggerMaxs[iAxis];
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd < 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart - METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if ( flFrac > flEnterFrac ) { flEnterFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart < 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
{
|
||||
flFrac = ( flDistStart + METEOR_TRIGGER_EPSILON ) / ( flDistStart - flDistEnd );
|
||||
if( flFrac < flExitFrac ) { flExitFrac = flFrac; }
|
||||
}
|
||||
|
||||
if ( ( flDistStart > 0.0f ) && ( flDistEnd > 0.0f ) )
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for intersection.
|
||||
if ( flExitFrac >= flEnterFrac )
|
||||
{
|
||||
// Check to see if we start in the world or the skybox!
|
||||
if ( flEnterFrac == 0.0f )
|
||||
{
|
||||
m_nLocation = METEOR_LOCATION_WORLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nLocation = METEOR_LOCATION_SKYBOX;
|
||||
}
|
||||
|
||||
// Calculate the enter/exit times.
|
||||
Vector vecEnterPoint, vecExitPoint, vecDeltaPosition;
|
||||
VectorSubtract( vecEndPosition, m_vecStartPosition, vecDeltaPosition );
|
||||
VectorScale( vecDeltaPosition, flEnterFrac, vecEnterPoint );
|
||||
VectorScale( vecDeltaPosition, flExitFrac, vecExitPoint );
|
||||
|
||||
m_flWorldEnterTime = vecEnterPoint.Length() / m_flSpeed;
|
||||
m_flWorldExitTime = vecExitPoint.Length() / m_flSpeed;
|
||||
m_flWorldEnterTime += m_flStartTime;
|
||||
m_flWorldExitTime += m_flStartTime;
|
||||
}
|
||||
|
||||
#undef METEOR_TRIGGER_EPSILON
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Meteor Spawner Functions.
|
||||
//
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
CEnvMeteorSpawnerShared::CEnvMeteorSpawnerShared()
|
||||
{
|
||||
m_pFactory = NULL;
|
||||
m_nMeteorCount = 0;
|
||||
|
||||
m_flStartTime = 0.0f;
|
||||
m_nRandomSeed = 0;
|
||||
|
||||
m_iMeteorType = -1;
|
||||
m_flMeteorDamageRadius = 0.0f;
|
||||
m_bSkybox = true;
|
||||
|
||||
m_flMinSpawnTime = 0.0f;
|
||||
m_flMaxSpawnTime = 0.0f;
|
||||
m_nMinSpawnCount = 0;
|
||||
m_nMaxSpawnCount = 0;
|
||||
m_vecMinBounds.Init();
|
||||
m_vecMaxBounds.Init();
|
||||
m_flMinSpeed = 0.0f;
|
||||
m_flMaxSpeed = 0.0f;
|
||||
|
||||
m_flNextSpawnTime = 0.0f;
|
||||
|
||||
m_vecTriggerMins.Init();
|
||||
m_vecTriggerMaxs.Init();
|
||||
m_vecTriggerCenter.Init();
|
||||
|
||||
// Debug!
|
||||
m_nRandomCallCount = 0;
|
||||
|
||||
m_aTargets.Purge();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorSpawnerShared::Init( IMeteorFactory *pFactory, int nRandomSeed, float flTime,
|
||||
const Vector &vecMinBounds, const Vector &vecMaxBounds,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs )
|
||||
{
|
||||
// Factory.
|
||||
m_pFactory = pFactory;
|
||||
|
||||
// Setup the random number stream.
|
||||
m_nRandomSeed = nRandomSeed;
|
||||
m_NumberStream.SetSeed( nRandomSeed );
|
||||
|
||||
// Start time.
|
||||
m_flStartTime = flTime;
|
||||
|
||||
// Copy the spawner bounds.
|
||||
m_vecMinBounds = vecMinBounds;
|
||||
m_vecMaxBounds = vecMaxBounds;
|
||||
|
||||
// Copy the trigger bounds.
|
||||
m_vecTriggerMins = vecTriggerMins;
|
||||
m_vecTriggerMaxs = vecTriggerMaxs;
|
||||
|
||||
// Get the center of the trigger bounds.
|
||||
m_vecTriggerCenter = ( m_vecTriggerMins + m_vecTriggerMaxs ) * 0.5f;
|
||||
|
||||
// Setup spawn time.
|
||||
m_flNextSpawnTime = m_flStartTime + m_flMaxSpawnTime;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
int CEnvMeteorSpawnerShared::GetRandomInt( int nMin, int nMax )
|
||||
{
|
||||
m_nRandomCallCount++;
|
||||
return m_NumberStream.RandomInt( nMin, nMax );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
float CEnvMeteorSpawnerShared::GetRandomFloat( float flMin, float flMax )
|
||||
{
|
||||
m_nRandomCallCount++;
|
||||
return m_NumberStream.RandomFloat( flMin, flMax );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
float CEnvMeteorSpawnerShared::MeteorThink( float flTime )
|
||||
{
|
||||
// Check for spawn.
|
||||
if ( flTime < m_flNextSpawnTime )
|
||||
return m_flNextSpawnTime;
|
||||
|
||||
while ( m_flNextSpawnTime < flTime )
|
||||
{
|
||||
// Get a random number of meteors to spawn and spawn them.
|
||||
int nMeteorCount = GetRandomInt( m_nMinSpawnCount, m_nMaxSpawnCount );
|
||||
for ( int iMeteor = 0; iMeteor < nMeteorCount; iMeteor++ )
|
||||
{
|
||||
// Increment the number of meteors created (starting with 1).
|
||||
m_nMeteorCount++;
|
||||
|
||||
// Get a random meteor position.
|
||||
Vector meteorOrigin( GetRandomFloat( m_vecMinBounds.GetX(), m_vecMaxBounds.GetX() ) /* x */,
|
||||
GetRandomFloat( m_vecMinBounds.GetY(), m_vecMaxBounds.GetY() ) /* y */,
|
||||
GetRandomFloat( m_vecMinBounds.GetZ(), m_vecMaxBounds.GetZ() ) /* z */ );
|
||||
|
||||
// Calculate the direction of the meteor based on "targets."
|
||||
Vector vecDirection( 0.0f, 0.0f, -1.0f );
|
||||
if ( m_aTargets.Count() > 0 )
|
||||
{
|
||||
float flFreq = 1.0f / m_aTargets.Count();
|
||||
float flFreqAccum = flFreq;
|
||||
|
||||
int iTarget;
|
||||
for( iTarget = 0; iTarget < m_aTargets.Count(); ++iTarget )
|
||||
{
|
||||
float flRandom = GetRandomFloat( 0.0f, 1.0f );
|
||||
if ( flRandom < flFreqAccum )
|
||||
break;
|
||||
|
||||
flFreqAccum += flFreq;
|
||||
}
|
||||
|
||||
// Should ever be here!
|
||||
if ( iTarget == m_aTargets.Count() )
|
||||
{
|
||||
iTarget--;
|
||||
}
|
||||
|
||||
// Just set it to the first target for now!!!
|
||||
// NOTE: Will randomly generate from list of targets when more than 1 in
|
||||
// the future.
|
||||
|
||||
// Move the meteor into the "world."
|
||||
Vector vecPositionInWorld;
|
||||
Vector vecSkyboxOrigin;
|
||||
g_pMapData->Get3DSkyboxOrigin( vecSkyboxOrigin );
|
||||
vecPositionInWorld = ( meteorOrigin - vecSkyboxOrigin );
|
||||
vecPositionInWorld *= g_pMapData->Get3DSkyboxScale();
|
||||
|
||||
Vector vecTargetPos = m_aTargets[iTarget].m_vecPosition;
|
||||
vecTargetPos.x += GetRandomFloat( -m_aTargets[iTarget].m_flRadius, m_aTargets[iTarget].m_flRadius );
|
||||
vecTargetPos.y += GetRandomFloat( -m_aTargets[iTarget].m_flRadius, m_aTargets[iTarget].m_flRadius );
|
||||
vecTargetPos.z += GetRandomFloat( -m_aTargets[iTarget].m_flRadius, m_aTargets[iTarget].m_flRadius );
|
||||
|
||||
vecDirection = vecTargetPos - vecPositionInWorld;
|
||||
VectorNormalize( vecDirection );
|
||||
}
|
||||
|
||||
// Pass in the randomized position, randomized speed, and start time.
|
||||
m_pFactory->CreateMeteor( m_nMeteorCount, m_iMeteorType, meteorOrigin,
|
||||
vecDirection /* direction */,
|
||||
GetRandomFloat( m_flMinSpeed, m_flMaxSpeed ) /* speed */,
|
||||
m_flNextSpawnTime, m_flMeteorDamageRadius,
|
||||
m_vecTriggerMins, m_vecTriggerMaxs );
|
||||
}
|
||||
|
||||
// Set next spawn time.
|
||||
m_flNextSpawnTime += GetRandomFloat( m_flMinSpawnTime, m_flMaxSpawnTime );
|
||||
}
|
||||
|
||||
// Return the next spawn time.
|
||||
return ( m_flNextSpawnTime - gpGlobals->curtime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvMeteorSpawnerShared::AddToTargetList( const Vector &vecPosition, float flRadius )
|
||||
{
|
||||
int iTarget = m_aTargets.AddToTail();
|
||||
m_aTargets[iTarget].m_vecPosition = vecPosition;
|
||||
m_aTargets[iTarget].m_flRadius = flRadius;
|
||||
}
|
||||
|
||||
@@ -1,202 +1,202 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENV_METEOR_SHARED_H
|
||||
#define ENV_METEOR_SHARED_H
|
||||
#pragma once
|
||||
|
||||
#include "vstdlib/random.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Shared Meteor Class
|
||||
//
|
||||
#define METEOR_INVALID_TIME -9999.9f
|
||||
#define METEOR_PASSIVE_TIME 0.0f
|
||||
#define METEOR_MAX_LIFETIME 60.0f
|
||||
#define METEOR_MIN_SIZE Vector( -100, -100, -100 )
|
||||
#define METEOR_MAX_SIZE Vector( 100, 100, 100 )
|
||||
|
||||
#define METEOR_LOCATION_INVALID -1
|
||||
#define METEOR_LOCATION_WORLD 0
|
||||
#define METEOR_LOCATION_SKYBOX 1
|
||||
|
||||
class CEnvMeteorShared
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Initialization.
|
||||
//-------------------------------------------------------------------------
|
||||
CEnvMeteorShared();
|
||||
void Init( int nID, float flStartTime, float flPassiveTime,
|
||||
const Vector &vecStartPosition,
|
||||
const Vector &vecDirection, float flSpeed, float flDamageRadius,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns the position of the object at a given time.
|
||||
//-------------------------------------------------------------------------
|
||||
void GetPositionAtTime( float flTime, Vector &vecPosition );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Changes an objects paramters from "skybox space" to "world space."
|
||||
//-------------------------------------------------------------------------
|
||||
void ConvertFromSkyboxToWorld( void );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Changes an objects paramters from "world space" to "skybox space."
|
||||
//-------------------------------------------------------------------------
|
||||
void ConvertFromWorldToSkybox( void );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns whether or not the object is the the skybox given the time.
|
||||
//-------------------------------------------------------------------------
|
||||
bool IsInSkybox( float flTime );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns whether or not the object is moving in the skybox (or passive).
|
||||
//-------------------------------------------------------------------------
|
||||
bool IsPassive( float flTime );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns whether or not the object will ever transition from skybox to world.
|
||||
//-------------------------------------------------------------------------
|
||||
bool WillTransition( void );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns the splash damage radius of the object.
|
||||
//-------------------------------------------------------------------------
|
||||
float GetDamageRadius( void );
|
||||
|
||||
public:
|
||||
|
||||
int m_nID; // unique identifier
|
||||
|
||||
// The objects initial parametric conditions.
|
||||
Vector m_vecStartPosition;
|
||||
Vector m_vecDirection;
|
||||
float m_flSpeed; // (units/sec), unit = 1 inch
|
||||
float m_flStartTime;
|
||||
|
||||
// NOTE: All times are absolute - ie m_flStartTime has been added in.
|
||||
|
||||
// The time after the starting time in which it object starts to "move."
|
||||
float m_flPassiveTime;
|
||||
|
||||
// The enter and exit times define the times at which the object enters and
|
||||
// exits the world. In other words, m_flEnterTime is the time at which the
|
||||
// object leaves the skybox and enters the world. m_flExitTime is the opposite.
|
||||
float m_flWorldEnterTime;
|
||||
float m_flWorldExitTime;
|
||||
|
||||
float m_flPosTime; // Timer used to find the position of the meteor.
|
||||
Vector m_vecPos;
|
||||
|
||||
//
|
||||
int m_nLocation; // 0 = Skybox, 1 = World
|
||||
|
||||
float m_flDamageRadius; //
|
||||
|
||||
private:
|
||||
|
||||
// Calculate the enter/exit times. (called from Init)
|
||||
void CalcEnterAndExitTimes( const Vector &vecTriggerMins, const Vector &vecTriggerMaxs );
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Meteor Factory Interface
|
||||
//
|
||||
abstract_class IMeteorFactory
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void CreateMeteor( int nID, int iType,
|
||||
const Vector &vecPosition, const Vector &vecDirection,
|
||||
float flSpeed, float flStartTime, float flDamageRadius,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs ) = 0;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Shared Meteor Spawner Class
|
||||
//
|
||||
class CEnvMeteorSpawnerShared
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_NOBASE( CEnvMeteorSpawnerShared );
|
||||
DECLARE_EMBEDDED_NETWORKVAR();
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Initialization.
|
||||
//-------------------------------------------------------------------------
|
||||
CEnvMeteorSpawnerShared();
|
||||
void Init( IMeteorFactory *pFactory, int nRandomSeed, float flTime,
|
||||
const Vector &vecMinBounds, const Vector &vecMaxBounds,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Method to generate meteors.
|
||||
// Time passed in here is global time, not delta time.
|
||||
// The function returns the time at which it must be called again.
|
||||
//-------------------------------------------------------------------------
|
||||
float MeteorThink( float flTime );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Add meteor target data, used to determine meteor travel direction.
|
||||
//-------------------------------------------------------------------------
|
||||
void AddToTargetList( const Vector &vecPosition, float flRadius );
|
||||
|
||||
// Debugging!
|
||||
int GetRandomInt( int nMin, int nMax );
|
||||
float GetRandomFloat( float flMin, float flMax );
|
||||
|
||||
public:
|
||||
|
||||
// Factory.
|
||||
IMeteorFactory *m_pFactory; // Meteor creation factory.
|
||||
|
||||
int m_nMeteorCount; // Number of meteors created - used as IDs
|
||||
|
||||
// Initial spawner data.
|
||||
CNetworkVar( float, m_flStartTime ); // Start time.
|
||||
CNetworkVar( int, m_nRandomSeed ); // The random number stream seed.
|
||||
|
||||
CNetworkVar( int, m_iMeteorType ); // Type of meteor.
|
||||
float m_flMeteorDamageRadius; // Meteor damage radius.
|
||||
CNetworkVar( bool, m_bSkybox ); // Is the spawner in the skybox?
|
||||
|
||||
CNetworkVar( float, m_flMinSpawnTime ); // Spawn time - Min
|
||||
CNetworkVar( float, m_flMaxSpawnTime ); // Max
|
||||
CNetworkVar( int, m_nMinSpawnCount ); // Number of meteors to spawn - Min
|
||||
CNetworkVar( int, m_nMaxSpawnCount ); // Max
|
||||
CNetworkVector( m_vecMinBounds ); // Spawner volume (space) - Min
|
||||
CNetworkVector( m_vecMaxBounds ); // Max
|
||||
CNetworkVar( float, m_flMinSpeed ); // Meteor speed - Min
|
||||
CNetworkVar( float, m_flMaxSpeed ); // Max
|
||||
CNetworkVector( m_vecTriggerMins ); // World Bounds (Trigger) in 3D Skybox - Min
|
||||
CNetworkVector( m_vecTriggerMaxs ); // Max
|
||||
Vector m_vecTriggerCenter;
|
||||
|
||||
// Generated data.
|
||||
int m_nRandomCallCount; // Debug! Keep track of number steam calls.
|
||||
float m_flNextSpawnTime; // Next meteor spawn time (random).
|
||||
CUniformRandomStream m_NumberStream; // Used to generate random numbers.
|
||||
|
||||
// Use "Targets" to determine meteor direction(s).
|
||||
struct meteortarget_t
|
||||
{
|
||||
Vector m_vecPosition;
|
||||
float m_flRadius;
|
||||
};
|
||||
CUtlVector<meteortarget_t> m_aTargets;
|
||||
};
|
||||
|
||||
#endif // ENV_METEOR_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENV_METEOR_SHARED_H
|
||||
#define ENV_METEOR_SHARED_H
|
||||
#pragma once
|
||||
|
||||
#include "vstdlib/random.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Shared Meteor Class
|
||||
//
|
||||
#define METEOR_INVALID_TIME -9999.9f
|
||||
#define METEOR_PASSIVE_TIME 0.0f
|
||||
#define METEOR_MAX_LIFETIME 60.0f
|
||||
#define METEOR_MIN_SIZE Vector( -100, -100, -100 )
|
||||
#define METEOR_MAX_SIZE Vector( 100, 100, 100 )
|
||||
|
||||
#define METEOR_LOCATION_INVALID -1
|
||||
#define METEOR_LOCATION_WORLD 0
|
||||
#define METEOR_LOCATION_SKYBOX 1
|
||||
|
||||
class CEnvMeteorShared
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Initialization.
|
||||
//-------------------------------------------------------------------------
|
||||
CEnvMeteorShared();
|
||||
void Init( int nID, float flStartTime, float flPassiveTime,
|
||||
const Vector &vecStartPosition,
|
||||
const Vector &vecDirection, float flSpeed, float flDamageRadius,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns the position of the object at a given time.
|
||||
//-------------------------------------------------------------------------
|
||||
void GetPositionAtTime( float flTime, Vector &vecPosition );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Changes an objects paramters from "skybox space" to "world space."
|
||||
//-------------------------------------------------------------------------
|
||||
void ConvertFromSkyboxToWorld( void );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Changes an objects paramters from "world space" to "skybox space."
|
||||
//-------------------------------------------------------------------------
|
||||
void ConvertFromWorldToSkybox( void );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns whether or not the object is the the skybox given the time.
|
||||
//-------------------------------------------------------------------------
|
||||
bool IsInSkybox( float flTime );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns whether or not the object is moving in the skybox (or passive).
|
||||
//-------------------------------------------------------------------------
|
||||
bool IsPassive( float flTime );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns whether or not the object will ever transition from skybox to world.
|
||||
//-------------------------------------------------------------------------
|
||||
bool WillTransition( void );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Returns the splash damage radius of the object.
|
||||
//-------------------------------------------------------------------------
|
||||
float GetDamageRadius( void );
|
||||
|
||||
public:
|
||||
|
||||
int m_nID; // unique identifier
|
||||
|
||||
// The objects initial parametric conditions.
|
||||
Vector m_vecStartPosition;
|
||||
Vector m_vecDirection;
|
||||
float m_flSpeed; // (units/sec), unit = 1 inch
|
||||
float m_flStartTime;
|
||||
|
||||
// NOTE: All times are absolute - ie m_flStartTime has been added in.
|
||||
|
||||
// The time after the starting time in which it object starts to "move."
|
||||
float m_flPassiveTime;
|
||||
|
||||
// The enter and exit times define the times at which the object enters and
|
||||
// exits the world. In other words, m_flEnterTime is the time at which the
|
||||
// object leaves the skybox and enters the world. m_flExitTime is the opposite.
|
||||
float m_flWorldEnterTime;
|
||||
float m_flWorldExitTime;
|
||||
|
||||
float m_flPosTime; // Timer used to find the position of the meteor.
|
||||
Vector m_vecPos;
|
||||
|
||||
//
|
||||
int m_nLocation; // 0 = Skybox, 1 = World
|
||||
|
||||
float m_flDamageRadius; //
|
||||
|
||||
private:
|
||||
|
||||
// Calculate the enter/exit times. (called from Init)
|
||||
void CalcEnterAndExitTimes( const Vector &vecTriggerMins, const Vector &vecTriggerMaxs );
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Meteor Factory Interface
|
||||
//
|
||||
abstract_class IMeteorFactory
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void CreateMeteor( int nID, int iType,
|
||||
const Vector &vecPosition, const Vector &vecDirection,
|
||||
float flSpeed, float flStartTime, float flDamageRadius,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs ) = 0;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Shared Meteor Spawner Class
|
||||
//
|
||||
class CEnvMeteorSpawnerShared
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_NOBASE( CEnvMeteorSpawnerShared );
|
||||
DECLARE_EMBEDDED_NETWORKVAR();
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Initialization.
|
||||
//-------------------------------------------------------------------------
|
||||
CEnvMeteorSpawnerShared();
|
||||
void Init( IMeteorFactory *pFactory, int nRandomSeed, float flTime,
|
||||
const Vector &vecMinBounds, const Vector &vecMaxBounds,
|
||||
const Vector &vecTriggerMins, const Vector &vecTriggerMaxs );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Method to generate meteors.
|
||||
// Time passed in here is global time, not delta time.
|
||||
// The function returns the time at which it must be called again.
|
||||
//-------------------------------------------------------------------------
|
||||
float MeteorThink( float flTime );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Add meteor target data, used to determine meteor travel direction.
|
||||
//-------------------------------------------------------------------------
|
||||
void AddToTargetList( const Vector &vecPosition, float flRadius );
|
||||
|
||||
// Debugging!
|
||||
int GetRandomInt( int nMin, int nMax );
|
||||
float GetRandomFloat( float flMin, float flMax );
|
||||
|
||||
public:
|
||||
|
||||
// Factory.
|
||||
IMeteorFactory *m_pFactory; // Meteor creation factory.
|
||||
|
||||
int m_nMeteorCount; // Number of meteors created - used as IDs
|
||||
|
||||
// Initial spawner data.
|
||||
CNetworkVar( float, m_flStartTime ); // Start time.
|
||||
CNetworkVar( int, m_nRandomSeed ); // The random number stream seed.
|
||||
|
||||
CNetworkVar( int, m_iMeteorType ); // Type of meteor.
|
||||
float m_flMeteorDamageRadius; // Meteor damage radius.
|
||||
CNetworkVar( bool, m_bSkybox ); // Is the spawner in the skybox?
|
||||
|
||||
CNetworkVar( float, m_flMinSpawnTime ); // Spawn time - Min
|
||||
CNetworkVar( float, m_flMaxSpawnTime ); // Max
|
||||
CNetworkVar( int, m_nMinSpawnCount ); // Number of meteors to spawn - Min
|
||||
CNetworkVar( int, m_nMaxSpawnCount ); // Max
|
||||
CNetworkVector( m_vecMinBounds ); // Spawner volume (space) - Min
|
||||
CNetworkVector( m_vecMaxBounds ); // Max
|
||||
CNetworkVar( float, m_flMinSpeed ); // Meteor speed - Min
|
||||
CNetworkVar( float, m_flMaxSpeed ); // Max
|
||||
CNetworkVector( m_vecTriggerMins ); // World Bounds (Trigger) in 3D Skybox - Min
|
||||
CNetworkVector( m_vecTriggerMaxs ); // Max
|
||||
Vector m_vecTriggerCenter;
|
||||
|
||||
// Generated data.
|
||||
int m_nRandomCallCount; // Debug! Keep track of number steam calls.
|
||||
float m_flNextSpawnTime; // Next meteor spawn time (random).
|
||||
CUniformRandomStream m_NumberStream; // Used to generate random numbers.
|
||||
|
||||
// Use "Targets" to determine meteor direction(s).
|
||||
struct meteortarget_t
|
||||
{
|
||||
Vector m_vecPosition;
|
||||
float m_flRadius;
|
||||
};
|
||||
CUtlVector<meteortarget_t> m_aTargets;
|
||||
};
|
||||
|
||||
#endif // ENV_METEOR_SHARED_H
|
||||
|
||||
@@ -1,293 +1,293 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
// Information about algorithmic stuff that can occur on both client + server
|
||||
//
|
||||
// In order to reduce network traffic, it's possible to create a algorithms
|
||||
// that will work on both the client and the server and be totally repeatable.
|
||||
// All we need do is to send down initial conditions and let the algorithm
|
||||
// compute the values at various times. Note that this algorithm will be called
|
||||
// at different times with different frequencies on the client and server.
|
||||
//
|
||||
// The trick here is that in order for it to be repeatable, the algorithm either
|
||||
// cannot depend on random numbers, or, if it does, we need to make sure that
|
||||
// the random numbers generated are effectively done at the beginning of time,
|
||||
// so that differences in frame rate on client and server won't matter. It also
|
||||
// is important that the initial state sent across the network is identical
|
||||
// bitwise so that we produce the exact same results. Therefore no compression
|
||||
// should be used in the datatables.
|
||||
//
|
||||
// Note also that each algorithm must have its own random number stream so that
|
||||
// it cannot possibly interact with other code using random numbers that will
|
||||
// be called at various different intervals on the client + server. Use the
|
||||
// CUniformRandomStream class for this.
|
||||
//
|
||||
// There are two types of client-server neutral code: Code that doesn't interact
|
||||
// with player prediction, and code that does. The code that doesn't interact
|
||||
// with player prediction simply has to be able to produce the result f(time)
|
||||
// where time is monotonically increasing. For prediction, we have to produce
|
||||
// the result f(time) where time does *not* monotonically increase (time can be
|
||||
// anywhere between the "current" time and the prior 10 seconds).
|
||||
//
|
||||
// Code that is not used by player prediction can maintain state because later
|
||||
// calls will always compute the value at some future time. This computation can
|
||||
// use random number generation, but with the following restriction: Your code
|
||||
// must generate exactly the same number of random numbers regardless of how
|
||||
// frequently the code is called.
|
||||
//
|
||||
// In specific, this means that all random numbers used must either be computed
|
||||
// at init time, or must be used in an 'event-based form'. Namely, use random
|
||||
// numbers to compute the time at which events occur and the random inputs for
|
||||
// those events. When simulating forward, you must simulate all intervening
|
||||
// time and generate the same number of random numbers.
|
||||
//
|
||||
// For functions planned to be used by player prediction, one method is to use
|
||||
// some sort of stateless computation (where the only states are the initial
|
||||
// state and time). Note that random number generators have state implicit in
|
||||
// the number of calls made to that random number generator, and therefore you
|
||||
// cannot call a random number generator unless you are able to
|
||||
//
|
||||
// 1) Use a random number generator that can return the ith random number, namely:
|
||||
//
|
||||
// float r = random( i ); // i == the ith number in the random sequence
|
||||
//
|
||||
// 2) Be able to accurately know at any given time t how many random numbers
|
||||
// have already been generated (namely, compute the i in part 1 above).
|
||||
//
|
||||
// There is another alternative for code meant to be used by player prediction:
|
||||
// you could just store a history of 'events' from which you could completely
|
||||
// determine the value of f(time). That history would need to be at least 10
|
||||
// seconds long, which is guaranteed to be longer than the amount of time that
|
||||
// prediction would need. I've written a class which I haven't tested yet (but
|
||||
// will be using soon) called CTimedEventQueue (currently located in
|
||||
// env_wind_shared.h) which I plan to use to solve my problem (getting wind to
|
||||
// blow players).
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "env_wind_shared.h"
|
||||
#include "soundenvelope.h"
|
||||
#include "IEffects.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "sharedInterface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// globals
|
||||
//-----------------------------------------------------------------------------
|
||||
static Vector s_vecWindVelocity( 0, 0, 0 );
|
||||
|
||||
|
||||
CEnvWindShared::CEnvWindShared() : m_WindAveQueue(10), m_WindVariationQueue(10)
|
||||
{
|
||||
m_pWindSound = NULL;
|
||||
}
|
||||
|
||||
CEnvWindShared::~CEnvWindShared()
|
||||
{
|
||||
if (m_pWindSound)
|
||||
{
|
||||
CSoundEnvelopeController::GetController().Shutdown( m_pWindSound );
|
||||
}
|
||||
}
|
||||
|
||||
void CEnvWindShared::Init( int nEntIndex, int iRandomSeed, float flTime,
|
||||
int iInitialWindYaw, float flInitialWindSpeed )
|
||||
{
|
||||
m_iEntIndex = nEntIndex;
|
||||
m_flWindAngleVariation = m_flWindSpeedVariation = 1.0f;
|
||||
m_flStartTime = m_flSimTime = m_flSwitchTime = m_flVariationTime = flTime;
|
||||
m_iWindSeed = iRandomSeed;
|
||||
m_Stream.SetSeed( iRandomSeed );
|
||||
m_WindVariationStream.SetSeed( iRandomSeed );
|
||||
m_iWindDir = m_iInitialWindDir = iInitialWindYaw;
|
||||
|
||||
m_flAveWindSpeed = m_flWindSpeed = m_flInitialWindSpeed = flInitialWindSpeed;
|
||||
|
||||
/*
|
||||
// Cache in the wind sound...
|
||||
if (!g_pEffects->IsServer())
|
||||
{
|
||||
CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
|
||||
m_pWindSound = controller.SoundCreate( -1, CHAN_STATIC,
|
||||
"EnvWind.Loop", ATTN_NONE );
|
||||
controller.Play( m_pWindSound, 0.0f, 100 );
|
||||
}
|
||||
*/
|
||||
|
||||
// Next time a change happens (which will happen immediately), it'll stop gusting
|
||||
m_bGusting = true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Computes wind variation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define WIND_VARIATION_UPDATE_TIME 0.1f
|
||||
|
||||
void CEnvWindShared::ComputeWindVariation( float flTime )
|
||||
{
|
||||
// The wind variation is updated every 10th of a second..
|
||||
while( flTime >= m_flVariationTime )
|
||||
{
|
||||
m_flWindAngleVariation = m_WindVariationStream.RandomFloat( -10, 10 );
|
||||
m_flWindSpeedVariation = 1.0 + m_WindVariationStream.RandomFloat( -0.2, 0.2 );
|
||||
m_flVariationTime += WIND_VARIATION_UPDATE_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the wind sound
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvWindShared::UpdateWindSound( float flTotalWindSpeed )
|
||||
{
|
||||
if (!g_pEffects->IsServer())
|
||||
{
|
||||
float flDuration = random->RandomFloat( 1.0f, 2.0f );
|
||||
CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
|
||||
|
||||
// FIXME: Tweak with these numbers
|
||||
float flNormalizedWindSpeed = flTotalWindSpeed / 150.0f;
|
||||
if (flNormalizedWindSpeed > 1.0f)
|
||||
flNormalizedWindSpeed = 1.0f;
|
||||
float flPitch = 120 * Bias( flNormalizedWindSpeed, 0.3f ) + 100;
|
||||
float flVolume = 0.3f * Bias( flNormalizedWindSpeed, 0.3f ) + 0.7f;
|
||||
controller.SoundChangePitch( m_pWindSound, flPitch, flDuration );
|
||||
controller.SoundChangeVolume( m_pWindSound, flVolume, flDuration );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the wind speed
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define WIND_ACCELERATION 150.0f // wind speed can accelerate this many units per second
|
||||
#define WIND_DECELERATION 15.0f // wind speed can decelerate this many units per second
|
||||
|
||||
float CEnvWindShared::WindThink( float flTime )
|
||||
{
|
||||
// NOTE: This algorithm can be client-server neutal because we're using
|
||||
// the random number generator to generate *time* at which the wind changes.
|
||||
// We therefore need to structure the algorithm so that no matter the
|
||||
// frequency of calls to this function we produce the same wind speeds...
|
||||
|
||||
ComputeWindVariation( flTime );
|
||||
|
||||
while (true)
|
||||
{
|
||||
// First, simulate up to the next switch time...
|
||||
float flTimeToSwitch = m_flSwitchTime - m_flSimTime;
|
||||
float flMaxDeltaTime = flTime - m_flSimTime;
|
||||
|
||||
bool bGotToSwitchTime = (flMaxDeltaTime > flTimeToSwitch);
|
||||
|
||||
float flSimDeltaTime = bGotToSwitchTime ? flTimeToSwitch : flMaxDeltaTime;
|
||||
|
||||
// Now that we've chosen
|
||||
// either ramp up, or sleep till change
|
||||
bool bReachedSteadyState = true;
|
||||
if ( m_flAveWindSpeed > m_flWindSpeed )
|
||||
{
|
||||
m_flWindSpeed += WIND_ACCELERATION * flSimDeltaTime;
|
||||
if (m_flWindSpeed > m_flAveWindSpeed)
|
||||
m_flWindSpeed = m_flAveWindSpeed;
|
||||
else
|
||||
bReachedSteadyState = false;
|
||||
}
|
||||
else if ( m_flAveWindSpeed < m_flWindSpeed )
|
||||
{
|
||||
m_flWindSpeed -= WIND_DECELERATION * flSimDeltaTime;
|
||||
if (m_flWindSpeed < m_flAveWindSpeed)
|
||||
m_flWindSpeed = m_flAveWindSpeed;
|
||||
else
|
||||
bReachedSteadyState = false;
|
||||
}
|
||||
|
||||
// Update the sim time
|
||||
|
||||
// If we didn't get to a switch point, then we're done simulating for now
|
||||
if (!bGotToSwitchTime)
|
||||
{
|
||||
m_flSimTime = flTime;
|
||||
|
||||
// We're about to exit, let's set the wind velocity...
|
||||
QAngle vecWindAngle( 0, m_iWindDir + m_flWindAngleVariation, 0 );
|
||||
AngleVectors( vecWindAngle, &s_vecWindVelocity );
|
||||
float flTotalWindSpeed = m_flWindSpeed * m_flWindSpeedVariation;
|
||||
s_vecWindVelocity *= flTotalWindSpeed;
|
||||
|
||||
// If we reached a steady state, we don't need to be called until the switch time
|
||||
// Otherwise, we should be called immediately
|
||||
|
||||
// FIXME: If we ever call this from prediction, we'll need
|
||||
// to only update the sound if it's a new time
|
||||
// Or, we'll need to update the sound elsewhere.
|
||||
// Update the sound....
|
||||
// UpdateWindSound( flTotalWindSpeed );
|
||||
|
||||
// Always immediately call, the wind is forever varying
|
||||
return ( flTime + 0.01f );
|
||||
}
|
||||
|
||||
m_flSimTime = m_flSwitchTime;
|
||||
|
||||
// Switch gusting state..
|
||||
if( m_bGusting )
|
||||
{
|
||||
// wind is gusting, so return to normal wind
|
||||
m_flAveWindSpeed = m_Stream.RandomInt( m_iMinWind, m_iMaxWind );
|
||||
|
||||
// set up for another gust later
|
||||
m_bGusting = false;
|
||||
m_flSwitchTime += m_flMinGustDelay + m_Stream.RandomFloat( 0, m_flMaxGustDelay );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
m_OnGustEnd.FireOutput( NULL, NULL );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// time for a gust.
|
||||
m_flAveWindSpeed = m_Stream.RandomInt( m_iMinGust, m_iMaxGust );
|
||||
|
||||
// change wind direction, maybe a lot
|
||||
m_iWindDir = anglemod( m_iWindDir + m_Stream.RandomInt(-m_iGustDirChange, m_iGustDirChange) );
|
||||
|
||||
// set up to stop the gust in a short while
|
||||
m_bGusting = true;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
m_OnGustStart.FireOutput( NULL, NULL );
|
||||
#endif
|
||||
|
||||
// !!!HACKHACK - gust duration tied to the length of a particular wave file
|
||||
m_flSwitchTime += m_flGustDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to reset windspeed..
|
||||
//-----------------------------------------------------------------------------
|
||||
void ResetWindspeed()
|
||||
{
|
||||
s_vecWindVelocity.Init( 0, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to sample the windspeed at a particular time
|
||||
//-----------------------------------------------------------------------------
|
||||
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 );
|
||||
}
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
// Information about algorithmic stuff that can occur on both client + server
|
||||
//
|
||||
// In order to reduce network traffic, it's possible to create a algorithms
|
||||
// that will work on both the client and the server and be totally repeatable.
|
||||
// All we need do is to send down initial conditions and let the algorithm
|
||||
// compute the values at various times. Note that this algorithm will be called
|
||||
// at different times with different frequencies on the client and server.
|
||||
//
|
||||
// The trick here is that in order for it to be repeatable, the algorithm either
|
||||
// cannot depend on random numbers, or, if it does, we need to make sure that
|
||||
// the random numbers generated are effectively done at the beginning of time,
|
||||
// so that differences in frame rate on client and server won't matter. It also
|
||||
// is important that the initial state sent across the network is identical
|
||||
// bitwise so that we produce the exact same results. Therefore no compression
|
||||
// should be used in the datatables.
|
||||
//
|
||||
// Note also that each algorithm must have its own random number stream so that
|
||||
// it cannot possibly interact with other code using random numbers that will
|
||||
// be called at various different intervals on the client + server. Use the
|
||||
// CUniformRandomStream class for this.
|
||||
//
|
||||
// There are two types of client-server neutral code: Code that doesn't interact
|
||||
// with player prediction, and code that does. The code that doesn't interact
|
||||
// with player prediction simply has to be able to produce the result f(time)
|
||||
// where time is monotonically increasing. For prediction, we have to produce
|
||||
// the result f(time) where time does *not* monotonically increase (time can be
|
||||
// anywhere between the "current" time and the prior 10 seconds).
|
||||
//
|
||||
// Code that is not used by player prediction can maintain state because later
|
||||
// calls will always compute the value at some future time. This computation can
|
||||
// use random number generation, but with the following restriction: Your code
|
||||
// must generate exactly the same number of random numbers regardless of how
|
||||
// frequently the code is called.
|
||||
//
|
||||
// In specific, this means that all random numbers used must either be computed
|
||||
// at init time, or must be used in an 'event-based form'. Namely, use random
|
||||
// numbers to compute the time at which events occur and the random inputs for
|
||||
// those events. When simulating forward, you must simulate all intervening
|
||||
// time and generate the same number of random numbers.
|
||||
//
|
||||
// For functions planned to be used by player prediction, one method is to use
|
||||
// some sort of stateless computation (where the only states are the initial
|
||||
// state and time). Note that random number generators have state implicit in
|
||||
// the number of calls made to that random number generator, and therefore you
|
||||
// cannot call a random number generator unless you are able to
|
||||
//
|
||||
// 1) Use a random number generator that can return the ith random number, namely:
|
||||
//
|
||||
// float r = random( i ); // i == the ith number in the random sequence
|
||||
//
|
||||
// 2) Be able to accurately know at any given time t how many random numbers
|
||||
// have already been generated (namely, compute the i in part 1 above).
|
||||
//
|
||||
// There is another alternative for code meant to be used by player prediction:
|
||||
// you could just store a history of 'events' from which you could completely
|
||||
// determine the value of f(time). That history would need to be at least 10
|
||||
// seconds long, which is guaranteed to be longer than the amount of time that
|
||||
// prediction would need. I've written a class which I haven't tested yet (but
|
||||
// will be using soon) called CTimedEventQueue (currently located in
|
||||
// env_wind_shared.h) which I plan to use to solve my problem (getting wind to
|
||||
// blow players).
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "env_wind_shared.h"
|
||||
#include "soundenvelope.h"
|
||||
#include "IEffects.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "sharedInterface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// globals
|
||||
//-----------------------------------------------------------------------------
|
||||
static Vector s_vecWindVelocity( 0, 0, 0 );
|
||||
|
||||
|
||||
CEnvWindShared::CEnvWindShared() : m_WindAveQueue(10), m_WindVariationQueue(10)
|
||||
{
|
||||
m_pWindSound = NULL;
|
||||
}
|
||||
|
||||
CEnvWindShared::~CEnvWindShared()
|
||||
{
|
||||
if (m_pWindSound)
|
||||
{
|
||||
CSoundEnvelopeController::GetController().Shutdown( m_pWindSound );
|
||||
}
|
||||
}
|
||||
|
||||
void CEnvWindShared::Init( int nEntIndex, int iRandomSeed, float flTime,
|
||||
int iInitialWindYaw, float flInitialWindSpeed )
|
||||
{
|
||||
m_iEntIndex = nEntIndex;
|
||||
m_flWindAngleVariation = m_flWindSpeedVariation = 1.0f;
|
||||
m_flStartTime = m_flSimTime = m_flSwitchTime = m_flVariationTime = flTime;
|
||||
m_iWindSeed = iRandomSeed;
|
||||
m_Stream.SetSeed( iRandomSeed );
|
||||
m_WindVariationStream.SetSeed( iRandomSeed );
|
||||
m_iWindDir = m_iInitialWindDir = iInitialWindYaw;
|
||||
|
||||
m_flAveWindSpeed = m_flWindSpeed = m_flInitialWindSpeed = flInitialWindSpeed;
|
||||
|
||||
/*
|
||||
// Cache in the wind sound...
|
||||
if (!g_pEffects->IsServer())
|
||||
{
|
||||
CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
|
||||
m_pWindSound = controller.SoundCreate( -1, CHAN_STATIC,
|
||||
"EnvWind.Loop", ATTN_NONE );
|
||||
controller.Play( m_pWindSound, 0.0f, 100 );
|
||||
}
|
||||
*/
|
||||
|
||||
// Next time a change happens (which will happen immediately), it'll stop gusting
|
||||
m_bGusting = true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Computes wind variation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define WIND_VARIATION_UPDATE_TIME 0.1f
|
||||
|
||||
void CEnvWindShared::ComputeWindVariation( float flTime )
|
||||
{
|
||||
// The wind variation is updated every 10th of a second..
|
||||
while( flTime >= m_flVariationTime )
|
||||
{
|
||||
m_flWindAngleVariation = m_WindVariationStream.RandomFloat( -10, 10 );
|
||||
m_flWindSpeedVariation = 1.0 + m_WindVariationStream.RandomFloat( -0.2, 0.2 );
|
||||
m_flVariationTime += WIND_VARIATION_UPDATE_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the wind sound
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvWindShared::UpdateWindSound( float flTotalWindSpeed )
|
||||
{
|
||||
if (!g_pEffects->IsServer())
|
||||
{
|
||||
float flDuration = random->RandomFloat( 1.0f, 2.0f );
|
||||
CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
|
||||
|
||||
// FIXME: Tweak with these numbers
|
||||
float flNormalizedWindSpeed = flTotalWindSpeed / 150.0f;
|
||||
if (flNormalizedWindSpeed > 1.0f)
|
||||
flNormalizedWindSpeed = 1.0f;
|
||||
float flPitch = 120 * Bias( flNormalizedWindSpeed, 0.3f ) + 100;
|
||||
float flVolume = 0.3f * Bias( flNormalizedWindSpeed, 0.3f ) + 0.7f;
|
||||
controller.SoundChangePitch( m_pWindSound, flPitch, flDuration );
|
||||
controller.SoundChangeVolume( m_pWindSound, flVolume, flDuration );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the wind speed
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define WIND_ACCELERATION 150.0f // wind speed can accelerate this many units per second
|
||||
#define WIND_DECELERATION 15.0f // wind speed can decelerate this many units per second
|
||||
|
||||
float CEnvWindShared::WindThink( float flTime )
|
||||
{
|
||||
// NOTE: This algorithm can be client-server neutal because we're using
|
||||
// the random number generator to generate *time* at which the wind changes.
|
||||
// We therefore need to structure the algorithm so that no matter the
|
||||
// frequency of calls to this function we produce the same wind speeds...
|
||||
|
||||
ComputeWindVariation( flTime );
|
||||
|
||||
while (true)
|
||||
{
|
||||
// First, simulate up to the next switch time...
|
||||
float flTimeToSwitch = m_flSwitchTime - m_flSimTime;
|
||||
float flMaxDeltaTime = flTime - m_flSimTime;
|
||||
|
||||
bool bGotToSwitchTime = (flMaxDeltaTime > flTimeToSwitch);
|
||||
|
||||
float flSimDeltaTime = bGotToSwitchTime ? flTimeToSwitch : flMaxDeltaTime;
|
||||
|
||||
// Now that we've chosen
|
||||
// either ramp up, or sleep till change
|
||||
bool bReachedSteadyState = true;
|
||||
if ( m_flAveWindSpeed > m_flWindSpeed )
|
||||
{
|
||||
m_flWindSpeed += WIND_ACCELERATION * flSimDeltaTime;
|
||||
if (m_flWindSpeed > m_flAveWindSpeed)
|
||||
m_flWindSpeed = m_flAveWindSpeed;
|
||||
else
|
||||
bReachedSteadyState = false;
|
||||
}
|
||||
else if ( m_flAveWindSpeed < m_flWindSpeed )
|
||||
{
|
||||
m_flWindSpeed -= WIND_DECELERATION * flSimDeltaTime;
|
||||
if (m_flWindSpeed < m_flAveWindSpeed)
|
||||
m_flWindSpeed = m_flAveWindSpeed;
|
||||
else
|
||||
bReachedSteadyState = false;
|
||||
}
|
||||
|
||||
// Update the sim time
|
||||
|
||||
// If we didn't get to a switch point, then we're done simulating for now
|
||||
if (!bGotToSwitchTime)
|
||||
{
|
||||
m_flSimTime = flTime;
|
||||
|
||||
// We're about to exit, let's set the wind velocity...
|
||||
QAngle vecWindAngle( 0, m_iWindDir + m_flWindAngleVariation, 0 );
|
||||
AngleVectors( vecWindAngle, &s_vecWindVelocity );
|
||||
float flTotalWindSpeed = m_flWindSpeed * m_flWindSpeedVariation;
|
||||
s_vecWindVelocity *= flTotalWindSpeed;
|
||||
|
||||
// If we reached a steady state, we don't need to be called until the switch time
|
||||
// Otherwise, we should be called immediately
|
||||
|
||||
// FIXME: If we ever call this from prediction, we'll need
|
||||
// to only update the sound if it's a new time
|
||||
// Or, we'll need to update the sound elsewhere.
|
||||
// Update the sound....
|
||||
// UpdateWindSound( flTotalWindSpeed );
|
||||
|
||||
// Always immediately call, the wind is forever varying
|
||||
return ( flTime + 0.01f );
|
||||
}
|
||||
|
||||
m_flSimTime = m_flSwitchTime;
|
||||
|
||||
// Switch gusting state..
|
||||
if( m_bGusting )
|
||||
{
|
||||
// wind is gusting, so return to normal wind
|
||||
m_flAveWindSpeed = m_Stream.RandomInt( m_iMinWind, m_iMaxWind );
|
||||
|
||||
// set up for another gust later
|
||||
m_bGusting = false;
|
||||
m_flSwitchTime += m_flMinGustDelay + m_Stream.RandomFloat( 0, m_flMaxGustDelay );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
m_OnGustEnd.FireOutput( NULL, NULL );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// time for a gust.
|
||||
m_flAveWindSpeed = m_Stream.RandomInt( m_iMinGust, m_iMaxGust );
|
||||
|
||||
// change wind direction, maybe a lot
|
||||
m_iWindDir = anglemod( m_iWindDir + m_Stream.RandomInt(-m_iGustDirChange, m_iGustDirChange) );
|
||||
|
||||
// set up to stop the gust in a short while
|
||||
m_bGusting = true;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
m_OnGustStart.FireOutput( NULL, NULL );
|
||||
#endif
|
||||
|
||||
// !!!HACKHACK - gust duration tied to the length of a particular wave file
|
||||
m_flSwitchTime += m_flGustDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to reset windspeed..
|
||||
//-----------------------------------------------------------------------------
|
||||
void ResetWindspeed()
|
||||
{
|
||||
s_vecWindVelocity.Init( 0, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to sample the windspeed at a particular time
|
||||
//-----------------------------------------------------------------------------
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -1,244 +1,244 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Implements visual effects entities: sprites, beams, bubbles, etc.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENV_WIND_SHARED_H
|
||||
#define ENV_WIND_SHARED_H
|
||||
|
||||
#include "utllinkedlist.h"
|
||||
#include "vstdlib/random.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include <float.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSoundPatch;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class used to help store events that occurred over time
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
class CTimedEventQueue
|
||||
{
|
||||
public:
|
||||
// The time passed in here represents the amount of time the queue stores
|
||||
CTimedEventQueue( float flMaxTime );
|
||||
|
||||
// Adds an event to the queue, will pop off stale events from the queue
|
||||
// NOTE: All events added to the queue must monotonically increase in time!
|
||||
I PushEvent( float flTime, const T &data );
|
||||
|
||||
// Grabs the last event that happened before or at the specified time
|
||||
I GetEventIndex( float flTime ) const;
|
||||
|
||||
// Gets event information
|
||||
float GetEventTime( I i ) const;
|
||||
const T &GetEventData( I i ) const;
|
||||
|
||||
private:
|
||||
struct QueueEntry_t
|
||||
{
|
||||
float m_flTime;
|
||||
T m_Data;
|
||||
};
|
||||
|
||||
float m_flQueueHeadTime;
|
||||
float m_flMaxTime;
|
||||
CUtlLinkedList< T, I > m_Queue;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The time passed in here represents the amount of time the queue stores
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
CTimedEventQueue<T,I>::CTimedEventQueue( float flMaxTime ) : m_flMaxTime(flMaxTime)
|
||||
{
|
||||
// The length of time of events in the queue must be reasonable
|
||||
Assert( m_flMaxTime > 0.0f );
|
||||
m_flQueueHeadTime = -FLT_MAX;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Adds an event to the queue, will pop off stale events from the queue
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
I CTimedEventQueue<T,I>::PushEvent( float flTime, const T &data )
|
||||
{
|
||||
Assert( m_flQueueHeadTime <= flTime );
|
||||
m_flQueueHeadTime = flTime;
|
||||
|
||||
// First push the event...
|
||||
I idx = m_Queue.AddToHead();
|
||||
m_Queue[idx].m_flTime = flTime;
|
||||
m_Queue[idx].m_Data = data;
|
||||
|
||||
// Then retire stale events...
|
||||
I i = m_Queue.Tail();
|
||||
while (m_Queue[i].m_flTime < m_flQueueHeadTime - m_flMaxTime )
|
||||
{
|
||||
I prev = m_Queue.Prev(i);
|
||||
Assert( prev != m_Queue.InvalidIndex() );
|
||||
m_Queue.Remove(i);
|
||||
i = prev;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Grabs the last event that happened before or at the specified time
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
I CTimedEventQueue<T,I>::GetEventIndex( float flTime ) const
|
||||
{
|
||||
// This checks for a request that fell off the queue
|
||||
Assert( (flTime >= m_flQueueHeadTime - m_flMaxTime) && (flTime <= m_flQueueHeadTime) );
|
||||
|
||||
// Then retire stale events...
|
||||
I i = m_Queue.Head();
|
||||
while( m_Queue[i].m_flTime > flTime )
|
||||
{
|
||||
i = m_Queue.Next(i);
|
||||
Assert( i != m_Queue.InvalidIndex() );
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets event information
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
inline float CTimedEventQueue<T,I>::GetEventTime( I i ) const
|
||||
{
|
||||
return m_Queue[i].m_flTime;
|
||||
}
|
||||
|
||||
template <class T, class I>
|
||||
inline const T &CTimedEventQueue<T,I>::GetEventData( I i ) const
|
||||
{
|
||||
return m_Queue[i].m_Data;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implementation of the class that computes windspeed
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEnvWindShared
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_NOBASE( CEnvWindShared );
|
||||
DECLARE_EMBEDDED_NETWORKVAR();
|
||||
|
||||
CEnvWindShared();
|
||||
~CEnvWindShared();
|
||||
|
||||
void Init( int iEntIndex, int iRandomSeed, float flTime, int iWindDir, float flInitialWindSpeed );
|
||||
|
||||
// Method to update the wind speed
|
||||
// Time passed in here is global time, not delta time
|
||||
// The function returns the time at which it must be called again
|
||||
float WindThink( float flTime );
|
||||
|
||||
// FIXME: These really should be private
|
||||
CNetworkVar( float, m_flStartTime );
|
||||
|
||||
CNetworkVar( int, m_iWindSeed ); // random number seed...
|
||||
|
||||
CNetworkVar( int, m_iMinWind ); // the slowest the wind can normally blow
|
||||
CNetworkVar( int, m_iMaxWind ); // the fastest the wind can normally blow
|
||||
CNetworkVar( int, m_iMinGust ); // the slowest that a gust can be
|
||||
CNetworkVar( int, m_iMaxGust ); // the fastest that a gust can be
|
||||
|
||||
CNetworkVar( float, m_flMinGustDelay ); // min time between gusts
|
||||
CNetworkVar( float, m_flMaxGustDelay ); // max time between gusts
|
||||
|
||||
CNetworkVar( float, m_flGustDuration ); // max time between gusts
|
||||
|
||||
CNetworkVar( int, m_iGustDirChange ); // max number of degrees wind dir changes on gusts.
|
||||
int m_iszGustSound; // name of the wind sound to play for gusts.
|
||||
int m_iWindDir; // wind direction (yaw)
|
||||
float m_flWindSpeed; // the wind speed
|
||||
|
||||
CNetworkVar( int, m_iInitialWindDir );
|
||||
CNetworkVar( float, m_flInitialWindSpeed );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
COutputEvent m_OnGustStart;
|
||||
COutputEvent m_OnGustEnd;
|
||||
#endif
|
||||
|
||||
private:
|
||||
struct WindAveEvent_t
|
||||
{
|
||||
float m_flStartWindSpeed; // the wind speed at the time of the event
|
||||
float m_flAveWindSpeed; // the average wind speed of the event
|
||||
};
|
||||
|
||||
struct WindVariationEvent_t
|
||||
{
|
||||
float m_flWindAngleVariation;
|
||||
float m_flWindSpeedVariation;
|
||||
};
|
||||
|
||||
void ComputeWindVariation( float flTime );
|
||||
|
||||
// Updates the wind sound
|
||||
void UpdateWindSound( float flTotalWindSpeed );
|
||||
|
||||
float m_flVariationTime;
|
||||
float m_flSimTime; // What's the time I last simulated up to?
|
||||
float m_flSwitchTime; // when do I actually switch from gust to not gust
|
||||
float m_flAveWindSpeed; // the average wind speed
|
||||
bool m_bGusting; // is the wind gusting right now?
|
||||
|
||||
float m_flWindAngleVariation;
|
||||
float m_flWindSpeedVariation;
|
||||
|
||||
int m_iEntIndex;
|
||||
|
||||
// Used to generate random numbers
|
||||
CUniformRandomStream m_Stream;
|
||||
|
||||
// NOTE: In order to make this algorithm independent of calling frequency
|
||||
// I have to decouple the stream used to generate average wind speed
|
||||
// and the stream used to generate wind variation since they are
|
||||
// simulated using different timesteps
|
||||
CUniformRandomStream m_WindVariationStream;
|
||||
|
||||
// Used to generate the wind sound...
|
||||
CSoundPatch *m_pWindSound;
|
||||
|
||||
// Event history required for prediction
|
||||
CTimedEventQueue< WindAveEvent_t, unsigned short > m_WindAveQueue;
|
||||
CTimedEventQueue< WindVariationEvent_t, unsigned short > m_WindVariationQueue;
|
||||
|
||||
private:
|
||||
CEnvWindShared( const CEnvWindShared & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to sample the windspeed at a particular time
|
||||
//-----------------------------------------------------------------------------
|
||||
void GetWindspeedAtTime( float flTime, Vector &vecVelocity );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to reset windspeed..
|
||||
//-----------------------------------------------------------------------------
|
||||
void ResetWindspeed();
|
||||
|
||||
|
||||
#endif // ENV_WIND_SHARED_H
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Implements visual effects entities: sprites, beams, bubbles, etc.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENV_WIND_SHARED_H
|
||||
#define ENV_WIND_SHARED_H
|
||||
|
||||
#include "utllinkedlist.h"
|
||||
#include "vstdlib/random.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include <float.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSoundPatch;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class used to help store events that occurred over time
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
class CTimedEventQueue
|
||||
{
|
||||
public:
|
||||
// The time passed in here represents the amount of time the queue stores
|
||||
CTimedEventQueue( float flMaxTime );
|
||||
|
||||
// Adds an event to the queue, will pop off stale events from the queue
|
||||
// NOTE: All events added to the queue must monotonically increase in time!
|
||||
I PushEvent( float flTime, const T &data );
|
||||
|
||||
// Grabs the last event that happened before or at the specified time
|
||||
I GetEventIndex( float flTime ) const;
|
||||
|
||||
// Gets event information
|
||||
float GetEventTime( I i ) const;
|
||||
const T &GetEventData( I i ) const;
|
||||
|
||||
private:
|
||||
struct QueueEntry_t
|
||||
{
|
||||
float m_flTime;
|
||||
T m_Data;
|
||||
};
|
||||
|
||||
float m_flQueueHeadTime;
|
||||
float m_flMaxTime;
|
||||
CUtlLinkedList< T, I > m_Queue;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The time passed in here represents the amount of time the queue stores
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
CTimedEventQueue<T,I>::CTimedEventQueue( float flMaxTime ) : m_flMaxTime(flMaxTime)
|
||||
{
|
||||
// The length of time of events in the queue must be reasonable
|
||||
Assert( m_flMaxTime > 0.0f );
|
||||
m_flQueueHeadTime = -FLT_MAX;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Adds an event to the queue, will pop off stale events from the queue
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
I CTimedEventQueue<T,I>::PushEvent( float flTime, const T &data )
|
||||
{
|
||||
Assert( m_flQueueHeadTime <= flTime );
|
||||
m_flQueueHeadTime = flTime;
|
||||
|
||||
// First push the event...
|
||||
I idx = m_Queue.AddToHead();
|
||||
m_Queue[idx].m_flTime = flTime;
|
||||
m_Queue[idx].m_Data = data;
|
||||
|
||||
// Then retire stale events...
|
||||
I i = m_Queue.Tail();
|
||||
while (m_Queue[i].m_flTime < m_flQueueHeadTime - m_flMaxTime )
|
||||
{
|
||||
I prev = m_Queue.Prev(i);
|
||||
Assert( prev != m_Queue.InvalidIndex() );
|
||||
m_Queue.Remove(i);
|
||||
i = prev;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Grabs the last event that happened before or at the specified time
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
I CTimedEventQueue<T,I>::GetEventIndex( float flTime ) const
|
||||
{
|
||||
// This checks for a request that fell off the queue
|
||||
Assert( (flTime >= m_flQueueHeadTime - m_flMaxTime) && (flTime <= m_flQueueHeadTime) );
|
||||
|
||||
// Then retire stale events...
|
||||
I i = m_Queue.Head();
|
||||
while( m_Queue[i].m_flTime > flTime )
|
||||
{
|
||||
i = m_Queue.Next(i);
|
||||
Assert( i != m_Queue.InvalidIndex() );
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets event information
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I>
|
||||
inline float CTimedEventQueue<T,I>::GetEventTime( I i ) const
|
||||
{
|
||||
return m_Queue[i].m_flTime;
|
||||
}
|
||||
|
||||
template <class T, class I>
|
||||
inline const T &CTimedEventQueue<T,I>::GetEventData( I i ) const
|
||||
{
|
||||
return m_Queue[i].m_Data;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implementation of the class that computes windspeed
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEnvWindShared
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_NOBASE( CEnvWindShared );
|
||||
DECLARE_EMBEDDED_NETWORKVAR();
|
||||
|
||||
CEnvWindShared();
|
||||
~CEnvWindShared();
|
||||
|
||||
void Init( int iEntIndex, int iRandomSeed, float flTime, int iWindDir, float flInitialWindSpeed );
|
||||
|
||||
// Method to update the wind speed
|
||||
// Time passed in here is global time, not delta time
|
||||
// The function returns the time at which it must be called again
|
||||
float WindThink( float flTime );
|
||||
|
||||
// FIXME: These really should be private
|
||||
CNetworkVar( float, m_flStartTime );
|
||||
|
||||
CNetworkVar( int, m_iWindSeed ); // random number seed...
|
||||
|
||||
CNetworkVar( int, m_iMinWind ); // the slowest the wind can normally blow
|
||||
CNetworkVar( int, m_iMaxWind ); // the fastest the wind can normally blow
|
||||
CNetworkVar( int, m_iMinGust ); // the slowest that a gust can be
|
||||
CNetworkVar( int, m_iMaxGust ); // the fastest that a gust can be
|
||||
|
||||
CNetworkVar( float, m_flMinGustDelay ); // min time between gusts
|
||||
CNetworkVar( float, m_flMaxGustDelay ); // max time between gusts
|
||||
|
||||
CNetworkVar( float, m_flGustDuration ); // max time between gusts
|
||||
|
||||
CNetworkVar( int, m_iGustDirChange ); // max number of degrees wind dir changes on gusts.
|
||||
int m_iszGustSound; // name of the wind sound to play for gusts.
|
||||
int m_iWindDir; // wind direction (yaw)
|
||||
float m_flWindSpeed; // the wind speed
|
||||
|
||||
CNetworkVar( int, m_iInitialWindDir );
|
||||
CNetworkVar( float, m_flInitialWindSpeed );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
COutputEvent m_OnGustStart;
|
||||
COutputEvent m_OnGustEnd;
|
||||
#endif
|
||||
|
||||
private:
|
||||
struct WindAveEvent_t
|
||||
{
|
||||
float m_flStartWindSpeed; // the wind speed at the time of the event
|
||||
float m_flAveWindSpeed; // the average wind speed of the event
|
||||
};
|
||||
|
||||
struct WindVariationEvent_t
|
||||
{
|
||||
float m_flWindAngleVariation;
|
||||
float m_flWindSpeedVariation;
|
||||
};
|
||||
|
||||
void ComputeWindVariation( float flTime );
|
||||
|
||||
// Updates the wind sound
|
||||
void UpdateWindSound( float flTotalWindSpeed );
|
||||
|
||||
float m_flVariationTime;
|
||||
float m_flSimTime; // What's the time I last simulated up to?
|
||||
float m_flSwitchTime; // when do I actually switch from gust to not gust
|
||||
float m_flAveWindSpeed; // the average wind speed
|
||||
bool m_bGusting; // is the wind gusting right now?
|
||||
|
||||
float m_flWindAngleVariation;
|
||||
float m_flWindSpeedVariation;
|
||||
|
||||
int m_iEntIndex;
|
||||
|
||||
// Used to generate random numbers
|
||||
CUniformRandomStream m_Stream;
|
||||
|
||||
// NOTE: In order to make this algorithm independent of calling frequency
|
||||
// I have to decouple the stream used to generate average wind speed
|
||||
// and the stream used to generate wind variation since they are
|
||||
// simulated using different timesteps
|
||||
CUniformRandomStream m_WindVariationStream;
|
||||
|
||||
// Used to generate the wind sound...
|
||||
CSoundPatch *m_pWindSound;
|
||||
|
||||
// Event history required for prediction
|
||||
CTimedEventQueue< WindAveEvent_t, unsigned short > m_WindAveQueue;
|
||||
CTimedEventQueue< WindVariationEvent_t, unsigned short > m_WindVariationQueue;
|
||||
|
||||
private:
|
||||
CEnvWindShared( const CEnvWindShared & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to sample the windspeed at a particular time
|
||||
//-----------------------------------------------------------------------------
|
||||
void GetWindspeedAtTime( float flTime, Vector &vecVelocity );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Method to reset windspeed..
|
||||
//-----------------------------------------------------------------------------
|
||||
void ResetWindspeed();
|
||||
|
||||
|
||||
#endif // ENV_WIND_SHARED_H
|
||||
|
||||
|
||||
@@ -1,133 +1,133 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
|
||||
class CAchievementEp1KillAntlionsWithCar : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_physics" );
|
||||
SetVictimFilter( "npc_antlion" );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 15 );
|
||||
}
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// any model that passed previous filters and begins with "props_vehicles" is a physics car
|
||||
const char *pszName = GetModelName( pInflictor );
|
||||
const char szPrefix[] = "props_vehicles";
|
||||
if ( 0 == Q_strncmp( pszName, szPrefix, ARRAYSIZE( szPrefix ) - 1 ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1KillAntlionsWithCar, ACHIEVEMENT_EP1_KILL_ANTLIONS_WITHCARS, "EP1_KILL_ANTLIONS_WITHCARS", 5 );
|
||||
|
||||
class CAchievementEp1KillEnemiesWithSniperAlyx : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorEntityNameFilter( "sniper_alyx" );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 30 );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1KillEnemiesWithSniperAlyx, ACHIEVEMENT_EP1_KILL_ENEMIES_WITHSNIPERALYX, "EP1_KILL_ENEMIES_WITHSNIPERALYX", 10 );
|
||||
|
||||
class CAchievementEp1BeatCitizenEscortNoCitizenDeaths : public CFailableAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_LISTEN_KILL_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 1 );
|
||||
SetVictimFilter( "npc_citizen" );
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// if any citizens die while this achievement is active, achievement fails
|
||||
SetFailed();
|
||||
}
|
||||
|
||||
// map event where achievement is activated
|
||||
virtual const char *GetActivationEventName() { return "EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS_START"; }
|
||||
// map event where achievement is evaluated for success
|
||||
virtual const char *GetEvaluationEventName() { return "EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS_END"; }
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1BeatCitizenEscortNoCitizenDeaths, ACHIEVEMENT_EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS, "EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS", 15 );
|
||||
|
||||
extern int CalcPlayerAttacks( bool bBulletOnly );
|
||||
|
||||
class CAchievementEp1BeatGameOneBullet : public CFailableAchievement
|
||||
{
|
||||
DECLARE_CLASS( CAchievementEp1BeatGameOneBullet, CFailableAchievement );
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
|
||||
virtual void OnEvaluationEvent()
|
||||
{
|
||||
// get # of attacks w/bullet weapons
|
||||
int iBulletAttackCount = CalcPlayerAttacks( true );
|
||||
// if more than 1 bullet fired, fail
|
||||
if ( iBulletAttackCount > 1 )
|
||||
{
|
||||
SetFailed();
|
||||
}
|
||||
BaseClass::OnEvaluationEvent();
|
||||
}
|
||||
|
||||
// map event where achievement is activated
|
||||
virtual const char *GetActivationEventName() { return "EP1_START_GAME"; }
|
||||
// map event where achievement is evaluated for success
|
||||
virtual const char *GetEvaluationEventName() { return "EP1_BEAT_GAME"; }
|
||||
|
||||
// additional status for debugging
|
||||
virtual void PrintAdditionalStatus()
|
||||
{
|
||||
if ( m_bActivated )
|
||||
{
|
||||
Msg( "Player bullet attacks: %d\n", CalcPlayerAttacks( true ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1BeatGameOneBullet, ACHIEVEMENT_EP1_BEAT_GAME_ONEBULLET, "EP1_BEAT_GAME_ONEBULLET", 40 );
|
||||
|
||||
// Ep1-specific macro that sets game dir filter. We need this because Ep1/Ep2/... share a binary so we need runtime check against running game.
|
||||
#define DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, "episodic", iPointValue, false )
|
||||
|
||||
// achievements which are won by a map event firing once
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_MAINELEVATOR, "EP1_BEAT_MAINELEVATOR", 5 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_CITADELCORE, "EP1_BEAT_CITADELCORE", 5 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_CITADELCORE_NOSTALKERKILLS, "EP1_BEAT_CITADELCORE_NOSTALKERKILLS", 10 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_GARAGEELEVATORSTANDOFF, "EP1_BEAT_GARAGEELEVATORSTANDOFF", 10 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_HOSPITALATTICGUNSHIP, "EP1_BEAT_HOSPITALATTICGUNSHIP", 5 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_GAME, "EP1_BEAT_GAME", 20 );
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
|
||||
class CAchievementEp1KillAntlionsWithCar : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_physics" );
|
||||
SetVictimFilter( "npc_antlion" );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 15 );
|
||||
}
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// any model that passed previous filters and begins with "props_vehicles" is a physics car
|
||||
const char *pszName = GetModelName( pInflictor );
|
||||
const char szPrefix[] = "props_vehicles";
|
||||
if ( 0 == Q_strncmp( pszName, szPrefix, ARRAYSIZE( szPrefix ) - 1 ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1KillAntlionsWithCar, ACHIEVEMENT_EP1_KILL_ANTLIONS_WITHCARS, "EP1_KILL_ANTLIONS_WITHCARS", 5 );
|
||||
|
||||
class CAchievementEp1KillEnemiesWithSniperAlyx : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorEntityNameFilter( "sniper_alyx" );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 30 );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1KillEnemiesWithSniperAlyx, ACHIEVEMENT_EP1_KILL_ENEMIES_WITHSNIPERALYX, "EP1_KILL_ENEMIES_WITHSNIPERALYX", 10 );
|
||||
|
||||
class CAchievementEp1BeatCitizenEscortNoCitizenDeaths : public CFailableAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_LISTEN_KILL_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 1 );
|
||||
SetVictimFilter( "npc_citizen" );
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// if any citizens die while this achievement is active, achievement fails
|
||||
SetFailed();
|
||||
}
|
||||
|
||||
// map event where achievement is activated
|
||||
virtual const char *GetActivationEventName() { return "EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS_START"; }
|
||||
// map event where achievement is evaluated for success
|
||||
virtual const char *GetEvaluationEventName() { return "EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS_END"; }
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1BeatCitizenEscortNoCitizenDeaths, ACHIEVEMENT_EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS, "EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS", 15 );
|
||||
|
||||
extern int CalcPlayerAttacks( bool bBulletOnly );
|
||||
|
||||
class CAchievementEp1BeatGameOneBullet : public CFailableAchievement
|
||||
{
|
||||
DECLARE_CLASS( CAchievementEp1BeatGameOneBullet, CFailableAchievement );
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "episodic" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
|
||||
virtual void OnEvaluationEvent()
|
||||
{
|
||||
// get # of attacks w/bullet weapons
|
||||
int iBulletAttackCount = CalcPlayerAttacks( true );
|
||||
// if more than 1 bullet fired, fail
|
||||
if ( iBulletAttackCount > 1 )
|
||||
{
|
||||
SetFailed();
|
||||
}
|
||||
BaseClass::OnEvaluationEvent();
|
||||
}
|
||||
|
||||
// map event where achievement is activated
|
||||
virtual const char *GetActivationEventName() { return "EP1_START_GAME"; }
|
||||
// map event where achievement is evaluated for success
|
||||
virtual const char *GetEvaluationEventName() { return "EP1_BEAT_GAME"; }
|
||||
|
||||
// additional status for debugging
|
||||
virtual void PrintAdditionalStatus()
|
||||
{
|
||||
if ( m_bActivated )
|
||||
{
|
||||
Msg( "Player bullet attacks: %d\n", CalcPlayerAttacks( true ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp1BeatGameOneBullet, ACHIEVEMENT_EP1_BEAT_GAME_ONEBULLET, "EP1_BEAT_GAME_ONEBULLET", 40 );
|
||||
|
||||
// Ep1-specific macro that sets game dir filter. We need this because Ep1/Ep2/... share a binary so we need runtime check against running game.
|
||||
#define DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, "episodic", iPointValue, false )
|
||||
|
||||
// achievements which are won by a map event firing once
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_MAINELEVATOR, "EP1_BEAT_MAINELEVATOR", 5 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_CITADELCORE, "EP1_BEAT_CITADELCORE", 5 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_CITADELCORE_NOSTALKERKILLS, "EP1_BEAT_CITADELCORE_NOSTALKERKILLS", 10 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_GARAGEELEVATORSTANDOFF, "EP1_BEAT_GARAGEELEVATORSTANDOFF", 10 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_HOSPITALATTICGUNSHIP, "EP1_BEAT_HOSPITALATTICGUNSHIP", 5 );
|
||||
DECLARE_EP1_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP1_BEAT_GAME, "EP1_BEAT_GAME", 20 );
|
||||
|
||||
#endif // GAME_DLL
|
||||
@@ -1,186 +1,186 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
#include "iservervehicle.h"
|
||||
#include "npc_antlion.h"
|
||||
#include "npc_hunter.h"
|
||||
|
||||
|
||||
class CAchievementEp2KillPoisonAntlion : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void Init()
|
||||
{
|
||||
SetVictimFilter( "npc_antlion" );
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
CNPC_Antlion *pAntlion = dynamic_cast<CNPC_Antlion *>( pVictim );
|
||||
if ( pAntlion && pAntlion->IsWorker() )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillPoisonAntlion, ACHIEVEMENT_EP2_KILL_POISONANTLION, "EP2_KILL_POISONANTLION", 5 );
|
||||
|
||||
class CAchievementEp2KillAllGrubs : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void Init()
|
||||
{
|
||||
SetVictimFilter( "npc_antlion_grub" );
|
||||
SetFlags( ACH_LISTEN_KILL_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 333 );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillAllGrubs, ACHIEVEMENT_EP2_KILL_ALLGRUBS, "EP2_KILL_ALLGRUBS", 20 );
|
||||
|
||||
class CAchievementEp2KillEnemiesWithCar : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_vehicle_jeep" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 20 );
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// count this if the object is a driveable vehicle and local player is driving
|
||||
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
|
||||
IDrivableVehicle *pDriveableVehicle = dynamic_cast<IDrivableVehicle *>( pInflictor );
|
||||
if ( pLocalPlayer && pDriveableVehicle && pDriveableVehicle->GetDriver() == pLocalPlayer )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillEnemiesWithCar, ACHIEVEMENT_EP2_KILL_ENEMIES_WITHCAR, "EP2_KILL_ENEMIES_WITHCAR", 5 );
|
||||
|
||||
class CAchievementEp2KillHunterWithFlechette : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetVictimFilter( "npc_hunter" );
|
||||
SetInflictorFilter( "hunter_flechette" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillHunterWithFlechette, ACHIEVEMENT_EP2_KILL_HUNTER_WITHFLECHETTES, "EP2_KILL_HUNTER_WITHFLECHETTES", 10 );
|
||||
|
||||
class CAchievementEp2FindAllWebCaches : public CBaseAchievement
|
||||
{
|
||||
virtual void Init()
|
||||
{
|
||||
static const char *szComponents[] =
|
||||
{
|
||||
"EP2_WEBCACHE_01", "EP2_WEBCACHE_02", "EP2_WEBCACHE_03", "EP2_WEBCACHE_04",
|
||||
"EP2_WEBCACHE_05", "EP2_WEBCACHE_06", "EP2_WEBCACHE_07", "EP2_WEBCACHE_08", "EP2_WEBCACHE_09"
|
||||
};
|
||||
SetFlags( ACH_HAS_COMPONENTS | ACH_LISTEN_COMPONENT_EVENTS | ACH_SAVE_GLOBAL );
|
||||
m_pszComponentNames = szComponents;
|
||||
m_iNumComponents = ARRAYSIZE( szComponents );
|
||||
SetComponentPrefix( "EP2_WEBCACHE" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( m_iNumComponents );
|
||||
}
|
||||
|
||||
// don't show progress notifications for this achievement, it's distracting
|
||||
virtual bool ShouldShowProgressNotification() { return false; }
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2FindAllWebCaches , ACHIEVEMENT_EP2_BREAK_ALLWEBS, "EP2_BREAK_ALLWEBS", 5 );
|
||||
|
||||
class CAchievementEp2KillChopperNoMisses: public CFailableAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
|
||||
virtual void ListenForEvents()
|
||||
{
|
||||
ListenForGameEvent( "helicopter_grenade_punt_miss" );
|
||||
}
|
||||
|
||||
// map event where achievement is activated
|
||||
virtual const char *GetActivationEventName() { return "EP2_KILL_CHOPPER_NOMISSES_START"; }
|
||||
// map event where achievement is evaluated for success
|
||||
virtual const char *GetEvaluationEventName() { return "EP2_KILL_CHOPPER_NOMISSES_END"; }
|
||||
|
||||
void FireGameEvent_Internal( IGameEvent *event )
|
||||
{
|
||||
if ( 0 == Q_strcmp( event->GetName(), "helicopter_grenade_punt_miss" ) )
|
||||
{
|
||||
SetFailed();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillChopperNoMisses, ACHIEVEMENT_EP2_KILL_CHOPPER_NOMISSES, "EP2_KILL_CHOPPER_NOMISSES", 15 );
|
||||
|
||||
class CAchievementEp2FindAllRadarCaches : public CBaseAchievement
|
||||
{
|
||||
virtual void Init()
|
||||
{
|
||||
static const char *szComponents[] =
|
||||
{
|
||||
"EP2_RADARCACHE_VAN", "EP2_RADARCACHE_SHACK", "EP2_RADARCACHE_RPG", "EP2_RADARCACHE_CAVE", "EP2_RADARCACHE_HANGING"
|
||||
};
|
||||
SetFlags( ACH_HAS_COMPONENTS | ACH_LISTEN_COMPONENT_EVENTS | ACH_SAVE_GLOBAL );
|
||||
m_pszComponentNames = szComponents;
|
||||
m_iNumComponents = ARRAYSIZE( szComponents );
|
||||
SetComponentPrefix( "EP2_RADARCACHE" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( m_iNumComponents );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2FindAllRadarCaches, ACHIEVEMENT_EP2_FIND_ALLRADARCACHES, "EP2_FIND_ALLRADARCACHES", 10 );
|
||||
|
||||
// Ep2-specific macro that sets game dir filter. We need this because Ep1/Ep2/... share a binary so we need runtime check against running game.
|
||||
#define DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, "ep2", iPointValue, false )
|
||||
|
||||
#define DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, "ep2", iPointValue, true )
|
||||
|
||||
// achievements which are won by a map event firing once
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_ANTLIONINVASION, "EP2_BEAT_ANTLIONINVASION", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_ANTLIONGUARDS, "EP2_BEAT_ANTLIONGUARDS", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_HUNTERAMBUSH, "EP2_BEAT_HUNTERAMBUSH", 10 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_KILL_COMBINECANNON, "EP2_KILL_COMBINECANNON", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_RACEWITHDOG, "EP2_BEAT_RACEWITHDOG", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_ROCKETCACHEPUZZLE, "EP2_BEAT_ROCKETCACHEPUZZLE", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_WHITEFORESTINN, "EP2_BEAT_WHITEFORESTINN", 10 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_PUT_ITEMINROCKET, "EP2_PUT_ITEMINROCKET", 30 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_MISSILESILO2, "EP2_BEAT_MISSILESILO2", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_OUTLAND12_NOBUILDINGSDESTROYED, "EP2_BEAT_OUTLAND12_NOBUILDINGSDESTROYED", 35 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_GAME, "EP2_BEAT_GAME", 20 );
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
#include "iservervehicle.h"
|
||||
#include "npc_antlion.h"
|
||||
#include "npc_hunter.h"
|
||||
|
||||
|
||||
class CAchievementEp2KillPoisonAntlion : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void Init()
|
||||
{
|
||||
SetVictimFilter( "npc_antlion" );
|
||||
SetFlags( ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
CNPC_Antlion *pAntlion = dynamic_cast<CNPC_Antlion *>( pVictim );
|
||||
if ( pAntlion && pAntlion->IsWorker() )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillPoisonAntlion, ACHIEVEMENT_EP2_KILL_POISONANTLION, "EP2_KILL_POISONANTLION", 5 );
|
||||
|
||||
class CAchievementEp2KillAllGrubs : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void Init()
|
||||
{
|
||||
SetVictimFilter( "npc_antlion_grub" );
|
||||
SetFlags( ACH_LISTEN_KILL_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 333 );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillAllGrubs, ACHIEVEMENT_EP2_KILL_ALLGRUBS, "EP2_KILL_ALLGRUBS", 20 );
|
||||
|
||||
class CAchievementEp2KillEnemiesWithCar : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_ENEMY_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetInflictorFilter( "prop_vehicle_jeep" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 20 );
|
||||
}
|
||||
|
||||
virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
|
||||
{
|
||||
// count this if the object is a driveable vehicle and local player is driving
|
||||
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
|
||||
IDrivableVehicle *pDriveableVehicle = dynamic_cast<IDrivableVehicle *>( pInflictor );
|
||||
if ( pLocalPlayer && pDriveableVehicle && pDriveableVehicle->GetDriver() == pLocalPlayer )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillEnemiesWithCar, ACHIEVEMENT_EP2_KILL_ENEMIES_WITHCAR, "EP2_KILL_ENEMIES_WITHCAR", 5 );
|
||||
|
||||
class CAchievementEp2KillHunterWithFlechette : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_KILL_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetVictimFilter( "npc_hunter" );
|
||||
SetInflictorFilter( "hunter_flechette" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillHunterWithFlechette, ACHIEVEMENT_EP2_KILL_HUNTER_WITHFLECHETTES, "EP2_KILL_HUNTER_WITHFLECHETTES", 10 );
|
||||
|
||||
class CAchievementEp2FindAllWebCaches : public CBaseAchievement
|
||||
{
|
||||
virtual void Init()
|
||||
{
|
||||
static const char *szComponents[] =
|
||||
{
|
||||
"EP2_WEBCACHE_01", "EP2_WEBCACHE_02", "EP2_WEBCACHE_03", "EP2_WEBCACHE_04",
|
||||
"EP2_WEBCACHE_05", "EP2_WEBCACHE_06", "EP2_WEBCACHE_07", "EP2_WEBCACHE_08", "EP2_WEBCACHE_09"
|
||||
};
|
||||
SetFlags( ACH_HAS_COMPONENTS | ACH_LISTEN_COMPONENT_EVENTS | ACH_SAVE_GLOBAL );
|
||||
m_pszComponentNames = szComponents;
|
||||
m_iNumComponents = ARRAYSIZE( szComponents );
|
||||
SetComponentPrefix( "EP2_WEBCACHE" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( m_iNumComponents );
|
||||
}
|
||||
|
||||
// don't show progress notifications for this achievement, it's distracting
|
||||
virtual bool ShouldShowProgressNotification() { return false; }
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2FindAllWebCaches , ACHIEVEMENT_EP2_BREAK_ALLWEBS, "EP2_BREAK_ALLWEBS", 5 );
|
||||
|
||||
class CAchievementEp2KillChopperNoMisses: public CFailableAchievement
|
||||
{
|
||||
protected:
|
||||
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_LISTEN_MAP_EVENTS | ACH_SAVE_WITH_GAME );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( 1 );
|
||||
}
|
||||
|
||||
virtual void ListenForEvents()
|
||||
{
|
||||
ListenForGameEvent( "helicopter_grenade_punt_miss" );
|
||||
}
|
||||
|
||||
// map event where achievement is activated
|
||||
virtual const char *GetActivationEventName() { return "EP2_KILL_CHOPPER_NOMISSES_START"; }
|
||||
// map event where achievement is evaluated for success
|
||||
virtual const char *GetEvaluationEventName() { return "EP2_KILL_CHOPPER_NOMISSES_END"; }
|
||||
|
||||
void FireGameEvent_Internal( IGameEvent *event )
|
||||
{
|
||||
if ( 0 == Q_strcmp( event->GetName(), "helicopter_grenade_punt_miss" ) )
|
||||
{
|
||||
SetFailed();
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2KillChopperNoMisses, ACHIEVEMENT_EP2_KILL_CHOPPER_NOMISSES, "EP2_KILL_CHOPPER_NOMISSES", 15 );
|
||||
|
||||
class CAchievementEp2FindAllRadarCaches : public CBaseAchievement
|
||||
{
|
||||
virtual void Init()
|
||||
{
|
||||
static const char *szComponents[] =
|
||||
{
|
||||
"EP2_RADARCACHE_VAN", "EP2_RADARCACHE_SHACK", "EP2_RADARCACHE_RPG", "EP2_RADARCACHE_CAVE", "EP2_RADARCACHE_HANGING"
|
||||
};
|
||||
SetFlags( ACH_HAS_COMPONENTS | ACH_LISTEN_COMPONENT_EVENTS | ACH_SAVE_GLOBAL );
|
||||
m_pszComponentNames = szComponents;
|
||||
m_iNumComponents = ARRAYSIZE( szComponents );
|
||||
SetComponentPrefix( "EP2_RADARCACHE" );
|
||||
SetGameDirFilter( "ep2" );
|
||||
SetGoal( m_iNumComponents );
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEp2FindAllRadarCaches, ACHIEVEMENT_EP2_FIND_ALLRADARCACHES, "EP2_FIND_ALLRADARCACHES", 10 );
|
||||
|
||||
// Ep2-specific macro that sets game dir filter. We need this because Ep1/Ep2/... share a binary so we need runtime check against running game.
|
||||
#define DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, "ep2", iPointValue, false )
|
||||
|
||||
#define DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( achievementID, achievementName, iPointValue ) \
|
||||
DECLARE_MAP_EVENT_ACHIEVEMENT_( achievementID, achievementName, "ep2", iPointValue, true )
|
||||
|
||||
// achievements which are won by a map event firing once
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_ANTLIONINVASION, "EP2_BEAT_ANTLIONINVASION", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_ANTLIONGUARDS, "EP2_BEAT_ANTLIONGUARDS", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_HUNTERAMBUSH, "EP2_BEAT_HUNTERAMBUSH", 10 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_KILL_COMBINECANNON, "EP2_KILL_COMBINECANNON", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_RACEWITHDOG, "EP2_BEAT_RACEWITHDOG", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_ROCKETCACHEPUZZLE, "EP2_BEAT_ROCKETCACHEPUZZLE", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_WHITEFORESTINN, "EP2_BEAT_WHITEFORESTINN", 10 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_PUT_ITEMINROCKET, "EP2_PUT_ITEMINROCKET", 30 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_MISSILESILO2, "EP2_BEAT_MISSILESILO2", 5 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT( ACHIEVEMENT_EP2_BEAT_OUTLAND12_NOBUILDINGSDESTROYED, "EP2_BEAT_OUTLAND12_NOBUILDINGSDESTROYED", 35 );
|
||||
DECLARE_EP2_MAP_EVENT_ACHIEVEMENT_HIDDEN( ACHIEVEMENT_EP2_BEAT_GAME, "EP2_BEAT_GAME", 20 );
|
||||
|
||||
#endif // GAME_DLL
|
||||
@@ -1,101 +1,101 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
#include "basegrenade_shared.h"
|
||||
|
||||
CAchievementMgr g_AchievementMgrEpisodic; // global achievement mgr for episodic
|
||||
|
||||
class CAchievementEpXGetZombineGrenade : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_SAVE_GLOBAL );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across EPX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ListenForEvents()
|
||||
{
|
||||
ListenForGameEvent( "physgun_pickup" );
|
||||
}
|
||||
|
||||
void FireGameEvent_Internal( IGameEvent *event )
|
||||
{
|
||||
if ( 0 == Q_strcmp( event->GetName(), "physgun_pickup" ) )
|
||||
{
|
||||
// was the object picked up a frag grenade?
|
||||
CBaseEntity *pEntityPickedUp = UTIL_EntityByIndex( event->GetInt( "entindex" ) );
|
||||
if ( pEntityPickedUp && pEntityPickedUp->ClassMatches( "npc_grenade_frag" ) )
|
||||
{
|
||||
// get the grenade object
|
||||
CBaseGrenade *pGrenade = dynamic_cast<CBaseGrenade *>( pEntityPickedUp );
|
||||
if ( pGrenade )
|
||||
{
|
||||
// was the original thrower a zombine?
|
||||
CBaseEntity *pOriginalThrower = pGrenade->GetOriginalThrower();
|
||||
if ( pOriginalThrower && pOriginalThrower->ClassMatches( "npc_zombine" ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEpXGetZombineGrenade, ACHIEVEMENT_EPX_GET_ZOMBINEGRENADE, "EPX_GET_ZOMBINEGRENADE", 5 );
|
||||
|
||||
class CAchievementEpXKillZombiesWithFlares : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_SAVE_WITH_GAME );
|
||||
SetGoal( 15 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep1 for PC. (Shared across EPX for X360.)
|
||||
SetGameDirFilter( "episodic" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ListenForEvents()
|
||||
{
|
||||
ListenForGameEvent( "flare_ignite_npc" );
|
||||
}
|
||||
|
||||
void FireGameEvent_Internal( IGameEvent *event )
|
||||
{
|
||||
if ( 0 == Q_strcmp( event->GetName(), "flare_ignite_npc" ) )
|
||||
{
|
||||
CBaseEntity *pEntityIgnited = UTIL_EntityByIndex( event->GetInt( "entindex" ) );
|
||||
// was it a zombie that got set on fire?
|
||||
if ( pEntityIgnited &&
|
||||
( ( pEntityIgnited->ClassMatches( "npc_zombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_zombine" ) ) ||
|
||||
( pEntityIgnited->ClassMatches( "npc_fastzombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_poisonzombie" ) ) ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEpXKillZombiesWithFlares, ACHIEVEMENT_EPX_KILL_ZOMBIES_WITHFLARES, "EPX_KILL_ZOMBIES_WITHFLARES", 5 );
|
||||
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "achievementmgr.h"
|
||||
#include "baseachievement.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
#include "basegrenade_shared.h"
|
||||
|
||||
CAchievementMgr g_AchievementMgrEpisodic; // global achievement mgr for episodic
|
||||
|
||||
class CAchievementEpXGetZombineGrenade : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_SAVE_GLOBAL );
|
||||
SetGoal( 1 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep2 for PC. (Shared across EPX for X360.)
|
||||
SetGameDirFilter( "ep2" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ListenForEvents()
|
||||
{
|
||||
ListenForGameEvent( "physgun_pickup" );
|
||||
}
|
||||
|
||||
void FireGameEvent_Internal( IGameEvent *event )
|
||||
{
|
||||
if ( 0 == Q_strcmp( event->GetName(), "physgun_pickup" ) )
|
||||
{
|
||||
// was the object picked up a frag grenade?
|
||||
CBaseEntity *pEntityPickedUp = UTIL_EntityByIndex( event->GetInt( "entindex" ) );
|
||||
if ( pEntityPickedUp && pEntityPickedUp->ClassMatches( "npc_grenade_frag" ) )
|
||||
{
|
||||
// get the grenade object
|
||||
CBaseGrenade *pGrenade = dynamic_cast<CBaseGrenade *>( pEntityPickedUp );
|
||||
if ( pGrenade )
|
||||
{
|
||||
// was the original thrower a zombine?
|
||||
CBaseEntity *pOriginalThrower = pGrenade->GetOriginalThrower();
|
||||
if ( pOriginalThrower && pOriginalThrower->ClassMatches( "npc_zombine" ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEpXGetZombineGrenade, ACHIEVEMENT_EPX_GET_ZOMBINEGRENADE, "EPX_GET_ZOMBINEGRENADE", 5 );
|
||||
|
||||
class CAchievementEpXKillZombiesWithFlares : public CBaseAchievement
|
||||
{
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
SetFlags( ACH_SAVE_WITH_GAME );
|
||||
SetGoal( 15 );
|
||||
|
||||
if ( IsPC() )
|
||||
{
|
||||
// only in Ep1 for PC. (Shared across EPX for X360.)
|
||||
SetGameDirFilter( "episodic" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ListenForEvents()
|
||||
{
|
||||
ListenForGameEvent( "flare_ignite_npc" );
|
||||
}
|
||||
|
||||
void FireGameEvent_Internal( IGameEvent *event )
|
||||
{
|
||||
if ( 0 == Q_strcmp( event->GetName(), "flare_ignite_npc" ) )
|
||||
{
|
||||
CBaseEntity *pEntityIgnited = UTIL_EntityByIndex( event->GetInt( "entindex" ) );
|
||||
// was it a zombie that got set on fire?
|
||||
if ( pEntityIgnited &&
|
||||
( ( pEntityIgnited->ClassMatches( "npc_zombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_zombine" ) ) ||
|
||||
( pEntityIgnited->ClassMatches( "npc_fastzombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_poisonzombie" ) ) ) )
|
||||
{
|
||||
IncrementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
DECLARE_ACHIEVEMENT( CAchievementEpXKillZombiesWithFlares, ACHIEVEMENT_EPX_KILL_ZOMBIES_WITHFLARES, "EPX_KILL_ZOMBIES_WITHFLARES", 5 );
|
||||
|
||||
#endif // GAME_DLL
|
||||
@@ -1,32 +1,32 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Shared data between client and server side npc_advisor classes.
|
||||
//
|
||||
// Catchphrase: "It's advising us!!!"
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef NPC_ADVISOR_SHARED_H
|
||||
#define NPC_ADVISOR_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// Set this to 0 to disable the advisor's special AI behavior (all that object chucking),
|
||||
// which we did in Ep2 to make him a scripted creature.
|
||||
#define NPC_ADVISOR_HAS_BEHAVIOR 0
|
||||
|
||||
#if NPC_ADVISOR_HAS_BEHAVIOR
|
||||
// Message ID constants used for communciation between client and server.
|
||||
enum
|
||||
{
|
||||
ADVISOR_MSG_START_BEAM = 10,
|
||||
ADVISOR_MSG_STOP_BEAM,
|
||||
ADVISOR_MSG_STOP_ALL_BEAMS,
|
||||
ADVISOR_MSG_START_ELIGHT,
|
||||
ADVISOR_MSG_STOP_ELIGHT,
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // NPC_ADVISOR_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Shared data between client and server side npc_advisor classes.
|
||||
//
|
||||
// Catchphrase: "It's advising us!!!"
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef NPC_ADVISOR_SHARED_H
|
||||
#define NPC_ADVISOR_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// Set this to 0 to disable the advisor's special AI behavior (all that object chucking),
|
||||
// which we did in Ep2 to make him a scripted creature.
|
||||
#define NPC_ADVISOR_HAS_BEHAVIOR 0
|
||||
|
||||
#if NPC_ADVISOR_HAS_BEHAVIOR
|
||||
// Message ID constants used for communciation between client and server.
|
||||
enum
|
||||
{
|
||||
ADVISOR_MSG_START_BEAM = 10,
|
||||
ADVISOR_MSG_STOP_BEAM,
|
||||
ADVISOR_MSG_STOP_ALL_BEAMS,
|
||||
ADVISOR_MSG_START_ELIGHT,
|
||||
ADVISOR_MSG_STOP_ELIGHT,
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // NPC_ADVISOR_SHARED_H
|
||||
|
||||
+250
-250
@@ -1,251 +1,251 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "eventlist.h"
|
||||
#include "stringregistry.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// NOTE: If CStringRegistry allowed storing arbitrary data, we could just use that.
|
||||
// in this case we have the "isPrivate" member and the replacement rules
|
||||
// (eventIndex can be reused by private activities), so a custom table is necessary
|
||||
struct eventlist_t
|
||||
{
|
||||
int eventIndex;
|
||||
int iType;
|
||||
unsigned short stringKey;
|
||||
short isPrivate;
|
||||
};
|
||||
|
||||
CUtlVector<eventlist_t> g_EventList;
|
||||
|
||||
// This stores the actual event names. Also, the string ID in the registry is simply an index
|
||||
// into the g_EventList array.
|
||||
CStringRegistry g_EventStrings;
|
||||
|
||||
// this is just here to accelerate adds
|
||||
static int g_HighestEvent = 0;
|
||||
|
||||
int g_nEventListVersion = 1;
|
||||
|
||||
|
||||
void EventList_Init( void )
|
||||
{
|
||||
g_HighestEvent = 0;
|
||||
}
|
||||
|
||||
void EventList_Free( void )
|
||||
{
|
||||
g_EventStrings.ClearStrings();
|
||||
g_EventList.Purge();
|
||||
|
||||
// So studiohdrs can reindex event indices
|
||||
++g_nEventListVersion;
|
||||
}
|
||||
|
||||
// add a new event to the database
|
||||
eventlist_t *EventList_AddEventEntry( const char *pName, int iEventIndex, bool isPrivate, int iType )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
int index = g_EventList.AddToTail();
|
||||
eventlist_t *pList = &g_EventList[index];
|
||||
pList->eventIndex = iEventIndex;
|
||||
pList->stringKey = g_EventStrings.AddString( pName, index );
|
||||
pList->isPrivate = isPrivate;
|
||||
pList->iType = iType;
|
||||
|
||||
// UNDONE: This implies that ALL shared activities are added before ANY custom activities
|
||||
// UNDONE: Segment these instead? It's a 32-bit int, how many activities do we need?
|
||||
if ( iEventIndex > g_HighestEvent )
|
||||
{
|
||||
g_HighestEvent = iEventIndex;
|
||||
}
|
||||
|
||||
return pList;
|
||||
}
|
||||
|
||||
// get the database entry from a string
|
||||
static eventlist_t *ListFromString( const char *pString )
|
||||
{
|
||||
// just use the string registry to do this search/map
|
||||
int stringID = g_EventStrings.GetStringID( pString );
|
||||
if ( stringID < 0 )
|
||||
return NULL;
|
||||
|
||||
return &g_EventList[stringID];
|
||||
}
|
||||
|
||||
// Get the database entry for an index
|
||||
static eventlist_t *ListFromEvent( int eventIndex )
|
||||
{
|
||||
// ugly linear search
|
||||
for ( int i = 0; i < g_EventList.Size(); i++ )
|
||||
{
|
||||
if ( g_EventList[i].eventIndex == eventIndex )
|
||||
{
|
||||
return &g_EventList[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int EventList_GetEventType( int eventIndex )
|
||||
{
|
||||
eventlist_t *pEvent = ListFromEvent( eventIndex );
|
||||
|
||||
if ( pEvent )
|
||||
{
|
||||
return pEvent->iType;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
bool EventList_RegisterSharedEvent( const char *pszEventName, int iEventIndex, int iType )
|
||||
{
|
||||
// UNDONE: Do we want to do these checks when not in developer mode? or maybe DEBUG only?
|
||||
// They really only matter when you change the list of code controlled activities. IDs
|
||||
// for content controlled activities never collide because they are generated.
|
||||
|
||||
// first, check to make sure the slot we're asking for is free. It must be for
|
||||
// a shared event.
|
||||
eventlist_t *pList = ListFromString( pszEventName );
|
||||
if ( !pList )
|
||||
{
|
||||
pList = ListFromEvent( iEventIndex );
|
||||
}
|
||||
|
||||
//Already in list.
|
||||
if ( pList )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
EventList_AddEventEntry( pszEventName, iEventIndex, false, iType );
|
||||
return true;
|
||||
}
|
||||
|
||||
Animevent EventList_RegisterPrivateEvent( const char *pszEventName )
|
||||
{
|
||||
eventlist_t *pList = ListFromString( pszEventName );
|
||||
if ( pList )
|
||||
{
|
||||
// this activity is already in the list. If the activity we collided with is also private,
|
||||
// then the collision is OK. Otherwise, it's a bug.
|
||||
if ( pList->isPrivate )
|
||||
{
|
||||
return (Animevent)pList->eventIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this private activity collides with a shared activity. That is not allowed.
|
||||
Warning( "***\nShared<->Private Event collision!\n***\n" );
|
||||
Assert(0);
|
||||
return AE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
pList = EventList_AddEventEntry( pszEventName, g_HighestEvent+1, true, AE_TYPE_SERVER );
|
||||
return (Animevent)pList->eventIndex;
|
||||
}
|
||||
|
||||
// Get the index for a given Event name
|
||||
// Done at load time for all models
|
||||
int EventList_IndexForName( const char *pszEventName )
|
||||
{
|
||||
// this is a fast O(lgn) search (actually does 2 O(lgn) searches)
|
||||
eventlist_t *pList = ListFromString( pszEventName );
|
||||
|
||||
if ( pList )
|
||||
{
|
||||
return pList->eventIndex;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the name for a given index
|
||||
// This should only be used in debug code, it does a linear search
|
||||
// But at least it only compares integers
|
||||
const char *EventList_NameForIndex( int eventIndex )
|
||||
{
|
||||
eventlist_t *pList = ListFromEvent( eventIndex );
|
||||
if ( pList )
|
||||
{
|
||||
return g_EventStrings.GetStringForKey( pList->stringKey );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void EventList_RegisterSharedEvents( void )
|
||||
{
|
||||
REGISTER_SHARED_ANIMEVENT( AE_EMPTY, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_LEFTFOOT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_RIGHTFOOT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_BODYDROP_LIGHT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_BODYDROP_HEAVY, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_SWISHSOUND, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_180TURN, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_ITEM_PICKUP, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_DROP, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_SET_SEQUENCE_NAME, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_SET_SEQUENCE_NUMBER, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_SET_ACTIVITY, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_HOLSTER, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_DRAW, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_FIRE, AE_TYPE_SERVER | AE_TYPE_WEAPON );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_PLAYSOUND, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_SV_PLAYSOUND, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_STOPSOUND, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_START_SCRIPTED_EFFECT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_STOP_SCRIPTED_EFFECT, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CLIENT_EFFECT_ATTACH, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_MUZZLEFLASH, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_MUZZLEFLASH, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_THUMPER_THUMP, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_AMMOCRATE_PICKUP_AMMO, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_RAGDOLL, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_ADDGESTURE, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_RESTARTGESTURE, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_ATTACK_BROADCAST, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_HURT_INTERACTION_PARTNER, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_SET_INTERACTION_CANTDIE, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_SV_DUSTTRAIL, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_CREATE_PARTICLE_EFFECT, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_RAGDOLL, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_ENABLE_BODYGROUP, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_DISABLE_BODYGROUP, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_BODYGROUP_SET_VALUE, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_BODYGROUP_SET_VALUE_CMODEL_WPN, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_PRIMARYATTACK, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_INCREMENTAMMO, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_HIDE, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_UNHIDE, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_PLAYWPNSOUND, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "eventlist.h"
|
||||
#include "stringregistry.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// NOTE: If CStringRegistry allowed storing arbitrary data, we could just use that.
|
||||
// in this case we have the "isPrivate" member and the replacement rules
|
||||
// (eventIndex can be reused by private activities), so a custom table is necessary
|
||||
struct eventlist_t
|
||||
{
|
||||
int eventIndex;
|
||||
int iType;
|
||||
unsigned short stringKey;
|
||||
short isPrivate;
|
||||
};
|
||||
|
||||
CUtlVector<eventlist_t> g_EventList;
|
||||
|
||||
// This stores the actual event names. Also, the string ID in the registry is simply an index
|
||||
// into the g_EventList array.
|
||||
CStringRegistry g_EventStrings;
|
||||
|
||||
// this is just here to accelerate adds
|
||||
static int g_HighestEvent = 0;
|
||||
|
||||
int g_nEventListVersion = 1;
|
||||
|
||||
|
||||
void EventList_Init( void )
|
||||
{
|
||||
g_HighestEvent = 0;
|
||||
}
|
||||
|
||||
void EventList_Free( void )
|
||||
{
|
||||
g_EventStrings.ClearStrings();
|
||||
g_EventList.Purge();
|
||||
|
||||
// So studiohdrs can reindex event indices
|
||||
++g_nEventListVersion;
|
||||
}
|
||||
|
||||
// add a new event to the database
|
||||
eventlist_t *EventList_AddEventEntry( const char *pName, int iEventIndex, bool isPrivate, int iType )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
int index = g_EventList.AddToTail();
|
||||
eventlist_t *pList = &g_EventList[index];
|
||||
pList->eventIndex = iEventIndex;
|
||||
pList->stringKey = g_EventStrings.AddString( pName, index );
|
||||
pList->isPrivate = isPrivate;
|
||||
pList->iType = iType;
|
||||
|
||||
// UNDONE: This implies that ALL shared activities are added before ANY custom activities
|
||||
// UNDONE: Segment these instead? It's a 32-bit int, how many activities do we need?
|
||||
if ( iEventIndex > g_HighestEvent )
|
||||
{
|
||||
g_HighestEvent = iEventIndex;
|
||||
}
|
||||
|
||||
return pList;
|
||||
}
|
||||
|
||||
// get the database entry from a string
|
||||
static eventlist_t *ListFromString( const char *pString )
|
||||
{
|
||||
// just use the string registry to do this search/map
|
||||
int stringID = g_EventStrings.GetStringID( pString );
|
||||
if ( stringID < 0 )
|
||||
return NULL;
|
||||
|
||||
return &g_EventList[stringID];
|
||||
}
|
||||
|
||||
// Get the database entry for an index
|
||||
static eventlist_t *ListFromEvent( int eventIndex )
|
||||
{
|
||||
// ugly linear search
|
||||
for ( int i = 0; i < g_EventList.Size(); i++ )
|
||||
{
|
||||
if ( g_EventList[i].eventIndex == eventIndex )
|
||||
{
|
||||
return &g_EventList[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int EventList_GetEventType( int eventIndex )
|
||||
{
|
||||
eventlist_t *pEvent = ListFromEvent( eventIndex );
|
||||
|
||||
if ( pEvent )
|
||||
{
|
||||
return pEvent->iType;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
bool EventList_RegisterSharedEvent( const char *pszEventName, int iEventIndex, int iType )
|
||||
{
|
||||
// UNDONE: Do we want to do these checks when not in developer mode? or maybe DEBUG only?
|
||||
// They really only matter when you change the list of code controlled activities. IDs
|
||||
// for content controlled activities never collide because they are generated.
|
||||
|
||||
// first, check to make sure the slot we're asking for is free. It must be for
|
||||
// a shared event.
|
||||
eventlist_t *pList = ListFromString( pszEventName );
|
||||
if ( !pList )
|
||||
{
|
||||
pList = ListFromEvent( iEventIndex );
|
||||
}
|
||||
|
||||
//Already in list.
|
||||
if ( pList )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
EventList_AddEventEntry( pszEventName, iEventIndex, false, iType );
|
||||
return true;
|
||||
}
|
||||
|
||||
Animevent EventList_RegisterPrivateEvent( const char *pszEventName )
|
||||
{
|
||||
eventlist_t *pList = ListFromString( pszEventName );
|
||||
if ( pList )
|
||||
{
|
||||
// this activity is already in the list. If the activity we collided with is also private,
|
||||
// then the collision is OK. Otherwise, it's a bug.
|
||||
if ( pList->isPrivate )
|
||||
{
|
||||
return (Animevent)pList->eventIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this private activity collides with a shared activity. That is not allowed.
|
||||
Warning( "***\nShared<->Private Event collision!\n***\n" );
|
||||
Assert(0);
|
||||
return AE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
pList = EventList_AddEventEntry( pszEventName, g_HighestEvent+1, true, AE_TYPE_SERVER );
|
||||
return (Animevent)pList->eventIndex;
|
||||
}
|
||||
|
||||
// Get the index for a given Event name
|
||||
// Done at load time for all models
|
||||
int EventList_IndexForName( const char *pszEventName )
|
||||
{
|
||||
// this is a fast O(lgn) search (actually does 2 O(lgn) searches)
|
||||
eventlist_t *pList = ListFromString( pszEventName );
|
||||
|
||||
if ( pList )
|
||||
{
|
||||
return pList->eventIndex;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the name for a given index
|
||||
// This should only be used in debug code, it does a linear search
|
||||
// But at least it only compares integers
|
||||
const char *EventList_NameForIndex( int eventIndex )
|
||||
{
|
||||
eventlist_t *pList = ListFromEvent( eventIndex );
|
||||
if ( pList )
|
||||
{
|
||||
return g_EventStrings.GetStringForKey( pList->stringKey );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void EventList_RegisterSharedEvents( void )
|
||||
{
|
||||
REGISTER_SHARED_ANIMEVENT( AE_EMPTY, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_LEFTFOOT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_RIGHTFOOT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_BODYDROP_LIGHT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_BODYDROP_HEAVY, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_SWISHSOUND, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_180TURN, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_ITEM_PICKUP, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_DROP, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_SET_SEQUENCE_NAME, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_SET_SEQUENCE_NUMBER, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_SET_ACTIVITY, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_HOLSTER, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_DRAW, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_WEAPON_FIRE, AE_TYPE_SERVER | AE_TYPE_WEAPON );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_PLAYSOUND, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_SV_PLAYSOUND, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_STOPSOUND, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_START_SCRIPTED_EFFECT, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_STOP_SCRIPTED_EFFECT, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CLIENT_EFFECT_ATTACH, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_MUZZLEFLASH, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_MUZZLEFLASH, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_THUMPER_THUMP, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_AMMOCRATE_PICKUP_AMMO, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_RAGDOLL, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_ADDGESTURE, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_RESTARTGESTURE, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_ATTACK_BROADCAST, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_HURT_INTERACTION_PARTNER, AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_NPC_SET_INTERACTION_CANTDIE, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_SV_DUSTTRAIL, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_CREATE_PARTICLE_EFFECT, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_RAGDOLL, AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_ENABLE_BODYGROUP, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_DISABLE_BODYGROUP, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_BODYGROUP_SET_VALUE, AE_TYPE_CLIENT );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_CL_BODYGROUP_SET_VALUE_CMODEL_WPN, AE_TYPE_CLIENT );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_PRIMARYATTACK, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_INCREMENTAMMO, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_HIDE, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_UNHIDE, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
|
||||
REGISTER_SHARED_ANIMEVENT( AE_WPN_PLAYWPNSOUND, AE_TYPE_CLIENT | AE_TYPE_SERVER );
|
||||
}
|
||||
+115
-115
@@ -1,115 +1,115 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTLIST_H
|
||||
#define EVENTLIST_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define AE_TYPE_SERVER ( 1 << 0 )
|
||||
#define AE_TYPE_SCRIPTED ( 1 << 1 ) // see scriptevent.h
|
||||
#define AE_TYPE_SHARED ( 1 << 2 )
|
||||
#define AE_TYPE_WEAPON ( 1 << 3 )
|
||||
#define AE_TYPE_CLIENT ( 1 << 4 )
|
||||
#define AE_TYPE_FACEPOSER ( 1 << 5 )
|
||||
|
||||
#define AE_TYPE_NEWEVENTSYSTEM ( 1 << 10 ) //Temporary flag.
|
||||
|
||||
#define AE_NOT_AVAILABLE -1
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AE_INVALID = -1, // So we have something more succint to check for than '-1'
|
||||
AE_EMPTY,
|
||||
AE_NPC_LEFTFOOT, // #define NPC_EVENT_LEFTFOOT 2050
|
||||
AE_NPC_RIGHTFOOT, // #define NPC_EVENT_RIGHTFOOT 2051
|
||||
AE_NPC_BODYDROP_LIGHT, //#define NPC_EVENT_BODYDROP_LIGHT 2001
|
||||
AE_NPC_BODYDROP_HEAVY, //#define NPC_EVENT_BODYDROP_HEAVY 2002
|
||||
AE_NPC_SWISHSOUND, //#define NPC_EVENT_SWISHSOUND 2010
|
||||
AE_NPC_180TURN, //#define NPC_EVENT_180TURN 2020
|
||||
AE_NPC_ITEM_PICKUP, //#define NPC_EVENT_ITEM_PICKUP 2040
|
||||
AE_NPC_WEAPON_DROP, //#define NPC_EVENT_WEAPON_DROP 2041
|
||||
AE_NPC_WEAPON_SET_SEQUENCE_NAME, //#define NPC_EVENT_WEAPON_SET_SEQUENCE_NAME 2042
|
||||
AE_NPC_WEAPON_SET_SEQUENCE_NUMBER, //#define NPC_EVENT_WEAPON_SET_SEQUENCE_NUMBER 2043
|
||||
AE_NPC_WEAPON_SET_ACTIVITY, //#define NPC_EVENT_WEAPON_SET_ACTIVITY 2044
|
||||
AE_NPC_HOLSTER,
|
||||
AE_NPC_DRAW,
|
||||
AE_NPC_WEAPON_FIRE,
|
||||
|
||||
AE_CL_PLAYSOUND, // #define CL_EVENT_SOUND 5004 // Emit a sound
|
||||
AE_SV_PLAYSOUND,
|
||||
AE_CL_STOPSOUND,
|
||||
|
||||
AE_START_SCRIPTED_EFFECT,
|
||||
AE_STOP_SCRIPTED_EFFECT,
|
||||
|
||||
AE_CLIENT_EFFECT_ATTACH,
|
||||
|
||||
AE_MUZZLEFLASH, // Muzzle flash from weapons held by the player
|
||||
AE_NPC_MUZZLEFLASH, // Muzzle flash from weapons held by NPCs
|
||||
|
||||
AE_THUMPER_THUMP, //Thumper Thump!
|
||||
AE_AMMOCRATE_PICKUP_AMMO, //Ammo crate pick up ammo!
|
||||
|
||||
AE_NPC_RAGDOLL,
|
||||
|
||||
AE_NPC_ADDGESTURE,
|
||||
AE_NPC_RESTARTGESTURE,
|
||||
|
||||
AE_NPC_ATTACK_BROADCAST,
|
||||
|
||||
AE_NPC_HURT_INTERACTION_PARTNER,
|
||||
AE_NPC_SET_INTERACTION_CANTDIE,
|
||||
|
||||
AE_SV_DUSTTRAIL,
|
||||
|
||||
AE_CL_CREATE_PARTICLE_EFFECT,
|
||||
|
||||
AE_RAGDOLL,
|
||||
|
||||
AE_CL_ENABLE_BODYGROUP,
|
||||
AE_CL_DISABLE_BODYGROUP,
|
||||
AE_CL_BODYGROUP_SET_VALUE,
|
||||
AE_CL_BODYGROUP_SET_VALUE_CMODEL_WPN,
|
||||
|
||||
AE_WPN_PRIMARYATTACK, // Used by weapons that want their primary attack to occur during an attack anim (i.e. grenade throwing)
|
||||
AE_WPN_INCREMENTAMMO,
|
||||
|
||||
AE_WPN_HIDE, // Used to hide player weapons
|
||||
AE_WPN_UNHIDE, // Used to unhide player weapons
|
||||
|
||||
AE_WPN_PLAYWPNSOUND, // Play a weapon sound from the weapon script file
|
||||
|
||||
LAST_SHARED_ANIMEVENT,
|
||||
} Animevent;
|
||||
|
||||
|
||||
typedef struct evententry_s evententry_t;
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
extern void EventList_Init( void );
|
||||
extern void EventList_Free( void );
|
||||
extern bool EventList_RegisterSharedEvent( const char *pszEventName, int iEventIndex, int iType = 0 );
|
||||
extern Animevent EventList_RegisterPrivateEvent( const char *pszEventName );
|
||||
extern int EventList_IndexForName( const char *pszEventName );
|
||||
extern const char *EventList_NameForIndex( int iEventIndex );
|
||||
Animevent EventList_RegisterPrivateEvent( const char *pszEventName );
|
||||
|
||||
// This macro guarantees that the names of each event and the constant used to
|
||||
// reference it in the code are identical.
|
||||
#define REGISTER_SHARED_ANIMEVENT( _n, b ) EventList_RegisterSharedEvent(#_n, _n, b );
|
||||
#define REGISTER_PRIVATE_ANIMEVENT( _n ) _n = EventList_RegisterPrivateEvent( #_n );
|
||||
|
||||
// Implemented in shared code
|
||||
extern void EventList_RegisterSharedEvents( void );
|
||||
extern int EventList_GetEventType( int eventIndex );
|
||||
|
||||
|
||||
|
||||
#endif // EVENTLIST_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTLIST_H
|
||||
#define EVENTLIST_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define AE_TYPE_SERVER ( 1 << 0 )
|
||||
#define AE_TYPE_SCRIPTED ( 1 << 1 ) // see scriptevent.h
|
||||
#define AE_TYPE_SHARED ( 1 << 2 )
|
||||
#define AE_TYPE_WEAPON ( 1 << 3 )
|
||||
#define AE_TYPE_CLIENT ( 1 << 4 )
|
||||
#define AE_TYPE_FACEPOSER ( 1 << 5 )
|
||||
|
||||
#define AE_TYPE_NEWEVENTSYSTEM ( 1 << 10 ) //Temporary flag.
|
||||
|
||||
#define AE_NOT_AVAILABLE -1
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AE_INVALID = -1, // So we have something more succint to check for than '-1'
|
||||
AE_EMPTY,
|
||||
AE_NPC_LEFTFOOT, // #define NPC_EVENT_LEFTFOOT 2050
|
||||
AE_NPC_RIGHTFOOT, // #define NPC_EVENT_RIGHTFOOT 2051
|
||||
AE_NPC_BODYDROP_LIGHT, //#define NPC_EVENT_BODYDROP_LIGHT 2001
|
||||
AE_NPC_BODYDROP_HEAVY, //#define NPC_EVENT_BODYDROP_HEAVY 2002
|
||||
AE_NPC_SWISHSOUND, //#define NPC_EVENT_SWISHSOUND 2010
|
||||
AE_NPC_180TURN, //#define NPC_EVENT_180TURN 2020
|
||||
AE_NPC_ITEM_PICKUP, //#define NPC_EVENT_ITEM_PICKUP 2040
|
||||
AE_NPC_WEAPON_DROP, //#define NPC_EVENT_WEAPON_DROP 2041
|
||||
AE_NPC_WEAPON_SET_SEQUENCE_NAME, //#define NPC_EVENT_WEAPON_SET_SEQUENCE_NAME 2042
|
||||
AE_NPC_WEAPON_SET_SEQUENCE_NUMBER, //#define NPC_EVENT_WEAPON_SET_SEQUENCE_NUMBER 2043
|
||||
AE_NPC_WEAPON_SET_ACTIVITY, //#define NPC_EVENT_WEAPON_SET_ACTIVITY 2044
|
||||
AE_NPC_HOLSTER,
|
||||
AE_NPC_DRAW,
|
||||
AE_NPC_WEAPON_FIRE,
|
||||
|
||||
AE_CL_PLAYSOUND, // #define CL_EVENT_SOUND 5004 // Emit a sound
|
||||
AE_SV_PLAYSOUND,
|
||||
AE_CL_STOPSOUND,
|
||||
|
||||
AE_START_SCRIPTED_EFFECT,
|
||||
AE_STOP_SCRIPTED_EFFECT,
|
||||
|
||||
AE_CLIENT_EFFECT_ATTACH,
|
||||
|
||||
AE_MUZZLEFLASH, // Muzzle flash from weapons held by the player
|
||||
AE_NPC_MUZZLEFLASH, // Muzzle flash from weapons held by NPCs
|
||||
|
||||
AE_THUMPER_THUMP, //Thumper Thump!
|
||||
AE_AMMOCRATE_PICKUP_AMMO, //Ammo crate pick up ammo!
|
||||
|
||||
AE_NPC_RAGDOLL,
|
||||
|
||||
AE_NPC_ADDGESTURE,
|
||||
AE_NPC_RESTARTGESTURE,
|
||||
|
||||
AE_NPC_ATTACK_BROADCAST,
|
||||
|
||||
AE_NPC_HURT_INTERACTION_PARTNER,
|
||||
AE_NPC_SET_INTERACTION_CANTDIE,
|
||||
|
||||
AE_SV_DUSTTRAIL,
|
||||
|
||||
AE_CL_CREATE_PARTICLE_EFFECT,
|
||||
|
||||
AE_RAGDOLL,
|
||||
|
||||
AE_CL_ENABLE_BODYGROUP,
|
||||
AE_CL_DISABLE_BODYGROUP,
|
||||
AE_CL_BODYGROUP_SET_VALUE,
|
||||
AE_CL_BODYGROUP_SET_VALUE_CMODEL_WPN,
|
||||
|
||||
AE_WPN_PRIMARYATTACK, // Used by weapons that want their primary attack to occur during an attack anim (i.e. grenade throwing)
|
||||
AE_WPN_INCREMENTAMMO,
|
||||
|
||||
AE_WPN_HIDE, // Used to hide player weapons
|
||||
AE_WPN_UNHIDE, // Used to unhide player weapons
|
||||
|
||||
AE_WPN_PLAYWPNSOUND, // Play a weapon sound from the weapon script file
|
||||
|
||||
LAST_SHARED_ANIMEVENT,
|
||||
} Animevent;
|
||||
|
||||
|
||||
typedef struct evententry_s evententry_t;
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
extern void EventList_Init( void );
|
||||
extern void EventList_Free( void );
|
||||
extern bool EventList_RegisterSharedEvent( const char *pszEventName, int iEventIndex, int iType = 0 );
|
||||
extern Animevent EventList_RegisterPrivateEvent( const char *pszEventName );
|
||||
extern int EventList_IndexForName( const char *pszEventName );
|
||||
extern const char *EventList_NameForIndex( int iEventIndex );
|
||||
Animevent EventList_RegisterPrivateEvent( const char *pszEventName );
|
||||
|
||||
// This macro guarantees that the names of each event and the constant used to
|
||||
// reference it in the code are identical.
|
||||
#define REGISTER_SHARED_ANIMEVENT( _n, b ) EventList_RegisterSharedEvent(#_n, _n, b );
|
||||
#define REGISTER_PRIVATE_ANIMEVENT( _n ) _n = EventList_RegisterPrivateEvent( #_n );
|
||||
|
||||
// Implemented in shared code
|
||||
extern void EventList_RegisterSharedEvents( void );
|
||||
extern int EventList_GetEventType( int eventIndex );
|
||||
|
||||
|
||||
|
||||
#endif // EVENTLIST_H
|
||||
|
||||
@@ -1,141 +1,141 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EXPRESSIONSAMPLE_H
|
||||
#define EXPRESSIONSAMPLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "interpolatortypes.h"
|
||||
|
||||
class CUtlBuffer;
|
||||
class ISceneTokenProcessor;
|
||||
class IChoreoStringPool;
|
||||
|
||||
#pragma pack(1)
|
||||
struct EdgeInfo_t
|
||||
{
|
||||
EdgeInfo_t() :
|
||||
m_bActive( false ),
|
||||
m_CurveType( CURVE_DEFAULT ),
|
||||
m_flZeroPos( 0.0f )
|
||||
{
|
||||
}
|
||||
|
||||
bool m_bActive;
|
||||
unsigned short m_CurveType;
|
||||
float m_flZeroPos;
|
||||
};
|
||||
|
||||
struct CExpressionSample
|
||||
{
|
||||
CExpressionSample() :
|
||||
value( 0.0f ),
|
||||
time( 0.0f )
|
||||
{
|
||||
selected = 0;
|
||||
m_curvetype = CURVE_DEFAULT;
|
||||
}
|
||||
|
||||
void SetCurveType( int curveType )
|
||||
{
|
||||
m_curvetype = curveType;
|
||||
}
|
||||
|
||||
int GetCurveType() const
|
||||
{
|
||||
return m_curvetype;
|
||||
}
|
||||
|
||||
// Height
|
||||
float value;
|
||||
// time from start of event
|
||||
float time;
|
||||
|
||||
unsigned short selected : 1;
|
||||
private:
|
||||
unsigned short m_curvetype : 15;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Provides generic access to scene or event ramp data
|
||||
//-----------------------------------------------------------------------------
|
||||
class ICurveDataAccessor
|
||||
{
|
||||
public:
|
||||
virtual float GetDuration() = 0;
|
||||
virtual bool CurveHasEndTime() = 0; // only matters for events
|
||||
virtual int GetDefaultCurveType() = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The generic curve data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CCurveData
|
||||
{
|
||||
public:
|
||||
int GetCount( void );
|
||||
CExpressionSample *Get( int index );
|
||||
CExpressionSample *Add( float time, float value, bool selected );
|
||||
void Delete( int index );
|
||||
void Clear( void );
|
||||
void Resort( ICurveDataAccessor *data );
|
||||
|
||||
EdgeInfo_t *GetEdgeInfo( int idx );
|
||||
|
||||
void SetEdgeInfo( bool leftEdge, int curveType, float zero );
|
||||
void GetEdgeInfo( bool leftEdge, int& curveType, float& zero ) const;
|
||||
void SetEdgeActive( bool leftEdge, bool state );
|
||||
bool IsEdgeActive( bool leftEdge ) const;
|
||||
int GetEdgeCurveType( bool leftEdge ) const;
|
||||
float GetEdgeZeroValue( bool leftEdge ) const;
|
||||
void RemoveOutOfRangeSamples( ICurveDataAccessor *data );
|
||||
|
||||
void SaveToBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool );
|
||||
|
||||
void Parse( ISceneTokenProcessor *tokenizer, ICurveDataAccessor *data );
|
||||
void FileSave( CUtlBuffer& buf, int level, const char *name );
|
||||
|
||||
float GetIntensity( ICurveDataAccessor *data, float time );
|
||||
CExpressionSample *GetBoundedSample( ICurveDataAccessor *data, int number, bool& bClamped );
|
||||
|
||||
CCurveData & operator = (const CCurveData &src)
|
||||
{
|
||||
// Copy ramp over
|
||||
m_Ramp.RemoveAll();
|
||||
int i;
|
||||
for ( i = 0; i < src.m_Ramp.Count(); i++ )
|
||||
{
|
||||
CExpressionSample sample = src.m_Ramp[ i ];
|
||||
CExpressionSample *newSample = Add( sample.time, sample.value, sample.selected );
|
||||
newSample->SetCurveType( sample.GetCurveType() );
|
||||
}
|
||||
m_RampEdgeInfo[ 0 ] = src.m_RampEdgeInfo[ 0 ];
|
||||
m_RampEdgeInfo[ 1 ] = src.m_RampEdgeInfo[ 1 ];
|
||||
|
||||
return *this;
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
CUtlVector< CExpressionSample > m_Ramp;
|
||||
EdgeInfo_t m_RampEdgeInfo[ 2 ];
|
||||
|
||||
public:
|
||||
float GetIntensityArea( ICurveDataAccessor *data, float time );
|
||||
|
||||
private:
|
||||
void UpdateIntensityArea( ICurveDataAccessor *data );
|
||||
CUtlVector< float > m_RampAccumulator;
|
||||
};
|
||||
|
||||
|
||||
#endif // EXPRESSIONSAMPLE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EXPRESSIONSAMPLE_H
|
||||
#define EXPRESSIONSAMPLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "interpolatortypes.h"
|
||||
|
||||
class CUtlBuffer;
|
||||
class ISceneTokenProcessor;
|
||||
class IChoreoStringPool;
|
||||
|
||||
#pragma pack(1)
|
||||
struct EdgeInfo_t
|
||||
{
|
||||
EdgeInfo_t() :
|
||||
m_bActive( false ),
|
||||
m_CurveType( CURVE_DEFAULT ),
|
||||
m_flZeroPos( 0.0f )
|
||||
{
|
||||
}
|
||||
|
||||
bool m_bActive;
|
||||
unsigned short m_CurveType;
|
||||
float m_flZeroPos;
|
||||
};
|
||||
|
||||
struct CExpressionSample
|
||||
{
|
||||
CExpressionSample() :
|
||||
value( 0.0f ),
|
||||
time( 0.0f )
|
||||
{
|
||||
selected = 0;
|
||||
m_curvetype = CURVE_DEFAULT;
|
||||
}
|
||||
|
||||
void SetCurveType( int curveType )
|
||||
{
|
||||
m_curvetype = curveType;
|
||||
}
|
||||
|
||||
int GetCurveType() const
|
||||
{
|
||||
return m_curvetype;
|
||||
}
|
||||
|
||||
// Height
|
||||
float value;
|
||||
// time from start of event
|
||||
float time;
|
||||
|
||||
unsigned short selected : 1;
|
||||
private:
|
||||
unsigned short m_curvetype : 15;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Provides generic access to scene or event ramp data
|
||||
//-----------------------------------------------------------------------------
|
||||
class ICurveDataAccessor
|
||||
{
|
||||
public:
|
||||
virtual float GetDuration() = 0;
|
||||
virtual bool CurveHasEndTime() = 0; // only matters for events
|
||||
virtual int GetDefaultCurveType() = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The generic curve data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CCurveData
|
||||
{
|
||||
public:
|
||||
int GetCount( void );
|
||||
CExpressionSample *Get( int index );
|
||||
CExpressionSample *Add( float time, float value, bool selected );
|
||||
void Delete( int index );
|
||||
void Clear( void );
|
||||
void Resort( ICurveDataAccessor *data );
|
||||
|
||||
EdgeInfo_t *GetEdgeInfo( int idx );
|
||||
|
||||
void SetEdgeInfo( bool leftEdge, int curveType, float zero );
|
||||
void GetEdgeInfo( bool leftEdge, int& curveType, float& zero ) const;
|
||||
void SetEdgeActive( bool leftEdge, bool state );
|
||||
bool IsEdgeActive( bool leftEdge ) const;
|
||||
int GetEdgeCurveType( bool leftEdge ) const;
|
||||
float GetEdgeZeroValue( bool leftEdge ) const;
|
||||
void RemoveOutOfRangeSamples( ICurveDataAccessor *data );
|
||||
|
||||
void SaveToBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool );
|
||||
bool RestoreFromBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool );
|
||||
|
||||
void Parse( ISceneTokenProcessor *tokenizer, ICurveDataAccessor *data );
|
||||
void FileSave( CUtlBuffer& buf, int level, const char *name );
|
||||
|
||||
float GetIntensity( ICurveDataAccessor *data, float time );
|
||||
CExpressionSample *GetBoundedSample( ICurveDataAccessor *data, int number, bool& bClamped );
|
||||
|
||||
CCurveData & operator = (const CCurveData &src)
|
||||
{
|
||||
// Copy ramp over
|
||||
m_Ramp.RemoveAll();
|
||||
int i;
|
||||
for ( i = 0; i < src.m_Ramp.Count(); i++ )
|
||||
{
|
||||
CExpressionSample sample = src.m_Ramp[ i ];
|
||||
CExpressionSample *newSample = Add( sample.time, sample.value, sample.selected );
|
||||
newSample->SetCurveType( sample.GetCurveType() );
|
||||
}
|
||||
m_RampEdgeInfo[ 0 ] = src.m_RampEdgeInfo[ 0 ];
|
||||
m_RampEdgeInfo[ 1 ] = src.m_RampEdgeInfo[ 1 ];
|
||||
|
||||
return *this;
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
CUtlVector< CExpressionSample > m_Ramp;
|
||||
EdgeInfo_t m_RampEdgeInfo[ 2 ];
|
||||
|
||||
public:
|
||||
float GetIntensityArea( ICurveDataAccessor *data, float time );
|
||||
|
||||
private:
|
||||
void UpdateIntensityArea( ICurveDataAccessor *data );
|
||||
CUtlVector< float > m_RampAccumulator;
|
||||
};
|
||||
|
||||
|
||||
#endif // EXPRESSIONSAMPLE_H
|
||||
|
||||
@@ -1,71 +1,71 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef FORCEFEEDBACK_H
|
||||
#define FORCEFEEDBACK_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FFMSG_START = 0,
|
||||
FFMSG_STOP,
|
||||
FFMSG_STOPALL,
|
||||
FFMSG_PAUSE,
|
||||
FFMSG_RESUME
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FORCE_FEEDBACK_SHOT_SINGLE,
|
||||
FORCE_FEEDBACK_SHOT_DOUBLE,
|
||||
|
||||
FORCE_FEEDBACK_TAKEDAMAGE,
|
||||
|
||||
FORCE_FEEDBACK_SCREENSHAKE,
|
||||
|
||||
FORCE_FEEDBACK_SKIDDING,
|
||||
FORCE_FEEDBACK_BREAKING,
|
||||
|
||||
NUM_FORCE_FEEDBACK_PRESETS
|
||||
} FORCEFEEDBACK_t;
|
||||
|
||||
class CBasePlayer;
|
||||
|
||||
struct FFBaseParams_t
|
||||
{
|
||||
FFBaseParams_t() :
|
||||
m_flDirection( 0.0f ),
|
||||
m_flDuration( 0.0f ),
|
||||
m_flGain( 1.0f ),
|
||||
m_nPriority( 0 ),
|
||||
m_bSolo( false )
|
||||
{
|
||||
}
|
||||
|
||||
float m_flDirection; // yaw
|
||||
float m_flDuration; // seconds (-1 == INFINITE, 0.0 == use duration from .ffe file)
|
||||
float m_flGain; // 0 -> 1 global scale
|
||||
int m_nPriority; // Higher is more important
|
||||
bool m_bSolo; // Temporarily suppress all other FF effects while playing
|
||||
};
|
||||
|
||||
abstract_class IForceFeedback
|
||||
{
|
||||
public:
|
||||
// API
|
||||
virtual void StopAllEffects( CBasePlayer *player ) = 0;
|
||||
virtual void StopEffect( CBasePlayer *player, FORCEFEEDBACK_t effect ) = 0;
|
||||
virtual void StartEffect( CBasePlayer *player, FORCEFEEDBACK_t effect, const FFBaseParams_t& params ) = 0;
|
||||
|
||||
virtual void PauseAll( CBasePlayer *player ) = 0;
|
||||
virtual void ResumeAll( CBasePlayer *player ) = 0;
|
||||
};
|
||||
|
||||
extern IForceFeedback *forcefeedback;
|
||||
|
||||
#endif // FORCEFEEDBACK_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef FORCEFEEDBACK_H
|
||||
#define FORCEFEEDBACK_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FFMSG_START = 0,
|
||||
FFMSG_STOP,
|
||||
FFMSG_STOPALL,
|
||||
FFMSG_PAUSE,
|
||||
FFMSG_RESUME
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FORCE_FEEDBACK_SHOT_SINGLE,
|
||||
FORCE_FEEDBACK_SHOT_DOUBLE,
|
||||
|
||||
FORCE_FEEDBACK_TAKEDAMAGE,
|
||||
|
||||
FORCE_FEEDBACK_SCREENSHAKE,
|
||||
|
||||
FORCE_FEEDBACK_SKIDDING,
|
||||
FORCE_FEEDBACK_BREAKING,
|
||||
|
||||
NUM_FORCE_FEEDBACK_PRESETS
|
||||
} FORCEFEEDBACK_t;
|
||||
|
||||
class CBasePlayer;
|
||||
|
||||
struct FFBaseParams_t
|
||||
{
|
||||
FFBaseParams_t() :
|
||||
m_flDirection( 0.0f ),
|
||||
m_flDuration( 0.0f ),
|
||||
m_flGain( 1.0f ),
|
||||
m_nPriority( 0 ),
|
||||
m_bSolo( false )
|
||||
{
|
||||
}
|
||||
|
||||
float m_flDirection; // yaw
|
||||
float m_flDuration; // seconds (-1 == INFINITE, 0.0 == use duration from .ffe file)
|
||||
float m_flGain; // 0 -> 1 global scale
|
||||
int m_nPriority; // Higher is more important
|
||||
bool m_bSolo; // Temporarily suppress all other FF effects while playing
|
||||
};
|
||||
|
||||
abstract_class IForceFeedback
|
||||
{
|
||||
public:
|
||||
// API
|
||||
virtual void StopAllEffects( CBasePlayer *player ) = 0;
|
||||
virtual void StopEffect( CBasePlayer *player, FORCEFEEDBACK_t effect ) = 0;
|
||||
virtual void StartEffect( CBasePlayer *player, FORCEFEEDBACK_t effect, const FFBaseParams_t& params ) = 0;
|
||||
|
||||
virtual void PauseAll( CBasePlayer *player ) = 0;
|
||||
virtual void ResumeAll( CBasePlayer *player ) = 0;
|
||||
};
|
||||
|
||||
extern IForceFeedback *forcefeedback;
|
||||
|
||||
#endif // FORCEFEEDBACK_H
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FUNC_DUST_SHARED_H
|
||||
#define FUNC_DUST_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// Flags for m_DustFlags.
|
||||
#define DUSTFLAGS_ON (1<<0) // emit particles..
|
||||
#define DUSTFLAGS_SCALEMOTES (1<<1) // scale to keep the same size on screen
|
||||
#define DUSTFLAGS_FROZEN (1<<2) // just emit m_SpawnRate # of particles and freeze
|
||||
#define DUST_NUMFLAGS 3
|
||||
|
||||
|
||||
#endif // FUNC_DUST_SHARED_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FUNC_DUST_SHARED_H
|
||||
#define FUNC_DUST_SHARED_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// Flags for m_DustFlags.
|
||||
#define DUSTFLAGS_ON (1<<0) // emit particles..
|
||||
#define DUSTFLAGS_SCALEMOTES (1<<1) // scale to keep the same size on screen
|
||||
#define DUSTFLAGS_FROZEN (1<<2) // just emit m_SpawnRate # of particles and freeze
|
||||
#define DUST_NUMFLAGS 3
|
||||
|
||||
|
||||
#endif // FUNC_DUST_SHARED_H
|
||||
|
||||
+512
-512
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user