-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get handle to spawned entity through commands
- Loading branch information
1 parent
46494c1
commit 8c5d283
Showing
6 changed files
with
83 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::World; | ||
|
||
use super::Command; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct CommandBuffer { | ||
commands: Vec<Command>, | ||
} | ||
|
||
impl CommandBuffer { | ||
pub fn new() -> Self { | ||
CommandBuffer { | ||
commands: Vec::new(), | ||
} | ||
} | ||
|
||
pub fn add(&mut self, command: Command) { | ||
self.commands.push(command); | ||
} | ||
|
||
/// Executes all commands on the `World` and clears the command buffer. | ||
pub fn apply(&mut self, world: &mut World) { | ||
for command in self.commands.drain(..) { | ||
command.execute(world); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters