From 9eb4d9b498f88d738e5d3f2580004338e406ea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sun, 25 Jun 2023 20:19:49 +0200 Subject: [PATCH] feat: reset animation in reset command --- src/commands/all_command.rs | 2 +- src/commands/command_data.rs | 4 ++++ src/commands/reset_command.rs | 8 +++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commands/all_command.rs b/src/commands/all_command.rs index ec4ea3f..9f7e2ef 100644 --- a/src/commands/all_command.rs +++ b/src/commands/all_command.rs @@ -8,7 +8,7 @@ pub struct AllCommand; impl SpecificCommandHandler for AllCommand { fn handle(&self, command: CommandData) -> Result<(), CommandHandleError> { - let (cmd, map) = command.deconstruct(); + let (cmd, map) = command.deconstruct_map(); if cmd.parsed_arguments().len() < 4 { println!("Less than 4 args."); diff --git a/src/commands/command_data.rs b/src/commands/command_data.rs index ce6d607..3d414a2 100644 --- a/src/commands/command_data.rs +++ b/src/commands/command_data.rs @@ -36,4 +36,8 @@ impl<'d, 'a> CommandData<'d, 'a> { pub fn deconstruct_animation(self) -> (&'d Command<'d>, &'d mut AnimationStorage) { (self.command, self.animation_storage) } + + pub fn deconstruct(self) -> (&'d Command<'d>, &'d mut Map<'a>, &'d mut AnimationStorage) { + (self.command, self.map, self.animation_storage) + } } \ No newline at end of file diff --git a/src/commands/reset_command.rs b/src/commands/reset_command.rs index 93ecbb1..024c5bd 100644 --- a/src/commands/reset_command.rs +++ b/src/commands/reset_command.rs @@ -6,11 +6,9 @@ pub struct ResetCommand; impl SpecificCommandHandler for ResetCommand { fn handle(&self, command: CommandData) -> Result<(), CommandHandleError> { - for led in command.map().get_map_mut() { - led.r = 0; - led.g = 0; - led.b = 0; - } + let (_, map, animation) = command.deconstruct(); + map.clear(); + animation.remove_animation(); Ok(()) } -- 2.48.1