Beispiel #1
0
        /// <summary>Mines this asteroid belt for ore</summary>
        /// <param name="ship">Ship to load ore onto</param>
        /// <returns>True if the ship has completed its mining operation (cargo hold is full)</returns>
        public bool Mine(Ship ship)
        {
            AssertShipInRange(ship, "mine this asteroid belt");

            var ore = new Ore();

            var oreQuantity = (uint) Math.Floor(ship.CargoHoldRemaining/ore.SizePerUnit);
            ore.Quantity = Min(Rand.Next(Richness / 2, Richness), oreQuantity, AmountRemaining);
            ore.Owner = ship.Owner;

            ship.AddCargo(ore);
            AmountRemaining -= ore.Quantity;

            Universe.EventPump.RaiseEvent(ship, EventType.ShipCargo, "Mined {0:n0} ore from {1}", ore.Quantity, Name);
            return (ship.CargoHoldRemaining < ore.SizePerUnit);
        }
Beispiel #2
0
        /// <summary>Load refined ore onto a ship</summary>
        /// <param name="ship"></param>
        /// <returns>True if the ship has picked up all the ore it can</returns>
        public bool LoadRefinedOre(Ship ship)
        {
            AssertShipInRange(ship, "load refined ore from this refinery");

            if (RefinedOre != 0)
            {
                var refinedOre = new RefinedOre();

                uint maxOreCanCarry = (refinedOre.SizePerUnit == 0d) ? RefinedOre : Math.Min((uint) Math.Floor(ship.CargoHoldRemaining/refinedOre.SizePerUnit), RefinedOre);

                RefinedOre -= maxOreCanCarry;

                refinedOre.Quantity = maxOreCanCarry;
                refinedOre.Owner = Owner;

                ship.AddCargo(refinedOre);

                Universe.EventPump.RaiseEvent(ship, EventType.ShipCargo, "Loaded {0:n0} refined ore from {1}", refinedOre.Quantity, Name);

                return (refinedOre.SizePerUnit == 0d) || (ship.CargoHoldRemaining < refinedOre.SizePerUnit);
            }

            return false;
        }