Ejemplo n.º 1
0
 public IntoTheFutureConsignedObjectProxy(object data)
 {
     mData = data as BotShopRegister.ConsignedObject;
 }
Ejemplo n.º 2
0
        protected static void Cleanup1 <TConsigned>(Logger log, string prefix, int maximumAge, ref Dictionary <ulong, List <TConsigned> > list)
            where TConsigned : ICancelSellableUIItem, ISellableUIItem, IShopItem
        {
            if (list == null)
            {
                list = new Dictionary <ulong, List <TConsigned> >();

                if (log != null)
                {
                    log(" " + prefix + ".sConsignedObjects Restarted");
                }
            }

            List <ulong> remove = new List <ulong>();

            foreach (KeyValuePair <ulong, List <TConsigned> > objects in list)
            {
                if ((objects.Value == null) || (objects.Value.Count == 0))
                {
                    remove.Add(objects.Key);
                }
                else
                {
                    SimDescription owner = null;

                    for (int i = objects.Value.Count - 1; i >= 0; i--)
                    {
                        TConsigned obj = objects.Value[i];

                        IGameObject consignedObj = null;
                        int         age          = 0;

                        if (obj is ConsignmentRegister.ConsignedObject)
                        {
                            ConsignmentRegister.ConsignedObject castObj = obj as ConsignmentRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is PotionShopConsignmentRegister.ConsignedObject)
                        {
                            PotionShopConsignmentRegister.ConsignedObject castObj = obj as PotionShopConsignmentRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is BotShopRegister.ConsignedObject)
                        {
                            BotShopRegister.ConsignedObject castObj = obj as BotShopRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is FruitVeggieStand.ConsignedObject)
                        {
                            FruitVeggieStand.ConsignedObject castObj = obj as FruitVeggieStand.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        try
                        {
                            if ((age < 0) || (age >= maximumAge))
                            {
                                if (owner == null)
                                {
                                    owner = SimDescription.Find(objects.Key);
                                }

                                bool success = false;
                                if (owner != null)
                                {
                                    if (owner.CreatedSim != null)
                                    {
                                        success = Inventories.TryToMove(consignedObj, owner.CreatedSim);
                                    }

                                    if ((!success) && (owner.Household != null) && (owner.Household.SharedFamilyInventory != null))
                                    {
                                        success = Inventories.TryToMove(consignedObj, owner.Household.SharedFamilyInventory.Inventory);
                                    }
                                }

                                if (!success)
                                {
                                    consignedObj.Destroy();

                                    if (log != null)
                                    {
                                        log(" Over Age Object deleted");
                                    }
                                }
                                else
                                {
                                    if (log != null)
                                    {
                                        log(" Over Age Object returned");
                                    }
                                }

                                objects.Value.RemoveAt(i);
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(consignedObj, e);
                        }
                    }
                }
            }

            foreach (ulong id in remove)
            {
                list.Remove(id);

                if (log != null)
                {
                    log(" Removed: " + id);
                }
            }
        }