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 void Choose_RandomElementFromEmptyArray_ThrowsException() { // setup var source = new int[0]; // act & assert Assert.Throws <ArgumentOutOfRangeException>(() => _random.Choose(source)); }
public Pop(Planet planet, Point position, int generation = 0) : base(planet, position) { _random = planet.Random; Generation = generation; Fullness = Planet.Config.PopStartingFullness; _nextWalk = Planet.Random.Next(Planet.Config.PopWalkDelay); _food = new Food[Enum.GetValues(typeof(FoodTypes)).Length]; for (int i = 0; i < _food.Length; i++) { _food[i] = new Food((FoodTypes)i, 0); } _digestionTimers = new List <int>(); _wanderDirection = _random.Choose <Point>(Directions); Gender = _random.Choose(Genders.Male, Genders.Female); }
public void AddEncounter(GameSession game, PlayerInfo targetPlayer) { Random safeRandom = App.GetSafeRandom(); List <int> list = game.GameDatabase.GetPlayerColonySystemIDs(targetPlayer.ID).ToList <int>(); if (list.Count <= 0) { return; } int systemid = safeRandom.Choose <int>((IList <int>)list); game.GameDatabase.InsertIncomingRandom(targetPlayer.ID, systemid, RandomEncounter.RE_SLAVERS, game.GameDatabase.GetTurnCount() + 1); if (!game.DetectedIncomingRandom(targetPlayer.ID, systemid)) { return; } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INCOMING_SLAVERS, EventMessage = TurnEventMessage.EM_INCOMING_SLAVERS, PlayerID = targetPlayer.ID, SystemID = systemid, TurnNumber = game.GameDatabase.GetTurnCount() }); }
public void AddEncounter(GameSession game, PlayerInfo targetPlayer, int?targetSystem = null) { Random safeRandom = App.GetSafeRandom(); List <int> list = game.GameDatabase.GetPlayerColonySystemIDs(targetPlayer.ID).ToList <int>(); if (!targetSystem.HasValue && list.Count <= 0) { return; } if (!targetSystem.HasValue) { List <int> noAsteroidBelt = list.Where <int>((Func <int, bool>)(x => !game.GameDatabase.GetStarSystemOrbitalObjectInfos(x).Any <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(y => game.GameDatabase.GetAsteroidBeltInfo(y.ID) != null)))).ToList <int>(); list.RemoveAll((Predicate <int>)(x => noAsteroidBelt.Contains(x))); targetSystem = list.Count <= 0 ? new int?(safeRandom.Choose <int>((IList <int>)noAsteroidBelt)) : new int?(safeRandom.Choose <int>((IList <int>)list)); } game.GameDatabase.InsertIncomingRandom(targetPlayer.ID, targetSystem.Value, RandomEncounter.RE_ASTEROID_SHOWER, game.GameDatabase.GetTurnCount() + 1); if (!game.DetectedIncomingRandom(targetPlayer.ID, targetSystem.Value)) { return; } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INCOMING_ASTEROID_SHOWER, EventMessage = TurnEventMessage.EM_INCOMING_ASTEROID_SHOWER, PlayerID = targetPlayer.ID, SystemID = targetSystem.Value, TurnNumber = game.GameDatabase.GetTurnCount() }); }
public void AddEncounter(GameSession game, PlayerInfo targetPlayer) { Random safeRandom = App.GetSafeRandom(); List <FleetInfo> list1 = game.GameDatabase.GetFleetInfosByPlayerID(this.PlayerId, FleetType.FL_NORMAL).ToList <FleetInfo>(); List <int> list2 = game.GameDatabase.GetPlayerColonySystemIDs(targetPlayer.ID).ToList <int>(); if (list2.Count <= 0 || list1.Count <= 0) { return; } int systemid = safeRandom.Choose <int>((IList <int>)list2); game.GameDatabase.InsertIncomingRandom(targetPlayer.ID, systemid, RandomEncounter.RE_GHOST_SHIP, game.GameDatabase.GetTurnCount() + 1); if (!game.DetectedIncomingRandom(targetPlayer.ID, systemid)) { return; } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INCOMING_GHOST_SHIP, EventMessage = TurnEventMessage.EM_INCOMING_GHOST_SHIP, PlayerID = targetPlayer.ID, SystemID = systemid, TurnNumber = game.GameDatabase.GetTurnCount() }); }
public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int?targetSystem = null) { Random safeRandom = App.GetSafeRandom(); List <KeyValuePair <StarSystemInfo, Vector3> > outlyingStars = EncounterTools.GetOutlyingStars(gamedb); StarSystemInfo starSystemInfo; if (targetSystem.HasValue) { starSystemInfo = gamedb.GetStarSystemInfo(targetSystem.Value); } else { int count = outlyingStars.Count / 3; if (count <= 0) { return; } List <KeyValuePair <StarSystemInfo, Vector3> > range = outlyingStars.GetRange(0, count); starSystemInfo = safeRandom.Choose <KeyValuePair <StarSystemInfo, Vector3> >((IList <KeyValuePair <StarSystemInfo, Vector3> >)range).Key; } gamedb.InsertIncomingGM(starSystemInfo.ID, EasterEgg.GM_SYSTEM_KILLER, 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_SYSTEMKILLER, EventMessage = TurnEventMessage.EM_INCOMING_SYSTEMKILLER, PlayerID = playerInfo.ID, TurnNumber = gamedb.GetTurnCount() }); } } }
public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int SystemId, int OrbitId) { OrbitalObjectInfo orbitalObjectInfo = gamedb.GetOrbitalObjectInfo(OrbitId); gamedb.RemoveOrbitalObject(orbitalObjectInfo.ID); int orbitalId = gamedb.InsertAsteroidBelt(orbitalObjectInfo.ParentID, orbitalObjectInfo.StarSystemID, orbitalObjectInfo.OrbitalPath, "Morrigi Relic Belt", App.GetSafeRandom().Next()); int fleetID = gamedb.InsertFleet(this.PlayerId, 0, SystemId, SystemId, "Morrigi Relic", FleetType.FL_NORMAL); gamedb.InsertMorrigiRelicInfo(new MorrigiRelicInfo() { SystemId = SystemId, FleetId = fleetID, IsAggressive = true }); Random safeRandom = App.GetSafeRandom(); Matrix orbitalTransform = gamedb.GetOrbitalTransform(orbitalId); List <int> list = MorrigiRelic._designIds.Where <int>((Func <int, bool>)(x => x != MorrigiRelic._designIds.Last <int>())).ToList <int>(); for (int shipIndex = 0; shipIndex < safeRandom.Next(1, assetdb.GlobalMorrigiRelicData.NumTombs + 1); ++shipIndex) { int num = gamedb.InsertShip(fleetID, safeRandom.Choose <int>((IList <int>)list), null, (ShipParams)0, new int?(), 0); this.SetRelicPosition(safeRandom, gamedb, assetdb, num, shipIndex, orbitalTransform); for (int index = 0; index < assetdb.GlobalMorrigiRelicData.NumFighters; ++index) { int shipID = gamedb.InsertShip(fleetID, MorrigiRelic._designIds.Last <int>(), null, (ShipParams)0, new int?(), 0); gamedb.SetShipParent(shipID, num); } } }
public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int?targetSystem = null) { Random safeRandom = App.GetSafeRandom(); if (targetSystem == null) { List <ColonyInfo> source = gamedb.GetColonyInfos().ToList <ColonyInfo>(); List <int> list = (from x in source select gamedb.GetOrbitalObjectInfo(x.OrbitalObjectID).StarSystemID).ToList <int>(); List <NeutronStarInfo> neutronStars = new List <NeutronStarInfo>(); list.RemoveAll((int x) => neutronStars.Any((NeutronStarInfo y) => y.TargetSystemId == x)); if (list.Count == 0) { return; } targetSystem = new int?(safeRandom.Choose(list)); } gamedb.InsertIncomingGM(targetSystem.Value, EasterEgg.GM_NEUTRON_STAR, gamedb.GetTurnCount() + 1); List <PlayerInfo> list2 = gamedb.GetStandardPlayerInfos().ToList <PlayerInfo>(); foreach (PlayerInfo playerInfo in list2) { if (gamedb.GetStratModifier <int>(StratModifiers.GrandMenaceWarningTime, playerInfo.ID) > 0) { gamedb.InsertTurnEvent(new TurnEvent { EventType = TurnEventType.EV_INCOMING_NEUTRON_STAR, EventMessage = TurnEventMessage.EM_INCOMING_NEUTRON_STAR, PlayerID = playerInfo.ID, SystemID = targetSystem.Value, TurnNumber = gamedb.GetTurnCount() }); } } }
/// <summary> /// Generate an <see cref="ImageGrid"/> object with random properties within defined ranges /// </summary> public ImageGrid Generate() { // use the ImageGeneration library to spin up an image grid half var imageHalf = ImageGenerator .GenerateImageHalf(_random.Choose(_sizes), _random.Choose(_fillChances)); // make our own with that image half's properties, a random color, and the current date return(new ImageGrid { Id = Guid.NewGuid().ToString(), Color = _random.Choose(ImageGrid.Colors.Keys), Size = imageHalf.Size, Half = imageHalf.Pixels, DateCreated = DateTime.UtcNow }); }
public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int?targetSystem = null) { Random safeRandom = App.GetSafeRandom(); int id; if (!targetSystem.HasValue) { List <KeyValuePair <StarSystemInfo, Vector3> > list = EncounterTools.GetOutlyingStars(gamedb).ToList <KeyValuePair <StarSystemInfo, Vector3> >(); List <KeyValuePair <StarSystemInfo, Vector3> > range = list.GetRange(0, (int)Math.Ceiling((double)list.Count / 3.0)); if (range.Count == 0) { return; } id = safeRandom.Choose <KeyValuePair <StarSystemInfo, Vector3> >((IList <KeyValuePair <StarSystemInfo, Vector3> >)range).Key.ID; } else { id = targetSystem.Value; } gamedb.InsertIncomingGM(id, EasterEgg.GM_LOCUST_SWARM, 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_LOCUST, EventMessage = TurnEventMessage.EM_INCOMING_LOCUST, PlayerID = playerInfo.ID, TurnNumber = gamedb.GetTurnCount() }); } } }
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 void AddEncounter(GameSession game, PlayerInfo targetPlayer, int?forceSystem = null) { if (game.GameDatabase.GetStratModifier <bool>(StratModifiers.ImmuneToSpectre, targetPlayer.ID)) { return; } Random safeRandom = App.GetSafeRandom(); List <int> list = game.GameDatabase.GetPlayerColonySystemIDs(targetPlayer.ID).ToList <int>(); if (list.Count <= 0 && !forceSystem.HasValue) { return; } int systemid = forceSystem.HasValue ? forceSystem.Value : safeRandom.Choose <int>((IList <int>)list); game.GameDatabase.InsertIncomingRandom(targetPlayer.ID, systemid, RandomEncounter.RE_SPECTORS, game.GameDatabase.GetTurnCount() + 1); if (!game.DetectedIncomingRandom(targetPlayer.ID, systemid)) { return; } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_INCOMING_SPECTORS, EventMessage = TurnEventMessage.EM_INCOMING_SPECTORS, PlayerID = targetPlayer.ID, SystemID = systemid, TurnNumber = game.GameDatabase.GetTurnCount() }); }
public ArrowTypes GetRandomArrowType(bool includeDefaultArrows) { List <ArrowTypes> list = new List <ArrowTypes>(); if (includeDefaultArrows && !this.Exclusions.Contains(Pickups.Arrows)) { list.Add(ArrowTypes.Normal); } if (!this.Exclusions.Contains(Pickups.BombArrows)) { list.Add(ArrowTypes.Bomb); } if (!this.Exclusions.Contains(Pickups.LaserArrows)) { list.Add(ArrowTypes.Laser); } if (!this.Exclusions.Contains(Pickups.BrambleArrows)) { list.Add(ArrowTypes.Bramble); } if (!this.Exclusions.Contains(Pickups.DrillArrows)) { list.Add(ArrowTypes.Drill); } if (SaveData.Instance.Unlocks.SunkenCity && !this.Exclusions.Contains(Pickups.BoltArrows)) { list.Add(ArrowTypes.Bolt); } if (SaveData.Instance.Unlocks.TowerForge && !this.Exclusions.Contains(Pickups.SuperBombArrows)) { list.Add(ArrowTypes.SuperBomb); } if (SaveData.Instance.Unlocks.Ascension && !this.Exclusions.Contains(Pickups.FeatherArrows)) { list.Add(ArrowTypes.Feather); } if (GameData.DarkWorldDLC && !this.Exclusions.Contains(Pickups.TriggerArrows)) { list.Add(ArrowTypes.Trigger); } if (GameData.DarkWorldDLC && !this.Exclusions.Contains(Pickups.PrismArrows)) { list.Add(ArrowTypes.Prism); } // Add modded arrows to the mix for (int i = 0; i < ModArrow.ModArrowTypes.Count; i++) { list.Add((ArrowTypes)i + 11); } if (list.Count == 0) { return(ArrowTypes.Normal); } return(Random.Choose(list)); }
private static bool GenerateNumber(GameFieldModel model, Random rand, IndexPair pair) { var availableNumbers = GetHeuristicsAvailableNumbers(model, pair); sbyte number = rand.Choose(availableNumbers); model.SetItemNumber(pair, number); return !model.IsItemEmpty(pair); }
public void Step() { CurrentStep++; // Remove aged and starved pops var deadPops = Population.FindAll(p => p.Age >= Config.PopMaxAge); AgeDeaths += deadPops.Count; var starvedPops = Population.FindAll(p => p.Fullness <= 0); StarvationDeaths += starvedPops.Count; deadPops.Concat(starvedPops).ToList().ForEach(p => { Population.Remove(p); //GetCross(p.Position).ForEach(pos => AddFertility(pos, Config.PopDeathFertility)); AddFertility(p.Position, p.GetFood(FoodTypes.Berry) * Config.BushBerryGrowCost + p.DigestionAmount); }); // Add newborn pops Population = Population.Concat(_newPops).ToList(); _newPops.Clear(); // Remove aged bushes var deadBushes = Bushes.FindAll(b => b.Age >= Config.BushMaxAge); deadBushes.ForEach(b => { Bushes.Remove(b); int fertility = Config.BushDeathFertility + b.Berries * Config.BushBerryGrowCost; var cross = GetCross(b.Position); //.ForEach(p => AddFertility(p, fertility)); for (var i = 0; i < fertility; i++) { AddFertility(Random.Choose <Point>(cross), 1); } RemoveBushRange(b); }); // Add newly grown bushes Bushes = Bushes.Concat(_newBushes).ToList(); _newBushes.ForEach(AddBushRange); _newBushes.Clear(); Population.ForEach(p => p.Step()); Bushes.ForEach(b => b.Step()); }
private void MoveTowards(Point target) { var dir = target - Position; var movement = Point.Zero; if (dir.X != 0 && dir.Y != 0) { movement = _random.Choose(dir.XDir(), dir.YDir()); } else if (dir.X != 0) { movement = dir.XDir(); } else if (dir.Y != 0) { movement = dir.YDir(); } if (PositionFree(Position + movement)) { Position += movement; } else { // Try another random direction movement = _random.Choose <Point>(Directions.Where(d => d != movement).ToList()); if (PositionFree(Position + movement)) { Position += movement; } } }
public void EmitParticles(Vector2 position, int numParticles = -1) { if (numParticles == -1) { numParticles = MaxNumParticles; } while (_freeParticleSlots.Count > 0 && numParticles > 0) { int idx = _freeParticleSlots.Pop(); Particles[idx] = new Particle { Velocity = MaxParticleSpeed * Random.NextBilateralVector2().GetClampedTo(1.0f), Position = position + MaxParticleSpread * Random.NextBilateralVector2().GetClampedTo(1.0f), Color = Random.Choose(Colors), Texture = Random.Choose(Textures), TTL = Random.NextFloatBetween(MinTTL, MaxTTL), AngularVelocity = Random.NextFloatBetween(-MaxAngularVelocity, MaxAngularVelocity) }; numParticles--; } }
public static void AddSuperNovas(GameSession game, GameDatabase gamedb, AssetDatabase assetdb) { if (!gamedb.HasEndOfFleshExpansion() || game.ScriptModules.SuperNova == null || gamedb.GetTurnCount() < assetdb.GlobalSuperNovaData.MinTurns) { return; } string nameValue1 = game.GameDatabase.GetNameValue("GMCount"); if (string.IsNullOrEmpty(nameValue1)) { game.GameDatabase.InsertNameValuePair("GMCount", "0"); nameValue1 = game.GameDatabase.GetNameValue("GMCount"); } int nameValue2 = game.GameDatabase.GetNameValue <int>("GSGrandMenaceCount"); int num1 = int.Parse(nameValue1); if (num1 >= nameValue2) { return; } Random safeRandom = App.GetSafeRandom(); if (!safeRandom.CoinToss(assetdb.GlobalSuperNovaData.Chance)) { return; } List <StarSystemInfo> list1 = gamedb.GetStarSystemInfos().ToList <StarSystemInfo>(); List <SuperNovaInfo> list2 = gamedb.GetSuperNovaInfos().ToList <SuperNovaInfo>(); List <int> intList = new List <int>(); foreach (StarSystemInfo starSystemInfo in list1) { StarSystemInfo ssi = starSystemInfo; StellarClass stellarClass = new StellarClass(ssi.StellarClass); if ((stellarClass.Type == StellarType.O || stellarClass.Type == StellarType.B) && !list2.Any <SuperNovaInfo>((Func <SuperNovaInfo, bool>)(x => x.SystemId == ssi.ID))) { intList.Add(ssi.ID); } } if (intList.Count <= 0) { return; } game.ScriptModules.SuperNova.AddInstance(gamedb, assetdb, safeRandom.Choose <int>((IList <int>)intList)); int num2; game.GameDatabase.UpdateNameValuePair("GMCount", (num2 = num1 + 1).ToString()); }
public static void SpawnGameObjectsInRingFormation(Vector2 center, float radius, int numToSpawn, Random rand, params KnownGameObject[] types) { Vector2 localPosition = new Vector2(radius, 0.0f); Angle angle = new Angle { Radians = MathHelper.TwoPi / numToSpawn }; for (int bonbonIndex = 0; bonbonIndex < numToSpawn; bonbonIndex++) { KnownGameObject type = rand.Choose(types); GameObject go = GameObjectFactory.CreateKnown(type); go.SetWorldPosition(center + localPosition); Game.AddGameObject(go); localPosition = localPosition.GetRotated(angle); } }
/// <summary>Generates a random <see cref="string"/> of a given length using the System.Random generator with a specific set of characters.</summary> /// <param name="random">The random generation algorithm.</param> /// <param name="length">The length of the randomized <see cref="string"/> to generate.</param> /// <param name="characterPool">The set of allowable characters.</param> /// <returns>The generated randomized <see cref="string"/>.</returns> public static string NextString(this Random random, int length, char[] characterPool) { _ = random ?? throw new ArgumentNullException(nameof(random)); _ = characterPool ?? throw new ArgumentNullException(nameof(characterPool)); if (length < 1) { throw new ArgumentException("(" + nameof(length) + " < 1)"); } if (characterPool.Length < 1) { throw new ArgumentException("(" + nameof(characterPool) + "." + nameof(characterPool.Length) + " < 1)"); } char[] randomstring = new char[length]; for (int i = 0; i < randomstring.Length; i++) { randomstring[i] = random.Choose(characterPool); } return(new string(randomstring)); }
public void Step() { Age++; if (Age <= Planet.Config.BushMaxGrowAge && Grown && _random.NextFloat() < Planet.Config.BushBerryGrowChance) { var fertileTiles = Planet.GetCross(Position) .Where(p => Planet.IsInBounds(p) && Planet.GetFertility(p) >= Planet.Config.BushBerryGrowCost).ToList(); if (fertileTiles.Count > 0 && Planet.SpendFertility(_random.Choose <Point>(fertileTiles), Planet.Config.BushBerryGrowCost)) { Berries++; } if (Berries > Planet.Config.BushMaxBerries) { Berries = Planet.Config.BushMaxBerries; Planet.TrySeedBushCross(Position); } } }
public RandomLoggerActor(string name, TimeSpan minPeriod, TimeSpan maxPeriod, params string[] logTopics) { _random = new Random(); _logTopics = logTopics; _logger = Context.WithIdentity(name); _minPeriod = minPeriod; _maxPeriod = maxPeriod; Receive <LogSomething>(msg => { var time = DateTime.UtcNow; var level = _random.Choose(Enum.GetValues(typeof(LogLevel)).Cast <LogLevel>()); var template = "{Guid} {Value} {Time} {TimeSinceLastMessage}"; var guid = Guid.NewGuid(); var value = _random.Next(); var timeDiff = (time - msg.Sent).TotalMilliseconds; _logger.Log( level, template, guid, value, time, timeDiff ); _mediator.Tell(new Publish("Logs", $"{guid} {value} {time} {timeDiff}")); ScheduleNext(); }); ScheduleNext(); }
public static Vector2 ShakeVector(this Random random) { return(new Vector2(random.Choose(shakeVectorOffsets), random.Choose(shakeVectorOffsets))); }
/// <summary> /// Generates the parameters for a planet /// </summary> private static ConfigNode GenerateBody(Planet planet, String folder, String referenceBody = "Sun", String systematicName = null) { String name = systematicName ?? Utility.GenerateName(); ConfigNode node = new ConfigNode("Body"); // Name if (planet != Kerbin) { node.AddValue("name", name); } else { node.AddValue("name", "Kerbin"); node.AddValue("cbNameLater", name); } // Random Main Menu Body node.AddValue("randomMainMenuBody", "" + (referenceBody == "Sun")); // Template ConfigNode template = new ConfigNode("Template"); node.AddConfigNode(template); if (planet != Kerbin) { if (planet.gas_giant) { template.AddValue("name", "Jool"); } else { template.AddValue("name", Utility.GetTemplate(planet.surface_pressure > 0.00001, false)); template.AddValue("removeAllPQSMods", "True"); if (planet.surface_pressure <= 0.00001) { template.AddValue("removeAtmosphere", "True"); } template.AddValue("removeOcean", "True"); // TODO: Handle atmospheres and ocean } } else { template.AddValue("name", "Kerbin"); template.AddValue("removePQSMods", "PQSLandControl, QuadEnhanceCoast, VertexHeightMap, VertexHeightNoiseVertHeightCurve2, VertexRidgedAltitudeCurve, VertexSimplexHeightAbsolute"); template.AddValue("removeAtmosphere", "True"); template.AddValue("removeOcean", "True"); } // Properties ConfigNode properties = new ConfigNode("Properties"); node.AddConfigNode(properties); properties.AddValue("radius", "" + (planet.radius * 100)); properties.AddValue("geeASL", "" + planet.surface_grav); properties.AddValue("rotationPeriod", "" + (planet.day * 60 * 60)); properties.AddValue("tidallyLocked", "" + planet.resonant_period); properties.AddValue("initialRotation", "" + Random.Next(0, 361)); properties.AddValue("albedo", "" + planet.albedo); properties.AddValue("timewarpAltitudeLimits", String.Join(" ", Templates.KerbinTimewarplimits.Select(i => (Int32)(i * ((planet.radius * 100) / 600000))))); //properties.AddValue("useTheInName", "False"); // Log Console.WriteLine($"Generated a planet named {name}. GasGiant: {planet.gas_giant}. Template: {template.GetValue("name")}"); // Color Color planetColor = Utility.GenerateColor(); // Orbit ConfigNode orbit = new ConfigNode("Orbit"); node.AddConfigNode(orbit); orbit.AddValue("referenceBody", referenceBody); orbit.AddValue("eccentricity", "" + planet.e); orbit.AddValue("semiMajorAxis", "" + (planet.a * 100 * Constants.KM_PER_AU)); orbit.AddValue("longitudeOfAscendingNode", "" + Random.Range(0, 181)); orbit.AddValue("meanAnomalyAtEpochD", "" + Random.Range(0, 181)); if (planet.gas_giant) { orbit.AddValue("color", Parser.WriteColor(Utility.AlterColor(planetColor))); } // Inclination orbit.AddValue("inclination", "" + Random.Range(-3, 5)); // Log Console.WriteLine($"Generated orbit around {referenceBody} for {name}"); // Scaled Space ConfigNode scaled = new ConfigNode("ScaledVersion"); node.AddConfigNode(scaled); // Material ConfigNode mat = new ConfigNode("Material"); scaled.AddConfigNode(mat); if (!planet.gas_giant) { mat.AddValue("texture", folder + "/PluginData/" + name + "_Texture.png"); mat.AddValue("normals", folder + "/PluginData/" + name + "_Normals.png"); } if (planet.gas_giant) { // Texture String[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + "/data/textures/"); String texture = Random.Choose(files); String textureName = Path.GetFileNameWithoutExtension(texture) + ".png"; Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/systems/" + folder + "/PluginData/"); File.Copy(texture, Directory.GetCurrentDirectory() + "/systems/" + folder + "/PluginData/" + textureName, true); mat.AddValue("texture", folder + "/PluginData/" + textureName); // Load the Image Color average; using (Bitmap image = new Bitmap(Directory.GetCurrentDirectory() + "/systems/" + folder + "/PluginData/" + textureName)) { average = Utility.GetAverageColor(image); } // Scale mat.AddValue("mainTexScale", (Random.Next(0, 2) == 1 ? 1 : -1) + "," + (Random.Next(0, 2) == 1 ? 1 : -1)); mat.AddValue("color", Parser.WriteColor(Utility.ReColor(Utility.AlterColor(planetColor), average))); ConfigNode gradient = new ConfigNode("Gradient"); mat.AddConfigNode(gradient); gradient.AddValue("0.0", Parser.WriteColor(Utility.AlterColor(planetColor))); gradient.AddValue("0.6", "0.0549,0.0784,0.141,1"); gradient.AddValue("1.0", "0.0196,0.0196,0.0196,1"); } // Log Console.WriteLine($"Generated scaled space for {name}"); // Atmosphere if (planet.surface_pressure > 0.00001) { ConfigNode atmosphere = new ConfigNode("Atmosphere"); node.AddConfigNode(atmosphere); atmosphere.AddValue("enabled", "True"); atmosphere.AddValue("oxygen", "" + Random.Boolean(10)); atmosphere.AddValue("atmosphereDepth", "" + (planet.radius * 100 * Random.Range(0.1, 0.16))); atmosphere.AddValue("atmosphereMolarMass", "" + (planet.molecule_weight / 1000)); atmosphere.AddValue("staticPressureASL", "" + ((planet.surface_pressure / 1000) * 101.324996948242)); atmosphere.AddValue("temperatureSeaLevel", "" + planet.surface_temp); if (planet.gas_giant) { atmosphere.AddValue("ambientColor", Parser.WriteColor(Utility.AlterColor(planetColor))); atmosphere.AddValue("lightColor", Parser.WriteColor(Utility.AlterColor(Utility.LightColor(planetColor)))); } GenerateAtmosphereCurves(ref atmosphere, planet.gas_giant ? "Jool" : Utility.GetTemplate(true, true)); // Log Console.WriteLine($"Generated atmosphere for {name}"); // Ocean if (!planet.gas_giant) { if (planet.surface_temp < planet.boil_point && (Random.Next(0, 100) < 35)) { ConfigNode ocean = new ConfigNode("Ocean"); node.AddConfigNode(ocean); ocean.AddValue("density", "" + planet.hydrosphere * (Random.NextDouble() * 2)); ocean.AddValue("minLevel", "1"); ocean.AddValue("maxLevel", "6"); ocean.AddValue("minDetailDistance", "8"); ocean.AddValue("maxQuadLengthsPerFrame", "0.03"); Color waterColor = Utility.GenerateColor(); ocean.AddValue("oceanColor", Parser.WriteColor(waterColor)); ConfigNode oceanmat = new ConfigNode("Material"); ocean.AddConfigNode(oceanmat); oceanmat.AddValue("colorFromSpace", Parser.WriteColor(waterColor)); oceanmat.AddValue("color", Parser.WriteColor(waterColor)); ConfigNode oceanfallbackmat = new ConfigNode("FallbackMaterial"); ocean.AddConfigNode(oceanfallbackmat); oceanfallbackmat.AddValue("colorFromSpace", Parser.WriteColor(waterColor)); oceanfallbackmat.AddValue("color", Parser.WriteColor(waterColor)); Console.WriteLine($"Generated ocean for {name}"); } } } // Rings :D if (planet.gas_giant && (Random.Next(0, 100) < 5)) { ConfigNode rings = new ConfigNode("Rings"); node.AddConfigNode(rings); ConfigNode ringDatatbase = Utility.Load("rings"); ConfigNode data = Random.Choose(ringDatatbase.nodes); RingPrefab def = Parser.CreateObjectFromConfigNode <RingPrefab>(data); foreach (RingPrefab.Ring r in def.Rings) { ConfigNode ring = new ConfigNode("Ring"); rings.AddConfigNode(ring); ring.AddValue("innerRadius", "" + (planet.radius * 0.1 * r.InnerRadius)); ring.AddValue("outerRadius", "" + (planet.radius * 0.1 * r.OuterRadius)); ring.AddValue("angle", "" + r.Angle); ring.AddValue("color", Parser.WriteColor(Utility.AlterColor(planetColor))); ring.AddValue("lockRotation", "" + r.LockRotation); ring.AddValue("unlit", "False"); } // Log Console.WriteLine($"Generated rings around {name}"); } // PQS if (!planet.gas_giant) { Color average; List <Color> biomes; GeneratePQS(ref node, name, folder, planet, planetColor, out average, out biomes); // Biomes ConfigNode bio = new ConfigNode("Biomes"); properties.AddConfigNode(bio); for (int i = 0; i < biomes.Count; i++) { ConfigNode biome = new ConfigNode("Biome"); bio.AddConfigNode(biome); biome.AddValue("name", "Biome " + (i + 1)); biome.AddValue("value", "1"); biome.AddValue("color", Parser.WriteColor(biomes[i])); } Console.WriteLine($"Generated biomes for {name}"); // Apply colors orbit.AddValue("color", Parser.WriteColor(Utility.AlterColor(average))); if (node.HasNode("Atmosphere")) { ConfigNode atmosphere = node.GetNode("Atmosphere"); atmosphere.AddValue("ambientColor", Parser.WriteColor(Utility.AlterColor(average))); atmosphere.AddValue("lightColor", Parser.WriteColor(Utility.AlterColor(Utility.LightColor(average)))); } ConfigNode gradient = new ConfigNode("Gradient"); mat.AddConfigNode(gradient); gradient.AddValue("0.0", Parser.WriteColor(Utility.AlterColor(average))); gradient.AddValue("0.6", "0.0549,0.0784,0.141,1"); gradient.AddValue("1.0", "0.0196,0.0196,0.0196,1"); } // Log Console.WriteLine($"Generation of body {name} finished!"); Console.WriteLine(); // Return return(node); }
/// <summary> /// Creates the ConfigNode for the SunBody /// </summary> private static ConfigNode GenerateSun(SolarSystem system, Boolean systematicNames) { // Create the Body node String name = Random.Next(0, 100) < (systematicNames ? 50 : 1) ? Utility.SystematicStarName() : Utility.GenerateStarName(); ConfigNode node = new ConfigNode("Body"); node.AddValue("name", "Sun"); node.AddValue("cbNameLater", name); // Template ConfigNode template = new ConfigNode("Template"); node.AddConfigNode(template); template.AddValue("name", "Sun"); // Properties ConfigNode properties = new ConfigNode("Properties"); node.AddConfigNode(properties); properties.AddValue("radius", "" + (system.stellar_radius_ratio * 261600000)); properties.AddValue("mass", "" + (system.stellar_mass_ratio * 1.75656696858329E+28)); properties.AddValue("timewarpAltitudeLimits", String.Join(" ", Templates.SunTimewarplimits.Select(i => (Int32)(i * system .stellar_radius_ratio )))); //properties.AddValue("useTheInName", "False"); // Log Console.WriteLine($"Generated root body named {name}"); // Scaled Space ConfigNode scaled = new ConfigNode("ScaledVersion"); node.AddConfigNode(scaled); // Load database stuff ConfigNode starDatabase = Utility.Load("stars"); ConfigNode data = starDatabase.GetNode(system.type.star_class); data = Random.Choose(data.nodes); StarPrefab star = Parser.CreateObjectFromConfigNode <StarPrefab>(data); // Materials ConfigNode mat = new ConfigNode("Material"); scaled.AddConfigNode(mat); mat.AddValue("emitColor0", Parser.WriteColor(star.Material.EmitColor0)); mat.AddValue("emitColor1", Parser.WriteColor(star.Material.EmitColor1)); mat.AddValue("sunspotPower", "" + star.Material.SunspotPower); mat.AddValue("sunspotColor", Parser.WriteColor(star.Material.SunspotColor)); mat.AddValue("rimColor", Parser.WriteColor(star.Material.RimColor)); mat.AddValue("rimPower", "" + star.Material.RimPower); mat.AddValue("rimBlend", "" + star.Material.RimBlend); // Light Node ConfigNode light = new ConfigNode("Light"); scaled.AddConfigNode(light); light.AddValue("sunlightColor", Parser.WriteColor(star.Light.SunlightColor)); light.AddValue("sunlightIntensity", "" + star.Light.SunlightIntensity); light.AddValue("sunlightShadowStrength", "" + star.Light.SunlightShadowStrength); light.AddValue("scaledSunlightColor", Parser.WriteColor(star.Light.ScaledSunlightColor)); light.AddValue("scaledSunlightIntensity", "" + star.Light.ScaledSunlightIntensity); light.AddValue("IVASunColor", Parser.WriteColor(star.Light.IvaSunColor)); light.AddValue("IVASunIntensity", "" + star.Light.IvaSunIntensity); light.AddValue("ambientLightColor", Parser.WriteColor(star.Light.AmbientLightColor)); light.AddValue("sunLensFlareColor", Parser.WriteColor(star.Light.SunLensFlareColor)); light.AddValue("givesOffLight", "" + star.Light.GivesOffLight); light.AddValue("luminosity", "" + (system.stellar_luminosity_ratio * 1360)); // TODO: Coronas // Log Console.WriteLine($"Generated scaled space for {name}"); Console.WriteLine(); // Return it return(node); }
public override Expression Apply(Expression expression, Random random) { var i = random.Next(_expressionFinder.FoundExpressions.Count); var expressionToInject = _expressionFinder.FoundExpressions[i]; var typeArgument = expressionToInject.Type.GetGenericArguments()[0]; var prm = Expression.Parameter(typeArgument, "prm"); var candidateExpressions = new List <Expression> { Expression.Constant(random.Choose(new List <bool> { true, false })), }; if (typeArgument == typeof(bool)) { candidateExpressions.Add(prm); } var properties = typeArgument.GetProperties().Where(p => !p.GetMethod.IsStatic).ToList(); properties = FilterPropertyInfos(typeArgument, properties); var boolProperties = properties.Where(p => p.PropertyType == typeof(bool)).ToList(); if (boolProperties.Any()) { candidateExpressions.Add(Expression.Property(prm, random.Choose(boolProperties))); } // compare two properties var propertiesOfTheSameType = properties.GroupBy(p => p.PropertyType).Where(g => g.Count() > 1).ToList(); if (propertiesOfTheSameType.Any()) { var propertyGroup = random.Choose(propertiesOfTheSameType).ToList(); var firstProperty = random.Choose(propertyGroup); var secondProperty = random.Choose(propertyGroup.Where(p => p != firstProperty).ToList()); candidateExpressions.Add(Expression.NotEqual(Expression.Property(prm, firstProperty), Expression.Property(prm, secondProperty))); } // compare property to constant if (properties.Any()) { var property = random.Choose(properties); candidateExpressions.Add( Expression.NotEqual( Expression.Property(prm, property), Expression.Default(property.PropertyType))); } if (IsEntityType(typeArgument)) { var entityType = Context.Model.FindEntityType(typeArgument); var navigations = entityType.GetNavigations().ToList(); var collectionNavigations = navigations.Where(n => n.IsCollection()).ToList(); var collectionNavigation = random.Choose(collectionNavigations); if (collectionNavigation != null) { var any = EnumerableAnyMethodInfo.MakeGenericMethod(collectionNavigation.ForeignKey.DeclaringEntityType.ClrType); // collection.Any() candidateExpressions.Add( Expression.Call( any, Expression.Property(prm, collectionNavigation.PropertyInfo))); } var navigation = random.Choose(navigations); } var lambdaBody = random.Choose(candidateExpressions); var negated = random.Next(6) > 3; if (negated) { lambdaBody = Expression.Not(lambdaBody); } var where = WhereMethodInfo.MakeGenericMethod(typeArgument); var lambda = Expression.Lambda(lambdaBody, prm); var injector = new ExpressionInjector(expressionToInject, e => Expression.Call(where, e, lambda)); return(injector.Visit(expression)); }
public IntelMissionDesc Choose(Random random) { return(this.ByID(random.Choose <IntelMission>((IEnumerable <IntelMission>) this._byID.Keys))); }
/// <summary> /// Chooses an item in the list at random. /// </summary> /// <typeparam name="T">The element type of the collection.</typeparam> /// <param name="random">The random number generator.</param> /// <param name="source">The source collection to get elements from.</param> /// <param name="defaultValue">The default value to return when the collection is empty.</param> /// <returns> /// The choice of Steins;Gate, or the <paramref name="defaultValue"/> if the collection is empty. /// </returns> /// /// <exception cref="ArgumentNullException"> /// <paramref name="random"/> or <paramref name="source"/> is null. /// </exception> public static T Choose <T>(this Random random, IEnumerable <T> source, T defaultValue = default(T)) { return(random.Choose(source.ToList())); }
public KeyValuePair <int, int>?GetLoot(out Item special) { special = null; if (!Geode.IsGeode) { return(null); } try { if (RNG.NextDouble() <= 0.1 && Game1.player.team.SpecialOrderRuleActive("DROP_QI_BEANS")) { int count = RNG.NextDouble() < Config.Geode.ManyBeansOdds ? Config.Geode.ManyBeansCount : 1; return(new KeyValuePair <int, int>(ID_QI_BEAN, count)); } if (Geode.ID == ID_GOLDEN_COCONUT) { if (RNG.NextDouble() < Config.Geode.CoconutHatOdds && !Game1.player.hasOrWillReceiveMail("goldenCoconutHat")) { Game1.player.mailReceived.Add("goldenCoconutHat"); special = new StardewValley.Objects.Hat(ID_GOLDEN_HELMET); return(null); } return(RNG.Choose(GOLDEN_COCONUT_DROPS_LIST)); } if (Geode.ID == ID_ARTIFACT_TROVE || RNG.NextDouble() < Config.Geode.TreasureOdds) { Log.Trace("Treasure code path chosen"); return(GetGeodeTreasure()); } Log.Trace("Mineral code path chosen"); int amount = (RNG.Next(3) * 2) + 1; if (RNG.NextDouble() < Config.Geode.TenMineralsOdds) { amount = 10; } if (RNG.NextDouble() < Config.Geode.TwentyMineralsOdds) { amount = 20; } if (RNG.NextDouble() >= Config.Geode.OreCoalOdds) { switch (RNG.Next(4)) { case 0: case 1: return(new KeyValuePair <int, int>(ID_STONE, amount)); case 2: return(new KeyValuePair <int, int>(ID_CLAY, 1)); case 3: { int parentSheetIndex = Geode.ID switch { ID_OMNI_GEODE => ID_FIRE_QUARTZ + (RNG.Next(3) * 2), ID_FROZEN_GEODE => ID_FROZEN_TEAR, ID_GEODE => ID_EARTH_CRYSTAL, _ => ID_FIRE_QUARTZ // Magma Geode }; return(new KeyValuePair <int, int>(parentSheetIndex, 1)); } } } switch (Geode.ID) { case ID_GEODE: return((RNG.Next(3)) switch { 0 => new KeyValuePair <int, int>(ID_COPPER_ORE, amount), 1 => new KeyValuePair <int, int>((Game1.player.deepestMineLevel > 25) ? ID_IRON_ORE : ID_COPPER_ORE, amount), // 2 _ => new KeyValuePair <int, int>(ID_COAL, amount) }); case ID_FROZEN_GEODE: return((RNG.Next(4)) switch { 0 => new KeyValuePair <int, int>(ID_COPPER_ORE, amount), 1 => new KeyValuePair <int, int>(ID_IRON_ORE, amount), 2 => new KeyValuePair <int, int>(ID_COAL, amount), // 3 _ => new KeyValuePair <int, int>((Game1.player.deepestMineLevel > 75) ? ID_GOLD_ORE : ID_IRON_ORE, amount) });
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); }