Authoring a Brush Entity/Code: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[http://employmentin.desdee.info/ employment in san antonio texas] [http://sinkhead.info/index0_1000.html page] [http://advancecardcredit.skunkish.info/ advance card credit] [http://noglobalwarming.desdee.info/ no global warming] [http://3doorsdown.betrunk.info/ 3 doors down] [http://pokemoncards.desdee.info/ pokemon cards] [http://sonyplaystation.shippon.info/ sony playstation] [http://reverenddean.shippon.info/ reverend dean] [http://hondagenerator.footle.info/ honda generator parts] [http://discountwedding.betrunk.info/ discount wedding invitation] [http://useddirtbike.footle.info/ used dirt bike engines] [http://algebricformula.stratose.info/ algebric formula] [http://equippingforcerapid.shippon.info/ equipping force rapid] [http://stephenmillerjapan.stratose.info/ stephen miller japan] [http://cigarettesale.sinkhead.info/ cigarette sale] [http://montypythonspamalot.footle.info/ monty python spamalot ticket] [http://rocketlaunch.betrunk.info/ rocket launch video] [http://birthdayparty.skunkish.info/ birthday party supplies] [http://freesprintpcs.coolish.info/ free sprint pcs ringtones] [http://mobilityscooter.shippon.info/ mobility scooter] [http://smallfishimage.skunkish.info/ small fish image] [http://lowfrequency.skunkish.info/ low frequency pulse measuring transducer] [http://johnshepherd.desdee.info/ john shepherd vaughan and co] [http://universityof.footle.info/ university of florida womens basketball] [http://tubeamplification.injelly.info/ tube amplification] [http://effectsofslave.desdee.info/ effects of slave trade on africa] [http://urbangolfgame.whacks.info/ urban golf game] [http://pioneerdvdremote.stratose.info/ pioneer dvd remote] [http://palmsoftwaredevelopment.footle.info/ palm software development tools] [http://mouthherpes.whacks.info/ mouth herpes] [http://freevirusscan.injelly.info/ free virus scan] [http://sleepingduring.desdee.info/ sleeping during the day i hide away] [http://safechildren.shippon.info/ safe children] [http://samsungcellphone.footle.info/ samsung cell phone] [http://footle.info/index0_250.html index] [http://houstonrockets.shippon.info/ houston rockets] [http://southafricapolice.stratose.info/ south africa police services] [http://knowledgemanagement.coolish.info/ knowledge management model] [http://businesscard.shippon.info/ business card paper glossy] [http://translatelatvian.footle.info/ translate latvian] [http://searchenginemarketing.sinkhead.info/ search engine marketing boston] [http://inventortutorial.betrunk.info/ inventor tutorial] [http://personalchecks.shippon.info/ personal checks] [http://sixsecurityservices.sinkhead.info/ six security services] [http://paidinfullalbum.whacks.info/ paid in full album cover] [http://americanlegalreform.whacks.info/ american legal reform] [http://coolish.info/index0_250.html url] [http://ashleyfurniture.skunkish.info/ ashley furniture company] [http://socialnetwork.betrunk.info/ social network maps] [http://blackjack.sinkhead.info/ black jack] [http://pricesofpetrol.footle.info/ prices of petrol] [http://acrageforsale.shippon.info/ acrage for sale in texas] [http://thesimpsons.betrunk.info/ the simpsons] [http://ariamovieclips.shippon.info/ aria movie clips] [http://monahanpat.whacks.info/ monahan pat] [http://icscollectionagency.coolish.info/ ics collection agency] [http://terrilynch.sinkhead.info/ terri lynch] [http://application.betrunk.info/ application for extension of time] [http://texasreleaseof.sinkhead.info/ texas release of lien form] [http://ironserumlevels.skunkish.info/ iron serum levels] [http://glucose.shippon.info/ glucose] [http://spain92nj.whacks.info/ spain 92 nj] [http://sherrynorth.betrunk.info/ sherry north] [http://overnighttramadol.footle.info/ overnight tramadol] [http://addanimalbite.betrunk.info/ add animal bite link] [http://laweightloss.desdee.info/ la weightloss] [http://successfulhome.footle.info/ successful home businesses] [http://illinoismissing.desdee.info/ illinois missing child] [http://alabamasegregation.stratose.info/ alabama segregation laws] [http://downloadfreemusic.skunkish.info/ download free music] [http://aircanadareservation.skunkish.info/ air canada reservation] [http://insitudefinition.skunkish.info/ in situ definition science] [http://cingulargophone.betrunk.info/ cingular go phone prepaid] [http://nosuchthingas.sinkhead.info/ no such thing as a witch] [http://eatingdisorder.desdee.info/ eating disorder] [http://milliondollars.injelly.info/ million dollars picture] [http://protectsecurity.stratose.info/ pro tect security] [http://thestarspangled.injelly.info/ the star spangled banner] [http://pornosites.stratose.info/ porno sites] [http://airlinecontinental.coolish.info/ airline continental reservation] [http://metalsignwestern.whacks.info/ metal sign western] [http://shippon.info/index5_666.html index] [http://academyawardwinning.injelly.info/ academy award winning documentaries] [http://artificialflowers.coolish.info/ artificial flowers in the uk] [http://mobic.whacks.info/ mobic] [http://ancientgreek.coolish.info/ ancient greek writing pictures] [http://papercutter.coolish.info/ paper cutter] [http://phenterminecheap.injelly.info/ phentermine cheap] [http://best6monthcdrates.stratose.info/ best 6 month cd rates] [http://makeawishfoundation.whacks.info/ make a wish foundation of central florida] [http://phasecorrelation.skunkish.info/ phase correlation method] [http://elysianfields.coolish.info/ elysian fields] [http://texasdepartment.betrunk.info/ texas department state health services] [http://oceancitywebcams.skunkish.info/ ocean city webcams] [http://freehardcoreporn.whacks.info/ free hardcore porn] [http://graphicdesign.sinkhead.info/ graphic design] [http://amd64computers.desdee.info/ amd 64 computers] [http://shippon.info/index3_250.html page] [http://freeonlinedating.stratose.info/ free online dating] [http://teenthumbtgp.footle.info/ teen thumb tgp]
[[Category:Programming]]
[[Category:Programming]]
<pre>
<pre>

Revision as of 17:45, 1 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 );
}