Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef PROP_SFR_VEHICLE
- #define PROP_SFR_VEHICLE
- /*
- prop_sfr_vehicle.h
- */
- #include "props.h"
- #include "props_shared.h"
- #include "iservervehicle.h"
- #include "vehicle_baseserver.h"
- #include "vehicle_viewblend_shared.h"
- class CPropSFRVehicle : public CBaseAnimating/*CPhysicsPropMultiplayer*/, public IDrivableVehicle, public CBaseServerVehicle
- {
- DECLARE_CLASS( CPropSFRVehicle, CBaseAnimating/*CPhysicsPropMultiplayer*/ );
- public:
- DECLARE_DATADESC();
- DECLARE_NETWORKCLASS();
- CPropSFRVehicle();
- virtual ~CPropSFRVehicle();
- //HACK
- CPropSFRVehicle *GetDriveableVehicle(){return this;}
- // CBaseEntity
- virtual void Precache( void );
- virtual void Spawn( void );
- virtual void Think( void );
- virtual bool ShouldThink() { return ( GetDriver() != NULL ); }
- virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
- virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE; };
- virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
- virtual void Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info );
- virtual IServerVehicle* GetServerVehicle() { return this; }
- //Vehicle Stuff
- Vector GetSmoothedVelocity( void ); //Save and update our smoothed velocity for prediction
- // Driving
- void DriveVehicle( CBasePlayer *pPlayer, CUserCmd *ucmd ); // Player driving entrypoint
- virtual void DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iButtonsDown, int iButtonsReleased ); // Driving Button handling
- virtual void ResetControls();
- // Engine handling
- virtual void StartEngine( void );
- virtual void StopEngine( void );
- virtual bool IsEngineOn( void );
- //State
- virtual void TurnOn();
- virtual void TurnOff();
- virtual bool IsOn(){return m_bIsOn;}
- // IDrivableVehicle
- public:
- virtual CBaseEntity *GetDriver( void );
- /*
- psy:
- I had to reimplement these here and neglect the parent class's because the parent class's re-call
- these method through the "GetDriveableVehicle" method and create an infinite recursive loop.
- */
- virtual void ItemPostFrame( CBasePlayer *pPlayer );
- virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData );
- virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
- virtual void FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move ) {}
- virtual bool CanEnterVehicle( CBaseEntity *pEntity );
- virtual bool CanExitVehicle( CBaseEntity *pEntity );
- virtual void EnterVehicle( CBaseCombatCharacter *pPassenger );
- virtual bool AllowBlockedExit( CBaseCombatCharacter *pPassenger, int nRole ) { return true; }
- virtual bool AllowMidairExit( CBaseCombatCharacter *pPassenger, int nRole ) { return false; }
- virtual void PreExitVehicle( CBaseCombatCharacter *pPassenger, int nRole ) {}
- virtual void ExitVehicle( int nRole );
- virtual string_t GetVehicleScriptName() { return m_vehicleScript; }
- virtual bool PassengerShouldReceiveDamage( CTakeDamageInfo &info ) { return false; }
- //Deprecated because handles only one passenger
- virtual void SetVehicleEntryAnim( bool bOn ) {ASSERT(false);}
- virtual void SetVehicleExitAnim( bool bOn, Vector vecEyeExitEndpoint ) {ASSERT(false);}
- // CPropSFRVehicle
- void InputEnterVehicleImmediate( inputdata_t &inputdata );
- private:
- void ResetUseKey( CBasePlayer *pPlayer );
- protected:
- float m_flTimeLastEnterExit;
- Vector m_vecSmoothedVelocity;
- CNetworkHandle( CBasePlayer, m_hPlayer );
- string_t m_vehicleScript;
- //State
- CNetworkVar(bool, m_bIsOn);
- COutputEvent m_playerOn;
- COutputEvent m_playerOff;
- };
- class CPropSFRVehicleWithViewSmoothing : public CPropSFRVehicle
- {
- public:
- DECLARE_CLASS( CPropSFRVehicleWithViewSmoothing, CPropSFRVehicle );
- DECLARE_DATADESC();
- CPropSFRVehicleWithViewSmoothing();
- virtual void GetVehicleViewPosition( int nRole, Vector *pOrigin, QAngle *pAngles, float *pFOV = NULL );
- virtual void SetVehicle( CBaseEntity *pVehicle );
- void InitViewSmoothing( const Vector &vecStartOrigin, const QAngle &vecStartAngles );
- virtual void EnterVehicle( CBaseCombatCharacter *pPlayer );
- virtual void ExitVehicle( int iRole );
- #ifdef CLIENT_DLL
- virtual void UpdateViewAngles( C_BasePlayer *pLocalPlayer, CUserCmd *pCmd );
- #endif
- virtual void DampenEyePosition( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles );
- void DampenForwardMotion( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles, float flFrameTime );
- void DampenUpMotion( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles, float flFrameTime );
- void ComputePDControllerCoefficients( float *pCoefficientsOut, float flFrequency, float flDampening, float flDeltaTime );
- protected:
- ViewSmoothingData_t m_ViewSmoothing;
- Vector m_vecLastEyePos;
- Vector m_vecLastEyeTarget;
- Vector m_vecEyeSpeed;
- Vector m_vecTargetSpeed;
- float m_flViewAngleDeltaTime;
- static const float _VEHICLE_FRAMETIME_MIN;
- static const float _VEHICLE_DELTA_LENGHT_MAX;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment