Exemplo n.º 1
0
 public Star(string name, string sprite, StellarClass stellarClass, float temperature, float radius, Vector2 position, params SpaceObject[] children)
     : base(children)
 {
     Name = name;
     Class = stellarClass;
     Temperature = temperature;
     PhotosphereRadius = radius;
     CoronaRadius = radius * 1.25f;
     TextureId = sprite;
 }
Exemplo n.º 2
0
        protected override StarMapSystem CreateSystem(
            GameObjectSet gos,
            StarSystemInfo oi,
            StarMapBase.SyncContext context)
        {
            StellarClass      stellarClass  = StellarClass.Parse(oi.StellarClass);
            StarDisplayParams displayParams = StarHelper.GetDisplayParams(stellarClass);
            StarMapSystem     starMapSystem = new StarMapSystem(gos.App, displayParams.AssetPath, oi.Origin, StarHelper.CalcRadius(stellarClass.Size) / StarSystemVars.Instance.StarRadiusIa, oi.Name);

            gos.Add((IGameObject)starMapSystem);
            return(starMapSystem);
        }
Exemplo n.º 3
0
        protected override StarMapSystem CreateSystem(
            GameObjectSet gos,
            StarSystemInfo oi,
            StarMapBase.SyncContext context)
        {
            StellarClass  stellarClass  = StellarClass.Parse(oi.StellarClass);
            StarMapSystem starMapSystem = new StarMapSystem(this.App, StarHelper.GetDisplayParams(stellarClass).AssetPath, oi.Origin, StarHelper.CalcRadius(stellarClass.Size) / StarSystemVars.Instance.StarRadiusIa, oi.Name);

            starMapSystem.SetSensorRange(this._sim.GameDatabase.GetSystemStratSensorRange(oi.ID, this._sim.LocalPlayer.ID));
            gos.Add((IGameObject)starMapSystem);
            return(starMapSystem);
        }
Exemplo n.º 4
0
        public static void AddSuperNovas(GameSession game, GameDatabase gamedb, AssetDatabase assetdb)
        {
            if (!gamedb.HasEndOfFleshExpansion() || game.ScriptModules.SuperNova == null || gamedb.GetTurnCount() < assetdb.GlobalSuperNovaData.MinTurns)
            {
                return;
            }
            string nameValue1 = game.GameDatabase.GetNameValue("GMCount");

            if (string.IsNullOrEmpty(nameValue1))
            {
                game.GameDatabase.InsertNameValuePair("GMCount", "0");
                nameValue1 = game.GameDatabase.GetNameValue("GMCount");
            }
            int nameValue2 = game.GameDatabase.GetNameValue <int>("GSGrandMenaceCount");
            int num1       = int.Parse(nameValue1);

            if (num1 >= nameValue2)
            {
                return;
            }
            Random safeRandom = App.GetSafeRandom();

            if (!safeRandom.CoinToss(assetdb.GlobalSuperNovaData.Chance))
            {
                return;
            }
            List <StarSystemInfo> list1   = gamedb.GetStarSystemInfos().ToList <StarSystemInfo>();
            List <SuperNovaInfo>  list2   = gamedb.GetSuperNovaInfos().ToList <SuperNovaInfo>();
            List <int>            intList = new List <int>();

            foreach (StarSystemInfo starSystemInfo in list1)
            {
                StarSystemInfo ssi          = starSystemInfo;
                StellarClass   stellarClass = new StellarClass(ssi.StellarClass);
                if ((stellarClass.Type == StellarType.O || stellarClass.Type == StellarType.B) && !list2.Any <SuperNovaInfo>((Func <SuperNovaInfo, bool>)(x => x.SystemId == ssi.ID)))
                {
                    intList.Add(ssi.ID);
                }
            }
            if (intList.Count <= 0)
            {
                return;
            }
            game.ScriptModules.SuperNova.AddInstance(gamedb, assetdb, safeRandom.Choose <int>((IList <int>)intList));
            int num2;

            game.GameDatabase.UpdateNameValuePair("GMCount", (num2 = num1 + 1).ToString());
        }
Exemplo n.º 5
0
        public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int SystemId, int OrbitId)
        {
            int num1 = OrbitId;

            if (gamedb.GetLargeAsteroidInfo(OrbitId) == null && gamedb.GetAsteroidBeltInfo(OrbitId) == null)
            {
                OrbitalObjectInfo orbitalObjectInfo = gamedb.GetOrbitalObjectInfo(OrbitId);
                StarSystemInfo    starSystemInfo    = gamedb.GetStarSystemInfo(SystemId);
                gamedb.RemoveOrbitalObject(orbitalObjectInfo.ID);
                if (!orbitalObjectInfo.ParentID.HasValue)
                {
                    num1 = gamedb.InsertAsteroidBelt(new int?(), orbitalObjectInfo.StarSystemID, orbitalObjectInfo.OrbitalPath, "Swarmed Asteroid Belt", App.GetSafeRandom().Next());
                }
                else
                {
                    int         num2        = gamedb.GetStarSystemOrbitalObjectInfos(SystemId).Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => !x.ParentID.HasValue)).Count <OrbitalObjectInfo>();
                    OrbitalPath orbitalPath = gamedb.OrbitNumberToOrbitalPath(num2 + 1, StellarClass.Parse(starSystemInfo.StellarClass).Size, new float?());
                    num1 = gamedb.InsertAsteroidBelt(new int?(), orbitalObjectInfo.StarSystemID, orbitalPath, "Swarmed Asteroid Belt", App.GetSafeRandom().Next());
                }
            }
            SwarmerInfo si = new SwarmerInfo();

            si.GrowthStage    = 0;
            si.SystemId       = SystemId;
            si.OrbitalId      = num1;
            si.HiveFleetId    = new int?(gamedb.InsertFleet(this.PlayerId, 0, SystemId, SystemId, "Swarm", FleetType.FL_NORMAL));
            si.QueenFleetId   = new int?();
            si.SpawnHiveDelay = 1;
            gamedb.InsertSwarmerInfo(si);
            gamedb.InsertShip(si.HiveFleetId.Value, this._hiveStage1DesignId, null, (ShipParams)0, new int?(), 0);
        }
Exemplo n.º 6
0
        internal static void Sync(App game, int systemId, string mapPanelId, bool isClickable)
        {
            bool flag = StarMap.IsInRange(game.Game.GameDatabase, game.LocalPlayer.ID, game.GameDatabase.GetStarSystemInfo(systemId), (Dictionary <int, List <ShipInfo> >)null);

            StarSystemMapUI.ResetMap(game, mapPanelId);
            if (systemId == 0)
            {
                return;
            }
            float        time         = 0.0f;
            GameDatabase gameDatabase = game.GameDatabase;
            IEnumerable <OrbitalObjectInfo> orbitalObjectInfos = gameDatabase.GetStarSystemOrbitalObjectInfos(systemId);
            StarSystemInfo starSystemInfo = gameDatabase.GetStarSystemInfo(systemId);
            StellarClass   stellarClass   = StellarClass.Parse(starSystemInfo.StellarClass);

            if (starSystemInfo.IsDeepSpace)
            {
                return;
            }
            float num1 = StarHelper.CalcRadius(StellarSize.Ia);
            float num2 = StarHelper.CalcRadius(StellarSize.VII);
            float num3 = ScalarExtensions.Lerp(0.67f, 3f, (float)(((double)StarHelper.CalcRadius(stellarClass.Size) - (double)num2) / ((double)num1 - (double)num2)));

            StarSystemMapUI.IconParams iconParams1 = StarSystemMapUI.IconParams.Default;
            iconParams1.ObjectID  = StarSystemDetailsUI.StarItemID;
            iconParams1.Text      = starSystemInfo.Name;
            iconParams1.Icon      = "sysmap_star";
            iconParams1.X         = 0.0f;
            iconParams1.Y         = 0.0f;
            iconParams1.Scale     = num3;
            iconParams1.Color     = StarHelper.CalcIconColor(stellarClass);
            iconParams1.Clickable = isClickable;
            StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams1);
            foreach (AsteroidBeltInfo asteroidBeltInfo in gameDatabase.GetStarSystemAsteroidBeltInfos(systemId))
            {
                AsteroidBeltInfo           asteroidBelt      = asteroidBeltInfo;
                OrbitalObjectInfo          orbitalObjectInfo = orbitalObjectInfos.First <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => x.ID == asteroidBelt.ID));
                StarSystemMapUI.IconParams iconParams2       = new StarSystemMapUI.IconParams();
                iconParams2.SetPos(game, orbitalObjectInfos, time, orbitalObjectInfo.ID);
                iconParams2.ObjectID  = orbitalObjectInfo.ID;
                iconParams2.Icon      = "sysmap_roiddust";
                iconParams2.Scale     = 0.85f;
                iconParams2.Color     = Vector4.One;
                iconParams2.Text      = orbitalObjectInfo.Name;
                iconParams2.Clickable = false;
                StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams2);
            }
            PlanetInfo[] systemPlanetInfos = gameDatabase.GetStarSystemPlanetInfos(systemId);
            foreach (OrbitalObjectInfo orbitalObjectInfo in orbitalObjectInfos.Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => !x.ParentID.HasValue)))
            {
                OrbitalObjectInfo orbital    = orbitalObjectInfo;
                PlanetInfo        planetInfo = ((IEnumerable <PlanetInfo>)systemPlanetInfos).FirstOrDefault <PlanetInfo>((Func <PlanetInfo, bool>)(x => x.ID == orbital.ID));
                if (planetInfo != null)
                {
                    string str = StarSystemMapUI.SelectIcon(planetInfo, orbitalObjectInfos, (IEnumerable <PlanetInfo>)systemPlanetInfos);
                    if (string.IsNullOrEmpty(str))
                    {
                        App.Log.Trace(string.Format("Planet {0} does not have an icon to represent it in the mini system map.", (object)orbital.Name), "gui");
                    }
                    else
                    {
                        AIColonyIntel colonyIntelForPlanet = game.GameDatabase.GetColonyIntelForPlanet(game.LocalPlayer.ID, planetInfo.ID);
                        if (colonyIntelForPlanet != null && flag)
                        {
                            Vector3 primaryColor = game.GameDatabase.GetPlayerInfo(colonyIntelForPlanet.OwningPlayerID).PrimaryColor;
                            Vector4 vector4      = new Vector4(primaryColor.X, primaryColor.Y, primaryColor.Z, 1f);
                            StarSystemMapUI.IconParams iconParams2 = StarSystemMapUI.IconParams.Default;
                            iconParams2.SetPos(game, orbitalObjectInfos, time, planetInfo.ID);
                            iconParams2.ObjectID  = 0;
                            iconParams2.Icon      = "sysmap_ownerring";
                            iconParams2.Scale     = 0.85f;
                            iconParams2.Color     = vector4;
                            iconParams2.Text      = string.Empty;
                            iconParams2.Clickable = false;
                            StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams2);
                        }
                        StarSystemMapUI.IconParams iconParams3 = new StarSystemMapUI.IconParams();
                        iconParams3.SetPos(game, orbitalObjectInfos, time, planetInfo.ID);
                        iconParams3.ObjectID  = planetInfo.ID;
                        iconParams3.Icon      = str;
                        iconParams3.Scale     = 0.85f;
                        iconParams3.Color     = Vector4.One;
                        iconParams3.Text      = orbital.Name;
                        iconParams3.Clickable = isClickable;
                        StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams3);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private static IGameObject CreateProceduralStar(
            App game,
            CombatConfig.DataContext context,
            XmlElement node)
        {
            string  stringOrDefault1 = node["StellarClass"].ExtractStringOrDefault("G2V");
            string  stringOrDefault2 = node["Name"].ExtractStringOrDefault(string.Empty);
            Vector3 vector3OrDefault = node["Position"].ExtractVector3OrDefault(Vector3.Zero);

            context.TransformPosition(ref vector3OrDefault);
            return((IGameObject)Kerberos.Sots.GameStates.StarSystem.CreateStar(game, vector3OrDefault, StellarClass.Parse(stringOrDefault1), stringOrDefault2, 1f, true));
        }
Exemplo n.º 8
0
		private void GenStars ()
		{
			float starMassRatio = 0.8f;
			
			int numStars = GalaxyManager.numStarsPerSystem.NextValue () + 1;
			float[] masses = new float[numStars];
			StellarClass[] starClasses = new StellarClass[numStars];
			for (int s = 0; s<numStars; s++) {
				StellarClass starClass = (StellarClass)GalaxyManager.stellarDie.NextValue ();
				starClasses [s] = starClass;
				masses [s] = GalaxyManager.stellarMass [starClass].Rand ();
			}
			for (int i = 0; i<numStars; i++) {
				for (int s = 1; s<numStars; s++) {
					if (masses [s] > masses [s - 1]) {
						float m = masses [s];
						StellarClass st = starClasses [s];
						masses [s] = masses [s - 1];
						starClasses [s] = starClasses [s - 1];
						masses [s - 1] = m;
						starClasses [s - 1] = st;
						//adjust mass value to force decreasing mass
						float newMass = starMassRatio * masses [s];
						masses [s] = newMass;
						foreach (StellarClass sc in GalaxyManager.stellarMass.Keys) {
							MinMax scMinMax = GalaxyManager.stellarMass [sc];
							if (scMinMax.max > newMass && scMinMax.min < newMass) {
								starClasses [s] = sc;
								break;
							}
						}
					}
				}
			}
			for (int s = 0; s<numStars; s++) {
				StellarClass starClass = starClasses [s];
				float mass = masses [s];
				float diameter = GalaxyManager.stellarDiameter [starClass].Rand ();
				float luminosity = GalaxyManager.stellarLuminosity [starClass].Rand ();
				float temperature = GalaxyManager.stellarTemperature [starClass].Rand ();
				StellarColor color = GalaxyManager.stellarColor [starClass];
				StarBody starBody = new StarBody ();
				if (s == 0) {
					starBody.Init ("", CelestialBodyType.Star, mass, diameter, this);
				} else {
					starBody.Init ("", CelestialBodyType.Star, mass, diameter, this, stars [s - 1]);
				}
				starBody.stellarClass = starClass;
				starBody.luminosity = luminosity;
				starBody.temperature = temperature;
				starBody.color = color; 
				starBody.Print ();
				starBody.scale *= UnitConversion.Distance.SolDiameter.Value (diameter);
				celestialBodies.Add (starBody);
				totalMass += UnitConversion.Mass.SolMass.Value (mass, UnitConversion.Mass.MegaTon);
				
				stars.Add (starBody);
			}
		}
Exemplo n.º 9
0
        public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, NamesPool namesPool)
        {
            if (this.NumInstances >= VonNeumann.MaxVonNeumanns)
            {
                return;
            }
            int val1 = this._outlyingStars.Count <KeyValuePair <StarSystemInfo, Vector3> >();

            if (val1 == 0)
            {
                return;
            }
            Random safeRandom = App.GetSafeRandom();
            int    val2       = 5;
            float  num1       = 5f;
            KeyValuePair <StarSystemInfo, Vector3> outlyingStar = this._outlyingStars[safeRandom.Next(Math.Min(val1, val2))];

            this._outlyingStars.Remove(outlyingStar);
            Vector3 origin = outlyingStar.Key.Origin + Vector3.Normalize(outlyingStar.Value) * num1;

            App.Log.Trace(string.Format("Found von neumann homeworld target - Picked System = {0}   Target Coords = {1}", (object)outlyingStar.Key.Name, (object)origin), "game");
            StellarClass stellarClass = StarHelper.ChooseStellarClass(safeRandom);

            this.HomeWorldSystemId = gamedb.InsertStarSystem(new int?(), namesPool.GetSystemName(), new int?(), stellarClass.ToString(), origin, false, true, new int?());
            gamedb.GetStarSystemInfo(this.HomeWorldSystemId);
            int         num2          = 5;
            float       starOrbitStep = StarSystemVars.Instance.StarOrbitStep;
            float       num3          = StarHelper.CalcRadius(stellarClass.Size) + (float)num2 * ((float)num2 * 0.1f * starOrbitStep);
            float       x             = Ellipse.CalcSemiMinorAxis(num3, 0.0f);
            OrbitalPath path          = new OrbitalPath();

            path.Scale             = new Vector2(x, num3);
            path.InitialAngle      = 0.0f;
            this.HomeWorldPlanetId = gamedb.InsertPlanet(new int?(), this.HomeWorldSystemId, path, "VonNeumonia", "normal", new int?(), 0.0f, 0, 0, 5f);
            PlanetInfo planetInfo = gamedb.GetPlanetInfo(this.HomeWorldPlanetId);

            path              = new OrbitalPath();
            path.Scale        = new Vector2(15f, 15f);
            path.Rotation     = new Vector3(0.0f, 0.0f, 0.0f);
            path.DeltaAngle   = 10f;
            path.InitialAngle = 10f;
            VonNeumannInfo vi = new VonNeumannInfo()
            {
                SystemId             = this.HomeWorldSystemId,
                OrbitalId            = this.HomeWorldPlanetId,
                Resources            = assetdb.GlobalVonNeumannData.StartingResources,
                ConstructionProgress = 0
            };
            float radius = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);

            vi.FleetId = new int?(gamedb.InsertFleet(this.PlayerId, 0, vi.SystemId, vi.SystemId, "Von Neumann NeoBerserker", FleetType.FL_NORMAL));
            float  num4    = radius + 2000f;
            float  num5    = 1000f;
            Matrix matrix1 = gamedb.GetOrbitalTransform(this.HomeWorldPlanetId);

            matrix1 = Matrix.CreateWorld(matrix1.Position, Vector3.Normalize(matrix1.Position), Vector3.UnitY);
            Matrix matrix2 = matrix1;

            matrix2.Position = matrix2.Position + matrix2.Forward * num4 - matrix2.Right * num5;
            for (int index = 0; index < 3; ++index)
            {
                int shipID = gamedb.InsertShip(vi.FleetId.Value, VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.NeoBerserker].DesignId, null, (ShipParams)0, new int?(), 0);
                gamedb.UpdateShipSystemPosition(shipID, new Matrix?(matrix2));
                matrix2.Position += matrix2.Right * num5;
            }
            Random random     = new Random();
            float  radians1   = (float)((random.CoinToss(0.5) ? -1.0 : 1.0) * 0.785398185253143);
            float  radians2   = random.NextInclusive(0.0f, 6.283185f);
            Matrix rotationY1 = Matrix.CreateRotationY(radians1);
            Matrix rotationY2 = Matrix.CreateRotationY(radians2);
            Matrix world      = Matrix.CreateWorld(rotationY1.Forward * (matrix1.Position.Length * 0.75f), rotationY2.Forward, Vector3.UnitY);

            VonNeumann.VonNeumannShipDesigns index1 = (VonNeumann.VonNeumannShipDesigns)random.NextInclusive(21, 23);
            int shipID1 = gamedb.InsertShip(vi.FleetId.Value, VonNeumann.StaticShipDesigns[index1].DesignId, null, (ShipParams)0, new int?(), 0);

            gamedb.UpdateShipSystemPosition(shipID1, new Matrix?(world));
            world.Position -= world.Right * 1000f;
            int shipID2 = gamedb.InsertShip(vi.FleetId.Value, VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.Moon].DesignId, null, (ShipParams)0, new int?(), 0);

            gamedb.UpdateShipSystemPosition(shipID2, new Matrix?(world));
            world = Matrix.CreateWorld(world.Position + world.Right * 1000f * 2f, -world.Forward, Vector3.UnitY);
            int shipID3 = gamedb.InsertShip(vi.FleetId.Value, VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.Moon].DesignId, null, (ShipParams)0, new int?(), 0);

            gamedb.UpdateShipSystemPosition(shipID3, new Matrix?(world));
            gamedb.InsertVonNeumannInfo(vi);
            ++this.NumInstances;
        }