protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <Item> allOptions = GetOptions(me); Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false); foreach (Item option in allOptions) { foreach (SimDescription sim in sims.Values) { if (option.Test(sim, false, me)) { option.IncCount(); } } } Item choice = new CommonSelection <Item>(Name, me.FullName, allOptions, Auxillary).SelectSingle(); if (choice == null) { return(false); } mChoice = choice; } mChoice.Perform(me, ApplyAll); return(true); }
public override bool Run() { try { List <Item> items = new List <Item>(); foreach (GameObject obj in Inventories.QuickFind <GameObject>(Actor.Household.SharedFamilyInventory.Inventory)) { items.Add(new Item(obj)); } CommonSelection <Item> .Results choices = new CommonSelection <Item>(GetInteractionName(), items).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) { return(false); } foreach (Item item in choices) { Inventory inventory = Inventories.ParentInventory(item.Value); if (!inventory.TryToRemove(item.Value)) { continue; } uint stackNumber = Actor.Inventory.FindValidStack(item.Value); Actor.Inventory.AddInternal(item.Value, stackNumber, false); } } catch (Exception exception) { Common.Exception(Actor, Target, exception); } return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { List <Item> choices = new List <Item>(); foreach (T value in Enum.GetValues(FieldType)) { choices.Add(new Item(value)); } CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, choices).SelectMultiple(); if (selection == null) { return(OptionResult.Failure); } List <T> results = new List <T>(); foreach (Item item in selection) { results.Add(item.Value); } PrivatePerform(results); return(OptionResult.SuccessRetain); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<PreferenceMusic.Item> allOptions = new List<PreferenceMusic.Item>(); foreach (FavoriteMusicType type in Enum.GetValues(typeof(FavoriteMusicType))) { if ((type == FavoriteMusicType.None) || (type == FavoriteMusicType.Count)) continue; allOptions.Add(new PreferenceMusic.Item(type, (me.FavoriteMusic == type) ? 1 : 0)); } PreferenceMusic.Item choice = new CommonSelection<PreferenceMusic.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; mFavoriteMusic = choice.Value; } me.mFavouriteMusicType = mFavoriteMusic; if (PlumbBob.SelectedActor == me.CreatedSim) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId); } return true; }
protected override OptionResult Run(GameHitParameters <Sim> parameters) { List <VectorBooter.Item> choices = VectorBooter.GetVectorItems(parameters.mTarget.SimDescription); CommonSelection <VectorBooter.Item> .Results items = new CommonSelection <VectorBooter.Item>(Name, choices).SelectMultiple(); if ((items == null) || (items.Count == 0)) { return(OptionResult.Failure); } string vectors = null; foreach (VectorBooter.Item item in items) { VectorControl.Inoculate(parameters.mTarget.SimDescription, item.Value, true, false); vectors += Common.NewLine + " " + item.Value.GetLocalizedName(parameters.mTarget.IsFemale); } if (!string.IsNullOrEmpty(vectors)) { Common.Notify(parameters.mTarget, Common.Localize("Inoculate:Success", parameters.mTarget.IsFemale, new object[] { parameters.mTarget }) + vectors); } return(OptionResult.SuccessClose); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { List <Item> choices = new List <Item>(); foreach (SettingsKey key in Retuner.Settings.Keys) { if (key.IsDefault) { continue; } choices.Add(new Item(key)); } CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, choices).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) { return(OptionResult.Failure); } foreach (Item item in selection) { Retuner.Settings.Remove(item.Value); } return(OptionResult.SuccessClose); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <PreferenceMusic.Item> allOptions = new List <PreferenceMusic.Item>(); foreach (FavoriteMusicType type in Enum.GetValues(typeof(FavoriteMusicType))) { if ((type == FavoriteMusicType.None) || (type == FavoriteMusicType.Count)) { continue; } allOptions.Add(new PreferenceMusic.Item(type, (me.FavoriteMusic == type) ? 1 : 0)); } PreferenceMusic.Item choice = new CommonSelection <PreferenceMusic.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } mFavoriteMusic = choice.Value; } me.mFavouriteMusicType = mFavoriteMusic; if (PlumbBob.SelectedActor == me.CreatedSim) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId); } return(true); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<PreferenceColor.Item> allOptions = new List<PreferenceColor.Item>(); foreach (CASCharacter.NameColorPair color in CASCharacter.kColors) { allOptions.Add(new PreferenceColor.Item(color.mColor, (me.FavoriteColor == color.mColor) ? 1 : 0)); } PreferenceColor.Item choice = new CommonSelection<PreferenceColor.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; mFavoriteColor = choice.Value; } me.FavoriteColor = mFavoriteColor; if (PlumbBob.SelectedActor == me.CreatedSim) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId); } return true; }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Dictionary <string, bool> lookup = new Dictionary <string, bool>(); List <Item> profiles = new List <Item>(); foreach (WeatherSettings settings in Tempest.Settings.Weather) { foreach (WeatherProfile profile in settings.Profiles) { string name = Common.LocalizeEAString("Ui/Caption/Options:" + settings.Season) + ": " + profile.Name; if (lookup.ContainsKey(name)) { continue; } lookup.Add(name, true); profiles.Add(new Item(name, profile)); } } Item choice = new CommonSelection <Item>(Name, profiles).SelectSingle(); if (choice == null) { return(OptionResult.Failure); } Tempest.Settings.GetWeather(mSeason).AddProfile(choice.Value); Tempest.ReapplySettings(); return(OptionResult.SuccessRetain); }
protected override bool Run(SimDescription me, bool singleSelection) { List <Opportunity> allOpportunities = OpportunityEx.GetAllOpportunities(me.CreatedSim, OpportunityCategory.None); if (allOpportunities.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize("Opportunity:None")); return(false); } List <Item> allOptions = new List <Item>(); foreach (Opportunity item in allOpportunities) { string name = item.Name; if (item.IsCareer) { name = Common.LocalizeEAString("Ui/Caption/HUD/CareerPanel:Career") + ": " + name; } allOptions.Add(new Item(item, me.CreatedSim, name, allOpportunities)); } Item selection = new CommonSelection <Item>(Name, allOptions, new CompletedColumn()).SelectSingle(); if (selection == null) { return(false); } return(OpportunityEx.Perform(me, selection.Value.Guid)); }
protected override bool Run(SimDescription me, bool singleSelection) { List<SimCareer.Item> allOptions = new List<SimCareer.Item>(); allOptions.Add(new SimCareer.Item(OccupationNames.Undefined, Common.LocalizeEAString("Ui/Caption/ObjectPicker:All"), 0)); foreach (Occupation career in me.CareerManager.QuitCareers.Values) { allOptions.Add(new SimCareer.Item(career.Guid, career.CareerName, 0)); } CommonSelection<SimCareer.Item>.Results choices = new CommonSelection<SimCareer.Item>(Name, me.FullName, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) return false; foreach (SimCareer.Item item in choices) { if (item.Value == OccupationNames.Undefined) { me.CareerManager.QuitCareers.Clear(); break; } else { me.CareerManager.QuitCareers.Remove(item.Value); } } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { List <SimCareer.Item> allOptions = new List <SimCareer.Item>(); allOptions.Add(new SimCareer.Item(OccupationNames.Undefined, Common.LocalizeEAString("Ui/Caption/ObjectPicker:All"), 0)); foreach (Occupation career in me.CareerManager.QuitCareers.Values) { allOptions.Add(new SimCareer.Item(career.Guid, career.CareerName, 0)); } CommonSelection <SimCareer.Item> .Results choices = new CommonSelection <SimCareer.Item>(Name, me.FullName, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) { return(false); } foreach (SimCareer.Item item in choices) { if (item.Value == OccupationNames.Undefined) { me.CareerManager.QuitCareers.Clear(); break; } else { me.CareerManager.QuitCareers.Remove(item.Value); } } return(true); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <ZodiacSign.Item> allOptions = new List <ZodiacSign.Item>(); foreach (Zodiac zodiac in Enum.GetValues(typeof(Zodiac))) { if (zodiac == Zodiac.Unset) { continue; } allOptions.Add(new ZodiacSign.Item(zodiac)); } ZodiacSign.Item choice = new CommonSelection <ZodiacSign.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } mZodiac = choice.Value; } me.mZodiacSign = mZodiac; return(true); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<OutfitCategories> categories = new List<OutfitCategories>(); foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories))) { if (category == OutfitCategories.Special) continue; categories.Add(category); } List<Item> allOptions = GetOptions(me, categories); CommonSelection<Item>.Results choices = new CommonSelection<Item>(Name, me.FullName, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) return false; mOutfits.Clear(); mOutfits.AddRange(choices); } CASParts.Key currentKey = new CASParts.Key(me.CreatedSim); // Remove them in reverse to ensure that removing earlier indices doesn't alter the index of later ones for(int i=mOutfits.Count-1; i>=0; i--) { Item item = mOutfits[i]; if (item.Value == currentKey) continue; me.RemoveOutfit(item.Category, item.Index, true); } return true; }
protected override OptionResult Run(GameHitParameters<GameObject> parameters) { List<Moodlet.Item> options = new List<Moodlet.Item>(); foreach (BuffInstance instance in BuffManager.BuffDictionary.Values) { BuffNames guid = (BuffNames)instance.mBuffGuid; int value = 0; if (MasterController.Settings.mCustomBuffs.Contains(guid.ToString())) { value = 1; } options.Add(new Moodlet.Item(instance, value)); } CommonSelection<Moodlet.Item>.Results choices = new CommonSelection<Moodlet.Item>(Name, options).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) return OptionResult.Failure; foreach (Moodlet.Item item in choices) { string buff = item.Value.ToString(); if (item.Count > 0) { MasterController.Settings.mCustomBuffs.Remove(buff); } else { MasterController.Settings.mCustomBuffs.Add(buff); } } return OptionResult.SuccessRetain; }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, this.GetCareerOptions()).SelectMultiple(); List <CareerLevelItem> mLevelOptions = new List <CareerLevelItem>(); foreach (Item item in selection) { mLevelOptions.AddRange(GetLevelOptions(item.Value)); } CommonSelection <CareerLevelItem> .Results levelSelection = new CommonSelection <CareerLevelItem>(Name, mLevelOptions).SelectMultiple(); foreach (CareerLevelItem item in levelSelection) { mPicks.Add(item.Value); } if (mPicks.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize("Selection:Error")); return(OptionResult.Failure); } return(OptionResult.SuccessRetain); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <PreferenceColor.Item> allOptions = new List <PreferenceColor.Item>(); foreach (CASCharacter.NameColorPair color in CASCharacter.kColors) { allOptions.Add(new PreferenceColor.Item(color.mColor, (me.FavoriteColor == color.mColor) ? 1 : 0)); } PreferenceColor.Item choice = new CommonSelection <PreferenceColor.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } mFavoriteColor = choice.Value; } me.FavoriteColor = mFavoriteColor; if (PlumbBob.SelectedActor == me.CreatedSim) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId); } return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { try { List <Item> choices = new List <Item>(); foreach (object value in Enum.GetValues(FieldType)) { choices.Add(new Item(value)); } Item selection = new CommonSelection <Item>(Name, choices).SelectSingle(); if (selection == null) { return(OptionResult.Failure); } Value = selection.Value; return(OptionResult.SuccessRetain); } catch (Exception e) { Common.Exception(FieldType.ToString(), e); return(OptionResult.Failure); } }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { if (MasterController.Settings.SkillStamps.Count == 1) { if (!AcceptCancelDialog.Show(Common.Localize("SkillStamp:Prompt", me.IsFemale, new object[] { me }))) { return(false); } mChoice = MasterController.Settings.SkillStamps[0]; } else { List <Item> allOptions = new List <Item>(); foreach (SkillStamp stamp in MasterController.Settings.SkillStamps) { allOptions.Add(new ApplySkillStamp.Item(stamp)); } Item choice = new CommonSelection <ApplySkillStamp.Item>(Name, allOptions).SelectSingle(); if (choice == null) { return(false); } mChoice = choice.mStamp; } } foreach (KeyValuePair <SkillNames, int> skill in mChoice.Skills) { if (me.SkillManager.GetSkillLevel(skill.Key) > skill.Value) { continue; } Skill mySkill = me.SkillManager.GetElement(skill.Key); if ((mySkill == null) && (skill.Value >= 0)) { mySkill = me.SkillManager.AddElement(skill.Key); } if (mySkill != null) { try { mySkill.ForceSkillLevelUp(skill.Value); } catch (Exception e) { Common.Exception(me, null, "Skill: " + skill.Key, e); } } } return(true); }
public static bool Perform(SimDescription sim, bool promptStrength, bool random) { List <VectorBooter.Item> choices = VectorBooter.GetVectorItems(sim); int maxSelection = 0; if (!promptStrength) { maxSelection = 1; } List <VectorBooter.Item> selection = new List <VectorBooter.Item>(); if (random) { if (choices.Count == 0) { return(false); } selection.Add(RandomUtil.GetRandomObjectFromList(choices)); } else { CommonSelection <VectorBooter.Item> .Results items = new CommonSelection <VectorBooter.Item>(Common.Localize("Infect:MenuName"), choices).SelectMultiple(maxSelection); if ((items == null) || (items.Count == 0)) { return(false); } selection.AddRange(items); } foreach (VectorBooter.Item item in selection) { DiseaseVector.Variant strain = Vector.Settings.GetCurrentStrain(item.Value); int strength = strain.Strength; if (promptStrength) { string text = StringInputDialog.Show(Common.Localize("Infect:MenuName"), Common.Localize("Infect:Prompt", false, new object[] { item.Value.GetLocalizedName(false) }), strain.Strength.ToString()); if (!int.TryParse(text, out strength)) { Common.Notify(Common.Localize("Numeric:Error")); } } strain.Strength = strength; DiseaseVector disease = new DiseaseVector(item.Value, strain); disease.Infect(sim, true); } return(true); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List <SimTrait.Item> allOptions = new List <SimTrait.Item>(); foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits) { if (!me.TraitManager.HasElement(trait.Guid)) { continue; } if (!trait.IsReward) { continue; } allOptions.Add(new SimTrait.Item(trait.Guid, 1)); } mSelection = new CommonSelection <SimTrait.Item>(Name, me.FullName, allOptions).SelectMultiple(); if ((mSelection == null) || (mSelection.Count == 0)) { return(false); } } foreach (SimTrait.Item item in mSelection) { if (item == null) { continue; } TraitNames traitName = item.Value; if (!me.TraitManager.HasElement(traitName)) { continue; } Sims3.Gameplay.ActorSystems.Trait trait = TraitManager.GetTraitFromDictionary(traitName); if (trait != null) { me.RemoveTrait(trait); me.mSpendableHappiness += trait.Score; } } if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null)) { me.CreatedSim.SocialComponent.UpdateTraits(); } return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Dictionary <SkillNames, bool> lookup = new Dictionary <SkillNames, bool>(); List <SkillLevel.Item> allOptions = new List <SkillLevel.Item>(); foreach (Skill skill in SkillManager.SkillDictionary) { if (lookup.ContainsKey(skill.Guid)) { continue; } lookup.Add(skill.Guid, true); int count; if (!mStamp.Skills.TryGetValue(skill.Guid, out count)) { count = -1; } allOptions.Add(new SkillLevel.Item(skill, count)); } CommonSelection <SkillLevel.Item> .Results selection = new CommonSelection <SkillLevel.Item>(Name, allOptions, new SkillLevel.AuxillaryColumn()).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) { return(OptionResult.Failure); } foreach (SkillLevel.Item item in selection) { int level; if (!mStamp.Skills.TryGetValue(item.Skill, out level)) { level = -1; } string text = StringInputDialog.Show(Name, Common.Localize("SkillLevel:Prompt", false, new object[] { item.Name, item.MaximumLevel }), level.ToString(), 256, StringInputDialog.Validation.None); if (string.IsNullOrEmpty(text)) { return(OptionResult.Failure); } if (!int.TryParse(text, out level)) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error")); return(OptionResult.Failure); } mStamp.Skills.Remove(item.Skill); mStamp.Skills.Add(item.Skill, level); } MasterController.Settings.UpdateStamp(); return(OptionResult.SuccessRetain); }
public override bool Run() { try { List <InteractionObjectPair> allInteractions = Actor.GetAllInteractionsForActor(Actor); if (allInteractions == null) { return(false); } List <Item> items = new List <Item>(); foreach (InteractionObjectPair pair in allInteractions) { if (pair.InteractionDefinition is ISoloInteractionDefinition) { try { InteractionInstanceParameters p = new InteractionInstanceParameters(pair, Actor, new InteractionPriority(InteractionPriorityLevel.UserDirected), Autonomous, CancellableByPlayer); GreyedOutTooltipCallback callBack = null; if (!IUtil.IsPass(pair.InteractionDefinition.Test(ref p, ref callBack))) { continue; } items.Add(new Item(pair.InteractionDefinition.GetInteractionName(ref p), pair)); } catch (Exception e) { Common.Exception(Actor, null, pair.InteractionDefinition.GetType().ToString(), e); } } } Item choice = new CommonSelection <Item>(GetInteractionName(), items).SelectSingle(); if (choice == null) { return(false); } InteractionInstance instance = choice.Value.InteractionDefinition.CreateInstance(Actor, Actor, GetPriority(), Autonomous, CancellableByPlayer); Actor.InteractionQueue.Add(instance); return(base.Run()); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { if (MasterController.Settings.SkillStamps.Count == 1) { if (!AcceptCancelDialog.Show(Common.Localize("SkillStamp:Prompt", me.IsFemale, new object[] { me }))) { return false; } mChoice = MasterController.Settings.SkillStamps[0]; } else { List<Item> allOptions = new List<Item>(); foreach (SkillStamp stamp in MasterController.Settings.SkillStamps) { allOptions.Add(new ApplySkillStamp.Item(stamp)); } Item choice = new CommonSelection<ApplySkillStamp.Item>(Name, allOptions).SelectSingle(); if (choice == null) return false; mChoice = choice.mStamp; } } foreach (KeyValuePair<SkillNames, int> skill in mChoice.Skills) { if (me.SkillManager.GetSkillLevel(skill.Key) > skill.Value) { continue; } Skill mySkill = me.SkillManager.GetElement(skill.Key); if ((mySkill == null) && (skill.Value >= 0)) { mySkill = me.SkillManager.AddElement(skill.Key); } if (mySkill != null) { try { mySkill.ForceSkillLevelUp(skill.Value); } catch (Exception e) { Common.Exception(me, null, "Skill: " + skill.Key, e); } } } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { List <SimTrait.Item> allOptions = new List <SimTrait.Item>(); foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits) { if (trait.IsReward) { continue; } if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags())) { continue; } int count = 0; if (me.TraitManager.mSocialGroupTraitGuid == trait.Guid) { count = 1; } else if (me.HasTrait(trait.Guid)) { continue; } allOptions.Add(new SimTrait.Item(trait.Guid, count)); } SimTrait.Item selection = new CommonSelection <SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectSingle(); if (selection == null) { return(false); } TraitNames traitName = selection.Value; me.RemoveSocialGroupTrait(); if (traitName != me.TraitManager.mSocialGroupTraitGuid) { Sims3.Gameplay.ActorSystems.Trait selTrait = TraitManager.GetTraitFromDictionary(traitName); if (selTrait != null) { me.TraitManager.mSocialGroupTraitEnabled = true; me.AddSocialGroupTrait(selTrait); } } if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null)) { me.CreatedSim.SocialComponent.UpdateTraits(); } return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { OptionResult result = base.Run(parameters); if (result != OptionResult.Failure) { Item selection = new CommonSelection <Item>(Name, this.GetCarOptions()).SelectSingle(); if (selection == null) { return(OptionResult.Failure); } foreach (CareerLevelSettingOption.LevelData level in base.mPicks) { if (level.mLevel == -1) { foreach (Career career in CareerManager.CareerList) { foreach (string branch in career.CareerLevels.Keys) { foreach (KeyValuePair <int, Sims3.Gameplay.Careers.CareerLevel> levelData in career.CareerLevels[branch]) { PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(level.mCareer, true); PersistedSettings.CareerLevelSettings levelSettings = settings.GetSettingsForLevel(level.mBranchName, level.mLevel, true); levelSettings.mCarpoolType = selection.Value; levelData.Value.CarpoolType = selection.Value; } } } } else { PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(level.mCareer, true); PersistedSettings.CareerLevelSettings levelSettings = settings.GetSettingsForLevel(level.mBranchName, level.mLevel, true); levelSettings.mCarpoolType = selection.Value; NRaas.Careers.Settings.SetCareerData(settings); } } foreach (Sim sim in LotManager.Actors) { if (sim.Occupation != null) { sim.Occupation.RescheduleCarpool(); } } Common.Notify(Common.Localize("Generic:Success")); return(OptionResult.SuccessLevelDown); } return(result); }
public override bool Run() { try { Sim sim = Target as Sim; if (sim != null) { List <Item> allChoices = new List <Item>(); foreach (Skill skill in sim.SkillManager.List) { if (skill.IsHiddenSkill()) { continue; } if (!skill.ReachedMaxLevel()) { continue; } allChoices.Add(new Item(skill)); } if (allChoices.Count == 0) { return(false); } CommonSelection <Item> .Results results = new CommonSelection <Item>(Common.Localize("GenerateSkillCertificate:MenuName"), allChoices).SelectMultiple(); if ((results == null) || (results.Count == 0)) { return(false); } foreach (Item item in results) { Certificate certificate = GlobalFunctions.CreateObjectOutOfWorld("CertificateReward") as Certificate; certificate.OwnerSimDescription = sim.SimDescription; certificate.SkillName = item.Value.Guid; if (!Inventories.TryToMove(certificate, sim)) { certificate.Destroy(); } } } } catch (Exception exception) { Common.Exception(Actor, Target, exception); } return(true); }
public static IEnumerable <Item> GetChoices(string name) { List <Item> allOptions = new List <Item>(); allOptions.Add(null); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { if (!assembly.GetName().Name.StartsWith("NRaas")) { continue; } Type common = assembly.GetType("NRaas.CommonSpace.Helpers.Persistence"); if (common == null) { continue; } MethodInfo importer = common.GetMethod("ImportSettings", BindingFlags.Public | BindingFlags.Static); if (importer == null) { continue; } MethodInfo exporter = common.GetMethod("CreateExportString", BindingFlags.Public | BindingFlags.Static); if (exporter == null) { continue; } allOptions.Add(new Item(Common.AssemblyCheck.GetNamespace(assembly), importer, exporter)); } catch (Exception e) { Common.Exception(assembly.GetName().Name, e); } } CommonSelection <Item> selector = new CommonSelection <Item>(name, allOptions); selector.AllOnNull = true; CommonSelection <Item> .Results results = selector.SelectMultiple(); if ((results == null) || (results.Count == 0)) { return(null); } return(results); }
public override bool Run() { try { List <Item> choices = new List <Item>(); foreach (Quality quality in Enum.GetValues(typeof(Quality))) { if (quality == Quality.Any) { continue; } choices.Add(new Item(quality)); } Item choice = new CommonSelection <Item>(Common.Localize("SetQuality:MenuName"), choices).SelectSingle(); if (choice == null) { return(true); } int intQuality = (int)choice.Value; intQuality--; Ingredient ingredient = Target as Ingredient; if (ingredient != null) { if (ingredient.Plantable != null) { ingredient.Plantable.QualityLevel = Plant.kQualityLevels[intQuality]; } else { ingredient.SetQuality(choice.Value); } } else { Plant plant = Target as Plant; if (plant != null) { plant.mQualityLevel = Plant.kQualityLevels[intQuality]; } } } catch (Exception e) { Common.Exception(Actor, Target, e); } return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { List <InteractionObjectPair> interactions = DebugMenu.GetInteractions(parameters.mActor, parameters.mTarget, parameters.mHit); if (interactions == null) { return(OptionResult.Failure); } List <Item> allChoices = new List <Item>(); foreach (InteractionObjectPair pair in interactions) { string name = null; string[] path = pair.InteractionDefinition.GetPath(parameters.mActor.IsFemale); if (path != null) { foreach (string entry in path) { name += entry + " \\ "; } } name += pair.InteractionDefinition.GetInteractionName(parameters.mActor, parameters.mTarget, pair); allChoices.Add(new Item(pair.InteractionDefinition, name)); } CommonSelection <Item> .Results choices = new CommonSelection <Item>(Common.Localize("HotKeyMenu:MenuName"), allChoices).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) { return(OptionResult.Failure); } foreach (Item choice in choices) { if (DebugEnabler.Settings.mInteractions.ContainsKey(choice.Value.GetType())) { DebugEnabler.Settings.mInteractions.Remove(choice.Value.GetType()); } else { DebugEnabler.Settings.mInteractions.Add(choice.Value.GetType(), true); } } return(OptionResult.SuccessClose); }
public override bool Run() { try { List <Item> choices = new List <Item>(); foreach (RabbitHole hole in Sims3.Gameplay.Queries.GetObjects <RabbitHole>()) { choices.Add(new Item(hole)); } Item choice = new CommonSelection <Item>(Common.Localize("GoToRabbithole:MenuName", Target.IsFemale), choices).SelectSingle(); if (choice == null) { return(false); } List <InteractionObjectPair> interactions = choice.Value.GetAllInteractionsForActor(Target); if (interactions == null) { return(false); } for (int i = interactions.Count - 1; i >= 0; i--) { if (interactions[i].InteractionDefinition is IImmediateInteractionDefinition) { interactions.RemoveAt(i); } } if (InteractionDefinitionOptionList.Perform(Target, GameObjectHit.NoHit, interactions) == OptionResult.Failure) { InteractionInstance interaction = VisitCommunityLotEx.Singleton.CreateInstance(choice.Value.LotCurrent, Target, GetPriority(), Autonomous, CancellableByPlayer); Target.InteractionQueue.Add(interaction); } return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
protected override OptionResult Run(GameHitParameters <TTarget> parameters) { EnumOption selection = new CommonSelection <EnumOption>(Name, GetOptions()).SelectSingle(); if (selection == null) { return(OptionResult.Failure); } Value = selection.Value; Common.Notify(ToString()); return(OptionResult.SuccessRetain); }
protected override bool Run(SimDescription me, bool singleSelection) { School school = me.CareerManager.School; if (school == null) { return(false); } if (!ApplyAll) { List <AfterSchoolActivityCriteria.Item> choices = new List <AfterSchoolActivityCriteria.Item>(); foreach (AfterschoolActivity activity in school.AfterschoolActivities) { choices.Add(new AfterSchoolActivityCriteria.Item(activity.CurrentActivityType, 1)); } CommonSelection <AfterSchoolActivityCriteria.Item> .Results selection = new CommonSelection <AfterSchoolActivityCriteria.Item>(Name, choices).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) { return(false); } mSelection = selection; } bool changed = false; foreach (AfterSchoolActivityCriteria.Item item in mSelection) { for (int i = school.AfterschoolActivities.Count - 1; i >= 0; i--) { if (school.AfterschoolActivities[i].CurrentActivityType == item.Value) { school.AfterschoolActivities.RemoveAt(i); changed = true; break; } } } if (changed) { me.CareerManager.UpdateCareerUI(); } return(true); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { RabbitHole hole = parameters.mTarget as RabbitHole; List <Item> allOptions = new List <Item>(); foreach (Household house in Household.sHouseholdList) { if (house.RealEstateManager == null) { continue; } PropertyData data = house.RealEstateManager.FindProperty(hole); if (data == null) { continue; } RealEstate.OwnerType type = RealEstate.OwnerType.Partial; if (data.IsFullOwner) { type = RealEstate.OwnerType.Full; } allOptions.Add(new Item(house, hole, type)); } if (allOptions.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Failure")); return(OptionResult.Failure); } CommonSelection <Item> .Results choices = new CommonSelection <Item>(Name, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) { return(OptionResult.Failure); } foreach (Item item in choices) { item.Perform(); } return(OptionResult.SuccessClose); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { Dictionary <BookData, bool> lookup = new Dictionary <BookData, bool>(); foreach (ReadBookData data in me.ReadBookDataList.Values) { BookData bookData = BookData.GetBookData(BookData.BookType.General, data.BookID); if (bookData == null) { bookData = BookData.GetBookData(BookData.BookType.Toddler, data.BookID); if (bookData == null) { BookWrittenData writtenData; if (BookData.BookWrittenDataList.TryGetValue(data.BookID, out writtenData)) { bookData = writtenData; } if (bookData == null) { continue; } } } lookup.Add(bookData, true); } CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, GetOptions(me, lookup)).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) { return(false); } CommonSelection <Item> .HandleAllOrNothing(selection); mChoices = selection; } foreach (Item choice in mChoices) { Perform(me, choice.mBook, !choice.IsSet); } return(true); }
public static List <T> ListOptions <T>(List <T> allOptions, string name, int maxSelection, out bool okayed) where T : class, ICommonOptionItem { if ((allOptions == null) || (allOptions.Count == 0)) { okayed = false; return(new List <T>()); } CommonSelection <T> .Results results = new CommonSelection <T>(name, allOptions).SelectMultiple(maxSelection); okayed = results.mOkayed; return(new List <T>(results)); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { Item choice = new CommonSelection<Item>(Name, me.FullName, Common.DerivativeSearch.Find<Item>()).SelectSingle(); if (choice == null) return false; if (!AcceptCancelDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { choice.Name }))) { return false; } mItem = choice; } return mItem.Perform(me.LifeEventManager); }
protected override bool Run(SimDescription me, bool singleSelection) { List<SimTrait.Item> allOptions = new List<SimTrait.Item>(); foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits) { if (trait.IsReward) continue; if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags())) continue; int count = 0; if (me.TraitManager.mUniversityGraduateTraitGuid == trait.Guid) { count = 1; } else if (me.HasTrait(trait.Guid)) { continue; } allOptions.Add(new SimTrait.Item (trait.Guid, count)); } SimTrait.Item selection = new CommonSelection<SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectSingle(); if (selection == null) return false; TraitNames traitName = selection.Value; me.RemoveUniversityGraduateTrait(); if (traitName != me.TraitManager.mUniversityGraduateTraitGuid) { Sims3.Gameplay.ActorSystems.Trait selTrait = TraitManager.GetTraitFromDictionary(traitName); if (selTrait != null) { me.TraitManager.mUniversityGraduateTraitEnabled = true; me.AddUniversityGraduateTrait(selTrait); } } if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null)) { me.CreatedSim.SocialComponent.UpdateTraits(); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { if (!AcceptCancelDialog.Show(Common.Localize("ForceKill:Prompt", me.IsFemale, new object[] { me }))) { return false; } Occult.Item choice = new CommonSelection<Occult.Item>(Name, me.FullName, Occult.GetDeathOptions()).SelectSingle(); if (choice == null) return false; mDeathType = choice.Value.mDeathType; } return Perform(me, mDeathType); }
protected override bool Run(SimDescription me, bool singleSelection) { School school = me.CareerManager.School; if (school == null) return false; if (!ApplyAll) { List<AfterSchoolActivityCriteria.Item> choices = new List<AfterSchoolActivityCriteria.Item>(); foreach (AfterschoolActivity activity in school.AfterschoolActivities) { choices.Add(new AfterSchoolActivityCriteria.Item(activity.CurrentActivityType, 1)); } CommonSelection<AfterSchoolActivityCriteria.Item>.Results selection = new CommonSelection<AfterSchoolActivityCriteria.Item>(Name, choices).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) return false; mSelection = selection; } bool changed = false; foreach (AfterSchoolActivityCriteria.Item item in mSelection) { for(int i=school.AfterschoolActivities.Count-1; i>=0; i--) { if (school.AfterschoolActivities[i].CurrentActivityType == item.Value) { school.AfterschoolActivities.RemoveAt (i); changed = true; break; } } } if (changed) { me.CareerManager.UpdateCareerUI(); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<SimTrait.Item> allOptions = new List<SimTrait.Item>(); foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits) { if (!me.TraitManager.HasElement(trait.Guid)) continue; if (!trait.IsReward) continue; allOptions.Add(new SimTrait.Item(trait.Guid, 1)); } mSelection = new CommonSelection<SimTrait.Item>(Name, me.FullName, allOptions).SelectMultiple(); if ((mSelection == null) || (mSelection.Count == 0)) return false; } foreach (SimTrait.Item item in mSelection) { if (item == null) continue; TraitNames traitName = item.Value; if (!me.TraitManager.HasElement(traitName)) continue; Sims3.Gameplay.ActorSystems.Trait trait = TraitManager.GetTraitFromDictionary(traitName); if (trait != null) { me.RemoveTrait(trait); me.mSpendableHappiness += trait.Score; } } if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null)) { me.CreatedSim.SocialComponent.UpdateTraits(); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { Dictionary<BookData,bool> lookup = new Dictionary<BookData,bool>(); foreach(ReadBookData data in me.ReadBookDataList.Values) { BookData bookData = BookData.GetBookData(BookData.BookType.General, data.BookID); if (bookData == null) { bookData = BookData.GetBookData(BookData.BookType.Toddler, data.BookID); if (bookData == null) { BookWrittenData writtenData; if (BookData.BookWrittenDataList.TryGetValue(data.BookID, out writtenData)) { bookData = writtenData; } if (bookData == null) continue; } } lookup.Add(bookData, true); } CommonSelection<Item>.Results selection = new CommonSelection<Item>(Name, GetOptions(me, lookup)).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) return false; CommonSelection<Item>.HandleAllOrNothing(selection); mChoices = selection; } foreach (Item choice in mChoices) { Perform(me, choice.mBook, !choice.IsSet); } return true; }
protected override OptionResult Run(GameHitParameters<GameObject> parameters) { List<ApplySkillStamp.Item> allOptions = new List<ApplySkillStamp.Item>(); foreach(SkillStamp stamp in MasterController.Settings.SkillStamps) { allOptions.Add(new ApplySkillStamp.Item(stamp)); } CommonSelection<ApplySkillStamp.Item>.Results choices = new CommonSelection<ApplySkillStamp.Item>(Name, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) return OptionResult.Failure; foreach (ApplySkillStamp.Item choice in choices) { MasterController.Settings.SkillStamps.Remove(choice.mStamp); } MasterController.Settings.UpdateStamp(); return OptionResult.SuccessRetain; }
protected override OptionResult Run(GameHitParameters<GameObject> parameters) { List<BooksRead.Item> items = new List<BooksRead.Item>(); foreach (KeyValuePair<string, BookWrittenData> pair in BookData.BookWrittenDataList) { items.Add(new BooksRead.Item(pair.Value, pair.Key, false)); } CommonSelection<BooksRead.Item>.Results selection = new CommonSelection<BooksRead.Item>(Name, items).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) return OptionResult.Failure; CommonSelection<BooksRead.Item>.HandleAllOrNothing(selection); foreach (BooksRead.Item item in selection) { BookData.BookWrittenDataList.Remove(item.mKey); } return OptionResult.SuccessClose; }
protected override OptionResult Run(GameHitParameters<GameObject> parameters) { RabbitHole hole = parameters.mTarget as RabbitHole; List<Item> allOptions = new List<Item>(); foreach (Household house in Household.sHouseholdList) { if (house.RealEstateManager == null) continue; PropertyData data = house.RealEstateManager.FindProperty(hole); if (data == null) continue; RealEstate.OwnerType type = RealEstate.OwnerType.Partial; if (data.IsFullOwner) { type = RealEstate.OwnerType.Full; } allOptions.Add(new Item(house, hole, type)); } if (allOptions.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Failure")); return OptionResult.Failure; } CommonSelection<Item>.Results choices = new CommonSelection<Item>(Name, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) return OptionResult.Failure; foreach (Item item in choices) { item.Perform(); } return OptionResult.SuccessClose; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<ZodiacSign.Item> allOptions = new List<ZodiacSign.Item>(); foreach (Zodiac zodiac in Enum.GetValues(typeof(Zodiac))) { if (zodiac == Zodiac.Unset) continue; allOptions.Add(new ZodiacSign.Item(zodiac)); } ZodiacSign.Item choice = new CommonSelection<ZodiacSign.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; mZodiac = choice.Value; } me.mZodiacSign = mZodiac; return true; }
public static IEnumerable<Item> GetChoices(string name) { List<Item> allOptions = new List<Item>(); allOptions.Add(null); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { if (!assembly.GetName().Name.StartsWith("NRaas")) continue; Type common = assembly.GetType("NRaas.CommonSpace.Helpers.Persistence"); if (common == null) continue; MethodInfo importer = common.GetMethod("ImportSettings", BindingFlags.Public | BindingFlags.Static); if (importer == null) continue; MethodInfo exporter = common.GetMethod("CreateExportString", BindingFlags.Public | BindingFlags.Static); if (exporter == null) continue; allOptions.Add(new Item(Common.AssemblyCheck.GetNamespace(assembly), importer, exporter)); } catch (Exception e) { Common.Exception(assembly.GetName().Name, e); } } CommonSelection<Item> selector = new CommonSelection<Item>(name, allOptions); selector.AllOnNull = true; CommonSelection<Item>.Results results = selector.SelectMultiple(); if ((results == null) || (results.Count == 0)) return null; return results; }
public static bool Perform(string title, bool female, Inventory source, Inventory destination) { Dictionary<string, SellItem.Item> stack = new Dictionary<string, SellItem.Item>(); foreach (GameObject obj in Inventories.QuickFind<GameObject>(source)) { if ((obj is INotTransferableOnDeath) || (obj is IHiddenInInventory)) continue; if (!(destination.Owner is SharedFamilyInventory)) { if (!destination.CanAdd(obj)) continue; } SellItem.Item list; if (!stack.TryGetValue(obj.CatalogName, out list)) { list = new SellItem.Item(obj.CatalogName, obj.GetThumbnailKey()); stack.Add(obj.CatalogName, list); } list.Add(obj); } CommonSelection<SellItem.Item>.Results selection = new CommonSelection<SellItem.Item>(title, stack.Values).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) return false; foreach (SellItem.Item item in selection) { int count = 1; if (item.Count > 1) { string text = StringInputDialog.Show(title, Common.Localize("TransferItem:Prompt", female, new object[] { item.Name }), item.Count.ToString()); if (string.IsNullOrEmpty(text)) return false; if (!int.TryParse(text, out count)) { SimpleMessageDialog.Show(title, Common.Localize("Numeric:Error")); return false; } } if (count > item.Count) { count = item.Count; } for (int i = 0; i < count; i++) { Inventories.TryToMove(item.Value[i], destination); } } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { try { List<Item> allOptions = new List<Item>(); Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { foreach (Sims3.Gameplay.Careers.Career.EventDaily item in career.CareerEventManager.Events) { if (item is Sims3.Gameplay.Careers.Career.EventOpportunity) continue; if (!item.IsAvailable(career)) continue; allOptions.Add(new Item(item, career, item.EventType.ToString())); } } if (me.CareerManager.School != null) { foreach (Sims3.Gameplay.Careers.Career.EventDaily item in me.CareerManager.School.CareerEventManager.Events) { if (item is Sims3.Gameplay.Careers.Career.EventOpportunity) continue; if (!item.IsAvailable(me.CareerManager.School)) continue; allOptions.Add(new Item(item, me.CareerManager.School, item.EventType.ToString())); } } if (allOptions.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize("CareerEvent:None")); return false; } Item selection = new CommonSelection<Item>(Name, me.FullName, allOptions).SelectSingle(); if (selection == null) return false; selection.mEvent.RunEvent(selection.mCareer); } catch (Exception e) { Common.Exception(me, e); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<IApplyOptionItem> services = new List<IApplyOptionItem>(); foreach (ServiceType type in Enum.GetValues(typeof(ServiceType))) { int count = 0; bool found = false; foreach (Service service in Services.AllServices) { if (service.ServiceType == type) { count = service.mPool.Count; found = true; break; } } if (!found) continue; services.Add(new StatusServiceType.Item(type, count)); } foreach(PetPoolType type in Enum.GetValues(typeof(PetPoolType))) { if (PetPoolManager.IsPoolFull(type)) continue; int count = PetPoolManager.GetPoolSize(type); services.Add(new StatusPetPool.Item(type, count)); } if (GameUtils.IsInstalled(ProductVersion.EP10)) { services.Add(new MermaidServiceItem(CommonSpace.Helpers.Households.NumSims(Household.MermaidHousehold))); } IApplyOptionItem selection = new CommonSelection<IApplyOptionItem>(Name, me.FullName, services).SelectSingle(); if (selection == null) return false; mPool = selection; } List<IMiniSimDescription> list = new List<IMiniSimDescription>(); list.Add(me); if (!AddSim.TestForRemainingActive(list)) { Common.Notify(Common.Localize("AddSim:ActiveFail")); return false; } mPool.Apply(me); return true; }
protected override void OnPerform() { List<OutfitBase.Item> allOptions = new List<OutfitBase.Item>(); ICASModel casModel = Responder.Instance.CASModel; ArrayList outfits = casModel.GetOutfits(casModel.OutfitCategory); for (int i = 0; i < outfits.Count; i++) { allOptions.Add(new OutfitBase.Item(new CASParts.Key(casModel.OutfitCategory, i), casModel.CurrentSimDescription as SimDescription)); } OutfitBase.Item choice = new CommonSelection<OutfitBase.Item>(Common.Localize("ChangeOutfit:MenuName"), allOptions).SelectSingle(); if (choice == null) return; casModel.OutfitIndex = choice.Index; }
protected override OptionResult Run(Lot lot, Household me) { if (me != null) { List<ItemBase> allOptions = new List<ItemBase>(); foreach (RabbitHole hole in Sims3.Gameplay.Queries.GetObjects<RabbitHole>()) { if (!hole.RabbitHoleTuning.kCanInvestHere) continue; if (IsAlreadyOwned(hole, me)) continue; OwnerType type = OwnerType.NotOwned; PropertyData data = me.RealEstateManager.FindProperty(hole); if (data != null) { if (data.IsFullOwner) { type = OwnerType.Full; } else { type = OwnerType.Partial; } } allOptions.Add(new RabbitHoleItem(hole, type)); } foreach (Lot venue in LotManager.AllLots) { if (IsAlreadyOwned(venue, me)) continue; OwnerType type = OwnerType.NotOwned; int totalValue = 0; PropertyData data = me.RealEstateManager.FindProperty(venue); if (data != null) { type = OwnerType.Full; totalValue = data.TotalValue; } else { if (!venue.IsPurchaseableVenue) continue; } allOptions.Add(new VenueItem(venue, type, totalValue)); } CommonSelection<ItemBase>.Results choices = new CommonSelection<ItemBase>(Name, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) return OptionResult.Failure; List<ItemBase> purchase = new List<ItemBase>(); foreach (ItemBase item in choices) { if (item.mType != OwnerType.Full) { purchase.Add(item); } else { item.Perform(me); } } foreach (ItemBase item in purchase) { if (!item.Perform(me)) { SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Failure", false, new object[] { me.Name })); return OptionResult.Failure; } } } return OptionResult.SuccessClose; }
public static XmlElement ExtractFromFile() { BinModel.Singleton.PopulateExportBin(); List<SaveSetting> settings = new List<SaveSetting>(); foreach (ExportBinContents contents in BinModel.Singleton.ExportBinContents) { if (contents.HouseholdName == null) continue; if (!contents.HouseholdName.Contains("NRaas.Settings.")) continue; settings.Add(new SaveSetting(contents.HouseholdName, contents.HouseholdBio)); } if (settings.Count == 0) { SimpleMessageDialog.Show(Common.Localize("ImportSettings:MenuName"), Common.Localize("ImportSettings:Error")); return null; } SaveSetting selection = new CommonSelection<SaveSetting>(Common.Localize("ImportSettings:MenuName"), settings).SelectSingle(); if (selection == null) return null; XmlDocument doc = new XmlDocument(); doc.LoadXml(selection.mData); return doc.DocumentElement; }
protected IEnumerable<SimTrait.Item> GetChoices (SimDescription me, int max) { List<SimTrait.Item> allOptions = new List<SimTrait.Item>(); foreach (Trait trait in TraitManager.GetDictionaryTraits) { if (!trait.IsReward) continue; if (me != null) { if (mPreviousChoices.ContainsKey(trait.Guid)) continue; if (me.TraitManager.HasElement(trait.Guid)) { continue; } else if (!trait.TraitValidForAgeSpecies(CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Adult | me.Species))) { continue; } switch (trait.Guid) { case TraitNames.ForeverYoung: if (!me.AgingEnabled) continue; break; } } if (Traits.IsObjectBaseReward(trait.Guid)) { if ((me != null) && (me.CreatedSim == null)) continue; } allOptions.Add(new SimTrait.Item(trait.Guid, trait.Score)); } if (allOptions.Count == 0) return null; string title = Name; if (me != null) { title = me.FullName + Common.NewLine + Common.LocalizeEAString(false, "Ui/Caption/HUD/RewardTraitsShopDialog:Available", new object[] { (int)me.mSpendableHappiness }); } CommonSelection<SimTrait.Item>.Results selection = new CommonSelection<SimTrait.Item>(Name, title, allOptions).SelectMultiple(max); if ((selection == null) || (selection.Count == 0)) return null; if (me != null) { foreach (SimTrait.Item item in selection) { mPreviousChoices[item.Value] = true; } } return selection; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { Dictionary<string, bool> lookup = new Dictionary<string, bool>(); List<AlmaMaterCriteria.Item> allOptions = new List<AlmaMaterCriteria.Item>(); if (BoardingSchool.BoardingSchoolData.sBoardingSchoolDataList != null) { foreach (BoardingSchool.BoardingSchoolData data in BoardingSchool.BoardingSchoolData.sBoardingSchoolDataList.Values) { Add(allOptions, Common.LocalizeEAString(data.SchoolNameKey), data.AlmaMaterType, me, lookup); } } Add(allOptions, Common.LocalizeEAString("Gameplay/Careers/School:Community"), AlmaMater.Community, me, lookup); foreach (RabbitHole hole in Sims3.Gameplay.Queries.GetObjects<RabbitHole>()) { foreach (CareerLocation loc in hole.CareerLocations.Values) { if (loc.Career is School) { Add(allOptions, hole.CatalogName, AlmaMater.Community, me, lookup); } } } AlmaMaterCriteria.Item choice = new CommonSelection<AlmaMaterCriteria.Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; mAlmaMater = choice.Value.mAlmaMater; mAlmaMaterName = choice.Name; } me.AlmaMater = mAlmaMater; me.AlmaMaterName = mAlmaMaterName; switch (me.GraduationType) { case GraduationType.None: case GraduationType.NoSchool: me.GraduationType = GraduationType.Graduate; break; } if (me.BoardingSchool != null) { me.BoardingSchool.SetGraduatedSchoolType(BoardingSchool.BoardingSchoolTypes.None, false); me.BoardingSchool.CurrentSchoolType = BoardingSchool.BoardingSchoolTypes.None; } if (BoardingSchool.BoardingSchoolData.sBoardingSchoolDataList != null) { foreach (BoardingSchool.BoardingSchoolData data in BoardingSchool.BoardingSchoolData.sBoardingSchoolDataList.Values) { if (me.AlmaMater == data.AlmaMaterType) { if (me.BoardingSchool == null) { me.BoardingSchool = new BoardingSchool.BoardingSchoolInfo(me, BoardingSchool.BoardingSchoolTypes.None); } me.BoardingSchool.SetGraduatedSchoolType(data.SchoolType, false); break; } } } if (me.CreatedSim != null) { foreach (Diploma diploma in Inventories.QuickFind<Diploma>(me.CreatedSim.Inventory)) { diploma.mSchoolName = me.AlmaMaterName; } } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { List<SimTrait.Item> allOptions = new List<SimTrait.Item>(); foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits) { if (trait.IsReward) continue; if (trait.Guid == TraitNames.DescendantHiddenTrait) continue; if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags())) continue; if (trait.RobotOnly) continue; int count = 0; if (me.TraitManager.HasElement(trait.Guid)) { count = 1; } allOptions.Add(new SimTrait.Item (trait.Guid, count)); } CommonSelection<SimTrait.Item>.Results selection = new CommonSelection<SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectMultiple(); if (selection.Count == 0) return false; foreach (SimTrait.Item item in selection) { if (item == null) continue; TraitNames traitName = item.Value; Sims3.Gameplay.ActorSystems.Trait trait = TraitManager.GetTraitFromDictionary(traitName); if (trait != null) { if (me.TraitManager.HasElement(traitName)) { if (me.TraitManager.mSocialGroupTraitGuid == traitName) { me.RemoveSocialGroupTrait(); } else if (me.TraitManager.mUniversityGraduateTraitGuid == traitName) { me.RemoveUniversityGraduateTrait(); } else { me.RemoveTrait(trait); } } else { int iTraitsForBabiesAndToddlers = TraitManager.kTraitsForBabiesAndToddlers; int iTraitsForChildren = TraitManager.kTraitsForChildren; int iTraitsForTeens = TraitManager.kTraitsForTeens; int iTraitsForYoungAdultAndOlder = TraitManager.kTraitsForYoungAdultAndOlder; try { // Don't use MaxValue as EA adds to this number for [[University]] purposes TraitManager.kTraitsForBabiesAndToddlers = 10000000; TraitManager.kTraitsForChildren = 10000000; TraitManager.kTraitsForTeens = 10000000; TraitManager.kTraitsForYoungAdultAndOlder = 10000000; if (trait.IsHidden) { me.TraitManager.AddHiddenElement(traitName); } else { me.AddTrait(trait); } } finally { TraitManager.kTraitsForBabiesAndToddlers = iTraitsForBabiesAndToddlers; TraitManager.kTraitsForChildren = iTraitsForChildren; TraitManager.kTraitsForTeens = iTraitsForTeens; TraitManager.kTraitsForYoungAdultAndOlder = iTraitsForYoungAdultAndOlder; } } } } if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null)) { me.CreatedSim.SocialComponent.UpdateTraits(); } if (me.TraitManager.CountVisibleTraits() > me.TraitManager.NumTraitsForAge()) { Common.Notify(Common.Localize("ChangeTraits:MaxExceeded", me.IsFemale, new object[] { me, me.TraitManager.CountVisibleTraits(), me.TraitManager.NumTraitsForAge() })); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<AfterSchoolActivityCriteria.Item> choices = new List<AfterSchoolActivityCriteria.Item>(); List<AfterschoolActivity> customTypes = sCareerAfterschoolActivityList.Invoke<List<AfterschoolActivity>>(new object[] { me }); if (customTypes != null) { foreach (AfterschoolActivity type in customTypes) { choices.Add(new AfterSchoolActivityCriteria.Item(type, AfterSchoolActivityCriteria.HasActivity(me, type.CurrentActivityType) ? 1 : 0)); } } else { foreach (AfterschoolActivityType type in Enum.GetValues(typeof(AfterschoolActivityType))) { if ((me.Child) && (AfterschoolActivity.IsChildActivity(type))) { choices.Add(new AfterSchoolActivityCriteria.Item(type, AfterSchoolActivityCriteria.HasActivity(me, type) ? 1 : 0)); } else if (me.Teen && AfterschoolActivity.IsTeenActivity(type)) { choices.Add(new AfterSchoolActivityCriteria.Item(type, AfterSchoolActivityCriteria.HasActivity(me, type) ? 1 : 0)); } } } if (choices.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":NoChoices", me.IsFemale, new object[] { me })); return false; } CommonSelection<AfterSchoolActivityCriteria.Item>.Results selection = new CommonSelection<AfterSchoolActivityCriteria.Item>(Name, choices).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) return false; mSelection = selection; } foreach (AfterSchoolActivityCriteria.Item item in mSelection) { School school = me.CareerManager.School; if (school.AfterschoolActivities == null) { school.AfterschoolActivities = new List<AfterschoolActivity>(); } if (AfterSchoolActivityCriteria.HasActivity(me, item.Value)) { for (int i = school.AfterschoolActivities.Count - 1; i >= 0; i--) { if (school.AfterschoolActivities[i].CurrentActivityType == item.Value) { school.AfterschoolActivities.RemoveAt(i); } } } else { AfterschoolActivity newActivity = new AfterschoolActivity(item.Value); AfterschoolActivity oldActivity = item.Activity; if (oldActivity != null) { newActivity.ActivitySkillNameList = new List<Sims3.Gameplay.Skills.SkillNames>(oldActivity.ActivitySkillNameList); newActivity.mDaysForActivity = oldActivity.mDaysForActivity; } school.AfterschoolActivities.Add(newActivity); } me.CareerManager.UpdateCareerUI(); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { List<Item> allOptions = GetOptions(me); Dictionary<ulong, SimDescription> sims = SimListing.GetResidents(false); foreach (Item option in allOptions) { foreach (SimDescription sim in sims.Values) { if (option.Test(sim, false, me)) { option.IncCount(); } } } Item choice = new CommonSelection<Item>(Name, me.FullName, allOptions, Auxillary).SelectSingle(); if (choice == null) return false; mChoice = choice; } mChoice.Perform(me, ApplyAll); return true; }
protected List<Item> GetObjects(string header) { Dictionary<string, Item> hash = new Dictionary<string, Item>(); GetObjects(hash); { List<Item> options = new List<Item>(); int count = 0; foreach (Item item in hash.Values) { options.Add(item); count += item.Count; } List<Item> allOptions = new List<Item>(options); allOptions.Add(new Item("(" + Common.LocalizeEAString("Ui/Caption/ObjectPicker:All") + ")", null)); CommonSelection<Item>.Results selection = new CommonSelection<Item>(header, allOptions).SelectMultiple(); if ((selection != null) && (selection.Count > 0)) { foreach (Item list in selection) { if (list.mObjects.Count == 0) { return options; } } Item all = new Item("(" + Common.LocalizeEAString("Ui/Caption/ObjectPicker:All") + ")", null); hash.Clear(); foreach (Item list in selection) { all.mObjects.AddRange(list.mObjects); all.IncCount(list.mObjects.Count); if (list.mObjects.Count == 0) { return options; } else { string name = null; int count2 = 0; foreach (IGameObject obj in list.mObjects) { name = GetName(obj, false); Item item; if (!hash.TryGetValue(name, out item)) { item = AddItem(hash, name, obj); if (item != null) { item.mCatalogName = list.Name; } count2++; } else { item.Add(obj); } } if (count2 > 1) { name = "(" + Common.LocalizeEAString("Ui/Caption/ObjectPicker:All") + ": " + list.Name + ")"; hash.Add(name, new Item(name, list.Name, list.mObjects)); } } } options.Clear(); if (all.Count > 1) { options.Add(all); } foreach (Item item in hash.Values) { options.Add(item); } return new List<Item>(new CommonSelection<Item>(header, options).SelectMultiple()); } } return null; }
protected override bool Run(SimDescription me, bool singleSelection) { Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { List<CareerLevel> levels = AllLevels(career); if ((levels == null) || (levels.Count == 0)) return false; List<Item> allOptions = new List<Item>(); foreach (CareerLevel level in levels) { allOptions.Add(new Item(me, level)); } Item choice = new CommonSelection<Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; List<CareerLevel> order = null; if (choice.mLevel.Level < me.Occupation.CareerLevel) { order = LevelsBetween(choice.mLevel, career.CurLevel, true); } else { order = LevelsBetween(career.CurLevel, choice.mLevel, false); } if (order.Count == 0) { List<CareerLevel> oldBranches = AllBranches(career.CurLevel); List<CareerLevel> newBranches = AllBranches(choice.mLevel); CareerLevel common = null; foreach (CareerLevel branch in newBranches) { if (oldBranches.Contains(branch)) { common = branch; break; } } if (common != null) { order.AddRange(LevelsBetween(common, career.CurLevel, true)); order.AddRange(LevelsBetween(common, choice.mLevel, false)); } } foreach (CareerLevel level in order) { if (career.CurLevel == level) continue; if (career.CurLevel.LastLevel == level) { career.DemoteSim(); } else { Promote(career, level); } } return true; } else { XpBasedCareer xpCareer = me.Occupation as XpBasedCareer; if (xpCareer != null) { List<Item> allOptions = new List<Item>(); for (int level = 1; level <= xpCareer.HighestLevel; level++) { allOptions.Add(new Item(xpCareer.LevelJobTitle(level), level)); } Item choice = new CommonSelection<Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) return false; if (choice.mXPLevel < me.Occupation.CareerLevel) { xpCareer.mLevel = choice.mXPLevel; xpCareer.mXp = 0; } else { Dictionary<DelegateListener, ProcessEventDelegate> retain = new Dictionary<DelegateListener, ProcessEventDelegate>(); Dictionary<ulong, List<EventListener>> dictionary; EventTracker.Instance.mListeners.TryGetValue((ulong)EventTypeId.kActiveCareerAdvanceLevel, out dictionary); // Required to stop a hang when an inactive firefighter is promoted to level 10 if (me.Household != Household.ActiveHousehold) { foreach (List<EventListener> list in dictionary.Values) { foreach (EventListener listener in list) { DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if (target != null) { retain.Add(delListener, delListener.mProcessEvent); delListener.mProcessEvent = OnStub; } } } } } xpCareer.ForcePromoteToLevel(choice.mXPLevel); if (me.Household != Household.ActiveHousehold) { foreach (List<EventListener> list in dictionary.Values) { foreach (EventListener listener in list) { DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if (target != null) { delListener.mProcessEvent = retain[delListener]; } } } } } } return true; } } return false; }