Authoring a Brush Entity/Code: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (Spam revert.)
Line 1: Line 1:
[http://2001.c3.hu/mas/pxwrvr.html miss shop au] [http://www.systemsupport.und.edu/cache/avatars/emo/dvqkdc.html kingdom come get it on lyrics] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/lgdctj.html volcano eruptions in the last 10 years] [http://www.plurpage.com/classifieds/cache/bihnnb.html wine buys] [http://www.systemsupport.und.edu/cache/avatars/emo/lexoiv.html ortho online] [http://kom-pas.de/3xcms/config/hkatuploads/images/vqcdci.html upenn 2009] [http://ndr.hu/rhodes/leejvn.html movie bookings] [http://www.salona-yachts.eu/misc/mkgrfi.html japanese manufactories steel] [http://2001.c3.hu/mas/wgpute.html the last rock show] [http://aura.c3.hu/thumb/xlktbh.html eviction forms free] [http://www.olemissfans.com/chatpro/image/iikdcn.html online library science programs] [http://www.plurpage.com/classifieds/cache/kjlfcl.html lgbt latino] [http://www.easypayinfo.com/subscribe/tmp/miajhn.html signs of alzheimers] [http://www.plurpage.com/classifieds/cache/quaptq.html marine radio licence] [http://activeimage.c3.hu/css/njjqqa.html online bible school of the south pacific] [http://2001.c3.hu/mas/wesjxr.html microsoft pptp server] [http://aura.c3.hu/thumb/jcxhdu.html ethnic sensitive] [http://kom-pas.de/3xcms/config/hkatuploads/images/rcmkmh.html internet explorer 7.0] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/donire.html natural logarithm expansion] [http://aura.c3.hu/thumb/ehbolq.html erotic lesbian sex stories] [http://kristinlyseggen.com/gallery/1documentaries/7travel/iaexon.html arabic numerals in europe] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/rpouil.html europe national anthem] [http://2001.c3.hu/mas/lbtdta.html nicaragua missions] [http://www.farmelco.hu/test/css/ascqwa.html 1 k scandinavia] [http://www.easypayinfo.com/subscribe/tmp/cvvdeg.html yahoo fr mail] [http://kom-pas.de/3xcms/config/hkatuploads/images/cvdhqx.html investigated] [http://www.salona-yachts.eu/misc/afocov.html people doing crazy things] [http://kom-pas.de/3xcms/config/hkatuploads/images/umutax.html ip router linksys] [http://www.olemissfans.com/chatpro/image/gljhrd.html purchase stock directly] [http://www.olemissfans.com/chatpro/image/ujgnaw.html window treatment baltimore] [http://informer.siam.edu/themes/hm/nhvfqr.html download audiovox ringtones] [http://www.systemsupport.und.edu/cache/avatars/emo/awvsqt.html audiovox ringtone] [http://www.stillwaterhomes.com/listings/images/pic/sdepmb.html trailer park boy quote] [http://activeimage.c3.hu/css/gsejho.html removing moles] [http://www.stillwaterhomes.com/listings/images/pic/mqssdc.html automotive diamond film window] [http://www.stillwaterhomes.com/listings/images/pic/kjbhje.html auto body part michigan] [http://kom-pas.de/3xcms/config/hkatuploads/images/hvbobl.html qt kde windows] [http://www.plurpage.com/classifieds/cache/gexnje.html supe bowl 39] [http://aura.c3.hu/thumb/daofuu.html modern day explorers] [http://ndr.hu/rhodes/tqqjiv.html pillow talk is extra] [http://www.stillwaterhomes.com/listings/images/pic/aafawo.html estimate electric bill] [http://www.systemsupport.und.edu/cache/avatars/emo/cwpkrh.html jay shawn singer] [http://www.salona-yachts.eu/misc/fbjbia.html reseau contact elle et lui] [http://aura.c3.hu/thumb/gcoxhx.html nam network news] [http://www.stillwaterhomes.com/listings/images/pic/brhpnb.html white book 2.0] [http://aura.c3.hu/thumb/rqujll.html reaction vessels] [http://www.olemissfans.com/chatpro/image/kqogas.html television cable advertising cost] [http://www.salona-yachts.eu/misc/qmfsve.html warcraft ii patch] [http://www.lowell.edu/styles/old_style/css/fhhuho.html steel structures inc] [http://ndr.hu/rhodes/bcanfe.html 1832 online] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/uefevk.html james roberts] [http://www.easypayinfo.com/subscribe/tmp/dmcugp.html one 2 many] [http://www.stillwaterhomes.com/listings/images/pic/guqaxa.html justice home] [http://aura.c3.hu/thumb/qfrnra.html apache mysql php windows installer] [http://www.salona-yachts.eu/misc/ttveov.html 1 blonde legally] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/jlfnab.html rising junior] [http://www.plurpage.com/classifieds/cache/fhrbbl.html las vegas land for sale] [http://www.plurpage.com/classifieds/cache/nhoqbl.html mp3 to car adapter] [http://www.olemissfans.com/chatpro/image/xsapjx.html 1 game heat piston] [http://kom-pas.de/3xcms/config/hkatuploads/images/btkall.html amount injury personal settlement] [http://kristinlyseggen.com/gallery/1documentaries/7travel/wpsuvl.html sun tech student loans] [http://troniny.ovh.org/gallery/layout/qoogin.html new home in las vegas nevada] [http://www.stillwaterhomes.com/listings/images/pic/nwwjgj.html the texas state flag] [http://www.stillwaterhomes.com/listings/images/pic/cqfhpx.html price singapore stock] [http://kom-pas.de/3xcms/config/hkatuploads/images/xuvubm.html amc movie theater times] [http://www.salona-yachts.eu/misc/txtnkf.html awareness site myspace.com] [http://kristinlyseggen.com/gallery/1documentaries/7travel/gclrre.html ethical aspects of information technology] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/fnmtub.html world war ii memorial washington d.c.] [http://kom-pas.de/3xcms/config/hkatuploads/images/faikgr.html michigan properties rental vacation] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/lwbhxs.html stereo bluetooth headsets] [http://activeimage.c3.hu/css/qwxudq.html real estate agent license texas] [http://www.plurpage.com/classifieds/cache/ewixcs.html rectum pic] [http://aura.c3.hu/thumb/narivp.html web photo album templates] [http://ndr.hu/rhodes/oalqlx.html someone told me lyrics] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/tfpbcd.html marine trades association of new jersey] [http://maps.my2gig.com/cache/aebnob.html klein high school texas] [http://troniny.ovh.org/gallery/layout/ngaubr.html yahoo page ranking] [http://activeimage.c3.hu/css/hidjqd.html massachusetts school closings tuesday] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/ivqchc.html applets chat java system] [http://kristinlyseggen.com/gallery/1documentaries/7travel/oxvfjf.html affirmative action and university of michigan] [http://www.stillwaterhomes.com/listings/images/pic/qrijoq.html tintin images] [http://www.lowell.edu/styles/old_style/css/kwilth.html s african pop music] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/eomoms.html job quant] [http://kom-pas.de/3xcms/config/hkatuploads/images/xflxts.html urban management consultants] [http://troniny.ovh.org/gallery/layout/snmjcs.html paul pratt library] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/pfexle.html junk email e-mail mail chris] [http://kom-pas.de/3xcms/config/hkatuploads/images/ixngqj.html auto mag upgrade] [http://mkatzenbach.de/Website_MK_alt/content/cache/dir/end001/bivjiv.html 8 inch round cake pan] [http://aura.c3.hu/thumb/ctsqtf.html violent crime rate by state] [http://www.easypayinfo.com/subscribe/tmp/gkwjun.html research technology management magazine] [http://www.housing.und.edu/reshalls/blog/wp-content/uploads/2007/04/img/qehctl.html sildenafil] [http://2001.c3.hu/mas/cthxbe.html airline flight paths] [http://www.housing.und.edu/reshalls/blog/wp-content/uploads/2007/04/img/fnbomb.html cheap nexium] [http://ndr.hu/rhodes/onrljw.html new york tourist] [http://2001.c3.hu/mas/ijahho.html residental schools] [http://aura.c3.hu/thumb/nrqagm.html playroom flooring] [http://kom-pas.de/3xcms/config/hkatuploads/images/xklvji.html nail gun nail] [http://www.olemissfans.com/chatpro/image/kocolk.html is my domain name available to register] [http://www.easypayinfo.com/subscribe/tmp/iuqmwc.html roosevelts new deals] [http://www.salona-yachts.eu/misc/huagbc.html japanese lesbian gallery]
[[Category:Programming]]
[[Category:Programming]]
<pre>
<pre>

Revision as of 07:39, 12 November 2007

//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ========
//
// Purpose: Simple brush entity that moves when touched
//
//=============================================================================

#include "cbase.h"

class CMyBrushEntity : public CBaseToggle
{
public:
	DECLARE_CLASS( CMyBrushEntity, CBaseToggle );
	DECLARE_DATADESC();

	void Spawn( void );
	bool CreateVPhysics( void );

	void BrushTouch( CBaseEntity *pOther );
};

LINK_ENTITY_TO_CLASS( my_brush_entity, CMyBrushEntity );

// Start of our data description for the class
BEGIN_DATADESC( CMyBrushEntity )
	
	// Declare this function as being a touch function
	DEFINE_ENTITYFUNC( BrushTouch ),

END_DATADESC()

//-----------------------------------------------------------------------------
// Purpose: Sets up the entity's initial state
//-----------------------------------------------------------------------------
void CMyBrushEntity::Spawn( void )
{
	// We want to capture touches from other entities
	SetTouch( &CMyBrushEntity::BrushTouch );

	// We should collide with physics
	SetSolid( SOLID_VPHYSICS );
	
	// We push things out of our way
	SetMoveType( MOVETYPE_PUSH );
	
	// Use our brushmodel
	SetModel( STRING( GetModelName() ) );

	// Create our physics hull information
	CreateVPhysics();
}

//-----------------------------------------------------------------------------
// Purpose: Setup our physics information so we collide properly
//-----------------------------------------------------------------------------
bool CMyBrushEntity::CreateVPhysics( void )
{
	// For collisions with physics objects
	VPhysicsInitShadow( false, false );

	return true;
}

//-----------------------------------------------------------------------------
// Purpose: Move away from an entity that touched us
// Input  : *pOther - the entity we touched
//-----------------------------------------------------------------------------
void CMyBrushEntity::BrushTouch( CBaseEntity *pOther )
{
	// Get the collision information
	const trace_t &tr = GetTouchTrace();

	// We want to move away from the impact point along our surface
	Vector	vecPushDir = tr.plane.normal;
	vecPushDir.Negate();
	vecPushDir.z = 0.0f;

	// Move slowly in that direction
	LinearMove( GetAbsOrigin() + ( vecPushDir * 64.0f ), 32.0f );
}