Skip to content

CraftingJob ​

Inherits: RefCounted

Represents an active crafting operation with progress tracking Uses a single completion timer instead of polling for smoother performance Progress is calculated on-demand from timer.time_left when needed

Variables ​

CraftingRecipeDefinitionrecipenull
Entitycrafternull
CraftSchoolInstancecraft_school_instancenull
intquantity1
floatduration_per_item1.0
floattotal_duration1.0
boolis_activefalse
boolwas_cancelledfalse
boolis_completedfalse
intstart_time0
Timercompletion_timernull
ChronoManagerchrono_manager

Methods ​

voidstart()
voidcancel()
floatget_completion_percentage()
floatget_remaining_time()
floatget_elapsed_time()
intget_current_item_index()
floatget_current_item_progress()
intget_completed_item_count()
Dictionaryget_save_data()
voidrestore_from_save( data: Dictionary )
Stringget_time_remaining_formatted()
Dictionaryget_job_summary()

Signals ​

item_completed( item_index: int, total_items: int ) ​

========== SIGNALS ==========

job_completed() ​

Emitted when the crafting is done.

job_cancelled() ​

Emitted when the crafting is cancelled.

Variable descriptions ​

CraftingRecipeDefinition recipe = null ​

The recipe being crafted

Entity crafter = null ​

The entity doing the crafting

CraftSchoolInstance craft_school_instance = null ​

The craft school instance handling this job

int quantity = 1 ​

How many items are being crafted

float duration_per_item = 1.0 ​

Time per individual item

float total_duration = 1.0 ​

Total time for the entire job

bool is_active = false ​

Whether this job is currently active

bool was_cancelled = false ​

Whether this job was cancelled

bool is_completed = false ​

Whether this job completed successfully

int start_time = 0 ​

When the job started (using Time.get_ticks_msec())

Timer completion_timer = null ​

Single completion timer from ChronoManager pool

ChronoManager chrono_manager ​

ChronoManager system ref

Method descriptions ​

void start() ​

Start the crafting job

void cancel() ​

Cancel the crafting job

float get_completion_percentage() ​

Get completion percentage (0.0 to 1.0)

float get_remaining_time() ​

Get remaining time in seconds

float get_elapsed_time() ​

Get elapsed time in seconds

int get_current_item_index() ​

Get current item being worked on (1-indexed)

float get_current_item_progress() ​

Get progress on current item (0.0 to 1.0)

int get_completed_item_count() ​

Get how many items have been completed so far

Dictionary get_save_data() ​

Get data for saving the job state

void restore_from_save( data: Dictionary ) ​

Restore job from saved data

String get_time_remaining_formatted() ​

Get formatted time remaining string

Dictionary get_job_summary() ​

Get job summary for UI display