diff --git a/src/mw/MechanicalWarfare.java b/src/mw/MechanicalWarfare.java index 8685e282..14db2de9 100644 --- a/src/mw/MechanicalWarfare.java +++ b/src/mw/MechanicalWarfare.java @@ -11,6 +11,11 @@ public class MechanicalWarfare extends Mod{ new MWBlocks() }; + @Override + public void init(){ + // TODO create sounds + } + @Override public void loadContent(){ for(ContentList list : contents){ diff --git a/src/mw/content/MWBlocks.java b/src/mw/content/MWBlocks.java index 5f2473b0..744fdf77 100644 --- a/src/mw/content/MWBlocks.java +++ b/src/mw/content/MWBlocks.java @@ -3,8 +3,14 @@ import mindustry.content.*; import mindustry.ctype.*; import mindustry.graphics.*; +import mindustry.type.*; import mindustry.world.*; +import mindustry.world.blocks.defense.*; +import mindustry.world.blocks.distribution.*; import mindustry.world.blocks.environment.*; +import mw.world.blocks.defense.*; + +import static mindustry.type.ItemStack.*; public class MWBlocks implements ContentList{ public static Block @@ -13,7 +19,13 @@ public class MWBlocks implements ContentList{ lava, contaminatedWater, deepContaminatedWater, darksandContaminatedWater, sandContaminatedWater, //ores - oreIron, oreAluminum, oreUranium; + oreIron, oreAluminum, oreUranium, + + //defense + insulatorWall, insulatorWallLarge, reinforcedWall, reinforcedWallLarge, steelWall, steelWallLarge, + + //transport + aluminumConveyor, ironConveyor; @Override public void load(){ @@ -63,6 +75,8 @@ public void load(){ }}; darksandContaminatedWater = new ShallowLiquid("darksand-contaminated-water"){{ + set(contaminatedWater, Blocks.darksand); + liquidDrop = MWLiquids.contaminatedWater; speedMultiplier = 0.5f; variants = 0; @@ -74,11 +88,11 @@ public void load(){ blendGroup = contaminatedWater; cacheLayer = CacheLayer.water; albedo = 0.5f; - - set(contaminatedWater, Blocks.darksand); }}; sandContaminatedWater = new ShallowLiquid("sand-contaminated-water"){{ + set(contaminatedWater, Blocks.sand); + liquidDrop = MWLiquids.contaminatedWater; speedMultiplier = 0.5f; variants = 0; @@ -90,8 +104,6 @@ public void load(){ blendGroup = contaminatedWater; cacheLayer = CacheLayer.water; albedo = 0.5f; - - set(contaminatedWater, Blocks.sand); }}; //end region @@ -115,6 +127,38 @@ public void load(){ oreScale = 25.828543f; }}; + //end region + //region defense + + insulatorWall = new InsulatorWall("insulator-wall"){{ + requirements(Category.defense, with(MWItems.insulationPlate, 1)); + + health = 1000; + solid = true; + sync = true; + update = true; + powerProduction = 2; + }}; + + //end region + //region transport + + aluminumConveyor = new Conveyor("aluminum-conveyor"){{ + requirements(Category.distribution, with(Items.copper, 1, Items.lead, 1, MWItems.aluminum, 1)); + + health = 15; + speed = 0.123f; + displayedSpeed = 16f; + }}; + + ironConveyor = new Conveyor("iron-conveyor"){{ + requirements(Category.distribution, with(Items.copper, 1, Items.lead, 1, MWItems.aluminum, 1)); + + health = 55; + speed = 0.0538f; + displayedSpeed = 7f; + }}; + //end region } } diff --git a/src/mw/world/blocks/defense/InsulatorWall.java b/src/mw/world/blocks/defense/InsulatorWall.java new file mode 100644 index 00000000..35f3b5a9 --- /dev/null +++ b/src/mw/world/blocks/defense/InsulatorWall.java @@ -0,0 +1,68 @@ +package mw.world.blocks.defense; + +import arc.*; +import arc.math.*; +import arc.struct.*; +import arc.util.*; +import mindustry.entities.bullet.*; +import mindustry.gen.*; +import mindustry.graphics.*; +import mindustry.ui.*; +import mindustry.world.blocks.defense.*; + +public class InsulatorWall extends Wall{ + /** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */ + public float powerProduction = 2f; + /** The amount of production efficiency multiplier depends on the bullet type */ + public float energyMultiplier = 15f; + /** The bullet types which will multiply production efficiency */ + public Seq> multipliedTypes = Seq.with( + LightningBulletType.class, + LaserBulletType.class, + ContinuousLaserBulletType.class + ); + + public InsulatorWall(String name){ + super(name); + insulated = true; + flashHit = true; + consumesPower = false; + outputsPower = true; + hasPower = true; + } + + @Override + public void setBars(){ + super.setBars(); + + if(hasPower && outputsPower && !consumes.hasPower()){ + bars.add("power", (InsulatorWallBuild entity) -> new Bar(() -> + Core.bundle.format("bar.poweroutput", + Strings.fixed(entity.getPowerProduction() * 60 * entity.timeScale(), 1)), + () -> Pal.powerBar, + () -> entity.productionEfficiency)); + } + } + + public class InsulatorWallBuild extends WallBuild{ + public float productionEfficiency = 0.0f; + + @Override + public void updateTile(){ + super.updateTile(); + + productionEfficiency = Mathf.lerpDelta(productionEfficiency, 0f, 0.05f); + } + + @Override + public boolean collision(Bullet bullet){ + if(multipliedTypes.contains(bullet.type.getClass())){ + productionEfficiency += bullet.damage() / 150f * energyMultiplier; + }else{ + productionEfficiency += bullet.damage() / 150f; + } + + return super.collision(bullet); + } + } +}