mindustry logic execution, map- and schematic- parsing and rendering
make different block types for each module to allow different rendering
bendn 2023-06-30
parent b7d5377 · commit fa0f1b9
-rw-r--r--Cargo.toml10
-rw-r--r--assets/blocks/defense/build-tower-glow.pngbin2079 -> 0 bytes
-rw-r--r--assets/blocks/defense/radar-glow.pngbin619 -> 0 bytes
-rw-r--r--assets/blocks/defense/regen-projector-glow.pngbin8370 -> 0 bytes
-rw-r--r--assets/blocks/defense/regen-projector-mid.pngbin791 -> 0 bytes
-rw-r--r--assets/blocks/defense/shockwave-tower-heat.pngbin5535 -> 0 bytes
-rw-r--r--assets/blocks/drills/blast-drill-rim.pngbin800 -> 0 bytes
-rw-r--r--assets/blocks/drills/blast-drill-rotator.pngbin1012 -> 0 bytes
-rw-r--r--assets/blocks/drills/blast-drill-top.pngbin474 -> 0 bytes
-rw-r--r--assets/blocks/drills/blast-drill.pngbin1227 -> 1462 bytes
-rw-r--r--assets/blocks/drills/cliff-crusher-rotator-bottom.pngbin230 -> 0 bytes
-rw-r--r--assets/blocks/drills/drill-item-2.pngbin300 -> 0 bytes
-rw-r--r--assets/blocks/drills/drill-item-3.pngbin1562 -> 0 bytes
-rw-r--r--assets/blocks/drills/drill-item-4.pngbin1542 -> 0 bytes
-rw-r--r--assets/blocks/drills/eruption-drill-arrow-blur.pngbin919 -> 0 bytes
-rw-r--r--assets/blocks/drills/eruption-drill-arrow.pngbin258 -> 0 bytes
-rw-r--r--assets/blocks/drills/eruption-drill-glow.pngbin2705 -> 0 bytes
-rw-r--r--assets/blocks/drills/eruption-drill-item.pngbin685 -> 0 bytes
-rw-r--r--assets/blocks/drills/eruption-drill-top.pngbin2670 -> 0 bytes
-rw-r--r--assets/blocks/drills/eruption-drill.pngbin3917 -> 2615 bytes
-rw-r--r--assets/blocks/drills/impact-drill-arrow-blur.pngbin8471 -> 0 bytes
-rw-r--r--assets/blocks/drills/impact-drill-arrow.pngbin266 -> 0 bytes
-rw-r--r--assets/blocks/drills/impact-drill-item.pngbin712 -> 0 bytes
-rw-r--r--assets/blocks/drills/impact-drill-top-invert.pngbin1421 -> 0 bytes
-rw-r--r--assets/blocks/drills/impact-drill-top.pngbin1347 -> 0 bytes
-rw-r--r--assets/blocks/drills/impact-drill.pngbin3037 -> 2006 bytes
-rw-r--r--assets/blocks/drills/large-plasma-bore-glow.pngbin3549 -> 0 bytes
-rw-r--r--assets/blocks/drills/laser-drill-rotator.pngbin685 -> 0 bytes
-rw-r--r--assets/blocks/drills/laser-drill-top.pngbin510 -> 0 bytes
-rw-r--r--assets/blocks/drills/laser-drill.pngbin1424 -> 1064 bytes
-rw-r--r--assets/blocks/drills/mechanical-drill-rotator.pngbin347 -> 0 bytes
-rw-r--r--assets/blocks/drills/mechanical-drill-top.pngbin305 -> 0 bytes
-rw-r--r--assets/blocks/drills/mechanical-drill.pngbin438 -> 835 bytes
-rw-r--r--assets/blocks/drills/oil-extractor-liquid.pngbin478 -> 0 bytes
-rw-r--r--assets/blocks/drills/oil-extractor-rotator.pngbin903 -> 0 bytes
-rw-r--r--assets/blocks/drills/oil-extractor-top.pngbin425 -> 0 bytes
-rw-r--r--assets/blocks/drills/oil-extractor.pngbin954 -> 1219 bytes
-rw-r--r--assets/blocks/drills/plasma-bore-glow.pngbin2237 -> 0 bytes
-rw-r--r--assets/blocks/drills/pneumatic-drill-rotator.pngbin371 -> 0 bytes
-rw-r--r--assets/blocks/drills/pneumatic-drill-top.pngbin304 -> 0 bytes
-rw-r--r--assets/blocks/drills/pneumatic-drill.pngbin389 -> 784 bytes
-rw-r--r--assets/blocks/drills/water-extractor-liquid.pngbin211 -> 0 bytes
-rw-r--r--assets/blocks/drills/water-extractor-rotator.pngbin766 -> 0 bytes
-rw-r--r--assets/blocks/drills/water-extractor-top.pngbin606 -> 0 bytes
-rw-r--r--assets/blocks/drills/water-extractor.pngbin419 -> 836 bytes
-rw-r--r--assets/blocks/power/turbine-condenser-rotator-blur.pngbin12986 -> 0 bytes
-rw-r--r--assets/blocks/power/turbine-condenser-rotator.pngbin1238 -> 0 bytes
-rw-r--r--assets/blocks/power/turbine-condenser.pngbin2005 -> 2360 bytes
-rw-r--r--assets/blocks/production/phase-synthesizer-weave.pngbin322 -> 0 bytes
-rw-r--r--assets/blocks/production/phase-synthesizer.pngbin2353 -> 2423 bytes
-rw-r--r--assets/blocks/production/phase-weaver-weave.pngbin283 -> 0 bytes
-rw-r--r--assets/blocks/production/phase-weaver.pngbin1264 -> 1315 bytes
-rw-r--r--assets/blocks/turrets/tsunami-liquid.pngbin277 -> 0 bytes
-rw-r--r--assets/blocks/turrets/tsunami-top.pngbin216 -> 0 bytes
-rw-r--r--assets/blocks/turrets/tsunami.pngbin968 -> 985 bytes
-rw-r--r--assets/blocks/turrets/wave-liquid.pngbin133 -> 0 bytes
-rw-r--r--assets/blocks/turrets/wave-top.pngbin185 -> 0 bytes
-rw-r--r--assets/blocks/turrets/wave.pngbin563 -> 578 bytes
-rw-r--r--src/block/campaign.rs8
-rw-r--r--src/block/defense.rs27
-rw-r--r--src/block/distribution.rs46
-rw-r--r--src/block/drills.rs41
-rw-r--r--src/block/liquid.rs47
-rw-r--r--src/block/logic.rs22
-rw-r--r--src/block/mod.rs8
-rw-r--r--src/block/payload.rs64
-rw-r--r--src/block/power.rs49
-rw-r--r--src/block/production.rs70
-rw-r--r--src/block/simple.rs145
-rw-r--r--src/block/storage.rs24
-rw-r--r--src/block/turrets.rs69
-rw-r--r--src/block/walls.rs68
-rw-r--r--src/data/renderer.rs20
-rw-r--r--src/data/schematic.rs10
74 files changed, 372 insertions, 356 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9393816..adcbea5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,10 +9,7 @@ authors = [
]
repository = "https://github.com/bend-n/mindus.git"
license = "GPL-3.0"
-exclude = [
- ".github/",
- "items.py"
-]
+exclude = [".github/", "items.py"]
[dependencies]
@@ -32,3 +29,8 @@ walkdir = "2"
[[bin]]
name = "plandustry"
path = "src/exe/mod.rs"
+
+[profile.release]
+debug = 2
+opt-level = 3
+lto = true
diff --git a/assets/blocks/defense/build-tower-glow.png b/assets/blocks/defense/build-tower-glow.png
deleted file mode 100644
index 757d26d..0000000
--- a/assets/blocks/defense/build-tower-glow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/defense/radar-glow.png b/assets/blocks/defense/radar-glow.png
deleted file mode 100644
index 866ec4f..0000000
--- a/assets/blocks/defense/radar-glow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/defense/regen-projector-glow.png b/assets/blocks/defense/regen-projector-glow.png
deleted file mode 100644
index 4aa39ca..0000000
--- a/assets/blocks/defense/regen-projector-glow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/defense/regen-projector-mid.png b/assets/blocks/defense/regen-projector-mid.png
deleted file mode 100644
index d5f5c37..0000000
--- a/assets/blocks/defense/regen-projector-mid.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/defense/shockwave-tower-heat.png b/assets/blocks/defense/shockwave-tower-heat.png
deleted file mode 100644
index f949af1..0000000
--- a/assets/blocks/defense/shockwave-tower-heat.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/blast-drill-rim.png b/assets/blocks/drills/blast-drill-rim.png
deleted file mode 100644
index b71305c..0000000
--- a/assets/blocks/drills/blast-drill-rim.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/blast-drill-rotator.png b/assets/blocks/drills/blast-drill-rotator.png
deleted file mode 100644
index f781765..0000000
--- a/assets/blocks/drills/blast-drill-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/blast-drill-top.png b/assets/blocks/drills/blast-drill-top.png
deleted file mode 100644
index 189c04a..0000000
--- a/assets/blocks/drills/blast-drill-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/blast-drill.png b/assets/blocks/drills/blast-drill.png
index 18697e7..f775a7e 100644
--- a/assets/blocks/drills/blast-drill.png
+++ b/assets/blocks/drills/blast-drill.png
Binary files differ
diff --git a/assets/blocks/drills/cliff-crusher-rotator-bottom.png b/assets/blocks/drills/cliff-crusher-rotator-bottom.png
deleted file mode 100644
index 6799ee0..0000000
--- a/assets/blocks/drills/cliff-crusher-rotator-bottom.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/drill-item-2.png b/assets/blocks/drills/drill-item-2.png
deleted file mode 100644
index bd21ce9..0000000
--- a/assets/blocks/drills/drill-item-2.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/drill-item-3.png b/assets/blocks/drills/drill-item-3.png
deleted file mode 100644
index ed71640..0000000
--- a/assets/blocks/drills/drill-item-3.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/drill-item-4.png b/assets/blocks/drills/drill-item-4.png
deleted file mode 100644
index a18efb5..0000000
--- a/assets/blocks/drills/drill-item-4.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/eruption-drill-arrow-blur.png b/assets/blocks/drills/eruption-drill-arrow-blur.png
deleted file mode 100644
index e5c6e0e..0000000
--- a/assets/blocks/drills/eruption-drill-arrow-blur.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/eruption-drill-arrow.png b/assets/blocks/drills/eruption-drill-arrow.png
deleted file mode 100644
index 88b8b3e..0000000
--- a/assets/blocks/drills/eruption-drill-arrow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/eruption-drill-glow.png b/assets/blocks/drills/eruption-drill-glow.png
deleted file mode 100644
index d8f35a1..0000000
--- a/assets/blocks/drills/eruption-drill-glow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/eruption-drill-item.png b/assets/blocks/drills/eruption-drill-item.png
deleted file mode 100644
index 73a5e76..0000000
--- a/assets/blocks/drills/eruption-drill-item.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/eruption-drill-top.png b/assets/blocks/drills/eruption-drill-top.png
deleted file mode 100644
index 69b4faa..0000000
--- a/assets/blocks/drills/eruption-drill-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/eruption-drill.png b/assets/blocks/drills/eruption-drill.png
index f4b809a..5cafd99 100644
--- a/assets/blocks/drills/eruption-drill.png
+++ b/assets/blocks/drills/eruption-drill.png
Binary files differ
diff --git a/assets/blocks/drills/impact-drill-arrow-blur.png b/assets/blocks/drills/impact-drill-arrow-blur.png
deleted file mode 100644
index 49913d2..0000000
--- a/assets/blocks/drills/impact-drill-arrow-blur.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/impact-drill-arrow.png b/assets/blocks/drills/impact-drill-arrow.png
deleted file mode 100644
index 9277d39..0000000
--- a/assets/blocks/drills/impact-drill-arrow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/impact-drill-item.png b/assets/blocks/drills/impact-drill-item.png
deleted file mode 100644
index a9ab1b2..0000000
--- a/assets/blocks/drills/impact-drill-item.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/impact-drill-top-invert.png b/assets/blocks/drills/impact-drill-top-invert.png
deleted file mode 100644
index 792c61f..0000000
--- a/assets/blocks/drills/impact-drill-top-invert.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/impact-drill-top.png b/assets/blocks/drills/impact-drill-top.png
deleted file mode 100644
index 76d645c..0000000
--- a/assets/blocks/drills/impact-drill-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/impact-drill.png b/assets/blocks/drills/impact-drill.png
index b982da6..d676327 100644
--- a/assets/blocks/drills/impact-drill.png
+++ b/assets/blocks/drills/impact-drill.png
Binary files differ
diff --git a/assets/blocks/drills/large-plasma-bore-glow.png b/assets/blocks/drills/large-plasma-bore-glow.png
deleted file mode 100644
index b17b63b..0000000
--- a/assets/blocks/drills/large-plasma-bore-glow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/laser-drill-rotator.png b/assets/blocks/drills/laser-drill-rotator.png
deleted file mode 100644
index f9301d4..0000000
--- a/assets/blocks/drills/laser-drill-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/laser-drill-top.png b/assets/blocks/drills/laser-drill-top.png
deleted file mode 100644
index 3859f59..0000000
--- a/assets/blocks/drills/laser-drill-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/laser-drill.png b/assets/blocks/drills/laser-drill.png
index d85cd06..c1c1cc0 100644
--- a/assets/blocks/drills/laser-drill.png
+++ b/assets/blocks/drills/laser-drill.png
Binary files differ
diff --git a/assets/blocks/drills/mechanical-drill-rotator.png b/assets/blocks/drills/mechanical-drill-rotator.png
deleted file mode 100644
index 22326cc..0000000
--- a/assets/blocks/drills/mechanical-drill-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/mechanical-drill-top.png b/assets/blocks/drills/mechanical-drill-top.png
deleted file mode 100644
index dae2776..0000000
--- a/assets/blocks/drills/mechanical-drill-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/mechanical-drill.png b/assets/blocks/drills/mechanical-drill.png
index 2685c03..150423d 100644
--- a/assets/blocks/drills/mechanical-drill.png
+++ b/assets/blocks/drills/mechanical-drill.png
Binary files differ
diff --git a/assets/blocks/drills/oil-extractor-liquid.png b/assets/blocks/drills/oil-extractor-liquid.png
deleted file mode 100644
index 6639f08..0000000
--- a/assets/blocks/drills/oil-extractor-liquid.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/oil-extractor-rotator.png b/assets/blocks/drills/oil-extractor-rotator.png
deleted file mode 100644
index c10a7b7..0000000
--- a/assets/blocks/drills/oil-extractor-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/oil-extractor-top.png b/assets/blocks/drills/oil-extractor-top.png
deleted file mode 100644
index fe293d4..0000000
--- a/assets/blocks/drills/oil-extractor-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/oil-extractor.png b/assets/blocks/drills/oil-extractor.png
index 3601339..025cf7b 100644
--- a/assets/blocks/drills/oil-extractor.png
+++ b/assets/blocks/drills/oil-extractor.png
Binary files differ
diff --git a/assets/blocks/drills/plasma-bore-glow.png b/assets/blocks/drills/plasma-bore-glow.png
deleted file mode 100644
index fbfe8c4..0000000
--- a/assets/blocks/drills/plasma-bore-glow.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/pneumatic-drill-rotator.png b/assets/blocks/drills/pneumatic-drill-rotator.png
deleted file mode 100644
index b9b4988..0000000
--- a/assets/blocks/drills/pneumatic-drill-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/pneumatic-drill-top.png b/assets/blocks/drills/pneumatic-drill-top.png
deleted file mode 100644
index bf18f2d..0000000
--- a/assets/blocks/drills/pneumatic-drill-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/pneumatic-drill.png b/assets/blocks/drills/pneumatic-drill.png
index e755a63..6d4cda9 100644
--- a/assets/blocks/drills/pneumatic-drill.png
+++ b/assets/blocks/drills/pneumatic-drill.png
Binary files differ
diff --git a/assets/blocks/drills/water-extractor-liquid.png b/assets/blocks/drills/water-extractor-liquid.png
deleted file mode 100644
index a0d7135..0000000
--- a/assets/blocks/drills/water-extractor-liquid.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/water-extractor-rotator.png b/assets/blocks/drills/water-extractor-rotator.png
deleted file mode 100644
index ef62105..0000000
--- a/assets/blocks/drills/water-extractor-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/water-extractor-top.png b/assets/blocks/drills/water-extractor-top.png
deleted file mode 100644
index 3671dd0..0000000
--- a/assets/blocks/drills/water-extractor-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/drills/water-extractor.png b/assets/blocks/drills/water-extractor.png
index f38c9e7..37f3ed7 100644
--- a/assets/blocks/drills/water-extractor.png
+++ b/assets/blocks/drills/water-extractor.png
Binary files differ
diff --git a/assets/blocks/power/turbine-condenser-rotator-blur.png b/assets/blocks/power/turbine-condenser-rotator-blur.png
deleted file mode 100644
index adea102..0000000
--- a/assets/blocks/power/turbine-condenser-rotator-blur.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/power/turbine-condenser-rotator.png b/assets/blocks/power/turbine-condenser-rotator.png
deleted file mode 100644
index 76e45e9..0000000
--- a/assets/blocks/power/turbine-condenser-rotator.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/power/turbine-condenser.png b/assets/blocks/power/turbine-condenser.png
index 7322043..fdbc889 100644
--- a/assets/blocks/power/turbine-condenser.png
+++ b/assets/blocks/power/turbine-condenser.png
Binary files differ
diff --git a/assets/blocks/production/phase-synthesizer-weave.png b/assets/blocks/production/phase-synthesizer-weave.png
deleted file mode 100644
index 0c82c7a..0000000
--- a/assets/blocks/production/phase-synthesizer-weave.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/production/phase-synthesizer.png b/assets/blocks/production/phase-synthesizer.png
index 04a97da..1f61cd7 100644
--- a/assets/blocks/production/phase-synthesizer.png
+++ b/assets/blocks/production/phase-synthesizer.png
Binary files differ
diff --git a/assets/blocks/production/phase-weaver-weave.png b/assets/blocks/production/phase-weaver-weave.png
deleted file mode 100644
index b6dd7d2..0000000
--- a/assets/blocks/production/phase-weaver-weave.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/production/phase-weaver.png b/assets/blocks/production/phase-weaver.png
index 282d9bc..0b0aebb 100644
--- a/assets/blocks/production/phase-weaver.png
+++ b/assets/blocks/production/phase-weaver.png
Binary files differ
diff --git a/assets/blocks/turrets/tsunami-liquid.png b/assets/blocks/turrets/tsunami-liquid.png
deleted file mode 100644
index a9ddf83..0000000
--- a/assets/blocks/turrets/tsunami-liquid.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/turrets/tsunami-top.png b/assets/blocks/turrets/tsunami-top.png
deleted file mode 100644
index a9e5e38..0000000
--- a/assets/blocks/turrets/tsunami-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/turrets/tsunami.png b/assets/blocks/turrets/tsunami.png
index 257c708..abb3764 100644
--- a/assets/blocks/turrets/tsunami.png
+++ b/assets/blocks/turrets/tsunami.png
Binary files differ
diff --git a/assets/blocks/turrets/wave-liquid.png b/assets/blocks/turrets/wave-liquid.png
deleted file mode 100644
index b23962a..0000000
--- a/assets/blocks/turrets/wave-liquid.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/turrets/wave-top.png b/assets/blocks/turrets/wave-top.png
deleted file mode 100644
index c3effac..0000000
--- a/assets/blocks/turrets/wave-top.png
+++ /dev/null
Binary files differ
diff --git a/assets/blocks/turrets/wave.png b/assets/blocks/turrets/wave.png
index bf56315..8297f6b 100644
--- a/assets/blocks/turrets/wave.png
+++ b/assets/blocks/turrets/wave.png
Binary files differ
diff --git a/src/block/campaign.rs b/src/block/campaign.rs
index 9c87a15..9869eeb 100644
--- a/src/block/campaign.rs
+++ b/src/block/campaign.rs
@@ -1,8 +1,8 @@
//! campaign blocks
use crate::block::make_register;
-use crate::block::simple::{cost, SimpleBlock};
-
+use crate::block::simple::{cost, make_simple};
+make_simple!(CampaignBlock);
make_register! {
- "launch-pad" => SimpleBlock::new(3, true, cost!(Copper: 350, Lead: 200, Titanium: 150, Silicon: 140));
- "interplanetary-accelerator" => SimpleBlock::new(7, true, cost!(Copper: 16000, Silicon: 11000, Thorium: 13000, Titanium: 12000, SurgeAlloy: 6000, PhaseFabric: 5000));
+ "launch-pad" => CampaignBlock::new(3, true, cost!(Copper: 350, Lead: 200, Titanium: 150, Silicon: 140));
+ "interplanetary-accelerator" => CampaignBlock::new(7, true, cost!(Copper: 16000, Silicon: 11000, Thorium: 13000, Titanium: 12000, SurgeAlloy: 6000, PhaseFabric: 5000));
}
diff --git a/src/block/defense.rs b/src/block/defense.rs
index e197c37..88cf0d5 100644
--- a/src/block/defense.rs
+++ b/src/block/defense.rs
@@ -1,19 +1,20 @@
//! defense
use crate::block::make_register;
-use crate::block::simple::{cost, SimpleBlock};
+use crate::block::simple::{cost, make_simple};
+make_simple!(DefenseBlock);
make_register! {
- "mender" => SimpleBlock::new(1, true, cost!(Copper: 25, Lead: 30));
- "mend-projector" => SimpleBlock::new(2, true, cost!(Copper: 50, Lead: 100, Titanium: 25, Silicon: 40));
- "overdrive-projector" => SimpleBlock::new(2, true, cost!(Lead: 100, Titanium: 75, Silicon: 75, Plastanium: 30));
- "overdrive-dome" => SimpleBlock::new(3, true, cost!(Lead: 200, Titanium: 130, Silicon: 130, Plastanium: 80, SurgeAlloy: 120));
- "force-projector" => SimpleBlock::new(3, true, cost!(Lead: 100, Titanium: 75, Silicon: 125));
- "regen-projector" => SimpleBlock::new(3, true, cost!(Silicon: 80, Tungsten: 60, Oxide: 40, Beryllium: 80));
- "shock-mine" => SimpleBlock::new(1, true, cost!(Lead: 25, Silicon: 12));
- "radar" => SimpleBlock::new(1, true, cost!(Silicon: 60, Graphite: 50, Beryllium: 10));
- "build-tower" => SimpleBlock::new(3, true, cost!(Silicon: 150, Oxide: 40, Thorium: 60));
+ "mender" => DefenseBlock::new(1, true, cost!(Copper: 25, Lead: 30));
+ "mend-projector" => DefenseBlock::new(2, true, cost!(Copper: 50, Lead: 100, Titanium: 25, Silicon: 40));
+ "overdrive-projector" => DefenseBlock::new(2, true, cost!(Lead: 100, Titanium: 75, Silicon: 75, Plastanium: 30));
+ "overdrive-dome" => DefenseBlock::new(3, true, cost!(Lead: 200, Titanium: 130, Silicon: 130, Plastanium: 80, SurgeAlloy: 120));
+ "force-projector" => DefenseBlock::new(3, true, cost!(Lead: 100, Titanium: 75, Silicon: 125));
+ "regen-projector" => DefenseBlock::new(3, true, cost!(Silicon: 80, Tungsten: 60, Oxide: 40, Beryllium: 80));
+ "shock-mine" => DefenseBlock::new(1, true, cost!(Lead: 25, Silicon: 12));
+ "radar" => DefenseBlock::new(1, true, cost!(Silicon: 60, Graphite: 50, Beryllium: 10));
+ "build-tower" => DefenseBlock::new(3, true, cost!(Silicon: 150, Oxide: 40, Thorium: 60));
// barrier projector
// editor only
- "shockwave-tower" => SimpleBlock::new(3, true, cost!(SurgeAlloy: 50, Silicon: 150, Oxide: 30, Tungsten: 100));
- "shield-projector" => SimpleBlock::new(3, true, &[]);
- "large-shield-projector" => SimpleBlock::new(4, true, &[]);
+ "shockwave-tower" => DefenseBlock::new(3, true, cost!(SurgeAlloy: 50, Silicon: 150, Oxide: 30, Tungsten: 100));
+ "shield-projector" => DefenseBlock::new(3, true, &[]);
+ "large-shield-projector" => DefenseBlock::new(4, true, &[]);
}
diff --git a/src/block/distribution.rs b/src/block/distribution.rs
index b6bdbc1..c68a851 100644
--- a/src/block/distribution.rs
+++ b/src/block/distribution.rs
@@ -4,48 +4,44 @@ use std::fmt;
use image::RgbaImage;
-use crate::block::simple::{cost, state_impl, BuildCost, SimpleBlock};
-use crate::block::{
- impl_block, make_register, BlockLogic, DataConvertError, DeserializeError, SerializeError,
-};
+use crate::block::make_register;
+use crate::block::simple::{cost, make_simple, state_impl};
use crate::content;
-use crate::data::dynamic::{DynData, DynType};
+use crate::data::dynamic::DynType;
use crate::data::renderer::load;
-use crate::data::GridPos;
use crate::item;
-use crate::item::storage::Storage;
-use super::State;
+make_simple!(ConveyorBlock);
make_register! {
- "conveyor" => SimpleBlock::new(1, false, cost!(Copper: 1));
- "titanium-conveyor" => SimpleBlock::new(1, false, cost!(Copper: 1, Lead: 1, Titanium: 1));
- "plastanium-conveyor" => SimpleBlock::new(1, false, cost!(Graphite: 1, Silicon: 1, Plastanium: 1));
- "armored-conveyor" => SimpleBlock::new(1, false, cost!(Metaglass: 1, Thorium: 1, Plastanium: 1));
- "junction" => SimpleBlock::new(1, true, cost!(Copper: 2));
+ "conveyor" => ConveyorBlock::new(1, false, cost!(Copper: 1));
+ "titanium-conveyor" => ConveyorBlock::new(1, false, cost!(Copper: 1, Lead: 1, Titanium: 1));
+ "plastanium-conveyor" => ConveyorBlock::new(1, false, cost!(Graphite: 1, Silicon: 1, Plastanium: 1));
+ "armored-conveyor" => ConveyorBlock::new(1, false, cost!(Metaglass: 1, Thorium: 1, Plastanium: 1));
+ "junction" => ConveyorBlock::new(1, true, cost!(Copper: 2));
"bridge-conveyor" => BridgeBlock::new(1, false, cost!(Copper: 6, Lead: 6), 4, true);
"phase-conveyor" => BridgeBlock::new(1, false, cost!(Lead: 10, Graphite: 10, Silicon: 7, PhaseFabric: 5), 12, true);
"sorter" => ItemBlock::new(1, true, cost!(Copper: 2, Lead: 2));
"inverted-sorter" => ItemBlock::new(1, true, cost!(Copper: 2, Lead: 2));
- "router" => SimpleBlock::new(1, true, cost!(Copper: 3));
- "distributor" => SimpleBlock::new(2, true, cost!(Copper: 4, Lead: 4));
- "overflow-gate" => SimpleBlock::new(1, true, cost!(Copper: 4, Lead: 2));
- "underflow-gate" => SimpleBlock::new(1, true, cost!(Copper: 4, Lead: 2));
+ "router" => ConveyorBlock::new(1, true, cost!(Copper: 3));
+ "distributor" => ConveyorBlock::new(2, true, cost!(Copper: 4, Lead: 4));
+ "overflow-gate" => ConveyorBlock::new(1, true, cost!(Copper: 4, Lead: 2));
+ "underflow-gate" => ConveyorBlock::new(1, true, cost!(Copper: 4, Lead: 2));
"mass-driver" => BridgeBlock::new(3, true, cost!(Lead: 125, Titanium: 125, Thorium: 50, Silicon: 75), 55, false);
- "duct" => SimpleBlock::new(1, false, cost!(Beryllium: 1));
- "armored-duct" => SimpleBlock::new(1, false, cost!(Beryllium: 2, Tungsten: 1));
+ "duct" => ConveyorBlock::new(1, false, cost!(Beryllium: 1));
+ "armored-duct" => ConveyorBlock::new(1, false, cost!(Beryllium: 2, Tungsten: 1));
"duct-router" => ItemBlock::new(1, true, cost!(Beryllium: 10));
- "overflow-duct" => SimpleBlock::new(1, true, cost!(Graphite: 8, Beryllium: 8));
- "underflow-duct" => SimpleBlock::new(1, true, cost!(Graphite: 8, Beryllium: 8));
+ "overflow-duct" => ConveyorBlock::new(1, true, cost!(Graphite: 8, Beryllium: 8));
+ "underflow-duct" => ConveyorBlock::new(1, true, cost!(Graphite: 8, Beryllium: 8));
"duct-bridge" => BridgeBlock::new(1, true, cost!(Beryllium: 20), 3, true);
"duct-unloader" => ItemBlock::new(1, true, cost!(Graphite: 20, Silicon: 20, Tungsten: 10));
- "surge-conveyor" => SimpleBlock::new(1, false, cost!(SurgeAlloy: 1, Tungsten: 1));
- "surge-router" => SimpleBlock::new(1, false, cost!(SurgeAlloy: 5, Tungsten: 1)); // not symmetric
- "unit-cargo-loader" => SimpleBlock::new(3, true, cost!(Silicon: 80, SurgeAlloy: 50, Oxide: 20));
+ "surge-conveyor" => ConveyorBlock::new(1, false, cost!(SurgeAlloy: 1, Tungsten: 1));
+ "surge-router" => ConveyorBlock::new(1, false, cost!(SurgeAlloy: 5, Tungsten: 1)); // not symmetric
+ "unit-cargo-loader" => ConveyorBlock::new(3, true, cost!(Silicon: 80, SurgeAlloy: 50, Oxide: 20));
"unit-cargo-unload-point" => ItemBlock::new(2, true, cost!(Silicon: 60, Tungsten: 60));
// sandbox only
"item-source" => ItemBlock::new(1, true, &[]);
- "item-void" => SimpleBlock::new(1, true, &[]);
+ "item-void" => ConveyorBlock::new(1, true, &[]);
}
pub struct ItemBlock {
diff --git a/src/block/drills.rs b/src/block/drills.rs
index 5c5f87a..eb50b87 100644
--- a/src/block/drills.rs
+++ b/src/block/drills.rs
@@ -1,20 +1,27 @@
//! extraction of raw resources (mine part)
use crate::block::make_register;
-use crate::block::simple::{cost, SimpleBlock};
+use crate::block::simple::{cost, make_simple};
+use crate::data::renderer::read_with;
+make_simple!(DrillBlock, |_, _, name, _| {
+ if name == "cliff-crusher" {
+ const SFX: &[&str; 3] = &["", "-top", "-rotator"];
+ return Some(read_with("drills", "cliff-crusher", SFX, 2u16));
+ }
+ None
+});
-make_register!
-(
- "mechanical-drill" => SimpleBlock::new(2, true, cost!(Copper: 12));
- "pneumatic-drill" => SimpleBlock::new(2, true, cost!(Copper: 18, Graphite: 10));
- "laser-drill" => SimpleBlock::new(3, true, cost!(Copper: 35, Graphite: 30, Titanium: 20, Silicon: 30));
- "blast-drill" => SimpleBlock::new(4, true, cost!(Copper: 65, Titanium: 50, Thorium: 75, Silicon: 60));
- "water-extractor" => SimpleBlock::new(2, true, cost!(Copper: 30, Lead: 30, Metaglass: 30, Graphite: 30));
- "cultivator" => SimpleBlock::new(2, true, cost!(Copper: 25, Lead: 25, Silicon: 10));
- "oil-extractor" => SimpleBlock::new(3, true, cost!(Copper: 150, Lead: 115, Graphite: 175, Thorium: 115, Silicon: 75));
- "vent-condenser" => SimpleBlock::new(3, true, cost!(Graphite: 20, Beryllium: 60));
- "cliff-crusher" => SimpleBlock::new(2, false, cost!(Beryllium: 100, Graphite: 40));
- "plasma-bore" => SimpleBlock::new(2, false, cost!(Beryllium: 40));
- "large-plasma-bore" => SimpleBlock::new(3, false, cost!(Silicon: 100, Oxide: 25, Beryllium: 100, Tungsten: 70));
- "impact-drill" => SimpleBlock::new(4, true, cost!(Silicon: 70, Beryllium: 90, Graphite: 60));
- "eruption-drill" => SimpleBlock::new(5, true, cost!(Silicon: 200, Oxide: 20, Tungsten: 200, Thorium: 120));
-);
+make_register! {
+ "mechanical-drill" => DrillBlock::new(2, true, cost!(Copper: 12));
+ "pneumatic-drill" => DrillBlock::new(2, true, cost!(Copper: 18, Graphite: 10));
+ "laser-drill" => DrillBlock::new(3, true, cost!(Copper: 35, Graphite: 30, Titanium: 20, Silicon: 30));
+ "blast-drill" => DrillBlock::new(4, true, cost!(Copper: 65, Titanium: 50, Thorium: 75, Silicon: 60));
+ "water-extractor" => DrillBlock::new(2, true, cost!(Copper: 30, Lead: 30, Metaglass: 30, Graphite: 30));
+ "cultivator" => DrillBlock::new(2, true, cost!(Copper: 25, Lead: 25, Silicon: 10));
+ "oil-extractor" => DrillBlock::new(3, true, cost!(Copper: 150, Lead: 115, Graphite: 175, Thorium: 115, Silicon: 75));
+ "vent-condenser" => DrillBlock::new(3, true, cost!(Graphite: 20, Beryllium: 60));
+ "cliff-crusher" => DrillBlock::new(2, false, cost!(Beryllium: 100, Graphite: 40));
+ "plasma-bore" => DrillBlock::new(2, false, cost!(Beryllium: 40));
+ "large-plasma-bore" => DrillBlock::new(3, false, cost!(Silicon: 100, Oxide: 25, Beryllium: 100, Tungsten: 70));
+ "impact-drill" => DrillBlock::new(4, true, cost!(Silicon: 70, Beryllium: 90, Graphite: 60));
+ "eruption-drill" => DrillBlock::new(5, true, cost!(Silicon: 200, Oxide: 20, Tungsten: 200, Thorium: 120));
+}
diff --git a/src/block/liquid.rs b/src/block/liquid.rs
index ee7b591..f007747 100644
--- a/src/block/liquid.rs
+++ b/src/block/liquid.rs
@@ -2,42 +2,39 @@
use std::error::Error;
use std::fmt;
-use super::State;
use crate::block::distribution::BridgeBlock;
-use crate::block::simple::{cost, state_impl, BuildCost, SimpleBlock};
-use crate::block::{
- impl_block, make_register, BlockLogic, DataConvertError, DeserializeError, SerializeError,
-};
+use crate::block::make_register;
+use crate::block::simple::{cost, make_simple, state_impl};
use crate::content;
-use crate::data::dynamic::{DynData, DynType};
+use crate::data::dynamic::DynType;
use crate::data::renderer::load;
-use crate::data::GridPos;
use crate::fluid;
-use crate::item::storage::Storage;
+
+make_simple!(LiquidBlock);
make_register! {
- "reinforced-pump" => SimpleBlock::new(2, true, cost!(Beryllium: 40, Tungsten: 30, Silicon: 20));
- "mechanical-pump" => SimpleBlock::new(1, true, cost!(Copper: 15, Metaglass: 10));
- "rotary-pump" => SimpleBlock::new(2, true, cost!(Copper: 70, Metaglass: 50, Titanium: 35, Silicon: 20));
- "impulse-pump" => SimpleBlock::new(3, true, cost!(Copper: 80, Metaglass: 90, Titanium: 40, Thorium: 35, Silicon: 30));
- "conduit" => SimpleBlock::new(1, false, cost!(Metaglass: 1));
- "pulse-conduit" => SimpleBlock::new(1, false, cost!(Metaglass: 1, Titanium: 2));
- "plated-conduit" => SimpleBlock::new(1, false, cost!(Metaglass: 1, Thorium: 2, Plastanium: 1));
- "liquid-router" => SimpleBlock::new(1, true, cost!(Metaglass: 2, Graphite: 4));
- "liquid-container" => SimpleBlock::new(2, true, cost!(Metaglass: 15, Titanium: 10));
- "liquid-tank" => SimpleBlock::new(3, true, cost!(Metaglass: 40, Titanium: 30));
- "liquid-junction" => SimpleBlock::new(1, true, cost!(Metaglass: 8, Graphite: 4));
+ "reinforced-pump" => LiquidBlock::new(2, true, cost!(Beryllium: 40, Tungsten: 30, Silicon: 20));
+ "mechanical-pump" => LiquidBlock::new(1, true, cost!(Copper: 15, Metaglass: 10));
+ "rotary-pump" => LiquidBlock::new(2, true, cost!(Copper: 70, Metaglass: 50, Titanium: 35, Silicon: 20));
+ "impulse-pump" => LiquidBlock::new(3, true, cost!(Copper: 80, Metaglass: 90, Titanium: 40, Thorium: 35, Silicon: 30));
+ "conduit" => LiquidBlock::new(1, false, cost!(Metaglass: 1));
+ "pulse-conduit" => LiquidBlock::new(1, false, cost!(Metaglass: 1, Titanium: 2));
+ "plated-conduit" => LiquidBlock::new(1, false, cost!(Metaglass: 1, Thorium: 2, Plastanium: 1));
+ "liquid-router" => LiquidBlock::new(1, true, cost!(Metaglass: 2, Graphite: 4));
+ "liquid-container" => LiquidBlock::new(2, true, cost!(Metaglass: 15, Titanium: 10));
+ "liquid-tank" => LiquidBlock::new(3, true, cost!(Metaglass: 40, Titanium: 30));
+ "liquid-junction" => LiquidBlock::new(1, true, cost!(Metaglass: 8, Graphite: 4));
"bridge-conduit" => BridgeBlock::new(1, true, cost!(Metaglass: 8, Graphite: 4), 4, true);
"phase-conduit" => BridgeBlock::new(1, true, cost!(Metaglass: 20, Titanium: 10, Silicon: 7, PhaseFabric: 5), 12, true);
- "reinforced-conduit" => SimpleBlock::new(1, false, cost!(Beryllium: 2));
- "reinforced-liquid-junction" => SimpleBlock::new(1, true, cost!(Graphite: 4, Beryllium: 8));
+ "reinforced-conduit" => LiquidBlock::new(1, false, cost!(Beryllium: 2));
+ "reinforced-liquid-junction" => LiquidBlock::new(1, true, cost!(Graphite: 4, Beryllium: 8));
"reinforced-bridge-conduit" => BridgeBlock::new(1, true, cost!(Graphite: 8, Beryllium: 20), 4, true);
- "reinforced-liquid-router" => SimpleBlock::new(1, true, cost!(Graphite: 8, Beryllium: 4));
- "reinforced-liquid-container" => SimpleBlock::new(2, true, cost!(Tungsten: 10, Beryllium: 16));
- "reinforced-liquid-tank" => SimpleBlock::new(3, true, cost!(Tungsten: 40, Beryllium: 50));
+ "reinforced-liquid-router" => LiquidBlock::new(1, true, cost!(Graphite: 8, Beryllium: 4));
+ "reinforced-liquid-container" => LiquidBlock::new(2, true, cost!(Tungsten: 10, Beryllium: 16));
+ "reinforced-liquid-tank" => LiquidBlock::new(3, true, cost!(Tungsten: 40, Beryllium: 50));
// sandbox only
"liquid-source" => FluidBlock::new(1, true, &[]);
- "liquid-void" => SimpleBlock::new(1, true, &[]);
+ "liquid-void" => LiquidBlock::new(1, true, &[]);
}
pub struct FluidBlock {
diff --git a/src/block/logic.rs b/src/block/logic.rs
index a37a97f..76aa440 100644
--- a/src/block/logic.rs
+++ b/src/block/logic.rs
@@ -9,14 +9,12 @@ use flate2::{
FlushDecompress, Status,
};
-use super::State;
-use crate::block::simple::{cost, state_impl, BuildCost, SimpleBlock};
-use crate::block::{
- impl_block, make_register, BlockLogic, DataConvertError, DeserializeError, SerializeError,
-};
-use crate::data::dynamic::{DynData, DynType};
-use crate::data::{self, DataRead, DataWrite, GridPos};
-use crate::item::storage::Storage;
+use crate::block::make_register;
+use crate::block::simple::{cost, make_simple, state_impl};
+use crate::data::dynamic::DynType;
+use crate::data::{self, DataRead, DataWrite};
+
+make_simple!(LogicBlock);
make_register! {
// todo reinforced proc
@@ -26,10 +24,10 @@ make_register! {
"micro-processor" => ProcessorLogic::new(1, true, cost!(Copper: 90, Lead: 50, Silicon: 50));
"logic-processor" => ProcessorLogic::new(2, true, cost!(Lead: 320, Graphite: 60, Thorium: 50, Silicon: 80));
"hyper-processor" => ProcessorLogic::new(3, true, cost!(Lead: 450, Thorium: 75, Silicon: 150, SurgeAlloy: 50));
- "memory-cell" => SimpleBlock::new(1, true, cost!(Copper: 30, Graphite: 30, Silicon: 30));
- "memory-bank" => SimpleBlock::new(2, true, cost!(Copper: 30, Graphite: 80, Silicon: 80, PhaseFabric: 30));
- "logic-display" => SimpleBlock::new(3, true, cost!(Lead: 100, Metaglass: 50, Silicon: 50));
- "large-logic-display" => SimpleBlock::new(6, true, cost!(Lead: 200, Metaglass: 100, Silicon: 150, PhaseFabric: 75));
+ "memory-cell" => LogicBlock::new(1, true, cost!(Copper: 30, Graphite: 30, Silicon: 30));
+ "memory-bank" => LogicBlock::new(2, true, cost!(Copper: 30, Graphite: 80, Silicon: 80, PhaseFabric: 30));
+ "logic-display" => LogicBlock::new(3, true, cost!(Lead: 100, Metaglass: 50, Silicon: 50));
+ "large-logic-display" => LogicBlock::new(6, true, cost!(Lead: 200, Metaglass: 100, Silicon: 150, PhaseFabric: 75));
}
pub struct MessageLogic {
diff --git a/src/block/mod.rs b/src/block/mod.rs
index 7480545..ca20821 100644
--- a/src/block/mod.rs
+++ b/src/block/mod.rs
@@ -70,7 +70,7 @@ macro_rules! impl_block {
if self.build_cost.is_empty() {
None
} else {
- let mut storage = Storage::new();
+ let mut storage = crate::item::storage::Storage::new();
for (ty, cnt) in self.build_cost {
storage.add(*ty, *cnt, u32::MAX);
}
@@ -209,7 +209,7 @@ impl Block {
/// assert!(mindus::block::distribution::DISTRIBUTOR.name() == "distributor")
/// ```
pub fn name(&self) -> &str {
- &*self.name
+ &self.name
}
/// draw this block, with this state
@@ -217,12 +217,12 @@ impl Block {
if let Some(p) = self
.logic
.as_ref()
- .draw(&*self.category, &*self.name, state)
+ .draw(&self.category, &self.name, state)
{
return p;
}
use crate::data::renderer::read;
- read(&*self.category, &*self.name, self.get_size())
+ read(&self.category, &self.name, self.get_size())
}
/// size.
diff --git a/src/block/payload.rs b/src/block/payload.rs
index dad89e7..1cf52fe 100644
--- a/src/block/payload.rs
+++ b/src/block/payload.rs
@@ -2,17 +2,13 @@
use std::error::Error;
use std::fmt;
-use crate::block::simple::{cost, state_impl, BuildCost, SimpleBlock};
-use crate::block::{
- self, distribution::BridgeBlock, impl_block, make_register, BlockLogic, DataConvertError,
- DeserializeError, SerializeError,
-};
+use crate::block::simple::{cost, make_simple, state_impl};
+use crate::block::{self, distribution::BridgeBlock, make_register};
use crate::content;
-use crate::data::dynamic::{DynData, DynType};
-use crate::data::GridPos;
-use crate::item::storage::Storage;
+use crate::data::dynamic::DynType;
use crate::unit;
-use super::State;
+
+make_simple!(ConstructorBlock);
const GROUND_UNITS: &[unit::Type] = &[unit::Type::Dagger, unit::Type::Crawler, unit::Type::Nova];
const AIR_UNITS: &[unit::Type] = &[unit::Type::Flare, unit::Type::Mono];
@@ -22,41 +18,41 @@ make_register! {
"ground-factory" => AssemblerBlock::new(3, false, cost!(Copper: 50, Lead: 120, Silicon: 80), GROUND_UNITS);
"air-factory" => AssemblerBlock::new(3, false, cost!(Copper: 60, Lead: 70), AIR_UNITS);
"naval-factory" => AssemblerBlock::new(3, false, cost!(Copper: 150, Lead: 130, Metaglass: 120), NAVAL_UNITS);
- "additive-reconstructor" => SimpleBlock::new(3, false, cost!(Copper: 200, Lead: 120, Silicon: 90));
- "multiplicative-reconstructor" => SimpleBlock::new(5, false, cost!(Lead: 650, Titanium: 350, Thorium: 650, Silicon: 450));
- "exponential-reconstructor" => SimpleBlock::new(7, false,
+ "additive-reconstructor" => ConstructorBlock::new(3, false, cost!(Copper: 200, Lead: 120, Silicon: 90));
+ "multiplicative-reconstructor" => ConstructorBlock::new(5, false, cost!(Lead: 650, Titanium: 350, Thorium: 650, Silicon: 450));
+ "exponential-reconstructor" => ConstructorBlock::new(7, false,
cost!(Lead: 2000, Titanium: 2000, Thorium: 750, Silicon: 1000, Plastanium: 450, PhaseFabric: 600));
- "tetrative-reconstructor" => SimpleBlock::new(9, false,
+ "tetrative-reconstructor" => ConstructorBlock::new(9, false,
cost!(Lead: 4000, Thorium: 1000, Silicon: 3000, Plastanium: 600, PhaseFabric: 600, SurgeAlloy: 800));
- "repair-point" => SimpleBlock::new(1, true, cost!(Copper: 30, Lead: 30, Silicon: 20));
- "repair-turret" => SimpleBlock::new(2, true, cost!(Thorium: 80, Silicon: 90, Plastanium: 60));
- "tank-fabricator" => SimpleBlock::new(3, true, cost!(Silicon: 200, Beryllium: 150));
- "ship-fabricator" => SimpleBlock::new(3, true, cost!(Silicon: 250, Beryllium: 200));
- "mech-fabricator" => SimpleBlock::new(3, true, cost!(Silicon: 200, Graphite: 300, Tungsten: 60));
- "tank-refabricator" => SimpleBlock::new(3, true, cost!(Beryllium: 200, Tungsten: 80, Silicon: 100));
- "mech-refabricator" => SimpleBlock::new(3, true, cost!(Beryllium: 250, Tungsten: 120, Silicon: 150));
- "ship-refabricator" => SimpleBlock::new(3, true, cost!(Beryllium: 200, Tungsten: 100, Silicon: 150, Oxide: 40));
- "prime-refabricator" => SimpleBlock::new(5, true, cost!(Thorium: 250, Oxide: 200, Tungsten: 200, Silicon: 400));
- "tank-assembler" => SimpleBlock::new(5, true, cost!(Thorium: 500, Oxide: 150, Carbide: 80, Silicon: 500));
- "ship-assembler" => SimpleBlock::new(5, true, cost!(Carbide: 100, Oxide: 200, Tungsten: 500, Silicon: 800, Thorium: 400));
- "mech-assembler" => SimpleBlock::new(5, true, cost!(Carbide: 200, Thorium: 600, Oxide: 200, Tungsten: 500, Silicon: 900)); // smh collaris
- "basic-assembler-module" => SimpleBlock::new(5, true, cost!(Carbide: 300, Thorium: 500, Oxide: 200, PhaseFabric: 400)); // the dummy block
+ "repair-point" => ConstructorBlock::new(1, true, cost!(Copper: 30, Lead: 30, Silicon: 20));
+ "repair-turret" => ConstructorBlock::new(2, true, cost!(Thorium: 80, Silicon: 90, Plastanium: 60));
+ "tank-fabricator" => ConstructorBlock::new(3, true, cost!(Silicon: 200, Beryllium: 150));
+ "ship-fabricator" => ConstructorBlock::new(3, true, cost!(Silicon: 250, Beryllium: 200));
+ "mech-fabricator" => ConstructorBlock::new(3, true, cost!(Silicon: 200, Graphite: 300, Tungsten: 60));
+ "tank-refabricator" => ConstructorBlock::new(3, true, cost!(Beryllium: 200, Tungsten: 80, Silicon: 100));
+ "mech-refabricator" => ConstructorBlock::new(3, true, cost!(Beryllium: 250, Tungsten: 120, Silicon: 150));
+ "ship-refabricator" => ConstructorBlock::new(3, true, cost!(Beryllium: 200, Tungsten: 100, Silicon: 150, Oxide: 40));
+ "prime-refabricator" => ConstructorBlock::new(5, true, cost!(Thorium: 250, Oxide: 200, Tungsten: 200, Silicon: 400));
+ "tank-assembler" => ConstructorBlock::new(5, true, cost!(Thorium: 500, Oxide: 150, Carbide: 80, Silicon: 500));
+ "ship-assembler" => ConstructorBlock::new(5, true, cost!(Carbide: 100, Oxide: 200, Tungsten: 500, Silicon: 800, Thorium: 400));
+ "mech-assembler" => ConstructorBlock::new(5, true, cost!(Carbide: 200, Thorium: 600, Oxide: 200, Tungsten: 500, Silicon: 900)); // smh collaris
+ "basic-assembler-module" => ConstructorBlock::new(5, true, cost!(Carbide: 300, Thorium: 500, Oxide: 200, PhaseFabric: 400)); // the dummy block
// payload
- "payload-conveyor" => SimpleBlock::new(3, false, cost!(Copper: 10, Graphite: 10));
+ "payload-conveyor" => ConstructorBlock::new(3, false, cost!(Copper: 10, Graphite: 10));
"payload-router" => PayloadBlock::new(3, false, cost!(Copper: 10, Graphite: 15));
- "reinforced-payload-conveyor" => SimpleBlock::new(3, false, cost!(Tungsten: 10));
- "reinforced-payload-router" => SimpleBlock::new(3, false, cost!(Tungsten: 15));
+ "reinforced-payload-conveyor" => ConstructorBlock::new(3, false, cost!(Tungsten: 10));
+ "reinforced-payload-router" => ConstructorBlock::new(3, false, cost!(Tungsten: 15));
"payload-mass-driver" => BridgeBlock::new(3, true, cost!(Tungsten: 120, Silicon: 120, Graphite: 50), 700, false);
"large-payload-mass-driver" => BridgeBlock::new(5, true, cost!(Thorium: 200, Tungsten: 200, Silicon: 200, Graphite: 100, Oxide: 30), 1100, false);
- "small-deconstructor" => SimpleBlock::new(3, true, cost!(Beryllium: 100, Silicon: 100, Oxide: 40, Graphite: 80));
- "deconstructor" => SimpleBlock::new(5, true, cost!(Beryllium: 250, Oxide: 100, Silicon: 250, Carbide: 250));
+ "small-deconstructor" => ConstructorBlock::new(3, true, cost!(Beryllium: 100, Silicon: 100, Oxide: 40, Graphite: 80));
+ "deconstructor" => ConstructorBlock::new(5, true, cost!(Beryllium: 250, Oxide: 100, Silicon: 250, Carbide: 250));
"constructor" => PayloadBlock::new(3, true, cost!(Silicon: 100, Beryllium: 150, Tungsten: 80));
"large-constructor" => PayloadBlock::new(3, true, cost!(Silicon: 150, Oxide: 150, Tungsten: 200, PhaseFabric: 40));
- "payload-loader" => SimpleBlock::new(3, false, cost!(Graphite: 50, Silicon: 50, Tungsten: 80));
- "payload-unloader" => SimpleBlock::new(3, false, cost!(Graphite: 50, Silicon: 50, Tungsten: 30));
+ "payload-loader" => ConstructorBlock::new(3, false, cost!(Graphite: 50, Silicon: 50, Tungsten: 80));
+ "payload-unloader" => ConstructorBlock::new(3, false, cost!(Graphite: 50, Silicon: 50, Tungsten: 30));
// sandbox only
"payload-source" => PayloadBlock::new(5, false, &[]);
- "payload-void" => SimpleBlock::new(5, true, &[]);
+ "payload-void" => ConstructorBlock::new(5, true, &[]);
}
pub struct AssemblerBlock {
diff --git a/src/block/power.rs b/src/block/power.rs
index ad4f520..2df3e14 100644
--- a/src/block/power.rs
+++ b/src/block/power.rs
@@ -2,14 +2,11 @@
use std::error::Error;
use std::fmt;
-use super::State;
-use crate::block::simple::{cost, state_impl, BuildCost, SimpleBlock};
-use crate::block::{
- impl_block, make_register, BlockLogic, DataConvertError, DeserializeError, SerializeError,
-};
-use crate::data::dynamic::{DynData, DynType};
-use crate::data::GridPos;
-use crate::item::storage::Storage;
+use crate::block::make_register;
+use crate::block::simple::{cost, make_simple, state_impl};
+use crate::data::dynamic::DynType;
+
+make_simple!(GeneratorBlock);
make_register! {
// illuminator == power ?????
@@ -17,31 +14,31 @@ make_register! {
"power-node" => ConnectorBlock::new(1, true, cost!(Copper: 1, Lead: 3), 10);
"power-node-large" => ConnectorBlock::new(2, true, cost!(Lead: 10, Titanium: 5, Silicon: 3), 15);
"surge-tower" => ConnectorBlock::new(2, true, cost!(Lead: 10, Titanium: 7, Silicon: 15, SurgeAlloy: 15), 2);
- "diode" => SimpleBlock::new(1, false, cost!(Metaglass: 10, Silicon: 10, Plastanium: 5));
- "battery" => SimpleBlock::new(1, true, cost!(Copper: 5, Lead: 20));
- "battery-large" => SimpleBlock::new(3, true, cost!(Lead: 50, Titanium: 20, Silicon: 30));
- "combustion-generator" => SimpleBlock::new(1, true, cost!(Copper: 25, Lead: 15));
- "thermal-generator" => SimpleBlock::new(2, true, cost!(Copper: 40, Lead: 50, Metaglass: 40, Graphite: 35, Silicon: 35));
- "steam-generator" => SimpleBlock::new(2, true, cost!(Copper: 35, Lead: 40, Graphite: 25, Silicon: 30));
- "differential-generator" => SimpleBlock::new(3, true, cost!(Copper: 70, Lead: 100, Metaglass: 50, Titanium: 50, Silicon: 65));
- "rtg-generator" => SimpleBlock::new(2, true, cost!(Lead: 100, Thorium: 50, Silicon: 75, Plastanium: 75, PhaseFabric: 25));
- "solar-panel" => SimpleBlock::new(1, true, cost!(Lead: 10, Silicon: 15));
- "solar-panel-large" => SimpleBlock::new(3, true, cost!(Lead: 80, Silicon: 110, PhaseFabric: 15));
- "thorium-reactor" => SimpleBlock::new(3, true, cost!(Lead: 300, Metaglass: 50, Graphite: 150, Thorium: 150, Silicon: 200));
- "impact-reactor" => SimpleBlock::new(4, true,
+ "diode" => GeneratorBlock::new(1, false, cost!(Metaglass: 10, Silicon: 10, Plastanium: 5));
+ "battery" => GeneratorBlock::new(1, true, cost!(Copper: 5, Lead: 20));
+ "battery-large" => GeneratorBlock::new(3, true, cost!(Lead: 50, Titanium: 20, Silicon: 30));
+ "combustion-generator" => GeneratorBlock::new(1, true, cost!(Copper: 25, Lead: 15));
+ "thermal-generator" => GeneratorBlock::new(2, true, cost!(Copper: 40, Lead: 50, Metaglass: 40, Graphite: 35, Silicon: 35));
+ "steam-generator" => GeneratorBlock::new(2, true, cost!(Copper: 35, Lead: 40, Graphite: 25, Silicon: 30));
+ "differential-generator" => GeneratorBlock::new(3, true, cost!(Copper: 70, Lead: 100, Metaglass: 50, Titanium: 50, Silicon: 65));
+ "rtg-generator" => GeneratorBlock::new(2, true, cost!(Lead: 100, Thorium: 50, Silicon: 75, Plastanium: 75, PhaseFabric: 25));
+ "solar-panel" => GeneratorBlock::new(1, true, cost!(Lead: 10, Silicon: 15));
+ "solar-panel-large" => GeneratorBlock::new(3, true, cost!(Lead: 80, Silicon: 110, PhaseFabric: 15));
+ "thorium-reactor" => GeneratorBlock::new(3, true, cost!(Lead: 300, Metaglass: 50, Graphite: 150, Thorium: 150, Silicon: 200));
+ "impact-reactor" => GeneratorBlock::new(4, true,
cost!(Lead: 500, Metaglass: 250, Graphite: 400, Thorium: 100, Silicon: 300, SurgeAlloy: 250));
"beam-node" => ConnectorBlock::new(1, true, cost!(Beryllium: 8), 4);
"beam-tower" => ConnectorBlock::new(3, true, cost!(Beryllium: 30, Oxide: 10, Silicon: 10), 12);
- "turbine-condenser" => SimpleBlock::new(3, true, cost!(Beryllium: 60));
- "chemical-combustion-chamber" => SimpleBlock::new(3, true, cost!(Graphite: 40, Tungsten: 40, Oxide: 40, Silicon: 30));
- "pyrolosis-generator" => SimpleBlock::new(3, true, cost!(Graphite: 50, Carbide: 50, Oxide: 60, Silicon: 50));
- "flux-reactor" => SimpleBlock::new(5, true, cost!(Graphite: 300, Carbide: 200, Oxide: 100, Silicon: 600, SurgeAlloy: 300));
- "neoplasia-reactor" => SimpleBlock::new(5, true, cost!(Tungsten: 1000, Carbide: 300, Oxide: 150, Silicon: 500, PhaseFabric: 300, SurgeAlloy: 200));
+ "turbine-condenser" => GeneratorBlock::new(3, true, cost!(Beryllium: 60));
+ "chemical-combustion-chamber" => GeneratorBlock::new(3, true, cost!(Graphite: 40, Tungsten: 40, Oxide: 40, Silicon: 30));
+ "pyrolosis-generator" => GeneratorBlock::new(3, true, cost!(Graphite: 50, Carbide: 50, Oxide: 60, Silicon: 50));
+ "flux-reactor" => GeneratorBlock::new(5, true, cost!(Graphite: 300, Carbide: 200, Oxide: 100, Silicon: 600, SurgeAlloy: 300));
+ "neoplasia-reactor" => GeneratorBlock::new(5, true, cost!(Tungsten: 1000, Carbide: 300, Oxide: 150, Silicon: 500, PhaseFabric: 300, SurgeAlloy: 200));
// editor only
"beam-link" => ConnectorBlock::new(3, true, &[], 12);
// sandbox only
"power-source" => ConnectorBlock::new(1, true, &[], 100);
- "power-void" => SimpleBlock::new(1, true, &[]);
+ "power-void" => GeneratorBlock::new(1, true, &[]);
}
pub struct ConnectorBlock {
size: u8,
diff --git a/src/block/production.rs b/src/block/production.rs
index ab91605..7484ab0 100644
--- a/src/block/production.rs
+++ b/src/block/production.rs
@@ -1,42 +1,44 @@
//! the industry part of mindustry
use crate::block::make_register;
-use crate::block::simple::{cost, SimpleBlock};
+use crate::block::simple::{cost, make_simple};
make_register! {
- "graphite-press" => SimpleBlock::new(2, true, cost!(Copper: 75, Lead: 30));
- "multi-press" => SimpleBlock::new(3, true, cost!(Lead: 100, Graphite: 50, Titanium: 100, Silicon: 25));
- "silicon-smelter" => SimpleBlock::new(2, true, cost!(Copper: 30, Lead: 25));
- "silicon-crucible" => SimpleBlock::new(3, true, cost!(Metaglass: 80, Titanium: 120, Silicon: 60, Plastanium: 35));
- "kiln" => SimpleBlock::new(2, true, cost!(Copper: 60, Lead: 30, Graphite: 30));
- "plastanium-compressor" => SimpleBlock::new(2, true, cost!(Lead: 115, Graphite: 60, Titanium: 80, Silicon: 80));
- "phase-weaver" => SimpleBlock::new(2, true, cost!(Lead: 120, Thorium: 75, Silicon: 130));
- "surge-smelter" => SimpleBlock::new(3, true, cost!(Lead: 80, Thorium: 70, Silicon: 80));
- "cryofluid-mixer" => SimpleBlock::new(2, true, cost!(Lead: 65, Thorium: 60, Silicon: 40));
- "pyratite-mixer" => SimpleBlock::new(2, true, cost!(Copper: 50, Lead: 25));
- "blast-mixer" => SimpleBlock::new(2, true, cost!(Lead: 30, Thorium: 20));
- "melter" => SimpleBlock::new(1, true, cost!(Copper: 30, Lead: 35, Graphite: 45));
- "separator" => SimpleBlock::new(2, true, cost!(Copper: 30, Titanium: 25));
- "disassembler" => SimpleBlock::new(3, true, cost!(Titanium: 100, Thorium: 80, Silicon: 150, Plastanium: 40));
- "spore-press" => SimpleBlock::new(2, true, cost!(Lead: 35, Silicon: 30));
- "pulverizer" => SimpleBlock::new(1, true, cost!(Copper: 30, Lead: 25));
- "coal-centrifuge" => SimpleBlock::new(2, true, cost!(Lead: 30, Graphite: 40, Titanium: 20));
- "incinerator" => SimpleBlock::new(1, true, cost!(Lead: 15, Graphite: 5));
- "silicon-arc-furnace" => SimpleBlock::new(3, true, cost!(Beryllium: 70, Graphite: 80));
- "electrolyzer" => SimpleBlock::new(3, true, cost!(Silicon: 50, Graphite: 40, Beryllium: 130, Tungsten: 80));
- "atmospheric-concentrator" => SimpleBlock::new(3, true, cost!(Oxide: 60, Beryllium: 180, Silicon: 150));
- "oxidation-chamber" => SimpleBlock::new(3, true, cost!(Tungsten: 120, Graphite: 80, Silicon: 100, Beryllium: 120));
- "electric-heater" => SimpleBlock::new(2, false, cost!(Tungsten: 30, Oxide: 30));
- "slag-heater" => SimpleBlock::new(3, false, cost!(Tungsten: 50, Oxide: 20, Beryllium: 20));
- "phase-heater" => SimpleBlock::new(2, false, cost!(Oxide: 30, Carbide: 30, Beryllium: 30));
- "heat-redirector" => SimpleBlock::new(3, false, cost!(Tungsten: 10, Graphite: 10));
- "heat-router" => SimpleBlock::new(3, false, cost!(Tungsten: 15, Graphite: 10));
- "slag-incinerator" => SimpleBlock::new(1, true, cost!(Tungsten: 15));
- "carbide-crucible" => SimpleBlock::new(3, true, cost!(Tungsten: 110, Thorium: 150, Oxide: 60));
+ "graphite-press" => ProductionBlock::new(2, true, cost!(Copper: 75, Lead: 30));
+ "multi-press" => ProductionBlock::new(3, true, cost!(Lead: 100, Graphite: 50, Titanium: 100, Silicon: 25));
+ "silicon-smelter" => ProductionBlock::new(2, true, cost!(Copper: 30, Lead: 25));
+ "silicon-crucible" => ProductionBlock::new(3, true, cost!(Metaglass: 80, Titanium: 120, Silicon: 60, Plastanium: 35));
+ "kiln" => ProductionBlock::new(2, true, cost!(Copper: 60, Lead: 30, Graphite: 30));
+ "plastanium-compressor" => ProductionBlock::new(2, true, cost!(Lead: 115, Graphite: 60, Titanium: 80, Silicon: 80));
+ "phase-weaver" => ProductionBlock::new(2, true, cost!(Lead: 120, Thorium: 75, Silicon: 130));
+ "surge-smelter" => ProductionBlock::new(3, true, cost!(Lead: 80, Thorium: 70, Silicon: 80));
+ "cryofluid-mixer" => ProductionBlock::new(2, true, cost!(Lead: 65, Thorium: 60, Silicon: 40));
+ "pyratite-mixer" => ProductionBlock::new(2, true, cost!(Copper: 50, Lead: 25));
+ "blast-mixer" => ProductionBlock::new(2, true, cost!(Lead: 30, Thorium: 20));
+ "melter" => ProductionBlock::new(1, true, cost!(Copper: 30, Lead: 35, Graphite: 45));
+ "separator" => ProductionBlock::new(2, true, cost!(Copper: 30, Titanium: 25));
+ "disassembler" => ProductionBlock::new(3, true, cost!(Titanium: 100, Thorium: 80, Silicon: 150, Plastanium: 40));
+ "spore-press" => ProductionBlock::new(2, true, cost!(Lead: 35, Silicon: 30));
+ "pulverizer" => ProductionBlock::new(1, true, cost!(Copper: 30, Lead: 25));
+ "coal-centrifuge" => ProductionBlock::new(2, true, cost!(Lead: 30, Graphite: 40, Titanium: 20));
+ "incinerator" => ProductionBlock::new(1, true, cost!(Lead: 15, Graphite: 5));
+ "silicon-arc-furnace" => ProductionBlock::new(3, true, cost!(Beryllium: 70, Graphite: 80));
+ "electrolyzer" => ProductionBlock::new(3, true, cost!(Silicon: 50, Graphite: 40, Beryllium: 130, Tungsten: 80));
+ "atmospheric-concentrator" => ProductionBlock::new(3, true, cost!(Oxide: 60, Beryllium: 180, Silicon: 150));
+ "oxidation-chamber" => ProductionBlock::new(3, true, cost!(Tungsten: 120, Graphite: 80, Silicon: 100, Beryllium: 120));
+ "electric-heater" => ProductionBlock::new(2, false, cost!(Tungsten: 30, Oxide: 30));
+ "slag-heater" => ProductionBlock::new(3, false, cost!(Tungsten: 50, Oxide: 20, Beryllium: 20));
+ "phase-heater" => ProductionBlock::new(2, false, cost!(Oxide: 30, Carbide: 30, Beryllium: 30));
+ "heat-redirector" => ProductionBlock::new(3, false, cost!(Tungsten: 10, Graphite: 10));
+ "heat-router" => ProductionBlock::new(3, false, cost!(Tungsten: 15, Graphite: 10));
+ "slag-incinerator" => ProductionBlock::new(1, true, cost!(Tungsten: 15));
+ "carbide-crucible" => ProductionBlock::new(3, true, cost!(Tungsten: 110, Thorium: 150, Oxide: 60));
// slag centrifuge
- "surge-crucible" => SimpleBlock::new(3, true, cost!(Silicon: 100, Graphite: 80, Tungsten: 80, Oxide: 80));
- "cyanogen-synthesizer" => SimpleBlock::new(3, true, cost!(Carbide: 50, Silicon: 80, Beryllium: 90));
- "phase-synthesizer" => SimpleBlock::new(3, true, cost!(Carbide: 90, Silicon: 100, Thorium: 100, Tungsten: 200));
+ "surge-crucible" => ProductionBlock::new(3, true, cost!(Silicon: 100, Graphite: 80, Tungsten: 80, Oxide: 80));
+ "cyanogen-synthesizer" => ProductionBlock::new(3, true, cost!(Carbide: 50, Silicon: 80, Beryllium: 90));
+ "phase-synthesizer" => ProductionBlock::new(3, true, cost!(Carbide: 90, Silicon: 100, Thorium: 100, Tungsten: 200));
// heat reactor
// sandbox only
- "heat-source" => SimpleBlock::new(1, false, &[]);
+ "heat-source" => ProductionBlock::new(1, false, &[]);
}
+
+make_simple!(ProductionBlock);
diff --git a/src/block/simple.rs b/src/block/simple.rs
index 546f36b..c78eb0e 100644
--- a/src/block/simple.rs
+++ b/src/block/simple.rs
@@ -1,101 +1,96 @@
//! type used for basic blocks, eg turrets and factorys
-use std::any::type_name;
-
-use super::State;
-use crate::block::{impl_block, BlockLogic, DataConvertError, DeserializeError, SerializeError};
-use crate::data::dynamic::DynData;
-use crate::data::renderer::{load, read};
-use crate::data::GridPos;
use crate::item;
-use crate::item::storage::Storage;
macro_rules! state_impl {
- ($vis:vis $type:ty) =>
- {
+ ($vis:vis $type:ty) => {
$vis fn get_state(state: &$crate::block::State) -> &$type
- where Self: Sized
- {
+ where Self: Sized {
state.downcast_ref::<$type>().unwrap()
}
$vis fn get_state_mut(state: &mut $crate::block::State) -> &mut $type
- where Self: Sized
- {
+ where Self: Sized {
state.downcast_mut::<$type>().unwrap()
}
fn create_state(val: $type) -> $crate::block::State
- where Self: Sized
- {
+ where Self: Sized {
Box::new(val)
}
};
}
-use image::RgbaImage;
-pub(crate) use state_impl;
-pub type BuildCost = &'static [(item::Type, u32)];
-
-pub struct SimpleBlock {
- size: u8,
- symmetric: bool,
- build_cost: BuildCost,
-}
+pub(crate) use state_impl;
-impl SimpleBlock {
- #[must_use]
- pub const fn new(size: u8, symmetric: bool, build_cost: BuildCost) -> Self {
- assert!(size != 0, "invalid size");
- Self {
- size,
- symmetric,
- build_cost,
+macro_rules! make_simple {
+ ($name: ident, $draw: expr) => {
+ pub struct $name {
+ size: u8,
+ symmetric: bool,
+ build_cost: BuildCost,
}
- }
-}
-
-impl BlockLogic for SimpleBlock {
- impl_block!();
-
- fn data_from_i32(&self, _: i32, _: GridPos) -> Result<DynData, DataConvertError> {
- Ok(DynData::Empty)
- }
-
- fn deserialize_state(&self, _: DynData) -> Result<Option<State>, DeserializeError> {
- Ok(None)
- }
-
- fn clone_state(&self, _: &State) -> State {
- panic!("{} has no custom state", type_name::<Self>())
- }
-
- fn mirror_state(&self, _: &mut State, _: bool, _: bool) {
- panic!("{} has no custom state", type_name::<Self>());
- }
-
- fn rotate_state(&self, _: &mut State, _: bool) {
- panic!("{} has no custom state", type_name::<Self>());
- }
-
- fn serialize_state(&self, _: &State) -> Result<DynData, SerializeError> {
- Ok(DynData::Empty)
- }
-
- fn draw(&self, category: &str, name: &str, _: Option<&State>) -> Option<RgbaImage> {
- if category != "turrets" {
- return None;
+ impl $name {
+ #[must_use]
+ pub const fn new(size: u8, symmetric: bool, build_cost: BuildCost) -> Self {
+ assert!(size != 0, "invalid size");
+ Self {
+ size,
+ symmetric,
+ build_cost,
+ }
+ }
}
- let path = match name {
- "breach" | "diffuse" | "sublimate" | "titan" | "disperse" | "afflict" | "lustre"
- | "scathe" | "malign" => format!("bases/reinforced-block-{}", self.size),
- _ => format!("bases/block-{}", self.size),
+
+ use crate::block::{
+ impl_block, simple::BuildCost, BlockLogic, DataConvertError, DeserializeError,
+ SerializeError, State,
};
- let mut base = load(category, &path).unwrap();
- let top = read(category, name, self.size);
- image::imageops::overlay(&mut base, &top, 0, 0);
- Some(base)
- }
+ use crate::data::dynamic::DynData;
+ use crate::data::GridPos;
+ impl BlockLogic for $name {
+ impl_block!();
+
+ fn data_from_i32(&self, _: i32, _: GridPos) -> Result<DynData, DataConvertError> {
+ Ok(DynData::Empty)
+ }
+
+ fn deserialize_state(&self, _: DynData) -> Result<Option<State>, DeserializeError> {
+ Ok(None)
+ }
+
+ fn clone_state(&self, _: &State) -> State {
+ panic!("{} has no custom state", stringify!($name))
+ }
+
+ fn mirror_state(&self, _: &mut State, _: bool, _: bool) {
+ panic!("{} has no custom state", stringify!($name));
+ }
+
+ fn rotate_state(&self, _: &mut State, _: bool) {
+ panic!("{} has no custom state", stringify!($name));
+ }
+
+ fn serialize_state(&self, _: &State) -> Result<DynData, SerializeError> {
+ Ok(DynData::Empty)
+ }
+
+ fn draw(
+ &self,
+ category: &str,
+ name: &str,
+ state: Option<&State>,
+ ) -> Option<image::RgbaImage> {
+ $draw(self, category, name, state)
+ }
+ }
+ };
+ ($name: ident) => {
+ crate::block::simple::make_simple!($name, |_, _, _, _| { None });
+ };
}
+pub(crate) use make_simple;
+
+pub type BuildCost = &'static [(item::Type, u32)];
macro_rules! cost {
($($item:ident: $cnt:expr),+) => {
diff --git a/src/block/storage.rs b/src/block/storage.rs
index db93403..b64a0cd 100644
--- a/src/block/storage.rs
+++ b/src/block/storage.rs
@@ -1,18 +1,20 @@
//! cores, vaults, containers
use crate::block::distribution::ItemBlock;
use crate::block::make_register;
-use crate::block::simple::{cost, SimpleBlock};
+use crate::block::simple::{cost, make_simple};
make_register! {
- "core-shard" => SimpleBlock::new(3, true, cost!(Copper: 1000, Lead: 800));
- "core-foundation" => SimpleBlock::new(4, true, cost!(Copper: 3000, Lead: 3000, Silicon: 2000));
- "core-nucleus" => SimpleBlock::new(5, true, cost!(Copper: 8000, Lead: 8000, Thorium: 4000, Silicon: 5000));
- "core-bastion" => SimpleBlock::new(4, true, cost!(Graphite: 1000, Silicon: 1000, Beryllium: 800));
- "core-citadel" => SimpleBlock::new(5, true, cost!(Silicon: 4000, Beryllium: 4000, Tungsten: 3000, Oxide: 1000));
- "core-acropolis" => SimpleBlock::new(6, true, cost!(Beryllium: 6000, Silicon: 5000, Tungsten: 5000, Carbide: 3000, Oxide: 3000));
- "container" => SimpleBlock::new(2, true, cost!(Titanium: 100));
- "vault" => SimpleBlock::new(3, true, cost!(Titanium: 250, Thorium: 125));
+ "core-shard" => StorageBlock::new(3, true, cost!(Copper: 1000, Lead: 800));
+ "core-foundation" => StorageBlock::new(4, true, cost!(Copper: 3000, Lead: 3000, Silicon: 2000));
+ "core-nucleus" => StorageBlock::new(5, true, cost!(Copper: 8000, Lead: 8000, Thorium: 4000, Silicon: 5000));
+ "core-bastion" => StorageBlock::new(4, true, cost!(Graphite: 1000, Silicon: 1000, Beryllium: 800));
+ "core-citadel" => StorageBlock::new(5, true, cost!(Silicon: 4000, Beryllium: 4000, Tungsten: 3000, Oxide: 1000));
+ "core-acropolis" => StorageBlock::new(6, true, cost!(Beryllium: 6000, Silicon: 5000, Tungsten: 5000, Carbide: 3000, Oxide: 3000));
+ "container" => StorageBlock::new(2, true, cost!(Titanium: 100));
+ "vault" => StorageBlock::new(3, true, cost!(Titanium: 250, Thorium: 125));
"unloader" => ItemBlock::new(1, true, cost!(Titanium: 25, Silicon: 30));
- "reinforced-container" => SimpleBlock::new(2, true, cost!(Tungsten: 30, Graphite: 40));
- "reinforced-vault" => SimpleBlock::new(3, true, cost!(Tungsten: 125, Thorium: 70, Beryllium: 100));
+ "reinforced-container" => StorageBlock::new(2, true, cost!(Tungsten: 30, Graphite: 40));
+ "reinforced-vault" => StorageBlock::new(3, true, cost!(Tungsten: 125, Thorium: 70, Beryllium: 100));
}
+
+make_simple!(StorageBlock);
diff --git a/src/block/turrets.rs b/src/block/turrets.rs
index 1f1d99a..5aeaeaa 100644
--- a/src/block/turrets.rs
+++ b/src/block/turrets.rs
@@ -1,33 +1,46 @@
//! idk why its not in the [crate::block::defense] module
use crate::block::make_register;
-use crate::block::simple::{cost, SimpleBlock};
+use crate::block::simple::cost;
make_register! {
- "duo" => SimpleBlock::new(1, true, cost!(Copper: 35));
- "scatter" => SimpleBlock::new(2, true, cost!(Copper: 85, Lead: 45));
- "scorch" => SimpleBlock::new(1, true, cost!(Copper: 25, Graphite: 22));
- "hail" => SimpleBlock::new(1, true, cost!(Copper: 40, Graphite: 17));
- "wave" => SimpleBlock::new(2, true, cost!(Copper: 25, Lead: 75, Metaglass: 45));
- "lancer" => SimpleBlock::new(2, true, cost!(Copper: 60, Lead: 70, Titanium: 30, Silicon: 60));
- "arc" => SimpleBlock::new(1, true, cost!(Copper: 50, Lead: 50));
- "parallax" => SimpleBlock::new(2, true, cost!(Graphite: 30, Titanium: 90, Silicon: 120));
- "swarmer" => SimpleBlock::new(2, true, cost!(Graphite: 35, Titanium: 35, Silicon: 30, Plastanium: 45));
- "salvo" => SimpleBlock::new(2, true, cost!(Copper: 100, Graphite: 80, Titanium: 50));
- "segment" => SimpleBlock::new(2, true, cost!(Titanium: 40, Thorium: 80, Silicon: 130, PhaseFabric: 40));
- "tsunami" => SimpleBlock::new(3, true, cost!(Lead: 400, Metaglass: 100, Titanium: 250, Thorium: 100));
- "fuse" => SimpleBlock::new(3, true, cost!(Copper: 225, Graphite: 225, Thorium: 100));
- "ripple" => SimpleBlock::new(3, true, cost!(Copper: 150, Graphite: 135, Titanium: 60));
- "cyclone" => SimpleBlock::new(3, true, cost!(Copper: 200, Titanium: 125, Plastanium: 80));
- "foreshadow" => SimpleBlock::new(4, true, cost!(Copper: 1000, Metaglass: 600, Silicon: 600, Plastanium: 200, SurgeAlloy: 300));
- "spectre" => SimpleBlock::new(4, true, cost!(Copper: 900, Graphite: 300, Thorium: 250, Plastanium: 175, SurgeAlloy: 250));
- "meltdown" => SimpleBlock::new(4, true, cost!(Copper: 1200, Lead: 350, Graphite: 300, Silicon: 325, SurgeAlloy: 325));
- "breach" => SimpleBlock::new(3, true, cost!(Beryllium: 150, Silicon: 150, Graphite: 250));
- "diffuse" => SimpleBlock::new(3, true, cost!(Beryllium: 150, Silicon: 200, Graphite: 200, Tungsten: 50));
- "sublimate" => SimpleBlock::new(3, true, cost!(Tungsten: 150, Silicon: 200, Oxide: 40, Beryllium: 400));
- "titan" => SimpleBlock::new(4, true, cost!(Tungsten: 250, Silicon: 300, Thorium: 400));
- "disperse" => SimpleBlock::new(4, true, cost!(Thorium: 50, Oxide: 150, Silicon: 200, Beryllium: 350));
- "afflict" => SimpleBlock::new(4, true, cost!(SurgeAlloy: 100, Silicon: 200, Graphite: 250, Oxide: 40));
- "lustre" => SimpleBlock::new(4, true, cost!(Silicon: 250, Graphite: 200, Oxide: 50, Carbide: 90));
- "scathe" => SimpleBlock::new(5, true, cost!(Oxide: 200, SurgeAlloy: 400, Silicon: 800, Carbide: 500, PhaseFabric: 300));
- "malign" => SimpleBlock::new(5, true, cost!(Carbide: 400, Beryllium: 2000, Silicon: 800, Graphite: 800, PhaseFabric: 300));
+ "duo" => TurretBlock::new(1, true, cost!(Copper: 35));
+ "scatter" => TurretBlock::new(2, true, cost!(Copper: 85, Lead: 45));
+ "scorch" => TurretBlock::new(1, true, cost!(Copper: 25, Graphite: 22));
+ "hail" => TurretBlock::new(1, true, cost!(Copper: 40, Graphite: 17));
+ "wave" => TurretBlock::new(2, true, cost!(Copper: 25, Lead: 75, Metaglass: 45));
+ "lancer" => TurretBlock::new(2, true, cost!(Copper: 60, Lead: 70, Titanium: 30, Silicon: 60));
+ "arc" => TurretBlock::new(1, true, cost!(Copper: 50, Lead: 50));
+ "parallax" => TurretBlock::new(2, true, cost!(Graphite: 30, Titanium: 90, Silicon: 120));
+ "swarmer" => TurretBlock::new(2, true, cost!(Graphite: 35, Titanium: 35, Silicon: 30, Plastanium: 45));
+ "salvo" => TurretBlock::new(2, true, cost!(Copper: 100, Graphite: 80, Titanium: 50));
+ "segment" => TurretBlock::new(2, true, cost!(Titanium: 40, Thorium: 80, Silicon: 130, PhaseFabric: 40));
+ "tsunami" => TurretBlock::new(3, true, cost!(Lead: 400, Metaglass: 100, Titanium: 250, Thorium: 100));
+ "fuse" => TurretBlock::new(3, true, cost!(Copper: 225, Graphite: 225, Thorium: 100));
+ "ripple" => TurretBlock::new(3, true, cost!(Copper: 150, Graphite: 135, Titanium: 60));
+ "cyclone" => TurretBlock::new(3, true, cost!(Copper: 200, Titanium: 125, Plastanium: 80));
+ "foreshadow" => TurretBlock::new(4, true, cost!(Copper: 1000, Metaglass: 600, Silicon: 600, Plastanium: 200, SurgeAlloy: 300));
+ "spectre" => TurretBlock::new(4, true, cost!(Copper: 900, Graphite: 300, Thorium: 250, Plastanium: 175, SurgeAlloy: 250));
+ "meltdown" => TurretBlock::new(4, true, cost!(Copper: 1200, Lead: 350, Graphite: 300, Silicon: 325, SurgeAlloy: 325));
+ "breach" => TurretBlock::new(3, true, cost!(Beryllium: 150, Silicon: 150, Graphite: 250));
+ "diffuse" => TurretBlock::new(3, true, cost!(Beryllium: 150, Silicon: 200, Graphite: 200, Tungsten: 50));
+ "sublimate" => TurretBlock::new(3, true, cost!(Tungsten: 150, Silicon: 200, Oxide: 40, Beryllium: 400));
+ "titan" => TurretBlock::new(4, true, cost!(Tungsten: 250, Silicon: 300, Thorium: 400));
+ "disperse" => TurretBlock::new(4, true, cost!(Thorium: 50, Oxide: 150, Silicon: 200, Beryllium: 350));
+ "afflict" => TurretBlock::new(4, true, cost!(SurgeAlloy: 100, Silicon: 200, Graphite: 250, Oxide: 40));
+ "lustre" => TurretBlock::new(4, true, cost!(Silicon: 250, Graphite: 200, Oxide: 50, Carbide: 90));
+ "scathe" => TurretBlock::new(5, true, cost!(Oxide: 200, SurgeAlloy: 400, Silicon: 800, Carbide: 500, PhaseFabric: 300));
+ "malign" => TurretBlock::new(5, true, cost!(Carbide: 400, Beryllium: 2000, Silicon: 800, Graphite: 800, PhaseFabric: 300));
}
+
+use crate::data::renderer::load;
+crate::block::simple::make_simple!(TurretBlock, |me: &Self, _, name, _| {
+ let path = match name {
+ "breach" | "diffuse" | "sublimate" | "titan" | "disperse" | "afflict" | "lustre"
+ | "scathe" | "malign" => format!("bases/reinforced-block-{}", me.size),
+ _ => format!("bases/block-{}", me.size),
+ };
+ let mut base = load("turrets", &path).unwrap();
+ let top = load("turrets", name).unwrap();
+ image::imageops::overlay(&mut base, &top, 0, 0);
+ Some(base)
+});
diff --git a/src/block/walls.rs b/src/block/walls.rs
index 25dc4f2..1b6f25a 100644
--- a/src/block/walls.rs
+++ b/src/block/walls.rs
@@ -1,42 +1,46 @@
//! walls
-use super::State;
-use crate::block::simple::{cost, state_impl, BuildCost, SimpleBlock};
-use crate::block::{
- impl_block, make_register, BlockLogic, DataConvertError, DeserializeError, SerializeError,
-};
-use crate::data::dynamic::{DynData, DynType};
-use crate::data::GridPos;
-use crate::item::storage::Storage;
+use crate::block::make_register;
+use crate::block::simple::{cost, make_simple, state_impl};
+use crate::data::dynamic::DynType;
+use crate::data::renderer::{load, read_with, TOP};
+
+make_simple!(WallBlock, |_, _, name, _| {
+ if name == "thruster" {
+ const SFX: &[&str; 1] = &[TOP];
+ return Some(read_with("turrets", "thruster", SFX, 4u32));
+ }
+ Some(load("walls", name).unwrap())
+});
make_register! {
- "copper-wall" => SimpleBlock::new(1, true, cost!(Copper: 6));
- "copper-wall-large" => SimpleBlock::new(2, true, cost!(Copper: 6 * 4));
- "titanium-wall" => SimpleBlock::new(1, true, cost!(Titanium: 6));
- "titanium-wall-large" => SimpleBlock::new(2, true, cost!(Titanium: 6 * 4));
- "plastanium-wall" => SimpleBlock::new(1, true, cost!(Metaglass: 2, Plastanium: 5));
- "plastanium-wall-large" => SimpleBlock::new(2, true, cost!(Metaglass: 2 * 4, Plastanium: 5 * 4));
- "thorium-wall" => SimpleBlock::new(1, true, cost!(Thorium: 6));
- "thorium-wall-large" => SimpleBlock::new(2, true, cost!(Thorium: 6 * 4));
- "phase-wall" => SimpleBlock::new(1, true, cost!(PhaseFabric: 6));
- "phase-wall-large" => SimpleBlock::new(2, true, cost!(PhaseFabric: 6 * 4));
- "surge-wall" => SimpleBlock::new(1, true, cost!(SurgeAlloy: 6));
- "surge-wall-large" => SimpleBlock::new(2, true, cost!(SurgeAlloy: 6 * 4));
+ "copper-wall" => WallBlock::new(1, true, cost!(Copper: 6));
+ "copper-wall-large" => WallBlock::new(2, true, cost!(Copper: 6 * 4));
+ "titanium-wall" => WallBlock::new(1, true, cost!(Titanium: 6));
+ "titanium-wall-large" => WallBlock::new(2, true, cost!(Titanium: 6 * 4));
+ "plastanium-wall" => WallBlock::new(1, true, cost!(Metaglass: 2, Plastanium: 5));
+ "plastanium-wall-large" => WallBlock::new(2, true, cost!(Metaglass: 2 * 4, Plastanium: 5 * 4));
+ "thorium-wall" => WallBlock::new(1, true, cost!(Thorium: 6));
+ "thorium-wall-large" => WallBlock::new(2, true, cost!(Thorium: 6 * 4));
+ "phase-wall" => WallBlock::new(1, true, cost!(PhaseFabric: 6));
+ "phase-wall-large" => WallBlock::new(2, true, cost!(PhaseFabric: 6 * 4));
+ "surge-wall" => WallBlock::new(1, true, cost!(SurgeAlloy: 6));
+ "surge-wall-large" => WallBlock::new(2, true, cost!(SurgeAlloy: 6 * 4));
"door" => DoorBlock::new(1, true, cost!(Titanium: 6, Silicon: 4));
"door-large" => DoorBlock::new(2, true, cost!(Titanium: 6 * 4, Silicon: 4 * 4));
- "tungsten-wall" => SimpleBlock::new(1, true, cost!(Tungsten: 6));
- "large-tungsten-wall" => SimpleBlock::new(2, true, cost!(Tungsten: 6 * 4));
+ "tungsten-wall" => WallBlock::new(1, true, cost!(Tungsten: 6));
+ "large-tungsten-wall" => WallBlock::new(2, true, cost!(Tungsten: 6 * 4));
"blast-door" => DoorBlock::new(2, true, cost!(Tungsten: 24, Silicon: 24));
- "reinforced-surge-wall" => SimpleBlock::new(1, true, cost!(SurgeAlloy: 6, Tungsten: 2));
- "reinforced-surge-wall-large" => SimpleBlock::new(2, true, cost!(SurgeAlloy: 6 * 4, Tungsten: 2 * 4));
- "carbide-wall" => SimpleBlock::new(1, true, cost!(Thorium: 6, Carbide: 6));
- "carbide-wall-large" => SimpleBlock::new(2, true, cost!(Thorium: 6 * 4, Carbide: 6 * 4));
- "shielded-wall" => SimpleBlock::new(2, true, cost!(PhaseFabric: 20, SurgeAlloy: 12, Beryllium: 12));
+ "reinforced-surge-wall" => WallBlock::new(1, true, cost!(SurgeAlloy: 6, Tungsten: 2));
+ "reinforced-surge-wall-large" => WallBlock::new(2, true, cost!(SurgeAlloy: 6 * 4, Tungsten: 2 * 4));
+ "carbide-wall" => WallBlock::new(1, true, cost!(Thorium: 6, Carbide: 6));
+ "carbide-wall-large" => WallBlock::new(2, true, cost!(Thorium: 6 * 4, Carbide: 6 * 4));
+ "shielded-wall" => WallBlock::new(2, true, cost!(PhaseFabric: 20, SurgeAlloy: 12, Beryllium: 12));
// sandbox only
- "scrap-wall" => SimpleBlock::new(1, true, cost!(Scrap: 6));
- "scrap-wall-large" => SimpleBlock::new(2, true, cost!(Scrap: 24));
- "scrap-wall-huge" => SimpleBlock::new(3, true, cost!(Scrap: 54));
- "scrap-wall-gigantic" => SimpleBlock::new(4, true, cost!(Scrap: 96));
- "thruster" => SimpleBlock::new(4, false, cost!(Scrap: 96));
+ "scrap-wall" => WallBlock::new(1, true, cost!(Scrap: 6));
+ "scrap-wall-large" => WallBlock::new(2, true, cost!(Scrap: 24));
+ "scrap-wall-huge" => WallBlock::new(3, true, cost!(Scrap: 54));
+ "scrap-wall-gigantic" => WallBlock::new(4, true, cost!(Scrap: 96));
+ "thruster" => WallBlock::new(4, false, cost!(Scrap: 96));
}
pub struct DoorBlock {
diff --git a/src/data/renderer.rs b/src/data/renderer.rs
index f01c58a..e6cbe2b 100644
--- a/src/data/renderer.rs
+++ b/src/data/renderer.rs
@@ -30,16 +30,28 @@ fn load_zip() {
zip.extract("target/out").unwrap();
}
}
-
-const SUFFIXES: &[&str; 10] = &[
- "-bottom", "-mid", "", "-base", "-left", "-right", "-rotator", "-weave", "-top", "-over",
+pub const TOP: &str = "-top";
+const SUFFIXES: &[&str; 8] = &[
+ "-bottom", "-mid", "", "-base", "-left", "-right", TOP, "-over",
];
pub(crate) fn read<S>(category: &str, name: &str, size: S) -> RgbaImage
where
S: Into<u32> + Copy,
{
+ read_with(category, name, SUFFIXES, size)
+}
+
+pub(crate) fn read_with<S>(
+ category: &str,
+ name: &str,
+ suffixes: &'static [&'static str],
+ size: S,
+) -> RgbaImage
+where
+ S: Into<u32> + Copy,
+{
let mut c = RgbaImage::new(size.into() * 32, size.into() * 32);
- for suffix in SUFFIXES {
+ for suffix in suffixes {
if let Some(p) = load(category, &format!("{name}{suffix}")) {
image::imageops::overlay(&mut c, &p, 0, 0);
}
diff --git a/src/data/schematic.rs b/src/data/schematic.rs
index d2b8aec..5465498 100644
--- a/src/data/schematic.rs
+++ b/src/data/schematic.rs
@@ -42,18 +42,12 @@ impl<'l> Placement<'l> {
/// gets the current state of this placement. you can cast it with `placement.block::get_state(placement.get_state()?)?`
#[must_use]
pub fn get_state(&self) -> Option<&State> {
- match self.state {
- None => None,
- Some(ref b) => Some(b),
- }
+ self.state.as_ref()
}
/// get mutable state.
pub fn get_state_mut(&mut self) -> Option<&mut State> {
- match self.state {
- None => None,
- Some(ref mut b) => Some(b),
- }
+ self.state.as_mut()
}
/// draws this placement in particular