Exemple #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();
            }
        }
            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;

                    Server.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);
                    }
                    else
                    {
                        addon.Delete();
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1042001);                       // That must be in your pack for you to use it.
                }
            }
Exemple #3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            m_SecondContainer = reader.ReadItem() as BaseAddonContainer;
            m_Offset          = reader.ReadPoint3D();
        }
        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 );
        }
        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);
        }
Exemple #6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Item && InteriorDecorator.CheckUse(this.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 (this.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 && this.m_Decorator.Command == DecorateCommand.Up)
                        {
                            from.SendLocalizedMessage(1042274); // You cannot raise it up any higher.
                        }
                        else if (item is AddonComponent && this.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 (this.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(this.m_Decorator);
            }
Exemple #7
0
            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;

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

                    BaseHouse house = null;

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

                    bool isMaxSecureReached = false;
                    //Check if secure slot is already full
                    if (house != null)
                    {
                        if (!house.IsAosRules && house.SecureCount >= house.MaxSecures)
                        {
                            // The maximum number of secure items has been reached :
                            from.SendLocalizedMessage(1008142, true, house.MaxSecures.ToString());
                            isMaxSecureReached = true;
                        }
                        else if (house.IsAosRules ? !house.CheckAosLockdowns(1) : ((house.LockDownCount + 125) >= house.MaxLockDowns))
                        {
                            from.SendLocalizedMessage(1005379); // That would exceed the maximum lock down limit for this house
                            isMaxSecureReached = true;
                        }
                        else if (house.IsAosRules && !house.CheckAosStorage(addon.TotalItems))
                        {
                            from.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house.
                            isMaxSecureReached = true;
                        }
                    }

                    if (!isMaxSecureReached)
                    {
                        switch (res)
                        {
                        case AddonFitResult.Valid:
                            addon.MoveToWorld(new Point3D(p), map);
                            break;

                        case AddonFitResult.Blocked:
                            @from.SendLocalizedMessage(500269);     // You cannot build that there.
                            break;

                        case AddonFitResult.NotInHouse:
                            @from.SendLocalizedMessage(500274);     // You can only place this in a house that you own!
                            break;

                        case AddonFitResult.DoorsNotClosed:
                            @from.SendMessage("You must close all house doors before placing this.");
                            break;

                        case AddonFitResult.DoorTooClose:
                            @from.SendLocalizedMessage(500271);     // You cannot build near the door.
                            break;

                        case AddonFitResult.NoWall:
                            @from.SendLocalizedMessage(500268);     // This object needs to be mounted on something.
                            break;
                        }
                    }


                    if (res == AddonFitResult.Valid && house != null && !isMaxSecureReached)
                    {
                        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.
                }
            }
Exemple #8
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Decorator.Command == DecorateCommand.GetHue)
                {
                    int hue = 0;

                    if (targeted is Item)
                    {
                        hue = ((Item)targeted).Hue;
                    }
                    else if (targeted is Mobile)
                    {
                        hue = ((Mobile)targeted).Hue;
                    }
                    else
                    {
                        from.Target = new InternalTarget(m_Decorator);
                        return;
                    }

                    from.SendLocalizedMessage(1158862, string.Format("{0}", hue)); // That object is hue ~1_HUE~
                }
                else if (targeted is Item && CheckUse(m_Decorator, from))
                {
                    BaseHouse house = BaseHouse.FindHouseAt(from);
                    Item      item  = (Item)targeted;

                    bool isDecorableComponent = false;

                    if (m_Decorator.Command == DecorateCommand.Turn && IsSpecialTypes(item))
                    {
                        isDecorableComponent = true;
                    }
                    else if (item is AddonComponent || item is AddonContainerComponent || item is BaseAddonContainer || item is TrophyAddon)
                    {
                        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)
                        {
                            isDecorableComponent = true;
                        }

                        if (item is TrophyAddon)
                        {
                            isDecorableComponent = true;
                        }

                        if (item is EnormousVenusFlytrapAddon)
                        {
                            isDecorableComponent = true;
                        }

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

                                if (attributes.Length > 0)
                                {
                                    isDecorableComponent = true;
                                }
                            }
                        }
                    }
                    else if (item is Banner && m_Decorator.Command != DecorateCommand.Turn)
                    {
                        isDecorableComponent = true;
                    }

                    if (house == null || !house.IsCoOwner(from))
                    {
                        from.SendLocalizedMessage(502092); // You must be in your house to do
                    }
                    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.Turn)
                        {
                            from.SendLocalizedMessage(1042273); // You cannot turn that.
                        }
                        else 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
                    {
                        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);
            }