mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/data/schematic.rs')
-rw-r--r--src/data/schematic.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/data/schematic.rs b/src/data/schematic.rs
index ea0d335..0b9f9a0 100644
--- a/src/data/schematic.rs
+++ b/src/data/schematic.rs
@@ -12,6 +12,7 @@ use crate::block::{self, Block, BlockRegistry, Rotation};
use crate::data::{self, DataRead, DataWrite, GridPos, Serializer};
use crate::data::base64;
use crate::data::dynamic::{self, DynData, DynSerializer};
+use crate::item::storage::Storage as ItemStorage;
use crate::registry::RegistryEntry;
pub const MAX_DIMENSION: u16 = 128;
@@ -434,6 +435,21 @@ impl<'l> Schematic<'l>
{
self.blocks.iter()
}
+
+ pub fn compute_total_cost(&self) -> (ItemStorage, bool)
+ {
+ let mut cost = ItemStorage::new();
+ let mut sandbox = false;
+ for &Placement{block, ..} in self.blocks.iter()
+ {
+ if let Some(curr) = block.get_build_cost()
+ {
+ cost.add_all(curr, u32::MAX);
+ }
+ else {sandbox = true;}
+ }
+ (cost, sandbox)
+ }
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]