예제 #1
0
        public static IEnumerable <Kerberos.Sots.Data.StarMapFramework.Orbit> ChooseOrbitContents(
            Random random,
            StellarClass stellarClass)
        {
            Range <int> orbits            = StarHelper.ChooseOrbits(random, stellarClass);
            int         asteroidBeltCount = 0;

            for (int orbitNumber = 1; orbitNumber <= orbits.Max; ++orbitNumber)
            {
                OrbitContents orbitContents = OrbitContents.Empty;
                if (orbitNumber >= orbits.Min)
                {
                    bool flag = false;
                    while (!flag)
                    {
                        flag          = true;
                        orbitContents = WeightedChoices.Choose <OrbitContents>((double)StarHelper.CalcOrbitContentRoll(random, orbitNumber), StarHelper.OrbitContentWeights);
                        if (orbitContents == OrbitContents.AsteroidBelt && asteroidBeltCount >= 2)
                        {
                            flag = false;
                        }
                    }
                }
                if (orbitContents == OrbitContents.AsteroidBelt)
                {
                    ++asteroidBeltCount;
                }
                Kerberos.Sots.Data.StarMapFramework.Orbit orbiter = StarSystemHelper.CreateOrbiterParams(orbitContents);
                orbiter.OrbitNumber = orbitNumber;
                yield return(orbiter);
            }
        }
예제 #2
0
        public static StellarClass ResolveStellarClass(
            Random random,
            string typeStr,
            string subTypeStr,
            string sizeStr)
        {
            StellarType type;

            if (!StellarClass.TryParseType(typeStr, out type))
            {
                type = StarHelper.ChooseStellarType(random);
            }
            int subtype;

            if (!StellarClass.TryParseSubType(subTypeStr, out subtype))
            {
                subtype = StarHelper.ChooseStellarSubType(random);
            }
            StellarSize size;

            if (!StellarClass.TryParseSize(sizeStr, out size))
            {
                size = StarHelper.ChooseStellarSize(random, type, subtype);
            }
            return(new StellarClass(type, subtype, size));
        }
예제 #3
0
        public static int CalcMinOrbit(StellarClass value)
        {
            int num = StarHelper.CalcMinOrbitCore(value);

            if (num > 1)
            {
                StarSystem.Trace("Invalidating orbits below {0} due to size and heat of {1} star.", (object)num, (object)value);
            }
            return(num);
        }
예제 #4
0
 public static IEnumerable <IStellarEntity> CreateStar(
     Random random,
     StarOrbit orbiterParams)
 {
     StellarClass.Parse(orbiterParams.StellarClass);
     return((IEnumerable <IStellarEntity>) new IStellarEntity[1]
     {
         (IStellarEntity) new StellarEntity()
         {
             Params = (Kerberos.Sots.Data.StarMapFramework.Orbit)orbiterParams
         }
     });
 }
예제 #5
0
        private static void AssignOrbitNumbers(StellarClass stellarClass, List <Kerberos.Sots.Data.StarMapFramework.Orbit> orbitals)
        {
            int orbitNumber = StarHelper.CalcMinOrbit(stellarClass);

            foreach (Kerberos.Sots.Data.StarMapFramework.Orbit orbit in orbitals.Where <Kerberos.Sots.Data.StarMapFramework.Orbit>((Func <Kerberos.Sots.Data.StarMapFramework.Orbit, bool>)(x => x.OrbitNumber < 1)))
            {
                while (orbitals.Any <Kerberos.Sots.Data.StarMapFramework.Orbit>((Func <Kerberos.Sots.Data.StarMapFramework.Orbit, bool>)(x => x.OrbitNumber == orbitNumber)))
                {
                    ++orbitNumber;
                }
                orbit.OrbitNumber = orbitNumber;
                ++orbitNumber;
            }
        }
예제 #6
0
        private static float CalcRadius(Kerberos.Sots.Data.StarMapFramework.Orbit orbital)
        {
            if (orbital is StarOrbit)
            {
                return(StarSystemVars.Instance.StarRadius(StellarClass.Parse((orbital as StarOrbit).StellarClass).Size));
            }
            PlanetInfo planetInfo = StarSystemHelper.InferPlanetInfo(orbital);

            if (planetInfo != null)
            {
                return(StarSystemVars.Instance.SizeToRadius(planetInfo.Size));
            }
            throw new ArgumentException("unexpected type");
        }
예제 #7
0
        private static int ChooseOrbitCount(Random random, StellarClass stellarClass)
        {
            Orbits orbits = WeightedChoices.Choose <Orbits>(random, StarHelper.OrbitCountWeights);
            int    num1   = Math.Max(0, (int)orbits);
            int    val2   = num1;

            if ((Orbits)val2 != orbits)
            {
                throw new NotImplementedException(string.Format("Orbits.{0} not handled for Stars", (object)orbits));
            }
            switch (stellarClass.Size)
            {
            case StellarSize.Ia:
            case StellarSize.Ib:
            case StellarSize.II:
                StarSystem.Trace("Special Rule: If Star Size I or II THEN # of orbits = # of orbits + 4");
                val2 += 4;
                break;

            case StellarSize.III:
                StarSystem.Trace("Special Rule: If Star Size III THEN # of orbits = # of orbits + 2");
                val2 += 2;
                break;
            }
            switch (stellarClass.Type)
            {
            case StellarType.K:
                StarSystem.Trace("Special Rule: If Star Type K THEN # of orbits = # of orbits - 1");
                --val2;
                break;

            case StellarType.M:
                StarSystem.Trace("Special Rule: If Star Type M THEN # of orbits = # of orbits - 2");
                val2 -= 2;
                break;
            }
            int num2 = Math.Max(0, val2);

            StarSystem.Trace("Final orbit count: {0}\n", (object)num2);
            if (num2 == 0 && num1 > 0)
            {
                return(1);
            }
            return(num2);
        }
예제 #8
0
        private static Range <int> ChooseOrbits(Random random, StellarClass stellarClass)
        {
            Range <int> range = new Range <int>(0, 0);
            int         num   = StarHelper.ChooseOrbitCount(random, stellarClass);

            if (num <= 0)
            {
                return(range);
            }
            int max = num;
            int min = StarHelper.CalcMinOrbit(stellarClass);

            if (min > max)
            {
                return(range);
            }
            return(new Range <int>(min, max));
        }
예제 #9
0
 private static List <Kerberos.Sots.Data.StarMapFramework.Orbit> PopulateRandomOrbitsCore(
     Random random,
     Kerberos.Sots.Data.StarMapFramework.Orbit parentOrbital)
 {
     if (parentOrbital is StarOrbit)
     {
         StellarClass stellarClass = StellarClass.Parse((parentOrbital as StarOrbit).StellarClass);
         return(StarHelper.ChooseOrbitContents(random, stellarClass).ToList <Kerberos.Sots.Data.StarMapFramework.Orbit>());
     }
     if (parentOrbital is GasGiantLargeOrbit)
     {
         return(GasGiantHelper.ChooseOrbitContents(random).ToList <Kerberos.Sots.Data.StarMapFramework.Orbit>());
     }
     if (parentOrbital is GasGiantSmallOrbit)
     {
         return(GasGiantHelper.ChooseOrbitContents(random).ToList <Kerberos.Sots.Data.StarMapFramework.Orbit>());
     }
     return(new List <Kerberos.Sots.Data.StarMapFramework.Orbit>());
 }
예제 #10
0
 public static StarDisplayParams GetDisplayParams(StellarClass stellarClass)
 {
     return(StarHelper._displayParams[stellarClass.Type]);
 }
예제 #11
0
        private static int CalcMinOrbitCore(StellarClass value)
        {
            switch (value.Size)
            {
            case StellarSize.Ia:
                if (StellarClass.Contains("B0", "B4", value))
                {
                    return(8);
                }
                if (StellarClass.Contains("B5", "A9", value))
                {
                    return(7);
                }
                if (StellarClass.Contains("F0", "F9", value))
                {
                    return(6);
                }
                if (StellarClass.Contains("G0", "M4", value))
                {
                    return(7);
                }
                if (StellarClass.Contains("M5", "M9", value))
                {
                    return(8);
                }
                break;

            case StellarSize.Ib:
                if (StellarClass.Contains("B0", "B4", value))
                {
                    return(8);
                }
                if (StellarClass.Contains("B5", "B9", value))
                {
                    return(6);
                }
                if (StellarClass.Contains("A0", "F4", value))
                {
                    return(5);
                }
                if (StellarClass.Contains("F5", "G4", value))
                {
                    return(4);
                }
                if (StellarClass.Contains("G5", "K4", value))
                {
                    return(5);
                }
                if (StellarClass.Contains("K5", "M4", value))
                {
                    return(6);
                }
                if (StellarClass.Contains("M5", "M8", value))
                {
                    return(7);
                }
                if (StellarClass.Contains("M9", "M9", value))
                {
                    return(8);
                }
                break;

            case StellarSize.II:
                if (StellarClass.Contains("B0", "B4", value))
                {
                    return(7);
                }
                if (StellarClass.Contains("B5", "B9", value))
                {
                    return(5);
                }
                if (StellarClass.Contains("A0", "A4", value))
                {
                    return(3);
                }
                if (StellarClass.Contains("A5", "K4", value))
                {
                    return(2);
                }
                if (StellarClass.Contains("K5", "K9", value))
                {
                    return(3);
                }
                if (StellarClass.Contains("M0", "M4", value))
                {
                    return(4);
                }
                if (StellarClass.Contains("M5", "M9", value))
                {
                    return(6);
                }
                break;

            case StellarSize.III:
                if (StellarClass.Contains("B0", "B4", value))
                {
                    return(7);
                }
                if (StellarClass.Contains("B5", "B9", value))
                {
                    return(5);
                }
                if (StellarClass.Contains("M0", "M4", value))
                {
                    return(2);
                }
                if (StellarClass.Contains("M5", "M8", value))
                {
                    return(4);
                }
                if (StellarClass.Contains("M9", "M9", value))
                {
                    return(5);
                }
                break;

            case StellarSize.IV:
                if (StellarClass.Contains("B0", "B4", value))
                {
                    return(7);
                }
                if (StellarClass.Contains("B5", "B9", value))
                {
                    return(3);
                }
                break;

            case StellarSize.V:
                if (StellarClass.Contains("B0", "B4", value))
                {
                    return(6);
                }
                if (StellarClass.Contains("B5", "B9", value))
                {
                    return(3);
                }
                break;
            }
            return(1);
        }
예제 #12
0
 public static Vector4 CalcModelColor(StellarClass stellarClass)
 {
     return(StarHelper.CalcColor(stellarClass.Type, stellarClass.SubType, StarHelper.ModelColorTable));
 }
예제 #13
0
        public static StarSystem CreateStarSystem(Random random, Matrix worldTransform, Kerberos.Sots.Data.StarMapFramework.StarSystem systemParams, LegacyTerrain parentTerrain)
        {
            StellarClass stellarClass = StarHelper.ResolveStellarClass(random, systemParams.Type, systemParams.SubType, systemParams.Size);

            Kerberos.Sots.Data.StarMapFramework.StarOrbit starOrbit = new StarOrbit();
            starOrbit.Name         = systemParams.Name;
            starOrbit.StellarClass = stellarClass.ToString();
            int randomOrbital = 1;
            List <Kerberos.Sots.Data.StarMapFramework.Orbit> list = new List <Kerberos.Sots.Data.StarMapFramework.Orbit>();

            list.Add(starOrbit);
            for (int i = 0; i < list.Count; i++)
            {
                Kerberos.Sots.Data.StarMapFramework.Orbit thisOrbital = list[i];
                if (!(thisOrbital is EmptyOrbit))
                {
                    List <Kerberos.Sots.Data.StarMapFramework.Orbit> predefinedOrbitals = new List <Kerberos.Sots.Data.StarMapFramework.Orbit>();
                    predefinedOrbitals.AddRange(systemParams.Orbits.Where(delegate(Kerberos.Sots.Data.StarMapFramework.Orbit x)
                    {
                        if (string.IsNullOrEmpty(x.Parent))
                        {
                            return(thisOrbital is StarOrbit);
                        }
                        return(x.Parent == thisOrbital.Name);
                    }));
                    if (thisOrbital is StarOrbit)
                    {
                        StarSystemHelper.AssignOrbitNumbers(stellarClass, predefinedOrbitals);
                    }
                    else
                    {
                        int orbitNumber = 1;
                        predefinedOrbitals.ForEach(delegate(Kerberos.Sots.Data.StarMapFramework.Orbit x)
                        {
                            x.OrbitNumber = orbitNumber++;
                        });
                    }
                    List <Kerberos.Sots.Data.StarMapFramework.Orbit> list2 = StarSystemHelper.PopulateRandomOrbits(random, thisOrbital);
                    list2.RemoveAll((Kerberos.Sots.Data.StarMapFramework.Orbit x) => predefinedOrbitals.Any((Kerberos.Sots.Data.StarMapFramework.Orbit y) => y.OrbitNumber == x.OrbitNumber));
                    list2.ForEach(delegate(Kerberos.Sots.Data.StarMapFramework.Orbit x)
                    {
                        x.Name = string.Format("RandomOrbital{0}", ++randomOrbital);
                    });
                    list.AddRange(predefinedOrbitals);
                    list.AddRange(list2);
                }
            }
            StarSystem starSystem = new StarSystem();

            starSystem.Params          = systemParams;
            starSystem.WorldTransform  = worldTransform;
            starSystem.DisplayName     = systemParams.Name;
            starSystem.IsStartPosition = systemParams.isStartLocation;
            starSystem.WorldTransform  = worldTransform;
            starSystem.Terrain         = parentTerrain;
            foreach (Kerberos.Sots.Data.StarMapFramework.Orbit orbit in list)
            {
                bool isOrbitingStar        = orbit.Parent == starOrbit.Name;
                List <IStellarEntity> objs = new List <IStellarEntity>(StarSystemHelper.CreateOrbiters(random, orbit, isOrbitingStar));
                starSystem.AddRange(objs);
            }
            foreach (IStellarEntity stellarEntity in starSystem.Objects)
            {
                IStellarEntity stellarEntity2 = StarSystemHelper.FindOrbitParent(starSystem, stellarEntity);
                if (stellarEntity2 != null)
                {
                    stellarEntity.Orbit = StarSystem.SetOrbit(random, stellarEntity2.Params, stellarEntity.Params);
                }
            }
            return(starSystem);
        }