Exemplo n.º 1
0
        public static LegacyStarMap CreateStarMapFromFileCore(
            Random random,
            string starMapPath)
        {
            Starmap s = new Starmap();

            StarMapXmlUtility.LoadStarmapFromXml(starMapPath, ref s);
            return(LegacyStarMap.CreateStarMap(random, s));
        }
Exemplo n.º 2
0
        public static LegacyStarMap CreateStarMap(Random random, Starmap starmapParams)
        {
            LegacyStarMap map = new LegacyStarMap();

            foreach (Feature feature in starmapParams.Features)
            {
                map.AddRange(LegacyStarMap.CreateFeature(random, feature.LocalSpace, feature, map, (LegacyTerrain)null));
            }
            map._nodelines.AddRange((IEnumerable <NodeLine>)starmapParams.NodeLines);
            map._provinces.AddRange((IEnumerable <Province>)starmapParams.Provinces);
            map.FixPlanetTypes();
            return(map);
        }
Exemplo n.º 3
0
        public static IEnumerable <ILegacyStarMapObject> CreateTerrain(
            Random random,
            Matrix worldTransform,
            Kerberos.Sots.Data.StarMapFramework.Terrain terrainParams,
            LegacyStarMap map)
        {
            LegacyTerrain parentTerrain = new LegacyTerrain();
            List <ILegacyStarMapObject> legacyStarMapObjectList = new List <ILegacyStarMapObject>();

            foreach (Feature feature in terrainParams.Features)
            {
                Matrix worldTransform1 = feature.LocalSpace * worldTransform;
                legacyStarMapObjectList.AddRange(LegacyStarMap.CreateFeature(random, worldTransform1, feature, map, parentTerrain));
            }
            parentTerrain.Name   = terrainParams.Name;
            parentTerrain.Origin = new Vector3(worldTransform.M41, worldTransform.M42, worldTransform.M43);
            map._terrain.Add(parentTerrain);
            map._nodelines.AddRange((IEnumerable <NodeLine>)terrainParams.NodeLines);
            map._provinces.AddRange((IEnumerable <Province>)terrainParams.Provinces);
            return((IEnumerable <ILegacyStarMapObject>)legacyStarMapObjectList);
        }
Exemplo n.º 4
0
 public static IEnumerable <ILegacyStarMapObject> CreateFeature(
     Random random,
     Matrix worldTransform,
     Feature featureParams,
     LegacyStarMap map,
     LegacyTerrain parentTerrain)
 {
     if (featureParams.GetType() == typeof(Kerberos.Sots.Data.StarMapFramework.Terrain))
     {
         return(LegacyStarMap.CreateTerrain(random, worldTransform, featureParams as Kerberos.Sots.Data.StarMapFramework.Terrain, map));
     }
     if (featureParams.GetType() == typeof(Kerberos.Sots.Data.StarMapFramework.StarSystem))
     {
         return(LegacyStarMap.CreateStarSystem(random, worldTransform, featureParams as Kerberos.Sots.Data.StarMapFramework.StarSystem, parentTerrain));
     }
     if (featureParams.GetType() == typeof(StellarBody))
     {
         return(LegacyStarMap.CreateStellarObject(random, worldTransform, featureParams as StellarBody));
     }
     throw new ArgumentException(string.Format("Unsupported starmap feature '{0}'.", (object)featureParams.GetType()));
 }
Exemplo n.º 5
0
 internal void AssignEmptySystemNames(Random random, NamesPool namesPool)
 {
     foreach (Kerberos.Sots.StarSystem starSystem in this.Objects.OfType <Kerberos.Sots.StarSystem>())
     {
         if (string.IsNullOrWhiteSpace(starSystem.DisplayName) || starSystem.DisplayName.ToLower() == "random system")
         {
             starSystem.DisplayName = namesPool.GetSystemName();
         }
         List <IStellarEntity> list1 = starSystem.GetPlanets().ToList <IStellarEntity>();
         list1.Sort(new Comparison <IStellarEntity>(LegacyStarMap.CompareByOrbitNumber));
         int num1 = 0;
         foreach (IStellarEntity planet in list1)
         {
             ++num1;
             if (LegacyStarMap.IsRandomOrbitName(planet.Params))
             {
                 planet.Params.Name = string.Format("{0} {1}", (object)starSystem.DisplayName, (object)num1);
             }
             List <IStellarEntity> list2 = starSystem.GetMoons(planet).ToList <IStellarEntity>();
             list2.Sort(new Comparison <IStellarEntity>(LegacyStarMap.CompareByOrbitNumber));
             int num2 = 0;
             foreach (IStellarEntity stellarEntity in list2.Where <IStellarEntity>((Func <IStellarEntity, bool>)(x => LegacyStarMap.IsRandomOrbitName(x.Params))))
             {
                 stellarEntity.Params.Name = string.Format("{0}{1}", (object)planet.Params.Name, (object)(char)(65 + num2));
                 ++num2;
             }
         }
         List <IStellarEntity> list3 = starSystem.GetAsteroidBelts().ToList <IStellarEntity>();
         list3.Sort(new Comparison <IStellarEntity>(LegacyStarMap.CompareByOrbitNumber));
         int num3 = 0;
         foreach (IStellarEntity stellarEntity in list3)
         {
             ++num3;
             if (LegacyStarMap.IsRandomOrbitName(stellarEntity.Params))
             {
                 stellarEntity.Params.Name = string.Format("{0} " + App.Localize("@UI_BELT_NAME_MOD") + " {1}", (object)starSystem.DisplayName, (object)num3);
             }
         }
     }
 }