Epic labeled break

This commit is contained in:
crumblingstatue 2023-04-15 23:05:56 +02:00
parent 464d8dc8be
commit 0cb1f9017e

View file

@ -17,7 +17,7 @@ use crate::{
game::{for_each_tile_on_screen, Biome, GameState}, game::{for_each_tile_on_screen, Biome, GameState},
graphics::{self, ScreenSc, ScreenVec}, graphics::{self, ScreenSc, ScreenVec},
input::Input, input::Input,
inventory::TileLayer, inventory::{TileLayer, UseAction},
math::{center_offset, TILE_SIZE}, math::{center_offset, TILE_SIZE},
res::Res, res::Res,
CliArgs, CliArgs,
@ -231,23 +231,30 @@ impl App {
self.game.world.player.col_en.en.pos.x = wpos.x as i32; self.game.world.player.col_en.en.pos.x = wpos.x as i32;
self.game.world.player.col_en.en.pos.y = wpos.y as i32; self.game.world.player.col_en.en.pos.y = wpos.y as i32;
} }
if self.input.lmb_down { 'item_use: {
let active_slot = &self.game.inventory.slots[self.game.selected_inv_slot]; if !self.input.lmb_down {
if active_slot.qty != 0 { break 'item_use;
let def = &self.game.itemdb.db[active_slot.id as usize]; }
let t = self.game.world.tile_at_mut(mouse_tpos, &self.game.worldgen); let Some(active_slot) = self.game.inventory.slots.get(self.game.selected_inv_slot) else {
match &def.use_action { log::error!("Selected slot {} out of bounds", self.game.selected_inv_slot);
crate::inventory::UseAction::PlaceTile { layer, id } => match layer { break 'item_use;
TileLayer::Bg => t.bg = *id, };
TileLayer::Mid => t.mid = *id, if active_slot.qty == 0 {
TileLayer::Fg => t.fg = *id, break 'item_use;
}, }
crate::inventory::UseAction::RemoveTile { layer } => match layer { let def = &self.game.itemdb.db[active_slot.id as usize];
TileLayer::Bg => t.bg = 0, let t = self.game.world.tile_at_mut(mouse_tpos, &self.game.worldgen);
TileLayer::Mid => t.mid = 0, match &def.use_action {
TileLayer::Fg => t.fg = 0, UseAction::PlaceTile { layer, id } => match layer {
}, TileLayer::Bg => t.bg = *id,
} TileLayer::Mid => t.mid = *id,
TileLayer::Fg => t.fg = *id,
},
UseAction::RemoveTile { layer } => match layer {
TileLayer::Bg => t.bg = 0,
TileLayer::Mid => t.mid = 0,
TileLayer::Fg => t.fg = 0,
},
} }
} }
if self.game.camera_offset.y > 643_000 { if self.game.camera_offset.y > 643_000 {