예제 #1
0
파일: Seed.cs 프로젝트: pallop/Servuo
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Seed.Deleted)
                {
                    return;
                }

                if (!m_Seed.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1042664);                       // You must have the object in your backpack to use it.
                    return;
                }

                if (targeted is PlantItem)
                {
                    PlantItem plant = (PlantItem)targeted;

                    plant.PlantSeed(from, m_Seed);
                }
                else if (targeted is Server.Items.GardenAddonComponent)
                {
                    Server.Items.GardenAddonComponent addon = (Server.Items.GardenAddonComponent)targeted;

                    if (addon.Plant != null)
                    {
                        from.SendLocalizedMessage(1150367); // This plot already has a plant!
                    }
                    else
                    {
                        Server.Multis.BaseHouse house = Server.Multis.BaseHouse.FindHouseAt(addon);

                        if (house != null)
                        {
                            int fertileDirt = from.Backpack == null ? 0 : from.Backpack.GetAmount(typeof(FertileDirt), false);

                            if (fertileDirt > 0)
                            {
                                from.SendGump(new FertileDirtGump(m_Seed, fertileDirt, addon));
                            }
                            else
                            {
                                RaisedGardenPlantItem dirt = new RaisedGardenPlantItem();
                                dirt.MoveToWorld(new Point3D(addon.X, addon.Y, addon.Z + 5), addon.Map);

                                dirt.PlantSeed(from, m_Seed);
                                addon.Plant    = dirt;
                                dirt.Component = addon;
                            }
                        }
                    }
                }
                else if (targeted is Item)
                {
                    ((Item)targeted).LabelTo(from, 1061919); // You must use a seed on a bowl of dirt!
                }
                else
                {
                    from.SendLocalizedMessage(1061919); // You must use a seed on a bowl of dirt!
                }
            }
예제 #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
            m_Component = reader.ReadItem() as GardenAddonComponent;
        }