public static void RegisterRoomListeners(Lot lot)
            {
                if (lot != null && !mRegistered.Contains(lot.LotId) && !lot.IsWorldLot)
                {
                    LotDisplayLevelInfo info = World.LotGetDisplayLevelInfo(lot.LotId);

                    for (int i = info.mMin; i <= info.mMax; i++)
                    {
                        foreach (int room in World.GetInsideRoomsAtLevel(lot.LotId, i, eRoomDefinition.LightBlocking))
                        {
                            List <Lot.OnAllowedInRoomCheck> list;
                            if (!lot.mRoomRestrictionCheckCallbacks.TryGetValue(room, out list))
                            {
                                list = new List <Lot.OnAllowedInRoomCheck>();
                                lot.mRoomRestrictionCheckCallbacks.Add(room, list);
                            }
                            if (!list.Contains(new Lot.OnAllowedInRoomCheck(OnAllowedInRoomCheck)))
                            {
                                list.Add(new Lot.OnAllowedInRoomCheck(OnAllowedInRoomCheck));
                            }
                        }
                    }

                    foreach (Sim sim in lot.GetAllActors())
                    {
                        if (sim != null)
                        {
                            sim.mAllowedRooms.Remove(lot.LotId);
                        }
                    }

                    mRegistered.Add(lot.LotId);
                }
            }
        public static List <Sim> GetTreatableSims(Sim actor, Lot lot)
        {
            List <Sim> list = null;

            if (!lot.IsWorldLot)
            {
                foreach (Sim s in lot.GetAllActors())
                {
                    if (s != actor && s.BuffManager.HasElement(LoadThis.buffNamePetstilence))
                    {
                        Lazy.Add(ref list, s);
                    }
                }
            }

            Sim[] objects = Queries.GetObjects <Sim>(actor.Position, kRadiusForValidSims);
            foreach (Sim sim in objects)
            {
                if (sim != actor && sim.BuffManager.HasElement(LoadThis.buffNamePetstilence) &&
                    !Lazy.Contains(list, sim))
                {
                    Lazy.Add(ref list, sim);
                }
            }
            return(list);
        }
Esempio n. 3
0
        public static List <Sim> GetTreatableSims(Sim actor, Lot lot)
        {
            List <Sim> list = null;

            if (!lot.IsWorldLot)
            {
                foreach (Sim s in lot.GetAllActors())
                {
                    if (s != actor && s.IsPet)
                    {
                        Lazy.Add(ref list, s);
                    }
                }
            }

            Sim[] objects = Queries.GetObjects <Sim>(actor.Position, kRadiusForValidSims);
            foreach (Sim sim in objects)
            {
                if (sim != actor && sim.IsPet && !Lazy.Contains(list, sim))
                {
                    Lazy.Add(ref list, sim);
                }
            }
            return(list);
        }
Esempio n. 4
0
            protected override bool OnPerform()
            {
                if (Decensor.Settings.mDisable)
                {
                    return(true);
                }

                if (mSims == null)
                {
                    Lot worldLot = LotManager.GetWorldLot();
                    if (worldLot == null)
                    {
                        return(true);
                    }

                    mSims  = new List <Sim>(worldLot.GetAllActors());
                    mIndex = -1;

                    mCount = 0;
                }

                mCount++;
                mIndex++;
                if (mIndex >= mSims.Count)
                {
                    if (mCount > (Decensor.Settings.mDelay / sDelay))
                    {
                        mSims.Clear();
                        mSims = null;
                    }
                }
                else
                {
                    VerifyCensor(mSims[mIndex]);
                }

                return(true);
            }
Esempio n. 5
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;
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        protected static bool IsWitnessed(ManagerProgressionBase manager, IScoringGenerator stats, SimDescription sim, int baseChance)
        {
            if (sim.CreatedSim == null)
            {
                stats.IncStat("Hibernating");
                return(false);
            }

            Lot lot = sim.CreatedSim.LotCurrent;

            if (lot == null)
            {
                return(false);
            }

            if (lot.IsWorldLot)
            {
                return(false);
            }

            if (lot.CanSimTreatAsHome(sim.CreatedSim))
            {
                stats.IncStat("At Home");
                return(false);
            }

            /*
             * if (lot.IsResidentialLot)
             * {
             *  stats.IncStat("Residential");
             *  return false;
             * }
             */

            foreach (Sim witness in lot.GetAllActors())
            {
                if (!witness.IsHuman)
                {
                    continue;
                }

                if (witness.SimDescription.ChildOrBelow)
                {
                    continue;
                }

                if (stats.AddScoring("IgnoreCurfew", witness.SimDescription) > 0)
                {
                    continue;
                }

                if (!RandomUtil.RandomChance(stats.AddScoring("CurfewWitness", witness.SimDescription) + baseChance))
                {
                    continue;
                }

                bool forceCurfew;
                if (IsUnderCurfew(manager, stats, witness.SimDescription, out forceCurfew))
                {
                    continue;
                }

                stats.IncStat("Witnessed");
                return(true);
            }

            return(false);
        }
Esempio n. 8
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);
        }
            public static void RegisterRoomListeners(Lot lot)
            {
                if (lot != null && !mRegistered.Contains(lot.LotId) && !lot.IsWorldLot)
                {
                    LotDisplayLevelInfo info = World.LotGetDisplayLevelInfo(lot.LotId);

                    for (int i = info.mMin; i <= info.mMax; i++)
                    {
                        foreach (int room in World.GetInsideRoomsAtLevel(lot.LotId, i, eRoomDefinition.LightBlocking))
                        {
                            List<Lot.OnAllowedInRoomCheck> list;
                            if (!lot.mRoomRestrictionCheckCallbacks.TryGetValue(room, out list))
                            {
                                list = new List<Lot.OnAllowedInRoomCheck>();
                                lot.mRoomRestrictionCheckCallbacks.Add(room, list);
                            }
                            if (!list.Contains(new Lot.OnAllowedInRoomCheck(OnAllowedInRoomCheck)))
                            {
                                list.Add(new Lot.OnAllowedInRoomCheck(OnAllowedInRoomCheck));
                            }
                        }
                    }

                    foreach (Sim sim in lot.GetAllActors())
                    {
                        if (sim != null)
                        {
                            sim.mAllowedRooms.Remove(lot.LotId);
                        }
                    }

                    mRegistered.Add(lot.LotId);
                }                             
            }