Esempio n. 1
0
void DoPathPlotter(){
	PathPlotterRS rs;
	int ret = DoPathPlotterBox( &rs );
	if ( ret == IDCANCEL ) {
		return;
	}
	if ( ret == IDNO ) {
		if ( g_PathView ) {
			delete g_PathView;
		}
		return;
	}

	if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
		DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
		return;
	}

	// tell Radiant we want to access the selected brushes
	g_FuncTable.m_pfnAllocateSelectedBrushHandles();

	brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
	// should be our trigger brush

	DEntity world;
	world.LoadEPairList( *g_EntityTable.m_pfnGetEntityKeyValList( brush->owner ) );

	DEPair* trigger_ep = world.FindEPairByKey( "targetname" );

	if ( trigger_ep ) {
		if ( !strcmp( world.m_Classname, "trigger_push" ) ) {
			DEPair* target_ep = world.FindEPairByKey( "target" );
			if ( target_ep ) {
				entity_s* entTarget = FindEntityFromTargetname( target_ep->value, NULL );
				if ( entTarget ) {
					if ( g_PathView ) {
						delete g_PathView;
					}
					g_PathView = new DBobView;

					g_PathView->Begin( trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra );
				}
				else{
					DoMessageBox( "trigger_push target could not be found.", "Error", MB_OK );
				}
			}
			else{
				DoMessageBox( "trigger_push has no target.", "Error", MB_OK );
			}
		}
		else{
			DoMessageBox( "You must select a 'trigger_push' entity.", "Error", MB_OK );
		}
	}
	else{
		DoMessageBox( "Entity must have a targetname", "Error", MB_OK );
	}

	g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}
Esempio n. 2
0
void DBobView_setEntity( Entity& entity, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra ){
	DEntity trigger;
	trigger.LoadEPairList( &entity );

	DEPair* trigger_ep = trigger.FindEPairByKey( "targetname" );

	if ( trigger_ep ) {
		if ( !strcmp( trigger.m_Classname, "trigger_push" ) ) {
			DEPair* target_ep = trigger.FindEPairByKey( "target" );
			if ( target_ep ) {
				const scene::Path* entTarget = FindEntityFromTargetname( target_ep->value );
				if ( entTarget ) {
					if ( g_PathView ) {
						delete g_PathView;
					}
					g_PathView = new DBobView;

					Entity* target = Node_getEntity( entTarget->top() );
					if ( target != 0 ) {
						if ( !bNoUpdate ) {
							g_PathView->trigger = &entity;
							entity.attach( *g_PathView );
							g_PathView->target = target;
							target->attach( *g_PathView );
						}
						g_PathView->Begin( trigger_ep->value, target_ep->value, multiplier, points, varGravity, bNoUpdate, bShowExtra );
					}
					else{
						globalErrorStream() << "bobToolz PathPlotter: trigger_push ARGH\n";
					}
				}
				else{
					globalErrorStream() << "bobToolz PathPlotter: trigger_push target could not be found..\n";
				}
			}
			else{
				globalErrorStream() << "bobToolz PathPlotter: trigger_push has no target..\n";
			}
		}
		else{
			globalErrorStream() << "bobToolz PathPlotter: You must select a 'trigger_push' entity..\n";
		}
	}
	else{
		globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n";
	}
	return;
}
Esempio n. 3
0
entity_s* FindEntityFromTargetname( const char* targetname, int* entNum ) {
    DEntity world;

    int count = g_FuncTable.m_pfnGetEntityCount();
    for ( int i = 0; i < count; i++ )
    {
        world.ClearEPairs();

        entity_s* ent = (entity_s*)g_FuncTable.m_pfnGetEntityHandle( i );

        world.LoadEPairList( *g_EntityTable.m_pfnGetEntityKeyValList( ent ) );

        DEPair* tn = world.FindEPairByKey( "targetname" );
        if ( tn ) {
            if ( !stricmp( tn->value, targetname ) ) {
                if ( entNum ) {
                    *entNum = i;
                }
                return ent;
            }
        }
    }
    return NULL;
}
Esempio n. 4
0
  void operator()(scene::Instance& instance) const
  {
    if(!instance.isSelected())
    {
      return;
    }
		ent.LoadFromEntity(instance.path().top());

		DEPair* pEpair = ent.FindEPairByKey("origin");
		if(!pEpair) {
			return;
		}

		vec3_t vec, out;
		sscanf( pEpair->value.GetBuffer(), "%f %f %f", &vec[0], &vec[1], &vec[2]);

		planter.FindDropPoint( vec, out );

		char buffer[256];
		sprintf( buffer, "%f %f %f", out[0], out[1], out[2] );
		ent.AddEPair( "origin", buffer );
		ent.RemoveFromRadiant();
		ent.BuildInRadiant(false);
  }