Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

700 lines
22 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Client-side CBasePlayer.
  4. //
  5. // - Manages the player's flashlight effect.
  6. //
  7. //=============================================================================//
  8. #ifndef C_BASEPLAYER_H
  9. #define C_BASEPLAYER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "c_playerlocaldata.h"
  14. #include "c_basecombatcharacter.h"
  15. #include "PlayerState.h"
  16. #include "usercmd.h"
  17. #include "shareddefs.h"
  18. #include "timedevent.h"
  19. #include "smartptr.h"
  20. #include "fx_water.h"
  21. #include "hintsystem.h"
  22. #include "SoundEmitterSystem/isoundemittersystembase.h"
  23. #include "c_env_fog_controller.h"
  24. #include "igameevents.h"
  25. #include "GameEventListener.h"
  26. #if defined USES_ECON_ITEMS
  27. #include "econ_item.h"
  28. #include "game_item_schema.h"
  29. #include "econ_item_view.h"
  30. #endif
  31. class C_BaseCombatWeapon;
  32. class C_BaseViewModel;
  33. class C_FuncLadder;
  34. class CFlashlightEffect;
  35. class C_EconWearable;
  36. extern int g_nKillCamMode;
  37. extern int g_nKillCamTarget1;
  38. extern int g_nKillCamTarget2;
  39. class C_CommandContext
  40. {
  41. public:
  42. bool needsprocessing;
  43. CUserCmd cmd;
  44. int command_number;
  45. };
  46. class C_PredictionError
  47. {
  48. public:
  49. float time;
  50. Vector error;
  51. };
  52. #define CHASE_CAM_DISTANCE_MIN 16.0f
  53. #define CHASE_CAM_DISTANCE_MAX 96.0f
  54. #define WALL_OFFSET 6.0f
  55. bool IsInFreezeCam( void );
  56. //-----------------------------------------------------------------------------
  57. // Purpose: Base Player class
  58. //-----------------------------------------------------------------------------
  59. class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener
  60. {
  61. public:
  62. DECLARE_CLASS( C_BasePlayer, C_BaseCombatCharacter );
  63. DECLARE_CLIENTCLASS();
  64. DECLARE_PREDICTABLE();
  65. DECLARE_INTERPOLATION();
  66. C_BasePlayer();
  67. virtual ~C_BasePlayer();
  68. virtual void Spawn( void );
  69. virtual void SharedSpawn(); // Shared between client and server.
  70. virtual bool GetSteamID( CSteamID *pID );
  71. // IClientEntity overrides.
  72. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  73. virtual void OnDataChanged( DataUpdateType_t updateType );
  74. virtual void PreDataUpdate( DataUpdateType_t updateType );
  75. virtual void PostDataUpdate( DataUpdateType_t updateType );
  76. virtual void ReceiveMessage( int classID, bf_read &msg );
  77. virtual void OnRestore();
  78. virtual void AddEntity( void );
  79. virtual void MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType );
  80. virtual void GetToolRecordingState( KeyValues *msg );
  81. virtual float GetPlayerMaxSpeed();
  82. void SetAnimationExtension( const char *pExtension );
  83. C_BaseViewModel *GetViewModel( int viewmodelindex = 0, bool bObserverOK=true );
  84. C_BaseCombatWeapon *GetActiveWeapon( void ) const;
  85. const char *GetTracerType( void );
  86. // View model prediction setup
  87. virtual void CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, float &zFar, float &fov );
  88. virtual void CalcViewModelView( const Vector& eyeOrigin, const QAngle& eyeAngles);
  89. // Handle view smoothing when going up stairs
  90. void SmoothViewOnStairs( Vector& eyeOrigin );
  91. virtual float CalcRoll (const QAngle& angles, const Vector& velocity, float rollangle, float rollspeed);
  92. void CalcViewRoll( QAngle& eyeAngles );
  93. void CreateWaterEffects( void );
  94. virtual void SetPlayerUnderwater( bool state );
  95. void UpdateUnderwaterState( void );
  96. bool IsPlayerUnderwater( void ) { return m_bPlayerUnderwater; }
  97. virtual Vector Weapon_ShootPosition();
  98. virtual void Weapon_DropPrimary( void ) {}
  99. virtual Vector GetAutoaimVector( float flScale );
  100. void SetSuitUpdate(const char *name, int fgroup, int iNoRepeat);
  101. // Input handling
  102. virtual bool CreateMove( float flInputSampleTime, CUserCmd *pCmd );
  103. virtual void AvoidPhysicsProps( CUserCmd *pCmd );
  104. virtual void PlayerUse( void );
  105. CBaseEntity *FindUseEntity( void );
  106. virtual bool IsUseableEntity( CBaseEntity *pEntity, unsigned int requiredCaps );
  107. // Data handlers
  108. virtual bool IsPlayer( void ) const { return true; }
  109. virtual int GetHealth() const { return m_iHealth; }
  110. int GetBonusProgress() const { return m_iBonusProgress; }
  111. int GetBonusChallenge() const { return m_iBonusChallenge; }
  112. // observer mode
  113. virtual int GetObserverMode() const;
  114. void SetObserverMode ( int iNewMode );
  115. virtual CBaseEntity *GetObserverTarget() const;
  116. void SetObserverTarget( EHANDLE hObserverTarget );
  117. bool AudioStateIsUnderwater( Vector vecMainViewOrigin );
  118. bool IsObserver() const;
  119. bool IsHLTV() const;
  120. bool IsReplay() const;
  121. void ResetObserverMode();
  122. bool IsBot( void ) const { return false; }
  123. // Eye position..
  124. virtual Vector EyePosition();
  125. virtual const QAngle &EyeAngles(); // Direction of eyes
  126. void EyePositionAndVectors( Vector *pPosition, Vector *pForward, Vector *pRight, Vector *pUp );
  127. virtual const QAngle &LocalEyeAngles(); // Direction of eyes
  128. // This can be overridden to return something other than m_pRagdoll if the mod uses separate
  129. // entities for ragdolls.
  130. virtual IRagdoll* GetRepresentativeRagdoll() const;
  131. // override the initial bone position for ragdolls
  132. virtual bool GetRagdollInitBoneArrays( matrix3x4_t *pDeltaBones0, matrix3x4_t *pDeltaBones1, matrix3x4_t *pCurrentBones, float boneDt ) OVERRIDE;
  133. // Returns eye vectors
  134. void EyeVectors( Vector *pForward, Vector *pRight = NULL, Vector *pUp = NULL );
  135. void CacheVehicleView( void ); // Calculate and cache the position of the player in the vehicle
  136. bool IsSuitEquipped( void ) { return m_Local.m_bWearingSuit; };
  137. // Team handlers
  138. virtual void TeamChange( int iNewTeam );
  139. // Flashlight
  140. void Flashlight( void );
  141. void UpdateFlashlight( void );
  142. // Weapon selection code
  143. virtual bool IsAllowedToSwitchWeapons( void ) { return !IsObserver(); }
  144. virtual C_BaseCombatWeapon *GetActiveWeaponForSelection( void );
  145. // Returns the view model if this is the local player. If you're in third person or
  146. // this is a remote player, it returns the active weapon
  147. // (and its appropriate left/right weapon if this is TF2).
  148. virtual C_BaseAnimating* GetRenderedWeaponModel();
  149. virtual bool IsOverridingViewmodel( void ) { return false; };
  150. virtual int DrawOverriddenViewmodel( C_BaseViewModel *pViewmodel, int flags ) { return 0; };
  151. virtual float GetDefaultAnimSpeed( void ) { return 1.0; }
  152. void SetMaxSpeed( float flMaxSpeed ) { m_flMaxspeed = flMaxSpeed; }
  153. float MaxSpeed() const { return m_flMaxspeed; }
  154. // Should this object cast shadows?
  155. virtual ShadowType_t ShadowCastType() { return SHADOWS_NONE; }
  156. virtual bool ShouldReceiveProjectedTextures( int flags )
  157. {
  158. return false;
  159. }
  160. bool IsLocalPlayer( void ) const;
  161. // Global/static methods
  162. virtual void ThirdPersonSwitch( bool bThirdperson );
  163. static bool LocalPlayerInFirstPersonView();
  164. static bool ShouldDrawLocalPlayer();
  165. static C_BasePlayer *GetLocalPlayer( void );
  166. int GetUserID( void );
  167. virtual bool CanSetSoundMixer( void );
  168. virtual int GetVisionFilterFlags( bool bWeaponsCheck = false ) { return 0x00; }
  169. bool HasVisionFilterFlags( int nFlags, bool bWeaponsCheck = false ) { return ( GetVisionFilterFlags( bWeaponsCheck ) & nFlags ) == nFlags; }
  170. virtual void CalculateVisionUsingCurrentFlags( void ) {}
  171. void BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, const char *pchHeadBoneName );
  172. // Specific queries about this player.
  173. bool InFirstPersonView();
  174. bool ShouldDrawThisPlayer();
  175. // Called by the view model if its rendering is being overridden.
  176. virtual bool ViewModel_IsTransparent( void );
  177. virtual bool ViewModel_IsUsingFBTexture( void );
  178. #if !defined( NO_ENTITY_PREDICTION )
  179. void AddToPlayerSimulationList( C_BaseEntity *other );
  180. void SimulatePlayerSimulatedEntities( void );
  181. void RemoveFromPlayerSimulationList( C_BaseEntity *ent );
  182. void ClearPlayerSimulationList( void );
  183. #endif
  184. virtual void PhysicsSimulate( void );
  185. virtual unsigned int PhysicsSolidMaskForEntity( void ) const { return MASK_PLAYERSOLID; }
  186. // Prediction stuff
  187. virtual bool ShouldPredict( void );
  188. virtual void PreThink( void );
  189. virtual void PostThink( void );
  190. virtual void ItemPreFrame( void );
  191. virtual void ItemPostFrame( void );
  192. virtual void AbortReload( void );
  193. virtual void SelectLastItem(void);
  194. virtual void Weapon_SetLast( C_BaseCombatWeapon *pWeapon );
  195. virtual bool Weapon_ShouldSetLast( C_BaseCombatWeapon *pOldWeapon, C_BaseCombatWeapon *pNewWeapon ) { return true; }
  196. virtual bool Weapon_ShouldSelectItem( C_BaseCombatWeapon *pWeapon );
  197. virtual bool Weapon_Switch( C_BaseCombatWeapon *pWeapon, int viewmodelindex = 0 ); // Switch to given weapon if has ammo (false if failed)
  198. virtual C_BaseCombatWeapon *GetLastWeapon( void ) { return m_hLastWeapon.Get(); }
  199. void ResetAutoaim( void );
  200. virtual void SelectItem( const char *pstr, int iSubType = 0 );
  201. virtual void UpdateClientData( void );
  202. bool IsLerpingFOV( void ) const;
  203. virtual float GetFOV( void );
  204. int GetDefaultFOV( void ) const;
  205. virtual bool IsZoomed( void ) { return false; }
  206. bool SetFOV( CBaseEntity *pRequester, int FOV, float zoomRate = 0.0f, int iZoomStart = 0 );
  207. void ClearZoomOwner( void );
  208. float GetFOVDistanceAdjustFactor();
  209. virtual void ViewPunch( const QAngle &angleOffset );
  210. void ViewPunchReset( float tolerance = 0 );
  211. void UpdateButtonState( int nUserCmdButtonMask );
  212. int GetImpulse( void ) const;
  213. virtual void Simulate();
  214. virtual bool ShouldInterpolate();
  215. virtual bool ShouldDraw();
  216. virtual int DrawModel( int flags );
  217. // Called when not in tactical mode. Allows view to be overriden for things like driving a tank.
  218. virtual void OverrideView( CViewSetup *pSetup );
  219. // returns the player name
  220. const char * GetPlayerName();
  221. virtual const Vector GetPlayerMins( void ) const; // uses local player
  222. virtual const Vector GetPlayerMaxs( void ) const; // uses local player
  223. // Is the player dead?
  224. bool IsPlayerDead();
  225. bool IsPoisoned( void ) { return m_Local.m_bPoisoned; }
  226. C_BaseEntity *GetUseEntity();
  227. // Vehicles...
  228. IClientVehicle *GetVehicle();
  229. bool IsInAVehicle() const { return ( NULL != m_hVehicle.Get() ) ? true : false; }
  230. virtual void SetVehicleRole( int nRole );
  231. void LeaveVehicle( void );
  232. bool UsingStandardWeaponsInVehicle( void );
  233. virtual void SetAnimation( PLAYER_ANIM playerAnim );
  234. float GetTimeBase( void ) const;
  235. float GetFinalPredictedTime() const;
  236. bool IsInVGuiInputMode() const;
  237. bool IsInViewModelVGuiInputMode() const;
  238. C_CommandContext *GetCommandContext();
  239. // Get the command number associated with the current usercmd we're running (if in predicted code).
  240. int CurrentCommandNumber() const;
  241. const CUserCmd *GetCurrentUserCommand() const;
  242. const QAngle& GetPunchAngle();
  243. void SetPunchAngle( const QAngle &angle );
  244. float GetWaterJumpTime() const;
  245. void SetWaterJumpTime( float flWaterJumpTime );
  246. float GetSwimSoundTime( void ) const;
  247. void SetSwimSoundTime( float flSwimSoundTime );
  248. float GetDeathTime( void ) { return m_flDeathTime; }
  249. void SetPreviouslyPredictedOrigin( const Vector &vecAbsOrigin );
  250. const Vector &GetPreviouslyPredictedOrigin() const;
  251. // CS wants to allow small FOVs for zoomed-in AWPs.
  252. virtual float GetMinFOV() const;
  253. virtual void DoMuzzleFlash();
  254. virtual void PlayPlayerJingle();
  255. virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity );
  256. virtual void PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force );
  257. virtual surfacedata_t * GetFootstepSurface( const Vector &origin, const char *surfaceName );
  258. virtual void GetStepSoundVelocities( float *velwalk, float *velrun );
  259. virtual void SetStepSoundTime( stepsoundtimes_t iStepSoundTime, bool bWalking );
  260. virtual const char *GetOverrideStepSound( const char *pszBaseStepSoundName ) { return pszBaseStepSoundName; }
  261. virtual void OnEmitFootstepSound( const CSoundParameters& params, const Vector& vecOrigin, float fVolume ) {}
  262. // Called by prediction when it detects a prediction correction.
  263. // vDelta is the line from where the client had predicted the player to at the usercmd in question,
  264. // to where the server says the client should be at said usercmd.
  265. void NotePredictionError( const Vector &vDelta );
  266. // Called by the renderer to apply the prediction error smoothing.
  267. void GetPredictionErrorSmoothingVector( Vector &vOffset );
  268. virtual void ExitLadder() {}
  269. surfacedata_t *GetLadderSurface( const Vector &origin );
  270. surfacedata_t *GetSurfaceData( void ) { return m_pSurfaceData; }
  271. void SetLadderNormal( Vector vecLadderNormal ) { m_vecLadderNormal = vecLadderNormal; }
  272. // Hints
  273. virtual CHintSystem *Hints( void ) { return NULL; }
  274. bool ShouldShowHints( void ) { return Hints() ? Hints()->ShouldShowHints() : false; }
  275. bool HintMessage( int hint, bool bForce = false, bool bOnlyIfClear = false ) { return Hints() ? Hints()->HintMessage( hint, bForce, bOnlyIfClear ) : false; }
  276. void HintMessage( const char *pMessage ) { if (Hints()) Hints()->HintMessage( pMessage ); }
  277. virtual IMaterial *GetHeadLabelMaterial( void );
  278. // Fog
  279. fogparams_t *GetFogParams( void ) { return &m_CurrentFog; }
  280. void FogControllerChanged( bool bSnap );
  281. void UpdateFogController( void );
  282. void UpdateFogBlend( void );
  283. float GetFOVTime( void ){ return m_flFOVTime; }
  284. virtual void OnAchievementAchieved( int iAchievement ) {}
  285. bool ShouldAnnounceAchievement( void ){ return m_flNextAchievementAnnounceTime < gpGlobals->curtime; }
  286. void SetNextAchievementAnnounceTime( float flTime ){ m_flNextAchievementAnnounceTime = flTime; }
  287. #if defined USES_ECON_ITEMS
  288. // Wearables
  289. virtual void UpdateWearables();
  290. C_EconWearable *GetWearable( int i ) { return m_hMyWearables[i]; }
  291. int GetNumWearables( void ) { return m_hMyWearables.Count(); }
  292. #endif
  293. bool HasFiredWeapon( void ) { return m_bFiredWeapon; }
  294. void SetFiredWeapon( bool bFlag ) { m_bFiredWeapon = bFlag; }
  295. virtual bool CanUseFirstPersonCommand( void ){ return true; }
  296. protected:
  297. fogparams_t m_CurrentFog;
  298. EHANDLE m_hOldFogController;
  299. public:
  300. int m_StuckLast;
  301. // Data for only the local player
  302. CNetworkVarEmbedded( CPlayerLocalData, m_Local );
  303. #if defined USES_ECON_ITEMS
  304. CNetworkVarEmbedded( CAttributeList, m_AttributeList );
  305. #endif
  306. // Data common to all other players, too
  307. CPlayerState pl;
  308. // Player FOV values
  309. int m_iFOV; // field of view
  310. int m_iFOVStart; // starting value of the FOV changing over time (client only)
  311. float m_flFOVTime; // starting time of the FOV zoom
  312. int m_iDefaultFOV; // default FOV if no other zooms are occurring
  313. EHANDLE m_hZoomOwner; // This is a pointer to the entity currently controlling the player's zoom
  314. // Only this entity can change the zoom state once it has ownership
  315. // For weapon prediction
  316. bool m_fOnTarget; //Is the crosshair on a target?
  317. char m_szAnimExtension[32];
  318. int m_afButtonLast;
  319. int m_afButtonPressed;
  320. int m_afButtonReleased;
  321. int m_nButtons;
  322. CUserCmd *m_pCurrentCommand;
  323. // Movement constraints
  324. EHANDLE m_hConstraintEntity;
  325. Vector m_vecConstraintCenter;
  326. float m_flConstraintRadius;
  327. float m_flConstraintWidth;
  328. float m_flConstraintSpeedFactor;
  329. protected:
  330. void CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  331. void CalcVehicleView(IClientVehicle *pVehicle, Vector& eyeOrigin, QAngle& eyeAngles,
  332. float& zNear, float& zFar, float& fov );
  333. virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  334. virtual Vector GetChaseCamViewOffset( CBaseEntity *target );
  335. void CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  336. virtual void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  337. virtual float GetDeathCamInterpolationTime();
  338. virtual void CalcDeathCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  339. void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
  340. virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  341. // Check to see if we're in vgui input mode...
  342. void DetermineVguiInputMode( CUserCmd *pCmd );
  343. // Used by prediction, sets the view angles for the player
  344. virtual void SetLocalViewAngles( const QAngle &viewAngles );
  345. virtual void SetViewAngles( const QAngle& ang );
  346. // used by client side player footsteps
  347. surfacedata_t* GetGroundSurface();
  348. virtual void FireGameEvent( IGameEvent *event );
  349. protected:
  350. // Did we just enter a vehicle this frame?
  351. bool JustEnteredVehicle();
  352. // DATA
  353. int m_iObserverMode; // if in spectator mode != 0
  354. EHANDLE m_hObserverTarget; // current observer target
  355. float m_flObserverChaseDistance; // last distance to observer traget
  356. Vector m_vecFreezeFrameStart;
  357. float m_flFreezeFrameStartTime; // Time at which we entered freeze frame observer mode
  358. float m_flFreezeFrameDistance;
  359. bool m_bWasFreezeFraming;
  360. float m_flDeathTime; // last time player died
  361. float m_flStepSoundTime;
  362. bool m_IsFootprintOnLeft;
  363. private:
  364. // Make sure no one calls this...
  365. C_BasePlayer& operator=( const C_BasePlayer& src );
  366. C_BasePlayer( const C_BasePlayer & ); // not defined, not accessible
  367. // Vehicle stuff.
  368. EHANDLE m_hVehicle;
  369. EHANDLE m_hOldVehicle;
  370. EHANDLE m_hUseEntity;
  371. float m_flMaxspeed;
  372. int m_iBonusProgress;
  373. int m_iBonusChallenge;
  374. CInterpolatedVar< Vector > m_iv_vecViewOffset;
  375. // Not replicated
  376. Vector m_vecWaterJumpVel;
  377. float m_flWaterJumpTime; // used to be called teleport_time
  378. int m_nImpulse;
  379. float m_flSwimSoundTime;
  380. Vector m_vecLadderNormal;
  381. QAngle m_vecOldViewAngles;
  382. bool m_bWasFrozen;
  383. int m_flPhysics;
  384. int m_nTickBase;
  385. int m_nFinalPredictedTick;
  386. EHANDLE m_pCurrentVguiScreen;
  387. bool m_bFiredWeapon;
  388. // Player flashlight dynamic light pointers
  389. CFlashlightEffect *m_pFlashlight;
  390. typedef CHandle<C_BaseCombatWeapon> CBaseCombatWeaponHandle;
  391. CNetworkVar( CBaseCombatWeaponHandle, m_hLastWeapon );
  392. #if !defined( NO_ENTITY_PREDICTION )
  393. CUtlVector< CHandle< C_BaseEntity > > m_SimulatedByThisPlayer;
  394. #endif
  395. // players own view models, left & right hand
  396. CHandle< C_BaseViewModel > m_hViewModel[ MAX_VIEWMODELS ];
  397. float m_flOldPlayerZ;
  398. float m_flOldPlayerViewOffsetZ;
  399. Vector m_vecVehicleViewOrigin; // Used to store the calculated view of the player while riding in a vehicle
  400. QAngle m_vecVehicleViewAngles; // Vehicle angles
  401. float m_flVehicleViewFOV;
  402. int m_nVehicleViewSavedFrame; // Used to mark which frame was the last one the view was calculated for
  403. // For UI purposes...
  404. int m_iOldAmmo[ MAX_AMMO_TYPES ];
  405. C_CommandContext m_CommandContext;
  406. // For underwater effects
  407. float m_flWaterSurfaceZ;
  408. bool m_bResampleWaterSurface;
  409. TimedEvent m_tWaterParticleTimer;
  410. CSmartPtr<WaterDebrisEffect> m_pWaterEmitter;
  411. bool m_bPlayerUnderwater;
  412. friend class CPrediction;
  413. // HACK FOR TF2 Prediction
  414. friend class CTFGameMovementRecon;
  415. friend class CGameMovement;
  416. friend class CTFGameMovement;
  417. friend class CHL1GameMovement;
  418. friend class CCSGameMovement;
  419. friend class CHL2GameMovement;
  420. friend class CDODGameMovement;
  421. friend class CPortalGameMovement;
  422. // Accessors for gamemovement
  423. float GetStepSize( void ) const { return m_Local.m_flStepSize; }
  424. float m_flNextAvoidanceTime;
  425. float m_flAvoidanceRight;
  426. float m_flAvoidanceForward;
  427. float m_flAvoidanceDotForward;
  428. float m_flAvoidanceDotRight;
  429. protected:
  430. virtual bool IsDucked( void ) const { return m_Local.m_bDucked; }
  431. virtual bool IsDucking( void ) const { return m_Local.m_bDucking; }
  432. virtual float GetFallVelocity( void ) { return m_Local.m_flFallVelocity; }
  433. bool ForceSetupBonesAtTimeFakeInterpolation( matrix3x4_t *pBonesOut, float curtimeOffset );
  434. float m_flLaggedMovementValue;
  435. // These are used to smooth out prediction corrections. They're most useful when colliding with
  436. // vphysics objects. The server will be sending constant prediction corrections, and these can help
  437. // the errors not be so jerky.
  438. Vector m_vecPredictionError;
  439. float m_flPredictionErrorTime;
  440. Vector m_vecPreviouslyPredictedOrigin; // Used to determine if non-gamemovement game code has teleported, or tweaked the player's origin
  441. char m_szLastPlaceName[MAX_PLACE_NAME_LENGTH]; // received from the server
  442. // Texture names and surface data, used by CGameMovement
  443. int m_surfaceProps;
  444. surfacedata_t* m_pSurfaceData;
  445. float m_surfaceFriction;
  446. char m_chTextureType;
  447. bool m_bSentFreezeFrame;
  448. float m_flFreezeZOffset;
  449. float m_flNextAchievementAnnounceTime;
  450. int m_nForceVisionFilterFlags; // Force our vision filter to a specific setting
  451. int m_nLocalPlayerVisionFlags;
  452. #if defined USES_ECON_ITEMS
  453. // Wearables
  454. CUtlVector<CHandle<C_EconWearable > > m_hMyWearables;
  455. #endif
  456. private:
  457. struct StepSoundCache_t
  458. {
  459. StepSoundCache_t() : m_usSoundNameIndex( 0 ) {}
  460. CSoundParameters m_SoundParameters;
  461. unsigned short m_usSoundNameIndex;
  462. };
  463. // One for left and one for right side of step
  464. StepSoundCache_t m_StepSoundCache[ 2 ];
  465. public:
  466. const char *GetLastKnownPlaceName( void ) const { return m_szLastPlaceName; } // return the last nav place name the player occupied
  467. float GetLaggedMovementValue( void ){ return m_flLaggedMovementValue; }
  468. bool ShouldGoSouth( Vector vNPCForward, Vector vNPCRight ); //Such a bad name.
  469. void SetOldPlayerZ( float flOld ) { m_flOldPlayerZ = flOld; }
  470. };
  471. EXTERN_RECV_TABLE(DT_BasePlayer);
  472. //-----------------------------------------------------------------------------
  473. // Inline methods
  474. //-----------------------------------------------------------------------------
  475. inline C_BasePlayer *ToBasePlayer( C_BaseEntity *pEntity )
  476. {
  477. if ( !pEntity || !pEntity->IsPlayer() )
  478. return NULL;
  479. #if _DEBUG
  480. Assert( dynamic_cast<C_BasePlayer *>( pEntity ) != NULL );
  481. #endif
  482. return static_cast<C_BasePlayer *>( pEntity );
  483. }
  484. inline C_BaseEntity *C_BasePlayer::GetUseEntity()
  485. {
  486. return m_hUseEntity;
  487. }
  488. inline IClientVehicle *C_BasePlayer::GetVehicle()
  489. {
  490. C_BaseEntity *pVehicleEnt = m_hVehicle.Get();
  491. return pVehicleEnt ? pVehicleEnt->GetClientVehicle() : NULL;
  492. }
  493. inline bool C_BasePlayer::IsObserver() const
  494. {
  495. return (GetObserverMode() != OBS_MODE_NONE);
  496. }
  497. inline int C_BasePlayer::GetImpulse( void ) const
  498. {
  499. return m_nImpulse;
  500. }
  501. inline C_CommandContext* C_BasePlayer::GetCommandContext()
  502. {
  503. return &m_CommandContext;
  504. }
  505. inline int CBasePlayer::CurrentCommandNumber() const
  506. {
  507. Assert( m_pCurrentCommand );
  508. return m_pCurrentCommand->command_number;
  509. }
  510. inline const CUserCmd *CBasePlayer::GetCurrentUserCommand() const
  511. {
  512. Assert( m_pCurrentCommand );
  513. return m_pCurrentCommand;
  514. }
  515. #endif // C_BASEPLAYER_H