public static bool SimCanLearnSkill(SkillNames skillName, SimDescription simDesc) { Skill skill = SkillManager.GetStaticSkill(skillName); if (skill == null) { return(false); } if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Adult | simDesc.Species) & skill.AvailableAgeSpecies) != CASAGSAvailabilityFlags.None) { return(true); } if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Teen | simDesc.Species) & skill.AvailableAgeSpecies) != CASAGSAvailabilityFlags.None) { return(true); } if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Child | simDesc.Species) & skill.AvailableAgeSpecies) != CASAGSAvailabilityFlags.None) { return(true); } if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Toddler | simDesc.Species) & skill.AvailableAgeSpecies) != CASAGSAvailabilityFlags.None) { return(true); } return(false); }
private static bool IsSimGoodForRoleCommonTest(IMiniSimDescription desc, RoleData data, IRoleGiver roleGiver, out string reason) { WorldName homeWorld = desc.HomeWorld; /* * bool isCelebrity = desc.IsCelebrity; * if (!data.CanBeCelebrity && isCelebrity) * { * reason = "Celebrity Fail"; * return false; * } */ if ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(desc.Age | desc.Species) & data.AvailableAgeSpecies) == CASAGSAvailabilityFlags.None) { reason = "Age/Species Fail"; return(false); } SimDescription description = desc as SimDescription; if (((description != null) && (description.CreatedSim == null)) && (description.WillAgeUpOnInstantiation && ((CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(AgingState.GetNextOlderAge(desc.Age, desc.Species) | desc.Species) & data.AvailableAgeSpecies) == CASAGSAvailabilityFlags.None))) { reason = "Age/Species Fail"; return(false); } if (data.FillRoleFrom == Role.RoleFillFrom.PeopleWhoDontLiveInThisWorld) { if ((homeWorld != WorldName.TouristWorld) && (GameUtils.GetWorldType(homeWorld) != WorldType.Vacation) && (GameUtils.GetWorldType(homeWorld) != WorldType.Future)) { reason = "Vacation World Fail"; return(false); } if (homeWorld == GameUtils.GetCurrentWorld()) { reason = "Home World Fail"; return(false); } if (GameUtils.GetWorldType(homeWorld) == WorldType.Future) { if (Sims3.Gameplay.Queries.CountObjects <ITimePortal>() == 0) { reason = "Time Portal Fail"; return(false); } } } /* * else if (data.FillRoleFrom == RoleFillFrom.CustomCreatedSim) * { * return false; * } */ IRoleGiverCustomIsSimGoodTest test = roleGiver as IRoleGiverCustomIsSimGoodTest; if ((test != null) && (!test.IsSimGoodForRole(desc))) { reason = "Role Giver Fail"; return(false); } reason = "Success"; return(true); }
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 string SetTraits(SimDescription me, IEnumerable <SimTrait.Item> choices) { string result = Name + Common.NewLine + me.FullName; bool success = false; foreach (SimTrait.Item selection in choices) { if (me.TraitManager.HasElement(selection.Value)) { continue; } Trait selected = TraitManager.GetTraitFromDictionary(selection.Value); if (selected != null) { if (!selected.TraitValidForAgeSpecies(CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Adult | me.Species))) { continue; } if (me.mSpendableHappiness < selected.Score) { continue; } me.mSpendableHappiness -= selected.Score; result += Common.NewLine + " " + selected.TraitName(me.IsFemale); success = true; if (Traits.IsObjectBaseReward(selected.Guid)) { if (me.Household == null) { continue; } if (me.CreatedSim == null) { continue; } HudModel hudModel = Sims3.UI.Responder.Instance.HudModel as HudModel; if (hudModel != null) { bool showTNS = SimTypes.IsSelectable(me); bool inHouseInventory = false; Sim rewardedSim = me.CreatedSim; hudModel.GiveRewardObjects(me.CreatedSim, selected.Guid, selected.ProductVersion, ref showTNS, ref inHouseInventory, ref rewardedSim); } } else { switch (selected.Guid) { case TraitNames.ForeverYoung: me.AgingEnabled = false; break; default: if (selected.Guid == TraitNames.SuperVampire) { me.AgingEnabled = false; } if (!me.AddTrait(selected)) { me.mSpendableHappiness += selected.Score; } break; } } } } if (!success) { result += Common.NewLine + " " + Common.Localize(GetTitlePrefix() + ":None"); } return(result); }