//public string GetConfigPath() { return m_ConfigPath; } // Use this for initialization public void Init(string configPath) { if (m_Initialized == false) { //m_ConfigPath = configPath; Dictionary <string, uint> celestialBodyIds = new Dictionary <string, uint>(); DirectoryInfo info = new DirectoryInfo(configPath); FileInfo[] fileInfo = info.GetFiles("*.xml"); foreach (FileInfo file in fileInfo) { // Load CelestialBody newBody = CelestialBody.Create(file); if (newBody != null) { // Temp hack to keep everything easier to see for now //float celestialScale = 100.0f; //newBody.transform.localScale = new Vector3( celestialScale, celestialScale, celestialScale ); m_CelestialBodies.Add(newBody.CelestialID, newBody); celestialBodyIds.Add(newBody.name, newBody.CelestialID); Debug.Log(file); } else { Debug.LogWarning("Celestial Manager failed to load: " + file.FullName); } } GameObject celestialBodyParent = new GameObject("Celestial Bodies"); // Set up the celestial hierarchy now that all bodies have been instantiated List <CelestialBody> bodies = GetCelestialBodies(CelestialBody.CelestialType.All); foreach (CelestialBody body in bodies) { if (body.OrbitParentName.Length > 0) { uint bodyID; if (celestialBodyIds.TryGetValue(body.OrbitParentName, out bodyID)) { CelestialBody parentBody; if (m_CelestialBodies.TryGetValue(bodyID, out parentBody)) { body.OrbitParentID = parentBody.CelestialID; } else { Debug.LogError("Failed to find orbit parent: " + bodyID.ToString()); } } else { Debug.LogError("Failed to find orbit parent: " + body.OrbitParentName); } } // For organization we parent all bodies to a dummy object body.transform.parent = celestialBodyParent.transform; } m_Initialized = true; } }