コード例 #1
0
        private void InitializeEntities()
        {
            var gameData     = AppModel.GameData;
            var entityLookup = gameData.EntityManager.DisplayEntityLookup;
            var rng          = m_gameServices.RandomNumberGenerator;

            var entities    = SystemDataFileUtility.LoadEntities("Data\\SolSystem.txt", entityLookup, rng);
            var earthEntity = entities.FirstOrDefault(x => x.GetRequiredComponent <InformationComponent>().Name == "Earth");

            if (earthEntity != null)
            {
                EntityUtility.MakeHomeWorld(earthEntity, EntityUtility.GetHumanTemplate());
            }

            var planetViewModels = entities.Select(x => new PlanetViewModel(x));

            m_planets.AddRange(planetViewModels);

            foreach (var planet in m_planets)
            {
                planet.UpdateFromEntity(entityLookup);
            }

            Planet = m_planets.FirstOrDefault(x => x.Name == "Earth");
        }