当前位置: 首页>>代码示例>>C++>>正文


C++ DispatchSpawn函数代码示例

本文整理汇总了C++中DispatchSpawn函数的典型用法代码示例。如果您正苦于以下问题:C++ DispatchSpawn函数的具体用法?C++ DispatchSpawn怎么用?C++ DispatchSpawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DispatchSpawn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Warning

//=========================================================
// Crea un NPC Grunt.
//=========================================================
CAI_BaseNPC *CSurvivalZombieSpawn::MakeGrunt()
{
	// Desactivado
	if ( Disabled || !sv_spawn_zombies.GetBool() )
		return NULL;

	CAI_BaseNPC *pGrunt = (CAI_BaseNPC *)CreateEntityByName("npc_grunt");

	// Ocurrio algún problema.
	if ( !pGrunt )
	{
		Warning("[SURVIVAL ZOMBIE MAKER] Ha ocurrido un problema al intentar crear un grunt. \r\n");
		return NULL;
	}

	Vector origin;

	if ( !CanMakeNPC(pGrunt, &origin) )
		return NULL;

	// Lugar de creación.
	pGrunt->SetAbsOrigin(origin);

	// Nombre del Grunt.
	// [¡NO CAMBIAR!] Es utilizado por otras entidades para referirse a los zombis creados por esta entidad.
	pGrunt->SetName(MAKE_STRING("survival_grunt"));

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pGrunt->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pGrunt->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

	// Creamos al grunt, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pGrunt);
	pGrunt->SetOwnerEntity(this);
	DispatchActivate(pGrunt);

	// Ahora creamos la música.
	pGruntMusic = (CEnvSound *)CreateEntityByName("env_sound");
	pGruntMusic->SetSourceEntityName(MAKE_STRING("survival_grunt"));
	pGruntMusic->SetSoundName(MAKE_STRING("NPC_Grunt.BackgroundMusic"));
	pGruntMusic->SetRadius(8000.0);
	
	pGruntMusic->SetAbsOrigin(origin);
	DispatchSpawn(pGruntMusic);
	pGruntMusic->SetOwnerEntity(this);
	DispatchActivate(pGruntMusic);

	pGruntMusic->SetPitch(100);
	pGruntMusic->SetVolume(1);
	pGruntMusic->PlayManual(1, 100);

	return pGrunt;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:61,代码来源:director_spawn.cpp

示例2: CC_ASW_Ent_Create

//------------------------------------------------------------------------------
// Purpose: Create an NPC of the given type
//------------------------------------------------------------------------------
void CC_ASW_Ent_Create( const CCommand& args )
{
	MDLCACHE_CRITICAL_SECTION();

	bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
	CBaseEntity::SetAllowPrecache( true );

	// Try to create entity
	CBaseEntity *entity = dynamic_cast< CBaseEntity * >( CreateEntityByName(args[1]) );
	if (entity)
	{
		entity->Precache();		

		// Now attempt to drop into the world
		CASW_Player* pPlayer = ToASW_Player( UTIL_GetCommandClient() );
		if (!pPlayer)
			return;

		trace_t tr;
		UTIL_TraceLine( pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 30 ),
			pPlayer->GetCrosshairTracePos(), MASK_SOLID, 
			pPlayer, COLLISION_GROUP_NONE, &tr );

		if ( tr.fraction != 0.0 )
		{
			// Raise the end position a little up off the floor, place the npc and drop him down
			tr.endpos.z += 12;
			entity->Teleport( &tr.endpos, NULL, NULL );
			// this was causing aliens to spawn under ground 
			//UTIL_DropToFloor( entity, MASK_SOLID );
		}
		DispatchSpawn(entity);
	}
	CBaseEntity::SetAllowPrecache( allowPrecache );
}
开发者ID:Nightgunner5,项目名称:Jastian-Summer,代码行数:38,代码来源:asw_concommands.cpp

示例3: CreateEntityByName

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CAntlionGrub::CreateNugget( void )
{
	CGrubNugget *pNugget = (CGrubNugget *) CreateEntityByName( "item_grubnugget" );
	if ( pNugget == NULL )
		return;

	Vector vecOrigin;
	Vector vecForward;
	GetAttachment( LookupAttachment( "glow" ), vecOrigin, &vecForward );

	// Find out what size to make this nugget!
	int nDenomination = GetNuggetDenomination();
	pNugget->SetDenomination( nDenomination );
	
	pNugget->SetAbsOrigin( vecOrigin );
	pNugget->SetAbsAngles( RandomAngle( 0, 360 ) );
	DispatchSpawn( pNugget );

	IPhysicsObject *pPhys = pNugget->VPhysicsGetObject();
	if ( pPhys )
	{
		Vector vecForward;
		GetVectors( &vecForward, NULL, NULL );
		
		Vector vecVelocity = RandomVector( -35.0f, 35.0f ) + ( vecForward * -RandomFloat( 50.0f, 75.0f ) );
		AngularImpulse vecAngImpulse = RandomAngularImpulse( -100.0f, 100.0f );

		pPhys->AddVelocity( &vecVelocity, &vecAngImpulse );
	}
}
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:33,代码来源:npc_antliongrub.cpp

示例4: CreateEntityByName

CBaseEntity * CEntHost::GiveNamedItem( const char * szName, int iSubType, bool removeIfNotCarried )
{
    // If I already own this type don't create one
    if ( GetHost()->Weapon_OwnsThisType( szName, iSubType ) )
        return NULL;

    CBaseEntity *pEntity = CreateEntityByName( szName );

    if ( !pEntity ) {
        Msg( "NULL Ent in GiveNamedItem!\n" );
        return NULL;
    }

    pEntity->SetLocalOrigin( GetLocalOrigin() );
    pEntity->AddSpawnFlags( SF_NORESPAWN );

    CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>(pEntity);

    DispatchSpawn( pEntity );

    if ( pWeapon ) {
        pWeapon->SetSubType( iSubType );
        GetHost()->Weapon_Equip( pWeapon );
    }
    else {
        if ( pEntity && !(pEntity->IsMarkedForDeletion()) ) {
            pEntity->Touch( GetHost() );
        }
    }

    return pEntity;
}
开发者ID:WootsMX,项目名称:InSource,代码行数:32,代码来源:ent_host.cpp

示例5: Assert

void CEntHost::CreateViewModel( int index )
{
    Assert( IsPlayer() );
    Assert( index >= 0 && index < MAX_VIEWMODELS );

    if ( !IsPlayer() )
        return;

    if ( GetPlayer()->GetViewModel( index ) )
        return;

    CPredictedViewModel *vm = (CPredictedViewModel *)CreateEntityByName( "predicted_viewmodel" );

    if ( vm ) {
        vm->SetAbsOrigin( GetAbsOrigin() );
        vm->SetOwner( GetPlayer() );
        vm->SetIndex( index );

        DispatchSpawn( vm );
        vm->FollowEntity( GetPlayer(), false );
        vm->AddEffects( EF_NODRAW );

        GetPlayer()->m_hViewModel.Set( index, vm );
    }
}
开发者ID:WootsMX,项目名称:InSource,代码行数:25,代码来源:ent_host.cpp

示例6: Assert

CBaseEntity *CreateServerStatueFromOBBs( const CUtlVector<outer_collision_obb_t> &vecSphereOrigins, CBaseAnimating *pAnimating )
{
	Assert( vecSphereOrigins.Count() > 0 );

	if ( vecSphereOrigins.Count() <= 0 )
		return NULL;

	CStatueProp *pStatue = static_cast<CStatueProp *>( CreateEntityByName( "physics_prop_statue" ) );

	if ( pStatue )
	{
		pStatue->m_pInitOBBs = &vecSphereOrigins;

		pStatue->m_hInitBaseAnimating = pAnimating;
		pStatue->SetModelName( pAnimating->GetModelName() );
		pStatue->SetAbsOrigin( pAnimating->GetAbsOrigin() );
		pStatue->SetAbsAngles( pAnimating->GetAbsAngles() );
		DispatchSpawn( pStatue );
		pStatue->Activate();

		pStatue->AddEffects( EF_NODRAW );
		pStatue->CollisionProp()->SetSurroundingBoundsType( USE_GAME_CODE );
		pStatue->AddSolidFlags( ( pAnimating->GetSolidFlags() & FSOLID_CUSTOMBOXTEST ) | ( pAnimating->GetSolidFlags() & FSOLID_CUSTOMRAYTEST ) );

		pAnimating->SetParent( pStatue );

		// You'll need to keep track of the child for collision rules
		pStatue->SetThink( &CStatueProp::CollisionPartnerThink );
		pStatue->SetNextThink( gpGlobals->curtime + 1.0f );
	}

	return pStatue;
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:33,代码来源:physics_prop_statue.cpp

示例7: entData

//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
CAI_Hint* CAI_HintManager::CreateHint( HintNodeData *pNodeData, const char *pMapData )
{
	// Reset last found hint if new node is added
	CAI_HintManager::ResetFoundHints();

	CAI_Hint *pHint = (CAI_Hint*)CreateEntityByName("ai_hint");
	if ( pHint )
	{	
		// First, parse the mapdata chunk we were passed
		if ( pMapData )
		{
			CEntityMapData entData( (char*)pMapData );
			pHint->ParseMapData( &entData );

			// Restore the desired classname (parsing the mapdata stomps it)
			pHint->SetClassname( "ai_hint" );
		}

		pHint->SetName( pNodeData->strEntityName );
		pHint->SetAbsOrigin( pNodeData->vecPosition );
		memcpy( &(pHint->m_NodeData), pNodeData, sizeof(HintNodeData) );
		DispatchSpawn( pHint );

		return pHint;
	}

	return NULL;
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:33,代码来源:ai_hint.cpp

示例8: DispatchSpawn

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFGrenadePipebombProjectile* CTFGrenadePipebombProjectile::Create( const Vector &position, const QAngle &angles, 
																    const Vector &velocity, const AngularImpulse &angVelocity, 
																    CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo, bool bRemoteDetonate )
{
	CTFGrenadePipebombProjectile *pGrenade = static_cast<CTFGrenadePipebombProjectile*>( CBaseEntity::CreateNoSpawn( bRemoteDetonate ? "tf_projectile_pipe_remote" : "tf_projectile_pipe", position, angles, pOwner ) );
	if ( pGrenade )
	{
		// Set the pipebomb mode before calling spawn, so the model & associated vphysics get setup properly
		pGrenade->SetPipebombMode( bRemoteDetonate );
		DispatchSpawn( pGrenade );

		pGrenade->InitGrenade( velocity, angVelocity, pOwner, weaponInfo );

#ifdef _X360 
		if ( pGrenade->m_iType != TF_GL_MODE_REMOTE_DETONATE )
		{
			pGrenade->SetDamage( TF_WEAPON_GRENADE_XBOX_DAMAGE );
		}
#endif
		pGrenade->m_flFullDamage = pGrenade->GetDamage();

		if ( pGrenade->m_iType != TF_GL_MODE_REMOTE_DETONATE )
		{
			// Some hackery here. Reduce the damage by 25%, so that if we explode on timeout,
			// we'll do less damage. If we explode on contact, we'll restore this to full damage.
			pGrenade->SetDamage( pGrenade->GetDamage() * TF_WEAPON_PIPEBOMB_TIMER_DMG_REDUCTION );
		}

		pGrenade->ApplyLocalAngularVelocityImpulse( angVelocity );
	}

	return pGrenade;
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:36,代码来源:tf_weapon_grenade_pipebomb.cpp

示例9: Precache

//-----------------------------------------------------------------------------
// Purpose: Spawn
//-----------------------------------------------------------------------------
void CGrappleHook::Spawn(void)
{
	Precache();
	SetModel(HOOK_MODEL);
	SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM);
	UTIL_SetSize(this, -Vector(1, 1, 1), Vector(1, 1, 1));
	SetSolid(SOLID_BBOX);
	SetGravity(0.05f);
	// The rock is invisible, the crossbow bolt is the visual representation
	AddEffects(EF_NODRAW);
	// Make sure we're updated if we're underwater
	UpdateWaterState();
	SetTouch(&CGrappleHook::HookTouch);
	SetThink(&CGrappleHook::FlyThink);
	SetNextThink(gpGlobals->curtime + 0.1f);
	//m_pSpring = NULL;
	m_fSpringLength = 0.0f;
	m_bPlayerWasStanding = false;

	// Create bolt model and parent it
	CBaseEntity *pBolt = CBaseEntity::CreateNoSpawn("prop_dynamic", GetAbsOrigin(), GetAbsAngles(), this);
	pBolt->SetModelName(MAKE_STRING(BOLT_MODEL));
	pBolt->SetModel(BOLT_MODEL);
	DispatchSpawn(pBolt);
	pBolt->SetParent(this);
}
开发者ID:SCell555,项目名称:hl2-asw-port,代码行数:29,代码来源:weapon_grapple.cpp

示例10: SetModelName

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponStriderBuster::Spawn( void )
{	
	SetModelName( AllocPooledString("models/magnusson_device.mdl") );
	BaseClass::Spawn();
	
	// Setup for being shot by the player
	m_takedamage = DAMAGE_EVENTS_ONLY;

	// Ignore touches until launched.
	SetTouch ( NULL );

	AddFlag( FL_AIMTARGET|FL_OBJECT );

	m_hParticleEffect = CreateEntityByName( "info_particle_system" );
	if ( m_hParticleEffect )
	{
		m_hParticleEffect->KeyValue( "start_active", "1" );
		m_hParticleEffect->KeyValue( "effect_name", "striderbuster_smoke" );
		DispatchSpawn( m_hParticleEffect );
		if ( gpGlobals->curtime > 0.2f )
		{
			m_hParticleEffect->Activate();
		}
		m_hParticleEffect->SetAbsOrigin( GetAbsOrigin() );
		m_hParticleEffect->SetParent( this );
	}

	SetHealth( striderbuster_health.GetFloat() );
	
	SetNextThink(gpGlobals->curtime + 0.01f);
}
开发者ID:FooGames,项目名称:SecobMod,代码行数:34,代码来源:weapon_striderbuster.cpp

示例11: Warning

void CGstringInteraction::InputStartInteraction( inputdata_t &inputdata )
{
	if ( m_bInteractionActive )
	{
		Warning( "Can't start interaction while there is one active!\n" );
		return;
	}

	if ( m_hInteractiveObject.Get() == NULL )
	{
		Warning( "Interaction entity has no interactive object assigned!\n" );
		return;
	}

	if ( !inputdata.pActivator->IsPlayer() )
	{
		Warning( "Interaction must be triggered by a player.\n" );
		return;
	}

	CDynamicProp *pInteractiveObject = dynamic_cast< CDynamicProp* >( m_hInteractiveObject.Get() );

	if ( pInteractiveObject != NULL )
	{
		pInteractiveObject->SetInteractionEntity( this );
		inputdata_t data;
		data.value.SetString( m_strObjectSequenceName );
		pInteractiveObject->InputSetAnimation( data );
		pInteractiveObject->SetNextThink( gpGlobals->curtime + 0.1f );
	}
	else
	{
		Warning( "Interaction entity must be a prop_dynamic!\n" );
		return;
	}

	CGstringInteractionBody *pFirstpersonBody = assert_cast< CGstringInteractionBody* >( CreateEntityByName( "gstring_interaction_body" ) );
	Assert( pFirstpersonBody );

	pFirstpersonBody->SetAbsOrigin( pInteractiveObject->GetAbsOrigin() );
	pFirstpersonBody->SetAbsAngles( pInteractiveObject->GetAbsAngles() );
	pFirstpersonBody->SetModel( FIRSTPERSON_BODY_MODEL );

	DispatchSpawn( pFirstpersonBody );

	const int iPlayerSequence = pFirstpersonBody->LookupSequence( m_strPlayerSequenceName.ToCStr() );
	if ( iPlayerSequence >= 0 )
	{
		pFirstpersonBody->ResetSequence( iPlayerSequence );
	}

	CGstringPlayer *pPlayer = assert_cast< CGstringPlayer* >( inputdata.pActivator );
	pPlayer->BeginInteraction( pFirstpersonBody );
	m_hPlayer.Set( pPlayer );

	pFirstpersonBody->SetInteractionEntity( this );
	m_bInteractionActive = true;

	m_InteractionStartEvent.FireOutput( inputdata.pActivator, inputdata.pCaller );
}
开发者ID:joeangry,项目名称:g-string_2013,代码行数:60,代码来源:cgstring_interaction.cpp

示例12: SelectRandomBoss

//=========================================================
// Crea un Jefe.
//=========================================================
CAI_BaseNPC *CDirectorSpawn::MakeBoss()
{
	// Desactivado
	if ( Disabled )
		return NULL;

	// Seleccionamos una clase de NPC para crear.
	const char *pClass	= SelectRandomBoss();
	CAI_BaseNPC *pNPC	= VerifyClass(pClass);

	// Ocurrio algún problema.
	if ( !pNPC )
	{
		Warning("[DIRECTOR SPAWN] Ha ocurrido un problema al intentar crear un Jefe. \r\n");
		return NULL;
	}

	Vector origin;

	// Verificamos si podemos crear el Grunt en el radio.
	if ( !CanMakeNPC(pNPC, &origin) )
		return NULL;

	// Lugar de creación.
	pNPC->SetAbsOrigin(origin);

	// Nombre del Jefe.
	pNPC->SetName(MAKE_STRING(BOSS_NAME));

	QAngle angles	= GetAbsAngles();
	angles.x		= 0.0;
	angles.z		= 0.0;

	pNPC->SetAbsAngles(angles);

	// Tiene que caer al suelo.
	pNPC->AddSpawnFlags(SF_NPC_FALL_TO_GROUND);

	// Creamos al Jefe, le decimos quien es su dios (creador) y lo activamos.
	DispatchSpawn(pNPC);
	pNPC->SetOwnerEntity(this);
	DispatchActivate(pNPC);

	// Al parecer se atoro en una pared.
	if ( !PostSpawn(pNPC) )
		return NULL;

	// Debe conocer la ubicación del jugador (Su enemigo)
	CIN_Player *pPlayer = UTIL_GetRandomInPlayer();

	if ( pPlayer )
	{
		// Ataca al jugador YA
		pNPC->SetEnemy(pPlayer);
		pNPC->UpdateEnemyMemory(pPlayer, pPlayer->GetAbsOrigin());
	}

	return pNPC;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:62,代码来源:director_spawn.cpp

示例13: SpawnAllEntities

void SpawnAllEntities( int nEntities, HierarchicalSpawn_t *pSpawnList, bool bActivateEntities )
{
	int nEntity;
	for (nEntity = 0; nEntity < nEntities; nEntity++)
	{
		VPROF( "MapEntity_ParseAllEntities_Spawn");
		CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;

		if ( pSpawnList[nEntity].m_pDeferredParent )
		{
			// UNDONE: Promote this up to the root of this function?
			MDLCACHE_CRITICAL_SECTION();
			CBaseEntity *pParent = pSpawnList[nEntity].m_pDeferredParent;
			int iAttachment = -1;
			CBaseAnimating *pAnim = pParent->GetBaseAnimating();
			if ( pAnim )
			{
				iAttachment = pAnim->LookupAttachment(pSpawnList[nEntity].m_pDeferredParentAttachment);
			}
			pEntity->SetParent( pParent, iAttachment );
		}
		if ( pEntity )
		{
			if (DispatchSpawn(pEntity) < 0)
			{
				for ( int i = nEntity+1; i < nEntities; i++ )
				{
					// this is a child object that will be deleted now
					if ( pSpawnList[i].m_pEntity && pSpawnList[i].m_pEntity->IsMarkedForDeletion() )
					{
						pSpawnList[i].m_pEntity = NULL;
					}
				}
				// Spawn failed.
				gEntList.CleanupDeleteList();
				// Remove the entity from the spawn list
				pSpawnList[nEntity].m_pEntity = NULL;
			}
		}
	}

	if ( bActivateEntities )
	{
		VPROF( "MapEntity_ParseAllEntities_Activate");
		bool bAsyncAnims = mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, false );
		for (nEntity = 0; nEntity < nEntities; nEntity++)
		{
			CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;

			if ( pEntity )
			{
				MDLCACHE_CRITICAL_SECTION();
				pEntity->Activate();
			}
		}
		mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, bAsyncAnims );
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:58,代码来源:mapentities.cpp

示例14: FrameUpdatePostEntityThink

	virtual void FrameUpdatePostEntityThink( void )
	{
		// Wait until we're all spawned in
		if ( gpGlobals->curtime < 5 )
			return;

		if ( m_bIssuedNextMapCommand )
			return;

		if ( !m_bParsedMapFile )
		{
			m_bParsedMapFile = true;

			// See if we've got a camera file to import cameras from
			char szFullName[512];
			Q_snprintf(szFullName,sizeof(szFullName), "maps/%s.txt", STRING( gpGlobals->mapname ));
			KeyValues *pkvMapCameras = new KeyValues( "MapCameras" );
			if ( pkvMapCameras->LoadFromFile( filesystem, szFullName, "MOD" ) )
			{
				Warning( "Devshots: Loading point_devshot_camera positions from %s. \n", szFullName );

				// Get each camera, and add it to our list
				KeyValues *pkvCamera = pkvMapCameras->GetFirstSubKey();
				while ( pkvCamera )
				{
					// Get camera name
					const char *pCameraName = pkvCamera->GetName();

					// Make a camera, and move it to the position specified
					CPointDevShotCamera	*pCamera = (CPointDevShotCamera*)CreateEntityByName( "point_devshot_camera" );
					Assert( pCamera );
					pCamera->KeyValue( "cameraname", pCameraName );
					pCamera->KeyValue( "origin", pkvCamera->GetString( "origin", "0 0 0" ) );
					pCamera->KeyValue( "angles", pkvCamera->GetString( "angles", "0 0 0" ) );
					pCamera->KeyValue( "FOV", pkvCamera->GetString( "FOV", "75" ) );
					DispatchSpawn( pCamera );
					pCamera->Activate();

					// Move to next camera
					pkvCamera = pkvCamera->GetNextKey();
				}
			}

			if ( !g_iDevShotCameraCount )
			{
				Warning( "Devshots: No point_devshot_camera in %s. Moving to next map.\n", STRING( gpGlobals->mapname ) );

				CBasePlayer *pPlayer = UTIL_GetLocalPlayerOrListenServerHost();
				if ( pPlayer )
				{
					engine->ClientCommand( pPlayer->edict(), "devshots_nextmap" );
					m_bIssuedNextMapCommand = true;
					return;
				}
			}
		}
	}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:57,代码来源:point_devshot_camera.cpp

示例15: CC_AI_Hull

//------------------------------------------------------------------------------
// Display the hull type of the specified NPC.
//------------------------------------------------------------------------------
void CC_AI_Hull( const CCommand &args )
{
	if ( !g_pAINetworkManager )
		return;

	bool bSpawned = false;
	CBaseEntity *pEnt = NULL;

	if ( !args[1] || !args[1][0] )
	{		
		// No arg means the entity under the crosshair.
		pEnt = FindPickerEntity( UTIL_GetCommandClient() );
		if ( !pEnt )
		{
			DevMsg( "No entity under the crosshair.\n" );
			return;
		}
	}
	else
	{
		// Find the entity specified on the command line.
		pEnt = gEntList.FindEntityGeneric( NULL, args[1] );

		if ( !pEnt )
		{
			// Not found, try to create one.
			pEnt = (CAI_BaseNPC *)CreateEntityByName( args[1] );
			if ( !pEnt )
			{
				DevMsg( "Entity %s not found, and couldn't create!\n", args[1] );
				return;
			}

			bSpawned = true;
			DispatchSpawn( pEnt );
		}
	}

	CAI_BaseNPC *pNPC = dynamic_cast<CAI_BaseNPC *>( pEnt );
	if ( !pNPC )
	{
		DevMsg( "Entity %s is not an NPC.\n", pEnt->GetDebugName() );
		return;
	}
	
	Hull_t eHull = pNPC->GetHullType();

	if ( bSpawned )
	{
		UTIL_Remove( pEnt );
	}

	g_pAINetworkManager->GetEditOps()->DrawHull( eHull );

	CBaseEntity::m_nDebugPlayer = UTIL_GetCommandClientIndex();
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:59,代码来源:ai_concommands.cpp


注:本文中的DispatchSpawn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。