psy_commando

prop_sfr_vehicle.h

Apr 28th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.05 KB | None | 0 0
  1. #ifndef PROP_SFR_VEHICLE
  2. #define PROP_SFR_VEHICLE
  3. /*
  4. prop_sfr_vehicle.h
  5. */
  6. #include "props.h"
  7. #include "props_shared.h"
  8. #include "iservervehicle.h"
  9. #include "vehicle_baseserver.h"
  10. #include "vehicle_viewblend_shared.h"
  11.  
  12. class CPropSFRVehicle : public CBaseAnimating/*CPhysicsPropMultiplayer*/, public IDrivableVehicle, public CBaseServerVehicle
  13. {
  14.    DECLARE_CLASS( CPropSFRVehicle, CBaseAnimating/*CPhysicsPropMultiplayer*/ );
  15. public:
  16.    DECLARE_DATADESC();
  17.    DECLARE_NETWORKCLASS();
  18.  
  19.  
  20.     CPropSFRVehicle();
  21.     virtual ~CPropSFRVehicle();
  22.  
  23.    //HACK
  24.    CPropSFRVehicle  *GetDriveableVehicle(){return this;}
  25.  
  26.     // CBaseEntity
  27.    virtual void Precache( void );
  28.     virtual void Spawn( void );
  29.     virtual void Think( void );
  30.    virtual bool ShouldThink() { return ( GetDriver() != NULL ); }
  31.    virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
  32.    virtual int  ObjectCaps( void ) { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE; };
  33.    virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  34.     virtual void Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info );
  35.  
  36.    virtual IServerVehicle*  GetServerVehicle() { return this; }
  37.  
  38.    //Vehicle Stuff
  39.     Vector GetSmoothedVelocity( void ); //Save and update our smoothed velocity for prediction
  40.     // Driving
  41.     void    DriveVehicle( CBasePlayer *pPlayer, CUserCmd *ucmd );   // Player driving entrypoint
  42.     virtual void DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iButtonsDown, int iButtonsReleased ); // Driving Button handling
  43.    virtual void ResetControls();
  44.  
  45.     // Engine handling
  46.     virtual void    StartEngine( void );
  47.     virtual void    StopEngine( void );
  48.     virtual bool    IsEngineOn( void );
  49.  
  50.    //State
  51.    virtual void TurnOn();
  52.    virtual void TurnOff();
  53.    virtual bool IsOn(){return m_bIsOn;}
  54.  
  55. // IDrivableVehicle
  56. public:
  57.     virtual CBaseEntity *GetDriver( void );
  58.  
  59.    /*
  60.    psy:
  61.     I had to reimplement these here and neglect the parent class's because the parent class's re-call
  62.     these method through the "GetDriveableVehicle" method and create an infinite recursive loop.
  63.    */
  64.     virtual void        ItemPostFrame( CBasePlayer *pPlayer );
  65.    virtual void     ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData );
  66.  
  67.     virtual void        SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
  68.     virtual void        FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move ) {}
  69.     virtual bool        CanEnterVehicle( CBaseEntity *pEntity );
  70.     virtual bool        CanExitVehicle( CBaseEntity *pEntity );
  71.     virtual void        EnterVehicle( CBaseCombatCharacter *pPassenger );
  72.     virtual bool        AllowBlockedExit( CBaseCombatCharacter *pPassenger, int nRole ) { return true; }
  73.     virtual bool        AllowMidairExit( CBaseCombatCharacter *pPassenger, int nRole ) { return false; }
  74.     virtual void        PreExitVehicle( CBaseCombatCharacter *pPassenger, int nRole ) {}
  75.     virtual void        ExitVehicle( int nRole );
  76.     virtual string_t    GetVehicleScriptName() { return m_vehicleScript; }
  77.    virtual bool     PassengerShouldReceiveDamage( CTakeDamageInfo &info ) { return false; }
  78.  
  79.    //Deprecated because handles only one passenger
  80.     virtual void        SetVehicleEntryAnim( bool bOn ) {ASSERT(false);}
  81.     virtual void        SetVehicleExitAnim( bool bOn, Vector vecEyeExitEndpoint ) {ASSERT(false);}
  82.    
  83.  
  84.    // CPropSFRVehicle
  85.    void InputEnterVehicleImmediate( inputdata_t &inputdata );
  86.  
  87. private:
  88.    void ResetUseKey( CBasePlayer *pPlayer );
  89.  
  90. protected:
  91.    float m_flTimeLastEnterExit;
  92.     Vector m_vecSmoothedVelocity;
  93.    CNetworkHandle( CBasePlayer, m_hPlayer );
  94.    string_t m_vehicleScript;
  95.  
  96.    //State
  97.    CNetworkVar(bool, m_bIsOn);
  98.  
  99.  
  100.    COutputEvent     m_playerOn;
  101.     COutputEvent        m_playerOff;
  102. };
  103.  
  104. class CPropSFRVehicleWithViewSmoothing : public CPropSFRVehicle
  105. {
  106. public:
  107.    DECLARE_CLASS( CPropSFRVehicleWithViewSmoothing, CPropSFRVehicle );
  108.    DECLARE_DATADESC();
  109.  
  110.    CPropSFRVehicleWithViewSmoothing();
  111.     virtual void GetVehicleViewPosition( int nRole, Vector *pOrigin, QAngle *pAngles, float *pFOV = NULL );
  112.     virtual void SetVehicle( CBaseEntity *pVehicle );
  113.     void    InitViewSmoothing( const Vector &vecStartOrigin, const QAngle &vecStartAngles );
  114.    virtual void EnterVehicle( CBaseCombatCharacter *pPlayer );
  115.     virtual void    ExitVehicle( int iRole );
  116.  
  117. #ifdef CLIENT_DLL
  118.    virtual void UpdateViewAngles( C_BasePlayer *pLocalPlayer, CUserCmd *pCmd );
  119. #endif
  120.  
  121.    virtual void DampenEyePosition( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles );
  122.  
  123.     void DampenForwardMotion( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles, float flFrameTime );
  124.     void DampenUpMotion( Vector &vecVehicleEyePos, QAngle &vecVehicleEyeAngles, float flFrameTime );
  125.     void ComputePDControllerCoefficients( float *pCoefficientsOut, float flFrequency, float flDampening, float flDeltaTime );
  126.  
  127. protected:
  128.    ViewSmoothingData_t      m_ViewSmoothing;
  129.  
  130.     Vector      m_vecLastEyePos;
  131.     Vector      m_vecLastEyeTarget;
  132.     Vector      m_vecEyeSpeed;
  133.     Vector      m_vecTargetSpeed;
  134.  
  135.     float       m_flViewAngleDeltaTime;
  136.  
  137.    static const float _VEHICLE_FRAMETIME_MIN;
  138.    static const float _VEHICLE_DELTA_LENGHT_MAX;
  139. };
  140.  
  141. #endif
Advertisement
Add Comment
Please, Sign In to add comment