[−][src]Struct myelin_engine::object_builder::ObjectBuilder
ObjectDescription factory, which can be used in order to configure
the properties of a new object.
Methods can be chained on it in order to configure it.
If associated_data is never called and T implements Default, then
the default value is used. Otherwise build will return an error.
Examples
use myelin_engine::prelude::*; use std::f64::consts::FRAC_PI_2; let object = ObjectBuilder::<()>::default() .shape( PolygonBuilder::default() .vertex(-50.0, -50.0) .vertex(50.0, -50.0) .vertex(50.0, 50.0) .vertex(-50.0, 50.0) .build() .unwrap(), ) .location(300.0, 450.0) .rotation(Radians::try_new(FRAC_PI_2).unwrap()) .mobility(Mobility::Movable(Vector { x: 3.0, y: 5.0 })) .build() .unwrap();
Methods
impl<T> ObjectBuilder<T>[src]
pub fn shape(&mut self, polygon: Polygon) -> &mut Self[src]
Examples
use myelin_engine::prelude::*; ObjectBuilder::<()>::default().shape( PolygonBuilder::default() .vertex(-50.0, -50.0) .vertex(50.0, -50.0) .vertex(50.0, 50.0) .vertex(-50.0, 50.0) .build() .unwrap(), );
pub fn location(&mut self, x: f64, y: f64) -> &mut Self[src]
Examples
use myelin_engine::prelude::*; ObjectBuilder::<()>::default().location(3.0, 2.0);
pub fn mobility(&mut self, mobility: Mobility) -> &mut Self[src]
Examples
use myelin_engine::prelude::*; ObjectBuilder::<()>::default().mobility(Mobility::Movable(Vector { x: -12.0, y: 4.0 }));
pub fn rotation(&mut self, rotation: Radians) -> &mut Self[src]
Examples
use myelin_engine::prelude::*; ObjectBuilder::<()>::default().rotation(Radians::try_new(4.5).unwrap());
pub fn passable(&mut self, passable: bool) -> &mut Self[src]
Examples
use myelin_engine::prelude::*; let builder = ObjectBuilder::<()>::default();
pub fn associated_data(&mut self, associated_data: T) -> &mut Self[src]
Examples
use myelin_engine::prelude::*; let builder = ObjectBuilder::<String>::default().associated_data(String::from("Foo"));
pub fn build(&mut self) -> Result<ObjectDescription<T>, ObjectBuilderError>[src]
Build the ObjectDescription with all specified settings
Errors
If a non-optional member has not specified while building an error is returned, containing flags specifying which setting has been omitted
Examples
use myelin_engine::prelude::*; use std::f64::consts::FRAC_PI_2; let object = ObjectBuilder::<()>::default() .shape( PolygonBuilder::default() .vertex(-50.0, -50.0) .vertex(50.0, -50.0) .vertex(50.0, 50.0) .vertex(-50.0, 50.0) .build() .unwrap(), ) .location(300.0, 450.0) .rotation(Radians::try_new(FRAC_PI_2).unwrap()) .mobility(Mobility::Movable(Vector { x: 3.0, y: 5.0 })) .build() .unwrap();
Trait Implementations
impl<T> From<ObjectDescription<T>> for ObjectBuilder<T>[src]
fn from(object_description: ObjectDescription<T>) -> Self[src]
impl<T> Default for ObjectBuilder<T>[src]
impl<T: Debug> Debug for ObjectBuilder<T>[src]
Auto Trait Implementations
impl<T> Send for ObjectBuilder<T> where
T: Send,
T: Send,
impl<T> Sync for ObjectBuilder<T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
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<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>, [src]
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>[src]
fn is_in_subset(&self) -> bool[src]
unsafe fn to_subset_unchecked(&self) -> SS[src]
fn from_subset(element: &SS) -> SP[src]
impl<T> Downcast for T where
T: Any,
T: Any,