示例#1
0
        protected override bool Allow(SimDescription sim)
        {
            if (sim.ChildOrBelow)
            {
                IncStat("Too Young");
                return(false);
            }
            else if (sim.LotHome == null)
            {
                IncStat("Homeless");
                return(false);
            }
            else if (sim.CreatedByService != null)
            {
                IncStat("Service");
                return(false);
            }
            else if (sim.CreatedSim == null)
            {
                IncStat("Hibernating");
                return(false);
            }
            else if (sim.AssignedRole != null)
            {
                IncStat("Role");
                return(false);
            }
            else if (!(sim.Occupation is Career))
            {
                IncStat("Not Career");
                return(false);
            }

            try
            {
                if (sim.CreatedSim.CurrentOutfitCategory != Sims3.SimIFace.CAS.OutfitCategories.Career)
                {
                    IncStat("Not Career");
                    return(false);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim, e);

                IncStat("Exception");
                return(false);
            }

            DateAndTime queryTime = SimClock.CurrentTime();

            queryTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);
            if (sim.Occupation.IsWorkHour(queryTime))
            {
                IncStat("Too Close");
                return(false);
            }

            return(base.Allow(sim));
        }
示例#2
0
        protected override bool Allow(SimDescription me, IMiniSimDescription actor)
        {
            if (me.CareerManager != null)
            {
                DateAndTime TwoHourTime = SimClock.CurrentTime();
                TwoHourTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

                if (me.Occupation != null)
                {
                    if (me.Occupation.IsWorkHour(TwoHourTime))
                    {
                        return(false);
                    }
                }
                if (me.CareerManager.School != null)
                {
                    if (me.CareerManager.School.IsWorkHour(TwoHourTime))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#3
0
文件: Roles.cs 项目: yakoder/NRaas
        public static bool GetRoleHours(SimDescription sim, ref DateAndTime start, ref DateAndTime end)
        {
            if ((sim != null) && (sim.AssignedRole != null))
            {
                IRoleGiverExtended roleGivingObject = sim.AssignedRole.RoleGivingObject as IRoleGiverExtended;
                if (roleGivingObject != null)
                {
                    float startTime;
                    float endTime;
                    roleGivingObject.GetRoleTimes(out startTime, out endTime);

                    start = new DateAndTime(SimClock.ConvertToTicks((float)SimClock.DayToInt(SimClock.CurrentDayOfWeek), TimeUnit.Days));
                    end   = new DateAndTime(SimClock.ConvertToTicks((float)SimClock.DayToInt(SimClock.CurrentDayOfWeek), TimeUnit.Days));
                    if (SimClock.HoursPassedOfDay >= endTime)
                    {
                        start = SimClock.Add(start, TimeUnit.Hours, startTime);
                        end   = SimClock.Add(end, TimeUnit.Hours, endTime + 24f);
                    }
                    else
                    {
                        start = SimClock.Add(start, TimeUnit.Hours, startTime);
                        end   = SimClock.Add(end, TimeUnit.Hours, endTime);
                    }

                    return(true);
                }
            }

            return(false);
        }
示例#4
0
            protected override bool Allow(SimDescription sim)
            {
                if (sim.Household == null)
                {
                    IncStat("No Home");
                    return(false);
                }
                else if (SimTypes.IsSpecial(sim))
                {
                    IncStat("Special");
                    return(false);
                }
                else if (CommuteAlarmRunning())
                {
                    IncStat("Running");
                    return(false);
                }

                Career job = Job;

                DateAndTime queryTime = SimClock.CurrentTime();

                queryTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);
                if (!job.IsWorkHour(queryTime))
                {
                    IncStat("Too Early");
                    return(false);
                }

                return(base.Allow(sim));
            }
示例#5
0
 protected override bool PerformResults(CastIceBlastTerrainEx ths, string epicJazzName, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
 {
     if (spellCastingSucceeded)
     {
         ths.AnimateSim("SuccessIdle");
         SpeedTrap.Sleep((uint)SimClock.ConvertToTicks(2f, TimeUnit.Minutes));
         ths.AnimateSim("Success");
         ths.OnSpellSuccess();
         return(true);
     }
     else
     {
         return(base.PerformResults(ths, epicJazzName, definition, control, false, spellCastingEpiclyFailed));
     }
 }
示例#6
0
        protected static bool TryGiveDayOffForHoliday(Career job)
        {
            DateAndTime queryTime = SimClock.CurrentTime();

            queryTime.Ticks += SimClock.ConvertToTicks(2.1f, TimeUnit.Hours);
            if (job.IsWorkHour(queryTime))
            {
                //HolidayManager instance = HolidayManager.Instance;
                //if ((instance != null) && instance.IsThisDayAHoliday(queryTime))
                {
                    job.TakePaidTimeOff(1);
                    return(true);
                }
            }
            return(false);
        }
示例#7
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Sim sim = Sim.CreatedSim;

            BandInstrument.PlayBandInstrument <TInstrument> interaction = sim.InteractionQueue.GetCurrentInteraction() as BandInstrument.PlayBandInstrument <TInstrument>;
            if (interaction != null)
            {
                int elapsedCalendarDays = SimClock.ElapsedCalendarDays();

                SimData data = GetData <SimData>(Sim);

                DateAndTime lastChange = data.mLast;
                lastChange.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

                if (lastChange > SimClock.CurrentTime())
                {
                    data.mLast = SimClock.CurrentTime();

                    interaction.TriggerAudio(false);

                    if (interaction.mInstrumentSound == null)
                    {
                        Sims3.Gameplay.Skills.Guitar.Composition PlayingComposition = null;

                        try
                        {
                            PlayingComposition = (interaction.mSkill as BandSkill).GetRandomComposition(false);
                        }
                        catch (Exception)
                        {
                            // If the known compositions is zero, GetRandom will except
                        }

                        if (PlayingComposition != null)
                        {
                            interaction.mInstrumentSound = new ObjectSound(interaction.Target.ObjectId, PlayingComposition.AudioClip);
                            interaction.mInstrumentSound.StartLoop();
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
        public override Phone.Call.ConversationBehavior OnCallConnected()
        {
            try
            {
                if ((Actor.LotHome == null) || !Actor.IsSelectable)
                {
                    return(Phone.Call.ConversationBehavior.JustHangUp);
                }

                float arrivalTime = Phone.kForeignVisitorArrivalTime;

                DateAndTime startTime = SimClock.CurrentTime();

                if (!Common.kDebugging)
                {
                    float hoursPassedOfDay = SimClock.HoursPassedOfDay;
                    float num2             = 24f - (hoursPassedOfDay - arrivalTime);
                    if (num2 < 1f)
                    {
                        num2 += 24f;
                    }

                    long ticks = SimClock.ConvertToTicks(num2, TimeUnit.Hours);
                    startTime += new DateAndTime(ticks);
                }

                SimpleMessageDialog.Show(Common.LocalizeEAString("Gameplay/Situations/Party:InviteForeignVisitorsTitle"), Common.LocalizeEAString(false, "Gameplay/Situations/Party:InviteForeignVisitorsStart", new object[] { arrivalTime }), ModalDialog.PauseMode.PauseSimulator);

                new ForeignVisitorsSituationEx(Actor.LotHome, Actor, new List <MiniSimDescription>(mSimsToCall), startTime);

                return(Phone.Call.ConversationBehavior.ExpressSatisfaction);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }

            return(ConversationBehavior.JustHangUp);
        }
示例#9
0
        private void calculateNextShowTime()
        {
            if (mShowIndex < ShowTimes.Length)
            {
                float timeUntilShow = SimClock.HoursUntil(ShowTimes[mShowIndex]);

                long timeAsLong = SimClock.ConvertToTicks(timeUntilShow, TimeUnit.Hours);
                this.mNextShowTime = SimClock.CurrentTicks + timeAsLong;
                if (Message.Sender.IsDebugging())
                {
                    Message.Sender.Debug(this, "Show " + mShowIndex + " is in " + timeUntilShow.ToString() + " hours");
                }
                mShowIndex++;
            }
            else
            {
                mNextShowTime = long.MaxValue;
            }
        }
示例#10
0
            protected override bool Allow(SimDescription sim)
            {
                if (CommuteAlarmRunning())
                {
                    IncStat("Running");
                    return(false);
                }

                DateAndTime queryTime = SimClock.CurrentTime();

                queryTime.Ticks += SimClock.ConvertToTicks(3f, TimeUnit.Hours);
                if (!Job.IsWorkHour(queryTime))
                {
                    IncStat("Too Early");
                    return(false);
                }

                return(base.Allow(sim));
            }
示例#11
0
        public static void OnAlarm()
        {
            if (sFirstAlarm)
            {
                sFirstAlarm = false;
                StyledNotification.Show(new StyledNotification.Format("Work Pusher Activated", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage));
            }

            int iJobSync = 0, iSchoolSync = 0;
            int iJobTwoHourPush = 0, iSchoolTwoHourPush = 0;

            string sJobNames = null, sSchoolNames = null;

            DateAndTime NowTime     = SimClock.CurrentTime();
            DateAndTime TwoHourTime = SimClock.CurrentTime();

            TwoHourTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

            List <Sim> sims = new List <Sim>(Sims3.Gameplay.Queries.GetObjects <Sim>());

            foreach (Sim sim in sims)
            {
                if (sim.CareerManager == null)
                {
                    continue;
                }

                if (sim.Household == null)
                {
                    continue;
                }

                if (sim.Household.IsServiceNpcHousehold)
                {
                    continue;
                }

                {
                    Career job = sim.Job;
                    if (job != null)
                    {
                        float fPrevValue = job.HoursUntilWork;

                        job.SetHoursUntilWork();

                        if (fPrevValue > job.HoursUntilWork + 1f)
                        {
                            iJobSync++;
                        }

                        if (job.ShouldBeAtWork(NowTime))
                        {
                            sCarPoolers.Remove(sim);

                            InteractionInstance instance = job.CreateWorkInteractionInstance();
                            if (instance != null)
                            {
                                if ((((AutonomyRestrictions.GetLevel() >= AutonomyLevel.Two) && kPushActive) || sim.IsNPC) &&
                                    (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                {
                                    VisitSituation.AnnounceTimeToGoToWork(sim);

                                    sim.InteractionQueue.CancelAllInteractions();

                                    sim.InteractionQueue.Add(instance);

                                    sJobNames += "\n" + sim.Name;
                                }
                            }
                        }
                        else
                        {
                            if ((!sCarPoolers.ContainsKey(sim)) &&
                                (job.CurLevel != null) &&
                                (job.ShouldBeAtWork(TwoHourTime)))
                            {
                                // Check to see if the timer is already running, and if so, don't bother
                                if ((job.mRegularWorkDayGoToWorkHandle == AlarmHandle.kInvalidHandle) ||
                                    (AlarmManager.Global.GetTimeLeft(job.mRegularWorkDayGoToWorkHandle, TimeUnit.Minutes) <= 0))
                                {
                                    iJobTwoHourPush++;

                                    if (job.mRegularWorkDayTwoHoursBeforeStartHandle != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(job.mRegularWorkDayTwoHoursBeforeStartHandle);
                                        job.mRegularWorkDayTwoHoursBeforeStartHandle = AlarmHandle.kInvalidHandle;
                                    }

                                    if ((!sim.IsSelectable || !job.CarpoolEnabled) || !job.CurLevel.HasCarpool)
                                    {
                                        InteractionInstance instance = job.CreateWorkInteractionInstance();
                                        if ((instance != null) &&
                                            (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                        {
                                            sim.InteractionQueue.CancelAllInteractions();
                                        }

                                        float num  = ((job.CurLevel.StartTime - NowTime.Hour) + 24f) % 24f;
                                        float time = num - job.AverageTimeToReachWork;
                                        if (time < 0f)
                                        {
                                            time = 0f;
                                        }
                                        job.mRegularWorkDayGoToWorkHandle = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, new AlarmTimerCallback(job.RegularWorkDayGoToWorkHandle), "Career: time to push go to work", AlarmType.AlwaysPersisted, job.OwnerDescription);
                                    }
                                    else
                                    {
                                        sCarPoolers.Add(sim, true);

                                        StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Objects/Vehicles/CarpoolManager:CarpoolComing", new object[] { sim }), ObjectGuid.InvalidObjectGuid, sim.ObjectId, StyledNotification.NotificationStyle.kGameMessagePositive);
                                        StyledNotification.Show(format, job.CareerIconColored);
                                    }
                                }
                            }
                        }
                    }
                }

                {
                    School school = sim.CareerManager.School;
                    if (school != null)
                    {
                        float fPrevValue = school.HoursUntilWork;

                        school.SetHoursUntilWork();

                        if (fPrevValue > school.HoursUntilWork + 1f)
                        {
                            iSchoolSync++;
                        }

                        if (school.ShouldBeAtWork(NowTime))
                        {
                            sBusPoolers.Remove(sim);

                            InteractionInstance instance = school.CreateWorkInteractionInstance();
                            if (instance != null)
                            {
                                if ((((AutonomyRestrictions.GetLevel() >= AutonomyLevel.Two) && kPushActive) || sim.IsNPC) &&
                                    (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                {
                                    VisitSituation.AnnounceTimeToGoToWork(sim);

                                    sim.InteractionQueue.CancelAllInteractions();

                                    sim.InteractionQueue.Add(instance);

                                    sSchoolNames += "\n" + sim.Name;
                                }
                            }
                        }
                        else
                        {
                            if ((!sBusPoolers.ContainsKey(sim)) &&
                                (school.ShouldBeAtWork(TwoHourTime)))
                            {
                                // Check to see if the timer is already running, and if so, don't bother
                                if ((school.mRegularWorkDayGoToWorkHandle == AlarmHandle.kInvalidHandle) ||
                                    (AlarmManager.Global.GetTimeLeft(school.mRegularWorkDayGoToWorkHandle, TimeUnit.Minutes) <= 0))
                                {
                                    iSchoolTwoHourPush++;

                                    if (school.mRegularWorkDayTwoHoursBeforeStartHandle != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(school.mRegularWorkDayTwoHoursBeforeStartHandle);
                                        school.mRegularWorkDayTwoHoursBeforeStartHandle = AlarmHandle.kInvalidHandle;
                                    }

                                    if (school.PickUpCarpool != null)
                                    {
                                        sBusPoolers.Add(sim, true);

                                        school.PickUpCarpool.TryShowTNS(sim, Localization.LocalizeString("Gameplay/Objects/Vehicles/CarpoolManager:SchoolBusComing", new object[] { sim }), Localization.LocalizeString("Ui/Tooltip/Hud/School:SchoolBusArrives", new object[] { SimClockUtils.GetText((int)(school.CurLevel.StartTime - 1f), 0) }));
                                    }
                                    else
                                    {
                                        InteractionInstance instance = school.CreateWorkInteractionInstance();
                                        if ((instance != null) &&
                                            (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                        {
                                            sim.InteractionQueue.CancelAllInteractions();
                                        }

                                        float num  = ((school.CurLevel.StartTime - NowTime.Hour) + 24f) % 24f;
                                        float time = num - school.AverageTimeToReachWork;
                                        if (time < 0f)
                                        {
                                            time = 0f;
                                        }
                                        school.mRegularWorkDayGoToWorkHandle = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, new AlarmTimerCallback(school.RegularWorkDayGoToWorkHandle), "Career: time to push go to work", AlarmType.AlwaysPersisted, school.OwnerDescription);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            bool bShow = false;

            string msg = "Work Pusher:";

            if (iJobSync > 0)
            {
                msg  += "\nWork Alarms Resync'd: " + iJobSync.ToString();
                bShow = true;
            }
            if (iJobTwoHourPush > 0)
            {
                msg  += "\nWork Two Hour Alarms: " + iJobTwoHourPush.ToString();
                bShow = true;
            }
            if (sJobNames != null)
            {
                msg  += "\nPushed to Work: " + sJobNames;
                bShow = true;
            }
            if (iSchoolSync > 0)
            {
                msg  += "\nSchool Alarms Resync'd: " + iSchoolSync.ToString();
                bShow = true;
            }
            if (iSchoolTwoHourPush > 0)
            {
                msg  += "\nSchool Two Hour Alarms: " + iSchoolTwoHourPush.ToString();
                bShow = true;
            }
            if (sSchoolNames != null)
            {
                msg  += "\nPushed to School: " + sSchoolNames;// iSchoolCount.ToString();
                bShow = true;
            }

            if ((bShow) && (sVerbose))
            {
                StyledNotification.Show(new StyledNotification.Format(msg, ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage));
            }
        }
示例#12
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            //if (!UIUtils.IsOkayToStartModalDialog()) return false;

            bool hasExclusiveAccess;
            Lot  partyVenue = GetVenue(parameters.mActor, out hasExclusiveAccess);

            float            num2;
            OutfitCategories formalwear;

            Sims3.Gameplay.Situations.Party party = null;
            bool isPartyAtHome = (partyVenue == parameters.mActor.LotHome);

            if (partyVenue == null)
            {
                return(OptionResult.Failure);
            }
            if (!parameters.mActor.IsSelectable)
            {
                return(OptionResult.Failure);
            }

            PartyPickerDialog.PartyType partyTypes = PartyPickerDialog.PartyType.kAll;

            // Keep as GameUtils
            if (GameUtils.IsOnVacation())
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kBirthday;
            }

            if (partyVenue.LastDiedSim == null)
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kFuneral;
            }

            Sim actorSim = parameters.mActor as Sim;

            Political job = actorSim.Occupation as Political;

            if ((job == null) || (!job.HasCampaignMoneyMetric()))
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kCampaign;
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kWedding;

            foreach (Sim sim in CommonSpace.Helpers.Households.AllSims(parameters.mActor.Household))
            {
                if (sim.IsEngaged)
                {
                    partyTypes |= PartyPickerDialog.PartyType.kWedding;
                    break;
                }
            }

            if (!GameUtils.IsInstalled(ProductVersion.EP4))
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kBachelorParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
            }
            else
            {
                if (isPartyAtHome)
                {
                    if (!actorSim.SimDescription.Child)
                    {
                        partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                    }

                    if (!actorSim.SimDescription.Teen)
                    {
                        partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                        partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
                    }
                }
                else
                {
                    partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                    partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                    partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
                }
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kPoolParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kFeastParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kCostumeParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kGiftGivingParty;
            if (GameUtils.IsInstalled(ProductVersion.EP8) /*&& isPartyAtHome*/)
            {
                partyTypes |= PartyPickerDialog.PartyType.kFeastParty;
                partyTypes |= PartyPickerDialog.PartyType.kCostumeParty;
                partyTypes |= PartyPickerDialog.PartyType.kGiftGivingParty;
                //if (PoolParty.CanSimThrowPoolParty(actorSim))
                if (partyVenue.GetSwimmingPoolCount() > 0)
                {
                    partyTypes |= PartyPickerDialog.PartyType.kPoolParty;
                }
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kJuiceKeggerParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kBonfire;
            partyTypes &= ~PartyPickerDialog.PartyType.kTailgatingParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kVideoGameLANParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kMasqueradeBall;
            partyTypes &= ~PartyPickerDialog.PartyType.kVictoryParty;

            if (GameUtils.IsInstalled(ProductVersion.EP9))
            {
                partyTypes |= PartyPickerDialog.PartyType.kTailgatingParty;
                partyTypes |= PartyPickerDialog.PartyType.kVideoGameLANParty;
                partyTypes |= PartyPickerDialog.PartyType.kMasqueradeBall;
                partyTypes |= PartyPickerDialog.PartyType.kVictoryParty;

                if (JuiceKeggerParty.CanSimThrowJuiceKeggerParty(actorSim))
                {
                    partyTypes |= PartyPickerDialog.PartyType.kJuiceKeggerParty;
                }

                if (BonfireParty.CanSimThrowBonfire(actorSim))
                {
                    partyTypes |= PartyPickerDialog.PartyType.kBonfire;
                }
            }

            bool         criteriaCanceled;
            SimSelection list = SimSelection.Create(Common.Localize("Party:SelectTitle"), actorSim.SimDescription, this, GetCriteria(parameters), false, false, out criteriaCanceled);

            if (list.IsEmpty)
            {
                SimpleMessageDialog.Show(Common.LocalizeEAString("Gameplay/Objects/Electronics/Phone/CallThrowParty:NoSimsWT"), Common.LocalizeEAString(parameters.mActor.IsFemale, "Gameplay/Objects/Electronics/Phone/CallThrowParty:NoSims", new object[] { parameters.mActor }), ModalDialog.PauseMode.PauseSimulator);
                return(OptionResult.Failure);
            }

            float openHour    = -1f;
            float closingHour = -1f;

            PartyPickerDialog.PartyInfo info = PartyPickerDialogEx.Show(partyTypes, list.GetPickerInfo(), parameters.mActor.GetThumbnailKey(), isPartyAtHome, 25, -1, openHour, closingHour, PartyPickerDialog.ClothingType.kNone, actorSim.IsFemale);
            if ((info == null) || (info.PartyType == PartyPickerDialog.PartyType.kNone))
            {
                return(OptionResult.Failure);
            }

            float hoursPassedOfDay = SimClock.HoursPassedOfDay;

            if (hoursPassedOfDay > info.Time)
            {
                num2 = 24f - (hoursPassedOfDay - info.Time);
            }
            else
            {
                num2 = info.Time - hoursPassedOfDay;
            }
            if (num2 < 1f)
            {
                num2 += 24f;
            }
            long        ticks            = SimClock.ConvertToTicks(num2, TimeUnit.Hours);
            DateAndTime startTime        = SimClock.CurrentTime() + new DateAndTime(ticks);
            bool        bHostIsLegendary = actorSim.HasTrait(TraitNames.LegendaryHost);
            float       fMaxLTR          = 0f;
            LTRData     data             = LTRData.Get(LongTermRelationshipTypes.Friend);

            if (data != null)
            {
                fMaxLTR = data.Liking - 1;
            }
            List <SimDescription> simList = new List <SimDescription>();

            foreach (object obj2 in info.SimList)
            {
                SimDescription simDescription = obj2 as SimDescription;
                if ((simDescription != null) && CanSimBeInvitedToParty(simDescription, partyVenue, actorSim, fMaxLTR, bHostIsLegendary, true))
                {
                    if (!simList.Contains(simDescription))
                    {
                        simList.Add(simDescription);
                        if (simDescription.TraitManager.HasElement(TraitNames.PartyAnimal))
                        {
                            Sim createdSim = simDescription.CreatedSim;
                            if (createdSim != null)
                            {
                                TraitTipsManager.ShowTraitTip(13271263770231522640L, createdSim, TraitTipsManager.TraitTipCounterIndex.PartyAnimal, TraitTipsManager.kPartyAnimalCountOfParties);
                            }
                        }
                        if (simDescription.IsCelebrity)
                        {
                            EventTracker.SendEvent(EventTypeId.kPartyInviteCeleb, parameters.mActor);
                        }
                    }

                    bool bShouldMatchAge = (simDescription.Age == actorSim.SimDescription.Age) && ((simDescription.Teen) || (simDescription.Child));
                    if (!hasExclusiveAccess && RandomUtil.RandomChance(HouseParty.HousePartyParams.PercentageChanceOfBringingAFriend))
                    {
                        SimDescription friend = SocialComponent.FindFriendNotInList(simDescription, simList, parameters.mActor.LotHome, bShouldMatchAge);
                        if ((friend != null) && CanSimBeInvitedToParty(friend, partyVenue, null, 0f, false, false))
                        {
                            simList.Add(friend);
                        }
                    }
                }
            }

            DateAndTime time = startTime;

            time.Ticks -= SimClock.ConvertToTicks(Sims3.Gameplay.Situations.Party.HoursToStartRentBeforePartyStart, TimeUnit.Hours);
            if (time.CompareTo(SimClock.CurrentTime()) < 0)
            {
                time = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Minutes, 2f);
            }

            if ((partyVenue != parameters.mActor.LotHome) && !RentScheduler.Instance.RentLot(partyVenue, actorSim, time, simList, hasExclusiveAccess))
            {
                SimpleMessageDialog.Show(string.Empty, Phone.Call.LocalizeCallString("ThrowParty", "CantRent", new object[] { parameters.mActor }), ModalDialog.PauseMode.PauseSimulator);
                return(OptionResult.Failure);
            }

            switch (info.ClothingType)
            {
            case PartyPickerDialog.ClothingType.kFormal:
                formalwear = OutfitCategories.Formalwear;
                break;

            case PartyPickerDialog.ClothingType.kCasual:
                formalwear = OutfitCategories.Everyday;
                break;

            case PartyPickerDialog.ClothingType.kSwimwear:
                formalwear = OutfitCategories.Swimwear;
                break;

            case PartyPickerDialog.ClothingType.kCostumes:
                formalwear = OutfitCategories.Everyday;
                break;

            default:
                formalwear = OutfitCategories.Everyday;
                break;
            }

            float infoTime = info.Time;

            switch (info.PartyType)
            {
            case PartyPickerDialog.PartyType.kCampaign:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FundraiserTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FundraiserStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new CampaignFundraiser(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewFundraiser, parameters.mActor);
                break;

            case PartyPickerDialog.PartyType.kBirthday:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BirthdayTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BirthdayStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BirthdayParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kWedding:
                string messageText = string.Empty;
                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    messageText = Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingStartWithArch", new object[] { infoTime });
                }
                else
                {
                    messageText = Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingStart", new object[] { infoTime });
                }

                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingTitle"), messageText, ModalDialog.PauseMode.PauseSimulator);

                EnsureFianceeIsInvitedToWeddingParty(actorSim, simList);

                party = new WeddingParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kFuneral:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FuneralTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FuneralStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new Funeral(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kBachelorParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BachelorPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BachelorStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BachelorParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewBachelorParty, actorSim);
                actorSim.SimDescription.SetHadBachelorParty();
                break;

            case PartyPickerDialog.PartyType.kTeenParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:TeenPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:TeenStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new TeenParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kChildSlumberParty:
            case PartyPickerDialog.PartyType.kTeenSlumberParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:SlumberPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:SlumberStart", new object[] { infoTime, actorSim }), ModalDialog.PauseMode.PauseSimulator);
                party = new SlumberParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kCostumeParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:CostumePartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:CostumePartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new CostumeParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kCostumePartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kGiftGivingParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:GiftGivingPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:GiftGivingPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new GiftGivingParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kGiftGivingPartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kPoolParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:PoolPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:PoolPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new PoolParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kSchedulePoolParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kFeastParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:FeastPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:FeastPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new FeastParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kFeastPartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kJuiceKeggerParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:JuiceKeggerPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:JuiceKeggerStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new JuiceKeggerParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewJuiceKeggerParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kTailgatingParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:TailgatingPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:TailgatingStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new TailgatingParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewTailgatingParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kBonfire:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:BonfireTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:BonfireStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BonfireParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewBonfireParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kVideoGameLANParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VideoGameLANPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VideoGameLANStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new VideoGameLANParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewVideoGameLANParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kMasqueradeBall:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:MasqueradeBallTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:MasqueradeStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new MasqueradeBall(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewMasqueradeBall, actorSim);
                break;

            case PartyPickerDialog.PartyType.kVictoryParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VictoryPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VictoryStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new VictoryParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewVictoryParty, actorSim);
                break;

            default:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:GenericTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:HouseStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new HouseParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;
            }

            if (party == null)
            {
                return(OptionResult.Failure);
            }

            foreach (SimDescription sim in party.GuestDescriptions)
            {
                Instantiation.EnsureInstantiate(sim, party.Lot);
            }

            EventTracker.SendEvent(new PartyEvent(EventTypeId.kThrewParty, actorSim, actorSim.SimDescription, party));
            if (actorSim.HasTrait(TraitNames.PartyAnimal))
            {
                TraitTipsManager.ShowTraitTip(13271263770231522640L, actorSim, TraitTipsManager.TraitTipCounterIndex.PartyAnimal, TraitTipsManager.kPartyAnimalCountOfParties);
            }
            return(OptionResult.SuccessClose);
        }
示例#13
0
        public override bool Run()
        {
            try
            {
                ProxyDefinition definition = InteractionDefinition as ProxyDefinition;

                if (mIsMaster)
                {
                    Actor.SynchronizationRole   = Sim.SyncRole.Initiator;
                    Actor.SynchronizationTarget = WooHooee;
                }
                else
                {
                    Actor.SynchronizationRole   = Sim.SyncRole.Receiver;
                    Actor.SynchronizationTarget = WooHooer;
                }

                bool success = false;
                try
                {
                    if (mIsMaster && !Actor.HasExitReason())
                    {
                        ElevatorWooHoo entry = definition.ProxyClone(WooHooer).CreateInstance(Target, WooHooee, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as ElevatorWooHoo;
                        entry.LinkedInteractionInstance = this;
                        entry.WooHooer = WooHooer;
                        entry.WooHooee = WooHooee;

                        if (!WooHooee.InteractionQueue.AddNext(entry))
                        {
                            return(false);
                        }
                    }

                    if (!SafeToSync())
                    {
                        return(false);
                    }

                    Actor.LoopIdle();
                    Actor.SynchronizationLevel = Sim.SyncLevel.NotStarted;
                    if (!Actor.WaitForSynchronizationLevelWithSim(Actor.SynchronizationTarget, Sim.SyncLevel.NotStarted, ElevatorDoors.kWooHooSyncTime))
                    {
                        FinishLinkedInteraction(mIsMaster);
                        return(false);
                    }

                    if (!Target.RouteToElevator(Actor))
                    {
                        FinishLinkedInteraction(mIsMaster);
                        return(false);
                    }

                    Target.InteriorObj.AddElevatorColumnToUseList(Actor);
                    Actor.RouteTurnToFace(Target.Position);
                    Actor.LoopIdle();
                    Actor.SynchronizationLevel = Sim.SyncLevel.Started;
                    if (!Actor.WaitForSynchronizationLevelWithSim(Actor.SynchronizationTarget, Sim.SyncLevel.Started, ElevatorDoors.kWooHooSyncTime))
                    {
                        FinishLinkedInteraction(mIsMaster);
                        return(false);
                    }

                    if (!Target.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.CutToHeadOfLine, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), ElevatorDoors.kWooHooSyncTime))
                    {
                        FinishLinkedInteraction(mIsMaster);
                        return(false);
                    }

                    IsDoneRouting       = true;
                    CancellableByPlayer = false;
                    Slot slotName = Slot.RoutingSlot_0;
                    if (!mIsMaster)
                    {
                        slotName = Slot.RoutingSlot_1;
                    }
                    Actor.SimRoutingComponent.DisallowBeingPushed      = true;
                    Actor.SimRoutingComponent.ShouldIgnoreAllObstacles = true;
                    if (!Actor.RouteToSlot(Target.InteriorObj, slotName))
                    {
                        WanderOut();
                        FinishLinkedInteraction(mIsMaster);
                        return(false);
                    }
                    Target.SimLine.RemoveFromQueue(Actor);
                    Actor.LoopIdle();
                    Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                    if (!Actor.WaitForSynchronizationLevelWithSim(Actor.SynchronizationTarget, Sim.SyncLevel.Routed, ElevatorDoors.kWooHooSyncTime))
                    {
                        WanderOut();
                        FinishLinkedInteraction(mIsMaster);
                        return(false);
                    }
                    IsInsideElevator = true;
                    StandardEntry(false);
                    Actor.LoopIdle();
                    Actor.SimDescription.Contactable = false;
                    if (!StartSync(mIsMaster))
                    {
                        WanderOut();
                        StandardExit(false);
                        return(false);
                    }

                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        definition.Definition.Restart(mIsMaster, WooHooer, WooHooee, Autonomous, Target);
                    }
                }

                BeginCommodityUpdates();

                try
                {
                    if (mIsMaster)
                    {
                        AcquireStateMachine("Elevator");
                        SetActorAndEnter("x", Actor, "Enter");
                        SetActorAndEnter("y", WooHooee, "Enter");
                        SetActor("elevatorExterior", Target);

                        success = true;

                        if (Woohooer.Settings.UsingTraitScoring)
                        {
                            if (ScoringLookup.GetScore("ElevatorSuccess", Actor.SimDescription) < 0)
                            {
                                success = false;
                            }
                            else if (ScoringLookup.GetScore("ElevatorSuccess", WooHooee.SimDescription) < 0)
                            {
                                success = false;
                            }
                        }

                        if (success)
                        {
                            isWooHooing = true;
                            RockGemMetalBase.HandleNearbyWoohoo(Target, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                            AddOneShotScriptEventHandler(0x6e, WooHooTurnOnCensorBars);
                            AddOneShotScriptEventHandler(0x6f, WooHooTurnOffCensorBars);
                            mJealousyAlarm = AlarmManager.Global.AddAlarm(4f, TimeUnit.Minutes, StartJealousyBroadcaster, "StartJealousyBroadcaster", AlarmType.DeleteOnReset, Target);
                            AnimateJoinSims("WooHooAccept");

                            CommonWoohoo.RunPostWoohoo(Actor, WooHooee, Target, definition.GetStyle(this), definition.GetLocation(Target), true);

                            CommonWoohoo.TestNakedOutfit(Woohooer.Settings.mNakedOutfitElevator, WooHooer, WooHooee);

                            if (CommonPregnancy.IsSuccess(WooHooer, WooHooee, Autonomous, definition.GetStyle(this)))
                            {
                                CommonPregnancy.Impregnate(WooHooer, WooHooee, Autonomous, definition.GetStyle(this));
                            }

                            RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);
                            isWooHooing = false;
                        }
                        else
                        {
                            ElevatorDoors.WooHoo linkedInteractionInstance = LinkedInteractionInstance as ElevatorDoors.WooHoo;
                            if (linkedInteractionInstance != null)
                            {
                                linkedInteractionInstance.IsFail = true;
                            }
                            AddOneShotScriptEventHandler(0x65, new SacsEventHandler(WooHooRejectCallback));
                            AnimateJoinSims("WooHooReject");
                            SpeedTrap.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.RandomFloatGaussianDistribution(ElevatorDoors.kWooHooFailWaitTime[0x0], ElevatorDoors.kWooHooFailWaitTime[0x1]), TimeUnit.Minutes));
                            if (WooHooer.LotHome != Target.LotCurrent)
                            {
                                WooHooer.BuffManager.AddElement(BuffNames.WalkOfShame, Origin.FromRejectedWooHooOffHome);
                            }
                            Relationship.Get(WooHooee, WooHooer, true).LTR.UpdateLiking(ElevatorDoors.kWooHooRejectRelHit);
                        }
                        AnimateNoYield("y", "Exit");
                        AnimateSim("Exit");
                    }
                    Actor.SynchronizationLevel = Sim.SyncLevel.Committed;
                    Actor.WaitForSynchronizationLevelWithSim(Actor.SynchronizationTarget, Sim.SyncLevel.Committed, ElevatorDoors.kWooHooSyncTime);
                    if (IsFail && !mIsMaster)
                    {
                        Actor.SetPosition(Target.InteriorObj.GetPositionOfSlot(Slot.RoutingSlot_0));
                        SpeedTrap.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.RandomFloatGaussianDistribution(ElevatorDoors.kWooHooFailKickerOutWaitTime[0x0], ElevatorDoors.kWooHooFailKickerOutWaitTime[0x1]), TimeUnit.Minutes));
                    }
                    Target.RouteToElevator(Actor);
                    Actor.SynchronizationLevel = Sim.SyncLevel.Completed;
                    Actor.WaitForSynchronizationLevelWithSim(Actor.SynchronizationTarget, Sim.SyncLevel.Completed, ElevatorDoors.kWooHooSyncTime);
                    FinishLinkedInteraction(mIsMaster);
                    WaitForSyncComplete();
                }
                finally
                {
                    EndCommodityUpdates(true);
                }

                StandardExit(false);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
示例#14
0
        // replaces the method from RabbitHole class - identical except for new slot reassignment code
        public bool RouteNearEntranceAndEnterRabbitHole(Sim a, RabbitHole.IRabbitHoleFollowers inst, RabbitHole.BeforeEnteringRabbitHoleDelegate beforeEntering, bool canUseCar, Route.RouteMetaType routeMetaType, bool playRouteFailure)
        {
            if ((Target.RabbitHoleProxy.EnterSlots.Count == 0) || (Target.RabbitHoleProxy.ExitSlots.Count == 0))
            {
                return(false);
            }
            if (a.IsInRidingPosture && ((Target.RabbitHoleProxy.MountedEnterSlots.Count == 0) || (Target.RabbitHoleProxy.MountedExitSlots.Count == 0)))
            {
                return(false);
            }
            List <Sim>           list    = new List <Sim>();
            CarryingChildPosture posture = a.Posture as CarryingChildPosture;

            if (posture != null)
            {
                list.Add(posture.Child);
            }
            if (inst != null)
            {
                if (inst.SimFollowers != null)
                {
                    foreach (Sim sim in inst.SimFollowers)
                    {
                        posture = sim.Posture as CarryingChildPosture;
                        if (posture != null)
                        {
                            list.Add(posture.Child);
                        }
                    }
                    foreach (Sim sim2 in list)
                    {
                        inst.AddFollower(sim2);
                    }
                }
                else if (list.Count > 0)
                {
                    inst.AddFollower(list[0]);
                }
            }
            bool  flag   = false;
            Route item   = null;
            Sim   parent = null;

            if (a.IsInRidingPosture)
            {
                if (a.Parent is Sim)
                {
                    parent = a.Parent as Sim;
                }
                item = parent.CreateRoute();
                item.ExecutionFromNonSimTaskIsSafe = true;
            }
            else
            {
                item = a.CreateRoute();
            }
            bool flag2 = false;
            int  kRouteAttemptsToEnterRabbitHole = RabbitHole.kRouteAttemptsToEnterRabbitHole;
            Slot slotToUse = Slot.None;

            while ((kRouteAttemptsToEnterRabbitHole > 0) && !flag2)
            {
                kRouteAttemptsToEnterRabbitHole--;
                try
                {
                    Target.RabbitHoleProxy.ActiveEntryRoutes.Add(item);
                    if (playRouteFailure)
                    {
                        item.DoRouteFail = kRouteAttemptsToEnterRabbitHole == 0;
                    }
                    item.SetOption(Route.RouteOption.EnablePlanningAsCar, canUseCar);
                    if (Target.mGuid == RabbitHoleType.Subway)
                    {
                        item.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
                    }
                    if (Target.mGuid == RabbitHoleType.HoverTrainStation)
                    {
                        item.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false);
                    }
                    item.SetRouteMetaType(routeMetaType);
                    foreach (Slot slot2 in Target.RabbitHoleProxy.EnterSlots)
                    {
                        item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot2].Footprint.ObjectId);
                    }
                    foreach (Slot slot3 in Target.RabbitHoleProxy.MountedEnterSlots)
                    {
                        item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot3].Footprint.ObjectId);
                    }
                    item.PlanToSlot(Target.RabbitHoleProxy, (a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots).ToArray());
                    if (!item.PlanResult.Succeeded())
                    {
                        item.DoRouteFail = playRouteFailure;
                        if (a.IsInRidingPosture)
                        {
                            return(parent.DoRoute(item));
                        }
                        return(a.DoRoute(item));
                    }
                    slotToUse = (Slot)item.PlanResult.mDestSlotNameHash;

                    // Slot Reassignment
                    if ((Target.RabbitHoleProxy.EnterSlots.Count > 1) && (Target.RabbitHoleProxy.EnterSlots.Count <= 5))
                    {
                        slotToUse = ReassignSlot(Target.RabbitHoleProxy.EnterSlots.Count);
                    }
                    List <Sim> followers = (inst == null) ? null : inst.SimFollowers;
                    if ((!flag && (followers != null)) && ((followers.Count > 1) || ((followers.Count == 1) && (followers[0].Posture.Container != a))))
                    {
                        //if (RouteOutside(a, followers, this.RabbitHoleProxy.EnterSlots[0x0], false, true, true, false))
                        if (Target.RouteOutside(a, followers, Target.RabbitHoleProxy.EnterSlots[0], false, true, true, false))
                        {
                            flag  = true;
                            flag2 = true;
                        }
                    }
                    else
                    {
                        //flag2 = RouteOutside(a, followers, none, false, true, false, false);
                        flag2 = Target.RouteOutside(a, followers, slotToUse, false, true, false, false);
                    }
                    if (!flag2 && (kRouteAttemptsToEnterRabbitHole > 0))
                    {
                        if (IntroTutorial.TutorialSim == a)
                        {
                            break;
                        }
                        a.RemoveExitReason(ExitReason.RouteFailed);
                        if (a.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
                        {
                            break;
                        }
                        a.LoopIdle();
                        Simulator.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(RabbitHole.kMinSimMinutesToSleepOnFailedRouteAttempt, RabbitHole.kMaxSimMinutesToSleepOnFailedRouteAttempt), TimeUnit.Minutes));
                    }
                    continue;
                }
                finally
                {
                    Target.RabbitHoleProxy.ActiveEntryRoutes.Remove(item);
                }
            }
            item = null;
            if (((a.ExitReason & ExitReason.HigherPriorityNext) == ExitReason.None) && ((a.ExitReason & ExitReason.UserCanceled) == ExitReason.None))
            {
                if (flag2)
                {
                    RabbitHole.NumSuccess++;
                }
                else
                {
                    RabbitHole.NumFail++;
                }
            }
            if (!flag2)
            {
                return(flag2);
            }
            if ((beforeEntering != null) && !beforeEntering())
            {
                List <Sim> simFollowers = null;
                if (inst != null)
                {
                    simFollowers = inst.SimFollowers;
                }
                //RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList<Slot>(a.IsInRidingPosture ? this.RabbitHoleProxy.MountedEnterSlots : this.RabbitHoleProxy.EnterSlots), false, false, true, true);
                Target.RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList <Slot>(a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots), false, false, true, true);
                return(false);
            }
            LeadingHorsePosture posture2 = a.Posture as LeadingHorsePosture;

            if (posture2 != null)
            {
                Sim container = posture2.Container as Sim;
                LeadingHorsePosture.ReleaseHorseFromLeadingPosture(a, container, false);
                Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType);
                Target.AnimateEnterRabbitHole(container, slotToUse, true, routeMetaType);
                return(flag2);
            }
            return(Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType));
        }
示例#15
0
        protected override bool OnPerform()
        {
            string msg = "OnPerform" + Common.NewLine;

            try
            {
                if ((TrafficManager.Singleton == null) || (LotManager.sLots == null))
                {
                    return(true);
                }

                Simulator.DestroyObject(TrafficManager.Singleton.mUpdateTrafficTask);
                TrafficManager.Singleton.mUpdateTrafficTask = ObjectGuid.InvalidObjectGuid;

                while (!TrafficManager.Enabled)
                {
                    FoodTruckManagerEx.Update();
                    SpeedTrap.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(TrafficManager.kTrafficCheckTime[0x0], TrafficManager.kTrafficCheckTime[0x1]), TimeUnit.Hours));
                }

                msg += "A";

                List <Lot> list = new List <Lot>();
                foreach (Lot lot in LotManager.AllLots)
                {
                    if (lot.StreetParking == null)
                    {
                        continue;
                    }

                    if (lot.IsWorldLot)
                    {
                        continue;
                    }

                    list.Add(lot);
                }

                if (TrafficManager.GeneratedTrafficTuning.sLotTuning == null)
                {
                    return(true);
                }

                msg += "B";

                PairedListDictionary <Type, int> dictionary = new PairedListDictionary <Type, int>();
                foreach (Type type in TrafficManager.GeneratedTrafficTuning.sLotTuning.Keys)
                {
                    if (!TrafficManager.Enabled)
                    {
                        break;
                    }

                    int[] carRange = TrafficManager.GeneratedTrafficTuning.GetCarRange(type);
                    if (carRange == null)
                    {
                        continue;
                    }

                    if (Math.Max(carRange[0x0], carRange[0x1]) > 0x0)
                    {
                        msg += "C";

                        int numTaxis = RandomUtil.GetInt(carRange[0x0], carRange[0x1]);
                        foreach (Lot lot in list)
                        {
                            if (!TrafficManager.Enabled)
                            {
                                break;
                            }

                            int num2 = (int)Sims3.SimIFace.Queries.CountObjects(type, lot.LotId);
                            if (num2 > 0x0)
                            {
                                msg += "D";

                                PairedListDictionary <Type, int> dictionary2;
                                Type type2;
                                int  num3 = 0x0;
                                if (TrafficManager.sGeneratedCarCount != null)
                                {
                                    TrafficManager.sGeneratedCarCount.TryGetValue(type.ToString(), out num3);
                                }

                                msg += "E";

                                if (!dictionary.ContainsKey(type))
                                {
                                    dictionary.Add(type, 0x0);
                                }

                                msg += "F";

                                (dictionary2 = dictionary)[type2 = type] = dictionary2[type2] + num2;
                                if (num3 < (numTaxis * dictionary[type]))
                                {
                                    msg += "G";

                                    CarNpcWithNoDriver car = GlobalFunctions.CreateObjectOutOfWorld("CarTaxiLightweight", ProductVersion.EP3) as CarNpcWithNoDriver;
                                    if (car != null)
                                    {
                                        Matrix44 mat = new Matrix44();
                                        if (lot.StreetParking.GetParkingSpotForCar(car, ref mat))
                                        {
                                            msg += "H";

                                            Vector3[]    vectorArray;
                                            Quaternion[] quaternionArray;
                                            if (World.FindPlaceOnRoadOffScreen(car.Proxy, mat.pos.V3, FindPlaceOnRoadOption.Road, 100f, out vectorArray, out quaternionArray))
                                            {
                                                msg += "I";

                                                car.GeneratingClassName = type.ToString();
                                                car.PlaceAt(vectorArray[0x0], mat.at.V3, null);
                                                car.DriveAroundFor(RandomUtil.GetFloat(TrafficManager.kCarDriveAroundTimeRange[0x0], TrafficManager.kCarDriveAroundTimeRange[0x1]), TimeUnit.Hours);
                                            }
                                            else
                                            {
                                                car.Destroy();
                                            }

                                            msg += "J";

                                            lot.StreetParking.FreeParkingSpotForCar(car);
                                            SpeedTrap.Sleep((uint)RandomUtil.GetInt(TrafficManager.kAfterSpawnWaitTime[0x0], TrafficManager.kAfterSpawnWaitTime[0x1]));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                msg += "K";

                // Custom
                FoodTruckManagerEx.Update();

                msg += "L";

                uint tickCount = (uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(TrafficManager.kTrafficCheckTime[0x0], TrafficManager.kTrafficCheckTime[0x1]), TimeUnit.Hours);
                SpeedTrap.Sleep(tickCount);
            }
            catch (Exception e)
            {
                Common.Exception(msg, e);
            }

            return(true);
        }
示例#16
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Guests.Count < TargetMinimum)
            {
                IncStat("Too Few");
                return(false);
            }

            AddStat("Guests", Guests.Count);

            if (Household.ActiveHousehold != null)
            {
                foreach (SimDescription active in HouseholdsEx.Humans(Household.ActiveHousehold))
                {
                    Target = active;
                    if (!TargetAllow(active))
                    {
                        continue;
                    }

                    if (mGuests.Contains(active))
                    {
                        continue;
                    }

                    if (ManagerFriendship.AreFriends(Sim, active))
                    {
                        mGuests.Add(active);
                    }
                }

                Target = null;
            }

            int delay = 3;

            if (Lot == Sim.LotHome)
            {
                Situations.PushGoHome(this, Sim);

                PushBuffetInteractions(this, Sim, Lot);

                DateAndTime startTime = SimClock.CurrentTime();
                startTime.Ticks += SimClock.ConvertToTicks(3f, TimeUnit.Hours);

                /*
                 * if (Lot != Sim.LotHome)
                 * {
                 *  DateAndTime rentTime = startTime;
                 *  rentTime.Ticks -= SimClock.ConvertToTicks(Sims3.Gameplay.Situations.Party.HoursToStartRentBeforePartyStart, TimeUnit.Hours);
                 *  if (rentTime.CompareTo(SimClock.CurrentTime()) < 0)
                 *  {
                 *      rentTime = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Minutes, 2f);
                 *  }
                 *
                 *  if (!RentScheduler.Instance.RentLot(Lot, Sim.CreatedSim, rentTime, Guests))
                 *  {
                 *      IncStat("Couldn't Rent");
                 *      Lot = Sim.LotHome;
                 *  }
                 * }
                 */

                Party party = GetParty(Lot, Sim.CreatedSim, Guests, PartyAttire, startTime);

                EventTracker.SendEvent(new PartyEvent(EventTypeId.kThrewParty, Sim.CreatedSim, Sim, party));

                delay = 3;
            }
            else
            {
                List <Sim> followers = new List <Sim>();

                foreach (SimDescription guest in Guests)
                {
                    if (SimTypes.IsSelectable(guest))
                    {
                        continue;
                    }

                    if (!Sims.Instantiate(guest, Lot, false))
                    {
                        continue;
                    }

                    Sim guestSim = guest.CreatedSim;
                    if (guestSim == null)
                    {
                        continue;
                    }

                    guestSim.PushSwitchToOutfitInteraction(Sims3.Gameplay.Actors.Sim.ClothesChangeReason.GoingToSituation, PartyAttire);

                    followers.Add(guestSim);
                }

                AddStat("Followers", followers.Count);

                if (!Situations.PushMassVisit(this, Sim, followers, Lot))
                {
                    return(false);
                }

                delay = 0;
            }

            if (mReport)
            {
                Manager.AddAlarm(new DelayedStoryScenario(this, delay));
            }

            return(true);
        }
示例#17
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);
                        }
                    }
                }
            }
        }