Struct widgetry::mapspace::world::ObjectBuilder[][src]

pub struct ObjectBuilder<'a, ID: ObjectID> {
    world: &'a mut World<ID>,
    id: ID,
    hitbox: Option<Polygon>,
    zorder: usize,
    draw_normal: Option<ToggleZoomedBuilder>,
    draw_hover: Option<ToggleZoomedBuilder>,
    tooltip: Option<Text>,
    clickable: bool,
    draggable: bool,
    keybindings: Vec<(MultiKey, &'static str)>,
}
Expand description

This provides a builder API for adding objects to a World.

Fields

world: &'a mut World<ID>id: IDhitbox: Option<Polygon>zorder: usizedraw_normal: Option<ToggleZoomedBuilder>draw_hover: Option<ToggleZoomedBuilder>tooltip: Option<Text>clickable: booldraggable: boolkeybindings: Vec<(MultiKey, &'static str)>

Implementations

Specifies the geometry of the object. Required.

Provides ordering for overlapping objects. Higher values are “on top” of lower values.

Specifies how to draw this object normally (while not hovering on it)

Draw the object by coloring its hitbox

Indicate that an object doesn’t need to be drawn individually. A call to draw_master_batch covers it.

Specifies how to draw the object while the cursor is hovering on it. Note that an object isn’t considered hoverable unless this is specified!

Draw the object in a hovered state by transforming the normal drawing.

Draw the object in a hovered state by changing the alpha value of the normal drawing.

Draw the object in a hovered state by adding an outline to the normal drawing. The specified color and thickness will be used when unzoomed. For the zoomed view, the color’s opacity and the thickness will be halved.

Draw a tooltip while hovering over this object.

Mark the object as clickable. WorldOutcome::ClickedObject will be fired.

Mark the object as draggable. The user can hover on this object, then click and drag it. WorldOutcome::Dragging events will be fired.

Note that dragging an object doesn’t transform it at all (for example, by translating its hitbox). The caller is responsible for doing that.

While the user hovers over this object, they can press a key to perform the specified action. WorldOutcome::Keypress will be fired.

Finalize the object, adding it to the World.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.