Authoring a Brush Entity/Code

From Valve Developer Community
Jump to navigation Jump to search

adult literacy core curriculum glucotrol telescope aeroflot airlines free movies virgin blue amway dress wear wedding georgia aquarium immigration and naturalization service citalopram shemale porn continental airlines home page free indian sex miacalcin chopard watch tissot watches mortgage refinancing no closing cost eq2 macros blood customer service blonde wedding cakes we live together horoscope love sign compatibility gay mpegs samsung pc suite free pc games wifes black porn star india sexy boot balls toyota trucks hawaiian airline fucking mature kitchener on flight jacket striptease video jewelry making kits buy viagra in the uk topshop sympathy card free t mobile sidekick 2 freeadultmovies car classic kit rockport boat shoes discount wedding favor sierra nevada express store baclofen markie post mazda rx7 water heater winamp gambling game irrigation systems pheromone lil bow wow t-mobile sidekick scooters motor ephedra danger doorknobs erotig asian boy free reverse cell phone funny cartoon mercedes tamiflu and mexico dish network key female spanking wire jewelry adderall side effects anal sex gallery asian women for marriage buy ambien camel cigarette amateur blog kentucky lake house boat rental lapdancing adobe acrobat distiller free download mineral makeup recipes ncaa sports triamcinolone big breasts nod32 antivirus jeep ecm car accessories jenifer aniston performance appraisals black hummer h2 filing bankrupcy norton antivirus download free cheap sex hotsex encore download tila chanel replica handbags hot install replace spa tub exchange currency cheap vicodin

//===== 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 );
}