public static void DisplayDialog(SimDescription actor, Household target, bool allowHorse) { List <SimDescription> pets = new List <SimDescription>(); foreach (SimDescription pet in Households.Pets(actor.Household)) { if (target != null) { int price = GetPrice(pet); if (price == 0) { continue; } if (target.FamilyFunds < price) { continue; } } pets.Add(pet); } while (true) { string title = Common.Localize("PetSelection:Title"); int maxPrice = int.MaxValue; if (target != null) { title = target.Name + Common.NewLine + Common.Localize("SellPet:Funds", false, new object[] { target.FamilyFunds }); maxPrice = target.FamilyFunds; } PetSelection.Results results = new PetSelection(actor, title, maxPrice, pets).SelectMultiple((target != null) ? 1 : 0); if ((results == null) || (results.Count == 0)) { return; } if (actor.CreatedSim != null) { PlumbBob.SelectActor(actor.CreatedSim); } foreach (SimDescription sim in results) { if ((target == null) && (sim.IsHorse) && (!allowHorse)) { Common.Notify(sim.CreatedSim, Common.Localize("SellPet:WrongSpecies", sim.IsFemale, new object[] { sim })); } else if (Relationships.GetParents(sim).Count < 0) { Common.Notify(sim.CreatedSim, Common.Localize("SellPet:NoPedigree", sim.IsFemale, new object[] { sim })); } else { int price = GetPrice(sim); if (price > maxPrice) { price = maxPrice; } if (price == 0) { Common.Notify(sim.CreatedSim, Common.Localize("SellPet:NoPrice", sim.IsFemale, new object[] { sim })); } else { actor.ModifyFunds(price); Common.Notify(sim.CreatedSim, Common.Localize("SellPet:Success", sim.IsFemale, new object[] { sim, price })); actor.Household.Remove(sim); pets.Remove(sim); Household choice = target; if (choice == null) { List <Household> choices = new List <Household>(); foreach (Household house in Household.GetHouseholdsLivingInWorld()) { if (house == actor.Household) { continue; } if (!house.CanAddSpeciesToHousehold(sim.Species)) { continue; } if (house.FamilyFunds < price) { continue; } choices.Add(house); } if (choices.Count > 0) { choice = RandomUtil.GetRandomObjectFromList(choices); } } if (choice != null) { choice.ModifyFamilyFunds(-price); choice.Add(sim); sim.LastName = SimTypes.HeadOfFamily(choice).LastName; Instantiation.AttemptToPutInSafeLocation(sim.CreatedSim, false); } else { sim.Dispose(true); } } } } if (target == null) { break; } } }
public static void DisplayDialog(SimDescription actor, Household target, bool allowHorse) { List<SimDescription> pets = new List<SimDescription>(); foreach (SimDescription pet in Households.Pets(actor.Household)) { if (target != null) { int price = GetPrice(pet); if (price == 0) continue; if (target.FamilyFunds < price) continue; } pets.Add(pet); } while (true) { string title = Common.Localize("PetSelection:Title"); int maxPrice = int.MaxValue; if (target != null) { title = target.Name + Common.NewLine + Common.Localize("SellPet:Funds", false, new object[] { target.FamilyFunds }); maxPrice = target.FamilyFunds; } PetSelection.Results results = new PetSelection(actor, title, maxPrice, pets).SelectMultiple((target != null) ? 1 : 0); if ((results == null) || (results.Count == 0)) return; if (actor.CreatedSim != null) { PlumbBob.SelectActor(actor.CreatedSim); } foreach (SimDescription sim in results) { if ((target == null) && (sim.IsHorse) && (!allowHorse)) { Common.Notify(sim.CreatedSim, Common.Localize("SellPet:WrongSpecies", sim.IsFemale, new object[] { sim })); } else if (Relationships.GetParents(sim).Count < 0) { Common.Notify(sim.CreatedSim, Common.Localize("SellPet:NoPedigree", sim.IsFemale, new object[] { sim })); } else { int price = GetPrice(sim); if (price > maxPrice) { price = maxPrice; } if (price == 0) { Common.Notify(sim.CreatedSim, Common.Localize("SellPet:NoPrice", sim.IsFemale, new object[] { sim })); } else { actor.ModifyFunds(price); Common.Notify(sim.CreatedSim, Common.Localize("SellPet:Success", sim.IsFemale, new object[] { sim, price })); actor.Household.Remove(sim); pets.Remove(sim); Household choice = target; if (choice == null) { List<Household> choices = new List<Household>(); foreach (Household house in Household.GetHouseholdsLivingInWorld()) { if (house == actor.Household) continue; if (!house.CanAddSpeciesToHousehold(sim.Species)) continue; if (house.FamilyFunds < price) continue; choices.Add(house); } if (choices.Count > 0) { choice = RandomUtil.GetRandomObjectFromList(choices); } } if (choice != null) { choice.ModifyFamilyFunds(-price); choice.Add(sim); sim.LastName = SimTypes.HeadOfFamily(choice).LastName; Instantiation.AttemptToPutInSafeLocation(sim.CreatedSim, false); } else { sim.Dispose(true); } } } } if (target == null) break; } }