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: 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)>
Implementations
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.
Mark that an object is hoverable, but don’t actually draw anything while hovering on it
Mark the object as clickable. WorldOutcome::ClickedObject
will be fired.
Mark the object as clickable or not. 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.
Auto Trait Implementations
impl<'a, ID> RefUnwindSafe for ObjectBuilder<'a, ID> where
ID: RefUnwindSafe,
impl<'a, ID> !Send for ObjectBuilder<'a, ID>
impl<'a, ID> !Sync for ObjectBuilder<'a, ID>
impl<'a, ID> Unpin for ObjectBuilder<'a, ID> where
ID: Unpin,
impl<'a, ID> !UnwindSafe for ObjectBuilder<'a, ID>
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
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
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self