protected override bool PrivateUpdate(ScenarioFrame frame) { if (Sim.CreatedSim == null) return false; if (Sim.CreatedSim.Posture == null) return false; Sim horseSim = Sim.CreatedSim.Posture.Container as Sim; if ((horseSim == null) || (!horseSim.IsHorse)) { bool horseFound = false; List<SimDescription> lotHorses = new List<SimDescription>(); List<SimDescription> horses = new List<SimDescription>(); foreach (SimDescription sim in HouseholdsEx.Pets(Sim.Household)) { if (!sim.IsHorse) continue; if (sim.SkillManager == null) continue; horseFound = true; if (sim.CreatedSim == null) continue; if (sim.ChildOrBelow) continue; if (sim.IsPregnant) continue; if (ManagerSim.GetLTR(sim, Sim) < 0) continue; if (sim.CreatedSim.LotCurrent == Sim.CreatedSim.LotCurrent) { lotHorses.Add(sim); } horses.Add(sim); } if (horses.Count == 0) { IncStat("No Horse"); if (!horseFound) { bool found = false; foreach (Lot lot in ManagerLot.GetOwnedLots(Sim)) { if (lot.GetObjects<IBoxStall>().Length > 0) { found = true; break; } } if (!found) { IncStat("No Stalls"); return false; } Add(frame, new PetAdoptionScenario(CASAgeGenderFlags.Horse, Sim), ScenarioResult.Start); } return false; } if (lotHorses.Count > 0) { horses = lotHorses; } AddStat("Horses", horses.Count); while (horses.Count > 0) { SimDescription horseChoice = RandomUtil.GetRandomObjectFromList(horses); horses.Remove(horseChoice); float num = horseChoice.HasTrait(TraitNames.UntrainedHorse) ? TraitTuning.UntrainedHorseSaddleLtrThreshold : RidingSkill.kMinLtrForMountAccept; if (ManagerSim.GetLTR(horseChoice, Sim) < num) { Add(frame, new ExistingFriendScenario(horseChoice, Sim, false), ScenarioResult.Start); IncStat("Friend Building"); return false; } horseSim = horseChoice.CreatedSim; if (RemountScenario.Perform(Manager, this, Sim, horseSim, new RemountScenario(Sim, horseSim))) { break; } horseSim = null; } if (horseSim == null) { IncStat("Mount Fail"); return false; } Skills.AddListener(new HorseMountedScenario(Sim, horseSim, mPushes)); IncStat("AddListener"); } else { Add(frame, new HorseMountedScenario(Sim, horseSim, mPushes), ScenarioResult.Start); } return true; }
protected void Perform(StoryProgressionObject manager, IScoringGenerator stats, string tag, List <SimDescription> movers, ChildrenMove children, bool ignoreHead) { if (movers.Count == 0) { return; } SimDescription focus = movers[0]; if (focus.Household == null) { stats.IncStat(tag + " Break: No Home"); mGoing.AddRange(movers); return; } else if (SimTypes.IsSpecial(focus)) { stats.IncStat(tag + " Break: Special"); mGoing.AddRange(movers); return; } else { bool adult = false; foreach (SimDescription sim in movers) { if (manager.Households.AllowGuardian(sim)) { adult = true; break; } } if (!adult) { stats.IncStat(tag + " Break: Child Transfer"); mStaying.AddRange(Households.All(focus.Household)); foreach (SimDescription sim in movers) { if (SimTypes.IsSelectable(sim)) { continue; } mStaying.Remove(sim); mGoing.Add(sim); } return; } List <SimDescription> going = new List <SimDescription>(); List <SimDescription> staying = new List <SimDescription>(); List <SimDescription> houseChildrenPetsPlumbots = new List <SimDescription>(); bool ancestral = manager.GetValue <IsAncestralOption, bool>(focus.Household); SimDescription head = null; if (!ignoreHead) { head = SimTypes.HeadOfFamily(focus.Household); } else if (ancestral) { stats.IncStat(tag + " Break: Ancestral Head Denied"); mStaying.AddRange(Households.All(focus.Household)); return; } foreach (SimDescription sim in Households.All(focus.Household)) { stats.IncStat(sim.FullName, Common.DebugLevel.Logging); SimDescription partner = null; if (SimTypes.IsSelectable(sim)) { stats.IncStat(tag + " Break: Active"); staying.Add(sim); } else if (!manager.Households.Allow(stats, sim, 0)) { stats.IncStat(tag + " Break: User Denied"); staying.Add(sim); } else if (IsPartner(sim, staying, out partner)) { stats.IncStat(tag + " Break: Partner Stay"); staying.Add(sim); } else if ((IsPartner(sim, movers, out partner)) || (IsPartner(sim, going, out partner))) { if ((head == sim) && (Households.NumHumans(focus.Household) != 1)) { stats.IncStat(tag + " Break: Partner Go Denied"); going.Remove(partner); staying.Add(sim); if (!staying.Contains(partner)) { staying.Add(partner); } } else { stats.IncStat(tag + " Break: Partner Go"); going.Add(sim); } } else if (movers.Contains(sim)) { if ((head == sim) && (Households.NumHumans(focus.Household) != 1)) { stats.IncStat(tag + " Break: Go Denied"); staying.Add(sim); } else { stats.IncStat(tag + " Break: Go"); going.Add(sim); } } else if (head == sim) { stats.IncStat(tag + " Break: Head Stay"); staying.Add(sim); } else if ((sim.YoungAdultOrAbove) && (!sim.IsPet) && (!sim.IsEP11Bot)) { stats.IncStat(tag + " Break: Stay"); staying.Add(sim); } else { houseChildrenPetsPlumbots.Add(sim); } } List <SimDescription> extraChildrenPets = new List <SimDescription>(); foreach (SimDescription child in houseChildrenPetsPlumbots) { bool bGoing = false; bool bMatch = false; if (child.IsPet) { int goingLiking = int.MinValue; foreach (SimDescription foci in going) { if (child.LastName == foci.LastName) { bMatch = true; int liking = ManagerSim.GetLTR(child, foci); if (goingLiking < liking) { goingLiking = liking; } } } int stayingLiking = int.MinValue; foreach (SimDescription foci in staying) { if (child.LastName == foci.LastName) { bMatch = true; int liking = ManagerSim.GetLTR(child, foci); if (stayingLiking < liking) { stayingLiking = liking; } } } if (goingLiking > stayingLiking) { bGoing = true; } } else { // this will handle plumbots that are related to the family (i.e. creation) if (children == ChildrenMove.RelatedStay) { foreach (SimDescription parent in Relationships.GetParents(child)) { if (staying.Contains(parent)) { bMatch = true; } } } else if (children == ChildrenMove.RelatedGo) { foreach (SimDescription parent in Relationships.GetParents(child)) { if (going.Contains(parent)) { bMatch = true; } } } else if (children != ChildrenMove.Stay) { foreach (SimDescription foci in going) { if (Relationships.GetChildren(foci).Contains(child)) { bMatch = true; if ((children != ChildrenMove.Scoring) || (ScoreChildMove(stats, tag, child, going))) { bGoing = true; break; } } } } } if (child.IsEP11Bot && !bGoing) { // test the liking for Plumbots without the HumanEmotion chip if (!manager.Households.AllowGuardian(child)) { bMatch = true; int goingLiking = int.MinValue; foreach (SimDescription foci in going) { int liking = ManagerSim.GetLTR(child, foci); if (goingLiking < liking) { goingLiking = liking; } } int stayingLiking = int.MinValue; foreach (SimDescription foci in staying) { int liking = ManagerSim.GetLTR(child, foci); if (stayingLiking < liking) { stayingLiking = liking; } } if (goingLiking > stayingLiking) { bGoing = true; } } } stats.IncStat(child.FullName, Common.DebugLevel.Logging); if ((!bMatch) && (manager.Households.AllowSoloMove(child))) { stats.IncStat(tag + " Break: Teen Stay"); staying.Add(child); } else if (bGoing) { if (children == ChildrenMove.Go) { stats.IncStat(tag + " Break: Child Go"); } else { stats.IncStat(tag + " Break: Child Scoring Go"); } going.Add(child); } else { if (children == ChildrenMove.Stay) { stats.IncStat(tag + " Break: Child Stay"); } else if (bMatch) { stats.IncStat(tag + " Break: Child Scoring Stay"); } extraChildrenPets.Add(child); } } bool foundAdult = false, foundBlood = false; foreach (SimDescription sim in staying) { if (manager.Deaths.IsDying(sim)) { continue; } if (!manager.Households.AllowGuardian(sim)) { continue; } if (ancestral) { if (Relationships.IsCloselyRelated(head, sim, false)) { foundBlood = true; } } foundAdult = true; } if ((!foundAdult) || ((ancestral) && (!foundBlood))) { stats.AddStat(tag + " Break: Extra", extraChildrenPets.Count); going.AddRange(extraChildrenPets); if (ancestral) { stats.IncStat(tag + " Break: Ancestral"); mStaying.AddRange(going); return; } } mStaying.AddRange(staying); foreach (SimDescription sim in mStaying) { going.Remove(sim); } mGoing.AddRange(going); } }