Server.Engines.Craft.CraftItem.Craft C# (CSharp) Method

Craft() public method

public Craft ( Server.Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool ) : void
from Server.Mobile
craftSystem CraftSystem
typeRes System.Type
tool Server.Items.BaseTool
return void
        public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool)
        {
            if (from.BeginAction(typeof(CraftSystem)))
            {
                bool allRequiredSkills = true;
                double chance = GetSuccessChance(from,  craftSystem, false, ref allRequiredSkills);

                if (allRequiredSkills && chance >= 0.0)
                {
                        int badCraft = craftSystem.CanCraft(from, tool, m_Type);

                        if (badCraft <= 0)
                        {
                            int resHue = 0;
                            int maxAmount = 0;
                            object message = null;

                            if (ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message))
                            {
                                message = null;

                                if (ConsumeAttributes(from, ref message, false))
                                {
                                    CraftContext context = craftSystem.GetContext(from);

                                    if (context != null)
                                        context.OnMade(this);

                                    int iMin = craftSystem.MinCraftEffect;
                                    int iMax = (craftSystem.MaxCraftEffect - iMin) + 1;
                                    int iRandom = Utility.Random(iMax);
                                    iRandom += iMin + 1;
                                    new InternalTimer(from, craftSystem, this, typeRes, tool, iRandom).Start();
                                }
                                else
                                {
                                    from.EndAction(typeof(CraftSystem));
                                    from.SendGump(new CraftGump(from, craftSystem, tool, message));
                                }
                            }
                            else
                            {
                                from.EndAction(typeof(CraftSystem));
                                from.SendGump(new CraftGump(from, craftSystem, tool, message));
                            }
                        }
                        else
                        {
                            from.EndAction(typeof(CraftSystem));
                            from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
                        }
                }
                else
                {
                    from.EndAction(typeof(CraftSystem));
                    from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); // You don't have the required skills to attempt this item.
                }

            }
            else
            {
                from.SendLocalizedMessage(500119); // You must wait to perform another action
            }
        }

Usage Example

Exemplo n.º 1
0
        public void CreateItem(Mobile from, Type type, Type typeRes, ITool tool, CraftItem realCraftItem)
        {
            // Verify if the type is in the list of the craftable item
            CraftItem craftItem = CraftItems.SearchFor(type);

            if (craftItem != null)
            {
                // The item is in the list, try to create it
                // Test code: items like sextant parts can be crafted either directly from ingots, or from different parts
                realCraftItem.Craft(from, this, typeRes, tool);
                //craftItem.Craft( from, this, typeRes, tool );
            }
        }
All Usage Examples Of Server.Engines.Craft.CraftItem::Craft