protected override void OnPrepare(GameState prev, object[] stateParams) { base.OnPrepare(prev, stateParams); this._targetSystemID = (int)stateParams[0]; this._selectedPlanetID = (int)stateParams[1]; this._sim = (GameSession)stateParams[2]; this._selectedFleetID = (int)stateParams[3]; this._designsToBuild = (List <int>)stateParams[4]; this._stationType = (StationType)stateParams[5]; this._missionEstimate = (MissionEstimate)stateParams[6]; this._useDirectRoute = (bool)stateParams[7]; this._rebase = (int?)stateParams[8]; this._crits = new GameObjectSet(this.App); this._dummies = new GameObjectSet(this.App); DesignInfo di = DesignLab.CreateStationDesignInfo(this.App.AssetDatabase, this.App.GameDatabase, this.App.LocalPlayer.ID, this._stationType, 1, false); StarSystemDummyOccupant systemDummyOccupant = new StarSystemDummyOccupant(this.App, this.App.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == di.DesignSections[0].FilePath)).ModelName, this._stationType); this._dummies.Add((IGameObject)systemDummyOccupant); this._starsystem.PostObjectAddObjects((IGameObject)systemDummyOccupant); this._manager = new StationPlacement(this.App, this.App.LocalPlayer.Faction.Name == "zuul"); this._manager.PostSetProp("SetStarSystem", (IGameObject)this._starsystem); this._manager.PostSetProp("SetPlacementStamp", (IGameObject)systemDummyOccupant); this._manager.PostSetProp("SetMissionType", (object)this._stationType.ToFlags()); this.App.UI.LoadScreen("StationPlacement"); }
public override void Initialize() { this._sky = new Sky(this._app, SkyUsage.StarMap, 0); this._crits = new GameObjectSet(this._app); this._planetView = this._crits.Add <PlanetView>(); this._crits.Add((IGameObject)this._sky); StationInfo stationInfo = this._app.GameDatabase.GetStationInfo(this._stationID); OrbitalObjectInfo orbitalObjectInfo1 = this._app.GameDatabase.GetOrbitalObjectInfo(this._stationID); OrbitalObjectInfo orbitalObjectInfo2 = this._app.GameDatabase.GetOrbitalObjectInfo(orbitalObjectInfo1.ParentID.Value); this._app.UI.SetText(this._app.UI.Path(this.ID, "station_class"), string.Format(App.Localize("@STATION_LEVEL"), (object)stationInfo.DesignInfo.StationLevel.ToString(), (object)stationInfo.DesignInfo.StationType.ToString())); this._app.UI.SetText(this._app.UI.Path(this.ID, "upkeep_cost"), string.Format(App.Localize("@STATION_UPKEEP_COST"), (object)GameSession.CalculateStationUpkeepCost(this._app.GameDatabase, this._app.AssetDatabase, stationInfo).ToString())); if (stationInfo.DesignInfo.StationType == StationType.NAVAL) { this._app.UI.SetText(this._app.UI.Path(this.ID, "naval_capacity"), string.Format(App.Localize("@STATION_FLEET_CAPACITY"), (object)this._app.GameDatabase.GetSystemSupportedCruiserEquivalent(this._app.Game, orbitalObjectInfo2.StarSystemID, this._app.LocalPlayer.ID).ToString())); } else { this._app.UI.SetVisible(this._app.UI.Path(this.ID, "naval_capacity"), false); } StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo2.StarSystemID); this._app.UI.SetText("gameStationName", orbitalObjectInfo1.Name); this._enteredStationName = orbitalObjectInfo2.Name; this._app.UI.SetText(this._app.UI.Path(this.ID, "system_name"), string.Format(App.Localize("@STATION_BUILT"), (object)starSystemInfo.Name).ToUpperInvariant()); this._cameraReduced = new OrbitCameraController(this._app); this._cameraReduced.MinDistance = 1002.5f; this._cameraReduced.MaxDistance = 10000f; this._cameraReduced.DesiredDistance = 2000f; this._cameraReduced.DesiredYaw = MathHelper.DegreesToRadians(45f); this._cameraReduced.DesiredPitch = -MathHelper.DegreesToRadians(25f); this._cameraReduced.SnapToDesiredPosition(); this._starmapReduced = new StarMap(this._app, this._app.Game, this._sky); this._starmapReduced.Initialize(this._crits); this._starmapReduced.SetCamera(this._cameraReduced); this._starmapReduced.FocusEnabled = false; this._starmapReduced.PostSetProp("Selected", this._starmapReduced.Systems.Reverse[starSystemInfo.ID].ObjectID); this._starmapReduced.PostSetProp("CullCenter", this._app.GameDatabase.GetStarSystemInfo(starSystemInfo.ID).Origin); this._starmapReduced.PostSetProp("CullRadius", 15f); DesignInfo di = DesignLab.CreateStationDesignInfo(this._app.AssetDatabase, this._app.GameDatabase, this._app.LocalPlayer.ID, stationInfo.DesignInfo.StationType, stationInfo.DesignInfo.StationLevel, false); this._stationModel = new StarSystemDummyOccupant(this._app, this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == di.DesignSections[0].FilePath)).ModelName, stationInfo.DesignInfo.StationType); this._stationModel.PostSetScale(1f / 500f); this._stationModel.PostSetPosition(this._trans); }
private Budget( GameDatabase gamedb, AssetDatabase assetdb, GameSession game, PlayerInfo playerInfo, FactionInfo playerFactionInfo, double maxDriveSpeed, double incomeFromTrade, SpendingCaps spendingCaps, IEnumerable <ColonyInfo> colonyInfos, Dictionary <int, PlanetInfo> planetInfos, Dictionary <int, OrbitalObjectInfo> orbitalObjectInfos, Dictionary <int, StarSystemInfo> starSystemInfos, HashSet <int> starSystemsWithGates, IEnumerable <StationInfo> stationInfos, IEnumerable <DesignInfo> reserveShipDesignInfos, IEnumerable <DesignInfo> shipDesignInfos, IEnumerable <DesignInfo> eliteShipDesignInfos, IEnumerable <DesignInfo> additionalShipDesignInfos) { this.CurrentSavings = playerInfo.Savings; this.SavingsInterest = playerFactionInfo.Name != "loa" ? GameSession.CalculateSavingsInterest(game, playerInfo) : 0.0; this.DebtInterest = playerFactionInfo.Name != "loa" ? GameSession.CalculateDebtInterest(game, playerInfo) : 0.0; this.TradeRevenue = incomeFromTrade; this.TaxRevenue = colonyInfos.Sum <ColonyInfo>((Func <ColonyInfo, double>)(x => Colony.GetTaxRevenue(game.App, playerInfo, x))); float num1 = gamedb.GetNameValue <float>("EconomicEfficiency") / 100f; this.TradeRevenue *= (double)num1; this.TradeRevenue *= (double)game.GameDatabase.GetStratModifierFloatToApply(StratModifiers.TradeRevenue, playerInfo.ID); this.TaxRevenue *= (double)num1; Player playerObject1 = game.GetPlayerObject(playerInfo.ID); if (playerObject1 == null || !playerObject1.IsAI()) { this.CurrentStationUpkeepExpenses = GameSession.CalculateStationUpkeepCosts(gamedb, assetdb, stationInfos); this.CurrentShipUpkeepExpenses = GameSession.CalculateFleetUpkeepCosts(assetdb, reserveShipDesignInfos, shipDesignInfos, eliteShipDesignInfos); this.AdditionalUpkeepExpenses = GameSession.CalculateShipUpkeepCosts(assetdb, additionalShipDesignInfos, 1f, false); } this.ColonySupportExpenses = colonyInfos.Sum <ColonyInfo>((Func <ColonyInfo, double>)(x => { OrbitalObjectInfo orbitalObjectInfo = orbitalObjectInfos[x.OrbitalObjectID]; PlanetInfo planetInfo = planetInfos[x.OrbitalObjectID]; StarSystemInfo starSystemInfo = starSystemInfos[orbitalObjectInfo.StarSystemID]; return(Colony.GetColonySupportCost(gamedb, assetdb, playerInfo, playerFactionInfo, orbitalObjectInfos[x.OrbitalObjectID], planetInfos[x.OrbitalObjectID], starSystemInfos[orbitalObjectInfos[x.OrbitalObjectID].StarSystemID], orbitalObjectInfos, planetInfos, starSystemInfos, starSystemsWithGates.Contains(orbitalObjectInfos[x.OrbitalObjectID].StarSystemID), maxDriveSpeed)); })); this.IORevenue = 0.0; List <int> list1 = gamedb.GetPlayerColonySystemIDs(playerInfo.ID).ToList <int>(); int num2 = list1.Where <int>((Func <int, bool>)(x => gamedb.GetStarSystemInfo(x).IsOpen)).Count <int>(); Player playerObject2 = game.GetPlayerObject(playerInfo.ID); float num3 = 0.0f; foreach (int num4 in list1) { List <BuildOrderInfo> list2 = gamedb.GetBuildOrdersForSystem(num4).ToList <BuildOrderInfo>(); float num5 = 0.0f; foreach (ColonyInfo colony in gamedb.GetColonyInfosForSystem(num4).ToList <ColonyInfo>()) { if (colony.PlayerID == playerInfo.ID) { num5 += Colony.GetConstructionPoints(game, colony); } } float num6 = num5 * game.GetStationBuildModifierForSystem(num4, playerInfo.ID); foreach (BuildOrderInfo buildOrderInfo in list2) { DesignInfo designInfo = gamedb.GetDesignInfo(buildOrderInfo.DesignID); if (designInfo.PlayerID == playerInfo.ID) { int num7 = designInfo.SavingsCost; if (designInfo.IsLoaCube()) { num7 = buildOrderInfo.LoaCubes * assetdb.LoaCostPerCube; } int num8 = buildOrderInfo.ProductionTarget - buildOrderInfo.Progress; float num9 = 0.0f; if (!designInfo.isPrototyped) { num9 = (float)(int)((double)num6 * ((double)gamedb.GetStratModifierFloatToApply(StratModifiers.PrototypeTimeModifier, playerInfo.ID) - 1.0)); switch (designInfo.Class) { case ShipClass.Cruiser: num7 = (int)((double)designInfo.SavingsCost * (double)gamedb.GetStratModifierFloatToApply(StratModifiers.PrototypeSavingsCostModifierCR, playerInfo.ID)); break; case ShipClass.Dreadnought: num7 = (int)((double)designInfo.SavingsCost * (double)gamedb.GetStratModifierFloatToApply(StratModifiers.PrototypeSavingsCostModifierDN, playerInfo.ID)); break; case ShipClass.Leviathan: num7 = (int)((double)designInfo.SavingsCost * (double)gamedb.GetStratModifierFloatToApply(StratModifiers.PrototypeSavingsCostModifierLV, playerInfo.ID)); break; case ShipClass.Station: RealShipClasses?realShipClass = designInfo.GetRealShipClass(); if ((realShipClass.GetValueOrDefault() != RealShipClasses.Platform ? 0 : (realShipClass.HasValue ? 1 : 0)) != 0) { num7 = (int)((double)designInfo.SavingsCost * (double)gamedb.GetStratModifierFloatToApply(StratModifiers.PrototypeSavingsCostModifierPF, playerInfo.ID)); break; } break; } } if (playerInfo.isStandardPlayer && playerObject2.IsAI() && playerObject2.Faction.Name == "loa") { num7 = (int)((double)num7 * 1.0); } if ((double)num8 <= (double)num6 - (double)num9) { num3 += (float)num7; num6 -= (float)num8; } this.TotalBuildShipCosts += (double)num7; } } this.IORevenue += (double)num6; } this.IORevenue *= (double)game.GameDatabase.GetStratModifierFloatToApply(StratModifiers.IORevenue, playerInfo.ID); this.PendingBuildShipsCost = (double)num3; foreach (MissionInfo missionInfo in game.GameDatabase.GetMissionInfos().Where <MissionInfo>((Func <MissionInfo, bool>)(x => x.Type == MissionType.CONSTRUCT_STN))) { FleetInfo fleetInfo = game.GameDatabase.GetFleetInfo(missionInfo.FleetID); if (fleetInfo.PlayerID == playerInfo.ID) { MissionEstimate missionEstimate = Kerberos.Sots.StarFleet.StarFleet.GetMissionEstimate(game, missionInfo.Type, (StationType)missionInfo.StationType.Value, fleetInfo.ID, missionInfo.TargetSystemID, missionInfo.TargetOrbitalObjectID, (List <int>)null, 1, false, new float?(), new float?()); this.TotalBuildStationsCost += (double)missionEstimate.ConstructionCost; if (missionEstimate.TotalTurns - 1 - missionEstimate.TurnsToReturn <= 1) { this.PendingBuildStationsCost += (double)missionEstimate.ConstructionCost; } } } foreach (MissionInfo missionInfo in game.GameDatabase.GetMissionInfos().Where <MissionInfo>((Func <MissionInfo, bool>)(x => { if (x.Type == MissionType.UPGRADE_STN) { return(x.Duration > 0); } return(false); }))) { FleetInfo fleetInfo = game.GameDatabase.GetFleetInfo(missionInfo.FleetID); if (game.GameDatabase.GetStationInfo(missionInfo.TargetOrbitalObjectID) != null && fleetInfo.PlayerID == playerInfo.ID && game.GameDatabase.GetWaypointsByMissionID(missionInfo.ID).First <WaypointInfo>().Type != WaypointType.ReturnHome) { StationInfo stationInfo = game.GameDatabase.GetStationInfo(missionInfo.TargetOrbitalObjectID); if (stationInfo.DesignInfo.StationLevel + 1 <= 5) { MissionEstimate missionEstimate = Kerberos.Sots.StarFleet.StarFleet.GetMissionEstimate(game, missionInfo.Type, stationInfo.DesignInfo.StationType, fleetInfo.ID, missionInfo.TargetSystemID, missionInfo.TargetOrbitalObjectID, (List <int>)null, stationInfo.DesignInfo.StationLevel + 1, false, new float?(), new float?()); DesignInfo stationDesignInfo = DesignLab.CreateStationDesignInfo(game.AssetDatabase, game.GameDatabase, fleetInfo.PlayerID, stationInfo.DesignInfo.StationType, stationInfo.DesignInfo.StationLevel + 1, false); this.TotalBuildStationsCost += (double)stationDesignInfo.SavingsCost; if (missionEstimate.TotalTurns - 1 - missionEstimate.TurnsToReturn <= 1) { this.PendingBuildStationsCost += (double)stationDesignInfo.SavingsCost; } } } } foreach (StationInfo stationInfo in game.GameDatabase.GetStationInfosByPlayerID(playerInfo.ID)) { List <DesignModuleInfo> queuedModules = game.GameDatabase.GetQueuedStationModules(stationInfo.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>(); if (queuedModules.Count > 0) { LogicalModule logicalModule1 = game.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == game.GameDatabase.GetModuleAsset(queuedModules.First <DesignModuleInfo>().ModuleID))); if (logicalModule1 != null) { this.PendingStationsModulesCost += (double)logicalModule1.SavingsCost; } foreach (DesignModuleInfo designModuleInfo in queuedModules) { DesignModuleInfo dmi = designModuleInfo; LogicalModule logicalModule2 = game.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == game.GameDatabase.GetModuleAsset(dmi.ModuleID))); if (logicalModule2 != null) { this.TotalStationsModulesCost += (double)logicalModule2.SavingsCost; } } } } this.TotalRevenue = this.TradeRevenue + this.TaxRevenue + this.IORevenue + this.SavingsInterest; this.RequiredSecurity = (int)Math.Ceiling(((double)num2 / (double)list1.Count != 0.0 ? ((double)assetdb.BaseCorruptionRate + 0.0199999995529652 * ((double)playerInfo.RateImmigration * 10.0)) / (2.0 * (double)playerInfo.RateGovernmentResearch) : 0.0) * 100.0); if (playerFactionInfo.Name == "loa") { this.RequiredSecurity = 0; } this.CorruptionExpenses = this.TotalRevenue * (double)Math.Max(0.0f, (float)(((double)assetdb.BaseCorruptionRate + 0.0199999995529652 * ((double)playerInfo.RateImmigration * 10.0) - 2.0 * ((double)playerInfo.RateGovernmentResearch * (double)playerInfo.RateGovernmentSecurity)) * ((double)num2 / (double)list1.Count))); if (playerFactionInfo.Name == "loa") { this.CorruptionExpenses = 0.0; } this.UpkeepExpenses = this.CurrentShipUpkeepExpenses + this.CurrentStationUpkeepExpenses + this.AdditionalUpkeepExpenses; this.TotalExpenses = this.UpkeepExpenses + this.ColonySupportExpenses + this.DebtInterest + this.CorruptionExpenses; this.OperatingBudget = this.TotalRevenue - this.TotalExpenses; this.DisposableIncome = Math.Max(this.OperatingBudget, 0.0); this.NetSavingsLoss = Math.Max(-this.OperatingBudget, 0.0) + this.PendingBuildShipsCost + this.PendingBuildStationsCost + this.PendingStationsModulesCost; this.RequestedGovernmentSpending = this.DisposableIncome * (double)playerInfo.RateGovernmentResearch; SpendingPool pool = new SpendingPool(); this.ResearchSpending = new ResearchSpending(playerInfo, this.DisposableIncome - this.RequestedGovernmentSpending, pool, spendingCaps); this.SecuritySpending = new SecuritySpending(playerInfo, this.RequestedGovernmentSpending * (double)playerInfo.RateGovernmentSecurity, pool, spendingCaps); this.StimulusSpending = new StimulusSpending(playerInfo, this.RequestedGovernmentSpending * (double)playerInfo.RateGovernmentStimulus, pool, spendingCaps); this.ProjectedGovernmentSpending = this.SecuritySpending.ProjectedTotal + this.StimulusSpending.ProjectedTotal; this.UnspentIncome = pool.Excess; this.NetSavingsIncome = this.DisposableIncome - this.ResearchSpending.RequestedTotal - this.SecuritySpending.RequestedTotal - this.StimulusSpending.RequestedTotal + this.UnspentIncome; this.ProjectedSavings = this.CurrentSavings + this.NetSavingsIncome - this.NetSavingsLoss; }