protected override bool PrivateUpdate(ScenarioFrame frame) { SimPersonality clan = Manager as SimPersonality; foreach (SimDescription sim in clan.GetClanMembers(false)) { clan.CheckRetention(sim); } if ((mScenarios == null) || (mScenarios.Count == 0)) { IncStat("No Choices"); return(false); } WeightOption scenario = RandomUtil.GetWeightedRandomObjectFromList(mScenarios.ToArray()) as WeightOption; if (scenario == null) { IncStat("Bad Choice"); return(false); } if (!mFirst) { if (scenario is SimPersonality.IMustBeFirstChoiceOption) { IncStat("Must Be First"); return(false); } } mFirst = false; mScenarios.Remove(scenario); Add(frame, scenario.GetScenario(), ScenarioResult.Start); Add(frame, new ResetChanceScenario(mPersonality), ScenarioResult.Success); return(true); }
public ICollection <SimDescription> Filter(Parameters parameters, string name, SimDescription sim, ICollection <SimDescription> potentials) { if (!mEnabled) { parameters.IncStat(name + " Disabled"); if (parameters.mDefaultAll) { return(parameters.mManager.Sims.All); } else { return(potentials); } } Collect(sim); if ((sim != null) && (potentials == null)) { switch (mStandardFilter) { case StandardFilter.Me: potentials = new List <SimDescription>(); potentials.Add(sim); break; case StandardFilter.Partner: potentials = new List <SimDescription>(); if (sim.Partner != null) { potentials.Add(sim.Partner); } break; case StandardFilter.AnyFlirt: potentials = parameters.mManager.Flirts.FindAnyFor(parameters, sim, mAllowAffair, false); break; case StandardFilter.ExistingFriend: potentials = parameters.mManager.Friends.FindExistingFriendFor(parameters, sim, mStandardGate, mStandardIgnoreBusy); break; case StandardFilter.Partnered: potentials = parameters.mManager.Romances.FindPartneredFor(sim); break; case StandardFilter.ExistingFlirt: potentials = parameters.mManager.Flirts.FindExistingFor(parameters, sim, mStandardDisallowPartner); break; case StandardFilter.ExistingOrAnyFlirt: potentials = parameters.mManager.Flirts.FindExistingFor(parameters, sim, mStandardDisallowPartner); if ((potentials == null) || (potentials.Count == 0)) { potentials = parameters.mManager.Flirts.FindAnyFor(parameters, sim, mAllowAffair, false); } break; case StandardFilter.ExistingEnemy: potentials = parameters.mManager.Friends.FindExistingEnemyFor(parameters, sim, mStandardGate, mStandardIgnoreBusy); break; case StandardFilter.Nemesis: potentials = parameters.mManager.Friends.FindNemesisFor(parameters, sim, mStandardIgnoreBusy); break; } if (potentials != null) { parameters.AddStat(name + " " + mStandardFilter.ToString(), potentials.Count); } } SimPersonality clan = parameters.mManager as SimPersonality; if (!string.IsNullOrEmpty(mClan)) { clan = parameters.mManager.Personalities.GetPersonality(mClan); if (clan == null) { parameters.IncStat(mClan + " Missing"); return(new List <SimDescription>()); } } if (clan != null) { if (potentials == null) { if (mClanMembers) { potentials = clan.GetClanMembers(mClanLeader); parameters.mIsFriendly = true; } else if (mClanLeader) { potentials = clan.MeAsList; parameters.mIsFriendly = true; } if (potentials != null) { parameters.AddStat(name + " Clan", potentials.Count); } } else if ((mClanLeader) || (mClanMembers)) { List <SimDescription> clanPotentials = new List <SimDescription>(); foreach (SimDescription potential in potentials) { if (clan.Me == potential) { if (!mClanLeader) { parameters.IncStat(name + " Leader Denied"); continue; } } else if (clan.IsMember(potential)) { if (!mClanMembers) { parameters.IncStat(name + " Member Denied"); continue; } } else { parameters.IncStat(name + " Non-clan Denied"); continue; } clanPotentials.Add(potential); } potentials = clanPotentials; } } if (potentials == null) { potentials = parameters.mManager.Sims.All; parameters.AddStat(name + " All", potentials.Count); } parameters.AddStat(name + " Potentials", potentials.Count); ScoringList <SimDescription> list = new ScoringList <SimDescription>(); foreach (SimDescription potential in potentials) { int score = 0; if (!Test(parameters, name, sim, potential, true, out score)) { continue; } list.Add(potential, score); parameters.mManager.Main.Sleep("SimScenarioFilter:Filter"); } List <SimDescription> results = list.GetBestByPercent(100); parameters.AddStat(name + " Results", results.Count); if (mThirdPartyFilter != ThirdPartyFilter.None) { Dictionary <SimDescription, bool> lookup = new Dictionary <SimDescription, bool>(); foreach (SimDescription result in results) { switch (mThirdPartyFilter) { case ThirdPartyFilter.Romantic: foreach (Relationship relation in Relationship.Get(result)) { if (!relation.AreRomantic()) { continue; } SimDescription other = relation.GetOtherSimDescription(result); if (other == null) { continue; } lookup[other] = true; } break; case ThirdPartyFilter.Friend: foreach (Relationship relation in Relationship.Get(result)) { if (!relation.AreFriends()) { continue; } SimDescription other = relation.GetOtherSimDescription(result); if (other == null) { continue; } lookup[other] = true; } break; case ThirdPartyFilter.Enemy: foreach (Relationship relation in Relationship.Get(result)) { if (!relation.AreEnemies()) { continue; } SimDescription other = relation.GetOtherSimDescription(result); if (other == null) { continue; } lookup[other] = true; } break; case ThirdPartyFilter.Partner: if (result.Partner == null) { continue; } lookup[result.Partner] = true; break; case ThirdPartyFilter.Parents: foreach (SimDescription parent in Relationships.GetParents(result)) { lookup[parent] = true; } break; case ThirdPartyFilter.Siblings: foreach (SimDescription sibling in Relationships.GetSiblings(result)) { lookup[sibling] = true; } break; case ThirdPartyFilter.Children: foreach (SimDescription child in Relationships.GetChildren(result)) { lookup[child] = true; } break; } parameters.mManager.Main.Sleep("SimScenarioFilter:Filter"); } results.Clear(); results.AddRange(lookup.Keys); parameters.AddStat(name + " " + mThirdPartyFilter, results.Count); } return(results); }