-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display homelessness count #17
Comments
"Scene Explorer" mod is useful in-game for selecting an entity and viewing its components. From investigations there are a couple of potential options:
Warning Some information about |
// From 'StatusSection', which inherits 'InfoSectionBase', which inherits 'UISystemBase'
Entity selectedEntity; // From 'InfoSectionBase' property
EntityManager entityManager = ((ComponentSystemBase)this).EntityManager;
Citizen componentData = ((EntityManager)(ref entityManager)).GetComponentData<Citizen>(selectedEntity);
entityManager = ((ComponentSystemBase)this).EntityManager;
HouseholdMember componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<HouseholdMember>(selectedEntity);
conditions = CitizenUIUtils.GetCitizenConditions(((ComponentSystemBase)this).EntityManager, selectedEntity, componentData, componentData2, conditions); public static NativeList<CitizenCondition> GetCitizenConditions(
EntityManager entityManager,
Entity entity,
Citizen citizen,
HouseholdMember householdMember,
NativeList<CitizenCondition> conditions
)
{
PropertyRenter propertyRenter = default(PropertyRenter);
if (
!((EntityManager)(ref entityManager)).HasComponent<CommuterHousehold>(householdMember.m_Household) &&
!((EntityManager)(ref entityManager)).HasComponent<TouristHousehold>(householdMember.m_Household) &&
(
!EntitiesExtensions.TryGetComponent<PropertyRenter>(entityManager, householdMember.m_Household, ref propertyRenter) ||
((EntityManager)(ref entityManager)).HasComponent<Game.Buildings.Park>(propertyRenter.m_Property))
)
{
CitizenCondition citizenCondition = new CitizenCondition(CitizenConditionKey.Homeless);
conditions.Add(ref citizenCondition);
}
} |
public static ActivityCondition GetConditions(Human human)
{
if ((human.m_Flags & HumanFlags.Homeless) != 0)
{ ... }
}
private void RemoveAllHomeless()
{
EntityManager entityManager = ((ComponentSystemBase)this).EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<HomelessHousehold>() });
entityManager = ((ComponentSystemBase)this).EntityManager;
((EntityManager)(ref entityManager)).AddComponent<Deleted>(val);
}
|
Ran some queries in Scene Explorer to compare with in-game (population
less useful stats
|
Old code comments during experimentation
|
It turns out that The most reliable option appears to be iterating over Should check whether It does appear that |
With the current issues with homelessness, it could be nice to show a homeless count/percentage. However, this data is not currently exposed to the UI, and may not even be calculated behind the scenes? Once implemented, the displayed value will also need to be determined, as a percentage of entire population may not be super beneficial at massive populations (then again, it is a very similar idea to unemployment, and could benefit from #16).
This will require some additional ECS work, particularly with Queries, but may also require a Job (depending on approach).
Note that unemployment does not necessarily indicate homeless (due to temporary unemployment allowance), but might help pare down list of citizens?
There are several mods that are already calculating this, including ByeByeHomeless and CimCensus. However, both of these mods seem a little bit overkill for simply calculating the number of homeless in the city, but they may be the only viable options...
The text was updated successfully, but these errors were encountered: