neighborly.components package
Submodules
neighborly.components.business module
Business Components.
This module contains class definitions for components and classes that model businesses in the settlement and character occupations.
- class neighborly.components.business.Business(district: neighborly.ecs.GameObject, name: str, owner_role: neighborly.components.business.JobRole, employee_roles: dict[neighborly.components.business.JobRole, int])[source]
Bases:
neighborly.ecs.ComponentA business where characters work.
- add_employee(employee: neighborly.ecs.GameObject, role: neighborly.components.business.JobRole) None[source]
Add an employee to the business.
- Parameters
employee – The employee to add.
role – The employee’s job role.
- property district: neighborly.ecs.GameObject
The district the residence is in.
- property employees: Mapping[neighborly.ecs.GameObject, neighborly.components.business.JobRole]
Employees mapped to their job role ID.
- get_open_positions() Iterable[neighborly.components.business.JobRole][source]
Get positions at the business with at least one open slot.
- property name: str
The name of the business.
- property owner: Optional[neighborly.ecs.GameObject]
Owner and their job role ID.
- property owner_role: neighborly.components.business.JobRole
The role of the business’ owner.
- remove_employee(employee: neighborly.ecs.GameObject) None[source]
Remove an employee from the business.
- Parameters
employee – The employee to remove.
- set_owner(owner: Optional[neighborly.ecs.GameObject]) None[source]
Set the owner of the business.
- Parameters
owner – The owner of the business.
- class neighborly.components.business.ClosedForBusiness[source]
Bases:
neighborly.ecs.TagComponentTags a business as closed and no longer active in the simulation.
- class neighborly.components.business.JobRole(display_name: str, description: str, job_level: int, requirements: list[neighborly.preconditions.base_types.Precondition], effects: list[neighborly.effects.base_types.Effect], monthly_effects: list[neighborly.effects.base_types.Effect], definition_id: str)[source]
Bases:
neighborly.ecs.ComponentInformation about a specific type of job in the world.
- check_requirements(gameobject: neighborly.ecs.GameObject) bool[source]
Check if a character passes all the requirements for this job.
- definition_id: str
The ID of this job role.
- description: str
A description of the role.
- display_name: str
The name of the role.
- effects: list[neighborly.effects.base_types.Effect]
Effects applied when the taking on the role.
- job_level: int
General level of prestige associated with this role.
- monthly_effects: list[neighborly.effects.base_types.Effect]
Effects applied every month the character has the role.
- requirements: list[neighborly.preconditions.base_types.Precondition]
Requirement functions for the role.
- class neighborly.components.business.Occupation(job_role: neighborly.components.business.JobRole, business: neighborly.ecs.GameObject, start_date: neighborly.datetime.SimDate)[source]
Bases:
neighborly.ecs.ComponentInformation about a character’s employment status.
- property business: neighborly.ecs.GameObject
The business they work for.
- property job_role: neighborly.components.business.JobRole
The job role.
- property start_date: neighborly.datetime.SimDate
The year they started this occupation.
- class neighborly.components.business.OpenForBusiness[source]
Bases:
neighborly.ecs.TagComponentTags a business as actively conducting business in the simulation.
- class neighborly.components.business.OpenToPublic[source]
Bases:
neighborly.ecs.TagComponentTags a business as frequented by characters that don’t work there.
- class neighborly.components.business.PendingOpening[source]
Bases:
neighborly.ecs.TagComponentTags a business that needs to find a business owner before it can open.
- class neighborly.components.business.Unemployed(timestamp: neighborly.datetime.SimDate)[source]
Bases:
neighborly.ecs.ComponentTags a character as needing a job, but not having a job.
- property timestamp: neighborly.datetime.SimDate
The date the character became unemployed
neighborly.components.character module
Components for representing Characters.
- class neighborly.components.character.Character(first_name: str, last_name: str, sex: neighborly.components.character.Sex, species: neighborly.ecs.GameObject)[source]
Bases:
neighborly.ecs.ComponentA character within the story world.
- property age: float
Get the character’s age.
- property first_name: str
The character’s first name.
- property full_name: str
The combined full name of the character.
- property last_name: str
The character’s last name.
- property life_stage: neighborly.components.character.LifeStage
Get the character’s life stage.
- property sex: neighborly.components.character.Sex
Get the characters sex.
- species: neighborly.ecs.GameObject
The character’s species
- class neighborly.components.character.LifeStage(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
enum.IntEnumAn enumeration of all the various life stages aging characters pass through.
- ADOLESCENT = 1
- ADULT = 3
- CHILD = 0
- SENIOR = 4
- YOUNG_ADULT = 2
- class neighborly.components.character.Pregnant(partner: neighborly.ecs.GameObject, due_date: neighborly.datetime.SimDate)[source]
Bases:
neighborly.ecs.ComponentTags a character as pregnant and tracks relevant information.
- due_date: neighborly.datetime.SimDate
The date the baby is due.
- partner: neighborly.ecs.GameObject
The GameObject ID of the character that impregnated this character.
- class neighborly.components.character.Sex(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
enum.IntEnumThe characters current sex.
- FEMALE = 2
- MALE = 1
- NOT_SPECIFIED = 3
- class neighborly.components.character.Species(adolescent_age: int, young_adult_age: int, adult_age: int, senior_age: int, lifespan: int, can_physically_age: bool)[source]
Bases:
neighborly.ecs.ComponentConfiguration information about a character’s species.
- adolescent_age
- adult_age
- can_physically_age
- lifespan
- senior_age
- young_adult_age
neighborly.components.location module
neighborly.components.relationship module
neighborly.components.residence module
Components for representing residential buildings.
- class neighborly.components.residence.Resident(residence: neighborly.ecs.GameObject)[source]
Bases:
neighborly.ecs.ComponentA Component attached to characters that tracks where they live.
- residence: neighborly.ecs.GameObject
The GameObject ID of their residence.
- class neighborly.components.residence.ResidentialBuilding(district: neighborly.ecs.GameObject)[source]
Bases:
neighborly.ecs.ComponentTags a building as managing multiple residential units.
- add_residential_unit(residence: neighborly.ecs.GameObject) None[source]
Add a residential unit to the building.
- property district: neighborly.ecs.GameObject
Get the district the residential building belongs to.
- remove_residential_unit(residence: neighborly.ecs.GameObject) None[source]
Add a residential unit to the building.
- property units: Iterable[neighborly.ecs.GameObject]
Get the residential units within the building.
- class neighborly.components.residence.ResidentialUnit(building: neighborly.ecs.GameObject, district: neighborly.ecs.GameObject)[source]
Bases:
neighborly.ecs.ComponentA Residence is a place where characters live.
- add_owner(owner: neighborly.ecs.GameObject) None[source]
Add owner to the residence.
- Parameters
owner – A GameObject reference to a residence owner.
- add_resident(resident: neighborly.ecs.GameObject) None[source]
Add a tenant to this residence.
- Parameters
resident – A GameObject reference to a resident.
- property building: neighborly.ecs.GameObject
Get the building the residential unit is in.
- property district: neighborly.ecs.GameObject
Get the district the residence is in.
- is_owner(character: neighborly.ecs.GameObject) bool[source]
Check if a GameObject owns a residence.
- Parameters
character – A GameObject reference to a residence owner.
- is_resident(character: neighborly.ecs.GameObject) bool[source]
Check if a GameObject is a resident.
- Parameters
character – A GameObject reference to a character
- property owners: Iterable[neighborly.ecs.GameObject]
Get the owners of the residence.
- remove_owner(owner: neighborly.ecs.GameObject) None[source]
Remove owner from residence.
- Parameters
owner – A GameObject reference to a residence owner.
- remove_resident(resident: neighborly.ecs.GameObject) None[source]
Remove a tenant rom this residence.
- Parameters
resident – A GameObject reference to a resident.
- property residents: Iterable[neighborly.ecs.GameObject]
Get all the residents of the residence.
- class neighborly.components.residence.Vacant[source]
Bases:
neighborly.ecs.TagComponentTags a residence that does not currently have anyone living there.
neighborly.components.settlement module
neighborly.settlement
This module contains classes and helper functions for defining and modeling settlements.
- class neighborly.components.settlement.District(name: str, description: str, settlement: neighborly.ecs.GameObject, residential_slots: int, business_slots: int)[source]
Bases:
neighborly.ecs.ComponentA subsection of a settlement.
- add_business(business: neighborly.ecs.GameObject) None[source]
Add a business to this district.
- Parameters
business – The business to add.
- add_residence(residence: neighborly.ecs.GameObject) None[source]
Add a residence to this district.
- Parameters
residence – The district to add.
- property business_slots: int
Get the number of slots remaining for businesses.
- property businesses: Iterable[neighborly.ecs.GameObject]
Get all the businesses in the district.
- property description: str
A short description of the district.
- property name: str
The name of the settlement.
- property population: int
The number of characters that live in this district.
- remove_business(business: neighborly.ecs.GameObject) bool[source]
Remove a business from this district.
- Parameters
business – The business to remove
- Returns
True if the business was successfully removed, False otherwise.
- Return type
bool
- remove_residence(residence: neighborly.ecs.GameObject) bool[source]
Remove a residence from this district.
- Parameters
residence – The residence to remove
- Returns
True if the residence was successfully removed, False otherwise.
- Return type
bool
- property residences: Iterable[neighborly.ecs.GameObject]
Get all the residential buildings in the district.
- property residential_slots: int
Get the number of slots remaining for residential buildings.
- property settlement: neighborly.ecs.GameObject
The settlement the district belongs to.
- class neighborly.components.settlement.Settlement(name: str, districts: Optional[list[neighborly.ecs.GameObject]] = None)[source]
Bases:
neighborly.ecs.ComponentA town, city, or village where characters live.
- add_district(district: neighborly.ecs.GameObject) None[source]
Add a district to this settlement.
- Parameters
district – The district to add.
- property districts: Iterable[neighborly.ecs.GameObject]
Return an iterable for this settlement’s districts.
- property name: str
The name of the settlement.
- property population: int
The total number of people living in the settlement.
- remove_district(district: neighborly.ecs.GameObject) bool[source]
Remove a district from this settlement.
- Parameters
district – The district to remove
- Returns
True if the district was successfully removed, False otherwise.
- Return type
bool
neighborly.components.skills module
neighborly.components.spawn_table module
Spawn Tables.
Spawn tables are used to manage the relative frequency of certain content appearing in the simulation.
- class neighborly.components.spawn_table.BusinessSpawnTable(entries: list[neighborly.components.spawn_table.BusinessSpawnTableEntry])[source]
Bases:
neighborly.ecs.ComponentManages the frequency that business types are spawned
- decrement_count(name: str) None[source]
Increment the instance count for an entry.
- Parameters
name – The name of entry to update
- increment_count(name: str) None[source]
Increment the instance count for an entry.
- Parameters
name – The name of entry to update
- property table: polars.dataframe.frame.DataFrame
Get the spawn table as a data frame.
- class neighborly.components.spawn_table.BusinessSpawnTableEntry[source]
Bases:
TypedDictA single row of data from a BusinessSpawnTable.
- instances: int
The current number of active instances.
- max_instances: int
Max number of instances of the business that may exist.
- min_population: int
The minimum settlement population required to spawn.
- name: str
The name of an entry.
- spawn_frequency: int
The relative frequency that this entry should spawn relative to others.
- class neighborly.components.spawn_table.CharacterSpawnTable(entries: list[neighborly.components.spawn_table.CharacterSpawnTableEntry])[source]
Bases:
neighborly.ecs.ComponentManages the frequency that character defs are spawned.
- property table: polars.dataframe.frame.DataFrame
Get the spawn table as a data frame.
- class neighborly.components.spawn_table.CharacterSpawnTableEntry[source]
Bases:
TypedDictData for a single row in a CharacterSpawnTable.
- name: str
The name of an entry.
- spawn_frequency: int
The relative frequency that this entry should spawn relative to others.
- class neighborly.components.spawn_table.ResidenceSpawnTable(entries: list[neighborly.components.spawn_table.ResidenceSpawnTableEntry])[source]
Bases:
neighborly.ecs.ComponentManages the frequency that residence types are spawned
- decrement_count(name: str) None[source]
Increment the instance count for an entry.
- Parameters
name – The name of entry to update
- increment_count(name: str) None[source]
Increment the instance count for an entry.
- Parameters
name – The name of entry to update
- property table: polars.dataframe.frame.DataFrame
Get the spawn table as a data frame.
- class neighborly.components.spawn_table.ResidenceSpawnTableEntry[source]
Bases:
TypedDictData for a single row in a ResidenceSpawnTable.
- instances: int
The number of instances of this residence type
- is_multifamily: bool
Is this a multifamily residential building.
- max_instances: int
Max number of instances of the business that may exist.
- name: str
The name of an entry.
- required_population: int
The number of people that need to live in the district.
- spawn_frequency: int
The relative frequency that this entry should spawn relative to others.
neighborly.components.stats module
neighborly.components.traits module
Trait system
This module contains class definitions for implementing the trait system.
- class neighborly.components.traits.Trait(definition_id: str, display_name: str, description: str, effects: list[neighborly.effects.base_types.Effect], conflicting_traits: Iterable[str])[source]
Bases:
neighborly.ecs.ComponentAdditional state associated with characters, businesses, and other GameObjects.
Users can use traits as another way to make runtime-changes to character behavior and component data. This class interface offers a more traditional object-oriented programming way of representing traits.
This component is attached to a GameObject that represents a trait and should not be added directly to a character or business.
- apply(target: neighborly.ecs.GameObject) None[source]
Callback method executed when the trait is added.
- Parameters
target – The gameobject with the trait
- property conflicting_traits: Iterable[str]
A set of names of this trait’s conflicts.
- property definition_id: str
The ID of this tag definition.
- property description: str
A short description of the tag.
- property display_name: str
The name of this tag printed.
- property effects: Iterable[neighborly.effects.base_types.Effect]
The effects associated with the trait.
- remove(target: neighborly.ecs.GameObject) None[source]
Callback method executed when the trait is removed.
- Parameters
target – The gameobject with the trait
- class neighborly.components.traits.Traits[source]
Bases:
neighborly.ecs.ComponentTracks the traits attached to a GameObject.
- add_trait(trait: neighborly.ecs.GameObject) bool[source]
Add a trait to the tracker.
- Parameters
trait – A trait to add.
- Returns
True if the trait was added successfully, False if already present or if the trait conflict with existing traits.
- Return type
bool
- has_conflicting_trait(trait: neighborly.ecs.GameObject) bool[source]
Check if a trait conflicts with current traits.
- Parameters
trait – The trait to check.
- Returns
True if the trait conflicts with any of the current traits or if any current traits conflict with the given trait. False otherwise.
- Return type
bool
- has_trait(trait: neighborly.ecs.GameObject) bool[source]
Check if a trait is present.
- remove_trait(trait: neighborly.ecs.GameObject) bool[source]
Remove a trait from the tracker.
- Parameters
trait – The trait to remove.
- Returns
True if a trait was successfully removed. False otherwise.
- Return type
bool
- property traits: Iterable[neighborly.ecs.GameObject]
Return an iterator for the trait collection.