protected override void GetPossibleSpecies(Household house, List <CASAgeGenderFlags> species) { if ((mSpecies == null) || (mSpecies.Count == 0)) { base.GetPossibleSpecies(house, species); } else { species.AddRange(mSpecies); } if (mCheckExisting) { List <CASAgeGenderFlags> existing = new List <CASAgeGenderFlags>(); foreach (SimDescription sim in HouseholdsEx.Pets(house)) { existing.Add(sim.Species); } for (int i = species.Count - 1; i >= 0; i--) { if (existing.Contains(species[i])) { species.RemoveAt(i); } } } }
protected override bool AllowHouse(Household house) { if (ManagerCareer.HasSkillCareer(Sim, SkillNames.Handiness)) { return(true); } if (ManagerCareer.HasSkillCareer(Household.ActiveHousehold, SkillNames.Handiness)) { return(false); } bool succcess = false; foreach (SimDescription sim in HouseholdsEx.All(house)) { if (ManagerFriendship.AreEnemies(sim, Sim, -25)) { return(false); } if (ManagerFriendship.AreFriends(sim, Sim, 25)) { succcess = true; } } return(succcess); }
public bool MoveSim(SimDescription sim, Household moveTo) { if (sim.Household == moveTo) { return(true); } if (sim.Household != null) { if (sim.CreatedSim != null) { try { if ((sim.CreatedSim.Autonomy != null) && (sim.CreatedSim.Autonomy.Motives == null)) { sim.CreatedSim.Autonomy.RecreateAllMotives(); IncStat("Motives Recreated"); } if (sim.CreatedSim.LotCurrent == null) { sim.CreatedSim.InternalOnSetLotCurrent(null); } } catch (Exception e) { Common.DebugException(sim, e); Sims.Reset(sim); } } Household oldHouse = sim.Household; ProcessAbandonHouse(oldHouse, moveTo); sim.Household.Remove(sim); foreach (SimDescription member in HouseholdsEx.All(oldHouse)) { GetData(member).InvalidateCache(); } } moveTo.Add(sim); foreach (SimDescription member in HouseholdsEx.All(moveTo)) { GetData(member).InvalidateCache(); } ManagerSim.ForceRecount(); SetValue <InspectedOption, bool>(moveTo, false); Sims.Instantiate(sim, moveTo.LotHome, true); return(sim.Household == moveTo); }
public static bool HasActiveRelation(Household home) { if (Household.ActiveHousehold == null) { return(false); } foreach (SimDescription sim in HouseholdsEx.All(home)) { foreach (SimDescription active in HouseholdsEx.All(Household.ActiveHousehold)) { if (Relationships.IsCloselyRelated(sim, active, false)) { return(true); } Relationship relation = Relationship.Get(sim, active, false); if (relation == null) { continue; } if (relation.AreFriendsOrRomantic()) { return(true); } } } return(false); }
protected override bool Allow(Household house) { if (!Households.Allow(this, house, 0)) { IncStat("User Denied"); return(false); } else if (!GetValue <AllowAdoptionOption, bool>(SimTypes.HeadOfFamily(house))) { IncStat("Adoption Denied"); return(false); } else { SimDescription head = SimTypes.HeadOfFamily(house); if (AddScoring("Cooldown: Between Adoptions", TestElapsedTime <DayOfLastPetOption, PetAdoptionScenario.MinTimeBetweenAdoptionOption>(head)) < 0) { AddStat("Too Soon After Adoption", GetElapsedTime <DayOfLastPetOption>(head)); return(false); } } mPassedInspection = Lots.PassesHomeInspection(this, House.LotHome, HouseholdsEx.Pets(House), ManagerLot.FindLotFlags.InspectPets); if ((mPassedInspection) && (!HouseholdsEx.IsFull(this, House, CASAgeGenderFlags.Dog, GetValue <RoomToLeaveOption, int>(), false))) { IncStat("Score Fail"); return(false); } return(base.Allow(house)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <SimDescription> members = new List <SimDescription>(House.AllSimDescriptions); foreach (SimDescription sim in members) { if (sim.AssignedRole != null) { if (!ManagerCareer.IsRegisterInstalled()) { IncStat("Not Register"); return(true); } House.Remove(sim); Household.NpcHousehold.Add(sim); IncStat("Role Moved"); } } if (HouseholdsEx.NumSims(House) == 0) { IncStat("House Empty"); return(true); } return(false); }
public List <SimDescription> GetDeedOwner(RabbitHole hole) { List <SimDescription> owners = new List <SimDescription>(); if (hole != null) { foreach (Household house in Household.GetHouseholdsLivingInWorld()) { if (house.RealEstateManager == null) { continue; } PropertyData data = house.RealEstateManager.FindProperty(hole); if (data == null) { continue; } foreach (SimDescription sim in HouseholdsEx.Humans(house)) { if (Households.AllowGuardian(sim)) { owners.Add(sim); } } } } return(owners); }
protected override void PrivateUpdate(bool fullUpdate, bool initialPass) { if (initialPass) { mActiveHousehold = Household.ActiveHousehold; } if ((ProgressionEnabled) && (fullUpdate)) { mHouseholdCount = 0; mAverageHouseholdHumanSize = 0f; foreach (Household house in Household.GetHouseholdsLivingInWorld()) { if (HouseholdsEx.NumSims(house) == 0) { continue; } mHouseholdCount++; mAverageHouseholdHumanSize += HouseholdsEx.NumHumansIncludingPregnancy(house); } if (mHouseholdCount == 0) { mAverageHouseholdHumanSize = 0f; } else { mAverageHouseholdHumanSize /= mHouseholdCount; } } base.PrivateUpdate(fullUpdate, initialPass); }
protected static void GiveDaysOff(StoryProgressionObject manager) { if (School.sGraduatingSims == null) { return; } foreach (SimDescription sim in School.sGraduatingSims.Keys) { GiveDayOff(sim); if ((!SimTypes.IsSelectable(sim)) || (manager.GetValue <DayOffOption, bool>())) { foreach (SimDescription member in HouseholdsEx.All(sim.Household)) { if (member == sim) { continue; } GiveDayOff(member); } } } }
protected override bool Allow(Household house) { if (SimTypes.IsSpecial(house)) { IncStat("Special"); return(false); } else if (house == Household.ActiveHousehold) { IncStat("Active"); return(false); } else if (house.LotHome == null) { IncStat("Homeless"); return(false); } else if (!Households.Allow(this, house, GetValue <ManagerHousehold.MinTimeBetweenMovesOption, int>())) { IncStat("Cooldown"); return(false); } else if (GetValue <IsAncestralOption, bool>(house)) { IncStat("Ancestral"); return(false); } else if (Lots.AllowCastes(this, house.LotHome, HouseholdsEx.All(house))) { IncStat("Unnecessary"); return(false); } return(base.Allow(house)); }
protected override bool TargetAllow(SimDescription sim) { if (sim.LotHome == null) { IncStat("Homeless"); return(false); } else if (sim.Household == Sim.Household) { IncStat("Same Home"); return(false); } else { foreach (SimDescription member in HouseholdsEx.All(sim.Household)) { if (member.TraitManager == null) { continue; } if (member.TraitManager.HasElement(TraitNames.FireproofLot)) { IncStat("Fireproof"); return(false); } } } return(base.TargetAllow(sim)); }
protected override bool Allow(SimDescription sim) { if (!base.Allow(sim)) { return(false); } if (Inventories.InventoryFind <CarOwnable>(sim) != null) { IncStat("Car Found"); return(false); } else if (AddScoring("PurchaseBicycle", sim) <= 0) { IncStat("Score Fail"); return(false); } else if (sim.Household != null) { foreach (SimDescription member in HouseholdsEx.All(sim.Household)) { if (member.ToddlerOrBelow) { IncStat("Toddler Fail"); return(false); } } } return(true); }
protected override void UpdateDayOfLastOption(SimDescription sim) { foreach (SimDescription member in HouseholdsEx.All(sim.Household)) { SetElapsedTime <DayOfLastPetOption>(sim); } }
protected int GetScore(SimDescription sim) { if (sim.LotHome == null) { return(-1000); } int score = (GetValue <MaximumSizeOption, int>(sim.Household) - HouseholdsEx.NumHumansIncludingPregnancy(sim.Household)) * 2; foreach (SimDescription member in HouseholdsEx.Humans(sim.Household)) { if (Relationships.IsCloselyRelated(member, sim, false)) { score++; } if (member.Elder) { score++; } else if (member.ToddlerOrBelow) { score--; } } return(score); }
protected override bool Allow(SimDescription sim) { if (sim.Genealogy == null) { IncStat("No Genealogy"); return(false); } Household house = GetData <StoredNetWorthSimData>(sim).Household; if (house == null) { IncStat("No House"); return(false); } else if (SimTypes.IsSpecial(house)) { IncStat("Special"); return(false); } else { int count = HouseholdsEx.NumHumans(house); if ((count > 1) || ((count == 1) && (house.SimDescriptions[0] != sim))) // Humans { IncStat("People Remain"); return(false); } } return(base.Allow(sim)); }
protected override bool TargetAllow(SimDescription sim) { if (Sim.Household == Target.Household) { IncStat("Same"); return(false); } else if (sim.Household == null) { IncStat("No Home"); return(false); } else if (SimTypes.IsSpecial(sim)) { IncStat("Special"); return(false); } else if (HouseholdsEx.IsFull(sim.Household, sim.IsPet, GetValue <MaximumSizeOption, int>(sim.Household))) { IncStat("Full"); return(false); } return(base.TargetAllow(sim)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (Households.MatchesAlertLevel(HouseholdsEx.All(House))) { mHead = SimTypes.HeadOfFamily(House); } return(Households.EliminateHousehold(UnlocalizedName, House)); }
protected override ICollection <SimDescription> GetSims() { if (mHouse == null) { return(null); } return(HouseholdsEx.All(mHouse)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if ((mNewHome.House != null) && (HouseholdsEx.NumSims(mNewHome.House) > 0)) { Add(frame, GetMoveInScenario(mNewHome), ScenarioResult.Start); } Add(frame, GetMoveOutScenario(mNewHome), ScenarioResult.Failure); return(false); }
protected override bool Allow() { if (HouseholdsEx.NumSims(mHouse) == 0) { IncStat("Empty"); return(false); } return(base.Allow()); }
protected override bool Allow(Household house) { if (Lots.FindLot(this, HouseholdsEx.All(house), 0, ManagerLot.FindLotFlags.Inspect, OnLotPriceCheck) == null) { IncStat("No Homes"); return(false); } return(base.Allow(house)); }
protected override ManagerStory.Story PrintStory(StoryProgressionObject manager, string name, object[] parameters, string[] extended, ManagerStory.StoryLogging logging) { if (name == null) { return(null); } if (manager == null) { manager = Lots; } if ((House != null) && (parameters == null)) { List <SimDescription> houseSims = new List <SimDescription>(HouseholdsEx.Humans(House)); for (int i = houseSims.Count - 1; i >= 0; i--) { if (houseSims[i].ChildOrAbove) { continue; } houseSims.RemoveAt(i); } if (houseSims.Count == 1) { name += "Single"; parameters = new object[] { houseSims[0], House.LotHome }; } else if (houseSims.Count == 2) { if (DuoSameHouse(houseSims[0], houseSims[1])) { name += "DuoSameHome"; } else { name += "Duo"; } parameters = new object[] { houseSims[0], houseSims[1], House.LotHome }; } else { SimDescription head = SimTypes.HeadOfFamily(House); string names = ManagerStory.CreateNameString(houseSims, head).ToString(); parameters = new object[] { head, names, House.LotHome }; } } return(base.PrintStory(manager, name, parameters, extended, logging)); }
protected CASAgeGenderFlags GetSpecies(SimDescription sim) { List <CASAgeGenderFlags> species = new List <CASAgeGenderFlags>(); if (mSpecies != CASAgeGenderFlags.None) { species.Add(mSpecies); } else { GetPossibleSpecies(sim.Household, species); } AddStat("Choices", species.Count); bool allowAnother = RandomUtil.RandomChance(GetValue <PetAdoptionBaseScenario.ChanceOfAnotherOptionV2, int>()); for (int i = species.Count - 1; i >= 0; i--) { CASAgeGenderFlags choice = species[i]; if (Sims.HasEnough(this, choice)) { IncStat("Maximum " + species); species.RemoveAt(i); } else if (HouseholdsEx.IsFull(this, sim.Household, choice, 0, true, allowAnother)) { species.RemoveAt(i); } } if (species.Count > 0) { if (mNewSim != null) { if (!species.Contains(mNewSim.Species)) { IncStat("House Wrong Species"); return(CASAgeGenderFlags.None); } else { return(mNewSim.Species); } } return(RandomUtil.GetRandomObjectFromList(species)); } else { return(CASAgeGenderFlags.None); } }
protected int GetTotalEnemies(Household house) { int total = 0; foreach (SimDescription sim in HouseholdsEx.All(house)) { total += Friends.FindExistingEnemyFor(this, sim, -50, true).Count; } return(total); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Money.AdjustFunds(House, "PayDebt", -House.FamilyFunds); mHead = SimTypes.HeadOfFamily(House); mMovers = new List <SimDescription>(HouseholdsEx.All(House)); Add(frame, new DebtSplitFamilyScenario(House), ScenarioResult.Start); Add(frame, new DebtForgivenScenario(House), ScenarioResult.Failure); return(false); }
protected override bool PrivateUpdate(ScenarioFrame frame) { UpdateMotivesScenario scenario = new UpdateMotivesScenario(); scenario.Manager = Manager; scenario.Perform(HouseholdsEx.All(OldHouse), frame); scenario.Perform(HouseholdsEx.All(NewHouse), frame); return(true); }
public void ProcessAbandonHouse(Household oldHouse, Household newHouse) { if (HouseholdsEx.NumHumans(oldHouse) != 1) { return; } Lots.ProcessAbandonLot(oldHouse.LotHome); foreach (PropertyData data in oldHouse.RealEstateManager.AllProperties) { ManagerMoney.TransferProperty(oldHouse, newHouse, data); } }
protected override bool Allow(SimDescription sim) { if (!base.Allow(sim)) { return(false); } if (SimTypes.IsDead(sim)) { IncStat("Dead"); return(false); } else if (SimTypes.IsTourist(sim)) { IncStat("Tourist"); return(false); } else if ((sim.AgingState != null) && (sim.AgingState.IsAgingInProgress())) { IncStat("Aging"); return(false); } else if (sim.Household == null) { IncStat("No Household"); return(false); } else if (HouseholdHasAgelessBaby(sim.Household)) { IncStat("Unaging Baby"); return(false); } else if (HouseholdsEx.IsFull(this, sim.Household, sim.Species, 0, true, true)) { IncStat("House Full"); return(false); } else if ((sim.CreatedSim != null) && (sim.CreatedSim.BuffManager.HasTransformBuff())) { IncStat("Transformed"); return(false); } else if (!Pregnancies.AllowImpregnation(this, sim, Managers.Manager.AllowCheck.Active)) { IncStat("User Denied"); return(false); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { int count = 0; foreach (GameObject obj in Lot.GetObjects <GameObject>()) { try { if (obj.HasBeenDestroyed) { continue; } int value = obj.Value; obj.AppreciateDepreciateDailyUpdate(); AddScoring("", obj.Value - value); count++; if (count > 250) { SpeedTrap.Sleep(); count = 0; } } catch (Exception e) { Common.DebugException(obj, e); } } Household house = Lot.Household; if (house != null) { foreach (Sim sim in HouseholdsEx.AllSims(house)) { if (!Inventories.VerifyInventory(sim.SimDescription)) { continue; } sim.Inventory.AppreciateDepreciateInventoryItems(); } } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { ScoringList <SimDescription> scoring = new ScoringList <SimDescription>(); SimDescription head = SimTypes.HeadOfFamily(House); foreach (SimDescription sim in HouseholdsEx.All(House)) { if (!Households.AllowSoloMove(sim)) { continue; } if (head != null) { if (head == sim) { continue; } if (head.Partner == sim) { continue; } } scoring.Add(sim, AddScoring("FindOwnHome", sim, sim.Partner)); } List <SimDescription> best = scoring.GetBestByMinScore(1); if ((best == null) || (best.Count == 0)) { IncStat("No Choices"); return(false); } else { foreach (SimDescription sim in best) { HouseholdBreakdown breakdown = new HouseholdBreakdown(Manager, this, UnlocalizedName, sim, HouseholdBreakdown.ChildrenMove.Scoring, false); Add(frame, new StandardMoveInLotScenario(breakdown, 0), ScenarioResult.Failure); Add(frame, new PostScenario(sim, mPassedInspection), ScenarioResult.Success); } } return(false); }