mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-23 20:09:45 +03:00
Integrating vscript interface code (based on Alien Swarm)
This commit is contained in:
@@ -30,6 +30,7 @@ class CEnvEntityMaker : public CPointEntity
|
||||
DECLARE_CLASS( CEnvEntityMaker, CPointEntity );
|
||||
public:
|
||||
DECLARE_DATADESC();
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
|
||||
virtual void Spawn( void );
|
||||
virtual void Activate( void );
|
||||
@@ -43,6 +44,10 @@ public:
|
||||
void InputForceSpawnAtPosition( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
void SpawnEntityFromScript();
|
||||
void SpawnEntityAtEntityOriginFromScript(HSCRIPT hEntity);
|
||||
void SpawnEntityAtNamedEntityOriginFromScript(const char* pszName);
|
||||
void SpawnEntityAtLocationFromScript(const Vector& vecAlternateOrigin, const Vector& vecAlternateAngles);
|
||||
private:
|
||||
|
||||
CPointTemplate *FindTemplate();
|
||||
@@ -102,6 +107,13 @@ BEGIN_DATADESC( CEnvEntityMaker )
|
||||
DEFINE_THINKFUNC( CheckSpawnThink ),
|
||||
END_DATADESC()
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CEnvEntityMaker, CBaseEntity, "env_entity_maker" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( SpawnEntityFromScript, "SpawnEntity", "Create an entity at the location of the maker" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( SpawnEntityAtEntityOriginFromScript, "SpawnEntityAtEntityOrigin", "Create an entity at the location of a specified entity instance" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( SpawnEntityAtNamedEntityOriginFromScript, "SpawnEntityAtNamedEntityOrigin", "Create an entity at the location of a named entity" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( SpawnEntityAtLocationFromScript, "SpawnEntityAtLocation", "Create an entity at a specified location and orientaton, orientation is Euler angle in degrees (pitch, yaw, roll)" )
|
||||
END_SCRIPTDESC()
|
||||
|
||||
LINK_ENTITY_TO_CLASS( env_entity_maker, CEnvEntityMaker );
|
||||
|
||||
|
||||
@@ -266,8 +278,50 @@ void CEnvEntityMaker::SpawnEntity( Vector vecAlternateOrigin, QAngle vecAlternat
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pTemplate->CreationComplete( hNewEntities );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Spawn an instance of the entity
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvEntityMaker::SpawnEntityFromScript()
|
||||
{
|
||||
SpawnEntity();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Spawn an instance of the entity
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvEntityMaker::SpawnEntityAtEntityOriginFromScript( HSCRIPT hEntity )
|
||||
{
|
||||
CBaseEntity *pTargetEntity = ToEnt( hEntity );
|
||||
if ( pTargetEntity )
|
||||
{
|
||||
SpawnEntity( pTargetEntity->GetAbsOrigin(), pTargetEntity->GetAbsAngles() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Spawn an instance of the entity
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvEntityMaker::SpawnEntityAtNamedEntityOriginFromScript( const char *pszName )
|
||||
{
|
||||
CBaseEntity *pTargetEntity = gEntList.FindEntityByName( NULL, pszName, this, NULL, NULL );
|
||||
|
||||
if( pTargetEntity )
|
||||
{
|
||||
SpawnEntity( pTargetEntity->GetAbsOrigin(), pTargetEntity->GetAbsAngles() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Spawn an instance of the entity
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEnvEntityMaker::SpawnEntityAtLocationFromScript( const Vector &vecAlternateOrigin, const Vector &vecAlternateAngles )
|
||||
{
|
||||
SpawnEntity( vecAlternateOrigin, *((QAngle *)&vecAlternateAngles) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns whether or not the template entities can fit if spawned.
|
||||
|
||||
Reference in New Issue
Block a user