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); } }
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); } } }