public void Dispose() { if ((mOpportunities != null) && (mSim.OpportunityHistory != null)) { mSim.OpportunityHistory.mCurrentOpportunities = mOpportunities; mSim.NeedsOpportunityImport = (true); if (mSim.CreatedSim != null) { if (mSim.CreatedSim.mOpportunityManager == null) { mSim.CreatedSim.mOpportunityManager = new OpportunityManager(mSim.CreatedSim); mSim.CreatedSim.mOpportunityManager.SetupLocationBasedOpportunities(); } try{ // [NRaas:]Due to an odd bit of coding at the bottom of AcceptOpportunityFromTravel(), // the expiration time for non-expirying opportunities is checked foreach (OpportunityHistory.OpportunityExportInfo info in mSim.OpportunityHistory.GetCurrentOpportunities()) { if (info.ExpirationTime < SimClock.CurrentTime()) { Opportunity opp = OpportunityManager.GetStaticOpportunity(info.Guid); if (opp != null) { bool requiresTimeout = (false); switch (opp.Timeout) { case Opportunity.OpportunitySharedData.TimeoutCondition.SimDays: case Opportunity.OpportunitySharedData.TimeoutCondition.SimHours: case Opportunity.OpportunitySharedData.TimeoutCondition.SimTime: case Opportunity.OpportunitySharedData.TimeoutCondition.Gig: case Opportunity.OpportunitySharedData.TimeoutCondition.AfterschoolRecitalOrAudition: requiresTimeout = (true); break; } if (!requiresTimeout) { info.ExpirationTime = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 1); } } } } mSim.CreatedSim.OpportunityManager.TravelFixup(); }catch (Exception exception) { // Get stack trace for the exception. with source file information var st = new StackTrace(exception, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + line); }finally{ } mSim.NeedsOpportunityImport = (false); } } }
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); }
public void Dispose() { if ((mOpportunities != null) && (mSim.OpportunityHistory != null)) { mSim.OpportunityHistory.mCurrentOpportunities = mOpportunities; mSim.NeedsOpportunityImport = true; if (mSim.CreatedSim != null) { if (mSim.CreatedSim.mOpportunityManager == null) { mSim.CreatedSim.mOpportunityManager = new OpportunityManager(mSim.CreatedSim); mSim.CreatedSim.mOpportunityManager.SetupLocationBasedOpportunities(); } try { // Due to an odd bit of coding at the bottom of AcceptOpportunityFromTravel(), // the expiration time for non-expirying opportunities is checked foreach (OpportunityHistory.OpportunityExportInfo info in mSim.OpportunityHistory.GetCurrentOpportunities()) { if (info.ExpirationTime < SimClock.CurrentTime()) { Opportunity opp = OpportunityManager.GetStaticOpportunity(info.Guid); if (opp != null) { bool requiresTimeout = false; switch (opp.Timeout) { case Opportunity.OpportunitySharedData.TimeoutCondition.SimDays: case Opportunity.OpportunitySharedData.TimeoutCondition.SimHours: case Opportunity.OpportunitySharedData.TimeoutCondition.SimTime: case Opportunity.OpportunitySharedData.TimeoutCondition.Gig: case Opportunity.OpportunitySharedData.TimeoutCondition.AfterschoolRecitalOrAudition: requiresTimeout = true; break; } if (!requiresTimeout) { info.ExpirationTime = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 1); } } } } mSim.CreatedSim.OpportunityManager.TravelFixup(); } catch (Exception e) { Common.Exception(mSim, e); } mSim.NeedsOpportunityImport = false; } } }
private void CheckIfGuestsNeedToGoHome() { List <Sim> simsToGoHome = new List <Sim>(); foreach (Sim sim in Guests) { bool flag = VisitSituation.IsGuestAllowedToStayOver(sim); if (sim.MoodManager.IsInStrongNegativeMood || (!flag && (sim.BuffManager.HasElement(BuffNames.Tired) || sim.BuffManager.HasElement(BuffNames.Exhausted)))) { AddSimToGoHome(sim, simsToGoHome); } if (sim.SimDescription.ChildOrBelow && (SimClock.Hours24 >= GetParams().HourAtWhichChildrenGoHome)) { AddSimToGoHome(sim, simsToGoHome); foreach (Genealogy genealogy in sim.Genealogy.Parents) { SimDescription simDescription = genealogy.SimDescription; if (simDescription != null) { Sim createdSim = simDescription.CreatedSim; if ((createdSim != null) && Guests.Contains(createdSim)) { AddSimToGoHome(createdSim, simsToGoHome); } } } } float delta = sim.MoodManager.MoodValue * GetParams().MoodToTimeMod; DateAndTime time; if (!flag && mTimeForSimToLeave.TryGetValue(sim.ObjectId, out time)) { time = SimClock.Add(time, TimeUnit.Minutes, delta); if (time.CompareTo(SimClock.CurrentTime()) < 0x0) { AddSimToGoHome(sim, simsToGoHome); } else { mTimeForSimToLeave[sim.ObjectId] = time; } } } foreach (Sim sim3 in simsToGoHome) { if (sim3.LotCurrent == Lot) { MakeGuestGoHome(sim3); } } }
private static void CalculateDateTimeOfHoliday(HolidayManager ths, ref Season season) { DateAndTime startTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour); startTime = SimClock.Subtract(startTime, TimeUnit.Days, Tempest.GetCurrentSeasonDay() - 1); List <Pair <Season, uint> > days = new List <Pair <Season, uint> >(); HolidaySettings settings = Tempest.Settings.GetHolidays(season); Common.StringBuilder result = new Common.StringBuilder("Season: " + season); result += Common.NewLine + "CurrentTime: " + SimClock.CurrentTime(); result += Common.NewLine + "StartTime: " + startTime; result += Common.NewLine + "ExpectedEndTime: " + SeasonsManager.ExpectedEndTime; result += Common.NewLine + "GetCurrentSeasonDay: " + Tempest.GetCurrentSeasonDay(); result += Common.NewLine + SimClock.ElapsedTime(TimeUnit.Days, startTime); foreach (HolidaySettings.Holiday day in settings.Days) { uint actualDay = day.GetActualDay(season); if (actualDay == 0) { continue; } days.Add(new Pair <Season, uint>(day.mSeason, actualDay - 1)); } days.Sort(SortByDay); foreach (Pair <Season, uint> day in days) { ths.mStartDateTimeOfHoliday = SimClock.Add(startTime, TimeUnit.Days, day.Second); result += Common.NewLine + "Days: " + day.Second + " Time: " + ths.mStartDateTimeOfHoliday; if (ths.mStartDateTimeOfHoliday.Ticks < SimClock.CurrentTicks) { ths.mStartDateTimeOfHoliday = DateAndTime.Invalid; } else { result += Common.NewLine + " Success"; season = day.First; break; } } Common.DebugNotify(result); }
public bool TryCreateJobForCustomer(Occupation ths, JobCreationSpec jobCreationSpec, OccupationLevelStaticData levelStaticData, out Job job) { job = null; jobCreationSpec.mJobDestinationType = jobCreationSpec.JobStaticData.DestinationType; jobCreationSpec.mCustomerType = JobCustomerType.Random; if ((jobCreationSpec.mLot == null) || !ths.TryCreateJob(jobCreationSpec, levelStaticData, out job)) { IncStat("CreateJob Fail"); return(false); } DateAndTime date = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 0); Occupation.MarkJobForCooldown(job, date); return(true); }
public void OnRouteToPartySucceeded(Sim actor, float x) { if (actor.LotCurrent != Lot) { OnRouteToPartyFailed(actor, x); } else if (actor != Host) { OnGuestHasArrived(actor); if (!actor.IsSelectable) { actor.Motives.SetMax(CommodityKind.Energy); } Relationship relationshipToHostedSituation = Relationship.Get(Host.SimDescription, actor.SimDescription, false); if (actor.SimDescription.Household != Host.SimDescription.Household) { relationshipToHostedSituation = GetRelationshipToHostedSituation(Host.SimDescription, actor.SimDescription); } float delta = GetParams().MinPartyTime; if (relationshipToHostedSituation != null) { delta += ((relationshipToHostedSituation.LTR.Liking + 100f) * GetParams().RelToTimeMod); } mTimeForSimToLeave[actor.ObjectId] = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, delta); actor.PlayReaction(ReactionTypes.Wave, Host, ReactionSpeed.CriticalWithRoute); if (Child is Start) { SetState(new Happening(this)); } else if (Child is Prepare) { SetState(new GetDressed(this)); } } }
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); }
public override bool Run() { string msg = null; try { mStart = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 3); StandardEntry(); if (!Target.StartComputing(this, SurfaceHeight.Table, true)) { StandardExit(); return(false); } msg += "A"; mWritingSkill = Actor.SkillManager.AddElement(SkillNames.Writing) as Writing; Target.StartVideo(Computer.VideoType.WordProcessor); mStartWritingTime = SimClock.CurrentTime(); BeginCommodityUpdates(); bool playFilledEffect = false; try { if (mWritingSkill.CurrentWriting == null) { msg += "B"; BookData.BookGenres choice = mWritingSkill.mNovelistGenre; if (choice == BookData.BookGenres.None) { List <BookData.BookGenres> genres = new List <BookData.BookGenres>(); foreach (BookData.BookGenres genre in Enum.GetValues(typeof(BookData.BookGenres))) { if (genre == BookData.BookGenres.None) { continue; } if (genre == BookData.BookGenres.Biography) { continue; } if (genre == BookData.BookGenres.Autobiography) { continue; } if (!Writing.CanWriteGenre(Actor, genre)) { continue; } switch (genre) { case BookData.BookGenres.Horror: case BookData.BookGenres.Poetry: if (!GameUtils.IsInstalled(ProductVersion.EP7)) { continue; } break; } genres.Add(genre); } if (genres.Count == 0) { return(false); } msg += "C"; if ((SimTypes.IsSelectable(mWritingSkill.SkillOwner)) || (StoryProgression.Main.GetValue <PromptForGenreOption, bool>())) { List <GenreOption> choices = new List <GenreOption>(); foreach (BookData.BookGenres genre in genres) { int count = 0; if (mWritingSkill.WrittenBookGenreCount != null) { if (!mWritingSkill.WrittenBookGenreCount.TryGetValue(genre, out count)) { count = 0; } } choices.Add(new GenreOption(genre, count)); } GenreOption option = new CommonSelection <GenreOption>(Common.Localize("ChooseBookGenre:Header", mWritingSkill.SkillOwner.IsFemale), mWritingSkill.SkillOwner.FullName, choices).SelectSingle(); if (option != null) { choice = option.Value; } } msg += "D"; if (choice == BookData.BookGenres.None) { choice = RandomUtil.GetRandomObjectFromList(genres); } } msg += "E"; if (!StartNewWriting(Target, mWritingSkill, choice)) { AnimateSim("WorkTyping"); EndCommodityUpdates(false); Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false); StandardExit(); return(false); } } msg += "F"; AnimateSim("WorkTyping"); ProgressMeter.ShowProgressMeter(Actor, 0f, ProgressMeter.GlowType.Weak); playFilledEffect = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), LoopDel, null); ProgressMeter.HideProgressMeter(Actor, playFilledEffect); float points = SimClock.ElapsedTime(TimeUnit.Hours, mStartWritingTime) * Computer.kWritingNovelPointsPerHour; mWritingSkill.AddPoints(points); } finally { EndCommodityUpdates(playFilledEffect); } msg += "G"; Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false); if (mWritingSkill.IsWritingComplete()) { WrittenBookData currentWriting = mWritingSkill.CurrentWriting; if (!BookData.BookWrittenDataList.ContainsKey(currentWriting.Title + mWritingSkill.SkillOwner.FullName)) { List <Lot> lots = new List <Lot>(); if ((!SimTypes.IsSelectable(Actor)) && (!StoryProgression.Main.GetValue <AddBooksToLibraryOption, bool>())) { foreach (Lot lot in LotManager.AllLots) { if (lot.GetMetaAutonomyType == Lot.MetaAutonomyType.Library) { lots.Add(lot); lot.mMetaAutonomyType = Lot.MetaAutonomyType.None; } } } try { msg += "H"; Target.FinalizeWriting(mWritingSkill); } finally { foreach (Lot lot in lots) { lot.mMetaAutonomyType = Lot.MetaAutonomyType.Library; } } } } msg += "I"; StandardExit(); return(playFilledEffect); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, msg, e); return(false); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (PromSituation.sInstance == null) { DateAndTime checkDay = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Days, PromSituation.kNumberOfDaysForAnnouncement); if (!HasValue <ValidDaysOption, DaysOfTheWeek>(checkDay.DayOfWeek)) { IncStat("Wrong Day: " + checkDay.DayOfWeek); return(false); } int elapsed = (SimClock.ElapsedCalendarDays() - GetValue <DayOfLastOption, int>()); if (elapsed < GetValue <CooldownOption, int>()) { AddStat("Cooldown", elapsed); return(false); } if (!RandomUtil.RandomChance(GetValue <ChanceOption, int>())) { IncStat("Chance Fail"); return(false); } if (PromSituation.HasValidConditionsToThrow()) { IncStat("Created"); PromSituation.Create(); GetOption <DayOfLastOption>().SetValue(SimClock.ElapsedCalendarDays()); return(true); } else { IncStat("Not Satisfied"); return(false); } } else if (PromSituation.GetDayOfScheduledProm() == SimClock.CurrentDayOfWeek) { if (GetValue <DayOffOption, bool>()) { foreach (SimDescription sim in HouseholdsEx.All(Household.ActiveHousehold)) { Occupation career = sim.Occupation; if (career != null) { float endHour = career.FinishTime; if (endHour != -1) { if (endHour > PromSituation.kTimeOfEventStart) { career.TakePaidTimeOff(1); IncStat("Time Off"); } } } } } } return(true); }