|
|
|
@ -24,7 +24,7 @@ pub struct State {
|
|
|
|
|
loaded_chunks: Box<HashMap<(i32, i32), Chunk>>, |
|
|
|
|
world_pos: (i32, i32), |
|
|
|
|
seed: u64, |
|
|
|
|
// @cleanup: Move to player struct
|
|
|
|
|
// CLEANUP: Move to player struct
|
|
|
|
|
player_inventory: InventoryView, |
|
|
|
|
player_position: usize, |
|
|
|
|
selected_object: Option<TileType>, |
|
|
|
@ -153,7 +153,7 @@ impl GameState for State {
|
|
|
|
|
None => {} // Nothing happened
|
|
|
|
|
Some(key) => { |
|
|
|
|
// A key is pressed or held
|
|
|
|
|
// @cleanup: Move to update trait
|
|
|
|
|
// CLEANUP: Move to update trait
|
|
|
|
|
match self.mode { |
|
|
|
|
DisplayMode::Game => { |
|
|
|
|
match key { |
|
|
|
@ -180,7 +180,7 @@ impl GameState for State {
|
|
|
|
|
// Views
|
|
|
|
|
VirtualKeyCode::I => { |
|
|
|
|
self.mode = DisplayMode::Inventory; |
|
|
|
|
// @cleanup: This really isn't the right place to reset the inventory view. Also: Cloning!
|
|
|
|
|
// CLEANUP: This really isn't the right place to reset the inventory view. Also: Cloning!
|
|
|
|
|
self.player_inventory = |
|
|
|
|
InventoryView::new(self.player_inventory.inv.clone()) |
|
|
|
|
} |
|
|
|
@ -210,7 +210,7 @@ impl GameState for State {
|
|
|
|
|
self.select_object(Point::from(mouse_pos)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// @cleanup: We shouldn't be cloning the state on each frame
|
|
|
|
|
// CLEANUP: We shouldn't be cloning the state on each frame
|
|
|
|
|
match self.mode { |
|
|
|
|
DisplayMode::Game => self.view.render(&mut self.clone(), ctx), |
|
|
|
|
DisplayMode::Inventory => self.player_inventory.render(&mut self.clone(), ctx), |
|
|
|
|