Example #1
0
        private void ClearComponents(Item item)
        {
            if (item is BaseAddon)
            {
                BaseAddon addon = (BaseAddon)item;

                foreach (AddonComponent c in addon.Components)
                {
                    c.Addon = null;
                    c.Delete();
                }

                addon.Components.Clear();
            }
            else if (item is BaseAddonContainer)
            {
                BaseAddonContainer addon = (BaseAddonContainer)item;

                foreach (AddonContainerComponent c in addon.Components)
                {
                    c.Addon = null;
                    c.Delete();
                }

                addon.Components.Clear();
            }
        }
Example #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_Addon  = reader.ReadItem() as BaseAddonContainer;
            m_Offset = reader.ReadPoint3D();

            if (m_Addon != null)
            {
                m_Addon.OnComponentLoaded(this);
            }

            AddonComponent.ApplyLightTo(this);
        }
            protected override void OnTarget(Mobile from, object targeted)
            {
                IPoint3D p   = targeted as IPoint3D;
                Map      map = from.Map;

                if (p == null || map == null || m_Deed.Deleted)
                {
                    return;
                }

                if (m_Deed.IsChildOf(from.Backpack))
                {
                    BaseAddonContainer addon = m_Deed.Addon;
                    addon.Resource = m_Deed.Resource;

                    UltimaOnline.Spells.SpellHelper.GetSurfaceTop(ref p);

                    BaseHouse house = null;

                    AddonFitResult res = addon.CouldFit(p, map, from, ref house);

                    if (res == AddonFitResult.Valid)
                    {
                        addon.MoveToWorld(new Point3D(p), map);
                    }
                    else if (res == AddonFitResult.Blocked)
                    {
                        from.SendLocalizedMessage(500269); // You cannot build that there.
                    }
                    else if (res == AddonFitResult.NotInHouse)
                    {
                        from.SendLocalizedMessage(500274); // You can only place this in a house that you own!
                    }
                    else if (res == AddonFitResult.DoorsNotClosed)
                    {
                        from.SendMessage("You must close all house doors before placing this.");
                    }
                    else if (res == AddonFitResult.DoorTooClose)
                    {
                        from.SendLocalizedMessage(500271); // You cannot build near the door.
                    }
                    else if (res == AddonFitResult.NoWall)
                    {
                        from.SendLocalizedMessage(500268); // This object needs to be mounted on something.
                    }
                    if (res == AddonFitResult.Valid)
                    {
                        m_Deed.Delete();
                        house.Addons.Add(addon);
                        house.AddSecure(from, addon);
                    }
                    else
                    {
                        addon.Delete();
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                }
            }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Item && InteriorDecorator.CheckUse(m_Decorator, from))
                {
                    BaseHouse house = BaseHouse.FindHouseAt(from);
                    Item      item  = (Item)targeted;

                    bool isDecorableComponent = false;

                    if (item is AddonComponent || item is AddonContainerComponent || item is BaseAddonContainer)
                    {
                        object addon = null;
                        int    count = 0;

                        if (item is AddonComponent)
                        {
                            AddonComponent component = (AddonComponent)item;
                            count = component.Addon.Components.Count;
                            addon = component.Addon;
                        }
                        else if (item is AddonContainerComponent)
                        {
                            AddonContainerComponent component = (AddonContainerComponent)item;
                            count = component.Addon.Components.Count;
                            addon = component.Addon;
                        }
                        else if (item is BaseAddonContainer)
                        {
                            BaseAddonContainer container = (BaseAddonContainer)item;
                            count = container.Components.Count;
                            addon = container;
                        }

                        if (count == 1 && Core.SE)
                        {
                            isDecorableComponent = true;
                        }

                        if (m_Decorator.Command == DecorateCommand.Turn)
                        {
                            FlipableAddonAttribute[] attributes = (FlipableAddonAttribute[])addon.GetType().GetCustomAttributes(typeof(FlipableAddonAttribute), false);

                            if (attributes.Length > 0)
                            {
                                isDecorableComponent = true;
                            }
                        }
                    }

                    if (house == null || !house.IsCoOwner(from))
                    {
                        from.SendLocalizedMessage(502092); // You must be in your house to do this.
                    }
                    else if (item.Parent != null || !house.IsInside(item))
                    {
                        from.SendLocalizedMessage(1042270); // That is not in your house.
                    }
                    else if (!house.IsLockedDown(item) && !house.IsSecure(item) && !isDecorableComponent)
                    {
                        if (item is AddonComponent && m_Decorator.Command == DecorateCommand.Up)
                        {
                            from.SendLocalizedMessage(1042274); // You cannot raise it up any higher.
                        }
                        else if (item is AddonComponent && m_Decorator.Command == DecorateCommand.Down)
                        {
                            from.SendLocalizedMessage(1042275); // You cannot lower it down any further.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1042271); // That is not locked down.
                        }
                    }
                    else if (item is VendorRentalContract)
                    {
                        from.SendLocalizedMessage(1062491); // You cannot use the house decorator on that object.
                    }
                    else if (item.TotalWeight + item.PileWeight > 100)
                    {
                        from.SendLocalizedMessage(1042272); // That is too heavy.
                    }
                    else
                    {
                        switch (m_Decorator.Command)
                        {
                        case DecorateCommand.Up: Up(item, from); break;

                        case DecorateCommand.Down: Down(item, from); break;

                        case DecorateCommand.Turn: Turn(item, from); break;
                        }
                    }
                }

                from.Target = new InternalTarget(m_Decorator);
            }