pub struct WorkerRouteEditorState {
pub worker_instance_id: String,
pub worker_label: String,
pub lodging_container_id: Option<String>,
pub stops: Vec<WorkerRouteStop>,
pub selected_stop_index: usize,
pub carry_return_ratio: f32,
pub sheet: RouteEditorSheet,
pub editing_index: Option<usize>,
pub panel_collapsed: bool,
}Expand description
Draft route for a hired worker. stops is the ordered, editable list;
lodging_container_id is the bed used for RestIfNeeded.
Fields§
§worker_instance_id: String§worker_label: String§lodging_container_id: Option<String>§stops: Vec<WorkerRouteStop>Ordered, player-authored stops. May be empty until the player adds some.
selected_stop_index: usizeSelected stop index for reorder / delete operations.
carry_return_ratio: f32Carry threshold passed to each HarvestNode stop’s compiled HarvestRoute.
sheet: RouteEditorSheetActive sheet (sub-screen). Stops is the root.
editing_index: Option<usize>When set, confirming a sheet replaces this stop instead of appending (Enter on a stop = edit it in place).
panel_collapsed: boolWhen true, only a thin bar is drawn so the map stays visible for clicks.
Implementations§
Source§impl WorkerRouteEditorState
impl WorkerRouteEditorState
pub fn new( worker_instance_id: String, worker_label: String, lodging_container_id: Option<String>, ) -> Self
pub fn toggle_panel_collapsed(&mut self)
pub fn from_saved_route( worker_instance_id: String, worker_label: String, route: &WorkerRouteView, lodging_fallback: Option<String>, ) -> Self
pub fn stop_count(&self) -> usize
pub fn select_stop(&mut self, index: usize)
pub fn move_selected_up(&mut self)
pub fn move_selected_down(&mut self)
pub fn remove_selected_stop(&mut self)
pub fn harvest_node_index(&self, node_id: &str) -> Option<usize>
pub fn deposit_container_index(&self, container_id: &str) -> Option<usize>
pub fn trade_stop_index( &self, npc_id: Option<&str>, template: &str, ) -> Option<usize>
Sourcepub fn insert_stop(&mut self, stop: WorkerRouteStop) -> (bool, usize)
pub fn insert_stop(&mut self, stop: WorkerRouteStop) -> (bool, usize)
Insert a stop, deduping targets that must not repeat (harvest nodes, deposit containers, identical sell stops): a duplicate selects the existing stop instead of appending. Returns (appended, index).
pub fn append_waypoint(&mut self, x: f32, y: f32, z: f32)
pub fn append_harvest_node(&mut self, node_id: &str) -> bool
pub fn append_deposit_at(&mut self, container_id: &str) -> bool
Sourcepub fn append_deposit_at_filtered(
&mut self,
container_id: &str,
filter_templates: Vec<String>,
)
pub fn append_deposit_at_filtered( &mut self, container_id: &str, filter_templates: Vec<String>, )
Append a filtered deposit (deposit only filter_templates, keep everything else —
e.g. keep the worker’s handsaw while depositing lumber).
pub fn append_rest_if_needed(&mut self)
pub fn append_wait(&mut self, wait_ticks: u64)
Sourcepub fn append_trade_with(
&mut self,
template: String,
npc_id: Option<String>,
sell_all: bool,
) -> bool
pub fn append_trade_with( &mut self, template: String, npc_id: Option<String>, sell_all: bool, ) -> bool
Append a TradeWith stop — sell template (whole stack) to npc_id
(None = auto-pick the nearest NPC that buys it). An identical sell
stop (same merchant + template) is selected instead of duplicated.
Sourcepub fn set_selected_trade_npc(&mut self, npc_id: String) -> bool
pub fn set_selected_trade_npc(&mut self, npc_id: String) -> bool
Pin the selected stop’s NPC when the player clicks a merchant on the map.
Only affects TradeWith stops; returns true if a stop was updated.
If pinning would duplicate another sell stop (same merchant + template),
the selected stop is removed and the existing one is selected instead.
Sourcepub fn set_selected_withdraw_container(&mut self, container_id: String) -> bool
pub fn set_selected_withdraw_container(&mut self, container_id: String) -> bool
Retarget the selected stop’s source container when the player clicks a
chest on the map. Only affects WithdrawFrom stops; returns true if a
stop was updated.
Sourcepub fn retarget_withdraw_container(&mut self, container_id: String) -> bool
pub fn retarget_withdraw_container(&mut self, container_id: String) -> bool
Retarget the stop currently being edited (or selected) to a new withdraw
chest. Prefer editing_index when set.
Sourcepub fn retarget_deposit_container(&mut self, container_id: String) -> bool
pub fn retarget_deposit_container(&mut self, container_id: String) -> bool
Retarget the stop currently being edited (or selected) to a new deposit
chest. Prefer editing_index when set.
pub fn open_sheet(&mut self, sheet: RouteEditorSheet)
Sourcepub fn begin_edit_selected(&mut self)
pub fn begin_edit_selected(&mut self)
Mark the selected stop as being edited; the next confirm_stop replaces
it in place. Caller then opens the matching sheet (prefilled).
Sourcepub fn sheet_back(&mut self)
pub fn sheet_back(&mut self)
Esc pops one sheet level. When editing, Esc from an items/filter sheet
returns to the container picker (still editing); Esc from the picker
cancels the edit. Root (Stops) is a no-op — the caller closes the editor.
Sourcepub fn confirm_stop(&mut self, stop: WorkerRouteStop) -> bool
pub fn confirm_stop(&mut self, stop: WorkerRouteStop) -> bool
Confirm the current sheet’s stop: replace the edited stop in place, or append (deduped). Returns true when a stop was appended/replaced and false when a duplicate selected the existing stop instead.
Sourcepub fn withdraw_line_drafts(
contents: &[ItemStack],
existing: &[WorkerRouteWithdrawItem],
) -> Vec<WithdrawLineDraft>
pub fn withdraw_line_drafts( contents: &[ItemStack], existing: &[WorkerRouteWithdrawItem], ) -> Vec<WithdrawLineDraft>
Build withdraw line drafts for container_id from its contents.
existing pre-fills modes (editing an existing stop); templates no
longer present are kept with available: 0.
Sourcepub fn withdraw_items_from_lines(
lines: &[WithdrawLineDraft],
) -> Vec<WorkerRouteWithdrawItem>
pub fn withdraw_items_from_lines( lines: &[WithdrawLineDraft], ) -> Vec<WorkerRouteWithdrawItem>
Collect the active withdraw lines into stop items (None = all).
Sourcepub fn build_idle_job_yaml(&self) -> String
pub fn build_idle_job_yaml(&self) -> String
YAML that parks the worker: mode: idle with no steps. Saving an empty
route means “stand down” rather than leaving the worker in a broken
job loop.
pub fn build_job_yaml(&self) -> Result<String, String>
Sourcepub fn to_route_view(&self) -> WorkerRouteView
pub fn to_route_view(&self) -> WorkerRouteView
Build a protocol route view matching the current draft (for optimistic client UI).
Trait Implementations§
Source§impl Clone for WorkerRouteEditorState
impl Clone for WorkerRouteEditorState
Source§fn clone(&self) -> WorkerRouteEditorState
fn clone(&self) -> WorkerRouteEditorState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more