diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/server/te_beamspline.cpp | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/server/te_beamspline.cpp')
| -rw-r--r-- | mp/src/game/server/te_beamspline.cpp | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/mp/src/game/server/te_beamspline.cpp b/mp/src/game/server/te_beamspline.cpp new file mode 100644 index 00000000..56b1a7b6 --- /dev/null +++ b/mp/src/game/server/te_beamspline.cpp @@ -0,0 +1,134 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $Workfile: $
+// $Date: $
+//
+//-----------------------------------------------------------------------------
+// $Log: $
+//
+// $NoKeywords: $
+//=============================================================================//
+#include "cbase.h"
+#include "basetempentity.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+#define MAX_SPLINE_POINTS 16
+//-----------------------------------------------------------------------------
+// Purpose: Dispatches beam spline tempentity
+//-----------------------------------------------------------------------------
+class CTEBeamSpline : public CBaseTempEntity
+{
+public:
+ DECLARE_CLASS( CTEBeamSpline, CBaseTempEntity );
+
+ CTEBeamSpline( const char *name );
+ virtual ~CTEBeamSpline( void );
+
+ virtual void Test( const Vector& current_origin, const QAngle& current_angles );
+
+ DECLARE_SERVERCLASS();
+
+public:
+ CNetworkArray( Vector, m_vecPoints, MAX_SPLINE_POINTS );
+ CNetworkVar( int, m_nPoints );
+};
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *name -
+//-----------------------------------------------------------------------------
+CTEBeamSpline::CTEBeamSpline( const char *name ) :
+ CBaseTempEntity( name )
+{
+ int i;
+ for ( i = 0; i < MAX_SPLINE_POINTS; i++ )
+ {
+ m_vecPoints.GetForModify( i ).Init();
+ }
+ m_nPoints = 0;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+CTEBeamSpline::~CTEBeamSpline( void )
+{
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *current_origin -
+// *current_angles -
+//-----------------------------------------------------------------------------
+void CTEBeamSpline::Test( const Vector& current_origin, const QAngle& current_angles )
+{
+ // Fill in data
+ m_nPoints = 6;
+ Vector m_vecStart = current_origin;
+
+ Vector forward, right;
+
+ m_vecStart[2] += 24;
+
+ AngleVectors( current_angles, &forward, &right, 0 );
+ forward[2] = 0.0;
+ VectorNormalize( forward );
+
+ VectorMA( m_vecStart, 100.0, forward, m_vecStart );
+
+ VectorMA( m_vecStart, -128.0, right, m_vecStart );
+
+ for ( int i = 0; i < m_nPoints; i++ )
+ {
+ m_vecPoints.Set( i, m_vecStart );
+ VectorMA( m_vecStart, 128/m_nPoints, right, m_vecStart );
+ VectorMA( m_vecStart, 30.0/m_nPoints, forward, m_vecStart );
+ }
+
+ CBroadcastRecipientFilter filter;
+ Create( filter, 0.0 );
+}
+
+IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEBeamSpline, DT_TEBeamSpline)
+ SendPropInt( SENDINFO( m_nPoints ), 5, SPROP_UNSIGNED ),
+
+ SendPropArray(
+ SendPropVector( SENDINFO_ARRAY(m_vecPoints), -1, SPROP_COORD),
+ m_vecPoints)
+END_SEND_TABLE()
+
+
+// Singleton to fire TEBeamSpline objects
+static CTEBeamSpline g_TEBeamSpline( "BeamSpline" );
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : msg_dest -
+// delay -
+// *origin -
+// *recipient -
+// points -
+// *points -
+//-----------------------------------------------------------------------------
+void TE_BeamSpline( IRecipientFilter& filter, float delay,
+ int points, Vector* rgPoints )
+{
+ int i;
+ g_TEBeamSpline.m_nPoints = points;
+ for ( i = 0; i < points; i++ )
+ {
+ g_TEBeamSpline.m_vecPoints.Set( i, rgPoints[ i ] );
+ }
+
+ for ( ; i < MAX_SPLINE_POINTS; i++ )
+ {
+ g_TEBeamSpline.m_vecPoints.GetForModify( i ).Init();
+ }
+
+ // Send it over the wire
+ g_TEBeamSpline.Create( filter, delay );
+}
\ No newline at end of file |