Skip to main content

Module jobs

Module jobs 

Source
Expand description

The job manager (Game). See docs/JOBS.md.

Every Work gets a sequential id (from 1) and a priority (sequential unless the owner keeps one). The manager indexes works by id, by priority, by category (+ (c − 1)·0x10, categories 1..14 from the registration mask’s bits) and by profession (the work’s slot). All of them are trees keyed by id, so iteration is in id order.

The AI’s work (9) and emergency (2) activities ask the manager for a job:

  • Jobs::assign_work: the citizen’s own profession’s works, then Jobs::assign_emergency, then the laborers’ works;
  • Jobs::assign_emergency: category lists chosen from low stock (Rand(n) on the game stream), each tried by distance;
  • try_list sorts candidate works by priority or path rank, ties by id, and offer offers them in order.

A work’s virtual slots are supplied by a WorkHost: try to assign (0 no, 1 not now, 2 taken), a second try, a task completed, a task failed, cancel every worker, refresh.

Original: FUN_1400fe650, FUN_1400fcd00, FUN_1400fca20, FUN_1400fce80, FUN_1400fd4d0, FUN_1400fd160, FUN_1400fd030.

Structs§

JobEvent
A CompleteTask’s report: complete (start) or failed (abort).
Jobs
The manager.
Work
Work.

Enums§

WorkKind
The kinds of work the port has, with their own state.

Constants§

CATEGORIES
Categories 1..14 (the registration mask’s bits 1..14).
CONSTRUCTION
Construction (BuildStructure and GatherRawMaterials, mask 0x2001).
EMERGENCY
Emergency (fire) work, the only category a citizen with an emergency tries.
NESTED
A try’s answer meaning “offer these other works for me” (WorkHost::take_offers).

Traits§

WorkHost
The citizen and world queries and the work slots the manager calls.