Beispiel #1
0
 public unsafe StellarClass(StellarType type, int subtype, StellarSize size)
 {
     this         = default;
     this.Type    = type;
     this.SubType = subtype;
     this.Size    = size;
 }
Beispiel #2
0
        public float StarRadius(StellarSize size)
        {
            switch (size)
            {
            case StellarSize.Ia:
                return(this.StarRadiusIa);

            case StellarSize.Ib:
                return(this.StarRadiusIb);

            case StellarSize.II:
                return(this.StarRadiusII);

            case StellarSize.III:
                return(this.StarRadiusIII);

            case StellarSize.IV:
                return(this.StarRadiusIV);

            case StellarSize.V:
                return(this.StarRadiusV);

            case StellarSize.VI:
                return(this.StarRadiusVI);

            case StellarSize.VII:
                return(this.StarRadiusVII);

            default:
                return(0.0f);
            }
        }
Beispiel #3
0
        public static StellarClass ChooseStellarClass(Random random)
        {
            StellarType type    = StarHelper.ChooseStellarType(random);
            int         subtype = StarHelper.ChooseStellarSubType(random);
            StellarSize size    = StarHelper.ChooseStellarSize(random, type, subtype);

            return(new StellarClass(type, subtype, size));
        }
Beispiel #4
0
        public static string Random(string Type = null, int?SubType = null, string Size = null)
        {
            string      str         = "";
            StellarType stellarType = (StellarType)StellarClass._rand.Next(0, 7);
            StellarSize stellarSize = (StellarSize)StellarClass._rand.Next(0, 8);
            int         num         = StellarClass._rand.Next(0, 9);

            return(str + (Type ?? stellarType.ToString()) + (object)(SubType ?? num) + (Size ?? stellarSize.ToString()));
        }
Beispiel #5
0
 public int CompareTo(object obj)
 {
     if (obj is StellarSize)
     {
         return(StellarSize.CompareTo(obj));
     }
     else if (obj is StellarObjectSize)
     {
         return(this.CompareTo((StellarObjectSize)obj));
     }
     return(StellarSize.CompareTo(obj));
 }
Beispiel #6
0
        public static StellarSize ChooseStellarSize(
            Random random,
            StellarType type,
            int subtype)
        {
            StellarSize stellarSize = WeightedChoices.Choose <StellarSize>(random, StarHelper.StarSizeWeights);

            if (stellarSize == StellarSize.IV && type >= StellarType.K && (subtype >= 5 && type <= StellarType.M) && subtype <= 9)
            {
                StarSystem.Trace("Special Rule: IF Star is type K5 through M9, THEN treat result IV as V.");
                stellarSize = StellarSize.V;
            }
            if (stellarSize == StellarSize.VI && type >= StellarType.B && (subtype >= 0 && type <= StellarType.F) && subtype <= 4)
            {
                StarSystem.Trace("Special Rule: IF Star is type B0 through F4, THEN treat result VI as V");
                stellarSize = StellarSize.V;
            }
            return(stellarSize);
        }
Beispiel #7
0
 public static bool TryParseSize(string str, out StellarSize value)
 {
     return(Enum.TryParse <StellarSize>(str, out value));
 }
Beispiel #8
0
        public Star Instantiate()
        {
            var candidates = Mod.Current.StellarObjectTemplates.OfType <Star>();

            if (StellarSize != null)
            {
                candidates = candidates.Where(s => s.StellarSize == StellarSize.Value);
            }
            if (Age != null)
            {
                candidates = candidates.Where(s => s.Age == Age);
            }
            if (Color != null)
            {
                candidates = candidates.Where(s => s.Color == Color);
            }
            if (Brightness != null)
            {
                candidates = candidates.Where(s => s.Brightness == Brightness);
            }
            if (!candidates.Any())
            {
                throw new Exception("No stars in SectType.txt match the criteria:\n\tStellar Size: " + (StellarSize == null ? "Any" : StellarSize.ToString()) + "\n\tAge: " + (Age ?? "Any") + "\n\tColor: " + (Color ?? "Any") + "\n\tBrightness: " + (Brightness ?? "Any"));
            }

            var star = candidates.PickRandom().Instantiate();

            var abil = Abilities.Instantiate();

            if (abil != null)
            {
                star.IntrinsicAbilities.Add(abil);
            }

            return(star);
        }
Beispiel #9
0
        public Planet Instantiate()
        {
            var candidates = Mod.Current.StellarObjectTemplates.OfType <Planet>();

            if (Atmosphere != null)
            {
                candidates = candidates.Where(p => p.Atmosphere == Atmosphere);
            }
            if (Surface != null)
            {
                candidates = candidates.Where(p => p.Surface == Surface);
            }
            if (StellarSize != null)
            {
                candidates = candidates.Where(p => p.StellarSize == StellarSize);
            }
            candidates = candidates.Where(p => p.Size.IsConstructed == IsConstructed);

            if (!candidates.Any())
            {
                throw new Exception("No planets in SectType.txt match the criteria:\n\tAtmosphere: " + (Atmosphere ?? "Any") + "\n\tSurface: " + (Surface ?? "Any") + "\n\tStellar Size: " + (StellarSize == null ? "Any" : StellarSize.ToString()));
            }

            var planet = candidates.PickRandom().Instantiate();

            if (planet.Size == null)
            {
                var sizes = Mod.Current.StellarObjectSizes.Where(sos => sos.StellarObjectType == "Planet" && !sos.IsConstructed && (StellarSize == null || sos.StellarSize == StellarSize.Value));
                planet.Size = sizes.PickRandom();
            }

            var abil = Abilities.Instantiate();

            if (abil != null)
            {
                planet.IntrinsicAbilities.Add(abil);
            }

            planet.ResourceValue[Resource.Minerals]     = RandomHelper.Range(Galaxy.Current.MinSpawnedPlanetValue, Galaxy.Current.MaxSpawnedPlanetValue);
            planet.ResourceValue[Resource.Organics]     = RandomHelper.Range(Galaxy.Current.MinSpawnedPlanetValue, Galaxy.Current.MaxSpawnedPlanetValue);
            planet.ResourceValue[Resource.Radioactives] = RandomHelper.Range(Galaxy.Current.MinSpawnedPlanetValue, Galaxy.Current.MaxSpawnedPlanetValue);

            planet.ConditionsAmount = RandomHelper.Range(Mod.Current.Settings.MinRandomPlanetConditions, Mod.Current.Settings.MaxRandomPlanetConditions);

            return(planet);
        }
Beispiel #10
0
        public AsteroidField Instantiate()
        {
            var candidates = Mod.Current.StellarObjectTemplates.OfType <AsteroidField>();

            if (Atmosphere != null)
            {
                candidates = candidates.Where(ast => ast.Atmosphere == Atmosphere);
            }
            if (Surface != null)
            {
                candidates = candidates.Where(ast => ast.Surface == Surface);
            }
            if (StellarSize != null)
            {
                candidates = candidates.Where(ast => ast.StellarSize == StellarSize);
            }

            if (!candidates.Any())
            {
                throw new Exception("No asteroid fields in SectType.txt match the criteria:\n\tAtmosphere: " + (Atmosphere ?? "Any") + "\n\tSurface: " + (Surface ?? "Any") + "\n\tStellar Size: " + (StellarSize == null ? "Any" : StellarSize.ToString()));
            }

            var asteroids = candidates.PickRandom().Instantiate();

            if (asteroids.Size == null)
            {
                var sizes = Mod.Current.StellarObjectSizes.Where(sos => sos.StellarObjectType == "Asteroids" && !sos.IsConstructed && (StellarSize == null || sos.StellarSize == StellarSize.Value));
                asteroids.Size = sizes.PickRandom();
            }

            var abil = Abilities.Instantiate();

            if (abil != null)
            {
                asteroids.IntrinsicAbilities.Add(abil);
            }

            asteroids.ResourceValue[Resource.Minerals]     = RandomHelper.Range(Galaxy.Current.MinSpawnedAsteroidValue, Galaxy.Current.MaxSpawnedAsteroidValue);
            asteroids.ResourceValue[Resource.Organics]     = RandomHelper.Range(Galaxy.Current.MinSpawnedAsteroidValue, Galaxy.Current.MaxSpawnedAsteroidValue);
            asteroids.ResourceValue[Resource.Radioactives] = RandomHelper.Range(Galaxy.Current.MinSpawnedAsteroidValue, Galaxy.Current.MaxSpawnedAsteroidValue);

            return(asteroids);
        }
Beispiel #11
0
 public int CompareTo(StellarObjectSize obj)
 {
     return(StellarSize.CompareTo(obj.StellarSize));
 }
Beispiel #12
0
 public static float CalcRadius(StellarSize size)
 {
     return(StarSystem.Vars.StarRadius(size));
 }