Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
insulator wall
Browse files Browse the repository at this point in the history
  • Loading branch information
GlennFolker committed Oct 11, 2020
1 parent d017413 commit 2920f16
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/mw/MechanicalWarfare.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
54 changes: 49 additions & 5 deletions src/mw/content/MWBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(){
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -90,8 +104,6 @@ public void load(){
blendGroup = contaminatedWater;
cacheLayer = CacheLayer.water;
albedo = 0.5f;

set(contaminatedWater, Blocks.sand);
}};

//end region
Expand All @@ -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
}
}
68 changes: 68 additions & 0 deletions src/mw/world/blocks/defense/InsulatorWall.java
Original file line number Diff line number Diff line change
@@ -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<Class<?>> 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);
}
}
}

0 comments on commit 2920f16

Please sign in to comment.