Ejemplo n.º 1
0
        public void CollidedMineral(Mineral mineral, World world, int materialID, SharedVisuals sharedVisuals)
        {
            //TODO: Let the user specify thresholds for which minerals to take ($, density, mass, type).  Also give an option to be less picky if near empty
            //TODO: Let the user specify thresholds for swapping lesser minerals for better ones
            //TODO: Add a portion

            if (base.CargoBays == null)
            {
                return;
            }
            else if (mineral.IsDisposed)
            {
                return;
            }

            var quantity = base.CargoBays.CargoVolume;

            if (quantity.Item2 - quantity.Item1 < mineral.VolumeInCubicMeters)
            {
                // The cargo bays are too full
                return;
            }

            // Save location in case it needs to be brought back
            Point3D position = mineral.PositionWorld;

            // Convert it to cargo
            Cargo_Mineral cargo = new Cargo_Mineral(mineral.MineralType, mineral.Density, mineral.VolumeInCubicMeters);

            // Try to add this to the cargo bays - the total volume may be enough, but the mineral may be too large for any
            // one cargo bay (or some of the cargo bays could be destroyed)
            if (base.CargoBays.Add(cargo))
            {
                // Finish removing it from the real world
                _map.RemoveItem(mineral, true);
                mineral.PhysicsBody.Dispose();

                this.ShouldRecalcMass_Large = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This will take the mineral if it fits
        /// NOTE: This method removes the mineral from the map
        /// </summary>
        private void CollidedMineral_ORIG(Mineral mineral, World world, int materialID, SharedVisuals sharedVisuals)
        {
            //TODO: Let the user specify thresholds for which minerals to take ($, density, mass, type).  Also give an option to be less picky if near empty
            //TODO: Let the user specify thresholds for swapping lesser minerals for better ones

            if (base.CargoBays == null)
            {
                return;
            }
            else if (mineral.IsDisposed)
            {
                return;
            }

            var quantity = base.CargoBays.CargoVolume;

            if (quantity.Item2 - quantity.Item1 < mineral.VolumeInCubicMeters)
            {
                // The cargo bays are too full
                return;
            }

            // Save location in case it needs to be brought back
            Point3D position = mineral.PositionWorld;

            // Try to pop this out of the map
            if (!_map.RemoveItem(mineral, true))
            {
                // It's already gone
                return;
            }

            // Convert it to cargo
            Cargo_Mineral cargo = new Cargo_Mineral(mineral.MineralType, mineral.Density, mineral.VolumeInCubicMeters);

            // Try to add this to the cargo bays - the total volume may be enough, but the mineral may be too large for any
            // one cargo bay
            if (base.CargoBays.Add(cargo))
            {
                // Finish removing it from the real world
                mineral.PhysicsBody.Dispose();

                this.ShouldRecalcMass_Large = true;
            }
            else
            {
                // It didn't fit, give it back to the map
                Mineral clone = new Mineral(mineral.MineralType, position, mineral.VolumeInCubicMeters, world, materialID, sharedVisuals, ItemOptionsAstMin2D.MINERAL_DENSITYMULT, mineral.Scale, mineral.Credits);
                _map.AddItem(clone);
            }
        }