Axiom.SceneManagers.Bsp.BspLevel.LoadEntities C# (CSharp) Method

LoadEntities() protected method

Internal method for parsing chosen entities.
protected LoadEntities ( Quake3Level q3lvl ) : void
q3lvl Quake3Level
return void
		protected void LoadEntities( Quake3Level q3lvl )
		{
			Vector3 origin = new Vector3();
			float angle = 0;
			bool isPlayerStart = false;
			string[] entities = q3lvl.Entities.Split( '\n' );

			for ( int i = 0; i < entities.Length; i++ )
			{
				// Remove whitespace and quotes.
				entities[ i ] = entities[ i ].Trim().Replace( "\"", "" );

				if ( entities[ i ].Length == 0 )
					continue;

				string[] paramList = entities[ i ].Split( ' ' );

				if ( paramList[ 0 ] == "origin" )
				{
					float[] vector = new float[ 3 ];
					for ( int v = 0; v < 3; v++ )
						vector[ v ] = StringConverter.ParseFloat( paramList[ v + 1 ] );

					q3lvl.TransformVector( vector );

					origin = new Vector3( vector[ 0 ], vector[ 1 ], vector[ 2 ] );
				}

				if ( paramList[ 0 ] == "angle" )
					angle = StringConverter.ParseFloat( paramList[ 1 ] );

				if ( ( paramList[ 0 ] == "classname" ) && ( paramList[ 1 ] == "info_player_deathmatch" ) )
					isPlayerStart = true;

				if ( paramList[ 0 ] == "}" )
				{
					if ( isPlayerStart )
					{
						ViewPoint vp = new ViewPoint();
						vp.position = origin;

						if ( q3lvl.Options.setYAxisUp )
							vp.orientation = Quaternion.FromAngleAxis( Utility.DegreesToRadians( angle ), Vector3.UnitY );
						else
							vp.orientation = Quaternion.FromAngleAxis( Utility.DegreesToRadians( angle ), Vector3.UnitZ );

						playerStarts.Add( vp );
					}

					isPlayerStart = false;
				}
			}
		}