public static AfterschoolActivityData GetActivity(AfterschoolActivityType activityType) { AfterschoolActivityData data; if (!Activities.TryGetValue(activityType, out data)) { return(null); } return(data); }
public override bool Run() { try { if ((SelectedObjects == null) || (SelectedObjects.Count <= 0x0)) { return(false); } AfterschoolActivityType chosenActivity = (InteractionDefinition as Definition).ChosenActivity; if (AfterschoolActivityEx.IsChildActivity(chosenActivity) && AfterschoolActivityEx.AlreadyHasChildActivity(Actor.SimDescription)) { return(false); } StandardEntry(); if (!Target.StartComputing(this, SurfaceHeight.Table, true)) { StandardExit(); return(false); } Target.StartVideo(Computer.VideoType.Browse); AnimateSim("GenericTyping"); bool flag = DoTimedLoop(kTimeToSpendSigningUp, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); if (flag) { foreach (object obj2 in SelectedObjects) { Sim actor = obj2 as Sim; if (!AfterschoolActivityEx.HasAfterschoolActivityOfType(actor.SimDescription, chosenActivity) && AfterschoolActivityEx.AddNewActivity(actor.SimDescription, chosenActivity)) { EventTracker.SendEvent(new AfterschoolActivityEvent(EventTypeId.kSignUpChildForAfterschoolActivity, Actor, actor, chosenActivity)); EventTracker.SendEvent(new AfterschoolActivityEvent(EventTypeId.kSignedUpForAfterschoolActivity, actor, Target, chosenActivity)); } } } Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false); StandardExit(); return(flag); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public override bool InRabbitHole() { try { bool succeeded = false; if ((SelectedObjects != null) && (SelectedObjects.Count > 0x0)) { AfterschoolActivityType chosenActivity = (InteractionDefinition as Definition).ChosenActivity; if (AfterschoolActivityEx.IsChildActivity(chosenActivity) && AfterschoolActivityEx.AlreadyHasChildActivity(Actor.SimDescription)) { return(false); } StartStages(); BeginCommodityUpdates(); succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); EndCommodityUpdates(succeeded); if (!succeeded) { return(succeeded); } foreach (object obj2 in SelectedObjects) { Sim actor = (Sim)obj2; if (!AfterschoolActivityEx.HasAfterschoolActivityOnDays(actor.SimDescription, AfterschoolActivityEx.GetDaysForActivityType(chosenActivity)) && AfterschoolActivityEx.AddNewActivity(actor.SimDescription, chosenActivity)) { EventTracker.SendEvent(new AfterschoolActivityEvent(EventTypeId.kSignUpChildForAfterschoolActivity, Actor, actor, chosenActivity)); EventTracker.SendEvent(new AfterschoolActivityEvent(EventTypeId.kSignedUpForAfterschoolActivity, actor, Target, chosenActivity)); } } } return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static bool HasAfterschoolActivityOfType(SimDescription actor, AfterschoolActivityType activity) { School school = actor.CareerManager.School; if (school != null) { List <AfterschoolActivity> afterschoolActivities = school.AfterschoolActivities; if (afterschoolActivities != null) { foreach (AfterschoolActivity activity2 in afterschoolActivities) { if (activity2.CurrentActivityType == activity) { return(true); } } } } return(false); }
public static bool DoesActivityConflictWithJob(SimDescription actor, AfterschoolActivityType activityToCheck) { School school = actor.CareerManager.School; if (school == null) { return(true); } Career occupationAsCareer = actor.CareerManager.Occupation as Career; if ((occupationAsCareer != null) && ((GetDaysForActivityType(activityToCheck) & occupationAsCareer.DaysOfWeekToWork) != DaysOfTheWeek.None)) { float num = (school.CurLevel.FinishTime() + AfterschoolActivity.kAfterschoolActivityLength) + AfterschoolActivity.kBufferTimeBetweenActivityAndJobStarting; if (num > occupationAsCareer.StartTime) { return(true); } } return(false); }
public static DaysOfTheWeek GetDaysForActivityType(AfterschoolActivityType activityType) { return(AfterschoolActivityBooter.GetActivity(activityType).mActivity.DaysForActivity); }
public static bool MeetsCommonAfterschoolActivityRequirements(SimDescription actor, AfterschoolActivityType activityToCheck, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool teen = actor.Teen; if (!actor.Child && !teen) { return(false); } School school = actor.CareerManager.School; if (school == null) { return(false); } else if (actor.IsEnrolledInBoardingSchool()) { return(false); } /* * else if (!AfterschoolActivity.WorldHasSchoolRabbitHole()) * { * return false; * } */ else if (HasAfterschoolActivityOfType(actor, activityToCheck)) { return(false); } else if (HasAfterschoolActivityOnDays(actor, GetDaysForActivityType(activityToCheck))) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(AfterschoolActivity.LocalizeString(actor.IsFemale, "DayConflict", new object[0x0])); return(false); } else if (DoesActivityConflictWithJob(actor, activityToCheck)) { return(false); } else if (teen && school.HasCompletedTeenAfterschoolActivityRecital) { return(false); } else if (HasCompletedRecitalForType(school, activityToCheck)) { return(false); } else if (IsChildActivity(activityToCheck) && AlreadyHasChildActivity(actor)) { return(false); } AgingManager singleton = AgingManager.Singleton; float num = singleton.AgingYearsToSimDays(singleton.GetCurrentAgingStageLength(actor)); float num2 = singleton.AgingYearsToSimDays(actor.AgingYearsSinceLastAgeTransition); float num3 = num - num2; if (num3 <= AfterschoolActivity.kDaysBeforeAgingTrigger) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(AfterschoolActivity.LocalizeString(actor.IsFemale, "AboutToAgeUp", new object[] { actor })); return(false); } return(true); }
public static bool HasCompletedRecitalForType(School school, AfterschoolActivityType activityType) { return(AfterschoolActivity.HasCompletedRecitalForType(school, activityType)); }
public static bool IsValidSimForSimPicker(SimDescription actor, AfterschoolActivityType activityToCheck) { return(AfterschoolActivityBooter.GetActivity(activityToCheck).IsValidFor(actor)); }
public static bool IsValidSimForSimPicker(SimDescription actor, AfterschoolActivityType activityToCheck) { return AfterschoolActivityBooter.GetActivity(activityToCheck).IsValidFor(actor); }
public WeightedChoice(AfterschoolActivityType type, float weight) { mType = type; mWeight = weight; }
public static DaysOfTheWeek GetDaysForActivityType(AfterschoolActivityType activityType) { return AfterschoolActivityBooter.GetActivity(activityType).mActivity.DaysForActivity; }
public static bool MeetsCommonAfterschoolActivityRequirements(SimDescription actor, AfterschoolActivityType activityToCheck, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool teen = actor.Teen; if (!actor.Child && !teen) { return false; } School school = actor.CareerManager.School; if (school == null) { return false; } else if (actor.IsEnrolledInBoardingSchool()) { return false; } /* else if (!AfterschoolActivity.WorldHasSchoolRabbitHole()) { return false; } */ else if (HasAfterschoolActivityOfType(actor, activityToCheck)) { return false; } else if (HasAfterschoolActivityOnDays(actor, GetDaysForActivityType(activityToCheck))) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(AfterschoolActivity.LocalizeString(actor.IsFemale, "DayConflict", new object[0x0])); return false; } else if (DoesActivityConflictWithJob(actor, activityToCheck)) { return false; } else if (teen && school.HasCompletedTeenAfterschoolActivityRecital) { return false; } else if (HasCompletedRecitalForType(school, activityToCheck)) { return false; } else if (IsChildActivity(activityToCheck) && AlreadyHasChildActivity(actor)) { return false; } AgingManager singleton = AgingManager.Singleton; float num = singleton.AgingYearsToSimDays(singleton.GetCurrentAgingStageLength(actor)); float num2 = singleton.AgingYearsToSimDays(actor.AgingYearsSinceLastAgeTransition); float num3 = num - num2; if (num3 <= AfterschoolActivity.kDaysBeforeAgingTrigger) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(AfterschoolActivity.LocalizeString(actor.IsFemale, "AboutToAgeUp", new object[] { actor })); return false; } return true; }
public static bool AddNewActivity(SimDescription actor, AfterschoolActivityType activityType) { School school = actor.CareerManager.School; if (school.AfterschoolActivities == null) { school.AfterschoolActivities = new List<AfterschoolActivity>(); } else if (AlreadyHasChildActivity(actor) || HasAfterschoolActivityOfType(actor, activityType)) { return false; } // Custom school.AfterschoolActivities.Add(AfterschoolActivityBooter.GetActivity(activityType).mActivity); string name = activityType.ToString(); if (actor.CreatedSim != null) { actor.CreatedSim.ShowTNSIfSelectable(TNSNames.SignUpForAfterschoolActivityTNS, actor, null, null, actor.IsFemale, actor.IsFemale, new object[] { actor, AfterschoolActivity.LocalizeString(actor.IsFemale, name, new object[0x0]), AfterschoolActivity.LocalizeString(actor.IsFemale, name + "Description", new object[0x0]) }); actor.CareerManager.UpdateCareerUI(); } return true; }
public static bool HasCompletedRecitalForType(School school, AfterschoolActivityType activityType) { return AfterschoolActivity.HasCompletedRecitalForType(school, activityType); }
public static bool HasAfterschoolActivityOfType(SimDescription actor, AfterschoolActivityType activity) { School school = actor.CareerManager.School; if (school != null) { List<AfterschoolActivity> afterschoolActivities = school.AfterschoolActivities; if (afterschoolActivities != null) { foreach (AfterschoolActivity activity2 in afterschoolActivities) { if (activity2.CurrentActivityType == activity) { return true; } } } } return false; }
public static AfterschoolActivityData GetActivity(AfterschoolActivityType activityType) { AfterschoolActivityData data; if (!Activities.TryGetValue(activityType, out data)) return null; return data; }
public Definition(AfterschoolActivityType type) : base(type) { }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { string guid = row.GetString("Guid"); if (string.IsNullOrEmpty(guid)) { BooterLogger.AddError(file + ": Guid empty"); return; } AfterschoolActivityType type = unchecked ((AfterschoolActivityType)ResourceUtils.HashString64(guid)); AfterschoolActivityData data = new AfterschoolActivityData(); data.mActivity = new AfterschoolActivity(type); List <string> skills = row.GetStringList("Skills", ','); if (skills != null) { foreach (string skillStr in skills) { SkillNames skill = SkillManager.sSkillEnumValues.ParseEnumValue(skillStr); if (skill == SkillNames.None) { BooterLogger.AddError(file + ": " + guid + " Unknown skill " + skillStr); return; } else { data.mActivity.ActivitySkillNameList.Add(skill); } } } if (data.mActivity.ActivitySkillNameList.Count == 0) { BooterLogger.AddError(file + ": " + guid + " Activity Must Have a Skill"); return; } DaysOfTheWeek days; if (!row.TryGetEnum <DaysOfTheWeek>("DaysOfTheWeek", out days, DaysOfTheWeek.All)) { BooterLogger.AddError(file + ": " + guid + " Unknown DaysOfTheWeek " + row.GetString("DaysOfTheWeek")); return; } data.mActivity.DaysForActivity = days; CASAgeGenderFlags genders; if (!row.TryGetEnum <CASAgeGenderFlags>("Genders", out genders, CASAgeGenderFlags.GenderMask)) { BooterLogger.AddError(file + ": " + guid + " Unknown Genders " + row.GetString("Genders")); return; } data.mGenders = genders; CASAgeGenderFlags ages; if (!row.TryGetEnum <CASAgeGenderFlags>("Ages", out ages, CASAgeGenderFlags.AgeMask)) { BooterLogger.AddError(file + ": " + guid + " Unknown Ages " + row.GetString("Ages")); return; } data.mAges = ages; if (row.Exists("PreLoop")) { data.mPreLoop = new Common.MethodStore(row.GetString("PreLoop"), new Type[] { typeof(GoToSchoolInRabbitHole), typeof(AfterschoolActivity) }).Method; if (data.mPreLoop == null) { BooterLogger.AddError(file + ": " + guid + " Missing PreLoop " + row.GetString("PreLoop")); return; } } if (row.Exists("Loop")) { data.mLoop = new Common.MethodStore(row.GetString("Loop"), new Type[] { typeof(GoToSchoolInRabbitHole), typeof(AfterschoolActivity) }).Method; if (data.mLoop == null) { BooterLogger.AddError(file + ": " + guid + " Missing Loop " + row.GetString("Loop")); return; } } if (row.Exists("PostLoop")) { data.mPostLoop = new Common.MethodStore(row.GetString("PostLoop"), new Type[] { typeof(GoToSchoolInRabbitHole), typeof(AfterschoolActivity) }).Method; if (data.mPostLoop == null) { BooterLogger.AddError(file + ": " + guid + " Missing PostLoop " + row.GetString("PostLoop")); return; } } Activities.Add(type, data); BooterLogger.AddTrace(file + ": " + guid + " Loaded"); }
public static bool DoesActivityConflictWithJob(SimDescription actor, AfterschoolActivityType activityToCheck) { School school = actor.CareerManager.School; if (school == null) { return true; } Career occupationAsCareer = actor.CareerManager.Occupation as Career; if ((occupationAsCareer != null) && ((GetDaysForActivityType(activityToCheck) & occupationAsCareer.DaysOfWeekToWork) != DaysOfTheWeek.None)) { float num = (school.CurLevel.FinishTime() + AfterschoolActivity.kAfterschoolActivityLength) + AfterschoolActivity.kBufferTimeBetweenActivityAndJobStarting; if (num > occupationAsCareer.StartTime) { return true; } } return false; }
public static bool IsChildActivity(AfterschoolActivityType type) { return AfterschoolActivityBooter.GetActivity(type).IsChild; }
public Definition(AfterschoolActivityType type) : base(type) { }
public static bool IsChildActivity(AfterschoolActivityType type) { return(AfterschoolActivityBooter.GetActivity(type).IsChild); }