private void WeaponSelectorSelectedWeaponChanged(object sender, bool isRightClick) { int?nullable = new int?(); if (this._weaponSelector.SelectedWeapon != null) { nullable = this.App.GameDatabase.GetWeaponID(this._weaponSelector.SelectedWeapon.FileName, this.App.LocalPlayer.ID); } if (nullable.HasValue) { this._selectedModule.WeaponID = new int?(nullable.Value); if (isRightClick) { foreach (DesignModuleInfo module in this.WorkingDesign.DesignSections[0].Modules) { string moduleass = this.App.GameDatabase.GetModuleAsset(module.ModuleID); if (((IEnumerable <LogicalBank>) this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleass)).Banks).Count <LogicalBank>() > 0) { module.WeaponID = new int?(nullable.Value); } } } this.UpdateListitem(isRightClick); } DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign); this.UpdateUICostETA(); this.HideWeaponSelector(); }
public static int AddOrGetEncounterDesignInfo( this GameDatabase db, IEnumerable <DesignInfo> designs, int playerID, string name, string factionName, params string[] sectionFilename) { for (int index = 0; index < ((IEnumerable <string>)sectionFilename).Count <string>(); ++index) { sectionFilename[index] = string.Format("factions\\{0}\\sections\\{1}", (object)factionName, (object)sectionFilename[index]); } DesignInfo designInfo1 = designs.FirstOrDefault <DesignInfo>((Func <DesignInfo, bool>)(x => x.Name == name)); if (designInfo1 != null) { return(designInfo1.ID); } DesignInfo designInfo2 = new DesignInfo(playerID, name, sectionFilename); if (string.IsNullOrEmpty(name)) { designInfo2.Name = DesignLab.GenerateDesignName(db.AssetDatabase, db, (DesignInfo)null, designInfo2, DesignLab.NameGenerators.FactionRandom); } return(db.InsertDesignByDesignInfo(designInfo2)); }
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 void ExecuteEncounter(GameSession game, PlayerInfo targetPlayer, int targetSystem) { Random safeRandom = App.GetSafeRandom(); int num1 = safeRandom.Next(game.AssetDatabase.GlobalSlaverData.MinAbductors, game.AssetDatabase.GlobalSlaverData.MaxAbductors); int num2 = safeRandom.Next(game.AssetDatabase.GlobalSlaverData.MinScavengers, game.AssetDatabase.GlobalSlaverData.MaxScavengers); int fleetID = game.GameDatabase.InsertFleet(this.PlayerId, 0, targetSystem, targetSystem, "Slaver Band", FleetType.FL_NORMAL); for (int index = 0; index < num1; ++index) { game.GameDatabase.InsertShip(fleetID, this._wraithAbductorDesignId, null, (ShipParams)0, new int?(), 0); } DesignInfo designInfo = game.GameDatabase.GetDesignInfo(this._scavengerDesignId); for (int index1 = 0; index1 < num2; ++index1) { int parentID = game.GameDatabase.InsertShip(fleetID, this._scavengerDesignId, null, (ShipParams)0, new int?(), 0); if (designInfo != null) { int index2 = 0; foreach (DesignSectionInfo designSection in designInfo.DesignSections) { foreach (WeaponBankInfo chooseWeapon in DesignLab.ChooseWeapons(game, (IList <LogicalWeapon>)game.AssetDatabase.Weapons.ToList <LogicalWeapon>(), ShipRole.SCAVENGER, WeaponRole.PLANET_ATTACK, designSection.ShipSectionAsset, this.PlayerId, (AITechStyles)null)) { if (chooseWeapon.DesignID.HasValue && chooseWeapon.DesignID.Value != 0) { int shipID = game.GameDatabase.InsertShip(fleetID, chooseWeapon.DesignID.Value, null, (ShipParams)0, new int?(), 0); game.GameDatabase.SetShipParent(shipID, parentID); game.GameDatabase.UpdateShipRiderIndex(shipID, index2); ++index2; } } } } } }
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); }
public static VonNeumann InitializeEncounter( GameDatabase gamedb, AssetDatabase assetdb) { VonNeumann vonNeumann = new VonNeumann(); vonNeumann.PlayerId = gamedb.InsertPlayer("Von Neumann", "vonneumann", new int?(), assetdb.RandomEncounterPrimaryColor, new Vector3(0.0f), "", "\\base\\factions\\vonneumann\\avatars\\Vonneumann_Avatar.tga", 0.0, 0, false, false, false, 0, AIDifficulty.Normal); foreach (KeyValuePair <VonNeumann.VonNeumannShipDesigns, VonNeumann.VonNeumannDesignInfo> keyValuePair in VonNeumann.StaticShipDesigns.ToList <KeyValuePair <VonNeumann.VonNeumannShipDesigns, VonNeumann.VonNeumannDesignInfo> >()) { DesignInfo design = new DesignInfo(vonNeumann.PlayerId, keyValuePair.Key.ToString(), new string[1] { string.Format("factions\\{0}\\sections\\{1}", (object)"vonneumann", (object)keyValuePair.Value.AssetName) }); DesignLab.SummarizeDesign(assetdb, gamedb, design); VonNeumann.StaticShipDesigns[keyValuePair.Key] = new VonNeumann.VonNeumannDesignInfo() { DesignId = gamedb.InsertDesignByDesignInfo(design), AssetName = keyValuePair.Value.AssetName }; } vonNeumann._outlyingStars = EncounterTools.GetOutlyingStars(gamedb); return(vonNeumann); }
public static FleetTypeFlags GetFleetTypeFlags( App app, int fleetID, int playerID, bool isLoa) { if (isLoa || app.GameDatabase.GetPlayerFaction(playerID).Name == "loa") { return(FleetTypeFlags.ANY); } AIFleetInfo aiFleetInfo = app.GameDatabase.GetAIFleetInfos(playerID).FirstOrDefault <AIFleetInfo>((Func <AIFleetInfo, bool>)(x => { int?fleetId = x.FleetID; int num = fleetID; return(fleetId.GetValueOrDefault() == num & fleetId.HasValue); })); FleetTemplate template = (FleetTemplate)null; string templateName = aiFleetInfo != null ? aiFleetInfo.FleetTemplate : DesignLab.DeduceFleetTemplate(app.GameDatabase, app.Game, fleetID); if (!string.IsNullOrEmpty(templateName)) { template = app.GameDatabase.AssetDatabase.FleetTemplates.First <FleetTemplate>((Func <FleetTemplate, bool>)(x => x.Name == templateName)); } if (template == null) { template = app.GameDatabase.AssetDatabase.FleetTemplates.FirstOrDefault <FleetTemplate>((Func <FleetTemplate, bool>)(x => x.Name == "DEFAULT_COMBAT")); } return(FleetManagement.GetFleetTypeFlags(template, isLoa)); }
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; }
public int SpawnPirateFleet(GameSession game, int targetSystem, int numShips) { Random random = new Random(); int fleetID = game.GameDatabase.InsertFleet(this.PlayerID, 0, targetSystem, 0, "Pirate Raiders", FleetType.FL_NORMAL); Dictionary <LogicalWeapon, int> dictionary1 = new Dictionary <LogicalWeapon, int>(); List <PlayerInfo> list1 = game.GameDatabase.GetStandardPlayerInfos().ToList <PlayerInfo>(); List <PlayerInfo> playerInfoList = new List <PlayerInfo>(); foreach (PlayerInfo playerInfo in list1) { Faction faction = game.AssetDatabase.GetFaction(playerInfo.FactionID); if (faction.Name != "liir_zuul" && faction.Name != "hiver" && faction.Name != "loa") { playerInfoList.Add(playerInfo); } foreach (LogicalWeapon key in game.GameDatabase.GetAvailableWeapons(game.AssetDatabase, playerInfo.ID).ToList <LogicalWeapon>()) { if (!dictionary1.ContainsKey(key)) { dictionary1.Add(key, 1); } else { Dictionary <LogicalWeapon, int> dictionary2; LogicalWeapon index; (dictionary2 = dictionary1)[index = key] = dictionary2[index] + 1; } } } if (playerInfoList.Count > 0) { List <LogicalWeapon> availableWeapons = new List <LogicalWeapon>(); foreach (LogicalWeapon logicalWeapon in game.AssetDatabase.Weapons.ToList <LogicalWeapon>()) { if (((IEnumerable <LogicalTurretClass>)logicalWeapon.TurretClasses).Count <LogicalTurretClass>() > 0 && WeaponEnums.IsBattleRider(logicalWeapon.DefaultWeaponClass)) { availableWeapons.Add(logicalWeapon); } } foreach (KeyValuePair <LogicalWeapon, int> keyValuePair in dictionary1) { if (keyValuePair.Value > 1 && !availableWeapons.Contains(keyValuePair.Key)) { availableWeapons.Add(keyValuePair.Key); } } for (int index1 = 0; index1 < numShips + 1; ++index1) { PlayerInfo playerInfo = random.Choose <PlayerInfo>((IList <PlayerInfo>)playerInfoList); Faction faction = game.AssetDatabase.GetFaction(playerInfo.FactionID); DesignInfo design1 = DesignLab.DesignShip(game, ShipClass.BattleRider, ShipRole.BOARDINGPOD, WeaponRole.PLANET_ATTACK, playerInfo.ID); DesignInfo design2 = DesignLab.DesignShip(game, ShipClass.BattleRider, ShipRole.DRONE, WeaponRole.UNDEFINED, playerInfo.ID); design1.PlayerID = this.PlayerID; design2.PlayerID = this.PlayerID; game.GameDatabase.InsertDesignByDesignInfo(design1); game.GameDatabase.InsertDesignByDesignInfo(design2); DesignInfo designInfo1; if (index1 == 0) { DesignInfo designInfo2 = DesignLab.DesignShip(game, ShipClass.Cruiser, ShipRole.COMMAND, WeaponRole.UNDEFINED, playerInfo.ID); designInfo1 = new DesignInfo(playerInfo.ID, "", new string[3] { ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Command)).FilePath, ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Mission)).FilePath, ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Engine)).FilePath }); } else { List <ShipSectionAsset> availableSections = game.GetAvailableShipSections(playerInfo.ID).ToList <ShipSectionAsset>(); List <string> list2 = ((IEnumerable <string>)Pirates.availableCommandSections).ToList <string>(); List <string> list3 = ((IEnumerable <string>)Pirates.availableMissionSections).ToList <string>(); List <string> list4 = ((IEnumerable <string>)Pirates.availableEngineSections).ToList <string>(); for (int index2 = 0; index2 < list2.Count <string>(); ++index2) { list2[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list2[index2]); } for (int index2 = 0; index2 < list3.Count <string>(); ++index2) { list3[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list3[index2]); } for (int index2 = 0; index2 < list4.Count <string>(); ++index2) { list4[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list4[index2]); } list2.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x)))); list3.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x)))); list4.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x)))); designInfo1 = new DesignInfo(playerInfo.ID, "", new string[3] { random.Choose <string>((IList <string>)list2), random.Choose <string>((IList <string>)list3), random.Choose <string>((IList <string>)list4) }); } designInfo1.Name = DesignLab.GenerateDesignName(game.AssetDatabase, game.GameDatabase, (DesignInfo)null, designInfo1, DesignLab.NameGenerators.FactionRandom); DesignLab.SummarizeDesign(game.AssetDatabase, game.GameDatabase, designInfo1); DesignInfo design3 = DesignLab.AssignWeaponsToDesign(game, designInfo1, availableWeapons, this.PlayerId, WeaponRole.BRAWLER, (AITechStyles)null); design3.PlayerID = this.PlayerID; int designID = game.GameDatabase.InsertDesignByDesignInfo(design3); int carrierID = game.GameDatabase.InsertShip(fleetID, designID, null, (ShipParams)0, new int?(), 0); game.AddDefaultStartingRiders(fleetID, designID, carrierID); } } return(fleetID); }
public override void Initialize() { this.App.UI.HideTooltip(); this.BankDict = new Dictionary <string, int>(); this.ItemIDDict = new Dictionary <string, string>(); this.ModuleBankdict = new Dictionary <int, string>(); DesignInfo designInfo = this._ship.DesignInfo; if (designInfo.DesignSections[0].Modules.Any <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => { ModuleEnums.StationModuleType?stationModuleType = x.StationModuleType; if ((stationModuleType.GetValueOrDefault() != ModuleEnums.StationModuleType.Combat ? 0 : (stationModuleType.HasValue ? 1 : 0)) != 0) { return(!x.WeaponID.HasValue); } return(false); }))) { this.UpdateStationDesignInfo(designInfo); this._app.GameDatabase.UpdateDesign(designInfo); } this.WorkingDesign = new DesignInfo(this._ship.DesignInfo.PlayerID, this._ship.DesignInfo.Name, new string[1] { this._ship.DesignInfo.DesignSections[0].FilePath }); this.WorkingDesign.StationLevel = designInfo.StationLevel; this.WorkingDesign.StationType = designInfo.StationType; DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign); this.WorkingDesign.DesignSections[0].Modules = new List <DesignModuleInfo>(); this.WorkingDesign.DesignSections[0].WeaponBanks = new List <WeaponBankInfo>(); this.WorkingDesign.DesignSections[0].Techs = new List <int>(); this.WorkingDesign.DesignSections[0].ShipSectionAsset = designInfo.DesignSections[0].ShipSectionAsset; int num = 0; foreach (DesignModuleInfo module in designInfo.DesignSections[0].Modules) { DesignModuleInfo designModuleInfo = new DesignModuleInfo() { MountNodeName = module.MountNodeName, ModuleID = module.ModuleID, WeaponID = module.WeaponID, DesignID = module.DesignID, StationModuleType = module.StationModuleType, ID = num }; ++num; this.WorkingDesign.DesignSections[0].Modules.Add(designModuleInfo); } this.UpdateStationDesignInfo(this.WorkingDesign); this.App.UI.ClearItems(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID)); DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign); foreach (DesignSectionInfo designSection in this.WorkingDesign.DesignSections) { foreach (DesignModuleInfo module in designSection.Modules) { if (module.WeaponID.HasValue) { this.App.UI.AddItem(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID), "", module.ID, ""); string itemGlobalId = this.App.UI.GetItemGlobalID(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID), "", module.ID, ""); string asset = this.App.GameDatabase.GetWeaponAsset(module.WeaponID.Value); LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset)); this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "wepimg"), "sprite", logicalWeapon.IconSpriteName); string index = "retrofitButton|" + module.ID.ToString(); this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "btnImageButton"), "id", index); if (!this.BankDict.ContainsKey(index)) { this.BankDict[index] = module.ID; } if (!this.ItemIDDict.ContainsKey(index)) { this.ItemIDDict[index] = itemGlobalId; } } } } this._weaponSelector = new WeaponSelector(this.App.UI, "gameWeaponSelector", ""); this.App.UI.SetParent(this._weaponSelector.ID, this.UI.Path(this.ID, "gameWeaponSelectorbox")); this._weaponSelector.SelectedWeaponChanged += new WeaponSelectionChangedEventHandler(this.WeaponSelectorSelectedWeaponChanged); StationInfo stationInfo = this.App.GameDatabase.GetStationInfosByPlayerID(this._ship.DesignInfo.PlayerID).FirstOrDefault <StationInfo>((Func <StationInfo, bool>)(x => x.ShipID == this._ship.ID)); if (stationInfo != null) { StationUI.SyncStationDetailsWidget(this.App.Game, this.UI.Path(this.ID, "stationDetails"), stationInfo.OrbitalObjectID, true); } this.UpdateUICostETA(); this.App.UI.SetEnabled(this.UI.Path(this.ID, "okButton"), (this.DesignChanged() ? 1 : 0) != 0); }