Ejemplo n.º 1
0
        public static uint GetActualDay(int day, Season season)
        {
            if (day == 0)
            {
                return(0);
            }

            uint length = SeasonsManager.GetSeasonLength(season);

            if (day > 0)
            {
                if (day > length)
                {
                    return(0);
                }
            }
            else
            {
                day = ((int)length + day);

                if (day < 0)
                {
                    return(0);
                }
            }

            return((uint)day);
        }
Ejemplo n.º 2
0
        public override void Startup()
        {
            // From StateMachine:Startup
            mBaseCallFlag |= BaseCallFlag.kStartup;

            // From InWorldSubState
            while (sDelayNextStateStartupCount > 0x0)
            {
                SpeedTrap.Sleep(0x0);
            }
            EventTracker.SendEvent(new InWorldSubStateEvent(this, true));

            // From EditTownState
            if (SeasonsManager.Enabled)
            {
                SeasonsManager.OnEnterEditTown();
            }

            AudioManager.MusicMode = MusicMode.EditTown;
            UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0));
            BorderTreatmentsController.Hide();
            GameUtils.Pause();
            base.PlaceLotWizardCheck();
            EditTownController.Load();
            Tutorialette.TriggerLesson(Lessons.EditTown, null);
            Tutorialette.TriggerLesson(Lessons.PlacingNewVenues, null);
            //Household.DestroyHouseholdsWithoutGuardians();
            CASExitLoadScreen.Close();
            InWorldSubState.EdgeScrollCheck();
            InWorldSubState.OpportunityDialogCheck();
        }
Ejemplo n.º 3
0
 void Awake()
 {
     seasonsManager = SeasonsManager.Instance;
     OnStoneTaken   = new GrabbableEvent();
     OnStoneTaken.AddListener(StoneTaken);
     seasonsManager.UpdateSeasonEvent.AddListener(OnSeasonUpdate);
 }
Ejemplo n.º 4
0
        public static uint GetActualDay(int day, Season season)
        {
            if (day == 0)
            {
                return(0);
            }

            uint length = SeasonsManager.GetSeasonLength(season);

            if (day > 0)
            {
                if (day > length)
                {
                    return(0);
                }
            }
            else
            {
                day = ((int)length + day) + 1; // +1 fixes last day of season issue but breaks holidays again

                if (day < 0)
                {
                    return(0);
                }
            }

            return((uint)day);
        }
Ejemplo n.º 5
0
        protected void ParseTemperatures(Season currentSeason)
        {
            XmlDbData xmlData = XmlDbData.ReadData("Seasons");

            if ((xmlData == null) || (xmlData.Tables == null))
            {
                return;
            }

            XmlDbTable xmlDbTable = SeasonsManager.GetXmlDbTable(xmlData, "Temperature");

            if (xmlDbTable != null)
            {
                foreach (XmlDbRow row in xmlDbTable.Rows)
                {
                    Season season;
                    if (!row.TryGetEnum <Season>("Season", out season, Season.Summer))
                    {
                        continue;
                    }

                    if (season != currentSeason)
                    {
                        continue;
                    }

                    ParseTemperature(row);
                }
            }
        }
Ejemplo n.º 6
0
        protected override bool Allow(GameHitParameters <GameObject> parameters)
        {
            if (!SeasonsManager.IsWeatherEnabled(mData.Type))
            {
                return(false);
            }

            return(base.Allow(parameters));
        }
Ejemplo n.º 7
0
        public static int GetCurrentSeasonDay()
        {
            if (!SeasonsManager.Enabled)
            {
                return(0);
            }

            DateAndTime currentTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour);

            // Number of remaining days
            int num = ((int)SimClock.ElapsedTime(TimeUnit.Days, currentTime, SeasonsManager.ExpectedEndTime));

            return((int)SeasonsManager.GetSeasonLength(SeasonsManager.CurrentSeason) - num);
        }
Ejemplo n.º 8
0
        public static void ToggleSeasons()
        {
            if (!GameUtils.IsInstalled(ProductVersion.EP8))
            {
                return;
            }

            bool enable = Traveler.Settings.mEnableSeasons;

            if (enable)
            {
                if (SeasonsManager.Enabled)
                {
                    return;
                }

                SeasonsManager.sSeasonsValidForWorld = SeasonsManager.Validity.Valid;
                SeasonsManager.PostWorldStartup();
            }
            else
            {
                //if (!SeasonsManager.Enabled) return;

                SeasonsManager.Shutdown();

                SeasonsManager.sSeasonsValidForWorld = SeasonsManager.Validity.Invalid;

                foreach (MotiveTuning tuning in MotiveTuning.GetAllTunings(CommodityKind.Temperature))
                {
                    tuning.Universal = false;
                }
            }

            foreach (Sim actor in LotManager.Actors)
            {
                if (actor.Motives == null)
                {
                    continue;
                }

                if (enable)
                {
                    actor.Motives.CreateMotive(CommodityKind.Temperature);
                }
                else
                {
                    actor.Motives.RemoveMotive(CommodityKind.Temperature);
                }
            }
        }
Ejemplo n.º 9
0
        protected static void OnWeather(Event e)
        {
            WeatherEvent weatherEvent = e as WeatherEvent;

            if (weatherEvent == null)
            {
                return;
            }

            if (Household.ActiveHousehold == null)
            {
                return;
            }

            if (Household.ActiveHousehold.LotHome == null)
            {
                return;
            }

            /*
             * switch (weatherEvent.Weather)
             * {
             *  case Weather.Rain:
             *  case Weather.Hail:
             *      foreach (Plant plant in Household.ActiveHousehold.LotHome.GetObjects<Plant>())
             *      {
             *          if ((!plant.IsOutside) || (SeasonsManager.IsShelteredFromPrecipitation(plant))) continue;
             *
             *          if (plant.WaterLevel < 100)
             *          {
             *              plant.WaterLevel = 100;
             *          }
             *      }
             *      break;
             * }
             */
            switch (weatherEvent.Weather)
            {
            case Weather.Hail:
                foreach (Plant plant in Household.ActiveHousehold.LotHome.GetObjects <Plant>())
                {
                    if ((!plant.IsOutside) || (SeasonsManager.IsShelteredFromPrecipitation(plant)))
                    {
                        continue;
                    }

                    if (RandomUtil.RandomChance(Tempest.Settings.mHailKillsPlants))
                    {
                        plant.SetDead();
                    }
                }
                break;
            }

            switch (weatherEvent.Weather)
            {
            case Weather.Hail:
            case Weather.Snow:
                foreach (HarvestPlant plant in Sims3.Gameplay.Queries.GetObjects <HarvestPlant>())
                {
                    if ((!plant.IsOutside) || (SeasonsManager.IsShelteredFromPrecipitation(plant)))
                    {
                        continue;
                    }

                    if (RandomUtil.RandomChance(Tempest.Settings.mHailKillsHarvestables))
                    {
                        HarvestPlant harvest = plant as HarvestPlant;
                        if (harvest != null)
                        {
                            harvest.SetGrowthStateFromHarvestToNext();
                        }
                    }
                }
                break;
            }
        }
Ejemplo n.º 10
0
                public override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    // Test new 6?

                    /*
                     * if (!actor.IsInActiveHousehold && isAutonomous)
                     * {
                     *  return false;
                     * }
                     */
                    if (actor.LotCurrent.IsWorldLot && actor.IsInActiveHousehold)
                    {
                        return(false);
                    }
                    if (SeasonsManager.Enabled && (SeasonsManager.CurrentWeather == Weather.Rain || SeasonsManager.CurrentWeather == Weather.Hail) && !SeasonsManager.IsShelteredFromPrecipitation(actor))
                    {
                        return(false);
                    }
                    return(true);
                }
Ejemplo n.º 11
0
        private static void SetUpHolidayManager(Season currentSeason, bool clear)
        {
            HolidayManager ths = HolidayManager.sInstance;

            if (ths == null)
            {
                return;
            }

            if (SeasonsManager.sInstance == null)
            {
                return;
            }

            if (clear)
            {
                ths.ClearCurrentHoliday();
            }

            if (SeasonsManager.GetSeasonEnabled(currentSeason))
            {
                if (ths.mStartDateTimeOfHoliday == DateAndTime.Invalid)
                {
                    ths.OnHolidayDone();

                    CalculateDateTimeOfHoliday(ths, ref currentSeason);

                    if (ths.mStartDateTimeOfHoliday != DateAndTime.Invalid)
                    {
                        ths.mCurrentSeason = currentSeason;
                        ths.SetHoliday();
                    }

                    if (TrickOrTreatSituation.NPCTrickOrTreatAlarm != AlarmHandle.kInvalidHandle)
                    {
                        AlarmManager.Global.RemoveAlarm(TrickOrTreatSituation.NPCTrickOrTreatAlarm);
                        TrickOrTreatSituation.NPCTrickOrTreatAlarm = AlarmHandle.kInvalidHandle;
                    }
                }

                if (ths.mStartDateTimeOfHoliday != DateAndTime.Invalid)
                {
                    DateAndTime time  = SimClock.CurrentTime();
                    long        ticks = (ths.mStartDateTimeOfHoliday - time).Ticks;

                    Common.DebugNotify("Initiate Holiday Alarm: " + Common.NewLine + SimClock.CurrentTime() + Common.NewLine + ths.mStartDateTimeOfHoliday + Common.NewLine + ticks);

                    if (ticks > 0)
                    {
                        ths.ClearAllAlarms();
                        //ths.StartAlarms();

                        if (sHolidayAlarm != null)
                        {
                            sHolidayAlarm.Dispose();
                        }

                        sHolidayAlarm = new Common.AlarmTask(SimClock.ConvertFromTicks(ticks, TimeUnit.Hours), TimeUnit.Hours, OnHolidayStarted);

                        long ticksToWarning = ticks - SimClock.ConvertToTicks((float)HolidayManager.kDaysBeforeHolidayToShowWarningTNS, TimeUnit.Days);
                        if (ticksToWarning > 0)
                        {
                            ths.mShowWarningAlarm = AlarmManager.Global.AddAlarm(SimClock.ConvertFromTicks(ticksToWarning, TimeUnit.Hours), TimeUnit.Hours, ths.OnShowWarningTns, "ShowWarningTns", AlarmType.AlwaysPersisted, null);
                        }
                    }
                }
            }
        }