示例#1
0
 public SecuritySpending(
     PlayerInfo playerInfo,
     double total,
     SpendingPool pool,
     SpendingCaps caps)
 {
     this.RequestedTotal               = total;
     this.RequestedOperations          = total * (double)playerInfo.RateSecurityOperations;
     this.RequestedIntelligence        = total * (double)playerInfo.RateSecurityIntelligence;
     this.RequestedCounterIntelligence = total - this.RequestedOperations - this.RequestedIntelligence;
     this.ProjectedOperations          = pool.Distribute(this.RequestedOperations, caps.SecurityOperations);
     this.ProjectedIntelligence        = pool.Distribute(this.RequestedIntelligence, caps.SecurityIntelligence);
     this.ProjectedCounterIntelligence = pool.Distribute(this.RequestedCounterIntelligence, caps.SecurityCounterIntelligence);
 }
示例#2
0
 public ResearchSpending(
     PlayerInfo playerInfo,
     double total,
     SpendingPool pool,
     SpendingCaps caps)
 {
     this.RequestedTotal           = total;
     this.RequestedCurrentProject  = total * (double)playerInfo.RateResearchCurrentProject;
     this.RequestedSpecialProject  = total * (double)playerInfo.RateResearchSpecialProject;
     this.RequestedSalvageResearch = total - this.RequestedCurrentProject - this.RequestedSpecialProject;
     this.ProjectedCurrentProject  = pool.Distribute(this.RequestedCurrentProject, caps.ResearchCurrentProject);
     this.ProjectedSpecialProject  = pool.Distribute(this.RequestedSpecialProject, caps.ResearchSpecialProject);
     this.ProjectedSalvageResearch = pool.Distribute(this.RequestedSalvageResearch, caps.ResearchSalvageResearch);
 }
示例#3
0
 public StimulusSpending(
     PlayerInfo playerInfo,
     double total,
     SpendingPool pool,
     SpendingCaps caps)
 {
     this.RequestedTotal        = total;
     this.RequestedMining       = total * (double)playerInfo.RateStimulusMining;
     this.RequestedColonization = total * (double)playerInfo.RateStimulusColonization;
     this.RequestedTrade        = total - this.RequestedMining - this.RequestedColonization;
     this.ProjectedMining       = pool.Distribute(this.RequestedMining, caps.StimulusMining);
     this.ProjectedColonization = pool.Distribute(this.RequestedColonization, caps.StimulusColonization);
     this.ProjectedTrade        = pool.Distribute(this.RequestedTrade, caps.StimulusTrade);
 }
示例#4
0
        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;
        }