Exemple #1
0
        private bool OnItemTargetChangeResponse(int restockId, string input)
        {
            if (int.TryParse(input, out int amount))
            {
                RestockItem ri = (RestockItem)m_Items[restockId];

                ri.Amount = amount;

                m_SubList.BeginUpdate();
                m_SubList.Items.Clear();
                for (int j = 0; j < m_Items.Count; j++)
                {
                    m_SubList.Items.Add(m_Items[j]);
                }

                m_SubList.SelectedIndex = restockId;
                m_SubList.EndUpdate();

                Engine.MainWindow.SafeAction(s => s.ShowMe());

                return(true);
            }

            Engine.MainWindow.SafeAction(s => s.ShowMe());

            return(false);
        }
Exemple #2
0
        private void OnItemTarget(bool location, Serial serial, Point3D loc, ushort gfx)
        {
            if (location || serial.IsMobile)
            {
                return;
            }

            Item item = World.FindItem(serial);

            if (item != null)
            {
                gfx = item.ItemID;
            }

            if (gfx == 0 || gfx >= 0x4000)
            {
                return;
            }

            if (!InputBox.Show(Engine.MainWindow, Language.GetString(LocString.EnterAmount),
                               Language.GetString(LocString.InputReq), "1"))
            {
                return;
            }

            RestockItem ri = new RestockItem(gfx, InputBox.GetInt(1));

            Add(ri);

            Engine.MainWindow.SafeAction(s => s.ShowMe());
        }
        private void increaseInRestock(RestockItem r, int amount)
        {
            int             newStock           = r.Product.Stock + amount;
            MySqlConnection databaseConnection = new MySqlConnection(DatabaseInfo.connectionString);

            try
            {
                databaseConnection.Open();
                string       sql = "UPDATE restock SET amount = @amount, approved=1 WHERE rId=@rId";
                MySqlCommand cmd = new MySqlCommand(sql, databaseConnection);
                cmd.Parameters.AddWithValue("@rId", r.RestockId);
                cmd.Parameters.AddWithValue("@amount", newStock);

                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                databaseConnection.Close();
            }
        }
Exemple #4
0
        public static GameObject ReturnRestocableObjectFromRegister(RestockItem rItem, ObjectGuid registerId)
        {
            GameObject restockObject   = null;
            bool       continueLooping = true;

            StoreSetRegister register = CMStoreSet.ReturnRegister(registerId, rItem.LotCurrent);

            if (register != null)
            {
                foreach (var stack in register.Inventory.InventoryItems.Values)
                {
                    if (!continueLooping)
                    {
                        break;
                    }

                    foreach (var item in stack.List)
                    {
                        ItemType type = RestockItemHelperClass.GetItemType((GameObject)item.Object);

                        if (rItem.info.Type == type)
                        {
                            //Does the name match
                            if (rItem.info.Name.Equals(item.Object.GetLocalizedName()))
                            {
                                restockObject   = (GameObject)item.Object;
                                continueLooping = false;
                                break;
                            }
                        }
                    }
                }
            }
            return(restockObject);
        }
        public void RejectRequest(RestockItem restockItemToReject, string message) //done
        {
            MySqlConnection databaseConnection = new MySqlConnection(DatabaseInfo.connectionString);

            try
            {
                databaseConnection.Open();
                string       sql = "UPDATE restock SET approved = @approved, message=@message WHERE rId=@rId";
                MySqlCommand cmd = new MySqlCommand(sql, databaseConnection);
                cmd.Parameters.AddWithValue("@rId", restockItemToReject.RestockId);
                cmd.Parameters.AddWithValue("@approved", 0);
                cmd.Parameters.AddWithValue("@message", message);
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                databaseConnection.Close();
            }
        }
        private void increaseInProducts(RestockItem r, int value)
        {
            int newStock = r.Product.Stock + value;

            MySqlConnection databaseConnection = new MySqlConnection(DatabaseInfo.connectionString);

            try
            {
                databaseConnection.Open();
                string       sql = "UPDATE products SET stock = stock + @stock WHERE id = @id";
                MySqlCommand cmd = new MySqlCommand(sql, databaseConnection);
                cmd.Parameters.AddWithValue("@id", r.Product.Id);
                cmd.Parameters.AddWithValue("@stock", newStock);
                //cmd.Parameters.AddWithValue("@id", 9);
                //cmd.Parameters.AddWithValue("@stock", 1);
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                databaseConnection.Close();
            }
        }
Exemple #7
0
        private void DoRestock()
        {
            Item bag = null;

            if (m_HotBag != Serial.Zero)
            {
                bag = World.FindItem(m_HotBag);
                if (bag != null && bag.RootContainer != World.Player)
                {
                    bag = null;
                }
            }

            if (bag == null)
            {
                bag = World.Player.Backpack;
                if (bag == null)
                {
                    World.Player.SendMessage(MsgLevel.Force, LocString.NoBackpack);
                    return;
                }
            }

            int num = 0;

            for (int i = 0; i < m_Items.Count; i++)
            {
                RestockItem ri    = m_Items[i];
                int         count = World.Player.Backpack.GetCount(ri.ItemID);

                num += Recurse(bag, m_Cont.Contains, ri, ref count);
            }

            World.Player.SendMessage(MsgLevel.Force, LocString.RestockDone, num, num != 1 ? "s" : "");
        }
Exemple #8
0
        private int Recurse(Item pack, List <Item> items, RestockItem ri, ref int count)
        {
            int num = 0;

            for (int i = 0; count < ri.Amount && i < items.Count; i++)
            {
                Item item = (Item)items[i];

                if (item.ItemID == ri.ItemID)
                {
                    int amt = ri.Amount - count;
                    if (amt > item.Amount)
                    {
                        amt = item.Amount;
                    }

                    DragDropManager.DragDrop(item, amt, pack);
                    count += amt;
                    num++;
                }
                else if (item.Contains.Count > 0)
                {
                    num += Recurse(pack, item.Contains, ri, ref count);
                }
            }

            return(num);
        }
Exemple #9
0
 public static bool RestockFromInventory(RestockItem restockItem, bool restockCraftable)
 {
     if (restockItem.info.Type != ItemType.Buy && !restockCraftable)
     {
         return(true);
     }
     return(false);
 }
Exemple #10
0
        public void RemoveItem(int itemId)
        {
            RestockItem item = Items.FirstOrDefault(a => a.ItemID == itemId);

            if (item != null)
            {
                Items.Remove(item);
                m_SubList?.Items?.Remove(item);

                World.Player?.SendMessage(MsgLevel.Force, LocString.ItemRemoved);
            }
        }
Exemple #11
0
 public override void Save(XmlTextWriter xml)
 {
     xml.WriteAttributeString("hotbag", m_HotBag.Value.ToString());
     for (int i = 0; i < m_Items.Count; i++)
     {
         xml.WriteStartElement("item");
         RestockItem ri = (RestockItem)m_Items[i];
         xml.WriteAttributeString("id", ri.ItemID.Value.ToString());
         xml.WriteAttributeString("amount", ri.Amount.ToString());
         xml.WriteEndElement();
     }
 }
Exemple #12
0
        public void SetItemAmount(int itemId, bool fromGump = false)
        {
            int         itemIndex = Items.FindIndex(a => a.ItemID == itemId);
            RestockItem item      = Items[itemIndex];

            if (item != null)
            {
                _fromGump = fromGump;

                InputDialogGump inputGump = new InputDialogGump(OnItemTargetChangeResponse, itemIndex, Language.GetString(LocString.EnterAmount), item.Amount.ToString());
                inputGump.SendGump();
            }
        }
Exemple #13
0
        private bool OnItemTargetChangeResponse(int restockId, string input)
        {
            if (int.TryParse(input, out int amount))
            {
                RestockItem ri = (RestockItem)Items[restockId];

                ri.Amount = amount;

                if (m_SubList != null)
                {
                    m_SubList.BeginUpdate();
                    m_SubList.Items.Clear();

                    for (int j = 0; j < Items.Count; j++)
                    {
                        m_SubList.Items.Add(Items[j]);
                    }

                    m_SubList.SelectedIndex = restockId;
                    m_SubList.EndUpdate();
                }

                if (_fromGump)
                {
                    _fromGump = false;

                    AgentsGump agent = new AgentsGump(this);
                    agent.SendGump();
                }
                else
                {
                    Engine.MainWindow.SafeAction(s => s.ShowMe());
                }

                return(true);
            }

            if (_fromGump)
            {
                _fromGump = false;

                AgentsGump agent = new AgentsGump(this);
                agent.SendGump();
            }
            else
            {
                Engine.MainWindow.SafeAction(s => s.ShowMe());
            }

            return(false);
        }
Exemple #14
0
        internal void AddRestockItem()
        {
            var tmpForm = new FormRestockItem();

            if (tmpForm.ShowDialog() == DialogResult.OK)
            {
                if (tmpForm.tbItemName.Text.Trim() != "")
                {
                    var tmpItem = new RestockItem(tmpForm.tbItemName.Text,
                                                  (int)tmpForm.nudRestockUpTo.Value);
                    listRestockItems.Add(tmpItem);
                    usedProfileForm.tbRestockItems.Text += tmpItem.Item + Environment.NewLine;
                }
            }
        }
Exemple #15
0
        public void Add(RestockItem item)
        {
            foreach (RestockItem restockItem in m_Items)
            {
                if (restockItem.ItemID.Value == item.ItemID.Value)
                {
                    World.Player?.SendMessage(MsgLevel.Force, LocString.ItemExists);
                    return;
                }
            }

            m_Items.Add(item);
            m_SubList.Items.Add(item);

            World.Player?.SendMessage(MsgLevel.Force, LocString.ItemAdded);
        }
Exemple #16
0
        private bool OnItemTargetAmountResponse(int gfx, string input)
        {
            if (int.TryParse(input, out int amount))
            {
                RestockItem ri = new RestockItem((ushort)gfx, amount);
                Add(ri);

                Engine.MainWindow.SafeAction(s => s.ShowMe());

                return(true);
            }

            Engine.MainWindow.SafeAction(s => s.ShowMe());

            return(false);
        }
Exemple #17
0
        private void OnItemTarget(bool location, Serial serial, Point3D loc, ushort gfx)
        {
            if (location || serial.IsMobile)
            {
                return;
            }

            Item item = World.FindItem(serial);

            if (item != null)
            {
                gfx = item.ItemID;
            }

            if (gfx == 0 || gfx >= 0x4000)
            {
                return;
            }

            if (!InputBox.Show(Engine.MainWindow, Language.GetString(LocString.EnterAmount),
                               Language.GetString(LocString.InputReq), "1"))
            {
                return;
            }

            RestockItem ri = new RestockItem(gfx, InputBox.GetInt(1));

            foreach (RestockItem restockItem in m_Items)
            {
                if (restockItem.ItemID.Value == gfx)
                {
                    World.Player.SendMessage(MsgLevel.Force, LocString.ItemExists);
                    return;
                }
            }

            m_Items.Add(ri);
            m_SubList.Items.Add(ri);

            World.Player.SendMessage(MsgLevel.Force, LocString.ItemAdded);

            Engine.MainWindow.SafeAction(s => s.ShowMe());
        }
Exemple #18
0
        public static GameObject ReturnRestocableObject(RestockItem rItem, ObjectGuid registerId)
        {
            StoreSetRegister register      = null;
            GameObject       restockObject = null;

            //If item is linked to a register, restock from the correct inventory
            if (registerId != ObjectGuid.InvalidObjectGuid)
            {
                register      = CMStoreSet.ReturnRegister(registerId, rItem.LotCurrent);
                restockObject = ReturnRestocableObjectFromRegister(rItem, registerId);
            }

            if (restockObject != null && register != null && !register.Inventory.TryToRemove(restockObject))
            {
                restockObject = null;
            }

            return(restockObject);
        }
Exemple #19
0
        private bool OnItemTargetAmountResponse(int gfx, string input)
        {
            if (int.TryParse(input, out int amount))
            {
                RestockItem ri = new RestockItem((ushort)gfx, amount);
                AddItem(ri);

                if (_fromGump)
                {
                    _fromGump = false;

                    AgentsGump agent = new AgentsGump(this);
                    agent.SendGump();
                }
                else
                {
                    Engine.MainWindow.SafeAction(s => s.ShowMe());
                }

                return(true);
            }

            if (_fromGump)
            {
                _fromGump = false;

                AgentsGump agent = new AgentsGump(this);
                agent.SendGump();
            }
            else
            {
                Engine.MainWindow.SafeAction(s => s.ShowMe());
            }

            return(false);
        }
        //!Getting the data
        public List <RestockItem> GetOutstandingData()
        {
            List <RestockItem> retlistOutstanding = new List <RestockItem>();
            MySqlConnection    databaseConnection = new MySqlConnection(DatabaseInfo.connectionString);

            //r.id, u.username, p.name, r.date, r.amount
            try
            {
                string query = "SELECT r.rId, p.id, u.username, p.name, r.date FROM restock r INNER JOIN products p ON r.products = p.id INNER JOIN users u ON r.users=u.id WHERE r.approved IS NULL ";
                databaseConnection.Open();
                MySqlCommand    commandDatabase = new MySqlCommand(query, databaseConnection);
                MySqlDataReader reader;

                reader = commandDatabase.ExecuteReader();
                //int id, string userId, string productId, DateTime dateOfRestock, int amountOfRestock
                while (reader.Read())
                {
                    int         _rId           = Convert.ToInt32(reader["rId"]);
                    int         _productId     = Convert.ToInt32(reader["id"]);
                    string      _username      = reader["username"].ToString();
                    string      _productName   = (reader["name"]).ToString();
                    DateTime    _dateOfRequest = Convert.ToDateTime(reader["date"]);
                    RestockItem r = new RestockItem(_rId, _productId, _username, _productName, _dateOfRequest);

                    //RestockItem r = new RestockItem(Convert.ToInt32(reader["id"]), reader["username"].ToString(), (reader["name"]).ToString(), Convert.ToDateTime(reader["date"]), GetNullable(reader, 4, reader.GetInt32));

                    retlistOutstanding.Add(r);
                }
                databaseConnection.Close();
                return(retlistOutstanding);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public override int Execute(IDataContext context)
        {
            var result = 0;

            ContextQuery = ctx =>
            {
                var baseItem = ctx.AsQueryable <ItemSource>().SingleOrDefault(t => t.Id == BaseItemId);
                if (baseItem == null)
                {
                    throw new DomainException($"Base item with Id {BaseItemId} could not be found");
                }

                var restockItem = RestockItem.Create(baseItem, AmountBeforeRestock, AmountToRestockTo, BotId);

                ctx.Add(restockItem);
                ctx.Commit();

                result = restockItem.Id;
            };

            ExecuteInternal(context);

            return(result);
        }
Exemple #22
0
        public override void OnButtonPress(int num)
        {
            switch (num)
            {
            case 1:
            {
                Targeting.OneTimeTarget(new Targeting.TargetResponseCallback(OnItemTarget));
                World.Player.SendMessage(MsgLevel.Force, LocString.TargItemAdd);
                break;
            }

            case 2:
            {
                if (m_SubList.SelectedIndex >= 0 && m_SubList.SelectedIndex < m_Items.Count)
                {
                    m_Items.RemoveAt(m_SubList.SelectedIndex);
                    m_SubList.Items.RemoveAt(m_SubList.SelectedIndex);
                }

                break;
            }

            case 3:
            {
                int i = m_SubList.SelectedIndex;
                if (i < 0 || i > m_Items.Count)
                {
                    return;
                }

                RestockItem ri = (RestockItem)m_Items[i];

                InputDialogGump inputGump = new InputDialogGump(OnItemTargetChangeResponse, m_SubList.SelectedIndex, Language.GetString(LocString.EnterAmount), ri.Amount.ToString());
                inputGump.SendGump();

                break;
            }

            case 4:
            {
                if (MessageBox.Show(Language.GetString(LocString.Confirm), Language.GetString(LocString.ClearList),
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    m_SubList.Items.Clear();
                    m_Items.Clear();
                }

                break;
            }

            case 5:
            {
                if (m_HotBag == Serial.Zero)
                {
                    SetHB();
                }
                else
                {
                    m_HotBag = Serial.Zero;
                    SetHBText();
                }

                break;
            }

            case 6:
            {
                OnHotKey();
                break;
            }
            }
        }
		public static bool RestockFromInventory(RestockItem restockItem, bool restockCraftable)
		{
			if (restockItem.info.Type != ItemType.Buy && !restockCraftable)
			{
				return true;
			}
			return false;
		}
		public static GameObject ReturnRestocableObject(RestockItem rItem, ObjectGuid registerId)
		{
			StoreSetRegister register = null;
			GameObject restockObject = null;

			//If item is linked to a register, restock from the correct inventory
			if (registerId != ObjectGuid.InvalidObjectGuid)
			{
				register = CMStoreSet.ReturnRegister(registerId, rItem.LotCurrent);
				restockObject = ReturnRestocableObjectFromRegister(rItem, registerId);
			}

			if (restockObject != null && register != null && !register.Inventory.TryToRemove(restockObject))
				restockObject = null;

			return restockObject;

		}
Exemple #25
0
        public override void OnButtonPress(int num)
        {
            switch (num)
            {
            case 1:
            {
                Targeting.OneTimeTarget(new Targeting.TargetResponseCallback(OnItemTarget));
                World.Player.SendMessage(MsgLevel.Force, LocString.TargItemAdd);
                break;
            }

            case 2:
            {
                if (m_SubList.SelectedIndex >= 0 && m_SubList.SelectedIndex < m_Items.Count)
                {
                    m_Items.RemoveAt(m_SubList.SelectedIndex);
                    m_SubList.Items.RemoveAt(m_SubList.SelectedIndex);
                }

                break;
            }

            case 3:
            {
                int i = m_SubList.SelectedIndex;
                if (i < 0 || i > m_Items.Count)
                {
                    return;
                }

                RestockItem ri = (RestockItem)m_Items[i];
                if (!InputBox.Show(Engine.MainWindow, Language.GetString(LocString.EnterAmount),
                                   Language.GetString(LocString.InputReq), ri.Amount.ToString()))
                {
                    return;
                }

                ri.Amount = InputBox.GetInt(ri.Amount);

                m_SubList.BeginUpdate();
                m_SubList.Items.Clear();
                for (int j = 0; j < m_Items.Count; j++)
                {
                    m_SubList.Items.Add(m_Items[j]);
                }

                m_SubList.SelectedIndex = i;
                m_SubList.EndUpdate();
                break;
            }

            case 4:
            {
                if (MessageBox.Show(Language.GetString(LocString.Confirm), Language.GetString(LocString.ClearList),
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    m_SubList.Items.Clear();
                    m_Items.Clear();
                }

                break;
            }

            case 5:
            {
                if (m_HotBag == Serial.Zero)
                {
                    SetHB();
                }
                else
                {
                    m_HotBag = Serial.Zero;
                    SetHBText();
                }

                break;
            }

            case 6:
            {
                OnHotKey();
                break;
            }
            }
        }
		public static GameObject ReturnRestocableObjectFromRegister(RestockItem rItem, ObjectGuid registerId)
		{
			GameObject restockObject = null;
			bool continueLooping = true;

			StoreSetRegister register = CMStoreSet.ReturnRegister(registerId, rItem.LotCurrent);

			if (register != null)
			{
				foreach (var stack in register.Inventory.InventoryItems.Values)
				{
					if (!continueLooping)
						break;

					foreach (var item in stack.List)
					{
						ItemType type = RestockItemHelperClass.GetItemType((GameObject)item.Object);

						if (rItem.info.Type == type)
						{
							//Does the name match
							if (rItem.info.Name.Equals(item.Object.GetLocalizedName()))
							{
								restockObject = (GameObject)item.Object;
								continueLooping = false;
								break;
							}
						}
					}
				}
			}
			return restockObject;
		}
Exemple #27
0
        public static GameObject RecreateSoldObject(RestockItem restockItem, SimDescription actor)
        {
            try
            {
                IGameObject      gameObject       = null;
                bool             restockBuyMode   = false;
                bool             restockCraftable = false;
                StoreSetRegister register         = null;

                bool         isRug;
                StoreSetBase shopBase = ReturnStoreSetBase(restockItem, out isRug);

                if (shopBase != null)
                {
                    if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                    {
                        register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
                    }

                    restockBuyMode   = shopBase.Info.RestockBuyMode;
                    restockCraftable = shopBase.Info.RestockCraftable;

                    #region Find the slot

                    bool slotFound = false;
                    Slot slot      = Slot.ContainmentSlot_0;
                    if (!isRug)
                    {
                        Slot[] containmentSlots = shopBase.GetContainmentSlots();

                        if (containmentSlots != null)
                        {
                            for (int i = 0; i < containmentSlots.Length; i++)
                            {
                                GameObject o = shopBase.GetContainedObject(containmentSlots[i]) as GameObject;

                                if (o != null && o.ObjectId == restockItem.ObjectId)
                                {
                                    slotFound = true;
                                    slot      = containmentSlots[i];
                                    break;
                                }
                            }
                        }
                    }
                    #endregion

                    //Restock from inventory only, if not buy object and linked to register
                    bool restockFromInventory = RestockFromInventory(restockItem, restockCraftable);

                    //Restock from buy mode
                    #region Buy Mode
                    if (!restockFromInventory)
                    {
                        if (restockItem.info.Type == ItemType.Buy || restockItem.info.Type == ItemType.Craftable)
                        {
                            gameObject = GlobalFunctions.CreateObject(restockItem.info.Key, restockItem.Position, restockItem.mLevel, restockItem.ForwardVector);
                            if (!(gameObject is FailureObject))
                            {
                                if (!string.IsNullOrEmpty(restockItem.info.DesignPreset))
                                {
                                    SortedList <string, bool>     enabledStencils = new SortedList <string, bool>();
                                    SortedList <string, Complate> patterns        = StoreHelperClass.ExtractPatterns(restockItem.info.DesignPreset, enabledStencils);
                                    DesignModeSwap designModeSwap = Complate.SetupDesignSwap(gameObject.ObjectId, patterns, false, enabledStencils);
                                    if (designModeSwap != null)
                                    {
                                        designModeSwap.ApplyToObject();
                                    }
                                }
                            }
                        }
                        else
                        {
                            gameObject = ReturnShoppingObject(restockItem, actor, register);
                            gameObject.AddToWorld();
                            gameObject.SetPosition(restockItem.Position);
                        }
                        #region Pay for Restock

                        //Reduce from base owner or register's owner
                        if (shopBase.Info.Owner != 0uL)
                        {
                            SimDescription sd = CMStoreSet.ReturnSim(shopBase.Info.Owner);
                            if (sd != null)
                            {
                                sd.ModifyFunds(-restockItem.info.Price);
                            }
                            else
                            {
                                CMStoreSet.PrintMessage("Couldn't find owner sim");
                            }
                        }
                        else if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                        {
                            //StoreSetRegister register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
                            if (register != null && register.Info.OwnerId != 0uL)
                            {
                                SimDescription sd = CMStoreSet.ReturnSim(register.Info.OwnerId);
                                if (sd != null)
                                {
                                    sd.ModifyFunds(-restockItem.info.Price);
                                }
                            }
                        }

                        #endregion
                    }
                    #endregion Buy Mode

                    #region Inventory
                    else
                    {
                        //Restock from Inventory
                        if (shopBase != null && shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
                        {
                            gameObject = ReturnRestocableObject(restockItem, shopBase.Info.RegisterId);

                            if (gameObject != null)
                            {
                                gameObject.AddToWorld();
                                gameObject.SetPosition(restockItem.Position);
                                gameObject.SetForward(restockItem.ForwardVector);
                            }
                            else
                            {
                                CMStoreSet.PrintMessage("Restockable object null");
                            }
                        }
                    }
                    #endregion Inventory

                    //Delete restock object
                    if (restockItem != null)
                    {
                        restockItem.Destroy();
                    }

                    //Add restocked item back to slot
                    if (slotFound)
                    {
                        IGameObject io = (IGameObject)shopBase;
                        gameObject.ParentToSlot(io, slot);
                    }


                    return((GameObject)gameObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Exception ex)
            {
                CMStoreSet.PrintMessage("RecreateSoldObject: " + ex.Message);
                return(null);
            }
        }
Exemple #28
0
        public static GameObject ReturnShoppingObject(RestockItem rItem, SimDescription actor, StoreSetRegister register)
        {
            GameObject o           = null;
            bool       keepLooping = true;

            switch (rItem.info.Type)
            {
            case ItemType.Herb:
            case ItemType.Ingredient:
                foreach (KeyValuePair <string, List <StoreItem> > kvp in Grocery.mItemDictionary)
                {
                    foreach (StoreItem item in kvp.Value)
                    {
                        if (item.Name.Equals(rItem.info.Name))
                        {
                            keepLooping = false;
                            IngredientData data = (IngredientData)item.CustomData;
                            if (rItem.info.Type == ItemType.Ingredient)
                            {
                                o = Ingredient.Create(data);
                            }
                            else
                            {
                                o = Herb.Create(data);
                                //PlantableNonIngredientData data = (PlantableNonIngredientData)item.CustomData;
                                //o = (GameObject)PlantableNonIngredient.Create(data);
                            }
                            break;
                        }
                    }
                    if (!keepLooping)
                    {
                        break;
                    }
                }

                break;

            case ItemType.Fish:
                o = Fish.CreateFishOfRandomWeight(rItem.info.FType);
                break;

            case ItemType.Craftable:
                break;

            case ItemType.Gem:
            case ItemType.Metal:

                o = (GameObject)RockGemMetalBase.Make(rItem.info.RockData, false);
                break;

            case ItemType.Nectar:

                NectarBottle bottle = (NectarBottle)GlobalFunctions.CreateObjectOutOfWorld("NectarBottle");
                NectarBottleObjectInitParams nectarBottleObjectInitParams = bottle.CreateAncientBottle(rItem.info.NectarAge, rItem.info.Price);

                if (nectarBottleObjectInitParams != null)
                {
                    bottle.mBottleInfo.FruitHash   = nectarBottleObjectInitParams.FruitHash;
                    bottle.mBottleInfo.Ingredients = nectarBottleObjectInitParams.Ingredients;
                    bottle.mBottleInfo.Name        = rItem.info.Name;             //nectarBottleObjectInitParams.Name;
                    bottle.mDateString             = nectarBottleObjectInitParams.DateString;
                    bottle.mBottleInfo.DateNum     = nectarBottleObjectInitParams.DateNum;
                    bottle.mBaseValue                   = rItem.info.Price;  // nectarBottleObjectInitParams.BaseValue;
                    bottle.ValueModifier                = (int)(nectarBottleObjectInitParams.CurrentValue - rItem.info.Price);
                    bottle.mBottleInfo.mCreator         = nectarBottleObjectInitParams.Creator;
                    bottle.mBottleInfo.NectarQuality    = Sims3.Gameplay.Objects.Quality.Neutral;                 //NectarBottle.GetQuality((float)rItem.info.Price);
                    bottle.mBottleInfo.MadeByLevel10Sim = nectarBottleObjectInitParams.MadeByLevel10Sim;
                    bottle.UpdateVisualState();
                }

                o = bottle;

                break;

            case ItemType.AlchemyPotion:

                foreach (AlchemyRecipe recipe in AlchemyRecipe.GetAllAwardPotionRecipes())
                {
                    if (rItem.info.Name.Equals(recipe.Name))
                    {
                        string[] array = new string[] { recipe.Key };

                        AlchemyRecipe randomAwardPotionRecipe = AlchemyRecipe.GetRandomAwardPotionRecipe();
                        PotionShopConsignmentRegister.PotionShopConsignmentRegisterData potionShopConsignmentRegisterData = new PotionShopConsignmentRegister.PotionShopConsignmentRegisterData();

                        potionShopConsignmentRegisterData.mParameters             = array;
                        potionShopConsignmentRegisterData.mObjectName             = randomAwardPotionRecipe.MedatorName;
                        potionShopConsignmentRegisterData.mGuid                   = potionShopConsignmentRegisterData.mObjectName.GetHashCode();
                        potionShopConsignmentRegisterData.mSellerAge              = CASAgeGenderFlags.None;
                        potionShopConsignmentRegisterData.mWeight                 = 100f;
                        potionShopConsignmentRegisterData.mSellPriceMinimum       = 0.75f;
                        potionShopConsignmentRegisterData.mSellPriceMaximum       = 1.25f;
                        potionShopConsignmentRegisterData.mDepreciationAgeMinimum = 0;
                        potionShopConsignmentRegisterData.mDepreciationAgeMaximum = 5;
                        potionShopConsignmentRegisterData.mLifespan               = 3f;
                        string text = string.Empty;
                        if (!string.IsNullOrEmpty(randomAwardPotionRecipe.CustomClassName))
                        {
                            text = randomAwardPotionRecipe.CustomClassName;
                        }
                        else
                        {
                            text = "Sims3.Gameplay.Objects.Alchemy.AlchemyPotion";
                        }
                        potionShopConsignmentRegisterData.mScriptClass = text;
                        potionShopConsignmentRegisterData.mIsRotatable = true;

                        PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData potionShopConsignmentRegisterObjectData2 = PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData.Create(potionShopConsignmentRegisterData);
                        potionShopConsignmentRegisterObjectData2.ShowTooltip = true;

                        o = (GameObject)potionShopConsignmentRegisterObjectData2.mObject;


                        break;
                    }
                }

                break;

            case ItemType.Bug:
                Terrarium t = Terrarium.Create(rItem.info.BugType);
                if (t != null)
                {
                    t.StartVfx();
                }
                o = t;
                break;

            case ItemType.Food:
                int servingPrice = 25;
                if (register != null)
                {
                    servingPrice = register.Info.ServingPrice;
                }

                IFoodContainer container = rItem.info.cookingProcess.Recipe.CreateFinishedFood(rItem.info.cookingProcess.Quantity, rItem.info.cookingProcess.Quality);

                if (rItem.info.cookingProcess.Quantity == Recipe.MealQuantity.Group)
                {
                    ((ServingContainerGroup)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice * ((ServingContainerGroup)container).mNumServingsLeft);
                    ((ServingContainerGroup)container).RemoveSpoilageAlarm();
                }
                else
                {
                    ((ServingContainerSingle)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice);
                    ((ServingContainerSingle)container).RemoveSpoilageAlarm();
                }

                o = (GameObject)container;

                break;

            case ItemType.Flowers:
                o = Wildflower.CreateWildflowerOfType(rItem.info.TypeOfWildFlower, Wildflower.WildflowerState.InVase);
                break;

            case ItemType.BookAlchemyRecipe_:
            case ItemType.BookComic_:
            case ItemType.BookFish_:
            case ItemType.BookGeneral_:
            case ItemType.BookRecipe_:
            case ItemType.BookSkill_:
            case ItemType.BookToddler_:
            case ItemType.SheetMusic_:
            case ItemType.AcademicTextBook_:

                foreach (KeyValuePair <string, List <StoreItem> > kvp in Bookstore.sItemDictionary)
                {
                    foreach (StoreItem item in kvp.Value)
                    {
                        if (item.Name.Equals(rItem.info.Name))
                        {
                            keepLooping = false;

                            if (rItem.info.Type == ItemType.BookGeneral_)
                            {
                                o = (GameObject)BookGeneral.CreateOutOfWorld(item.CustomData as BookGeneralData);
                            }
                            if (rItem.info.Type == ItemType.BookSkill_)
                            {
                                o = (GameObject)BookSkill.CreateOutOfWorld(item.CustomData as BookSkillData);
                            }
                            if (rItem.info.Type == ItemType.BookRecipe_)
                            {
                                o = (GameObject)BookRecipe.CreateOutOfWorld(item.CustomData as BookRecipeData);
                            }
                            if (rItem.info.Type == ItemType.SheetMusic_)
                            {
                                o = (GameObject)SheetMusic.CreateOutOfWorld(item.CustomData as SheetMusicData);
                            }
                            if (rItem.info.Type == ItemType.BookToddler_)
                            {
                                o = (GameObject)BookToddler.CreateOutOfWorld(item.CustomData as BookToddlerData);
                            }
                            if (rItem.info.Type == ItemType.BookFish_)
                            {
                                o = (GameObject)BookFish.CreateOutOfWorld(item.CustomData as BookFishData);
                            }
                            if (rItem.info.Type == ItemType.BookAlchemyRecipe_)
                            {
                                o = (GameObject)BookAlchemyRecipe.CreateOutOfWorld(item.CustomData as BookAlchemyRecipeData);
                            }
                            if (rItem.info.Type == ItemType.AcademicTextBook_)
                            {
                                o = (GameObject)AcademicTextBook.CreateOutOfWorld(item.CustomData as AcademicTextBookData, actor);
                            }
                            if (rItem.info.Type == ItemType.BookComic_)
                            {
                                o = (GameObject)BookComic.CreateOutOfWorld(item.CustomData as BookComicData);
                            }

                            break;
                        }
                    }
                    if (!keepLooping)
                    {
                        break;
                    }
                }


                break;

            case ItemType.JamJar:
                JamJar jamJar = GlobalFunctions.CreateObjectOutOfWorld("canningJarJam", ProductVersion.Store) as JamJar;

                if (jamJar != null)
                {
                    Type         tInfo = jamJar.GetType();
                    BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
                    FieldInfo    ingredientDataField = tInfo.GetField("mData", flags);
                    FieldInfo    ingredientKeyField  = tInfo.GetField("mIngredientKey", flags);
                    FieldInfo    qualityField        = tInfo.GetField("mQuality", flags);
                    FieldInfo    preservesField      = tInfo.GetField("mIsPreserves", flags);
                    MethodInfo   materialStateMethod = tInfo.GetMethod("SetMaterialState", flags);

                    ingredientDataField.SetValue(jamJar, rItem.info.IngData);
                    ingredientKeyField.SetValue(jamJar, rItem.info.IngredientKey);
                    qualityField.SetValue(jamJar, rItem.info.JamQuality);
                    preservesField.SetValue(jamJar, rItem.info.JamIsPreserve);
                    materialStateMethod.Invoke(jamJar, null);
                }
                o = (GameObject)jamJar;
                break;

            default:
                break;
            }

            return(o);
        }
Exemple #29
0
        private int Recurse( Item pack, ArrayList items, RestockItem ri, ref int count )
        {
            int num = 0;
            for(int i=0;count < ri.Amount && i<items.Count;i++)
            {
                Item item = (Item)items[i];

                if ( item.ItemID == ri.ItemID )
                {
                    int amt = ri.Amount - count;
                    if ( amt > item.Amount )
                        amt = item.Amount;
                    DragDropManager.DragDrop( item, amt, pack );
                    count += amt;
                    num ++;
                }
                else if ( item.Contains.Count > 0 )
                {
                    num += Recurse( pack, item.Contains, ri, ref count );
                }
            }

            return num;
        }
Exemple #30
0
        private void OnItemTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            if ( location || serial.IsMobile )
                return;

            Item item = World.FindItem( serial );
            if ( item != null )
                gfx = item.ItemID;

            if ( gfx == 0 || gfx >= 0x4000 )
                return;

            if ( !InputBox.Show( Engine.MainWindow, Language.GetString( LocString.EnterAmount ), Language.GetString( LocString.InputReq ), "1" ) )
                return;

            RestockItem ri = new RestockItem( gfx, InputBox.GetInt( 1 ) );
            m_Items.Add( ri );
            m_SubList.Items.Add( ri );

            World.Player.SendMessage( MsgLevel.Force, LocString.ItemAdded );

            Engine.MainWindow.ShowMe();
        }
Exemple #31
0
        public static GameObject CreateRestockItem(GameObject src, int value, bool isRug)
        {
            try
            {
                RestockItem item = null;

                if (isRug)
                {
                    item = GlobalFunctions.CreateObject(ResourceKey.FromString("319e4f1d:00000000:4d2d76202832ac21"),
                                                        src.PositionOnFloor, src.mLevel, src.ForwardVector) as RestockItem;
                }
                else
                {
                    item = GlobalFunctions.CreateObject(ResourceKey.FromString("319e4f1d:00000000:74eadf6231a9cf5e"),
                                                        src.PositionOnFloor, src.mLevel, src.ForwardVector) as RestockItem;
                }
                item.info.Key   = src.GetResourceKeyForClone(true);
                item.info.Type  = RestockItemHelperClass.GetItemType(src);
                item.info.Name  = src.GetLocalizedName();
                item.info.Price = value;

                switch (item.info.Type)
                {
                case ItemType.Buy:
                case ItemType.Craftable:
                    item.info.DesignPreset = ObjectDesigner.GetObjectDesignPreset(src.ObjectId);
                    break;

                case ItemType.Ingredient:
                    //item.info.IngData = (IngredientData)((Ingredient)src).Data;
                    // item.info.Key = ((Ingredient)src).GetResourceKey();
                    //item.info.IngredientKey = ((Ingredient)src).IngredientKey;
                    break;

                case ItemType.Fish:
                    item.info.FType = ((Fish)src).mFishType;
                    break;

                case ItemType.Herb:
                    //item.info.PlantData = ((PlantableNonIngredient)src).mData;
                    // item.info.Key = ((Herb)src).GetResourceKey();
                    break;

                case ItemType.Metal:
                    item.info.RockData = ((Metal)src).mGuid;
                    item.info.Key      = ((Metal)src).GetResourceKey();
                    break;

                case ItemType.Gem:
                    item.info.RockData = ((Gem)src).mGuid;
                    item.info.Key      = ((Gem)src).GetResourceKey();
                    break;

                case ItemType.Nectar:
                    item.info.Key       = ((NectarBottle)src).GetResourceKey();
                    item.info.NectarAge = ((NectarBottle)src).mBottleInfo.DateNum;

                    if (item.info.NectarAge == 0)
                    {
                        item.info.NectarAge = 1;
                    }

                    item.info.NectarFruitHash   = ((NectarBottle)src).mBottleInfo.FruitHash;
                    item.info.NectarIngredients = ((NectarBottle)src).Ingredients;                    //.in.mBottleInfo;
                    break;

                case ItemType.AlchemyPotion:

                    break;

                case ItemType.Bug:
                    item.info.BugType = ((NormalTerrarium)src).mInsectType;
                    break;

                case ItemType.Food:
                    item.info.cookingProcess = ((ServingContainer)src).CookingProcess;
                    break;

                case ItemType.Flowers:
                    item.info.TypeOfWildFlower = ((Wildflower)src).TypeOfWildFlower;
                    break;

                case ItemType.BookAlchemyRecipe_:
                case ItemType.BookComic_:
                case ItemType.BookFish_:
                case ItemType.BookGeneral_:
                case ItemType.BookRecipe_:
                case ItemType.BookSkill_:
                case ItemType.BookToddler_:
                case ItemType.SheetMusic_:
                case ItemType.AcademicTextBook_:
                    item.info.Name = ((Book)src).CatalogName;
                    break;

                case ItemType.JamJar:
                    Type         tInfo = src.GetType();
                    BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
                    FieldInfo    ingredientDataField = tInfo.GetField("mData", flags);
                    FieldInfo    ingredientKeyField  = tInfo.GetField("mIngredientKey", flags);
                    FieldInfo    qualityField        = tInfo.GetField("mQuality", flags);
                    FieldInfo    preservesField      = tInfo.GetField("mIsPreserves", flags);

                    item.info.IngData       = (IngredientData)ingredientDataField.GetValue(src);
                    item.info.IngredientKey = (string)ingredientKeyField.GetValue(src);
                    item.info.JamQuality    = (Quality)qualityField.GetValue(src);
                    item.info.JamIsPreserve = (bool)preservesField.GetValue(src);
                    break;

                default:
                    break;
                }
                return(item);
            }
            catch (System.Exception ex)
            {
                CMStoreSet.PrintMessage("CreateRestockItem: " + ex.Message);
                return(null);
            }
        }
 public void IncreaseRestockItem(RestockItem r, int amount)
 {
     increaseInRestock(r, amount);
     increaseInProducts(r, amount);
 }
		public static GameObject RecreateSoldObject(RestockItem restockItem, SimDescription actor)
		{
			try
			{
				IGameObject gameObject = null;
				bool restockBuyMode = false;
				bool restockCraftable = false;
				StoreSetRegister register = null;

				bool isRug;
				StoreSetBase shopBase = ReturnStoreSetBase(restockItem, out isRug);

				if (shopBase != null)
				{
					if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
					{
						register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
					}

					restockBuyMode = shopBase.Info.RestockBuyMode;
					restockCraftable = shopBase.Info.RestockCraftable;

					#region Find the slot

					bool slotFound = false;
					Slot slot = Slot.ContainmentSlot_0;
					if (!isRug)
					{
						Slot[] containmentSlots = shopBase.GetContainmentSlots();

						if (containmentSlots != null)
						{
							for (int i = 0; i < containmentSlots.Length; i++)
							{
								GameObject o = shopBase.GetContainedObject(containmentSlots[i]) as GameObject;

								if (o != null && o.ObjectId == restockItem.ObjectId)
								{
									slotFound = true;
									slot = containmentSlots[i];
									break;
								}
							}
						}
					}
					#endregion

					//Restock from inventory only, if not buy object and linked to register
					bool restockFromInventory = RestockFromInventory(restockItem, restockCraftable);

					//Restock from buy mode
					#region Buy Mode
					if (!restockFromInventory)
					{
						if (restockItem.info.Type == ItemType.Buy || restockItem.info.Type == ItemType.Craftable)
						{
							gameObject = GlobalFunctions.CreateObject(restockItem.info.Key, restockItem.Position, restockItem.mLevel, restockItem.ForwardVector);
							if (!(gameObject is FailureObject))
							{
								if (!string.IsNullOrEmpty(restockItem.info.DesignPreset))
								{
									SortedList<string, bool> enabledStencils = new SortedList<string, bool>();
									SortedList<string, Complate> patterns = StoreHelperClass.ExtractPatterns(restockItem.info.DesignPreset,enabledStencils);
									DesignModeSwap designModeSwap = Complate.SetupDesignSwap(gameObject.ObjectId, patterns, false, enabledStencils);
									if (designModeSwap != null)
									{
										designModeSwap.ApplyToObject();
									}
								}
							}
						}
						else
						{
							gameObject = ReturnShoppingObject(restockItem, actor, register);
							gameObject.AddToWorld();
							gameObject.SetPosition(restockItem.Position);                          
						}
						#region Pay for Restock

						//Reduce from base owner or register's owner
						if (shopBase.Info.Owner != 0uL)
						{
							SimDescription sd = CMStoreSet.ReturnSim(shopBase.Info.Owner);
							if (sd != null)
							{
								sd.ModifyFunds(-restockItem.info.Price);
							}
							else
							{
								CMStoreSet.PrintMessage("Couldn't find owner sim");
							}
						}
						else if (shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
						{
							//StoreSetRegister register = CMStoreSet.ReturnRegister(shopBase.Info.RegisterId, shopBase.LotCurrent);
							if (register != null && register.Info.OwnerId != 0uL)
							{
								SimDescription sd = CMStoreSet.ReturnSim(register.Info.OwnerId);
								if (sd != null)
								{
									sd.ModifyFunds(-restockItem.info.Price);
								}
							}
						}

						#endregion
					}
					#endregion Buy Mode

					#region Inventory
					else
					{
						//Restock from Inventory                
						if (shopBase != null && shopBase.Info.RegisterId != ObjectGuid.InvalidObjectGuid)
						{
							gameObject = ReturnRestocableObject(restockItem, shopBase.Info.RegisterId);

							if (gameObject != null)
							{
								gameObject.AddToWorld();
								gameObject.SetPosition(restockItem.Position);
								gameObject.SetForward(restockItem.ForwardVector);
							}
							else
							{
								CMStoreSet.PrintMessage("Restockable object null");
							}
						}
					}
					#endregion Inventory

					//Delete restock object
					if (restockItem != null)
						restockItem.Destroy();

					//Add restocked item back to slot                
					if (slotFound)
					{
						IGameObject io = (IGameObject)shopBase;
						gameObject.ParentToSlot(io, slot);
					}


					return (GameObject)gameObject;
				}
				else
				{
					return null;
				}
			}
			catch (System.Exception ex)
			{
				CMStoreSet.PrintMessage("RecreateSoldObject: " + ex.Message);
				return null;
			}

		}
Exemple #34
0
 public void Init()
 {
     restockItem = new RestockItemBuilder().With(ri => ri.Id, 13).BuildAndSave();
 }
		public static GameObject ReturnShoppingObject(RestockItem rItem, SimDescription actor, StoreSetRegister register)
		{
			GameObject o = null;
			bool keepLooping = true;

			switch (rItem.info.Type)
			{
			case ItemType.Herb:
			case ItemType.Ingredient:
				foreach (KeyValuePair<string, List<StoreItem>> kvp in Grocery.mItemDictionary)
				{
					foreach (StoreItem item in kvp.Value)
					{
						if (item.Name.Equals(rItem.info.Name))
						{
							keepLooping = false;
							IngredientData data = (IngredientData)item.CustomData;
							if (rItem.info.Type == ItemType.Ingredient)
							{                                   
								o = Ingredient.Create(data);

							}
							else
							{
								o = Herb.Create(data);
								//PlantableNonIngredientData data = (PlantableNonIngredientData)item.CustomData;
								//o = (GameObject)PlantableNonIngredient.Create(data);
							}
							break;
						}
					}
					if (!keepLooping)
						break;
				}

				break;
			case ItemType.Fish:
				o = Fish.CreateFishOfRandomWeight(rItem.info.FType);
				break;

			case ItemType.Craftable:
				break;
			case ItemType.Gem:
			case ItemType.Metal:

				o = (GameObject)RockGemMetalBase.Make(rItem.info.RockData, false);
				break;
			case ItemType.Nectar:

				NectarBottle bottle = (NectarBottle)GlobalFunctions.CreateObjectOutOfWorld("NectarBottle");
				NectarBottleObjectInitParams nectarBottleObjectInitParams = bottle.CreateAncientBottle(rItem.info.NectarAge, rItem.info.Price);

				if (nectarBottleObjectInitParams != null)
				{
					bottle.mBottleInfo.FruitHash = nectarBottleObjectInitParams.FruitHash;
					bottle.mBottleInfo.Ingredients = nectarBottleObjectInitParams.Ingredients;
					bottle.mBottleInfo.Name = rItem.info.Name;//nectarBottleObjectInitParams.Name;
					bottle.mDateString = nectarBottleObjectInitParams.DateString;
					bottle.mBottleInfo.DateNum = nectarBottleObjectInitParams.DateNum;
					bottle.mBaseValue = rItem.info.Price;// nectarBottleObjectInitParams.BaseValue;
					bottle.ValueModifier = (int)(nectarBottleObjectInitParams.CurrentValue - rItem.info.Price);
					bottle.mBottleInfo.mCreator = nectarBottleObjectInitParams.Creator;
					bottle.mBottleInfo.NectarQuality = Sims3.Gameplay.Objects.Quality.Neutral;//NectarBottle.GetQuality((float)rItem.info.Price);
					bottle.mBottleInfo.MadeByLevel10Sim = nectarBottleObjectInitParams.MadeByLevel10Sim;
					bottle.UpdateVisualState();
				}

				o = bottle;

				break;
			case ItemType.AlchemyPotion:

				foreach (AlchemyRecipe recipe in AlchemyRecipe.GetAllAwardPotionRecipes())
				{
					if (rItem.info.Name.Equals(recipe.Name))
					{
						string[] array = new string[] { recipe.Key };

						AlchemyRecipe randomAwardPotionRecipe = AlchemyRecipe.GetRandomAwardPotionRecipe();
						PotionShopConsignmentRegister.PotionShopConsignmentRegisterData potionShopConsignmentRegisterData = new PotionShopConsignmentRegister.PotionShopConsignmentRegisterData();

						potionShopConsignmentRegisterData.mParameters = array;
						potionShopConsignmentRegisterData.mObjectName = randomAwardPotionRecipe.MedatorName;
						potionShopConsignmentRegisterData.mGuid = potionShopConsignmentRegisterData.mObjectName.GetHashCode();
						potionShopConsignmentRegisterData.mSellerAge = CASAgeGenderFlags.None;
						potionShopConsignmentRegisterData.mWeight = 100f;
						potionShopConsignmentRegisterData.mSellPriceMinimum = 0.75f;
						potionShopConsignmentRegisterData.mSellPriceMaximum = 1.25f;
						potionShopConsignmentRegisterData.mDepreciationAgeMinimum = 0;
						potionShopConsignmentRegisterData.mDepreciationAgeMaximum = 5;
						potionShopConsignmentRegisterData.mLifespan = 3f;
						string text = string.Empty;
						if (!string.IsNullOrEmpty(randomAwardPotionRecipe.CustomClassName))
						{
							text = randomAwardPotionRecipe.CustomClassName;
						}
						else
						{
							text = "Sims3.Gameplay.Objects.Alchemy.AlchemyPotion";
						}
						potionShopConsignmentRegisterData.mScriptClass = text;
						potionShopConsignmentRegisterData.mIsRotatable = true;

						PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData potionShopConsignmentRegisterObjectData2 = PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData.Create(potionShopConsignmentRegisterData);
						potionShopConsignmentRegisterObjectData2.ShowTooltip = true;

						o = (GameObject)potionShopConsignmentRegisterObjectData2.mObject;


						break;
					}
				}

				break;
			case ItemType.Bug:
				Terrarium t = Terrarium.Create(rItem.info.BugType);
				if (t != null)
					t.StartVfx();
				o = t;
				break;

			case ItemType.Food:
				int servingPrice = 25;
				if (register != null)
					servingPrice = register.Info.ServingPrice;

				IFoodContainer container = rItem.info.cookingProcess.Recipe.CreateFinishedFood(rItem.info.cookingProcess.Quantity, rItem.info.cookingProcess.Quality);

				if (rItem.info.cookingProcess.Quantity == Recipe.MealQuantity.Group)
				{
					((ServingContainerGroup)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice * ((ServingContainerGroup)container).mNumServingsLeft);
					((ServingContainerGroup)container).RemoveSpoilageAlarm();
				}
				else
				{
					((ServingContainerSingle)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice);
					((ServingContainerSingle)container).RemoveSpoilageAlarm();
				}

				o = (GameObject)container;

				break;

			case ItemType.Flowers:                    
				o = Wildflower.CreateWildflowerOfType(rItem.info.TypeOfWildFlower, Wildflower.WildflowerState.InVase);
				break;

			case ItemType.BookAlchemyRecipe_:
			case ItemType.BookComic_:
			case ItemType.BookFish_:
			case ItemType.BookGeneral_:
			case ItemType.BookRecipe_:
			case ItemType.BookSkill_:
			case ItemType.BookToddler_:
			case ItemType.SheetMusic_:
			case ItemType.AcademicTextBook_:

				foreach (KeyValuePair<string, List<StoreItem>> kvp in Bookstore.sItemDictionary)
				{
					foreach (StoreItem item in kvp.Value)
					{
						if (item.Name.Equals(rItem.info.Name))
						{
							keepLooping = false;

							if (rItem.info.Type == ItemType.BookGeneral_)
								o = (GameObject)BookGeneral.CreateOutOfWorld(item.CustomData as BookGeneralData);
							if (rItem.info.Type == ItemType.BookSkill_)
								o = (GameObject)BookSkill.CreateOutOfWorld(item.CustomData as BookSkillData);
							if (rItem.info.Type == ItemType.BookRecipe_)
								o = (GameObject)BookRecipe.CreateOutOfWorld(item.CustomData as BookRecipeData);
							if (rItem.info.Type == ItemType.SheetMusic_)
								o = (GameObject)SheetMusic.CreateOutOfWorld(item.CustomData as SheetMusicData);
							if (rItem.info.Type == ItemType.BookToddler_)
								o = (GameObject)BookToddler.CreateOutOfWorld(item.CustomData as BookToddlerData);
							if (rItem.info.Type == ItemType.BookFish_)
								o = (GameObject)BookFish.CreateOutOfWorld(item.CustomData as BookFishData);
							if (rItem.info.Type == ItemType.BookAlchemyRecipe_)
								o = (GameObject)BookAlchemyRecipe.CreateOutOfWorld(item.CustomData as BookAlchemyRecipeData);
							if (rItem.info.Type == ItemType.AcademicTextBook_)
								o = (GameObject)AcademicTextBook.CreateOutOfWorld(item.CustomData as AcademicTextBookData, actor);
							if (rItem.info.Type == ItemType.BookComic_)
								o = (GameObject)BookComic.CreateOutOfWorld(item.CustomData as BookComicData);

							break;
						}
					}
					if (!keepLooping)
						break;
				}


				break;
			case ItemType.JamJar:
				JamJar jamJar = GlobalFunctions.CreateObjectOutOfWorld ("canningJarJam", ProductVersion.Store) as JamJar;

				if (jamJar != null) {
					Type tInfo = jamJar.GetType ();
					BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
					FieldInfo ingredientDataField = tInfo.GetField ("mData", flags);
					FieldInfo ingredientKeyField = tInfo.GetField ("mIngredientKey", flags);
					FieldInfo qualityField = tInfo.GetField ("mQuality", flags);
					FieldInfo preservesField = tInfo.GetField ("mIsPreserves", flags);

					ingredientDataField.SetValue (jamJar, rItem.info.IngData);
					ingredientKeyField.SetValue (jamJar, rItem.info.IngredientKey);
					qualityField.SetValue (jamJar, rItem.info.JamQuality);
					preservesField.SetValue (jamJar, rItem.info.JamIsPreserve);
				}
				o = (GameObject)jamJar;
				break;
			default:
				break;
			}

			return o;
		}