Game.Buildings.PropertyUtils
Assembly:
Namespace: Game.Buildings
Type: public static class
Base: System.Object
Summary:
Utility helpers used by building- and property-related systems in the game. PropertyUtils contains static helper functions to evaluate apartment quality, compute rent, determine zone density and mixing, and also defines two Burst-compiled job structs used by company/property matching systems (ExtractorFindCompanyJob and CompanyFindPropertyJob). These utilities are used by household/company find-property systems, extractor/company matching, and by gameplay logic that evaluates building desirability and rent calculations for Cities: Skylines 2 modding.
Fields
public static readonly float kHomelessApartmentSize
{{ YOUR_INFO }}
Constant apartment size used for homeless shelters / fallback housing quality calculations (value: 0.01f). Used when a building lacks normal property data (homeless fallback).
Properties
- No public properties on this static class.
{{ YOUR_INFO }}
Constructors
- No constructors (static helper class).
{{ YOUR_INFO }}
Methods
-
public struct ExtractorFindCompanyJob : IJob
{{ YOUR_INFO }}
Burst-compiled job that iterates extractor-related entities to find and match extractor properties with extractor-type companies. Reads a number of component lookups and lists (entities, extractor company entities, company prefabs, resource data, extractor area data, etc.), evaluates resource concentration and temperature constraints, and enqueues RentAction items for rent-matching via a NativeQueue. Also sets PropertySeeker enable/disable via an EntityCommandBuffer when a match is found. -
public struct CompanyFindPropertyJob : IJobChunk
{{ YOUR_INFO }}
Burst-compiled chunk job that runs over company entities (commercial, industrial or storage companies), evaluates free properties for suitability and scores them (using IndustrialFindPropertySystem / CommercialFindPropertySystem evaluation functions), and enqueues RentAction items for companies that should rent a property. Handles storage/company-specific logic, resource allowances, best-property selection, and uses a parallel EntityCommandBuffer writer and RentAction parallel queue writer. -
public static int GetRentPricePerRenter(BuildingPropertyData buildingPropertyData, int buildingLevel, int lotSize, float landValueBase, Game.Zones.AreaType areaType, ref EconomyParameterData economyParameterData, bool ignoreLandValue = false)
{{ YOUR_INFO }}
Calculate the rent price per renter for a property. Takes building property data, building/spawn level, lot size, base land value, zone area type and economy parameters. Considers zone-type base rent modifiers, land value modifiers (unless ignoreLandValue is true), space multiplier and whether the building is mixed-use to divide total rent across residential properties. Returns rounded integer rent per renter. -
public static float GetPropertyScore(Entity property, Entity household, DynamicBuffer<HouseholdCitizen> citizenBuffer, ref ComponentLookup<PrefabRef> prefabRefs, ref ComponentLookup<BuildingPropertyData> buildingProperties, ref ComponentLookup<Building> buildings, ref ComponentLookup<BuildingData> buildingDatas, ref ComponentLookup<Household> households, ref ComponentLookup<Citizen> citizens, ref ComponentLookup<Game.Citizens.Student> students, ref ComponentLookup<Worker> workers, ref ComponentLookup<SpawnableBuildingData> spawnableDatas, ref ComponentLookup<CrimeProducer> crimes, ref BufferLookup<Game.Net.ServiceCoverage> serviceCoverages, ref ComponentLookup<Locked> locked, ref ComponentLookup<ElectricityConsumer> electricityConsumers, ref ComponentLookup<WaterConsumer> waterConsumers, ref ComponentLookup<GarbageProducer> garbageProducers, ref ComponentLookup<MailProducer> mailProducers, ref ComponentLookup<Game.Objects.Transform> transforms, ref ComponentLookup<Abandoned> abandoneds, ref ComponentLookup<Park> parks, ref BufferLookup<ResourceAvailability> availabilities, NativeArray<int> taxRates, NativeArray<GroundPollution> pollutionMap, NativeArray<AirPollution> airPollutionMap, NativeArray<NoisePollution> noiseMap, CellMapData<TelecomCoverage> telecomCoverages, DynamicBuffer<CityModifier> cityModifiers, Entity healthcareService, Entity entertainmentService, Entity educationService, Entity telecomService, Entity garbageService, Entity policeService, CitizenHappinessParameterData citizenHappinessParameterData, GarbageParameterData garbageParameterData)
{{ YOUR_INFO }}
Computes a score representing how suitable a property is for a particular household. Factors include whether the household has moved-in flag, homeless-shelter special handling, apartment size and quality, citizen happiness averages, number of children/adults, commute times for students and workers, available services (via service coverages), pollution/noise/telecom bonuses/penalties, utilities (electricity, water, sewage), garbage/mail, and cached apartment quality. Returns a float score (negative infinity if property not valid). -
public static float GetServiceAvailability(Entity roadEdge, float curvePos, BufferLookup<ResourceAvailability> availabilities)
{{ YOUR_INFO }}
Returns a service coverage availability value for a road edge and curve position using NetUtils.GetAvailability when the ResourceAvailability buffer exists; otherwise returns 0. -
public static int2 GetElectricityBonusForApartmentQuality(Entity building, ref ComponentLookup<ElectricityConsumer> electricityConsumers, in CitizenHappinessParameterData data)
{{ YOUR_INFO }}
If electricity is not connected for the building, returns a negative wellbeing penalty (int2 with y component). Otherwise returns default (0,0). -
public static int2 GetWaterBonusForApartmentQuality(Entity building, ref ComponentLookup<WaterConsumer> waterConsumers, in CitizenHappinessParameterData data)
{{ YOUR_INFO }}
If water is not connected, returns penalties to health (x) and wellbeing (y) based on parameter data. Otherwise returns default (0,0). -
public static int2 GetSewageBonusForApartmentQuality(Entity building, ref ComponentLookup<WaterConsumer> waterConsumers, in CitizenHappinessParameterData data)
{{ YOUR_INFO }}
If sewage is not connected, returns negative health/wellbeing effects as defined in CitizenHappinessParameterData. Otherwise returns default (0,0). -
public static HouseholdFindPropertySystem.GenericApartmentQuality GetGenericApartmentQuality(Entity building, Entity buildingPrefab, ref Building buildingData, ref ComponentLookup<BuildingPropertyData> buildingProperties, ref ComponentLookup<BuildingData> buildingDatas, ref ComponentLookup<SpawnableBuildingData> spawnableDatas, ref ComponentLookup<CrimeProducer> crimes, ref BufferLookup<Game.Net.ServiceCoverage> serviceCoverages, ref ComponentLookup<Locked> locked, ref ComponentLookup<ElectricityConsumer> electricityConsumers, ref ComponentLookup<WaterConsumer> waterConsumers, ref ComponentLookup<GarbageProducer> garbageProducers, ref ComponentLookup<MailProducer> mailProducers, ref ComponentLookup<Game.Objects.Transform> transforms, ref ComponentLookup<Abandoned> abandoneds, NativeArray<GroundPollution> pollutionMap, NativeArray<AirPollution> airPollutionMap, NativeArray<NoisePollution> noiseMap, CellMapData<TelecomCoverage> telecomCoverages, DynamicBuffer<CityModifier> cityModifiers, Entity healthcareService, Entity entertainmentService, Entity educationService, Entity telecomService, Entity garbageService, Entity policeService, CitizenHappinessParameterData happinessParameterData, GarbageParameterData garbageParameterData)
{{ YOUR_INFO }}
Builds a GenericApartmentQuality struct containing apartmentSize, level, education/welfare/score & other bonuses derived from services, pollution, telecom, utilities, crime and homeless fallback. Uses building property and spawnable data; if building lacks property/spawnable data it's treated as homeless fallback. Used internally by GetApartmentQuality and GetPropertyScore. -
public static float GetApartmentQuality(int familySize, int children, Entity building, ref Building buildingData, Entity buildingPrefab, ref ComponentLookup<BuildingPropertyData> buildingProperties, ref ComponentLookup<BuildingData> buildingDatas, ref ComponentLookup<SpawnableBuildingData> spawnableDatas, ref ComponentLookup<CrimeProducer> crimes, ref BufferLookup<Game.Net.ServiceCoverage> serviceCoverages, ref ComponentLookup<Locked> locked, ref ComponentLookup<ElectricityConsumer> electricityConsumers, ref ComponentLookup<WaterConsumer> waterConsumers, ref ComponentLookup<GarbageProducer> garbageProducers, ref ComponentLookup<MailProducer> mailProducers, ref ComponentLookup<PrefabRef> prefabs, ref ComponentLookup<Game.Objects.Transform> transforms, ref ComponentLookup<Abandoned> abandoneds, NativeArray<GroundPollution> pollutionMap, NativeArray<AirPollution> airPollutionMap, NativeArray<NoisePollution> noiseMap, CellMapData<TelecomCoverage> telecomCoverages, DynamicBuffer<CityModifier> cityModifiers, Entity healthcareService, Entity entertainmentService, Entity educationService, Entity telecomService, Entity garbageService, Entity policeService, CitizenHappinessParameterData happinessParameterData, GarbageParameterData garbageParameterData, int averageHappiness)
{{ YOUR_INFO }}
Compute an apartment quality score tailored to a family (familySize and children) by combining GenericApartmentQuality with welfare/education bonuses and apartment wellbeing. Useful for household property selection and UI quality reporting. -
public static float GetCachedApartmentQuality(int familySize, int children, int averageHappiness, HouseholdFindPropertySystem.GenericApartmentQuality quality)
{{ YOUR_INFO }}
Shortcut to compute apartment quality from a precomputed GenericApartmentQuality and cached welfare bonuses. Avoids recomputing service/pollution/utility lookups. -
public static ZoneDensity GetZoneDensity(ZoneData zoneData, ZonePropertiesData zonePropertiesData)
{{ YOUR_INFO }}
Returns the ZoneDensity (Low, Medium, High) derived from zone area type and zone properties (scale, space multiplier, residential properties, office detection). Uses assertions for unknown AreaType. -
public static int GetResidentialProperties(BuildingPropertyData propertyData)
{{ YOUR_INFO }}
Counts and returns the number of residential properties in a BuildingPropertyData via CountProperties for Residential area type. -
public static bool IsMixedBuilding(Entity buildingPrefab, ref ComponentLookup<BuildingPropertyData> buildingPropertyDatas)
{{ YOUR_INFO }}
Checks whether a prefab entity is a mixed-use building (has both residential and commercial/manufactured allowances). Returns false if the prefab has no BuildingPropertyData component. -
public static int GetBuildingLevel(Entity prefabEntity, ComponentLookup<SpawnableBuildingData> spawnableBuildingDatas)
{{ YOUR_INFO }}
Return spawnable building level if SpawnableBuildingData exists, otherwise defaults to 1. -
public static bool IsMixedBuilding(BuildingPropertyData buildingPropertyData)
{{ YOUR_INFO }}
Determines whether a BuildingPropertyData represents a mixed building. If the buildingPropertyData has residential properties and sold/ manufactured resource allowances, returns true for mixed; otherwise false.
Usage Example
// Example usage inside a system/job or mod script context:
// Calculate rent per renter and sample apartment quality for a building.
BuildingPropertyData propData = /* get from component lookup */;
int buildingLevel = PropertyUtils.GetBuildingLevel(prefabEntity, spawnableDatas);
float landValueBase = 1200f;
int lotSize = 4;
var areaType = Game.Zones.AreaType.Residential;
int rentPerRenter = PropertyUtils.GetRentPricePerRenter(
propData,
buildingLevel,
lotSize,
landValueBase,
areaType,
ref economyParameters,
ignoreLandValue: false);
// Compute cached apartment quality for display (assuming GenericApartmentQuality precomputed)
var genericQuality = PropertyUtils.GetGenericApartmentQuality(
buildingEntity, prefabEntity, ref buildingData, ref buildingProperties, ref buildingDatas,
ref spawnableDatas, ref crimes, ref serviceCoverages, ref locked, ref electricityConsumers,
ref waterConsumers, ref garbageProducers, ref mailProducers, ref transforms, ref abandoneds,
pollutionMap, airPollutionMap, noiseMap, telecomCoverages, cityModifiers,
healthcareService, entertainmentService, educationService, telecomService, garbageService, policeService,
happinessParams, garbageParams);
float apartmentQuality = PropertyUtils.GetCachedApartmentQuality(
familySize, children, averageHappiness, genericQuality);
{{ YOUR_INFO }}