public void ExecuteEncounter( GameSession game, int targetSystem, float intensity = 1f, bool multiPlanets = false) { Random safeRandom = App.GetSafeRandom(); int minValue = (int)((double)game.AssetDatabase.GlobalMeteorShowerData.MinMeteors * (double)intensity); int maxValue = (int)((double)game.AssetDatabase.GlobalMeteorShowerData.MaxMeteors * (double)intensity); int num = safeRandom.Next(minValue, maxValue); int fleetID = game.GameDatabase.InsertFleet(this.PlayerId, 0, targetSystem, targetSystem, "Meteors", FleetType.FL_NORMAL); List <int> intList = new List <int>(); for (int index = 0; index < num; ++index) { intList.Add(game.GameDatabase.InsertShip(fleetID, safeRandom.Choose <int>((IList <int>) this.MeteorDesignIds), null, (ShipParams)0, new int?(), 0)); } List <ColonyInfo> list = game.GameDatabase.GetColonyInfosForSystem(targetSystem).ToList <ColonyInfo>(); foreach (int shipID in intList) { int planetId = 0; if (multiPlanets && list.Count > 0) { planetId = safeRandom.Choose <ColonyInfo>((IList <ColonyInfo>)list).OrbitalObjectID; } game.GameDatabase.UpdateShipSystemPosition(shipID, new Matrix?(MeteorShower.GetSpawnTransform(game.App, targetSystem, planetId))); } }
public static MeteorShower ResumeEncounter(GameDatabase gamedb) { if (gamedb.AssetDatabase.GetFaction("asteroids") == null) { return((MeteorShower)null); } MeteorShower meteorShower = new MeteorShower(); PlayerInfo playerInfo = gamedb.GetPlayerInfos().ToList <PlayerInfo>().FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => { if (!x.isStandardPlayer) { return(x.Name.Contains("Meteors")); } return(false); })); meteorShower.PlayerId = playerInfo.ID; List <DesignInfo> list = gamedb.GetDesignInfosForPlayer(meteorShower.PlayerId).ToList <DesignInfo>(); int length = ((IEnumerable <string>)MeteorShower.MeteorDesignFiles).Count <string>(); meteorShower._meteorDesignIds = new int[length]; for (int i = 0; i < length; ++i) { DesignInfo designInfo = list.FirstOrDefault <DesignInfo>((Func <DesignInfo, bool>)(x => x.DesignSections[0].FilePath.EndsWith(MeteorShower.MeteorDesignFiles[i]))); if (designInfo == null) { DesignInfo design = new DesignInfo(meteorShower.PlayerId, "Huge Meteor " + (object)i, new string[1] { string.Format("factions\\{0}\\sections\\{1}", (object)"asteroids", (object)MeteorShower.MeteorDesignFiles[i]) }); meteorShower._meteorDesignIds[i] = gamedb.InsertDesignByDesignInfo(design); } else { meteorShower._meteorDesignIds[i] = designInfo.ID; } } return(meteorShower); }
public static MeteorShower InitializeEncounter( GameDatabase gamedb, AssetDatabase assetdb) { if (assetdb.GetFaction("asteroids") == null) { return((MeteorShower)null); } MeteorShower meteorShower = new MeteorShower(); meteorShower.PlayerId = gamedb.InsertPlayer("Meteors", "asteroids", new int?(), assetdb.RandomEncounterPrimaryColor, new Vector3(0.0f), "", "\\base\\factions\\asteroids\\avatars\\Asteroids_Avatar.tga", 0.0, 0, false, false, false, 0, AIDifficulty.Normal); int length = ((IEnumerable <string>)MeteorShower.MeteorDesignFiles).Count <string>(); meteorShower._meteorDesignIds = new int[length]; for (int index = 0; index < length; ++index) { DesignInfo design = new DesignInfo(meteorShower.PlayerId, "Huge Meteor " + (object)index, new string[1] { string.Format("factions\\{0}\\sections\\{1}", (object)"asteroids", (object)MeteorShower.MeteorDesignFiles[index]) }); meteorShower._meteorDesignIds[index] = gamedb.InsertDesignByDesignInfo(design); } return(meteorShower); }