protected override bool PrivateUpdate(ScenarioFrame frame) { Add(frame, new ImmigrantCareerScenario(Sim, mRequirement), ScenarioResult.Start); if ((mRequirement.mFertile) && (Sim.TeenOrAbove) && (RandomUtil.RandomChance(25))) { Trait trait = TraitManager.GetTraitFromDictionary(TraitNames.FamilyOriented); if (trait != null) { Sim.RemoveTrait(TraitManager.GetTraitFromDictionary(TraitNames.DislikesChildren)); List <Trait> traits = new List <Trait>(Sim.TraitManager.List); if ((traits.Count > 0) && (traits.Count >= Sim.TraitManager.NumTraitsForAge())) { Sim.RemoveTrait(RandomUtil.GetRandomObjectFromList(traits)); } Sim.AddTrait(trait); } } if ((mRequirement.mSingle) && (Sim.TeenOrAbove) && (RandomUtil.RandomChance(25))) { Trait trait = TraitManager.GetTraitFromDictionary(TraitNames.Flirty); if (trait != null) { Sim.RemoveTrait(TraitManager.GetTraitFromDictionary(TraitNames.Unflirty)); List <Trait> traits = new List <Trait>(Sim.TraitManager.List); if ((traits.Count > 0) && (traits.Count >= Sim.TraitManager.NumTraitsForAge())) { Sim.RemoveTrait(RandomUtil.GetRandomObjectFromList(traits)); } Sim.AddTrait(trait); } } foreach (SimDescription other in mImmigrants) { if (Sim == other) { continue; } Relationship relation = Relationship.Get(Sim, other, true); if (relation == null) { continue; } relation.LTR.SetLiking(RandomUtil.GetFloat(25, 100)); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { foreach (Trait trait in new List <Trait>(Sim.TraitManager.List)) { if (trait.IsReward) { continue; } if (HasValue <ForceTraitOption, TraitNames>(Sim, trait.Guid)) { IncStat("Forced Trait Found"); return(false); } } IncStat("Necessary"); TraitNames removedTrait = TraitNames.Unknown; int available = Sim.TraitManager.NumTraitsForAge() - Sim.TraitManager.CountVisibleTraits(); if (available == 0) { foreach (Trait trait in new List <Trait>(Sim.TraitManager.List)) { if (HasValue <DisallowTraitOption, TraitNames>(Sim, trait.Guid)) { Sim.TraitManager.RemoveElement(trait.Guid); if ((trait.IsHidden) || (trait.IsReward)) { continue; } removedTrait = trait.Guid; IncStat("Disallowed Trait Removed"); available = 1; break; } } } if (available <= 0) { List <Trait> traits = new List <Trait>(Sim.TraitManager.List); RandomUtil.RandomizeListOfObjects(traits); foreach (Trait trait in traits) { if ((trait.IsHidden) || (trait.IsReward)) { continue; } Sim.TraitManager.RemoveElement(trait.Guid); removedTrait = trait.Guid; IncStat("Removed One"); break; } } List <TraitNames> choices = new List <TraitNames>(GetValue <ForceTraitOption, List <TraitNames> >(Sim)); RandomUtil.RandomizeListOfObjects(choices); bool readdTrait = true; bool result = false; foreach (TraitNames traitName in choices) { Trait trait = TraitManager.GetTraitFromDictionary(traitName); if (trait == null) { continue; } if (!trait.TraitValidForAgeSpecies(Sim.GetCASAGSAvailabilityFlags())) { continue; } bool success = false; if (trait.IsHidden) { success = Sim.TraitManager.AddElement(traitName, true); } else { success = Sim.AddTrait(trait); } if (success) { IncStat("Success"); result = true; GetData(Sim).InvalidateCache(); if ((!trait.IsHidden) && (!trait.IsReward)) { readdTrait = false; } break; } } if ((readdTrait) && (removedTrait != TraitNames.Unknown)) { Sim.AddTrait(TraitManager.GetTraitFromDictionary(removedTrait)); IncStat("Trait Readded"); } return(result); }