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.

122 lines
4.9 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef PROP_PORTAL_H
  8. #define PROP_PORTAL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "baseanimating.h"
  13. #include "PortalSimulation.h"
  14. #include "portal_base2d.h"
  15. #include "../portal2/func_portalled.h"
  16. // FIX ME
  17. #include "portal_shareddefs.h"
  18. // This is for portals not yet linked.
  19. #define PORTAL_LINKAGE_GROUP_INVALID 255
  20. class CPhysicsCloneArea;
  21. class CProp_Portal : public CPortal_Base2D
  22. {
  23. public:
  24. DECLARE_CLASS( CProp_Portal, CPortal_Base2D );
  25. DECLARE_SERVERCLASS();
  26. DECLARE_DATADESC();
  27. CProp_Portal( void );
  28. virtual ~CProp_Portal( void );
  29. CSoundPatch *m_pAmbientSound;
  30. virtual void Precache( void );
  31. virtual void CreateSounds( void );
  32. virtual void StopLoopingSounds( void );
  33. virtual void Spawn( void );
  34. virtual void Activate( void );
  35. virtual void OnRestore( void );
  36. void DelayedPlacementThink( void );
  37. static const char * s_szDelayedPlacementThinkContext;
  38. void PlacePortal( const Vector &vOrigin, const QAngle &qAngles, PortalPlacementResult_t eResult, bool bDelay = false );
  39. void NewLocation( const Vector &vOrigin, const QAngle &qAngles );
  40. virtual void PreTeleportTouchingEntity( CBaseEntity *pOther );
  41. virtual void PostTeleportTouchingEntity( CBaseEntity *pOther );
  42. void ResetModel( void ); //sets the model and bounding box
  43. void DoFizzleEffect( int iEffect, bool bDelayedPos = true ); //display cool visual effect
  44. void CreatePortalEffect( CBasePlayer* pPlayer, int iEffect, Vector vecOrigin, QAngle qAngles, int nTeam, int nPortalNum );
  45. void OnPortalDeactivated( void );
  46. void Fizzle( void );
  47. void ActivatePortal( void );
  48. void DeactivatePortal( void );
  49. void InputSetActivatedState( inputdata_t &inputdata );
  50. void InputFizzle( inputdata_t &inputdata );
  51. void InputNewLocation( inputdata_t &inputdata );
  52. void InputResize( inputdata_t &inputdata );
  53. void InputSetLinkageGroupId( inputdata_t &inputdata );
  54. void AddToLinkageGroup( void );
  55. virtual void UpdatePortalLinkage( void );
  56. virtual void StartTouch( CBaseEntity *pOther );
  57. virtual void Touch( CBaseEntity *pOther );
  58. virtual void EndTouch( CBaseEntity *pOther );
  59. //virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo ) { return FL_EDICT_ALWAYS; }
  60. virtual int UpdateTransmitState( void ) // set transmit filter to transmit always
  61. {
  62. return SetTransmitState( FL_EDICT_ALWAYS );
  63. }
  64. private:
  65. void DispatchPortalPlacementParticles( bool bIsSecondaryPortal );
  66. void UpdatePortalDetectorsOnPortalMoved( void );
  67. void UpdatePortalDetectorsOnPortalActivated( void );
  68. unsigned char m_iLinkageGroupID; //a group ID specifying which portals this one can possibly link to
  69. PortalFizzleType_t m_FizzleEffect;
  70. CNetworkHandle( CBaseEntity, m_hFiredByPlayer );
  71. CHandle<CFunc_Portalled> m_NotifyOnPortalled; //an entity that forwards notifications of teleports to map logic entities
  72. public:
  73. friend class CPropPortalTunnel;
  74. inline unsigned char GetLinkageGroup( void ) const { return m_iLinkageGroupID; };
  75. void ChangeLinkageGroup( unsigned char iLinkageGroupID );
  76. void SetFiredByPlayer( CBasePlayer *pPlayer );
  77. inline CBasePlayer *GetFiredByPlayer( void ) const { return (CBasePlayer *)m_hFiredByPlayer.Get(); }
  78. inline void SetFuncPortalled( CFunc_Portalled *pPortalledEnt = NULL ) { m_NotifyOnPortalled = pPortalledEnt; }
  79. static bool ms_DefaultPortalSizeInitialized; // for CEG protection
  80. static float ms_DefaultPortalHalfWidth;
  81. static float ms_DefaultPortalHalfHeight;
  82. //NULL portal will return default width/height
  83. static void GetPortalSize( float &fHalfWidth, float &fHalfHeight, CProp_Portal *pPortal = NULL );
  84. //find a portal with the designated attributes, or creates one with them, favors active portals over inactive
  85. static CProp_Portal *FindPortal( unsigned char iLinkageGroupID, bool bPortal2, bool bCreateIfNothingFound = false );
  86. static const CUtlVector<CProp_Portal *> *GetPortalLinkageGroup( unsigned char iLinkageGroupID );
  87. virtual float GetMinimumExitSpeed( bool bPlayer, bool bEntranceOnFloor, bool bExitOnFloor, const Vector &vEntityCenterAtExit, CBaseEntity *pEntity ); //return -FLT_MAX for no minimum
  88. virtual float GetMaximumExitSpeed( bool bPlayer, bool bEntranceOnFloor, bool bExitOnFloor, const Vector &vEntityCenterAtExit, CBaseEntity *pEntity ); //return FLT_MAX for no maximum
  89. CNetworkVar( int, m_nPlacementAttemptParity ); //Increments every time we try to move the portal in a predictable way. Will send a network packet to catch cases where placement succeeds on the client, but fails on the server.
  90. };
  91. // Finds a free linkage id for a portal.
  92. unsigned char UTIL_GetUnusedLinkageID( void );
  93. #endif //#ifndef PROP_PORTAL_H