public void SpawnScientist() { Vector3 vector3; Quaternion quaternion; if (this.Spawned == null || this.Spawned.Count >= this.MaxPopulation) { Debug.LogWarning("Attempted to spawn an AStar Scientist, but the spawner was full!"); return; } if (!ConVar.AI.npc_enable) { return; } int maxPopulation = this.MaxPopulation - this.Spawned.Count; for (int i = 0; i < maxPopulation; i++) { if (this.GetSpawnPoint(out vector3, out quaternion) != null) { BaseEntity baseEntity = GameManager.server.CreateEntity(this.ScientistAStarPrefab.resourcePath, vector3, quaternion, false); ScientistAStarDomain component = baseEntity.GetComponent <ScientistAStarDomain>(); if (!component) { baseEntity.Kill(BaseNetworkable.DestroyMode.None); return; } baseEntity.enableSaving = false; baseEntity.gameObject.AwakeFromInstantiate(); baseEntity.Spawn(); component.InstallPath(this.Path); this.Spawned.Add(component); } } }
public void SpawnScientist() { if (this.Spawned == null || this.Spawned.Count >= this.MaxPopulation) { Debug.LogWarning((object)"Attempted to spawn an AStar Scientist, but the spawner was full!"); } else { if (!AI.npc_enable) { return; } int num = this.MaxPopulation - this.Spawned.Count; for (int index = 0; index < num; ++index) { Vector3 pos; Quaternion rot; if (!Object.op_Equality((Object)this.GetSpawnPoint(out pos, out rot), (Object)null)) { BaseEntity entity = GameManager.server.CreateEntity(this.ScientistAStarPrefab.resourcePath, pos, rot, false); ScientistAStarDomain component = (ScientistAStarDomain)((Component)entity).GetComponent <ScientistAStarDomain>(); if (Object.op_Implicit((Object)component)) { entity.enableSaving = false; ((Component)entity).get_gameObject().AwakeFromInstantiate(); entity.Spawn(); component.InstallPath(this.Path); this.Spawned.Add(component); } else { entity.Kill(BaseNetworkable.DestroyMode.None); break; } } } } }