protected override void OnCommitMission() { if (this._selectedPlanetToEvacuate == 0) { double num1 = 0.0; foreach (int num2 in this.App.GameDatabase.GetStarSystemPlanets(this.TargetSystem).ToList <int>()) { ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(num2); if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID) { double civilianPopulation = this.App.GameDatabase.GetCivilianPopulation(num2, 0, false); if (civilianPopulation > num1) { this._selectedPlanetToEvacuate = num2; num1 = civilianPopulation; } } } } if (this._selectedPlanetToEvacuate == 0) { return; } Kerberos.Sots.StarFleet.StarFleet.SetEvacuationMission(this.App.Game, this.SelectedFleet, this.TargetSystem, this._useDirectRoute, this._selectedPlanetToEvacuate, this.GetDesignsToBuild()); AdmiralInfo admiralInfo = this.App.GameDatabase.GetAdmiralInfo(this.App.GameDatabase.GetFleetInfo(this._selectedFleet).AdmiralID); if (admiralInfo != null) { this.App.PostRequestSpeech(string.Format("STRAT_002-01_{0}_{1}EvacuationMissionConfirmation", (object)this.App.GameDatabase.GetFactionName(this.App.GameDatabase.GetPlayerFactionID(this.App.LocalPlayer.ID)), (object)admiralInfo.GetAdmiralSoundCueContext(this.App.AssetDatabase)), 50, 120, 0.0f); } FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), this.GetMissionTargetPlanets()); this.App.GetGameState <StarMapState>().RefreshStarmap(StarMapState.StarMapRefreshType.REFRESH_NORMAL); }
public static void UpdateTradeSliderNotchInfo(App App, int ColonyID, int value) { ColonyInfo colonyInfo = App.GameDatabase.GetColonyInfo(ColonyID); if (value == -1) { // Zerk: faster to just run delete query //if (App.GameDatabase.GetSliderNotchSettingInfoForColony(colonyInfo.PlayerID, colonyInfo.ID, UISlidertype.TradeSlider) == null) //return; App.GameDatabase.DeleteUISliderNotchSettingForColony(colonyInfo.PlayerID, colonyInfo.ID, UISlidertype.TradeSlider); } else { List <double> exportsForColony = App.Game.GetTradeRatesForWholeExportsForColony(colonyInfo.ID); UISliderNotchInfo settingInfoForColony = App.GameDatabase.GetSliderNotchSettingInfoForColony(colonyInfo.PlayerID, colonyInfo.ID, UISlidertype.TradeSlider); //App.Log.Trace(string.Format("Trade slider notched: Colony: {0}, Value: {1}, Notch: {2}", App.GameDatabase.GetColonyName(colonyInfo.OrbitalObjectID), value, exportsForColony.IndexOf(exportsForColony.FirstOrDefault(v => (int)Math.Ceiling(v * 100.0) == value))), "zerk"); double num = exportsForColony.First(v => (int)Math.Ceiling(v * 100.0) == value); if (settingInfoForColony != null) { settingInfoForColony.SliderValue = (double)exportsForColony.IndexOf(num); App.GameDatabase.UpdateUISliderNotchSetting(settingInfoForColony); return; } App.GameDatabase.InsertUISliderNotchSetting(App.LocalPlayer.ID, UISlidertype.TradeSlider, (double)exportsForColony.IndexOf(num), colonyInfo.ID); } }
public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int?targetSystem = null) { Random safeRandom = App.GetSafeRandom(); if (!targetSystem.HasValue) { List <ColonyInfo> list = gamedb.GetColonyInfos().ToList <ColonyInfo>(); ColonyInfo colonyInfo = safeRandom.Choose <ColonyInfo>((IList <ColonyInfo>)list); targetSystem = new int?(gamedb.GetOrbitalObjectInfo(colonyInfo.OrbitalObjectID).StarSystemID); } gamedb.InsertIncomingGM(targetSystem.Value, EasterEgg.GM_COMET, gamedb.GetTurnCount() + 1); foreach (PlayerInfo playerInfo in gamedb.GetStandardPlayerInfos().ToList <PlayerInfo>()) { if (gamedb.GetStratModifier <int>(StratModifiers.GrandMenaceWarningTime, playerInfo.ID) > 0) { gamedb.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INCOMING_COMET, EventMessage = TurnEventMessage.EM_INCOMING_COMET, PlayerID = playerInfo.ID, TurnNumber = gamedb.GetTurnCount() }); } } }
public static void SetOutputRateNew( App game, int orbitalId, string panelName, string valueStr) { PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(orbitalId); ColonyInfo colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(orbitalId); Colony.OutputRate rate = Colony.OutputRate.Trade; if (panelName.Contains("partInfraSlider")) { rate = Colony.OutputRate.Infra; } else if (panelName.Contains("partTerraSlider")) { rate = Colony.OutputRate.Terra; } else if (panelName.Contains("partShipConSlider")) { rate = Colony.OutputRate.ShipCon; } else if (panelName.Contains("partOverDevelopment")) { rate = Colony.OutputRate.OverDev; } float outputRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(valueStr)); Colony.SetOutputRate(game.GameDatabase, game.AssetDatabase, ref colonyInfoForPlanet, planetInfo, rate, outputRate); game.GameDatabase.UpdateColony(colonyInfoForPlanet); }
public static Matrix GetSpawnTransform(App app, int systemId) { bool flag = false; float num1 = 0.0f; float num2 = 0.0f; OrbitalObjectInfo orbitalObjectInfo1 = (OrbitalObjectInfo)null; Vector3 vector3_1 = Vector3.Zero; Vector3? nullable = new Vector3?(); foreach (OrbitalObjectInfo orbitalObjectInfo2 in app.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId)) { ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo2.ID); if (!flag || colonyInfoForPlanet != null) { PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo2.ID); float num3 = 1000f; if (planetInfo != null) { num3 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size); } Vector3 position = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position; float num4 = position.Length + num3; if ((double)num4 > (double)num1 || !flag && colonyInfoForPlanet != null) { orbitalObjectInfo1 = orbitalObjectInfo2; num1 = num4; flag = colonyInfoForPlanet != null; vector3_1 = position; num2 = num3 + 10000f; nullable = !orbitalObjectInfo2.ParentID.HasValue || orbitalObjectInfo2.ParentID.Value == 0 ? new Vector3?() : new Vector3?(app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position); if (flag) { break; } } } } if (orbitalObjectInfo1 == null) { return(Matrix.Identity); } Vector3 vector3_2 = Vector3.Zero; if (nullable.HasValue) { Matrix world = Matrix.CreateWorld(Vector3.Zero, Vector3.Normalize(nullable.Value), Vector3.UnitY); Vector3 v1 = Vector3.Normalize(vector3_1 - nullable.Value); vector3_2 = world.Right * num2; if ((double)Vector3.Dot(world.Right, v1) < 0.0) { vector3_2 *= -1f; } } Vector3 vector3_3 = -vector3_1; double num5 = (double)vector3_3.Normalize(); Vector3 position1 = vector3_1 - vector3_3 * num2 + vector3_2; return(Matrix.CreateWorld(position1, Vector3.Normalize(vector3_1 - position1), Vector3.UnitY)); }
protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams) { if (msgType == "list_sel_changed") { if (panelName == "filterDropdown") { this._currentFilterMode = (PlanetManagerDialog.PlanetFilterMode) int.Parse(msgParams[0]); this.SyncPlanetList(); } else if (panelName == "orderDropdown") { this._currentOrderMode = (PlanetManagerDialog.PlanetOrderMode) int.Parse(msgParams[0]); if (this._selectedSystem != (StarSystemInfo)null) { this.SetSyncedSystem(this._selectedSystem); } } else if (panelName == "sys_list_left") { StarSystemInfo starSystemInfo = this.App.GameDatabase.GetStarSystemInfo(int.Parse(msgParams[0])); if (starSystemInfo != (StarSystemInfo)null) { this.SetSyncedSystem(starSystemInfo); } } } if (msgType == "button_clicked") { if (panelName == PlanetManagerDialog.UIExitButton) { this.App.UI.CloseDialog((Dialog)this, true); } else if (panelName.StartsWith("btnColoninzePlanet")) { string[] strArray = panelName.Split('|'); int targetSystem = int.Parse(strArray[1]); int targetPlanet = int.Parse(strArray[2]); if (this.App.CurrentState.GetType() == typeof(StarMapState)) { ((StarMapState)this.App.CurrentState).ShowColonizePlanetOverlay(targetSystem, targetPlanet); } this.App.UI.CloseDialog((Dialog)this, true); } } if (!(msgType == "mouse_enter") || !panelName.StartsWith("MoraleRow")) { return; } int orbitalObjectID = int.Parse(panelName.Split('|')[0]); int x = int.Parse(msgParams[0]); int y = int.Parse(msgParams[1]); ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(orbitalObjectID); if (colonyInfoForPlanet == null || this.App.LocalPlayer.ID != colonyInfoForPlanet.PlayerID) { return; } StarSystemUI.ShowMoraleEventToolTip(this.App.Game, colonyInfoForPlanet.ID, x, y); }
public ColonySelfSufficientDialog(App game, int planetId, int missionId) : base(game, "dialogColonySelfSufficientEvent") { this.orbitalObject = game.GameDatabase.GetOrbitalObjectInfo(planetId); this.planet = game.GameDatabase.GetPlanetInfo(planetId); this.colony = game.GameDatabase.GetColonyInfoForPlanet(planetId); this.mission = game.GameDatabase.GetMissionInfo(missionId); }
public void Sync(int planetID, bool PopulationSliders = false, bool ShowColonizebuttons = false) { StarSystemUI.ClearColonyDetailsControl(this.App.Game, this._rootPanel); PlanetInfo planetInfo = this.App.GameDatabase.GetPlanetInfo(planetID); if (planetInfo == null) { return; } this._planetID = planetID; this.CachePlanet(planetInfo); StarSystemUI.SyncPlanetDetailsControlNew(this.App.Game, this._rootPanel, planetID); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "systemName"), "text", this.App.GameDatabase.GetStarSystemInfo(this.App.GameDatabase.GetOrbitalObjectInfo(planetInfo.ID).StarSystemID).Name); ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(planetID); this.App.UI.SetVisible(this.App.UI.Path(this._rootPanel, "rebellionActive"), (colonyInfoForPlanet != null ? (colonyInfoForPlanet.PlayerID != this.App.LocalPlayer.ID ? 0 : (colonyInfoForPlanet.RebellionType != RebellionType.None ? 1 : 0)) : 0) != 0); int num1 = 0; if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID) { this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partOverharvestSlider"), "id", "__partOverharvestSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString()); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partTradeSlider"), "id", "__partTradeSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString()); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partTerraSlider"), "id", "__partTerraSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString()); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partInfraSlider"), "id", "__partInfraSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString()); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partShipConSlider"), "id", "__partShipConSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString()); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partCivSlider"), "id", "__partCivSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString()); StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfoForPlanet.ID, this._widgetID, ""); this.App.UI.SetPropertyBool(this._rootPanel, "expanded", true); if (!PopulationSliders) { return; } foreach (ColonyFactionInfo faction1 in colonyInfoForPlanet.Factions) { this.App.UI.AddItem(this.App.UI.Path(this._rootPanel, "MoraleRow"), "", faction1.FactionID, "", "popItem"); string itemGlobalId = this.App.UI.GetItemGlobalID(this.App.UI.Path(this._rootPanel, "MoraleRow"), "", faction1.FactionID, ""); this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "partPopSlider"), "id", "__partPopSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString() + "|" + (object)faction1.FactionID); Faction faction2 = this.App.AssetDatabase.GetFaction(faction1.FactionID); this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "factionicon"), "sprite", "logo_" + faction2.Name.ToLower()); this.App.UI.SetSliderValue(this.App.UI.Path(itemGlobalId, "__partPopSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString() + "|" + (object)faction1.FactionID), (int)((double)faction1.CivPopWeight * 100.0)); this.App.UI.SetText(this.App.UI.Path(itemGlobalId, "gameMorale_human"), faction1.Morale.ToString()); double num2 = (colonyInfoForPlanet.CurrentStage == Kerberos.Sots.Data.ColonyStage.GemWorld ? Colony.GetMaxCivilianPop(this.App.GameDatabase, planetInfo) * (double)this.App.AssetDatabase.GemWorldCivMaxBonus : Colony.GetMaxCivilianPop(this.App.GameDatabase, planetInfo)) * (double)colonyInfoForPlanet.CivilianWeight * (double)faction1.CivPopWeight * (double)this.App.AssetDatabase.GetFaction(this.App.GameDatabase.GetPlayerFactionID(colonyInfoForPlanet.PlayerID)).GetImmigrationPopBonusValueForFaction(this.App.AssetDatabase.GetFaction(faction1.FactionID)); this.App.UI.SetText(this.App.UI.Path(itemGlobalId, "popRatio"), (faction1.CivilianPop / 1000000.0).ToString("0.0") + "M / " + (num2 / 1000000.0).ToString("0.0") + "M"); ++num1; } this.App.UI.SetShape(this._rootPanel, 0, 0, 360, 90 + 22 * (((IEnumerable <ColonyFactionInfo>)colonyInfoForPlanet.Factions).Count <ColonyFactionInfo>() > 1 ? ((IEnumerable <ColonyFactionInfo>)colonyInfoForPlanet.Factions).Count <ColonyFactionInfo>() : 0)); } else { if (colonyInfoForPlanet != null || !ShowColonizebuttons || !(this.App.CurrentState.GetType() == typeof(StarMapState))) { return; } StarSystemInfo starSystemInfo = this.App.GameDatabase.GetStarSystemInfo(this.App.GameDatabase.GetOrbitalObjectInfo(planetInfo.ID).StarSystemID); this.App.UI.SetVisible(this.App.UI.Path(this._rootPanel, "btnColoninzePlanet"), (Kerberos.Sots.StarFleet.StarFleet.CollectAvailableFleets(this.App.Game, this.App.LocalPlayer.ID, starSystemInfo.ID, MissionType.COLONIZATION, false).Any <FleetInfo>() && StarSystemDetailsUI.CollectPlanetListItemsForColonizeMission(this.App, starSystemInfo.ID, this.App.LocalPlayer.ID).Contains <int>(planetID) ? 1 : 0) != 0); this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "btnColoninzePlanet"), "id", "btnColoninzePlanet|" + starSystemInfo.ID.ToString() + "|" + planetInfo.ID.ToString()); } }
public StellarBody.Params GetStellarBodyParams(GameSession game, int orbitalId) { OrbitalObjectInfo orbitalObjectInfo = game.GameDatabase.GetOrbitalObjectInfo(orbitalId); ColonyInfo colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(orbitalId); PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(orbitalId); SystemColonyType colonyType = SystemColonyType.Normal; int num; double population; PlayerInfo povPlayerInfo; if (colonyInfoForPlanet != null) { num = colonyInfoForPlanet.PlayerID; population = colonyInfoForPlanet.ImperialPop; povPlayerInfo = game.GameDatabase.GetPlayerInfo(num); if (orbitalObjectInfo != null && povPlayerInfo != null) { HomeworldInfo homeworldInfo = game.GameDatabase.GetHomeworlds().FirstOrDefault <HomeworldInfo>((Func <HomeworldInfo, bool>)(x => x.SystemID == orbitalObjectInfo.StarSystemID)); if (homeworldInfo != null && homeworldInfo.SystemID != 0 && homeworldInfo.PlayerID == povPlayerInfo.ID) { colonyType = SystemColonyType.Home; } else if (game.GameDatabase.GetProvinceInfos().Any <ProvinceInfo>((Func <ProvinceInfo, bool>)(x => { if (x.CapitalSystemID != orbitalObjectInfo.StarSystemID || x.PlayerID != povPlayerInfo.ID) { return(false); } int capitalSystemId = x.CapitalSystemID; int?homeworld = povPlayerInfo.Homeworld; if (capitalSystemId == homeworld.GetValueOrDefault()) { return(!homeworld.HasValue); } return(true); }))) { colonyType = SystemColonyType.Capital; } } } else { num = 0; population = 0.0; povPlayerInfo = game.GameDatabase.GetPlayerInfo(game.LocalPlayer.ID); } FactionInfo factionInfo = game.GameDatabase.GetFactionInfo(povPlayerInfo.FactionID); float hazard = Math.Abs(planetInfo.Suitability - factionInfo.IdealSuitability); float stratModifier = (float)game.App.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, povPlayerInfo.ID); float radius = StarSystemVars.Instance.SizeToRadius(planetInfo.Size); Matrix transform = orbitalObjectInfo.OrbitalPath.GetTransform(0.0); return(this.GetStellarBodyParams(StarSystemMapUI.SelectIcon(planetInfo, game.GameDatabase.GetStarSystemOrbitalObjectInfos(orbitalObjectInfo.StarSystemID), (IEnumerable <PlanetInfo>)game.GameDatabase.GetStarSystemPlanetInfos(orbitalObjectInfo.StarSystemID)), transform.Position, radius, orbitalId, num, planetInfo.Type, hazard, stratModifier, factionInfo.Name, (float)planetInfo.Biosphere, population, new int?(), Colony.GetColonyStage(game.GameDatabase, num, (double)hazard), colonyType)); }
protected override void OnEnter() { base.OnEnter(); this._crits.Activate(); this._dummies.Activate(); this.App.UI.UnlockUI(); this.App.UI.SetScreen("StationPlacement"); this.App.UI.SetPropertyBool("gameCancelMissionButton", "lockout_button", true); this.App.UI.SetPropertyBool("gameConfirmMissionButton", "lockout_button", true); this.App.UI.SetPropertyBool("gameExitButton", "lockout_button", true); this._piechart = new BudgetPiechart(this.App.UI, "piechart", this.App.AssetDatabase); EmpireBarUI.SyncTitleFrame(this.App); EmpireBarUI.SyncTitleBar(this.App, "gameEmpireBar", this._piechart); this.Camera.DesiredPitch = MathHelper.DegreesToRadians(-40f); this.Camera.DesiredDistance = 80000f; this.Camera.MinPitch = MathHelper.DegreesToRadians(-60f); this.Camera.MaxPitch = MathHelper.DegreesToRadians(-20f); this._manager.Active = true; this._starsystem.SetAutoDrawEnabled(false); bool flag = false; if (this._stationType == StationType.MINING) { int?planetForStation = StarSystem.GetSuitablePlanetForStation(this.App.Game, this.App.LocalPlayer.ID, this._targetSystemID, this._stationType); if (planetForStation.HasValue) { this.SetSelectedObject(planetForStation.Value, ""); flag = true; } } else { foreach (PlanetInfo planetInfo in this.App.GameDatabase.GetPlanetInfosOrbitingStar(this._targetSystemID)) { if (planetInfo != null) { ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID); if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID) { this.SetSelectedObject(planetInfo.ID, ""); flag = true; break; } } } } if (!flag) { this.SetSelectedObject(-1, ""); } StationPlacementState.RefreshFleetAdmiralDetails(this.App, this._selectedFleetID); OverlayConstructionMission.RefreshMissionUI(this.App, this._selectedPlanetID, this._targetSystemID); OverlayConstructionMission.ReRefreshMissionDetails(this.App, this._missionEstimate); this.App.UI.AutoSizeContents("gameMissionDetails"); }
public static Matrix GetSpawnTransform(App app, int systemId, int planetId = 0) { float num1 = 0.0f; float num2 = 5000f; Matrix?nullable = new Matrix?(); if (planetId != 0) { PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(planetId); ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(planetId); if (planetInfo != null && colonyInfoForPlanet != null) { num2 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size) + 15000f; nullable = new Matrix?(app.GameDatabase.GetOrbitalTransform(planetId)); } } if (!nullable.HasValue) { foreach (OrbitalObjectInfo orbitalObjectInfo in app.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId)) { PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo.ID); if (planetInfo != null && app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo.ID) != null) { Matrix orbitalTransform = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo.ID); float lengthSquared = orbitalTransform.Position.LengthSquared; if ((double)lengthSquared > (double)num1) { num1 = lengthSquared; nullable = new Matrix?(orbitalTransform); num2 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size) + 15000f; } } } } if (!nullable.HasValue) { return(Matrix.Identity); } Vector3 position = nullable.Value.Position; double num3 = (double)position.Normalize(); Matrix world = Matrix.CreateWorld(nullable.Value.Position, position, Vector3.UnitY); Vector3 vector3 = Matrix.PolarDeviation(MeteorShower.MSRandom, 80f).Forward *num2; vector3.Y = Math.Max(Math.Min(vector3.Y, 300f), -300f); float num4 = MeteorShower.MSRandom.NextInclusive(-1500f, 1500f); double num5 = (double)vector3.Normalize(); Vector3 forward = -vector3; return(Matrix.CreateWorld(vector3 * (num2 + num4), forward, Vector3.UnitY) * world); }
protected override bool CanConfirmMission() { if (!this.IsValidFleetID(this.SelectedFleet) || Kerberos.Sots.StarFleet.StarFleet.GetNumColonizationShips(this._app.Game, this.SelectedFleet) <= 0) { return(false); } ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(this._selectedPlanetToEvacuate); if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID && this.App.GameDatabase.GetCivilianPopulation(this._selectedPlanetToEvacuate, 0, false) > 0.0) { return(this.IsValidFleetID(this.SelectedFleet)); } return(false); }
public static IEnumerable <int> CollectPlanetListItemsForEvacuateMission( App game, int systemId, int playerId) { List <int> planetIds = game.GameDatabase.GetStarSystemPlanets(systemId).ToList <int>(); foreach (int num in planetIds) { ColonyInfo ci = game.GameDatabase.GetColonyInfoForPlanet(num); if (ci != null && ci.PlayerID == playerId && game.GameDatabase.GetCivilianPopulation(num, 0, false) > 0.0) { yield return(num); } } }
private static bool IsSystemProvinceable(GameSession sim, int SystemId) { if (sim.GameDatabase.GetStarSystemProvinceID(SystemId).HasValue) { return(false); } foreach (int orbitalObjectID in sim.GameDatabase.GetStarSystemOrbitalObjectIDs(SystemId).ToList <int>()) { ColonyInfo colonyInfoForPlanet = sim.GameDatabase.GetColonyInfoForPlanet(orbitalObjectID); if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == sim.LocalPlayer.ID && Colony.IsColonySelfSufficient(sim, colonyInfoForPlanet, sim.GameDatabase.GetPlanetInfo(orbitalObjectID))) { return(true); } } return(false); }
public static Matrix GetSpawnTransform(App app, int systemId) { bool flag = false; float num1 = 0.0f; float num2 = 0.0f; OrbitalObjectInfo orbitalObjectInfo1 = (OrbitalObjectInfo)null; Vector3 vector3 = Vector3.Zero; foreach (OrbitalObjectInfo orbitalObjectInfo2 in app.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId)) { ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo2.ID); if (!flag || colonyInfoForPlanet != null) { PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo2.ID); float num3 = 1000f; if (planetInfo != null) { num3 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size); } Vector3 position = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position; float num4 = position.Length + num3; if ((double)num4 > (double)num1 || !flag && colonyInfoForPlanet != null) { orbitalObjectInfo1 = orbitalObjectInfo2; num1 = num4; flag = colonyInfoForPlanet != null; vector3 = position; num2 = num3 + 10000f; if (flag) { break; } } } } if (orbitalObjectInfo1 == null) { return(Matrix.Identity); } Vector3 forward = -vector3; double num5 = (double)forward.Normalize(); return(Matrix.CreateWorld(vector3 - forward * num2, forward, Vector3.UnitY)); }
public override void Initialize() { StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(this._systemID); ColonyInfo colonyInfo = this._app.GameDatabase.GetColonyInfo(this._colonyID); PlanetInfo planetInfo = this._app.GameDatabase.GetPlanetInfo(colonyInfo.OrbitalObjectID); PlayerInfo playerInfo = this._app.GameDatabase.GetPlayerInfo(colonyInfo.PlayerID); this._playerID = playerInfo.ID; this._planetID = colonyInfo.OrbitalObjectID; this._app.UI.SetPropertyString(this._app.UI.Path(this.ID, "title"), "text", App.Localize("@UI_INDEPENDENT_CIVILIZATION_FOUND_TITLE").ToUpperInvariant()); this._app.UI.SetPropertyString(this._app.UI.Path(this.ID, "faction_name"), "text", playerInfo.Name); this._app.UI.SetPropertyString(this._app.UI.Path(this.ID, "tech_level"), "text", ""); this._app.UI.SetPropertyString(this._app.UI.Path(this.ID, "avatar"), "texture", playerInfo.AvatarAssetPath); this._app.UI.SetPropertyString(this._app.UI.Path(this.ID, "tech_level"), "text", App.Localize("@UI_INDEPENDENT_TECH_" + playerInfo.Name.ToUpper())); StarSystemMapUI.Sync(this._app, this._systemID, this._app.UI.Path(this.ID, "system_map"), true); this._app.UI.SetEnabled(this._app.UI.Path(this.ID, "diploButton"), (Kerberos.Sots.StarFleet.StarFleet.CollectAvailableFleets(this._app.Game, this._app.LocalPlayer.ID, this._systemID, MissionType.CONSTRUCT_STN, true).Any <FleetInfo>() ? 1 : 0) != 0); this._planetWidgets = new List <PlanetWidget>(); this.SetSyncedSystem(starSystemInfo, planetInfo); }
private static Matrix GetSpawnMatrixForGardener( App app, int systemId, OrbitalObjectInfo[] objects) { StarSystemInfo starSystemInfo = app.GameDatabase.GetStarSystemInfo(systemId); if (starSystemInfo == (StarSystemInfo)null || starSystemInfo.IsDeepSpace) { return(Matrix.Identity); } float num1 = 0.0f; float num2 = 5000f; Vector3 vector3_1 = Vector3.Zero; bool flag = false; foreach (OrbitalObjectInfo orbitalObjectInfo in objects) { PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo.ID); if (planetInfo != null) { ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo.ID); Matrix orbitalTransform = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo.ID); float lengthSquared = orbitalTransform.Position.LengthSquared; if ((double)lengthSquared > (double)num1 || !flag && colonyInfoForPlanet != null) { num1 = lengthSquared; vector3_1 = orbitalTransform.Position; num2 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size) + 1500f; flag = colonyInfoForPlanet != null; } } } if ((double)num1 <= 0.0) { return(Matrix.Identity); } Vector3 vector3_2 = Vector3.Normalize(vector3_1); return(Matrix.CreateWorld(vector3_1 + vector3_2 * num2, -vector3_2, Vector3.UnitY)); }
private List <PlanetInfo> FilteredPlanetList(StarSystemInfo system) { List <PlanetInfo> list = this.App.GameDatabase.GetPlanetInfosOrbitingStar(system.ID).ToList <PlanetInfo>(); List <PlanetInfo> planetInfoList = new List <PlanetInfo>(); foreach (PlanetInfo planetInfo in list) { if (this.App.GameDatabase.IsSurveyed(this.App.LocalPlayer.ID, system.ID)) { if (this._currentFilterMode == PlanetManagerState.PlanetFilterMode.AllPlanets) { planetInfoList.Add(planetInfo); } else if (this._currentFilterMode == PlanetManagerState.PlanetFilterMode.SurveyedPlanets) { if (this.App.GameDatabase.GetColonyIntelForPlanet(this.App.LocalPlayer.ID, planetInfo.ID) == null) { planetInfoList.Add(planetInfo); } } else if (this._currentFilterMode == PlanetManagerState.PlanetFilterMode.OwnedPlanets) { ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID); if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID) { planetInfoList.Add(planetInfo); } } else if (this._currentFilterMode == PlanetManagerState.PlanetFilterMode.EnemyPlanets) { AIColonyIntel colonyIntelForPlanet = this.App.GameDatabase.GetColonyIntelForPlanet(this.App.LocalPlayer.ID, planetInfo.ID); if (colonyIntelForPlanet != null && colonyIntelForPlanet.OwningPlayerID != this.App.LocalPlayer.ID) { planetInfoList.Add(planetInfo); } } } } return(planetInfoList); }
protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams) { if (!(msgType == "button_clicked")) { return; } if (panelName == SuperWorldDialog.UIGemWorld) { ColonyInfo colonyInfo = this._app.GameDatabase.GetColonyInfo(this.colonyId); colonyInfo.CurrentStage = ColonyStage.GemWorld; colonyInfo.CivilianWeight /= 2f; this._app.GameDatabase.UpdateColony(colonyInfo); StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(this._app.GameDatabase.GetOrbitalObjectInfo(colonyInfo.OrbitalObjectID).StarSystemID); GameSession.ApplyMoralEvent(this._app, MoralEvent.ME_GEM_WORLD_FORMED, colonyInfo.PlayerID, new int?(colonyInfo.ID), starSystemInfo.ProvinceID, new int?(starSystemInfo.ID)); this._app.GameDatabase.InsertGovernmentAction(colonyInfo.PlayerID, App.Localize("@GA_GEMWORLD"), "GemWorld", 0, 0); this._app.UI.CloseDialog((Dialog)this, true); } else { if (!(panelName == SuperWorldDialog.UIForgeWorld)) { return; } ColonyInfo colonyInfo = this._app.GameDatabase.GetColonyInfo(this.colonyId); PlanetInfo planetInfo = this._app.GameDatabase.GetPlanetInfo(colonyInfo.OrbitalObjectID); colonyInfo.CurrentStage = ColonyStage.ForgeWorld; colonyInfo.CivilianWeight = 1f; planetInfo.Biosphere = 0; this._app.GameDatabase.UpdatePlanet(planetInfo); this._app.GameDatabase.UpdateColony(colonyInfo); StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(this._app.GameDatabase.GetOrbitalObjectInfo(colonyInfo.OrbitalObjectID).StarSystemID); GameSession.ApplyMoralEvent(this._app, MoralEvent.ME_FORGE_WORLD_FORMED, colonyInfo.PlayerID, new int?(colonyInfo.ID), starSystemInfo.ProvinceID, new int?(starSystemInfo.ID)); this._app.GameDatabase.InsertGovernmentAction(colonyInfo.PlayerID, App.Localize("@GA_FORGEWORLD"), "ForgeWorld", 0, 0); this._app.UI.CloseDialog((Dialog)this, true); } }
public void Enter(App app) { this._app = app; if (this._app.GameDatabase == null) { this._app.NewGame(); } app.Game.SetLocalPlayer(app.GetPlayer(1)); this._set = new GameObjectSet(app); this._postLoadedObjects = new List <IGameObject>(); this._set.Add((IGameObject) new Sky(app, SkyUsage.InSystem, new Random().Next())); if (ScriptHost.AllowConsole) { this._input = this._set.Add <CombatInput>(); } this._camera = this._set.Add <OrbitCameraController>(); this._camera.SetAttractMode(true); this._camera.TargetPosition = new Vector3(500000f, 0.0f, 0.0f); this._camera.MinDistance = 1f; this._camera.MaxDistance = 11000f; this._camera.DesiredDistance = 11000f; this._camera.DesiredPitch = MathHelper.DegreesToRadians(-2f); this._camera.DesiredYaw = MathHelper.DegreesToRadians(45f); int systemId = 0; IEnumerable <HomeworldInfo> homeworlds = this._app.GameDatabase.GetHomeworlds(); HomeworldInfo homeworldInfo = homeworlds.FirstOrDefault <HomeworldInfo>((Func <HomeworldInfo, bool>)(x => x.PlayerID == app.LocalPlayer.ID)); if (homeworldInfo != null) { systemId = homeworldInfo.SystemID; } else if (homeworlds.Count <HomeworldInfo>() > 0) { systemId = homeworlds.ElementAt <HomeworldInfo>(new Random().NextInclusive(0, homeworlds.Count <HomeworldInfo>() - 1)).SystemID; } this._starsystem = new StarSystem(this._app, 1f, systemId, new Vector3(0.0f, 0.0f, 0.0f), false, (CombatSensor)null, true, 0, false, true); this._set.Add((IGameObject)this._starsystem); this._starsystem.PostSetProp("InputEnabled", false); this._starsystem.PostSetProp("RenderSuroundingItems", false); Vector3 vector1 = new Vector3(); float num1 = 10000f; IEnumerable <PlanetInfo> infosOrbitingStar = this._app.GameDatabase.GetPlanetInfosOrbitingStar(systemId); bool flag1 = false; foreach (PlanetInfo planetInfo in infosOrbitingStar) { if (planetInfo != null) { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID); if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this._app.LocalPlayer.ID) { vector1 = this._app.GameDatabase.GetOrbitalTransform(planetInfo.ID).Position; num1 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size); flag1 = true; break; } } } if (!flag1) { PlanetInfo[] array = infosOrbitingStar.ToArray <PlanetInfo>(); if (array.Length > 0) { PlanetInfo planetInfo = array[new Random().Next(array.Length)]; vector1 = this._app.GameDatabase.GetOrbitalTransform(planetInfo.ID).Position; num1 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size); } } this._camera.DesiredYaw = -(float)Math.Atan2((double)vector1.Z, (double)vector1.X); this._camera.TargetPosition = vector1; Matrix rotationYpr = Matrix.CreateRotationYPR(this._camera.DesiredYaw, 0.0f, 0.0f); Vector3[] shuffledPlayerColors = Player.GetShuffledPlayerColors(this._rand); foreach (string index in this._players.Keys.ToList <string>()) { this._players[index] = new Player(app, app.Game, new PlayerInfo() { FactionID = app.GameDatabase.GetFactionIdFromName(index), AvatarAssetPath = string.Empty, BadgeAssetPath = app.AssetDatabase.GetRandomBadgeTexture(index, this._rand), PrimaryColor = shuffledPlayerColors[0], SecondaryColor = new Vector3(this._rand.NextSingle(), this._rand.NextSingle(), this._rand.NextSingle()) }, Player.ClientTypes.AI); this._set.Add((IGameObject)this._players[index]); } Vector3 zero = Vector3.Zero; double num2 = (double)Vector3.Cross(vector1, new Vector3(0.0f, 1f, 0.0f)).Normalize(); float num3 = 500f; int num4 = 4; float num5 = num3 * (float)num4; Vector3 vector3_1 = new Vector3(-num5, 0.0f, -num5); Vector3 vector3_2 = vector1 + -rotationYpr.Forward * (num1 + 2000f + num5); List <Vector3> vector3List1 = new List <Vector3>(); for (int index = 0; index < 81; ++index) { int num6 = index % 5; int num7 = index / 5; Vector3 vector3_3 = new Vector3(vector3_1.X + (float)num7 * num3, 0.0f, vector3_1.Z + (float)num6 * num3); vector3_3 += vector3_2; vector3List1.Add(vector3_3); } List <Vector3> vector3List2 = new List <Vector3>(); foreach (Vector3 pos in vector3List1) { if (this.PositionCollidesWithObject(pos, 400f)) { vector3List2.Add(pos); } } foreach (Vector3 vector3_3 in vector3List2) { vector3List1.Remove(vector3_3); } int num8 = this._rand.NextInclusive(6, 12); List <int> intList = new List <int>(); for (int index1 = 0; index1 < num8; ++index1) { int index2 = 0; bool flag2 = true; for (int index3 = 0; flag2 && index3 < vector3List1.Count; ++index3) { index2 = this._rand.NextInclusive(0, Math.Max(vector3List1.Count - 1, 0)); flag2 = intList.Contains(index2); if (intList.Count == vector3List1.Count) { break; } } Vector3 off = vector3List1.Count > 0 ? vector3List1[index2] : vector1; if (index1 < 3) { zero += this.CreateRandomShip(off, "loa", index1 == 0); } else { zero += this.CreateRandomShip(off, "", false); } if (!intList.Contains(index2)) { intList.Add(index2); } } if (num8 <= 0) { return; } Vector3 vector3_4 = zero / (float)num8; }
public override void Initialize() { CombatData combat = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn); PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID); if (player1 == null) { this._app.UI.CloseDialog((Dialog)this, true); } else { IEnumerable <PlayerInfo> playerInfos = this._app.GameDatabase.GetPlayerInfos(); StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID); string str1 = App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE"); if (starSystemInfo != (StarSystemInfo)null) { str1 = starSystemInfo.Name; } this._app.UI.SetPropertyString("summaryText", "text", "Combat - " + player1.VictoryStatus.ToString() + " at " + str1); int num1 = 0; int num2 = 0; float val2_1 = 0.0f; float val2_2 = 0.0f; double num3 = 0.0; double num4 = 0.0; float num5 = 0.0f; double num6 = 0.0; double num7 = 0.0; float num8 = 0.0f; int num9 = 0; int num10 = 0; Dictionary <int, float> dictionary1 = new Dictionary <int, float>(); Dictionary <int, float> dictionary2 = new Dictionary <int, float>(); foreach (PlayerInfo playerInfo in playerInfos) { PlayerInfo player = playerInfo; PlayerCombatData player2 = combat.GetPlayer(player.ID); if (player2 != null) { DiplomacyInfo diplomacyInfo = this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID); string itemGlobalId1; if (diplomacyInfo.State == DiplomacyState.WAR) { this._app.UI.AddItem("enemiesAvatars", "", player.ID, ""); itemGlobalId1 = this._app.UI.GetItemGlobalID("enemiesAvatars", "", player.ID, ""); } else { this._app.UI.AddItem("alliesAvatars", "", player.ID, ""); itemGlobalId1 = this._app.UI.GetItemGlobalID("alliesAvatars", "", player.ID, ""); } PlayerSetup playerSetup = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID)); string propertyValue = playerSetup == null ? player.Name : playerSetup.Name; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "name"), "text", propertyValue); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "playeravatar"), "texture", player.AvatarAssetPath); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "badge"), "texture", player.BadgeAssetPath); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId1, "primaryColor"), "color", player.PrimaryColor); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId1, "secondaryColor"), "color", player.SecondaryColor); this._app.UI.AddItem("combatSummary", "", player.ID, ""); string itemGlobalId2 = this._app.UI.GetItemGlobalID("combatSummary", "", player.ID, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "itemName"), "text", propertyValue); List <ShipData> shipData1 = player2.ShipData; List <WeaponData> weaponData1 = player2.WeaponData; List <PlanetData> planetData1 = player2.PlanetData; int count = shipData1.Count; int num11 = 0; float val1_1 = 0.0f; float val1_2 = 0.0f; Dictionary <int, string> dictionary3 = new Dictionary <int, string>(); foreach (ShipData shipData2 in shipData1) { num11 += shipData2.killCount; val1_1 += shipData2.damageDealt; val1_2 += shipData2.damageReceived; if (diplomacyInfo.State == DiplomacyState.WAR) { num10 += shipData2.destroyed ? 1 : 0; } else { num9 += shipData2.destroyed ? 1 : 0; } if (!dictionary3.ContainsKey(shipData2.designID)) { this._app.UI.AddItem(this._app.UI.Path(itemGlobalId2, "shipList"), "", shipData2.designID, ""); dictionary3.Add(shipData2.designID, this._app.UI.GetItemGlobalID(this._app.UI.Path(itemGlobalId2, "shipList"), "", shipData2.designID, "")); } } foreach (WeaponData weaponData2 in weaponData1) { if (diplomacyInfo.State == DiplomacyState.WAR) { if (!dictionary2.ContainsKey(weaponData2.weaponID)) { dictionary2.Add(weaponData2.weaponID, 0.0f); } Dictionary <int, float> dictionary4; int weaponId; (dictionary4 = dictionary2)[weaponId = weaponData2.weaponID] = dictionary4[weaponId] + weaponData2.damageDealt; } else { if (!dictionary1.ContainsKey(weaponData2.weaponID)) { dictionary1.Add(weaponData2.weaponID, 0.0f); } Dictionary <int, float> dictionary4; int weaponId; (dictionary4 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary4[weaponId] + weaponData2.damageDealt; } } foreach (PlanetData planetData2 in planetData1) { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID); if (colonyInfoForPlanet != null) { if (colonyInfoForPlanet.PlayerID != this._app.LocalPlayer.ID) { num3 += planetData2.imperialDamage; num4 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); num5 += planetData2.infrastructureDamage; } else { num6 += planetData2.imperialDamage; num7 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); num8 += planetData2.infrastructureDamage; } } } foreach (int key in dictionary3.Keys) { int des = key; DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(des); int num12 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Count <ShipData>(); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "stotalUnits"), 0, count); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "stotalUnits"), num12); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "stotalUnitsLabel"), "text", num12.ToString()); int num13 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, int>)(x => x.killCount)); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdestroyedUnits"), 0, num11); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdestroyedUnits"), num13); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdestroyedUnitsLabel"), "text", num13.ToString()); float num14 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, float>)(x => x.damageDealt)); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdamageInflicted"), 0, (int)val1_1); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdamageInflicted"), (int)num14); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdamageInflictedLabel"), "text", num14.ToString("N0")); float num15 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, float>)(x => x.damageReceived)); this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdamageTaken"), 0, (int)val1_2); this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdamageTaken"), (int)num15); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdamageTakenLabel"), "text", num15.ToString("N0")); this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "subitem_label"), "text", designInfo.Name); } num1 = Math.Max(count, num1); num2 = Math.Max(num11, num2); val2_1 = Math.Max(val1_1, val2_1); val2_2 = Math.Max(val1_2, val2_2); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "totalUnits"), 0, count); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "totalUnits"), count); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "totalUnitsLabel"), "text", count.ToString()); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "destroyedUnits"), 0, num11); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "destroyedUnits"), num11); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "destroyedUnitsLabel"), "text", num11.ToString()); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "damageInflicted"), 0, (int)val1_1); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "damageInflicted"), (int)val1_1); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "damageInflictedLabel"), "text", val1_1.ToString("N0")); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "damageTaken"), 0, (int)val1_2); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "damageTaken"), (int)val1_2); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "damageTakenLabel"), "text", val1_2.ToString("N0")); } } foreach (PlayerInfo playerInfo in playerInfos) { if (combat.GetPlayer(playerInfo.ID) != null) { string itemGlobalId = this._app.UI.GetItemGlobalID("combatSummary", "", playerInfo.ID, ""); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "totalUnits"), 0, num1); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "destroyedUnits"), 0, num2); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "damageInflicted"), 0, (int)val2_1); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "damageTaken"), 0, (int)val2_2); } } foreach (int key in dictionary1.Keys) { int weapon = key; this._app.UI.AddItem("alliedWeaponList", "", weapon, ""); string itemGlobalId = this._app.UI.GetItemGlobalID("alliedWeaponList", "", weapon, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "damageDealt"), "text", dictionary1[weapon].ToString("N0")); LogicalWeapon logicalWeapon = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)); string iconSpriteName = logicalWeapon.IconSpriteName; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "weaponIcon"), "sprite", iconSpriteName); this._app.UI.SetPropertyString(itemGlobalId, "tooltip", logicalWeapon.WeaponName); } foreach (int key in dictionary2.Keys) { int weapon = key; this._app.UI.AddItem("enemyWeaponList", "", weapon, ""); string itemGlobalId = this._app.UI.GetItemGlobalID("enemyWeaponList", "", weapon, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "damageDealt"), "text", dictionary2[weapon].ToString("N0")); string iconSpriteName = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)).IconSpriteName; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "weaponIcon"), "sprite", iconSpriteName); } int num16 = 0; string text1 = ""; if (num7 > 0.0 && num6 > 0.0) { text1 = text1 + num6.ToString("N0") + " Imperialists and " + num7.ToString("N0") + " civilians lost. "; } else if (num7 > 0.0) { text1 = text1 + num7.ToString("N0") + " civilians lost. "; } else if (num6 > 0.0) { text1 = text1 + num6.ToString("N0") + " Imperialists lost. "; } if (num4 > 0.0 && num3 > 0.0) { text1 = text1 + num3.ToString("N0") + " enemy Imperialists and " + num4.ToString("N0") + " enemy civilians killed."; } else if (num4 > 0.0) { text1 = text1 + num4.ToString("N0") + " enemy civilians killed."; } else if (num3 > 0.0) { text1 = text1 + num3.ToString("N0") + " enemy Imperialists killed."; } if (text1.Length > 0) { this._app.UI.AddItem("happenings", "", num16++, text1); } string text2 = ""; float num17; if ((double)num8 > 0.01) { string str2 = text2; num17 = num8 * 100f; string str3 = num17.ToString("#0.00"); text2 = str2 + "Infrastructure reduced by " + str3 + "%"; } if ((double)num5 > 0.01) { string str2 = text2; num17 = num5 * 100f; string str3 = num17.ToString("#0.00"); text2 = str2 + " Enemy infrastructure reduced by " + str3 + "%"; } if (text2.Length > 0) { this._app.UI.AddItem("happenings", "", num16++, text2); } string str4 = ""; if (num9 > 0) { str4 = num9 <= 1 ? str4 + num9.ToString() + " friendly ship lost. " : str4 + num9.ToString() + " friendly ships lost. "; } if (num10 > 0) { str4 = num9 <= 1 ? str4 + num10.ToString() + " enemy ship destroyed." : str4 + num10.ToString() + " enemy ships destroyed."; } if (str4.Length <= 0) { return; } UICommChannel ui = this._app.UI; int userItemId = num16; int num18 = userItemId + 1; string text3 = str4; ui.AddItem("happenings", "", userItemId, text3); } }
protected void UICommChannel_OnPanelMessage( string panelName, string msgType, string[] msgParams) { if (msgType == "slider_value") { if (!panelName.StartsWith("__")) { return; } string[] strArray = panelName.Split('|'); if (int.Parse(strArray[1]) != this._widgetID) { return; } ColonyInfo colonyInfo = this.App.GameDatabase.GetColonyInfo(int.Parse(strArray[2])); if (colonyInfo == null) { return; } if (PlanetWidget.IsOutputRateSlider(panelName)) { StarSystemDetailsUI.SetOutputRateNew(this.App, colonyInfo.OrbitalObjectID, panelName, msgParams[0]); StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName); } if (strArray[0].Contains("partOverharvestSlider")) { colonyInfo.OverharvestRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])); this.App.GameDatabase.UpdateColony(colonyInfo); StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName); } else if (strArray[0].Contains("partCivSlider")) { colonyInfo.CivilianWeight = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])); this.App.GameDatabase.UpdateColony(colonyInfo); StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName); } else { if (!strArray[0].Contains("partPopSlider")) { return; } int lockedVar = int.Parse(strArray[3]); Dictionary <int, float> ratios = new Dictionary <int, float>(); foreach (ColonyFactionInfo faction in colonyInfo.Factions) { ratios.Add(faction.FactionID, faction.CivPopWeight); } AlgorithmExtensions.DistributePercentages <int>(ref ratios, lockedVar, StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0]))); foreach (ColonyFactionInfo faction in colonyInfo.Factions) { faction.CivPopWeight = ratios[faction.FactionID]; this.App.GameDatabase.UpdateCivilianPopulation(faction); } this.App.GameDatabase.UpdateColony(colonyInfo); StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName); } } else { if (!(msgType == "slider_notched") || !panelName.StartsWith("__")) { return; } string[] strArray = panelName.Split('|'); if (int.Parse(strArray[1]) != this._widgetID) { return; } ColonyInfo colonyInfo = this.App.GameDatabase.GetColonyInfo(int.Parse(strArray[2])); if (colonyInfo == null || !panelName.Contains("partTradeSlider")) { return; } PlanetWidget.UpdateTradeSliderNotchInfo(this.App, colonyInfo.ID, int.Parse(msgParams[0])); } }
public static bool Simulate(GameSession game, int systemId, List <FleetInfo> fleets) { if (ScriptHost.AllowConsole) { App.Log.Trace(string.Format("Simulating RANDOM AI combat at: {0}", (object)systemId), "combat"); } bool flag1 = true; Dictionary <PlayerInfo, List <FleetInfo> > dictionary = new Dictionary <PlayerInfo, List <FleetInfo> >(); foreach (FleetInfo fleet in fleets) { PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(fleet.PlayerID); if (playerInfo != null) { if (!dictionary.ContainsKey(playerInfo)) { dictionary.Add(playerInfo, new List <FleetInfo>()); if (!playerInfo.isStandardPlayer && !CombatSimulatorRandoms.IsValidSimulateEncounterPlayer(game, playerInfo.ID)) { flag1 = false; } } dictionary[playerInfo].Add(fleet); } } List <ColonyInfo> colonyInfoList = new List <ColonyInfo>(); PlanetInfo[] systemPlanetInfos = game.GameDatabase.GetStarSystemPlanetInfos(systemId); if (systemPlanetInfos != null) { foreach (PlanetInfo planetInfo in systemPlanetInfos) { ColonyInfo colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID); if (colonyInfoForPlanet != null && colonyInfoForPlanet.IsIndependentColony(game.App)) { colonyInfoList.Add(colonyInfoForPlanet); } } } if (!flag1 && colonyInfoList.Count == 0 || dictionary.Keys.Count <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.isStandardPlayer)) != 1) { return(false); } bool flag2 = false; PlayerInfo index1 = dictionary.Keys.First <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.isStandardPlayer)); List <FleetInfo> aiPlayerFleets = dictionary[index1]; if (game.ScriptModules.Swarmers != null) { PlayerInfo index2 = dictionary.Keys.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == game.ScriptModules.Swarmers.PlayerID)); if (index2 != null) { FleetInfo randomsFleet1 = (FleetInfo)null; FleetInfo randomsFleet2 = (FleetInfo)null; foreach (FleetInfo fleetInfo in dictionary[index2]) { List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(fleetInfo.ID, false).ToList <ShipInfo>(); if (list.Count != 0) { if (list.Any <ShipInfo>((Func <ShipInfo, bool>)(x => x.DesignID == game.ScriptModules.Swarmers.SwarmQueenDesignID))) { randomsFleet1 = fleetInfo; } else { randomsFleet2 = fleetInfo; } } } if (randomsFleet1 != null) { CombatSimulatorRandoms.SimulateSwarmerQueen(CombatSimulatorRandoms._rand, game, systemId, randomsFleet1, index1.ID, aiPlayerFleets); } if (randomsFleet2 != null) { CombatSimulatorRandoms.SimulateSwarmerNest(CombatSimulatorRandoms._rand, game, systemId, randomsFleet2, index1.ID, aiPlayerFleets); } flag2 = true; } } if (game.ScriptModules.Gardeners != null) { PlayerInfo index2 = dictionary.Keys.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == game.ScriptModules.Gardeners.PlayerID)); if (index2 != null) { FleetInfo randomsFleet = dictionary[index2].FirstOrDefault <FleetInfo>(); if (randomsFleet != null) { CombatSimulatorRandoms.SimulateProteans(CombatSimulatorRandoms._rand, game, systemId, randomsFleet, index1.ID, aiPlayerFleets); } flag2 = true; } } if (game.ScriptModules.AsteroidMonitor != null) { PlayerInfo index2 = dictionary.Keys.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == game.ScriptModules.AsteroidMonitor.PlayerID)); if (index2 != null) { FleetInfo randomsFleet = dictionary[index2].FirstOrDefault <FleetInfo>(); if (randomsFleet != null) { CombatSimulatorRandoms.SimulateAsteroidMonitors(CombatSimulatorRandoms._rand, game, systemId, randomsFleet, index1.ID, aiPlayerFleets); } flag2 = true; } } if (game.ScriptModules.MorrigiRelic != null) { PlayerInfo index2 = dictionary.Keys.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == game.ScriptModules.MorrigiRelic.PlayerID)); if (index2 != null) { FleetInfo randomsFleet = dictionary[index2].FirstOrDefault <FleetInfo>(); if (randomsFleet != null) { CombatSimulatorRandoms.SimulateMorrigiRelics(CombatSimulatorRandoms._rand, game, systemId, randomsFleet, index1.ID, aiPlayerFleets); } flag2 = true; } } if (game.ScriptModules.Pirates != null) { PlayerInfo index2 = dictionary.Keys.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == game.ScriptModules.Pirates.PlayerID)); if (index2 != null) { FleetInfo randomsFleet = dictionary[index2].FirstOrDefault <FleetInfo>(); if (randomsFleet != null) { CombatSimulatorRandoms.SimulatePirateBase(CombatSimulatorRandoms._rand, game, systemId, randomsFleet, index1.ID, aiPlayerFleets); } flag2 = true; } } foreach (ColonyInfo indyColony in colonyInfoList) { Dictionary <PlayerInfo, List <FleetInfo> > enemyPlayers = new Dictionary <PlayerInfo, List <FleetInfo> >(); foreach (KeyValuePair <PlayerInfo, List <FleetInfo> > keyValuePair in dictionary) { if (keyValuePair.Key.isStandardPlayer && game.GameDatabase.GetDiplomacyStateBetweenPlayers(indyColony.PlayerID, keyValuePair.Key.ID) == DiplomacyState.WAR) { enemyPlayers.Add(keyValuePair.Key, keyValuePair.Value); } } if (enemyPlayers.Keys.Count != 0) { CombatSimulatorRandoms.SimulateIndyColony(CombatSimulatorRandoms._rand, game, systemId, indyColony, enemyPlayers); flag2 = true; } } return(flag2); }
private static void SimulateIndyColony( Random rand, GameSession game, int systemId, ColonyInfo indyColony, Dictionary <PlayerInfo, List <FleetInfo> > enemyPlayers) { StarSystemInfo starSystemInfo = game.GameDatabase.GetStarSystemInfo(systemId); PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(indyColony.OrbitalObjectID); List <PlayerInfo> standardPlayers = game.GameDatabase.GetStandardPlayerInfos().ToList <PlayerInfo>(); foreach (FleetInfo fleetInfo in game.GameDatabase.GetFleetInfoBySystemID(systemId, FleetType.FL_NORMAL).ToList <FleetInfo>()) { MissionInfo missionByFleetId = game.GameDatabase.GetMissionByFleetID(fleetInfo.ID); if (missionByFleetId != null && missionByFleetId.Type == MissionType.INVASION && missionByFleetId.TargetOrbitalObjectID == planetInfo.ID) { game.GameDatabase.InsertGovernmentAction(fleetInfo.PlayerID, App.Localize("@GA_INDEPENDANTCONQUERED"), "IndependantConquered", 0, 0); foreach (PlayerInfo playerInfo in standardPlayers) { if (game.GameDatabase.GetDiplomacyInfo(fleetInfo.PlayerID, playerInfo.ID).isEncountered) { game.GameDatabase.ApplyDiplomacyReaction(playerInfo.ID, fleetInfo.PlayerID, StratModifiers.DiplomacyReactionInvadeIndependentWorld, 1); } } } } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_COLONY_DESTROYED, EventMessage = TurnEventMessage.EM_COLONY_DESTROYED, PlayerID = indyColony.PlayerID, ColonyID = indyColony.ID, SystemID = systemId, TurnNumber = game.GameDatabase.GetTurnCount(), ShowsDialog = false }); StationTypeFlags stationTypeFlags = StationTypeFlags.CIVILIAN | StationTypeFlags.DIPLOMATIC | StationTypeFlags.DEFENCE; foreach (StationInfo stationInfo in game.GameDatabase.GetStationForSystemAndPlayer(systemId, indyColony.PlayerID).ToList <StationInfo>()) { int?parentId = stationInfo.OrbitalObjectInfo.ParentID; int id = planetInfo.ID; if ((parentId.GetValueOrDefault() != id ? 0 : (parentId.HasValue ? 1 : 0)) != 0 && ((StationTypeFlags)(1 << (int)(stationInfo.DesignInfo.StationType & (StationType)31)) & stationTypeFlags) != (StationTypeFlags)0) { game.GameDatabase.DestroyStation(game, stationInfo.ID, 0); } } game.GameDatabase.RemoveColonyOnPlanet(planetInfo.ID); if (enemyPlayers.Keys.Any <PlayerInfo>((Func <PlayerInfo, bool>)(x => standardPlayers.Any <PlayerInfo>((Func <PlayerInfo, bool>)(y => y.ID == x.ID))))) { GameSession.ApplyMoralEvent(game.App, MoralEvent.ME_LOSE_WORLD_ENEMY, indyColony.PlayerID, new int?(), starSystemInfo.ProvinceID, new int?()); } foreach (int num in enemyPlayers.Keys.Select <PlayerInfo, int>((Func <PlayerInfo, int>)(x => x.ID)).ToList <int>()) { int i = num; game.App.GameDatabase.ApplyDiplomacyReaction(indyColony.PlayerID, i, StratModifiers.DiplomacyReactionKillColony, 1); int factionId = game.App.GameDatabase.GetPlayerFactionID(indyColony.PlayerID); foreach (PlayerInfo playerInfo in standardPlayers.Where <PlayerInfo>((Func <PlayerInfo, bool>)(x => { if (x.FactionID == factionId) { return(x.ID != i); } return(false); })).ToList <PlayerInfo>()) { if (game.App.GameDatabase.GetDiplomacyInfo(i, playerInfo.ID).isEncountered) { game.App.GameDatabase.ApplyDiplomacyReaction(playerInfo.ID, i, StratModifiers.DiplomacyReactionKillRaceWorld, 1); } } } if (indyColony.CurrentStage == Kerberos.Sots.Data.ColonyStage.GemWorld) { GameSession.ApplyMoralEvent(game.App, MoralEvent.ME_LOSE_GEM, indyColony.PlayerID, new int?(), starSystemInfo.ProvinceID, new int?()); } else { if (indyColony.CurrentStage != Kerberos.Sots.Data.ColonyStage.ForgeWorld) { return; } GameSession.ApplyMoralEvent(game.App, MoralEvent.ME_LOSE_FORGE, indyColony.PlayerID, new int?(), starSystemInfo.ProvinceID, new int?()); } }
public void SyncEnemySide(int playerid) { CombatData combat = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn); PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID); if (player1 == null) { this._app.UI.CloseDialog((Dialog)this, true); } else { foreach (PlanetWidget sideplanetWidget in this._EnemySideplanetWidgets) { sideplanetWidget.Terminate(); } this._EnemySideplanetWidgets.Clear(); IEnumerable <PlayerInfo> playerInfos = this._app.GameDatabase.GetPlayerInfos(); StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID); App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE"); if (starSystemInfo != (StarSystemInfo)null) { string name = starSystemInfo.Name; } int val2_1 = 0; int val2_2 = 0; float val2_3 = 0.0f; float val2_4 = 0.0f; double num1 = 0.0; double num2 = 0.0; float num3 = 0.0f; int num4 = 0; Dictionary <int, float> dictionary1 = new Dictionary <int, float>(); PlayerInfo player = playerInfos.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == playerid)); PlayerCombatData player2 = combat.GetPlayer(player.ID); if (player2 != null) { this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID); PlayerSetup playerSetup = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID)); string propertyValue1 = playerSetup == null || !(playerSetup.Name != "") || playerSetup.AI ? player.Name : playerSetup.Name; this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "name"), "text", propertyValue1); this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "playeravatar"), "texture", player.AvatarAssetPath); this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "badge"), "texture", player.BadgeAssetPath); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "primaryColor"), "color", player.PrimaryColor); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "secondaryColor"), "color", player.SecondaryColor); this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "empireColor"), "color", player.PrimaryColor); this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerName"), "text", propertyValue1); List <ShipData> shipData1 = player2.ShipData; List <WeaponData> weaponData1 = player2.WeaponData; List <PlanetData> planetData1 = player2.PlanetData; int count = shipData1.Count; int val1_1 = 0; float val1_2 = 0.0f; float val1_3 = 0.0f; Dictionary <int, string> dictionary2 = new Dictionary <int, string>(); int userItemId1 = 0; this._app.UI.ClearItems(this._app.UI.Path("enemySide", "fleetDamage")); foreach (ShipData shipData2 in shipData1) { val1_1 += shipData2.killCount; val1_2 += shipData2.damageDealt; val1_3 += shipData2.damageReceived; num4 += shipData2.destroyed ? 1 : 0; DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(shipData2.designID); if (designInfo != null) { RealShipClasses?realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.AssaultShuttle ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0) { realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.Drone ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0) { realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.BoardingPod ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0 && this._app.Game.ScriptModules.MeteorShower.PlayerID != player.ID) { string propertyValue2 = ""; if (shipData2.destroyed) { propertyValue2 = designInfo.Name + " class ship has been destroyed."; } else if ((double)shipData2.damageReceived > 0.0) { propertyValue2 = designInfo.Name + " class ship has been damaged."; } if (propertyValue2 != "") { this._app.UI.AddItem(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, ""); this._app.UI.SetPropertyString(this._app.UI.Path(this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, ""), "name"), "text", propertyValue2); ++userItemId1; } } } } } } this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerScore"), "text", (shipData1.Count - num4).ToString() + "/" + shipData1.Count.ToString()); this._app.UI.SetSliderRange(this._app.UI.Path("enemySide", "playerData", "assets"), 0, shipData1.Count); this._app.UI.SetSliderValue(this._app.UI.Path("enemySide", "playerData", "assets"), shipData1.Count - num4); foreach (WeaponData weaponData2 in weaponData1) { if (!dictionary1.ContainsKey(weaponData2.weaponID)) { dictionary1.Add(weaponData2.weaponID, 0.0f); } Dictionary <int, float> dictionary3; int weaponId; (dictionary3 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary3[weaponId] + weaponData2.damageDealt; } this._app.UI.ClearItems(this._app.UI.Path("enemySide", "weaponDamage")); int num5 = 0; int userItemId2 = 0; string str = null; foreach (int key in dictionary1.Keys) { int weapon = key; if (num5 == 5 || str == null) { this._app.UI.AddItem(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, ""); str = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, ""); ++userItemId2; num5 = 0; for (int index = 0; index < 5; ++index) { this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + index.ToString()), false); } } this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "damageDealt"), "text", dictionary1[weapon].ToString("N0")); LogicalWeapon logicalWeapon = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)); string iconSpriteName = logicalWeapon.IconSpriteName; this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "weaponIcon"), "sprite", iconSpriteName); this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString()), "tooltip", logicalWeapon.WeaponName); this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + num5.ToString()), true); ++num5; } this._app.UI.ClearItems(this._app.UI.Path("enemySide", "planetDamage")); foreach (PlanetData planetData2 in planetData1) { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID); if (colonyInfoForPlanet != null) { num1 += planetData2.imperialDamage; num2 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); num3 += planetData2.infrastructureDamage; this._app.UI.AddItem(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, ""); string itemGlobalId = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, ""); OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(colonyInfoForPlanet.OrbitalObjectID); PlanetInfo planetInfo = this._app.GameDatabase.GetPlanetInfo(colonyInfoForPlanet.OrbitalObjectID); Faction faction = this._app.AssetDatabase.GetFaction(this._app.GameDatabase.GetPlayerFactionID(colonyInfoForPlanet.PlayerID)); double civilianPopulation = this._app.GameDatabase.GetCivilianPopulation(colonyInfoForPlanet.OrbitalObjectID, faction.ID, faction.HasSlaves()); float num6 = planetInfo != null ? planetInfo.Infrastructure : 0.0f; this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "planetName"), "text", orbitalObjectInfo != null ? orbitalObjectInfo.Name : "?"); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "civslbl"), "text", civilianPopulation.ToString("N0")); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "implbl"), "text", colonyInfoForPlanet.ImperialPop.ToString("N0")); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "infralbl"), "text", num6.ToString()); double num7 = civilianPopulation + planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)); this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "civAmount"), 0, (int)num7); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "civAmount"), (int)(num7 - planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage)))); double num8 = colonyInfoForPlanet.ImperialPop + planetData2.imperialDamage; this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "impAmount"), 0, (int)num8); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "impAmount"), (int)(num8 - planetData2.imperialDamage)); float num9 = num6 + planetData2.infrastructureDamage; this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "infraAmount"), 0, (int)(100.0 * (double)num9)); this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "infraAmount"), (int)(100.0 * ((double)num9 - (double)planetData2.infrastructureDamage))); if (planetInfo != null) { this._EnemySideplanetWidgets.Add(new PlanetWidget(this._app, itemGlobalId)); this._EnemySideplanetWidgets.Last <PlanetWidget>().Sync(planetInfo.ID, false, false); } } } Math.Max(count, val2_1); Math.Max(val1_1, val2_2); Math.Max(val1_2, val2_3); Math.Max(val1_3, val2_4); } this._app.UI.AutoSizeContents(this._app.UI.Path(this.ID, "enemySide")); } }
public static double DebugGetTaxRevenue(App game, PlayerInfo player, ColonyInfo colony) { try { double num = (double)((player.RateTax != 0f) ? (player.RateTax * 100f / game.AssetDatabase.TaxDivider) : 0f); } catch (Exception ex) { Debug.WriteLine("error {0} ", ex); throw; } return 0; }
public override void OnCommit( GameSession game, int playerId, int targetPlayerId, int?missionid = null) { List <CounterIntelResponse> source = new List <CounterIntelResponse>(); if (missionid.HasValue) { source = game.GameDatabase.GetCounterIntelResponses(missionid.Value).ToList <CounterIntelResponse>(); } if (source.Any <CounterIntelResponse>((Func <CounterIntelResponse, bool>)(x => !x.auto))) { game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INTEL_MISSION_NEWEST_COLONY_SYSTEM, EventMessage = TurnEventMessage.EM_INTEL_MISSION_NEWEST_COLONY_SYSTEM, PlayerID = playerId, TargetPlayerID = targetPlayerId, SystemID = int.Parse(source.First <CounterIntelResponse>().value), TurnNumber = game.GameDatabase.GetTurnCount(), ShowsDialog = true }); } else { List <ColonyInfo> list1 = game.GameDatabase.GetPlayerColoniesByPlayerId(targetPlayerId).ToList <ColonyInfo>(); if (list1.Count == 0) { game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INTEL_MISSION_NO_NEWEST_COLONY_SYSTEM, EventMessage = TurnEventMessage.EM_INTEL_MISSION_NO_NEWEST_COLONY_SYSTEM, PlayerID = playerId, TargetPlayerID = targetPlayerId, TurnNumber = game.GameDatabase.GetTurnCount() }); } else { ColonyInfo colonyInfo = list1.OrderByDescending <ColonyInfo, int>((Func <ColonyInfo, int>)(x => x.TurnEstablished)).First <ColonyInfo>(); int num = game.GameDatabase.GetOrbitalObjectInfo(colonyInfo.OrbitalObjectID).StarSystemID; if (source.Any <CounterIntelResponse>((Func <CounterIntelResponse, bool>)(x => x.auto))) { List <int> list2 = game.GameDatabase.GetPlayerColonySystemIDs(targetPlayerId).ToList <int>(); num = game.Random.Choose <int>((IList <int>)list2); } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INTEL_MISSION_NEWEST_COLONY_SYSTEM, EventMessage = TurnEventMessage.EM_INTEL_MISSION_NEWEST_COLONY_SYSTEM, PlayerID = playerId, TargetPlayerID = targetPlayerId, SystemID = num, ColonyID = colonyInfo.ID, TurnNumber = game.GameDatabase.GetTurnCount(), ShowsDialog = true }); } } }
protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams) { if (msgType == "edit_confirmed") { this.Confirm(); } if (msgType == "button_clicked") { if (!(panelName == "event_dialog_close")) { return; } this.Confirm(); } else if (msgType == "text_changed") { if (!(panelName == "gameColonyName")) { return; } this._enteredColonyName = msgParams[0]; } else if (msgType == "slider_value") { if (StarSystemDetailsUI.IsOutputRateSlider(panelName)) { StarSystemDetailsUI.SetOutputRate(this._app, this._planetID, panelName, msgParams[0]); StarSystemUI.SyncColonyDetailsWidget(this._app.Game, this._app.UI.Path(this.ID, "colony_details"), this._planetID, panelName); } else if (panelName == "partOverharvestSlider") { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(this._planetID); colonyInfoForPlanet.OverharvestRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])); this._app.GameDatabase.UpdateColony(colonyInfoForPlanet); StarSystemUI.SyncColonyDetailsWidget(this._app.Game, this._app.UI.Path(this.ID, "colony_details"), this._planetID, panelName); } else if (panelName == "partCivSlider") { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(this._planetID); colonyInfoForPlanet.CivilianWeight = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])); this._app.GameDatabase.UpdateColony(colonyInfoForPlanet); StarSystemUI.SyncColonyDetailsWidget(this._app.Game, this._app.UI.Path(this.ID, "colony_details"), this._planetID, panelName); } else { if (!(panelName == "partWorkRate")) { return; } ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(this._planetID); colonyInfoForPlanet.SlaveWorkRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])); this._app.GameDatabase.UpdateColony(colonyInfoForPlanet); StarSystemUI.SyncColonyDetailsWidget(this._app.Game, this._app.UI.Path(this.ID, "colony_details"), this._planetID, panelName); } } else { if (!(msgType == "list_sel_changed") || !(panelName == "gameViewportList")) { return; } this.SetColonyViewMode(int.Parse(msgParams[0])); } }
public override void Initialize() { this._colonyWidget = new FleetWidget(this._app, this.UI.Path(this.ID, "repairWidgetColonyList")); List <PlanetInfo> list1 = ((IEnumerable <PlanetInfo>) this._app.GameDatabase.GetStarSystemPlanetInfos(this._systemID)).ToList <PlanetInfo>(); List <PlanetInfo> planets1 = new List <PlanetInfo>(); List <ColonyInfo> source = new List <ColonyInfo>(); foreach (PlanetInfo planetInfo in list1) { ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID); if (colonyInfoForPlanet != null) { source.Add(colonyInfoForPlanet); if (colonyInfoForPlanet.PlayerID == this._app.LocalPlayer.ID) { planets1.Add(planetInfo); } } } this._colonyWidget.SetSyncedPlanets(planets1); this._suulkaWidget = new FleetWidget(this._app, this.UI.Path(this.ID, "gameRightListS")); this._suulkaWidget.ShipFilter += new FleetWidget.FleetWidgetShipFilter(this.SuulkaListFilter); this._suulkaWidget.SuulkaMode = true; this._suulkaWidget.DisableTooltips = true; this._suulkaDrainWidget = new FleetWidget(this._app, this.UI.Path(this.ID, "repairWidgetColonyList")); List <PlanetInfo> planets2 = new List <PlanetInfo>(); bool flag = this._fleets.Any <FleetInfo>((Func <FleetInfo, bool>)(x => { if (x.IsNormalFleet) { return(x.PlayerID != this._app.LocalPlayer.ID); } return(false); })); foreach (PlanetInfo planetInfo in list1) { PlanetInfo pi = planetInfo; ColonyInfo colonyInfo = source.FirstOrDefault <ColonyInfo>((Func <ColonyInfo, bool>)(x => x.OrbitalObjectID == pi.ID)); if ((!flag || colonyInfo == null || colonyInfo.PlayerID == this._app.LocalPlayer.ID) && (pi.Biosphere > 0 || colonyInfo != null)) { planets2.Add(pi); } } this._suulkaDrainWidget.SetSyncedPlanets(planets2); this._leftWidget = new FleetWidget(this._app, this.UI.Path(this.ID, "gameLeftList")); this._rightWidget = new FleetWidget(this._app, this.UI.Path(this.ID, "gameRightList")); this._leftWidget.DisableTooltips = true; this._rightWidget.RidersEnabled = true; this._rightWidget.SeparateDefenseFleet = false; this._rightWidget.DisableTooltips = true; this._leftWidget.ShipFilter += new FleetWidget.FleetWidgetShipFilter(this.LeftListFilter); this._rightWidget.ShipFilter += new FleetWidget.FleetWidgetShipFilter(this.RightListFilter); this._leftWidget.ShowColonies = true; this._leftWidget.OnlyLocalPlayer = true; this._leftWidget.ListStations = true; this._rightWidget.ListStations = true; List <StationInfo> list2 = this._app.GameDatabase.GetStationForSystemAndPlayer(this._systemID, this._app.LocalPlayer.ID).ToList <StationInfo>(); this._leftWidget.SetSyncedFleets(this._fleets); this._rightWidget.SetSyncedFleets(this._fleets); this._leftWidget.SetSyncedStations(list2); this._rightWidget.SetSyncedStations(list2); this._suulkaWidget.SetSyncedFleets(this._fleets); this._leftWidget.ShowEmptyFleets = false; this._rightWidget.ShowEmptyFleets = false; this._leftWidget.ShowFleetInfo = false; this._rightWidget.ShowFleetInfo = false; this._suulkaWidget.ShowEmptyFleets = false; this._suulkaWidget.ShowFleetInfo = false; this._rightWidget.RepairWidget = this._leftWidget; this._suulkaWidget.RepairWidget = this._suulkaDrainWidget; this._leftWidget.ShowRepairPoints = true; this._rightWidget.RepairMode = true; this._leftWidget.ExpandAll(); this._rightWidget.ExpandAll(); this._suulkaWidget.ExpandAll(); }
public void Sync(GameObjectSet gos) { StarMapBase.SyncContext context = new StarMapBase.SyncContext(this._db); List <StarSystemInfo> list1 = this._db.GetStarSystemInfos().ToList <StarSystemInfo>(); foreach (StarSystemInfo starSystemInfo in list1.Where <StarSystemInfo>((Func <StarSystemInfo, bool>)(x => !x.IsVisible)).ToList <StarSystemInfo>()) { if (!StarMap.IsInRange(this._db, this._sim.LocalPlayer.ID, starSystemInfo.ID)) { list1.Remove(starSystemInfo); } else { starSystemInfo.IsVisible = true; this._db.UpdateStarSystemVisible(starSystemInfo.ID, true); } } IEnumerable <StarMapTerrain> source1 = this.Terrain.Sync(gos, this._db.GetTerrainInfos(), context, false); IEnumerable <StarMapProvince> source2 = this.Provinces.Sync(gos, this._db.GetProvinceInfos(), context, false); IEnumerable <StarMapSystem> source3 = this.Systems.Sync(gos, (IEnumerable <StarSystemInfo>)list1, context, false); List <FleetInfo> list2 = this._db.GetFleetInfos(FleetType.FL_NORMAL | FleetType.FL_CARAVAN | FleetType.FL_ACCELERATOR).Where <FleetInfo>((Func <FleetInfo, bool>)(x => { if (!x.IsReserveFleet) { return(this._sim.GetPlayerObject(x.PlayerID) != null); } return(false); })).ToList <FleetInfo>(); int swarmerPlayer = this._sim.ScriptModules == null || this._sim.ScriptModules.Swarmers == null ? 0 : this._sim.ScriptModules.Swarmers.PlayerID; if (swarmerPlayer != 0) { foreach (FleetInfo fleetInfo in list2.Where <FleetInfo>((Func <FleetInfo, bool>)(x => { if (x.PlayerID == swarmerPlayer) { return(x.Name.Contains("Swarm")); } return(false); })).ToList <FleetInfo>()) { list2.Remove(fleetInfo); } } foreach (FleetInfo fleetInfo in list2.Where <FleetInfo>((Func <FleetInfo, bool>)(x => { if (this._db.GetMissionByFleetID(x.ID) != null) { return(this._db.GetMissionByFleetID(x.ID).Type == MissionType.PIRACY); } return(false); })).ToList <FleetInfo>()) { if (!this._db.PirateFleetVisibleToPlayer(fleetInfo.ID, this._sim.LocalPlayer.ID)) { list2.Remove(fleetInfo); } } IEnumerable <StarMapFleet> source4 = this.Fleets.Sync(gos, (IEnumerable <FleetInfo>)list2, context, true); this.PostObjectAddObjects((IGameObject[])source2.ToArray <StarMapProvince>()); this.PostObjectAddObjects((IGameObject[])source3.ToArray <StarMapSystem>()); this.PostObjectAddObjects((IGameObject[])source4.ToArray <StarMapFleet>()); if (this._sim.LocalPlayer.Faction.Name == "human") { this.PostObjectAddObjects((IGameObject[])this.NodeLines.Sync(gos, (IEnumerable <NodeLineInfo>) this._db.GetExploredNodeLines(this._sim.LocalPlayer.ID).Where <NodeLineInfo>((Func <NodeLineInfo, bool>)(x => x.IsPermenant)).ToList <NodeLineInfo>(), context, false).ToArray <StarMapNodeLine>()); } this.PostObjectAddObjects((IGameObject[])source1.ToArray <StarMapTerrain>()); Dictionary <int, int> dictionary1 = new Dictionary <int, int>(); List <StarMap.PlayerSystemPair> playerSystemPairList = new List <StarMap.PlayerSystemPair>(); foreach (StarMapFleet key in this.Fleets.Forward.Keys) { this._sim.GameDatabase.IsStealthFleet(key.FleetID); if (key.InTransit) { key.SetVisible(StarMap.IsInRange(this.App.Game.GameDatabase, this._sim.LocalPlayer.ID, key.Position, 1f, (Dictionary <int, List <ShipInfo> >)null)); } else { dictionary1[key.SystemID] = 0; bool flag = false; foreach (StarMap.PlayerSystemPair playerSystemPair in playerSystemPairList) { if (playerSystemPair.PlayerID == key.PlayerID && playerSystemPair.SystemID == key.SystemID) { flag = true; break; } } if (flag) { key.SetVisible(false); } else { key.SetVisible(StarMap.IsInRange(this.App.Game.GameDatabase, this._sim.LocalPlayer.ID, key.Position, 1f, (Dictionary <int, List <ShipInfo> >)null)); playerSystemPairList.Add(new StarMap.PlayerSystemPair() { PlayerID = key.PlayerID, SystemID = key.SystemID }); } } } foreach (StarMapFleet key in this.Fleets.Forward.Keys) { if (!key.InTransit && key.IsVisible) { key.SetSystemFleetIndex(dictionary1[key.SystemID]); Dictionary <int, int> dictionary2; int systemId; (dictionary2 = dictionary1)[systemId = key.SystemID] = dictionary2[systemId] + 1; } } foreach (StarMapFleet key in this.Fleets.Forward.Keys) { if (!key.InTransit && key.IsVisible) { key.SetSystemFleetCount(dictionary1[key.SystemID]); } } foreach (HomeworldInfo homeworld in this._db.GetHomeworlds()) { HomeworldInfo hw = homeworld; ColonyInfo hwci = this._db.GetColonyInfo(hw.ColonyID); if (hwci != null && list1.Any <StarSystemInfo>((Func <StarSystemInfo, bool>)(x => { if (x.ID == hw.SystemID) { return(hw.PlayerID == hwci.PlayerID); } return(false); }))) { this.PostSetProp("Homeworld", (object)this._sim.GetPlayerObject(hw.PlayerID).ObjectID, (object)this.Systems.Reverse[hw.SystemID].ObjectID); } } foreach (StarSystemInfo starSystemInfo in list1) { this.PostSetProp("ProvinceCapitalEffect", (object)false, (object)this.Systems.Reverse[starSystemInfo.ID].ObjectID); } foreach (ProvinceInfo provinceInfo in this._db.GetProvinceInfos().ToList <ProvinceInfo>()) { ProvinceInfo p = provinceInfo; if (list1.Any <StarSystemInfo>((Func <StarSystemInfo, bool>)(x => x.ID == p.CapitalSystemID))) { this.PostSetProp("ProvinceCapitalEffect", (object)true, (object)this.Systems.Reverse[p.CapitalSystemID].ObjectID); } } this.PostSetProp("RegenerateTerrain"); this.PostSetProp("RegenerateBorders"); this.PostSetProp("RegenerateFilters"); }
private string GetColonyName(ColonyInfo o) { return(this.db.GetOrbitalObjectInfo(o.OrbitalObjectID).Name); }