コード例 #1
0
        private void PopulateSystemList(bool SelectFirst = false)
        {
            List <StarSystemInfo> list = this._game.GameDatabase.GetVisibleStarSystemInfos(this._app.LocalPlayer.ID).Where <StarSystemInfo>((Func <StarSystemInfo, bool>)(x => this._game.GameDatabase.IsSurveyed(this._game.LocalPlayer.ID, x.ID))).ToList <StarSystemInfo>();

            this.SyncedSystems = list;
            foreach (StarSystemInfo starSystemInfo in list)
            {
                this._game.UI.AddItem(this.LeftContentList, "", starSystemInfo.ID, "", "TinySystemCard_Toggle");
                string itemGlobalId = this._game.UI.GetItemGlobalID(this.LeftContentList, "", starSystemInfo.ID, "");
                this._systemcardpanels.Add(starSystemInfo.ID, itemGlobalId);
                this._checkedsystems.Add(starSystemInfo.ID, false);
                this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, this.SystemButton), "id", this.SystemButton + "|" + (object)starSystemInfo.ID);
                this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, this.ToggleButton), "id", this.ToggleButton + "|" + (object)starSystemInfo.ID);
                string globalId1 = this._game.UI.GetGlobalID(this._game.UI.Path(itemGlobalId, "unselected"));
                string globalId2 = this._game.UI.GetGlobalID(this._game.UI.Path(itemGlobalId, "selected"));
                this._game.UI.GetGlobalID(this._game.UI.Path(itemGlobalId, "contentselected"));
                this.SystemSelectedPanels.Add(starSystemInfo.ID, globalId1);
                this.SystemUnselectedPanels.Add(starSystemInfo.ID, globalId2);
                this.SystemContentSelectedPanels.Add(starSystemInfo.ID, globalId2);
                this._game.UI.SetText(this._game.UI.Path(itemGlobalId, "itemName"), starSystemInfo.Name);
                Vector4 vector4 = StarHelper.CalcModelColor(new StellarClass(starSystemInfo.StellarClass));
                this._game.UI.SetPropertyColor(this._game.UI.Path(itemGlobalId, "colorGradient"), "color", new Vector3(vector4.X, vector4.Y, vector4.Z) * (float)byte.MaxValue);
            }
            if (!SelectFirst || !list.Any <StarSystemInfo>())
            {
                return;
            }
            this.SelectSystem(list.First <StarSystemInfo>().ID);
        }
コード例 #2
0
ファイル: StarMapLobby.cs プロジェクト: zerk-js/SOTSII-SOS
        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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: SystemWidget.cs プロジェクト: zerk-js/SOTSII-SOS
        public void Sync(int systemID)
        {
            StarSystemInfo starSystemInfo = this.App.GameDatabase.GetStarSystemInfo(systemID);

            if (starSystemInfo == (StarSystemInfo)null)
            {
                return;
            }
            this._systemID = systemID;
            this.CacheStar(starSystemInfo);
            StarSystemUI.SyncStarDetailsControl(this.App.Game, this._rootPanel, systemID);
            StarSystemUI.SyncStarDetailsStations(this.App.Game, this._rootPanel, systemID, this.App.LocalPlayer.ID);
            Vector4 vector4 = StarHelper.CalcModelColor(new StellarClass(starSystemInfo.StellarClass));

            this.App.UI.SetPropertyColorNormalized(this.App.UI.Path(this._rootPanel, "colorGradient"), "color", vector4.X, vector4.Y, vector4.Z, 0.5f);
            this._initialized = false;
        }
コード例 #5
0
        internal static void GenerateTestSystem(SolarSystemSettings solarSystemSettings)
        {
            StarHelper.CreateAndInitialiseSystemStar(ScaleHelper.Millions(1), StarHelper.BasicSunColor());

            string planetShader = "flatshaded";

            Planet earth = new Planet("earth", new Vector3d(ScaleHelper.Millions(20), 0, 0),
                                      NoiseGenerator.FastPlanet(6000),
                                      EffectLoader.LoadSM5Effect("AtmosphericScatteringGround").Clone(),
                                      6000, Color.DarkSeaGreen.ChangeTone(-100), Color.SaddleBrown, Color.SaddleBrown.ChangeTone(-10), 0.000001f);

            earth.Orbit(Vector3d.Zero, ScaleHelper.Millions(20), ScaleHelper.Millionths(0.1f));
            earth.AddAtmosphere();
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(earth);


            Planet moon = new Planet("moon", new Vector3d(ScaleHelper.Millions(20) + 20000, 0, 0),
                                     NoiseGenerator.Voronoi(0.02f),
                                     EffectLoader.LoadSM5Effect(planetShader).Clone(),
                                     2000, Color.DarkGray.ChangeTone(10), Color.DarkGray, Color.DarkGray.ChangeTone(-10));

            moon.Orbit(earth, 20000, ScaleHelper.Millionths(50f));
            moon.orbitAngle = RandomHelper.GetRandomeAngle();
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(moon);


            Planet moon2 = new Planet("moon2", new Vector3d(ScaleHelper.Millions(20) + 40000, 0, 0),
                                      NoiseGenerator.RidgedMultiFractal(0.02f),
                                      EffectLoader.LoadSM5Effect(planetShader).Clone(),
                                      1000, Color.SandyBrown.ChangeTone(-80), Color.SandyBrown.ChangeTone(-90), Color.SandyBrown.ChangeTone(-100));

            moon2.Orbit(earth, 40000, ScaleHelper.Millionths(50f));
            moon2.orbitAngle = RandomHelper.GetRandomeAngle();
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(moon2);

            Planet moon3 = new Planet("moon3", new Vector3d(ScaleHelper.Millions(20) + 45000, 0, 0),
                                      NoiseGenerator.RidgedMultiFractal(0.02f),
                                      EffectLoader.LoadSM5Effect(planetShader).Clone(),
                                      500, Color.DarkSlateGray.ChangeTone(10), Color.DarkSlateGray, Color.DarkSlateGray.ChangeTone(-10));

            moon3.Orbit(moon2, 5000, ScaleHelper.Millionths(50f));
            moon3.orbitAngle = RandomHelper.GetRandomeAngle();
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(moon3);
        }
コード例 #6
0
ファイル: StarSystemMapUI.cs プロジェクト: zerk-js/SOTSII-SOS
        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);
                    }
                }
            }
        }
コード例 #7
0
ファイル: StarSystemMapUI.cs プロジェクト: zerk-js/SOTSII-SOS
        private static void ResetMap(App game, string mapPanelId)
        {
            float num = Orbit.CalcOrbitRadius(StarHelper.CalcRadius(StellarSize.Ia), StarSystemVars.Instance.StarOrbitStep, 12) * 1.1f;

            game.UI.Send((object)nameof(ResetMap), (object)mapPanelId, (object)num);
        }
コード例 #8
0
ファイル: VonNeumann.cs プロジェクト: zerk-js/SOTSII-SOS
        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;
        }