示例#1
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            if (lot == null)
            {
                return(OptionResult.Failure);
            }

            World.DecayLeaves(lot.LotId, 1f);

            foreach (GameObject obj in lot.GetObjects <GameObject>())
            {
                if (obj.InUse)
                {
                    continue;
                }

                if (obj.InInventory)
                {
                    continue;
                }

                if (obj.IsCleanable)
                {
                    obj.Cleanable.ForceClean();
                }

                Hamper hamper = obj as Hamper;
                if (hamper != null)
                {
                    hamper.RemoveClothingPiles();
                }

                IThrowAwayable awayable = obj as IThrowAwayable;
                if ((awayable != null) &&
                    (!awayable.InUse) &&
                    (awayable.HandToolAllowUserPickupBase()) &&
                    (awayable.ShouldBeThrownAway()) &&
                    ((awayable.Parent == null) || (!awayable.Parent.InUse)) &&
                    (!(awayable is Bar.Glass)) &&
                    (!(awayable is Bill)))
                {
                    bool flag = false;
                    if (awayable is BarTray)
                    {
                        foreach (Slot slot in awayable.GetContainmentSlots())
                        {
                            if (awayable.GetContainedObject(slot) is Bar.Glass)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag)
                    {
                        awayable.ThrowAwayImmediately();
                    }
                }

                if (obj is IDestroyOnMagicalCleanup)
                {
                    obj.FadeOut(false, true);
                }
            }

            lot.FireManager.RestoreObjects();

            LotLocation[] puddles = World.GetPuddles(lot.LotId, LotLocation.Invalid);
            if (puddles.Length > 0x0)
            {
                foreach (LotLocation location in puddles)
                {
                    if ((lot.TombRoomManager == null) || !lot.TombRoomManager.IsObjectInATombRoom(location))
                    {
                        PuddleManager.RemovePuddle(lot.LotId, location);
                    }
                }
            }

            LotLocation[] burntTiles = World.GetBurntTiles(lot.LotId, LotLocation.Invalid);
            if (burntTiles.Length > 0x0)
            {
                foreach (LotLocation location2 in burntTiles)
                {
                    if ((lot.LotLocationIsPublicResidential(location2)) && ((lot.TombRoomManager == null) || !lot.TombRoomManager.IsObjectInATombRoom(location2)))
                    {
                        World.SetBurnt(lot.LotId, location2, false);
                    }
                }
            }

            if (me != null)
            {
                List <Fridge> fridges = new List <Fridge>(lot.GetObjects <Fridge>());
                if (fridges.Count > 0)
                {
                    Fridge fridge = fridges[0];
                    if ((fridge != null) &&
                        (me.SharedFridgeInventory != null) &&
                        (me.SharedFamilyInventory.Inventory != null))
                    {
                        foreach (ServingContainer container in Sims3.Gameplay.Queries.GetObjects <ServingContainer>(lot))
                        {
                            if ((!container.InUse) &&
                                (fridge.HandToolAllowDragDrop(container)) &&
                                (container.HasFood) &&
                                (container.HasFoodLeft()) &&
                                (!container.IsSpoiled) &&
                                (container.GetQuality() >= Quality.Neutral))
                            {
                                me.SharedFridgeInventory.Inventory.TryToAdd(container, false);
                            }
                        }
                    }
                }
            }

            foreach (Sim sim in lot.GetAllActors())
            {
                if (sim.Inventory == null)
                {
                    continue;
                }

                foreach (IThrowAwayable awayable in sim.Inventory.FindAll <IThrowAwayable>(true))
                {
                    if (awayable == null)
                    {
                        continue;
                    }

                    if (!awayable.HandToolAllowUserPickupBase())
                    {
                        continue;
                    }

                    if (!awayable.ShouldBeThrownAway())
                    {
                        continue;
                    }

                    if (awayable.InUse)
                    {
                        continue;
                    }

                    if ((awayable is Newspaper) && !(awayable as Newspaper).IsOld)
                    {
                        continue;
                    }

                    if (awayable is TrashPileOpportunity)
                    {
                        continue;
                    }

                    if ((awayable is PreparedFood) && !(awayable as PreparedFood).IsSpoiled)
                    {
                        continue;
                    }

                    awayable.ThrowAwayImmediately();
                }
            }

            return(OptionResult.SuccessClose);
        }
示例#2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool isActiveLot = false;

            if (Sim.ActiveActor != null)
            {
                isActiveLot = Lot.CanSimTreatAsHome(Sim.ActiveActor);

                if ((!isActiveLot) && (Household.ActiveHousehold.RealEstateManager != null))
                {
                    PropertyData data = Household.ActiveHousehold.RealEstateManager.FindProperty(Lot);
                    if ((data != null) && (data.PropertyType == RealEstatePropertyType.Resort))
                    {
                        isActiveLot = true;
                    }
                }
            }

            if (GetValue <CleanOption, bool>())
            {
                if ((!isActiveLot) && (!Lot.IsActive) && (!Occupation.DoesLotHaveAnyActiveJobs(Lot)))
                {
                    bool cleaner = false;
                    if ((Lot.Household != null) && (!Lot.IsBaseCampLotType))
                    {
                        bool child = false;

                        foreach (SimDescription sim in HouseholdsEx.All(Lot.Household))
                        {
                            if (AddScoring("Neat", sim) > 0)
                            {
                                cleaner = true;
                            }

                            if (sim.ToddlerOrBelow)
                            {
                                child = true;
                            }
                        }

                        if ((!child) && (Babysitter.Instance != null))
                        {
                            Babysitter.Instance.MakeServiceRequest(Lot, false, ObjectGuid.InvalidObjectGuid);
                        }
                    }
                    else
                    {
                        cleaner = true;

                        // Disable all services applied to this lot
                        Service[] serviceArray = new Service[] { Babysitter.Instance, Maid.Instance, PizzaDelivery.Instance, Repairman.Instance, SocialWorkerAdoption.Instance, Police.Instance };
                        foreach (Service service in serviceArray)
                        {
                            if (service == null)
                            {
                                continue;
                            }

                            service.MakeServiceRequest(Lot, false, ObjectGuid.InvalidObjectGuid);
                        }
                    }

                    foreach (GameObject obj in Lot.GetObjects <GameObject>())
                    {
                        if (obj.LotCurrent == null)
                        {
                            IncStat("Bogus Location " + obj.CatalogName + " (" + Lot.Name + ", " + Lot.Address + ")", Common.DebugLevel.High);
                            continue;
                        }

                        if (obj is IVelvetRopes)
                        {
                            if (!Bartending.IsBarVenue(Lot))
                            {
                                (obj as IVelvetRopes).NightlyCleanUp();
                            }
                        }

                        try
                        {
                            if (!Lot.DoesObjectNeedCleaning(obj))
                            {
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(obj, e);
                            continue;
                        }

                        if (cleaner)
                        {
                            if (obj.IsCleanable)
                            {
                                obj.Cleanable.ForceClean();
                            }

                            IThrowAwayable awayable = obj as IThrowAwayable;
                            if (awayable != null)
                            {
                                awayable.ThrowAwayImmediately();
                            }

                            Book book = obj as Book;
                            if ((book != null) && (!(book.Data is BookToddlerData)))
                            {
                                if (!book.InInventory)
                                {
                                    if (!Lots.PutAwayBook(this, book, Lot))
                                    {
                                        if (!Lot.IsResidentialLot)
                                        {
                                            book.FadeOut(false, true);
                                        }
                                    }
                                }
                            }
                        }

                        if ((obj is IDestroyOnMagicalCleanup) && ((!Lot.IsResidentialLot) || (!sExpandedInstalled)))
                        {
                            obj.FadeOut(false, true);
                        }
                    }

                    if (!Lot.IsResidentialLot)
                    {
                        Lot.FireManager.RestoreObjects();
                    }

                    LotLocation[] puddles = World.GetPuddles(Lot.LotCurrent.LotId, LotLocation.Invalid);
                    if (puddles.Length > 0)
                    {
                        foreach (LotLocation location in puddles)
                        {
                            PuddleManager.RemovePuddle(Lot.LotCurrent.LotId, location);
                        }
                    }

                    LotLocation[] burntTiles = World.GetBurntTiles(Lot.LotCurrent.LotId, LotLocation.Invalid);
                    if (burntTiles.Length > 0)
                    {
                        foreach (LotLocation location2 in burntTiles)
                        {
                            World.SetBurnt(Lot.LotId, location2, false);
                        }
                    }

                    foreach (ICatPrey prey in Sims3.Gameplay.Queries.GetObjects <ICatPrey>(Lot))
                    {
                        if (prey.IsUnconscious)
                        {
                            prey.Destroy();
                        }
                    }

                    if (!Lot.IsResidentialLot)
                    {
                        Lot.RepairAllObjects();
                    }
                }
            }

            if (GetValue <SeasonOption, bool>())
            {
                if ((!isActiveLot) || (Lot.IsBaseCampLotType) || (Lot.HasVirtualResidentialSlots))
                {
                    SeasonalLotMarker[] objects = Lot.GetObjects <SeasonalLotMarker>();
                    if ((objects.Length > 0x0) && objects[0x0].IsKickNeeded())
                    {
                        TimeUnit units = TimeUnit.Minutes;

                        if (Lot.IsCommunityLot)
                        {
                            foreach (Sim sim in Lot.GetAllActors())
                            {
                                Sim.MakeSimGoHome(sim, true, new InteractionPriority(InteractionPriorityLevel.High));

                                units = TimeUnit.Hours;
                            }
                        }
                        Lot.mGoHomeForSeasonChangeTimer = Lot.AlarmManager.AddAlarm(1f, units, Lot.ChangeSeason, "timer just to make it yieldable", AlarmType.DeleteOnReset, Lot);
                        Lot.AlarmManager.AlarmWillYield(Lot.mGoHomeForSeasonChangeTimer);
                    }
                }
                else
                {
                    Lot.MagicallyChangeSeason();
                }
            }

            return(true);
        }
示例#3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Household house = Household.ActiveHousehold;

            Lot lot = house.LotHome;

            foreach (IThrowAwayable awayable in Sims3.Gameplay.Queries.GetObjects <IThrowAwayable>(lot))
            {
                if (awayable == null)
                {
                    continue;
                }

                if (awayable.InUse)
                {
                    continue;
                }

                if (!awayable.HandToolAllowUserPickupBase())
                {
                    continue;
                }

                if (!awayable.ShouldBeThrownAway())
                {
                    continue;
                }

                if ((awayable.Parent != null) && (awayable.Parent.InUse))
                {
                    continue;
                }

                if (awayable is Bar.Glass)
                {
                    continue;
                }

                if (awayable is Bill)
                {
                    continue;
                }

                bool flag = false;
                if (awayable is BarTray)
                {
                    foreach (Slot slot in awayable.GetContainmentSlots())
                    {
                        if (awayable.GetContainedObject(slot) is Bar.Glass)
                        {
                            flag = true;
                            break;
                        }
                    }
                }

                if (!flag)
                {
                    awayable.ThrowAwayImmediately();
                }
            }

            foreach (IDestroyOnMagicalCleanup destroyable in Sims3.Gameplay.Queries.GetObjects <IDestroyOnMagicalCleanup>(lot))
            {
                GameObject obj = destroyable as GameObject;
                if (obj == null)
                {
                    continue;
                }

                obj.FadeOut(false, true);
            }

            List <Fridge> fridges = new List <Fridge>(lot.GetObjects <Fridge>());

            if (fridges.Count > 0)
            {
                Fridge fridge = fridges[0];
                if ((fridge != null) &&
                    (house.SharedFridgeInventory != null) &&
                    (house.SharedFamilyInventory.Inventory != null))
                {
                    foreach (ServingContainer container in Sims3.Gameplay.Queries.GetObjects <ServingContainer>(lot))
                    {
                        if ((!container.InUse) &&
                            (fridge.HandToolAllowDragDrop(container)) &&
                            (container.HasFood && container.HasFoodLeft()) &&
                            (!container.IsSpoiled &&
                             (container.GetQuality() >= Quality.Neutral)))
                        {
                            house.SharedFridgeInventory.Inventory.TryToAdd(container, false);
                        }
                    }
                }
            }

            foreach (Sim sim in HouseholdsEx.AllSims(house))
            {
                if (!Inventories.VerifyInventory(sim.SimDescription))
                {
                    continue;
                }

                foreach (IThrowAwayable awayable2 in Inventories.QuickDuoFind <IThrowAwayable, GameObject>(sim.Inventory))
                {
                    if (awayable2 == null)
                    {
                        continue;
                    }

                    if (awayable2.InUse)
                    {
                        continue;
                    }

                    if (!awayable2.HandToolAllowUserPickupBase())
                    {
                        continue;
                    }

                    if (!awayable2.ShouldBeThrownAway())
                    {
                        continue;
                    }

                    if (awayable2.InUse)
                    {
                        continue;
                    }

                    if ((awayable2 is Newspaper) && !(awayable2 as Newspaper).IsOld)
                    {
                        continue;
                    }

                    if (awayable2 is TrashPileOpportunity)
                    {
                        continue;
                    }

                    if ((awayable2 is PreparedFood) && !(awayable2 as PreparedFood).IsSpoiled)
                    {
                        continue;
                    }

                    awayable2.ThrowAwayImmediately();
                }
            }

            LotLocation[] puddles = World.GetPuddles(lot.LotId, LotLocation.Invalid);
            if (puddles.Length > 0x0)
            {
                foreach (LotLocation location in puddles)
                {
                    if ((lot.TombRoomManager == null) || !lot.TombRoomManager.IsObjectInATombRoom(location))
                    {
                        PuddleManager.RemovePuddle(lot.LotId, location);
                    }
                }
            }

            try
            {
                List <Bill> allBills            = new List <Bill>();
                List <Bill> allBillsInMailboxes = new List <Bill>();

                uint num = Bill.GetTotalAmountForAllBillsInHousehold(HouseholdsEx.AllSims(lot.Household)[0], allBills, allBillsInMailboxes);
                if (house.FamilyFunds >= num)
                {
                    foreach (Bill bill in allBills)
                    {
                        if (!bill.InUse)
                        {
                            Money.AdjustFunds(house, "Bills", -(int)bill.Amount);

                            bill.DestroyBill(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.DebugException(lot, e);
            }

            return(false);
        }
示例#4
0
        public static void MagicallyCleanUp(Lot lot, bool bAlsoRepair)
        {
            foreach (GameObject obj2 in lot.FindAllObjectsToClean())
            {
                if (!obj2.InUse)
                {
                    if (obj2.IsCleanable)
                    {
                        obj2.Cleanable.ForceClean();
                    }
                    IThrowAwayable awayable = obj2 as IThrowAwayable;
                    if (awayable != null)
                    {
                        awayable.ThrowAwayImmediately();
                    }
                    if (obj2 is Book)
                    {
                        Book book = obj2 as Book;
                        if (book.MyShelf != null)
                        {
                            if (!book.InInventory)
                            {
                                book.MyShelf.Inventory.TryToAdd(book);
                            }
                        }
                        else
                        {
                            Lot ownerLot = book.GetOwnerLot();
                            if (ownerLot == null)
                            {
                                ownerLot = lot;
                            }

                            List <Bookshelf> shelves = new List <Bookshelf> (ownerLot.GetObjects <Bookshelf> ());

                            if (shelves.Count > 0)
                            {
                                shelves[0].Inventory.TryToAdd(book);
                            }
                            else if (ownerLot.LotId == Sim.ActiveActor.LotHome.LotId)
                            {
                                Sim.ActiveActor.Household.SharedFamilyInventory.Inventory.TryToAdd(book);
                            }
                            else
                            {
                                book.FadeOut(false, true);
                            }
                        }
                    }
                }
            }
            LotLocation[] puddles = World.GetPuddles(lot.LotCurrent.LotId, LotLocation.Invalid);
            if (puddles.Length > 0)
            {
                foreach (LotLocation location in puddles)
                {
                    PuddleManager.RemovePuddle(lot.LotCurrent.LotId, location);
                }
            }
            LotLocation[] burntTiles = World.GetBurntTiles(lot.LotCurrent.LotId, LotLocation.Invalid);
            if (burntTiles.Length > 0)
            {
                foreach (LotLocation location2 in burntTiles)
                {
                    World.SetBurnt(lot.LotId, location2, false);
                }
            }
            if (bAlsoRepair)
            {
                lot.RepairAllObjects();
            }
        }