Skip to content

Job system

Folder structure

Path Contents
jobs/base/ AbstractJob, AbstractJobOrderJob
jobs/need/ NeedFullfilmentJob, SleepJob, DrinkJob
jobs/order/ ChopJob, MineJob
jobs/haul/ HaulJob
JobQueue.ts, Job.ts, index.ts Queue, deprecated Job type, re-exports

Flow

  1. Pending jobs – created by orders (chop, mine, area selection), haul creator, need scheduler
  2. Assignment – JobAssigner scores free colonists, assigns best match, sets path
  3. Movement – JobMovement ticks: colonists step along path; step time = MOVE_INTERVAL_MS / speedFactor
  4. Work – JobWorkExecution: chop/mine via ActionExecutor (async); drink/sleep via tick
  5. Completion – remove job, update state, onJobComplete (e.g. haul from gather)
  6. Cancel – user can cancel the current job from the citizen panel (Jobs tab). JobSystem.cancelJob(jobId) removes the job and clears its path; colonist's currentJobId is cleared. All job types (including drink and sleep) are cancellable.
  7. Force need jobs – "Go drink" / "Go sleep" in the Needs tab cancel any current job, then add a DrinkJob or SleepJob for that colonist. JobAssigner assigns need jobs in the queue even when DEBUG_HAUL_ONLY is set.

Job types

Type Target Dest Created by
ChopJob tree Area selection, order click
MineJob stone_chunk Area selection, order click
HaulJob wood_log/stone_brick storage zone HaulJobCreator (after gather, orphan scan)
DrinkJob water-adjacent tile NeedJobScheduler (event-driven)
SleepJob sleeping zone or current tile NeedJobScheduler (event-driven)

XP and skills

  • Chop → Woodworking; Mine → Mining
  • XP = 1 per 0.1s (actual elapsed time from start to completion)
  • Level-up when total XP ≥ threshold for next level