Class Household
A household is a set of PersonLike instances that live together on the same Lot
[DataContract]
public class Household : JsonTypeSafeGenericDataHolder, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderHousehold
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
Household(Map, Lot, bool)
Creates a new household on the given map and lot
public Household(Map lotMap, Lot lot, bool addedThroughPopulating = false)
Parameters
lotMap
MapThe map the lot is on.
lot
LotThe lot that this household should own (can be null)
addedThroughPopulating
boolWhether this household was generated automatically, and added through the PopulateLots option in PopulateLots().
Fields
AddedThroughPopulating
Whether this household was generated automatically, and added through the PopulateLots option in PopulateLots().
[DataMember]
public readonly bool AddedThroughPopulating
Field Value
ClothesStorage
This household's clothing storage, which is a set of WornClothes that are not currently being worn by any members, but that are owned by this household. To add new objects to the clothes storage, simply add them to this set.
[DataMember]
public readonly HashSet<WornClothes> ClothesStorage
Field Value
DefaultMoney
The amount of money that a household has by default. If the househould is exported throughly (Export(bool, bool, bool)), this value will be exported as well.
public const float DefaultMoney = 30000
Field Value
Description
The household's description
[DataMember]
public string Description
Field Value
DisallowFriendsVisiting
Whether visits from friends are currently disallowed.
[DataMember]
public bool DisallowFriendsVisiting
Field Value
DisallowNewspapers
Whether newspaper deliveries are disallowed in this household. This field is set by the ToggleNewspapers action.
[DataMember]
public bool DisallowNewspapers
Field Value
DisallowStrangersVisiting
Whether visits from strangers are currently disallowed.
[DataMember]
public bool DisallowStrangersVisiting
Field Value
FurnitureStorage
This household's furniture storage, which is a set of Furniture items that are not placed, but owned by this household. To add new objects to the furniture storage, use AddToFurnitureStorage(Furniture), which also moves it to the correct map and position. Removal is possible through this collection directly.
[DataMember]
public readonly HashSet<Furniture> FurnitureStorage
Field Value
HasBeenPlayed
Whether this household has previously been played by the player.
[DataMember]
public bool HasBeenPlayed
Field Value
RandomConstellations
A set of random constellations that will be used when new households are randomly generated in Generate(Map, Random, List<AgeGroup>, Dictionary<(int Person, int Other), Relation>). Add additional items to this list to create additional constellation options.
public static readonly List<Household.RandomConstellation> RandomConstellations
Field Value
UnopenedMail
A list of Mail instances that is yet to be opened. When a mail carrier delivers mail, it is automatically added to this list.
[DataMember]
public readonly List<Mail> UnopenedMail
Field Value
Properties
IsCurrent
A property that indicates whether or not this household is the same as CurrentHousehold
public bool IsCurrent { get; }
Property Value
Lot
The Lot that this household lives on. For exported households, this might be null.
public Lot Lot { get; }
Property Value
Members
The PersonLike instances that are members of this household
public IEnumerable<PersonLike> Members { get; }
Property Value
Money
The money that this household has, rounded by two digits after the decimal point
[DataMember]
public float Money { get; set; }
Property Value
Name
The name of this household. The name of a household is the LastName that most people in this household have.
public string Name { get; }
Property Value
TotalMemberAmount
The total amount of members of this household, which includes the amount of Members, as well as unborn babies of Members.
public int TotalMemberAmount { get; }
Property Value
Methods
Add(PersonLike)
Adds the given person to this household
public void Add(PersonLike person)
Parameters
person
PersonLikeThe person to add
AddToFurnitureStorage(Furniture)
Adds the given furniture item to this household's FurnitureStorage, additionally moving it to the appropriate Map and ensuring that it does not have any children (GetChildren<T>()) currently occupying it.
public void AddToFurnitureStorage(Furniture furniture)
Parameters
furniture
FurnitureThe furniture to add.
Exceptions
- InvalidOperationException
Thrown if the furniture has any children (GetChildren<T>()) on it.
AreUtilitiesDisabled(TimeSpan?)
Returns whether power and water should currently be considered disabled for the Lot that this household is on. This method returns true when UnopenedMail has contained a BillsMail for three or more in-game days.
public bool AreUtilitiesDisabled(TimeSpan? time = null)
Parameters
Returns
- bool
Whether utilites are disabled
Export(bool, bool, bool)
Exports this household's data into an ExportedHousehold, which can be saved to disk independently of the Map that this household is on.
public ExportedHousehold Export(bool thorough, bool custom, bool ignoreStorage = false)
Parameters
thorough
boolWhether people should be reset thoroughly in ResetToStatic(bool, bool), and whether the money should be reset to DefaultMoney
custom
boolWhether the export is custom, in which case people in it will keep their unlocalized names, pronouns and descriptions.
ignoreStorage
boolWhether the household storage should be ignored (and not exported along with this household).
Returns
- ExportedHousehold
An exported household
Generate(Map, Random, List<AgeGroup>, Dictionary<(int Person, int Other), Relation>)
Generates a new random household using the given settings, and using the RandomConstellations list. Data for invoking this method can be generated using Generate(Random).
public static IEnumerable<PersonLike> Generate(Map map, Random random, List<AgeGroup> ages, Dictionary<(int Person, int Other), Household.Relation> relations)
Parameters
map
MapThe map to generate a household for.
random
RandomThe random instance to use for generation.
ages
List<AgeGroup>The ages of the people that should be included in the household. The length of the list also determines the amount of people in the household.
relations
Dictionary<(int Person, int Other), Household.Relation>A set of familiar relations that should be applied to the generated people. The indices in the dictionary refer to the
ages
of the household members.
Returns
- IEnumerable<PersonLike>
The generated household's members.
GetAgeGroups(IEnumerable<PersonLike>)
Returns a combined flag of the age groups that the members of the given list belong to.
public static AgeGroup GetAgeGroups(IEnumerable<PersonLike> members)
Parameters
members
IEnumerable<PersonLike>The household members.
Returns
- AgeGroup
The combined flag of age groups.
GetExportedHouseholds()
Returns a set of all exported households currently available to the game, including default exported households and custom exported households.
public static IEnumerable<(FileInfo File, ExportedHousehold Household, string DisplayName, bool Custom, bool Hidden)> GetExportedHouseholds()
Returns
- IEnumerable<(FileInfo File, ExportedHousehold Household, string DisplayName, bool Custom, bool Hidden)>
The exported households available to the game.
GetMatchingConstellations(AgeGroup)
Returns a set of constellations that match the given combined flag of AgeGroup values.
public static IEnumerable<(Household.RandomConstellation Constellation, float MatchPercentage)> GetMatchingConstellations(AgeGroup ages)
Parameters
ages
AgeGroupThe ages.
Returns
- IEnumerable<(Household.RandomConstellation Constellation, float MatchPercentage)>
Matching constellations, as well as a percentage that determines how well they match.
GetWeeklyBills()
Returns the amount of tiny bucks that need to be paid weekly by a Household living on this lot. The bills result from the ElectricityRating and WaterRating of the objects on the lot, as well as additional values like the lot size, and the CityNative personality.
public Dictionary<string, float> GetWeeklyBills()
Returns
- Dictionary<string, float>
The amount of weekly bills, in tiny bucks
HasMember(Guid)
Returns whether the given person Id is a part of this household
public bool HasMember(Guid person)
Parameters
person
GuidThe unique id of the person to query
Returns
- bool
true if the person is part of this household, false otherwise
Import(ExportedHousehold, bool, bool)
Imports the given ExportedHousehold into this household. Note that existing Members are not removed or replaced beforehand.
public void Import(ExportedHousehold household, bool useExistingVisitors = false, bool updateExternalPeople = true)
Parameters
household
ExportedHouseholdThe household to import
useExistingVisitors
boolWhether existing visitors should be used, if they exist, instead of the exported household's members
updateExternalPeople
boolWhether to call UpdateExternalPeople(ICollection<Map>, Action<string>, Action<float>) when the import is finished.
Remove(PersonLike, bool)
Removes the given person from this household, if they're part of it
public void Remove(PersonLike person, bool removeHouseholdIfEmpty = true)
Parameters
person
PersonLikeThe person to remove
removeHouseholdIfEmpty
boolWhether the household should be removed from the underlying map if the removed member was the last
Update(GameTime, TimeSpan, float)
Updates this household and its data.
public void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
time
GameTimeThe game's time
passedInGame
TimeSpanThe amount of time passed in game
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
Validate(Map, AppliedMigrations)
This method is called when this object is loaded from disk.
public bool Validate(Map map, AppliedMigrations appliedMigrations)
Parameters
map
MapappliedMigrations
AppliedMigrations
Returns
- bool
false if the object is not valid, true otherwise
Events
OnGetWeeklyBills
An event that is invoked when weekly bills are calculated for a Household in GetWeeklyBills(). Mods can subscribe to this event to add additional costs or reduce the default costs.
public static event Household.WeeklyBillsDelegate OnGetWeeklyBills