For easier editing of Blueprint
s it’s useful to be able to copy and paste Structure
s.
For this to work I introduced:
cursor_item: Option<Structure>
to track what’s currently within the ‘clipboard’.
I also extended every Structure
with the function
as_template(&self) -> Self
which should return whatever makes sense for the copy and paste operation.
For example the content and current cooldown shouldn’t be copied, while an Assembler
‘s Recipe
should be.
For the Assembler
the implementation then looks like this:
pub fn as_template(&self) -> Self {
Self {
recipe: self.recipe,
..Default::default()
}
}
If the cursor_item
is set, I render a Structure
with a slight transparency at the cursor location.
The copy&paste then looks like this: