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.

82 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. // -------------------------------------------------------------------------------- //
  12. // An entity used to test traceline
  13. // -------------------------------------------------------------------------------- //
  14. class CTestTraceline : public CPointEntity
  15. {
  16. public:
  17. DECLARE_CLASS( CTestTraceline, CPointEntity );
  18. void Spawn( void );
  19. int UpdateTransmitState();
  20. DECLARE_SERVERCLASS();
  21. DECLARE_DATADESC();
  22. private:
  23. void Spin( void );
  24. };
  25. // This table encodes the CBaseEntity data.
  26. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTestTraceline, DT_TestTraceline)
  27. SendPropInt (SENDINFO(m_clrRender), 32, SPROP_UNSIGNED ),
  28. SendPropVector (SENDINFO(m_vecOrigin), 19, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER),
  29. SendPropFloat (SENDINFO_VECTORELEM(m_angRotation, 0), 19, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER),
  30. SendPropFloat (SENDINFO_VECTORELEM(m_angRotation, 1), 19, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER),
  31. SendPropFloat (SENDINFO_VECTORELEM(m_angRotation, 2), 19, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER),
  32. SendPropEHandle (SENDINFO_NAME(m_hMoveParent, moveparent)),
  33. END_SEND_TABLE()
  34. LINK_ENTITY_TO_CLASS( test_traceline, CTestTraceline );
  35. BEGIN_DATADESC( CTestTraceline )
  36. // Function Pointers
  37. DEFINE_FUNCTION( Spin ),
  38. END_DATADESC()
  39. void CTestTraceline::Spawn( void )
  40. {
  41. SetRenderColor( 255, 255, 255, 255 );
  42. SetNextThink( gpGlobals->curtime );
  43. SetThink( &CTestTraceline::Spin );
  44. }
  45. void CTestTraceline::Spin( void )
  46. {
  47. static ConVar traceline_spin( "traceline_spin","1" );
  48. if (traceline_spin.GetInt())
  49. {
  50. float s = sin( gpGlobals->curtime );
  51. QAngle angles = GetLocalAngles();
  52. angles[0] = 180.0 * 0.5 * (s * s * s + 1.0f) + 90;
  53. angles[1] = gpGlobals->curtime * 10;
  54. SetLocalAngles( angles );
  55. }
  56. SetNextThink( gpGlobals->curtime );
  57. }
  58. int CTestTraceline::UpdateTransmitState()
  59. {
  60. return SetTransmitState( FL_EDICT_ALWAYS );
  61. }