pub struct ToolInput<'ticket> {
pub read_ticket: ReadTicket<'ticket>,
pub cursor: Option<Cursor>,
pub character: Option<Handle<Character>>,
}Expand description
Resources available to a Tool to perform its function.
This is intended to provide future extensibility compared to having a complex
parameter list for Tool::use_tool.
Fields§
§read_ticket: ReadTicket<'ticket>Access to the universe being operated on.
cursor: Option<Cursor>Cursor identifying block(s) to act on. If None then the tool was used while
pointing at nothing or by an agent without an ability to aim.
character: Option<Handle<Character>>Character that is using the tool.
TODO: We want to be able to express “inventory host”, not just specifically Character (but there aren’t any other examples).
Implementations§
Source§impl<'ticket> ToolInput<'ticket>
impl<'ticket> ToolInput<'ticket>
Sourcepub fn cursor(&self) -> Result<&Cursor, ToolError>
pub fn cursor(&self) -> Result<&Cursor, ToolError>
Returns a Cursor indicating what blocks the tool should act on, if it is
a sort of tool that acts on blocks. If there is no Cursor, because of aim
or because of being used in a context where there cannot be any aiming, returns
Err(ToolError::NothingSelected) for convenient
propagation.
Sourcepub fn produce_items<S: Into<Slot>, I: IntoIterator<Item = S>>(
&self,
items: I,
) -> Result<UniverseTransaction, ToolError>
pub fn produce_items<S: Into<Slot>, I: IntoIterator<Item = S>>( &self, items: I, ) -> Result<UniverseTransaction, ToolError>
Add the provided items to the inventory from which the tool was used.
Trait Implementations§
Auto Trait Implementations§
impl<'ticket> Freeze for ToolInput<'ticket>
impl<'ticket> !RefUnwindSafe for ToolInput<'ticket>
impl<'ticket> Send for ToolInput<'ticket>
impl<'ticket> Sync for ToolInput<'ticket>
impl<'ticket> Unpin for ToolInput<'ticket>
impl<'ticket> !UnwindSafe for ToolInput<'ticket>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more