Beispiel #1
0
        public static Entity CreateJumpPoint(StarSystemFactory ssf, StarSystem system)
        {
            var primaryStarInfoDB = system.GetFirstEntityWithDataBlob <StarInfoDB>().GetDataBlob <OrbitDB>().Root.GetDataBlob <StarInfoDB>();

            NameDB        jpNameDB        = new NameDB("Jump Point");
            PositionDB    jpPositionDB    = new PositionDB(0, 0, 0, system.Guid);
            TransitableDB jpTransitableDB = new TransitableDB();

            jpTransitableDB.IsStabilized = system.Game.Settings.AllJumpPointsStabilized ?? false;

            if (!jpTransitableDB.IsStabilized)
            {
                // TODO: Introduce a random chance to stablize jumppoints.
            }

            var jpPositionLimits = new MinMaxStruct(ssf.GalaxyGen.Settings.OrbitalDistanceByStarSpectralType[primaryStarInfoDB.SpectralType].Min, ssf.GalaxyGen.Settings.OrbitalDistanceByStarSpectralType[primaryStarInfoDB.SpectralType].Max);

            jpPositionDB.X_AU = GMath.SelectFromRange(jpPositionLimits, system.RNG.NextDouble());
            jpPositionDB.Y_AU = GMath.SelectFromRange(jpPositionLimits, system.RNG.NextDouble());

            // Randomly flip the position sign to allow negative values.
            if (system.RNG.Next(0, 100) < 50)
            {
                jpPositionDB.X_AU = 0 - jpPositionDB.X_AU;
            }
            if (system.RNG.Next(0, 100) < 50)
            {
                jpPositionDB.Y_AU = 0 - jpPositionDB.Y_AU;
            }

            var dataBlobs = new List <BaseDataBlob> {
                jpNameDB, jpTransitableDB, jpPositionDB
            };

            Entity jumpPoint = Entity.Create(system, Guid.Empty, dataBlobs);

            return(jumpPoint);
        }
Beispiel #2
0
 /// <summary>
 /// Calculates where the value falls inside the MinMaxStruct.
 /// </summary>
 /// <returns>Value's percent in the MinMaxStruct (Ranged from 0.0 to 1.0)</returns>
 public static double GetPercentage(double value, MinMaxStruct minMax)
 {
     return(GetPercentage(value, minMax.Min, minMax.Max));
 }
Beispiel #3
0
 /// <summary>
 /// Selects a number from a range based on the selection percentage provided.
 /// </summary>
 public static double SelectFromRange(MinMaxStruct minMax, double selection)
 {
     return(minMax.Min + selection * (minMax.Max - minMax.Min));
 }
Beispiel #4
0
 public static double Clamp(double value, MinMaxStruct minMax)
 {
     return(Clamp(value, minMax.Min, minMax.Max));
 }