Counter Strike : Global Offensive Source Code
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.

729 lines
27 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef PORTAL_PLAYER_H
  9. #define PORTAL_PLAYER_H
  10. #pragma once
  11. class CPortal_Player;
  12. #include "player.h"
  13. #include "portal_playeranimstate.h"
  14. #include "portal_playerlocaldata.h"
  15. #include "simtimer.h"
  16. #include "soundenvelope.h"
  17. #include "npc_security_camera.h"
  18. #include "portal_player_shared.h"
  19. #include "weapon_portalbase.h"
  20. #include "in_buttons.h"
  21. #include "ai_speech.h" // For expresser host
  22. #include "basemultiplayerplayer.h"
  23. #include "paint_power_user.h"
  24. #include "paintable_entity.h"
  25. #include "ai_basenpc.h"
  26. #include "npc_security_camera.h"
  27. #include "portal_base2d.h"
  28. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  29. #include "portal2_item_inventory.h"
  30. #endif
  31. extern bool UTIL_TimeScaleIsNonStandard( void );
  32. #define PORTAL_COLOR_FLAG_BLUE ( 1 << 0 )
  33. #define PORTAL_COLOR_FLAG_PURPLE ( 1 << 1 )
  34. #define PORTAL_COLOR_FLAG_ORANGE ( 1 << 2 )
  35. #define PORTAL_COLOR_FLAG_RED ( 1 << 3 )
  36. enum PlayerGunType
  37. {
  38. PLAYER_NO_GUN = 0,
  39. PLAYER_PAINT_GUN,
  40. PLAYER_PORTAL_GUN
  41. };
  42. enum ForcedGrabControllerType
  43. {
  44. FORCE_GRAB_CONTROLLER_DEFAULT = 0,
  45. FORCE_GRAB_CONTROLLER_VM,
  46. FORCE_GRAB_CONTROLLER_PHYSICS
  47. };
  48. class CEntityPortalledNetworkMessage
  49. {
  50. public:
  51. DECLARE_CLASS_NOBASE( CEntityPortalledNetworkMessage );
  52. CEntityPortalledNetworkMessage( void );
  53. CHandle<CBaseEntity> m_hEntity;
  54. CHandle<CPortal_Base2D> m_hPortal;
  55. float m_fTime;
  56. bool m_bForcedDuck;
  57. uint32 m_iMessageCount;
  58. };
  59. class CMoveData;
  60. //=============================================================================
  61. // >> Portal_Player
  62. //=============================================================================
  63. class CPortal_Player : public PaintPowerUser< CPaintableEntity< CBaseMultiplayerPlayer > >
  64. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  65. , public IInventoryUpdateListener
  66. #endif
  67. {
  68. public:
  69. DECLARE_CLASS( CPortal_Player, PaintPowerUser< CPaintableEntity< CBaseMultiplayerPlayer > > );
  70. CPortal_Player();
  71. virtual ~CPortal_Player( void );
  72. static CPortal_Player *CreatePlayer( const char *className, edict_t *ed );
  73. DECLARE_SERVERCLASS();
  74. DECLARE_DATADESC();
  75. DECLARE_ENT_SCRIPTDESC();
  76. virtual void Precache( void );
  77. virtual void CreateSounds( void );
  78. virtual void StopLoopingSounds( void );
  79. virtual void Spawn( void );
  80. virtual void SharedSpawn();
  81. virtual void OnRestore( void );
  82. virtual int Restore( IRestore &restore );
  83. virtual void Activate( void );
  84. virtual void Touch( CBaseEntity *pOther );
  85. #ifdef PORTAL2
  86. virtual void InitialSpawn( void );
  87. void SetPlacingPhoto( bool bPlacing );
  88. void OnPhotoAdded( int nIndex );
  89. void OnPhotoRemoved( int nIndex );
  90. void SetSelectedPhoto( int nIndex );
  91. int GetSelectedPhoto( void );
  92. void ClearPhotos( void );
  93. void StripPhotos( bool bNotifyPlayer = true );
  94. void FlashDenyIndicator( float flDuration, unsigned char nType );
  95. void FlashInventory( float flDuration, unsigned char nType );
  96. void Flash( float flDuration, const Vector &vecPosition );
  97. void ControlHelperAnimate( unsigned char nActiveIcon, bool bClear = false );
  98. void UpdateLocatorEntityIndices( int *pIndices, int nNumIndices );
  99. void SetMotionBlurAmount( float flAmt ) { m_flMotionBlurAmount = flAmt; }
  100. #endif // PORTAL2
  101. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
  102. virtual float PlayScene( const char *pszScene, float flDelay, AI_Response *response, IRecipientFilter *filter );
  103. virtual void NotifySystemEvent( CBaseEntity *pNotify, notify_system_event_t eventType, const notify_system_event_params_t &params );
  104. virtual void PostThink( void );
  105. virtual void PreThink( void );
  106. void SwapThink();
  107. virtual void PlayerDeathThink();
  108. virtual void PlayerTransitionCompleteThink();
  109. virtual void PlayerCatchPatnerNotConnectingThink();
  110. void UpdatePortalPlaneSounds( void );
  111. void UpdateWooshSounds( void );
  112. Activity TranslateActivity( Activity ActToTranslate, bool *pRequired = NULL );
  113. virtual void Teleport( const Vector *newPosition, const QAngle *newAngles, const Vector *newVelocity, bool bUseSlowHighAccuracyContacts = true );
  114. Activity TranslateTeamActivity( Activity ActToTranslate );
  115. virtual void SetAnimation( PLAYER_ANIM playerAnim );
  116. virtual void PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper);
  117. virtual bool ClientCommand( const CCommand &args );
  118. virtual void CreateViewModel( int viewmodelindex = 0 );
  119. virtual bool BecomeRagdollOnClient( const Vector &force );
  120. virtual int OnTakeDamage( const CTakeDamageInfo &inputInfo );
  121. virtual int OnTakeDamage_Alive( const CTakeDamageInfo &info );
  122. virtual void Break( CBaseEntity *pBreaker, const CTakeDamageInfo &info );
  123. virtual bool WantsLagCompensationOnEntity( const CBasePlayer *pPlayer, const CUserCmd *pCmd, const CBitVec<MAX_EDICTS> *pEntityTransmitBits ) const;
  124. virtual void FireBullets ( const FireBulletsInfo_t &info );
  125. virtual bool Weapon_Switch( CBaseCombatWeapon *pWeapon, int viewmodelindex = 0);
  126. virtual Vector Weapon_ShootPosition();
  127. virtual bool BumpWeapon( CBaseCombatWeapon *pWeapon );
  128. virtual CBaseCombatWeapon* Weapon_OwnsThisType( const char *pszWeapon, int iSubType = 0 ) const; // True if already owns a weapon of this class
  129. virtual void Weapon_Equip( CBaseCombatWeapon *pWeapon );
  130. virtual void SelectItem( const char *pstr, int iSubType );
  131. virtual void ShutdownUseEntity( void );
  132. virtual bool ShouldDropActiveWeaponWhenKilled( void ) { return false; }
  133. virtual Vector EyeDirection3D( void );
  134. virtual Vector EyeDirection2D( void );
  135. virtual const Vector &WorldSpaceCenter() const;
  136. //virtual bool StartReplayMode( float fDelay, float fDuration, int iEntity );
  137. //virtual void StopReplayMode();
  138. virtual void Event_Killed( const CTakeDamageInfo &info );
  139. virtual void Jump( void );
  140. void UnDuck( void );
  141. bool UseFoundEntity( CBaseEntity *pUseEntity, bool bAutoGrab );
  142. bool IsInvalidHandoff( CBaseEntity *pObject );
  143. void PollForUseEntity( bool bBasicUse, CBaseEntity **ppUseEnt, CPortal_Base2D **ppUseThroughPortal );
  144. CBaseEntity* FindUseEntity( CPortal_Base2D **pThroughPortal );
  145. CBaseEntity* FindUseEntityThroughPortal( void );
  146. void ZoomIn( void );
  147. void ZoomOut( void );
  148. virtual bool IsZoomed( void );
  149. virtual void PlayerUse( void );
  150. //virtual bool StartObserverMode( int mode );
  151. virtual void GetStepSoundVelocities( float *velwalk, float *velrun );
  152. virtual void PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force );
  153. virtual void UpdateOnRemove( void );
  154. virtual void OnSave( IEntitySaveUtils *pUtils );
  155. virtual void SetupVisibility( CBaseEntity *pViewEntity, unsigned char *pvs, int pvssize );
  156. virtual void UpdatePortalViewAreaBits( unsigned char *pvs, int pvssize );
  157. virtual void ItemPostFrame( void );
  158. bool ValidatePlayerModel( const char *pModel );
  159. void ClearScriptedInteractions( void );
  160. void ParseScriptedInteractions( void );
  161. void AddScriptedInteraction( ScriptedNPCInteraction_t *pInteraction );
  162. CUtlVector<ScriptedNPCInteraction_t> *GetScriptedInteractions( void ) { return &m_ScriptedInteractions; }
  163. void FireConcept( const char *pConcept );
  164. bool IsTaunting( void );
  165. int GetTeamTauntState( void ) const { return m_nTeamTauntState; }
  166. void SetTeamTauntState( int nTeamTauntState );
  167. Vector GetTeamTauntPosition( void ) { return m_vTauntPosition; }
  168. QAngle GetTeamTauntAngles( void ) { return m_vTauntAngles; }
  169. QAngle GetTrickFireAngles( void ) { return m_vPreTauntAngles; }
  170. bool IsTrickFiring( void ) const { return m_bTrickFire; }
  171. void ClearTrickFiring( void ) { m_bTrickFire = false; }
  172. QAngle GetAnimEyeAngles( void ) { return m_angEyeAngles.Get(); }
  173. Vector GetAttackSpread( CBaseCombatWeapon *pWeapon, CBaseEntity *pTarget = NULL );
  174. virtual void CheatImpulseCommands( int iImpulse );
  175. void CreateRagdollEntity( const CTakeDamageInfo &info );
  176. void GiveAllItems( void );
  177. void GiveDefaultItems( void );
  178. void NoteWeaponFired( void );
  179. void ResetAnimation( void );
  180. void SetPlayerModel( void );
  181. int GetPlayerModelType( void ) { return m_iPlayerSoundType; }
  182. virtual void ForceDuckThisFrame( void );
  183. //void UnDuck ( void );
  184. //inline void ForceJumpThisFrame( void ) { ForceButtons( IN_JUMP ); }
  185. void DoAnimationEvent( PlayerAnimEvent_t event, int nData );
  186. void SetupBones( matrix3x4a_t *pBoneToWorld, int boneMask );
  187. // physics interactions
  188. virtual void PickupObject(CBaseEntity *pObject, bool bLimitMassAndSize );
  189. virtual void ForceDropOfCarriedPhysObjects( CBaseEntity *pOnlyIfHoldingThis );
  190. void ToggleHeldObjectOnOppositeSideOfPortal( void ) { m_bHeldObjectOnOppositeSideOfPortal = !m_bHeldObjectOnOppositeSideOfPortal; }
  191. void SetHeldObjectOnOppositeSideOfPortal( bool p_bHeldObjectOnOppositeSideOfPortal ) { m_bHeldObjectOnOppositeSideOfPortal = p_bHeldObjectOnOppositeSideOfPortal; }
  192. bool IsHeldObjectOnOppositeSideOfPortal( void ) { return m_bHeldObjectOnOppositeSideOfPortal; }
  193. CPortal_Base2D *GetHeldObjectPortal( void ) const { return m_hHeldObjectPortal.Get(); }
  194. void SetHeldObjectPortal( CPortal_Base2D *pPortal ) { m_hHeldObjectPortal = pPortal; }
  195. void SetUsingVMGrabState( bool bState ) { m_bUsingVMGrabState = bState; }
  196. bool IsUsingVMGrab( void );
  197. bool WantsVMGrab( void );
  198. void UpdateVMGrab( CBaseEntity *pEntity );
  199. bool IsForcingDrop( void ) { return m_bForcingDrop; }
  200. // This is set by the client when it picks something up
  201. // and used to initiate server grab logic. If we actually pick something up
  202. // it's held in 'm_hAttachedObject'.
  203. EHANDLE m_hGrabbedEntity;
  204. EHANDLE m_hPortalThroughWhichGrabOccured;
  205. bool m_bForcingDrop;
  206. CNetworkVar( bool, m_bUseVMGrab );
  207. CNetworkVar( bool, m_bUsingVMGrabState );
  208. float m_flUseKeyStartTime; // for long duration uses, record the initial keypress start time
  209. float m_flAutoGrabLockOutTime;
  210. void SetForcedGrabControllerType( ForcedGrabControllerType type );
  211. ForcedGrabControllerType m_ForcedGrabController;
  212. // Object we're successfully holding we network down to the client
  213. // for clientside simulation under multiplayer
  214. CNetworkHandle( CBaseEntity, m_hAttachedObject );
  215. CNetworkQAngle( m_vecCarriedObjectAngles );
  216. //not simulating physics on the client, network down any inability the held object has in reaching it's target position/orientation
  217. CNetworkVector( m_vecCarriedObject_CurPosToTargetPos );
  218. CNetworkQAngle( m_vecCarriedObject_CurAngToTargetAng );
  219. void SetUseKeyCooldownTime( float flCooldownDuration );
  220. void SetStuckOnPortalCollisionObject( void ) { m_bStuckOnPortalCollisionObject = true; }
  221. CWeaponPortalBase* GetActivePortalWeapon() const;
  222. void IncrementPortalsPlaced( bool bSecondaryPortal );
  223. void IncrementStepsTaken( void );
  224. void IncrementDistanceTaken( void );
  225. void UpdateSecondsTaken( void );
  226. void ResetThisLevelStats( void );
  227. int NumPortalsPlaced( void ) const { return m_StatsThisLevel.iNumPortalsPlaced; }
  228. int NumStepsTaken( void ) const { return m_StatsThisLevel.iNumStepsTaken; }
  229. float NumSecondsTaken( void ) const { return m_StatsThisLevel.fNumSecondsTaken; }
  230. float NumDistanceTaken( void ) const { return m_StatsThisLevel.fDistanceTaken; }
  231. bool IsHoldingEntity( CBaseEntity *pEnt );
  232. float GetHeldObjectMass( IPhysicsObject *pHeldObject );
  233. void SetNeuroToxinDamageTime( float fCountdownSeconds ) { m_fNeuroToxinDamageTime = gpGlobals->curtime + fCountdownSeconds; }
  234. void IncNumCamerasDetatched( void ) { ++m_iNumCamerasDetatched; }
  235. int GetNumCamerasDetatched( void ) const { return m_iNumCamerasDetatched; }
  236. void MarkClientCheckPVSDirty( void ) { m_bClientCheckPVSDirty = true; }
  237. void SetIsHoldingObject( bool bSet ) { m_bIsHoldingSomething = bSet; }
  238. virtual void ApplyPortalTeleportation( const CPortal_Base2D *pEnteredPortal, CMoveData *pMove );
  239. Vector m_vecTotalBulletForce; //Accumulator for bullet force in a single frame
  240. bool m_bSilentDropAndPickup;
  241. // Tracks our ragdoll entity.
  242. CNetworkHandle( CBaseEntity, m_hRagdoll ); // networked entity handle
  243. #if USE_SLOWTIME
  244. bool IsSlowingTime( void ) { return ( m_PortalLocal.m_bSlowingTime || UTIL_TimeScaleIsNonStandard() ); }
  245. #endif // USE_SLOWTIME
  246. void SetAirControlSupressionTime( float flDuration ) { m_PortalLocal.m_flAirControlSupressionTime = flDuration; }
  247. bool IsSuppressingAirControl( void ) { return m_PortalLocal.m_flAirControlSupressionTime != 0.0f; }
  248. virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
  249. virtual void ModifyOrAppendCriteria( AI_CriteriaSet& criteriaSet );
  250. float GetImplicitVerticalStepSpeed() const;
  251. void SetImplicitVerticalStepSpeed( float speed );
  252. const CPortalPlayerLocalData& GetPortalPlayerLocalData() const;
  253. virtual Vector EyePosition();
  254. #if USE_SLOWTIME
  255. // Time modulation
  256. void StartSlowingTime( float flDuration );
  257. void StopSlowingTime( void );
  258. #endif // USE_SLOWTIME
  259. void ShowViewFinder( void );
  260. void HideViewFinder( void );
  261. // Coop ping effect
  262. void PlayCoopPingEffect( void );
  263. CNetworkVar( bool, m_bPitchReorientation );
  264. CNetworkHandle( CPortal_Base2D, m_hPortalEnvironment ); //if the player is in a portal environment, this is the associated portal
  265. friend class CPortal_Base2D;
  266. virtual CBaseEntity* EntSelectSpawnPoint( void );
  267. void PickTeam( void );
  268. static void ClientDisconnected( edict_t *pPlayer );
  269. virtual void ChangeTeam( int iTeamNum );
  270. int FlashlightIsOn( void );
  271. bool FlashlightTurnOn( bool playSound /*= false*/ );
  272. void FlashlightTurnOff( bool playSound /*= false*/ );
  273. void SetInTractorBeam( CTrigger_TractorBeam *pTractorBeam );
  274. void SetLeaveTractorBeam( CTrigger_TractorBeam *pTractorBeam, bool bKeepFloating );
  275. CTrigger_TractorBeam* GetTractorBeam( void ) const { return m_PortalLocal.m_hTractorBeam.Get(); }
  276. friend class CPortalGameMovement;
  277. void PreventCrouchJump( CUserCmd* ucmd );
  278. void BridgeRemovedFromUnder( void );
  279. void WasDroppedByOtherPlayerWhileTaunting() { m_bWasDroppedByOtherPlayerWhileTaunting = true; }
  280. void OnPlayerLanded();
  281. void IncWheatleyMonitorDestructionCount( void ) { m_nWheatleyMonitorDestructionCount++; }
  282. int GetWheatleyMonitorDestructionCount( void ) { return m_nWheatleyMonitorDestructionCount; }
  283. void TurnOffPotatos( void ) { m_bPotatos = false; }
  284. void TurnOnPotatos( void ) { m_bPotatos = true; }
  285. void PlayCoopStepSound( const Vector& origin, int side, float volume );
  286. protected:
  287. mutable Vector m_vWorldSpaceCenterHolder; //WorldSpaceCenter() returns a reference, need an actual value somewhere
  288. CNetworkVarEmbedded( CPortalPlayerLocalData, m_PortalLocal );
  289. CHandle< CNPC_SecurityCamera > m_hRemoteTauntCamera;
  290. void RespawnPlayer( void );
  291. private:
  292. virtual const char *GetPlayerModelName( void );
  293. void PlayUseDenySound( void );
  294. public:
  295. void Taunt( const char *pchTauntForce = NULL, bool bAuto = false );
  296. private:
  297. bool SolveTeamTauntPositionAndAngles( CPortal_Player *pInitiator );
  298. bool ValidateTeamTaunt( CPortal_Player *pInitiator, Vector &vInitiatorPos, QAngle &angInitiatorAng, Vector &vAcceptorPos, QAngle &angAcceptorAng, bool bRecursed = false );
  299. void StartTaunt( void );
  300. bool FindRemoteTauntViewpoint( Vector *pOriginOut, QAngle *pAnglesOut );
  301. #if USE_SLOWTIME
  302. CBaseEntity *m_pSlowTimeColorFX;
  303. #endif // USE_SLOWTIME
  304. CSoundPatch *m_pWooshSound;
  305. CSoundPatch *m_pGrabSound;
  306. int m_nWheatleyMonitorDestructionCount;
  307. CNetworkQAngleXYZ( m_angEyeAngles );
  308. CPortalPlayerAnimState* m_PlayerAnimState;
  309. int m_iLastWeaponFireUsercmd;
  310. CNetworkVar( int, m_iSpawnInterpCounter );
  311. CNetworkVar( int, m_iPlayerSoundType );
  312. CUtlVector<ScriptedNPCInteraction_t> m_ScriptedInteractions;
  313. CNetworkVar( bool, m_bPingDisabled );
  314. CNetworkVar( bool, m_bTauntDisabled );
  315. CNetworkVar( bool, m_bTauntRemoteView );
  316. bool m_bTauntRemoteViewFOVFixup;
  317. CNetworkVector( m_vecRemoteViewOrigin );
  318. CNetworkQAngle( m_vecRemoteViewAngles );
  319. CNetworkVar( float, m_fTauntCameraDistance );
  320. CNetworkVar( int, m_nTeamTauntState );
  321. CNetworkVector( m_vTauntPosition );
  322. CNetworkQAngle( m_vTauntAngles );
  323. CNetworkQAngle( m_vPreTauntAngles );
  324. CNetworkVar( bool, m_bTrickFire );
  325. CNetworkHandle( CPortal_Player, m_hTauntPartnerInRange );
  326. CNetworkString( m_szTauntForce, PORTAL2_MP_TEAM_TAUNT_FORCE_LENGTH );
  327. CNetworkVar( bool, m_bHeldObjectOnOppositeSideOfPortal );
  328. CNetworkHandle( CPortal_Base2D, m_hHeldObjectPortal ); // networked entity handle
  329. #if USE_SLOWTIME
  330. bool m_bHasPlayedSlowTimeStopSound;
  331. #endif // USE_SLOWTIME
  332. bool m_bIntersectingPortalPlane;
  333. bool m_bStuckOnPortalCollisionObject;
  334. bool m_bPlayUseDenySound; // Signaled by PlayerUse, but can be unset by HL2 ladder code...
  335. float m_fNeuroToxinDamageTime;
  336. CNetworkVarEmbedded( PortalPlayerStatistics_t, m_StatsThisLevel );
  337. float m_fTimeLastNumSecondsUpdate;
  338. Vector m_vPrevPosition;
  339. int m_iNumCamerasDetatched;
  340. // In multiplayer, last time we used a coop ping to draw our partner's attention
  341. float m_flLastPingTime;
  342. // When a portal is placed in the same cluster as us, we flip this on
  343. // to signal the updating of the g_ClientCheck's cached PVS bits.
  344. bool m_bClientCheckPVSDirty;
  345. float m_flUseKeyCooldownTime; // Disable use key until curtime >= this number
  346. CNetworkVar( bool, m_bIsHoldingSomething );
  347. float m_flImplicitVerticalStepSpeed; // When moving with step code, the player has an implicit vertical
  348. // velocity that keeps her on ramps, steps, etc. We need this to
  349. // correctly transform her velocity when she teleports.
  350. // to check if the player just respawned on client
  351. CNetworkVar( bool, m_iSpawnCounter );
  352. // to check if the player was dropped from the bridge by the other player
  353. bool m_bWasDroppedByOtherPlayerWhileTaunting;
  354. public: // PAINT SPECIFIC
  355. bool IsReorienting() const;
  356. Vector GetPaintGunShootPosition();
  357. bool IsPressingJumpKey() const;
  358. bool IsHoldingJumpKey() const;
  359. bool IsTryingToSuperJump( const PaintPowerInfo_t* pInfo = NULL ) const;
  360. void SetJumpedThisFrame( bool jumped );
  361. bool JumpedThisFrame() const;
  362. void SetBouncedThisFrame( bool bounced );
  363. bool BouncedThisFrame() const;
  364. InAirState GetInAirState() const;
  365. bool WantsToSwapGuns( void );
  366. void SetWantsToSwapGuns( bool bWantsToSwap );
  367. bool IsUsingPostTeleportationBox() const;
  368. const Vector& GetInputVector() const;
  369. void SetInputVector( const Vector& vInput );
  370. virtual Vector BodyTarget( const Vector &posSrc, bool bNoisy);
  371. const Vector& GetPrevGroundNormal() const;
  372. void SetPrevGroundNormal( const Vector& vPrevNormal );
  373. float PredictedAirTimeEnd( void ); // Uses the current velocity
  374. float PredictedBounce( void ); // Uses the current velocity
  375. void OnBounced( float fTimeOffset = 0.0f );
  376. virtual void SetFogController( CFogController *pFogController );
  377. virtual PaintPowerType GetPaintPowerAtPoint( const Vector& worldContactPt ) const;
  378. virtual void Paint( PaintPowerType type, const Vector& worldContactPt );
  379. virtual void CleansePaint();
  380. void Reorient( QAngle& viewAngles );
  381. float GetReorientationProgress() const;
  382. bool IsDoneReorienting() const;
  383. virtual const Vector GetPlayerMins() const;
  384. virtual const Vector GetPlayerMaxs() const;
  385. const Vector& GetHullMins() const;
  386. const Vector& GetHullMaxs() const;
  387. const Vector& GetStandHullMins() const;
  388. const Vector& GetStandHullMaxs() const;
  389. const Vector& GetDuckHullMins() const;
  390. const Vector& GetDuckHullMaxs() const;
  391. float GetHullHeight() const;
  392. float GetHullWidth() const;
  393. float GetStandHullHeight() const;
  394. float GetStandHullWidth() const;
  395. float GetDuckHullHeight() const;
  396. float GetDuckHullWidth() const;
  397. virtual void UpdateCollisionBounds();
  398. virtual void InitVCollision( const Vector &vecAbsOrigin, const Vector &vecAbsVelocity );
  399. bool PlayGesture( const char *pGestureName );
  400. void SetAirDuck( bool bDuckedInAir );
  401. StickCameraState GetStickCameraState() const;
  402. void SetQuaternionPunch( const Quaternion& qPunch );
  403. void DecayQuaternionPunch();
  404. using BaseClass::AddSurfacePaintPowerInfo;
  405. void AddSurfacePaintPowerInfo( const BrushContact& contact, char const* context = 0 );
  406. void AddSurfacePaintPowerInfo( const trace_t& trace, char const* context = 0 );
  407. void SetEyeUpOffset( const Vector& vOldUp, const Vector& vNewUp );
  408. void SetEyeOffset( const Vector& vOldOrigin, const Vector& vNewOrigin );
  409. void GivePlayerPaintGun( bool bActivatePaintPowers, bool bSwitchTo );
  410. void GivePlayerPortalGun( bool bUpgraded, bool bSwitchTo );
  411. void GivePlayerWearable( const char *pItemName );
  412. void RemovePlayerWearable( const char *pItemName );
  413. void ResetBounceCount() { m_nBounceCount = 0; }
  414. void ResetAirTauntCount() { m_nAirTauntCount = 0; }
  415. // Anim state code
  416. CNetworkVarEmbedded( CPortalPlayerShared, m_Shared );
  417. void SetHullHeight( float flHeight );
  418. virtual void ChooseActivePaintPowers( PaintPowerInfoVector& activePowers );
  419. bool IsFullyConnected() { return m_bIsFullyConnected; }
  420. void OnFullyConnected();
  421. void NetworkPortalTeleportation( CBaseEntity *pOther, CPortal_Base2D *pPortal, float fTime, bool bForcedDuck );
  422. private: // PAINT SPECIFIC
  423. void DecayEyeOffset();
  424. void GivePortalPlayerItems( void );
  425. // Find all the contacts
  426. void DeterminePaintContacts();
  427. void PredictPaintContacts( const Vector& contactBoxMin,
  428. const Vector& contactBoxMax,
  429. const Vector& traceBoxMin,
  430. const Vector& traceBoxMax,
  431. float lookAheadTime,
  432. char const* context );
  433. void ChooseBestPaintPowersInRange( PaintPowerChoiceResultArray& bestPowers,
  434. PaintPowerConstIter begin,
  435. PaintPowerConstIter end,
  436. const PaintPowerChoiceCriteria_t& info ) const;
  437. // Paint Power User Implementation
  438. virtual PaintPowerState ActivateSpeedPower( PaintPowerInfo_t& powerInfo );
  439. virtual PaintPowerState UseSpeedPower( PaintPowerInfo_t& powerInfo );
  440. virtual PaintPowerState DeactivateSpeedPower( PaintPowerInfo_t& powerInfo );
  441. virtual PaintPowerState ActivateBouncePower( PaintPowerInfo_t& powerInfo );
  442. virtual PaintPowerState UseBouncePower( PaintPowerInfo_t& powerInfo );
  443. virtual PaintPowerState DeactivateBouncePower( PaintPowerInfo_t& powerInfo );
  444. void PlayPaintSounds( const PaintPowerChoiceResultArray& touchedPowers );
  445. void UpdatePaintedPower();
  446. void UpdateAirInputScaleFadeIn();
  447. void UpdateInAirState();
  448. void CachePaintPowerChoiceResults( const PaintPowerChoiceResultArray& choiceInfo );
  449. bool LateSuperJumpIsValid() const;
  450. void RecomputeBoundsForOrientation();
  451. void TryToChangeCollisionBounds( const Vector& newStandHullMin,
  452. const Vector& newStandHullMax,
  453. const Vector& newDuckHullMin,
  454. const Vector& newDuckHullMax );
  455. float SpeedPaintAcceleration( float flDefaultMaxSpeed,
  456. float flSpeed,
  457. float flWishCos,
  458. float flWishDirSpeed ) const;
  459. bool CheckToUseBouncePower( PaintPowerInfo_t& info );
  460. // stick camera
  461. void RotateUpVector( Vector& vForward, Vector& vUp );
  462. void SnapCamera( StickCameraState nCameraState, bool bLookingInBadDirection );
  463. void PostTeleportationCameraFixup( const CPortal_Base2D *pEnteredPortal );
  464. // Paint power debug
  465. void DrawJumpHelperDebug( PaintPowerConstIter begin, PaintPowerConstIter end, float duration, bool noDepthTest, const PaintPowerInfo_t* pSelected ) const;
  466. // PAINT POWER STATE
  467. PaintPowerInfo_t m_CachedJumpPower;
  468. Vector m_vInputVector;
  469. float m_flCachedJumpPowerTime;
  470. float m_flUsePostTeleportationBoxTime;
  471. float m_flSpeedDecelerationTime;
  472. float m_flPredictedJumpTime;
  473. bool m_bJumpWasPressedWhenForced; // The jump button was actually pressed when ForceDuckThisFrame() was called
  474. int m_nBounceCount; // Number of bounces in a row without touching the ground
  475. float m_LastGroundBouncePlaneDistance;
  476. float m_flLastSuppressedBounceTime;
  477. float m_flTimeSinceLastTouchedPower[3];
  478. int m_nPortalsEnteredInAirFlags;
  479. int m_nAirTauntCount;
  480. bool m_bIsFullyConnected;
  481. CNetworkVar( float, m_flMotionBlurAmount );
  482. //Swapping guns
  483. CNetworkVar( bool, m_bWantsToSwapGuns );
  484. bool m_bSendSwapProximityFailEvent;
  485. CNetworkVar( bool, m_bPotatos );
  486. PlayerGunType m_PlayerGunType;
  487. PlayerGunType m_PlayerGunTypeWhenDead;
  488. bool m_bSpawnFromDeath;
  489. bool m_bIsBendy;
  490. Vector m_vPrevGroundNormal; // Our ground normal from the previous frame
  491. Vector m_vGravity;
  492. CNetworkVar( float, m_flHullHeight );
  493. //encoding these messages directly in the player to ensure it's received in sync with the corresponding entity post-teleport update
  494. //each player has their own copy of the buffer that is only sent to them
  495. CUtlVector<CEntityPortalledNetworkMessage> m_EntityPortalledNetworkMessages;
  496. enum
  497. {
  498. MAX_ENTITY_PORTALLED_NETWORK_MESSAGES = 32,
  499. };
  500. CNetworkVar( uint32, m_iEntityPortalledNetworkMessageCount ); //always ticks up by one per add
  501. //variables we'd like to persist between instances of grab controllers
  502. struct GrabControllerPersistentVars_t
  503. {
  504. CHandle<CPortal_Base2D> m_hOscillationWatch;
  505. CHandle<CPortal_Base2D> m_hLookingThroughPortalLastUpdate;
  506. Vector m_vLastTargetPosition;
  507. bool m_bLastUpdateWasForcedPull;
  508. void ResetOscillationWatch( void )
  509. {
  510. m_hOscillationWatch = NULL;
  511. m_hLookingThroughPortalLastUpdate = NULL;
  512. m_vLastTargetPosition.Init();
  513. m_bLastUpdateWasForcedPull = false;
  514. }
  515. };
  516. GrabControllerPersistentVars_t m_GrabControllerPersistentVars;
  517. struct RecentPortalTransform_t
  518. {
  519. int command_number;
  520. CHandle<CPortal_Base2D> Portal;
  521. matrix3x4_t matTransform;
  522. };
  523. CUtlVector<RecentPortalTransform_t> m_PendingPortalTransforms; //portal transforms we've sent to the client but they have not yet acknowledged, needed for some input fixup
  524. friend class CPortalPlayerShared;
  525. friend class CGrabController;
  526. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  527. //----------------------------
  528. // ECONOMY INVENTORY MANAGEMENT
  529. public:
  530. // IInventoryUpdateListener
  531. virtual void InventoryUpdated( CPlayerInventory *pInventory );
  532. virtual void SOCacheUnsubscribed( const CSteamID & steamIDOwner ) { m_Shared.SetLoadoutUnavailable( true ); }
  533. void UpdateInventory( bool bInit );
  534. void VerifySOCache();
  535. // Inventory access
  536. CPortalPlayerInventory *Inventory( void ) { return &m_Inventory; }
  537. CEconItemView *GetItemInLoadoutSlot( int iLoadoutSlot );
  538. private:
  539. CPortalPlayerInventory m_Inventory;
  540. #endif //!defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  541. bool m_bReadyForDLCItemUpdates;
  542. };
  543. inline CPortal_Player *ToPortalPlayer( CBaseEntity *pEntity )
  544. {
  545. if ( !pEntity || !pEntity->IsPlayer() )
  546. return NULL;
  547. return assert_cast<CPortal_Player*>( pEntity );
  548. }
  549. inline CPortal_Player *GetPortalPlayer( int iPlayerIndex )
  550. {
  551. return static_cast<CPortal_Player*>( UTIL_PlayerByIndex( iPlayerIndex ) );
  552. }
  553. #endif //PORTAL_PLAYER_H