idTech4.Game.idEntity.Spawn C# (CSharp) Method

Spawn() public method

public Spawn ( ) : void
return void
		public virtual void Spawn()
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idConsole.WriteLine("TODO: idEntity.Spawn");
			/*int					i;
			const char			*temp;
			idVec3				origin;
			idMat3				axis;
			const idKeyValue	*networkSync;
			const char			*classname;
			const char			*scriptObjectName;*/

			idR.Game.RegisterEntity(this);

			_className = _spawnArgs.GetString("classname", null);

			idDeclEntity def = idR.Game.FindEntityDef(_className, false);

			if(def != null)
			{
				_entityDefIndex = def.Index;
			}

			/*
			TODO
			FixupLocalizedStrings();
			*/

			// parse static models the same way the editor display does
			_renderEntity = idR.GameEdit.ParseSpawnArgsToRenderEntity(_spawnArgs);
			_renderEntity.EntityIndex = this.Index;

			// TODO
			/*
					// go dormant within 5 frames so that when the map starts most monsters are dormant
					dormantStart = gameLocal.time - DELAY_DORMANT_TIME + gameLocal.msec * 5;*/

			/*

			// do the audio parsing the same way dmap and the editor do
			gameEdit->ParseSpawnArgsToRefSound( &spawnArgs, &refSound );

			// only play SCHANNEL_PRIVATE when sndworld->PlaceListener() is called with this listenerId
			// don't spatialize sounds from the same entity
			refSound.listenerId = entityNumber + 1;

			cameraTarget = NULL;
			temp = spawnArgs.GetString( "cameraTarget" );
			if ( temp && temp[0] ) {
				// update the camera taget
				PostEventMS( &EV_UpdateCameraTarget, 0 );
			}

			for ( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) {
				UpdateGuiParms( renderEntity.gui[ i ], &spawnArgs );
			}*/

			_flags.SolidForTeam = _spawnArgs.GetBool("solidForTeam", false);
			_flags.NeverDormant = _spawnArgs.GetBool("neverDormant", false);
			_flags.Hidden = _spawnArgs.GetBool("hide", false);

			if(_flags.Hidden == true)
			{
				// make sure we're hidden, since a spawn function might not set it up right
				idConsole.Warning("TODO: PostEventMS( &EV_Hide, 0 );");
			}
			/*cinematic = spawnArgs.GetBool( "cinematic", "0" );

			networkSync = spawnArgs.FindKey( "networkSync" );
			if ( networkSync ) {
				fl.networkSync = ( atoi( networkSync->GetValue() ) != 0 );
			}
		*/

			// every object will have a unique name
			this.Name = _spawnArgs.GetString("name", string.Format("{0}_{1}_{2}", this.ClassName, _spawnArgs.GetString("classname"), this.Index));

			// if we have targets, wait until all entities are spawned to get them
			// TODO
			/*if ( spawnArgs.MatchPrefix( "target" ) || spawnArgs.MatchPrefix( "guiTarget" ) ) {
				if ( gameLocal.GameState() == GAMESTATE_STARTUP ) {
					PostEventMS( &EV_FindTargets, 0 );
				} else {
					// not during spawn, so it's ok to get the targets
					FindTargets();
				}
			}*/

			_health = _spawnArgs.GetInteger("health");

			Vector3 origin = _renderEntity.Origin;
			Matrix axis = _renderEntity.Axis;
			
			InitDefaultPhysics(origin, axis);

			this.Origin = origin;
			this.Axis = axis;

			string temp = _spawnArgs.GetString("model");

			if(temp != string.Empty)
			{
				this.SetModel(temp);
			}

			if(_spawnArgs.GetString("bind", string.Empty) == string.Empty)
			{
				idConsole.Warning("TODO: PostEventMS( &EV_SpawnBind, 0 );");
			}

			// auto-start a sound on the entity
			// TODO
			/*if ( refSound.shader && !refSound.waitfortrigger ) {
				StartSoundShader( refSound.shader, SND_CHANNEL_ANY, 0, false, NULL );
			}*/

			// setup script object
			string scriptObjectName = _spawnArgs.GetString("scriptobject", string.Empty);

			if((this.ShouldConstructScriptObjectAtSpawn == true) && (scriptObjectName != string.Empty))
			{
				idConsole.Warning("TODO: script object");
				/*if ( !scriptObject.SetType( scriptObjectName ) ) {
					gameLocal.Error( "Script object '%s' not found on entity '%s'.", scriptObjectName, name.c_str() );
				}

				ConstructScriptObject();*/
			}
		}