/// <summary> /// This should get called on an infrequent basis, and randomize the available inventory /// </summary> public void RandomizeInventory(bool completelyNew) { RandomizePrices(); if (completelyNew) { this.StationInventory.Clear(); } List <Inventory> inventory = new List <Inventory>(); // Ships inventory.AddRange(AdjustInventory( this.StationInventory.Where(o => o.Ship != null), 3, () => { DefaultShipType shipType = GetRandomItemChance(_shipChances).ShipType; ShipDNA shipDNA = DefaultShips.GetDNA(shipType); return(new Inventory(shipDNA, StaticRandom.NextDouble(.5, 2))); })); // Parts inventory.AddRange(AdjustInventory( this.StationInventory.Where(o => o.Part != null), 4, () => { PartCreateChance partType = GetRandomItemChance(_partChances); ShipPartDNA partDNA = GetRandomPart(partType); //TODO: Have a chance to make 2 if it's something that could come in pairs (thruster, gun, etc) return(new Inventory(partDNA)); })); // Minerals inventory.AddRange(AdjustInventory( this.StationInventory.Where(o => o.Mineral != null), 4, () => { MineralType type = UtilityCore.GetRandomEnum <MineralType>(); double volume = StaticRandom.NextPercent(ItemOptionsAstMin2D.MINERAL_AVGVOLUME, 2); return(new Inventory(ItemOptionsAstMin2D.GetMineral(type, volume))); })); this.StationInventory.Clear(); this.StationInventory.AddRange(inventory); _inventoryRandomizeCountdown = StaticRandom.NextDouble(3 * 60, 8 * 60); }
private void StoreInStation(Cargo cargo) { Inventory inventory; if (cargo is Cargo_Mineral) { Cargo_Mineral cargoMineral = (Cargo_Mineral)cargo; MineralDNA mineralDNA = ItemOptionsAstMin2D.GetMineral(cargoMineral.MineralType, cargoMineral.Volume); inventory = new Inventory(mineralDNA); } else if (cargo is Cargo_ShipPart) { Cargo_ShipPart cargoPart = (Cargo_ShipPart)cargo; inventory = new Inventory(cargoPart.PartDNA); } else { throw new ApplicationException("Unknown type of cargo: " + cargo.GetType().ToString()); } _spaceDock.AddInventory(inventory, true); }