[][src]Struct myelin_engine::prelude::ObjectBuilder

pub struct ObjectBuilder { /* fields omitted */ }

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.

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 ObjectBuilder[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: Vec<u8>) -> &mut Self[src]

Examples

use myelin_engine::prelude::*;

let builder = ObjectBuilder::default().associated_data(String::from("Foo").into_bytes());

pub fn build(&mut self) -> Result<ObjectDescription, 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 Default for ObjectBuilder[src]

impl From<ObjectDescription> for ObjectBuilder[src]

impl Debug for ObjectBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>, 
[src]

impl<T> Downcast for T where
    T: Any