adding extend_plan and set_speed

This commit is contained in:
Dietrich 2022-12-13 11:31:29 +01:00
parent f5aae7efe1
commit 7bdc83c760
3 changed files with 15 additions and 3 deletions

View File

@ -10,7 +10,7 @@ use crate::{
},
TurtleGraphElement,
},
general::{angle::Angle, length::Length, Coordinate, Precision},
general::{angle::Angle, length::Length, Coordinate, Precision, Speed},
state::TurtleState,
};
/**
@ -146,6 +146,12 @@ impl TurtleCommands {
pub fn push(&mut self, segment: TurtleSegment) {
self.commands.push(segment)
}
pub fn extend(&mut self, segments: Vec<TurtleSegment>) {
self.commands.extend(segments.into_iter())
}
pub fn set_speed(&mut self, speed: Speed) {
self.state.set_speed(speed);
}
}
impl Iterator for TurtleCommands {

View File

@ -21,7 +21,7 @@ pub mod events;
mod general;
pub mod shapes;
mod state;
mod turtle_bundle;
pub mod turtle_bundle;
/**
The turtle plugin is the core of this turtle module.

View File

@ -9,7 +9,7 @@ use bevy_prototype_lyon::{
use crate::{
builders::{TurtlePlan, WithCommands},
commands::{DrawElement, MoveCommand, TurtleCommands, TurtleSegment},
general::length::Length,
general::{length::Length, Speed},
shapes::{self, TurtleColors},
};
@ -43,6 +43,9 @@ impl TurtleBundle {
pub fn apply_plan(&mut self, plan: TurtlePlan) {
self.commands = TurtleCommands::new(plan.get_commands());
}
pub fn extend_plan(&mut self, plan: TurtlePlan) {
self.commands.extend(plan.get_commands())
}
pub fn create_plan(&self) -> TurtlePlan {
TurtlePlan::new()
}
@ -55,6 +58,9 @@ impl TurtleBundle {
)));
self
}
pub fn set_speed(&mut self, speed: Speed) {
self.commands.set_speed(speed);
}
}
#[derive(Bundle)]