Example #1
0
		public static bool PlantingLotTest(Lot lotTryingToPlantingOn, Sim simTryingToPlant)
		{
			if (!lotTryingToPlantingOn.IsCommunityLot)
			{
				return lotTryingToPlantingOn.CanSimTreatAsHome(simTryingToPlant);
			}
			return false;
		}
Example #2
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);
        }
Example #3
0
        protected static bool IsUnderCurfew(ManagerProgressionBase manager, Common.IStatGenerator stats, SimDescription sim, out bool forceCurfew)
        {
            forceCurfew = false;

            if (!sim.IsHuman)
            {
                stats.IncStat("Not Human");
                return(false);
            }
            else if (sim.CreatedSim == null)
            {
                stats.IncStat("Hibernating");
                return(false);
            }
            else if (sim.CreatedSim.RoutingComponent == null)
            {
                stats.IncStat("No Routing Manager");
                return(false);
            }
            else if (sim.CreatedSim.RoutingComponent.RoutingParent != null)
            {
                stats.IncStat("Routing Parent");
                return(false);
            }
            else if (sim.CreatedSim.GetSituationOfType <TrickOrTreatSituation>() != null)
            {
                stats.IncStat("Trick Or Treat");
                return(false);
            }

            Lot currentLot = sim.CreatedSim.LotCurrent;

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

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

            int startCurfew = manager.GetValue <CurfewStartOption, int>(sim);
            int endCurfew   = manager.GetValue <CurfewEndOption, int>(sim);

            if ((startCurfew < 0) || (endCurfew < 0))
            {
                stats.IncStat("User Curfew Fail");
                return(false);
            }
            else if (startCurfew != endCurfew)
            {
                if (SimClock.IsTimeBetweenTimes(SimClock.HoursPassedOfDay, startCurfew, endCurfew))
                {
                    if (manager.GetValue <ForceCurfewOption, bool>(sim))
                    {
                        forceCurfew = true;

                        stats.IncStat("User Defined Curfew");
                        return(true);
                    }
                }
                else
                {
                    stats.IncStat("Not Curfew Time");
                    return(false);
                }
            }

            if (!sim.TeenOrBelow)
            {
                stats.IncStat("Adult Curfew");
                return(false);
            }

            if (startCurfew == endCurfew)
            {
                if (sim.ChildOrBelow)
                {
                    if (!EACurfewRetention.ChildCurfewIsInEffect())
                    {
                        stats.IncStat("Not Child EA Curfew");
                        return(false);
                    }
                }
                else
                {
                    if (!EACurfewRetention.TeenCurfewIsInEffect())
                    {
                        stats.IncStat("Not Teen EA Curfew");
                        return(false);
                    }
                }
            }

            if (IsSupervised(stats, sim.CreatedSim))
            {
                stats.IncStat("Supervised");
                return(false);
            }

            DaysOfTheWeek dayToCheck = SimClock.Yesterday;

            if (SimClock.Hours24 > 12)
            {
                dayToCheck = SimClock.CurrentDayOfWeek;
            }

            if (!manager.HasValue <ValidDaysOption, DaysOfTheWeek>(dayToCheck))
            {
                stats.IncStat("Not Valid Day");
                return(false);
            }

            if (!manager.GetValue <EnforceCurfewForJobOption, bool>())
            {
                stats.IncStat("For Job Disabled");
                return(true);
            }
            else
            {
                Occupation career = sim.Occupation;
                if ((career != null) && (!career.HasOpenHours) && (career.IsFollowingDayInTheWorkDayList(dayToCheck)))
                {
                    stats.IncStat("Work Day");
                    return(true);
                }

                School school = sim.CareerManager.School;
                if ((school != null) && (school.IsFollowingDayInTheWorkDayList(dayToCheck)))
                {
                    stats.IncStat("School Day");
                    return(true);
                }

                stats.IncStat("For Job Allowed");
                return(false);
            }
        }
Example #4
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);
        }