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.

76 lines
2.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "entityblocker.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. LINK_ENTITY_TO_CLASS( entity_blocker, CEntityBlocker );
  11. //-----------------------------------------------------------------------------
  12. // Purpose:
  13. // Input : &origin -
  14. // &mins -
  15. // &maxs -
  16. // NULL -
  17. // Output : CEntityBlocker
  18. //-----------------------------------------------------------------------------
  19. CEntityBlocker *CEntityBlocker::Create( const Vector &origin, const Vector &mins, const Vector &maxs, CBaseEntity *pOwner, bool bBlockPhysics )
  20. {
  21. CEntityBlocker *pBlocker = (CEntityBlocker *) CBaseEntity::Create( "entity_blocker", origin, vec3_angle, pOwner );
  22. if ( pBlocker != NULL )
  23. {
  24. pBlocker->SetSize( mins, maxs );
  25. if ( bBlockPhysics )
  26. {
  27. pBlocker->VPhysicsInitStatic();
  28. }
  29. }
  30. return pBlocker;
  31. }
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. //-----------------------------------------------------------------------------
  35. void CEntityBlocker::Spawn( void )
  36. {
  37. SetSolid( SOLID_BBOX );
  38. AddSolidFlags( FSOLID_CUSTOMRAYTEST );
  39. }
  40. //-----------------------------------------------------------------------------
  41. // Purpose: Entity blockers don't block tracelines so they don't screw up weapon fire, etc
  42. //-----------------------------------------------------------------------------
  43. bool CEntityBlocker::TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace )
  44. {
  45. return false;
  46. }
  47. //------------------------------------------------------------------------------
  48. // Purpose :
  49. // Input :
  50. // Output :
  51. //------------------------------------------------------------------------------
  52. void CC_Test_Entity_Blocker( void )
  53. {
  54. CBasePlayer *pPlayer = UTIL_GetCommandClient();
  55. Vector vecForward;
  56. pPlayer->GetVectors( &vecForward, NULL, NULL );
  57. trace_t tr;
  58. Vector vecOrigin = pPlayer->GetAbsOrigin() + (vecForward * 256);
  59. UTIL_TraceHull( vecOrigin + Vector(0,0,256), vecOrigin - Vector(0,0,256), VEC_HULL_MIN, VEC_HULL_MAX, MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &tr );
  60. if ( !tr.allsolid && !tr.startsolid )
  61. {
  62. CEntityBlocker::Create( tr.endpos, VEC_HULL_MIN, VEC_HULL_MAX, NULL, true );
  63. NDebugOverlay::Box( tr.endpos, VEC_HULL_MIN, VEC_HULL_MAX, 0, 255, 0, 64, 1000.0 );
  64. }
  65. }
  66. static ConCommand test_entity_blocker("test_entity_blocker", CC_Test_Entity_Blocker, "Test command that drops an entity blocker out in front of the player.", FCVAR_CHEAT );