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.

68 lines
1.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "func_ladder.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. //-----------------------------------------------------------------------------
  11. // Purpose: A transient entity used to construct a true CFuncLadder
  12. // FIXME: THIS ENTITY IS OBSOLETE NOW, SHOULD BE REMOVED FROM HERE AND .FGD AT SOME POINT!!!
  13. //-----------------------------------------------------------------------------
  14. class CFuncLadderEndPoint : public CBaseEntity
  15. {
  16. public:
  17. DECLARE_CLASS( CFuncLadderEndPoint, CBaseEntity );
  18. virtual void Activate();
  19. private:
  20. bool Validate();
  21. };
  22. LINK_ENTITY_TO_CLASS( func_ladderendpoint, CFuncLadderEndPoint );
  23. void CFuncLadderEndPoint::Activate()
  24. {
  25. BaseClass::Activate();
  26. if ( IsMarkedForDeletion() )
  27. return;
  28. Validate();
  29. }
  30. bool CFuncLadderEndPoint::Validate()
  31. {
  32. // Find the the other end
  33. Vector startPos = GetAbsOrigin();
  34. CFuncLadderEndPoint *other = dynamic_cast< CFuncLadderEndPoint * >( GetNextTarget() );
  35. if ( !other )
  36. {
  37. DevMsg( 1, "func_ladderendpoint(%s) without matching target\n", GetEntityName().ToCStr() );
  38. return false;
  39. }
  40. Vector endPos = other->GetAbsOrigin();
  41. CFuncLadder *ladder = ( CFuncLadder * )CreateEntityByName( "func_useableladder" );
  42. if ( ladder )
  43. {
  44. ladder->SetEndPoints( startPos, endPos );
  45. ladder->SetAbsOrigin( GetAbsOrigin() );
  46. ladder->SetParent( GetParent() );
  47. ladder->SetName( GetEntityName() );
  48. ladder->Spawn();
  49. }
  50. // Delete both endpoints
  51. UTIL_Remove( other );
  52. UTIL_Remove( this );
  53. return true;
  54. }