public StellarBody.Params GetStellarBodyParams( string iconSpriteName, Vector3 position, float radius, int orbitalId, int colonyPlayerId, string type, float hazard, float maxHazard, string faction, float biosphere, double population, int?typeVariant, Kerberos.Sots.Strategy.InhabitedPlanet.ColonyStage colonyStage, SystemColonyType colonyType) { try { XmlElement[] hazardPointBrackets = this.GetHazardPointBrackets(type, typeVariant, hazard, orbitalId); float num1 = float.Parse(hazardPointBrackets[1].GetAttribute("value")); float num2 = float.Parse(hazardPointBrackets[0].GetAttribute("value")); XmlElement atmo1 = this.GetAtmo(hazardPointBrackets[0].GetAttribute("atmo")); XmlElement atmo2 = this.GetAtmo(hazardPointBrackets[1].GetAttribute("atmo")); XmlElement heightGen1 = this.GetHeightGen(hazardPointBrackets[0].GetAttribute("heightgen")); XmlElement heightGen2 = this.GetHeightGen(hazardPointBrackets[1].GetAttribute("heightgen")); XmlElement faction1 = this.GetFaction(faction); Vector2 vector2 = faction1 != null?Vector2.Parse(faction1.GetAttribute("cityaltrange")) : Vector2.Zero; float t = 0.0f; if ((double)num1 - (double)num2 >= 1.40129846432482E-45) { t = ((float)(((double)hazard - (double)num2) / ((double)num1 - (double)num2))).Saturate(); } StellarBody.Params @params = new StellarBody.Params(); @params.Civilians = new StellarBody.PlanetCivilianData[0]; @params.IconSpriteName = iconSpriteName; @params.ColonyPlayerID = colonyPlayerId; @params.AtmoThickness = ScalarExtensions.Lerp(float.Parse(atmo1.GetAttribute("thick")), float.Parse(atmo2.GetAttribute("thick")), t); @params.AtmoKm = ScalarExtensions.Lerp(float.Parse(atmo1.GetAttribute("km")), float.Parse(atmo2.GetAttribute("km")), t); @params.AtmoKr = ScalarExtensions.Lerp(float.Parse(atmo1.GetAttribute("kr")), float.Parse(atmo2.GetAttribute("kr")), t); @params.AtmoScatterWaveLengths = Vector3.Lerp(Vector3.Parse(atmo1.GetAttribute("filter")), Vector3.Parse(atmo2.GetAttribute("filter")), t); @params.AtmoScaleDepth = ScalarExtensions.Lerp(float.Parse(atmo1.GetAttribute("scaledepth")), float.Parse(atmo2.GetAttribute("scaledepth")), t); @params.CloudDiffuseTexture = atmo1.GetAttribute("clouddiffuse"); @params.CloudSpecularTexture = atmo1.GetAttribute("cloudspecular"); @params.CloudOpacity = ScalarExtensions.Lerp(float.Parse(atmo1.GetAttribute("cloudcover")), float.Parse(atmo2.GetAttribute("cloudcover")), t); @params.CloudDiffuseColor = Vector3.Lerp(Vector3.Parse(atmo1.GetAttribute("clouddiffusecolor")), Vector3.Parse(atmo2.GetAttribute("clouddiffusecolor")), t); @params.CloudSpecularColor = Vector3.Lerp(Vector3.Parse(atmo1.GetAttribute("cloudspecularcolor")), Vector3.Parse(atmo2.GetAttribute("cloudspecularcolor")), t); @params.CityEmissiveTexture = faction1.GetAttribute("cityemissive"); @params.CitySprawl = (float)(population / 1000000000.0); @params.HeightGradient1Texture = hazardPointBrackets[0].GetAttribute("heightgrad"); @params.HeightGradient2Texture = hazardPointBrackets[1].GetAttribute("heightgrad"); @params.HeightGradient2Blend = t; @params.HeightGradient3Texture = faction1.GetAttribute("idealgrad"); @params.HeightGradient3Blend = 1f - (hazard / maxHazard).Saturate(); @params.MaxCityAltitude = vector2.Y; @params.MinCityAltitude = vector2.X; @params.WaterSpecularColor = Vector3.Lerp(Vector3.Parse(hazardPointBrackets[0].GetAttribute("waterspec")), Vector3.Parse(hazardPointBrackets[1].GetAttribute("waterspec")), t); @params.MaxLandHeight = ScalarExtensions.Lerp(float.Parse(hazardPointBrackets[0].GetAttribute("maxlandalt")), float.Parse(hazardPointBrackets[1].GetAttribute("maxlandalt")), t); @params.MaxWaterDepth = ScalarExtensions.Lerp(float.Parse(hazardPointBrackets[0].GetAttribute("maxseadepth")), float.Parse(hazardPointBrackets[1].GetAttribute("maxseadepth")), t); @params.WaterLevel = ScalarExtensions.Lerp(float.Parse(hazardPointBrackets[0].GetAttribute("sealevel")), float.Parse(hazardPointBrackets[1].GetAttribute("sealevel")), t); float num3 = ScalarExtensions.Lerp(float.Parse(hazardPointBrackets[0].GetAttribute("bumpiness")), float.Parse(hazardPointBrackets[1].GetAttribute("bumpiness")), t); @params.Position = position; @params.Radius = radius; @params.RandomSeed = orbitalId; @params.UseHeightMap = true; @params.TextureSize = 512; @params.BodyType = type; @params.ColonyStage = colonyStage; @params.ColonyType = colonyType; string attribute1 = heightGen1.GetAttribute(nameof(type)); string attribute2 = heightGen2.GetAttribute(nameof(type)); if (attribute1 == "planecuts") { StellarBody.HGPlaneCutsParams hgPlaneCutsParams = new StellarBody.HGPlaneCutsParams(); hgPlaneCutsParams.Bumpiness = num3; if (attribute2 == attribute1) { hgPlaneCutsParams.BaseHeight = ScalarExtensions.Lerp(float.Parse(heightGen1.GetAttribute("baseheight")), float.Parse(heightGen2.GetAttribute("baseheight")), t); hgPlaneCutsParams.Iterations = (int)ScalarExtensions.Lerp((float)int.Parse(heightGen1.GetAttribute("iterations")), (float)int.Parse(heightGen2.GetAttribute("iterations")), t); hgPlaneCutsParams.Shift = ScalarExtensions.Lerp(float.Parse(heightGen1.GetAttribute("shift")), float.Parse(heightGen2.GetAttribute("shift")), t); } else { hgPlaneCutsParams.BaseHeight = float.Parse(heightGen1.GetAttribute("baseheight")); hgPlaneCutsParams.Iterations = int.Parse(heightGen1.GetAttribute("iterations")); hgPlaneCutsParams.Shift = float.Parse(heightGen1.GetAttribute("shift")); } @params.HeightGen = (StellarBody.HeightGenParams)hgPlaneCutsParams; } else if (attribute1 == "blend") { StellarBody.HGBlendParams hgBlendParams = new StellarBody.HGBlendParams(); hgBlendParams.Bumpiness = num3; hgBlendParams.Layer1Texture = heightGen1.GetAttribute("base"); if (attribute2 == attribute1) { hgBlendParams.Layer2Texture = heightGen2.GetAttribute("base"); hgBlendParams.Layer2Amount = t; } else { hgBlendParams.Layer2Texture = hgBlendParams.Layer1Texture; hgBlendParams.Layer2Amount = 0.0f; } @params.HeightGen = (StellarBody.HeightGenParams)hgBlendParams; } return(@params); } catch (Exception ex) { App.Log.Warn(string.Format("Parse error resolving planet display rules (type={0}, will use defaults instead):\n" + ex.ToString(), (object)(type ?? "null")), "data"); return(StellarBody.Params.Default); } }
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); } } } }