Skip to main content

WorkerRouteEditorState

Struct WorkerRouteEditorState 

Source
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: usize

Selected stop index for reorder / delete operations.

§carry_return_ratio: f32

Carry threshold passed to each HarvestNode stop’s compiled HarvestRoute.

§sheet: RouteEditorSheet

Active 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: bool

When true, only a thin bar is drawn so the map stays visible for clicks.

Implementations§

Source§

impl WorkerRouteEditorState

Source

pub fn new( worker_instance_id: String, worker_label: String, lodging_container_id: Option<String>, ) -> Self

Source

pub fn toggle_panel_collapsed(&mut self)

Source

pub fn from_saved_route( worker_instance_id: String, worker_label: String, route: &WorkerRouteView, lodging_fallback: Option<String>, ) -> Self

Source

pub fn stop_count(&self) -> usize

Source

pub fn select_stop(&mut self, index: usize)

Source

pub fn move_selected_up(&mut self)

Source

pub fn move_selected_down(&mut self)

Source

pub fn remove_selected_stop(&mut self)

Source

pub fn harvest_node_index(&self, node_id: &str) -> Option<usize>

Source

pub fn deposit_container_index(&self, container_id: &str) -> Option<usize>

Source

pub fn trade_stop_index( &self, npc_id: Option<&str>, template: &str, ) -> Option<usize>

Source

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).

Source

pub fn append_waypoint(&mut self, x: f32, y: f32, z: f32)

Source

pub fn append_harvest_node(&mut self, node_id: &str) -> bool

Source

pub fn append_deposit_at(&mut self, container_id: &str) -> bool

Source

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).

Source

pub fn append_rest_if_needed(&mut self)

Source

pub fn append_wait(&mut self, wait_ticks: u64)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn open_add_menu(&mut self)

Source

pub fn open_sheet(&mut self, sheet: RouteEditorSheet)

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn withdraw_items_from_lines( lines: &[WithdrawLineDraft], ) -> Vec<WorkerRouteWithdrawItem>

Collect the active withdraw lines into stop items (None = all).

Source

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.

Source

pub fn build_job_yaml(&self) -> Result<String, String>

Source

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

Source§

fn clone(&self) -> WorkerRouteEditorState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkerRouteEditorState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more