This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d017413
commit 2920f16
Showing
3 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |