[−][src]Struct swarm_it::Carrier
Represnets the Carrier
object. Carrier is an entity that moves from slot to slot and
transfers payload in order to reach the desired layout.
Methods
impl<T: PartialEq + Eq + Hash + Copy> Carrier<T>
[src]
pub fn new(x: f64, y: f64) -> Carrier<T>
[src]
Creates new Carrier at the position specified
Example
let carrier = swarm_it::Carrier::<char>::new(100.0, 100.0);
pub fn get_payload(&self) -> Option<Payload<T>>
[src]
Returns current payload of the carrier
Example
let carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); let payload = carrier.get_payload(); assert_eq!(payload, None);
pub fn get_target(&self) -> Option<usize>
[src]
Returns index of the slot that carriers is going to
Example
let carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); let target = carrier.get_target(); assert_eq!(target, None)
pub fn get_reserved_target(&self) -> Option<usize>
[src]
Returns index of the slot that is reserverd as a target for the cargo that the carrier is going to pick-up or is currently transferring.
Example
let carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); let target = carrier.get_reserved_target(); assert_eq!(target, None)
pub fn get_position(&self) -> &Position
[src]
Returns current carrier position
Example
let x = 100.0; let y = 200.0; let carrier = swarm_it::Carrier::<char>::new(x, y); let position = carrier.get_position(); approx::assert_abs_diff_eq!(position.x, x); approx::assert_abs_diff_eq!(position.y, y);
pub fn get_angle(&self) -> f64
[src]
Returns current carrier angle.
Direction | Angle |
---|---|
Right | 0 / 2*π |
Down | π/2 |
Left | π |
Up | ³/₂*π |
Example
let carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); approx::assert_abs_diff_eq!(carrier.get_angle(), 0.0);
pub fn get_state(&self) -> State
[src]
Returns current carrier state
Example
let carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); assert_eq!(carrier.get_state(), swarm_it::State::IDLE);
pub fn set_acceleration(&mut self, acceleration: f64)
[src]
Sets carrier acceleration. This doesn't affect the current movement of a carrier, since this is controlled by the engine. It sets the carrier's ability to accelerate.
Example
let mut carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); carrier.set_acceleration(2.71); approx::assert_abs_diff_eq!(carrier.get_acceleration(), 2.71);
pub fn get_acceleration(&self) -> f64
[src]
Gets carrier acceleration. This doesn't return the current acceleration, but the number that defines the carrier's ability to accelerate.
Example
let mut carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); carrier.set_acceleration(2.71); approx::assert_abs_diff_eq!(carrier.get_acceleration(), 2.71);
pub fn set_max_speed(&mut self, max_speed: f64)
[src]
Sets maximum speed of a carrier.
Example
let mut carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); carrier.set_max_speed(3.01); approx::assert_abs_diff_eq!(carrier.get_max_speed(), 3.01);
pub fn get_max_speed(&self) -> f64
[src]
Returns maximum speed of a carrier.
Example
let mut carrier = swarm_it::Carrier::<char>::new(100.0, 100.0); carrier.set_max_speed(3.01); approx::assert_abs_diff_eq!(carrier.get_max_speed(), 3.01);
Trait Implementations
impl<T: Clone + PartialEq + Eq + Hash + Copy> Clone for Carrier<T>
[src]
fn clone(&self) -> Carrier<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Copy + PartialEq + Eq + Hash> Copy for Carrier<T>
[src]
Auto Trait Implementations
impl<T> Sync for Carrier<T> where
T: Sync,
T: Sync,
impl<T> Send for Carrier<T> where
T: Send,
T: Send,
impl<T> Unpin for Carrier<T> where
T: Unpin,
T: Unpin,
impl<T> RefUnwindSafe for Carrier<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> UnwindSafe for Carrier<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,