CreateItem() public method

public CreateItem ( Mobile from, Type type, Type typeRes, BaseTool tool, CraftItem realCraftItem ) : void
from Mobile
type Type
typeRes Type
tool BaseTool
realCraftItem CraftItem
return void
Ejemplo n.º 1
0
        public void CraftItem(CraftItem item)
        {
            object num = m_CraftSystem.CanCraft(m_From, m_Tool, item.ItemType);

            if ((num is int && (int)num > 0) || (num is string && !string.IsNullOrWhiteSpace((string)num)))
            {
                m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
            }
            else
            {
                Type type = null;

                CraftContext context = m_CraftSystem.GetContext(m_From);

                if (context != null)
                {
                    CraftSubResCol res      = (item.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                    int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
            }
        }
Ejemplo n.º 2
0
        public void CraftItem(CraftItem item)
        {
            int num = m_CraftSystem.CanCraft(m_From, m_Tool, item.ItemType);

            if (num > 0)
            {
                m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
            }
            else
            {
                Type type = null;

                CraftContext context = m_CraftSystem.GetContext(m_From);

                if (context != null)
                {
                    CraftSubResCol res      = (item.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                    int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
            }
        }
Ejemplo n.º 3
0
        public static void CraftItem(CraftItem item, CraftSystem system, Mobile from, BaseTool tool)
        {
            int          num     = system.CanCraft(from, tool, item.ItemType);
            CraftContext context = system.GetContext(from);

            if (context == null)
            {
                return;
            }

            if (num > 0)
            {
                context.Making = null;

                from.SendGump(new CraftGump(from, system, tool, num));
            }
            else
            {
                context.Making = item;

                Type type = null;

                CraftSubResCol res      = (item.UseSubRes2 ? system.CraftSubRes2 : system.CraftSubRes);
                int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                if (resIndex >= 0 && resIndex < res.Count)
                {
                    type = res.GetAt(resIndex).ItemType;
                }

                system.CreateItem(from, item.ItemType, type, tool, item);
            }
        }
Ejemplo n.º 4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0:     // Back Button
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
                break;
            }

            case 1:     // Make Button
            {
                if (m_CraftItem.TryCraft != null)
                {
                    m_CraftItem.TryCraft(m_From, m_CraftItem, m_Tool);
                    return;
                }

                int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);

                if (num > 0)
                {
                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
                }
                else
                {
                    Type type = null;

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    if (context != null)
                    {
                        CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                        int            resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                        if (resIndex > -1)
                        {
                            type = res.GetAt(resIndex).ItemType;
                        }
                    }

                    m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem);
                }
                break;
            }

            case 2:                                   //Make Number
                m_From.Prompt = new MakeNumberCraftPrompt(m_From, m_CraftSystem, m_CraftItem, m_Tool);
                m_From.SendLocalizedMessage(1112576); //Please type the amount you wish to create(1 - 100): <Escape to cancel>
                break;

            case 3:     //Make Max
                AutoCraftTimer.EndTimer(m_From);
                new AutoCraftTimer(m_From, m_CraftSystem, m_CraftItem, m_Tool, 9999, TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0), TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0));
                break;
            }
        }
Ejemplo n.º 5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            //Back
            if (info.ButtonID == 0)
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
            }

            //Guide
            else if (info.ButtonID == 1000)
            {
                string url = "http://www.uoancorp.com";
                sender.Mobile.LaunchBrowser(url);

                m_From.SendGump(new CraftGumpItem(m_From, m_CraftSystem, m_CraftItem, m_Tool));
                return;
            }

            //Make
            else
            {
                int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);

                if (num > 0)
                {
                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
                }

                else
                {
                    Type type = null;

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    if (context != null)
                    {
                        CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                        int            resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                        if (resIndex > -1)
                        {
                            type = res.GetAt(resIndex).ItemType;
                        }
                    }

                    m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem);
                }
            }
        }
Ejemplo n.º 6
0
        private void CraftItem()
        {
            if (m_From.HasGump(typeof(CraftGump)))
            {
                m_From.CloseGump(typeof(CraftGump));
            }

            if (m_From.HasGump(typeof(CraftGumpItem)))
            {
                m_From.CloseGump(typeof(CraftGumpItem));
            }

            m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, m_TypeRes, m_Tool, m_CraftItem);
        }
Ejemplo n.º 7
0
        private void CraftItem()
        {
            if (m_From.HasGump(typeof(CraftGump)))
            {
                m_From.CloseGump(typeof(CraftGump));
            }

            if (m_From.HasGump(typeof(CraftGumpItem)))
            {
                m_From.CloseGump(typeof(CraftGumpItem));
            }

            m_Attempts++;

            if (m_CraftItem.TryCraft != null)
            {
                m_CraftItem.TryCraft(m_From, m_CraftItem, m_Tool);
            }
            else
            {
                m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, m_TypeRes, m_Tool, m_CraftItem);
            }
        }
Ejemplo n.º 8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            // Back Button
            if (info.ButtonID == 0)
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
            }
            else             // Make Button
            {
                int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);

                if (num > 0)
                {
                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
                }
                else
                {
                    Type type = null;

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    if (context != null)
                    {
                        CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                        int            resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                        if (resIndex > -1)
                        {
                            type = res.GetAt(resIndex).ItemType;
                        }
                    }

                    m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem);
                }
            }
        }
Ejemplo n.º 9
0
        public async void CraftItem(CraftItem item)
        {
            var num = CraftSystem.CanCraft(From, Tool, item.ItemType);

            if (num > 0)
            {
                From.SendGump(new CraftGump(From, CraftSystem, Tool, num));
            }
            else if (From.NextSkillTime > Core.TickCount)
            {
                From.SendGump(new CraftGump(From, CraftSystem, Tool, 1045157)); // You must wait to perform another action.
            }
            else
            {
                Type type = null;

                CraftContext context = CraftSystem.GetContext(From);

                if (context != null)
                {
                    CraftSubResCol res      = item.UseSubRes2 ? CraftSystem.CraftSubRes2 : CraftSystem.CraftSubRes;
                    int            resIndex = item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex;

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                var success          = false;
                var fromPrevLocation = From.Location;

                for (var i = context.CraftNumber; i >= 0; i--)
                {
                    if (i == 0)
                    {
                        From.SendAsciiMessage(89, "You finished looping.");
                        return;
                    }

                    var badCraft = CraftSystem.CanCraft(From, Tool, item.ItemType);
                    if (badCraft > 0)
                    {
                        From.SendAsciiMessage(89, "Looping aborted.");
                        return;
                    }

                    if (From.Location != fromPrevLocation)
                    {
                        From.SendAsciiMessage(89, "You moved. Looping aborted.");
                        return;
                    }

                    From.CloseGump <CraftGump>();
                    From.CloseGump <CraftGumpItem>();

                    CraftSystem.CreateItem(From, item.ItemType, type, Tool, item, ref success);

                    if (!success)
                    {
                        return;
                    }

                    From.SendAsciiMessage(89, $"Looping [{i} more to go].");

                    var loopDelay = ((int)(CraftSystem.Delay * CraftSystem.MaxCraftEffect) + (int)ZhConfig.Crafting.AutoLoop.Delay) * 1000;

                    From.NextSkillTime = Core.TickCount + loopDelay;

                    await Timer.Pause(loopDelay);
                }
            }
        }
Ejemplo n.º 10
0
        public static void CraftItem( CraftItem item, CraftSystem system, Mobile from, BaseTool tool )
        {
            int num = system.CanCraft( from, tool, item.ItemType );
            CraftContext context = system.GetContext( from );

            if ( context == null )
                return;

            if ( num > 0 )
            {
                context.Making = null;

                from.SendGump( new CraftGump( from, system, tool, num ) );
            }
            else
            {
                context.Making = item;

                Type type = null;

                CraftSubResCol res = ( item.UseSubRes2 ? system.CraftSubRes2 : system.CraftSubRes );
                int resIndex = ( item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex );

                if ( resIndex >= 0 && resIndex < res.Count )
                    type = res.GetAt( resIndex ).ItemType;

                system.CreateItem( from, item.ItemType, type, tool, item );
            }
        }