Game.Simulation.PropertyProcessingSystem
Assembly: Assembly-CSharp (Game)
Namespace: Game.Simulation
Type: public class
Base: GameSystemBase
Summary:
PropertyProcessingSystem is a game simulation system responsible for managing property lifecycle and renting logic. It:
- Moves properties onto/off the market based on building data, land value, allowed resources and available company prefabs (PutPropertyOnMarketJob).
- Processes rent requests from renters and assigns renters to properties, updates renter buffers, triggers events (RentersUpdated, PathTargetMoved) and brand/trigger actions (PropertyRentJob).
- Maintains a NativeQueue
Fields
-
private EntityQuery m_CommercialCompanyPrefabQuery
Query for commercial company prefabs (ArchetypeData + CommercialCompanyData + IndustrialProcessData) used to find companies that can rent/operate commercial properties. -
private EntityQuery m_IndustrialCompanyPrefabQuery
Query for industrial company prefabs (ArchetypeData + IndustrialCompanyData + IndustrialProcessData, excluding storage companies) used to match industrial properties to companies. -
private EntityQuery m_PropertyGroupQuery
Query selecting placed properties that should be considered for market processing (Building + PrefabRef + PropertyToBeOnMarket and one of Commercial/Residential/Industrial/Extractor). -
private EntityQuery m_EconomyParameterQuery
Query used to fetch EconomyParameterData singleton required for rent/price calculations. -
private EndFrameBarrier m_EndFrameBarrier
Barrier used to create command buffers that will apply ECS structural changes safely at the end of the frame. -
private TriggerSystem m_TriggerSystem
Reference to the global TriggerSystem for enqueueing trigger actions related to renting and brands. -
private CityStatisticsSystem m_CityStatisticsSystem
Reference used to enqueue statistics events and register writers. -
private ResourceSystem m_ResourceSystem
Reference to resource prefabs and resource-related lookups. -
private EntityArchetype m_RentEventArchetype
Archetype used to create Rent event entities (Game.Common.Event + RentersUpdated). -
private EntityArchetype m_MovedEventArchetype
Archetype used to create Moved event entities (Game.Common.Event + PathTargetMoved). -
private NativeQueue<RentAction> m_RentActionQueue
Queue used by other systems/jobs to request rental actions. Persisted across system lifetime. -
private NativeList<Entity> m_ReservedProperties
Temporary list keeping properties reserved during processing to avoid double-assignment. -
private JobHandle m_Writers
Combined writers JobHandle used to track jobs that will write to shared data structures (used by GetRentActionQueue/AddWriter). -
private TypeHandle __TypeHandle
Generated handles container (component lookups / type handles) used by the system and its jobs to access ECS data efficiently.
Properties
- This type defines no public properties.
Constructors
public PropertyProcessingSystem()
Default constructor. The real initialization of queues, lists and system references happens in OnCreate; constructor is preserved but empty.
Methods
-
public override int GetUpdateInterval(SystemUpdatePhase phase)
Returns update interval (16). The system is set to update every 16 simulation ticks. -
protected override void OnCreate()
Initializes runtime resources: - Allocates m_RentActionQueue (NativeQueue) and m_ReservedProperties (NativeList).
- Gets references to TriggerSystem, CityStatisticsSystem, EndFrameBarrier, ResourceSystem.
- Creates archetypes for rent/moved events.
- Sets up entity queries (m_EconomyParameterQuery, m_PropertyGroupQuery, company prefab queries).
-
Calls RequireForUpdate for economy parameters.
-
public NativeQueue<RentAction> GetRentActionQueue(out JobHandle deps)
Returns the internal rent-action queue so other systems/jobs can enqueue RentAction items. Also returns a JobHandle (deps) representing writer dependencies; callers must satisfy job ordering. Asserts the system is enabled. -
public void AddWriter(JobHandle writer)
Combine an external Writer JobHandle into the system's internal m_Writers dependency so the system knows to wait for writers before processing the queue. -
protected override void OnDestroy()
Disposes NativeQueue and NativeList (m_RentActionQueue, m_ReservedProperties) and runs base cleanup. -
protected override void OnUpdate()
Main scheduling function: - If there are properties to process, schedules the PutPropertyOnMarketJob in parallel. That job:
- Evaluates each property with PropertyToBeOnMarket and determines whether to create a company entity (commercial/industrial) to rent the property; if none, toggles PropertyOnMarket component with asking rent calculated from economy params, land value, building level/lot size, area type.
- Schedules PropertyRentJob (IJob) to dequeue and process pending RentAction items:
- Validates renters and properties, checks capacity and company constraints, moves renters between properties, updates Renter buffers, updates PropertyRenter components and PropertyOnMarket state, enqueues triggers and statistics, updates WorkProvider capacity and homeless household handling, creates RentersUpdated and PathTargetMoved events as required.
-
Manages job dependencies and registers writers with EndFrameBarrier, TriggerSystem and CityStatisticsSystem.
-
PutPropertyOnMarketJob.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
IJobChunk worker that processes chunks of properties flagged to be placed on market. Matches allowed sold/manufactured resources to company prefabs and creates company-prefab entities to rent properties, or toggles PropertyOnMarket with a computed asking rent. -
PropertyRentJob.Execute()
IJob that processes the m_RentActionQueue by dequeuing RentAction items and performing the full renting logic described above. It updates renters, reserved properties, triggers, events and command buffers. -
private void __AssignQueries(ref SystemState state)
Compiler helper used to assign and prepare any generated queries (empty in this decompiled form but called during OnCreateForCompiler). -
protected override void OnCreateForCompiler()
Compiler-time initialization: assigns queries and populates __TypeHandle with component lookups used by jobs.
Usage Example
// Example: enqueue a rent request from another system/job
// Assume 'propertyProcessingSystem' is a reference to this system and
// 'renterEntity' and 'propertyEntity' are valid entities.
JobHandle writerDeps;
var rentQueue = propertyProcessingSystem.GetRentActionQueue(out writerDeps);
// If doing this from jobs, you must ensure to add the writer dependency:
// propertyProcessingSystem.AddWriter(jobHandleOfYourWriter);
rentQueue.Enqueue(new RentAction {
m_Renter = renterEntity,
m_Property = propertyEntity
});
// The PropertyProcessingSystem will process the queued RentAction items in its OnUpdate.
Notes and tips for modders: - Use GetRentActionQueue/AddWriter when enqueuing rent actions from jobs to ensure correct job dependency tracking. - The system uses EndFrameBarrier command buffers; structural changes (Add/RemoveComponent, CreateEntity) are deferred through that barrier. - If you need to intercept renting behavior, you can watch for RentersUpdated and PathTargetMoved events or add/remove PropertyOnMarket/PropertyToBeOnMarket components.