Ejemplo n.º 1
0
        public bool Harvest(Mobile from)
        {
            if (!SpecialAbilities.Exists(from))
            {
                return(false);
            }
            if (from.Backpack == null)
            {
                return(false);
            }

            if (m_PlantType != null && from.Backpack != null)
            {
                List <Item> m_Items = Plants.OnPlantHarvest(m_PlantType);

                int totalItems  = 0;
                int totalWeight = 0;

                foreach (Item item in m_Items)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    if (item.Deleted)
                    {
                        continue;
                    }

                    totalItems  += item.TotalItems;
                    totalWeight += item.TotalWeight;
                }

                bool delete = false;

                if (from.Backpack.TotalItems + totalItems > from.Backpack.MaxItems)
                {
                    from.SendMessage("Your backpack does not have enough space for that.");
                    delete = true;
                }

                if (from.Backpack.TotalWeight + totalWeight > from.Backpack.MaxWeight)
                {
                    from.SendMessage("Your backpack would not be able to handle that much weight.");
                    delete = true;
                }

                if (delete)
                {
                    Queue m_Queue = new Queue();

                    foreach (Item item in m_Items)
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        if (item.Deleted)
                        {
                            continue;
                        }

                        m_Queue.Enqueue(item);
                    }

                    while (m_Queue.Count > 0)
                    {
                        Item item = (Item)m_Queue.Dequeue();

                        item.Delete();
                    }

                    return(false);
                }

                foreach (Item item in m_Items)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    if (item.Deleted)
                    {
                        continue;
                    }

                    from.Backpack.DropItem(item);
                }

                SeedType  = null;
                PlantType = null;

                ReadyForHarvest = false;

                GrowthValue = 0;
                WaterValue  = 0;
                SoilValue   = 0;
                HeatValue   = 0;

                from.PlaySound(0x5AE);
                from.SendMessage("You harvest the plant.");

                TimedStatic dirt = new TimedStatic(Utility.RandomList(7681, 7682), 3);
                dirt.Name = "dirt";
                dirt.MoveToWorld(from.Location, from.Map);

                int dirtCount = Utility.RandomMinMax(2, 3);
                for (int a = 0; a < dirtCount; a++)
                {
                    Point3D newLocation = SpecialAbilities.GetRandomAdjustedLocation(from.Location, from.Map, true, 1, false);

                    dirt      = new TimedStatic(Utility.RandomList(7681, 7682), 3);
                    dirt.Name = "dirt";
                    dirt.MoveToWorld(newLocation, from.Map);
                }

                return(true);
            }

            return(false);
        }