Merge branch 'master' of https://github.com/Anuken/Mindustry into maps

 Conflicts:
	core/assets/bundles/bundle_fi.properties
	core/assets/bundles/bundle_th.properties
This commit is contained in:
Epowerj
2022-07-11 17:14:39 -04:00
102 changed files with 2046 additions and 1465 deletions

View File

@@ -12,7 +12,6 @@ import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.storage.*;
import mindustry.world.meta.*;
@@ -153,7 +152,7 @@ public class Pathfinder implements Runnable{
/** Packs a tile into its internal representation. */
public int packTile(Tile tile){
boolean nearLiquid = false, nearSolid = false, nearGround = false, solid = tile.solid() || tile.block() instanceof ConstructBlock, allDeep = tile.floor().isDeep();
boolean nearLiquid = false, nearSolid = false, nearGround = false, solid = tile.solid(), allDeep = tile.floor().isDeep();
for(int i = 0; i < 4; i++){
Tile other = tile.nearby(i);

View File

@@ -200,7 +200,12 @@ public class WaveSpawner{
/** Applies the standard wave spawn effects to a unit - invincibility, unmoving. */
public void spawnEffect(Unit unit){
unit.rotation = unit.angleTo(world.width()/2f * tilesize, world.height()/2f * tilesize);
spawnEffect(unit, unit.angleTo(world.width()/2f * tilesize, world.height()/2f * tilesize));
}
/** Applies the standard wave spawn effects to a unit - invincibility, unmoving. */
public void spawnEffect(Unit unit, float rotation){
unit.rotation = rotation;
unit.apply(StatusEffects.unmoving, 30f);
unit.apply(StatusEffects.invincible, 60f);
unit.add();
@@ -216,6 +221,7 @@ public class WaveSpawner{
@Remote(called = Loc.server, unreliable = true)
public static void spawnEffect(float x, float y, float rotation, UnitType u){
Fx.unitSpawn.at(x, y, rotation, u);
Time.run(30f, () -> Fx.spawn.at(x, y));

View File

@@ -92,7 +92,7 @@ public class Blocks{
//defense - erekir
radar,
buildTower,
regenProjector, barrierProjector,
regenProjector, barrierProjector, shockwaveTower,
//campaign only
shieldProjector,
largeShieldProjector,
@@ -136,7 +136,7 @@ public class Blocks{
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, foreshadow, spectre, meltdown, segment, parallax, tsunami,
//turrets - erekir
breach, diffuse, sublimate, titan, disperse, afflict, lustre, scathe, ravage,
breach, diffuse, sublimate, titan, disperse, afflict, lustre, scathe, smite, malign,
//units
groundFactory, airFactory, navalFactory,
@@ -1826,6 +1826,13 @@ public class Blocks{
consumePower(4f);
}};
shockwaveTower = new ShockwaveTower("shockwave-tower"){{
requirements(Category.effect, with(Items.surgeAlloy, 50, Items.silicon, 150, Items.oxide, 30, Items.tungsten, 100));
size = 3;
consumeLiquids(LiquidStack.with(Liquids.cyanogen, 1f / 60f));
consumePower(80f / 60f);
}};
//TODO 5x5??
shieldProjector = new BaseShield("shield-projector"){{
requirements(Category.effect, BuildVisibility.editorOnly, with());
@@ -2241,7 +2248,7 @@ public class Blocks{
requirements(Category.power, with(Items.titanium, 5, Items.lead, 10, Items.silicon, 3));
size = 2;
maxNodes = 15;
laserRange = 9.5f;
laserRange = 15f;
}};
surgeTower = new PowerNode("surge-tower"){{
@@ -2438,8 +2445,11 @@ public class Blocks{
size = 3;
ambientSound = Sounds.hum;
ambientSoundVolume = 0.06f;
spinSpeed = 0.6f;
spinners = true;
drawer = new DrawMulti(new DrawDefault(), new DrawBlurSpin("-rotator", 0.6f * 9f){{
blurThresh = 0.01f;
}});
hasLiquids = true;
outputLiquid = new LiquidStack(Liquids.water, 5f / 60f / 9f);
liquidCapacity = 20f;
@@ -4434,8 +4444,8 @@ public class Blocks{
limitRange();
}};
ravage = new ItemTurret("ravage"){{
requirements(Category.turret, with(Items.beryllium, 150, Items.silicon, 150, Items.carbide, 250, Items.phaseFabric, 100));
smite = new ItemTurret("smite"){{
requirements(Category.turret, with(Items.oxide, 200, Items.surgeAlloy, 400, Items.silicon, 800, Items.carbide, 500, Items.phaseFabric, 300));
ammo(
//this is really lazy
@@ -4443,7 +4453,6 @@ public class Blocks{
sprite = "large-orb";
width = 17f;
height = 21f;
hitSize = 7f;
hitSize = 8f;
shootEffect = new MultiEffect(Fx.shootTitan, Fx.colorSparkBig, new WaveEffect(){{
@@ -4453,7 +4462,7 @@ public class Blocks{
strokeFrom = 3f;
strokeTo = 0.3f;
}});
smokeEffect = Fx.shootSmokeRavage;
smokeEffect = Fx.shootSmokeSmite;
ammoMultiplier = 1;
pierceCap = 4;
pierce = true;
@@ -4685,7 +4694,7 @@ public class Blocks{
}
}};
shootWarmupSpeed = 0.05f;
shootWarmupSpeed = 0.04f;
shootY = 15f;
outlineColor = Pal.darkOutline;
size = 5;
@@ -4693,7 +4702,7 @@ public class Blocks{
reload = 100f;
recoil = 2f;
range = 300;
shootCone = 7f;
shootCone = 10f;
scaledHealth = 350;
rotateSpeed = 1.5f;
@@ -4701,7 +4710,333 @@ public class Blocks{
limitRange();
}};
//TODO 1 more turret
malign = new PowerTurret("malign"){{
requirements(Category.turret, with(Items.carbide, 400, Items.beryllium, 2000, Items.silicon, 800, Items.graphite, 800, Items.phaseFabric, 300));
var haloProgress = PartProgress.warmup;
Color haloColor = Color.valueOf("d370d3"), heatCol = Color.purple;
float haloY = -15f, haloRotSpeed = 1.5f;
var circleProgress = PartProgress.warmup.delay(0.9f);
var circleColor = haloColor;
float circleY = 25f, circleRad = 11f, circleRotSpeed = 3.5f, circleStroke = 1.6f;
shootType = new FlakBulletType(8f, 80f){{
sprite = "missile-large";
lifetime = 45f;
width = 12f;
height = 22f;
hitSize = 7f;
shootEffect = Fx.shootSmokeSquareBig;
smokeEffect = Fx.shootSmokeDisperse;
ammoMultiplier = 1;
hitColor = backColor = trailColor = lightningColor = circleColor;
frontColor = Color.white;
trailWidth = 3f;
trailLength = 12;
hitEffect = despawnEffect = Fx.hitBulletColor;
buildingDamageMultiplier = 0.3f;
trailEffect = Fx.colorSpark;
trailRotation = true;
trailInterval = 3f;
lightning = 1;
lightningCone = 15f;
lightningLength = 20;
lightningLengthRand = 30;
lightningDamage = 20f;
homingPower = 0.17f;
homingDelay = 19f;
homingRange = 160f;
explodeRange = 160f;
explodeDelay = 0f;
flakInterval = 20f;
despawnShake = 3f;
fragBullet = new LaserBulletType(90f){{
colors = new Color[]{haloColor.cpy().a(0.4f), haloColor, Color.white};
buildingDamageMultiplier = 0.25f;
width = 19f;
hitEffect = Fx.hitLancer;
sideAngle = 175f;
sideWidth = 1f;
sideLength = 40f;
lifetime = 22f;
drawSize = 400f;
length = 180f;
pierceCap = 2;
}};
fragSpread = fragRandomSpread = 0f;
splashDamage = 0f;
hitEffect = Fx.hitSquaresColor;
collidesGround = true;
}};
size = 5;
drawer = new DrawTurret("reinforced-"){{
parts.addAll(
//summoning circle
new ShapePart(){{
progress = circleProgress;
color = circleColor;
circle = true;
hollow = true;
stroke = 0f;
strokeTo = circleStroke;
radius = circleRad;
layer = Layer.effect;
y = circleY;
}},
new ShapePart(){{
progress = circleProgress;
rotateSpeed = -circleRotSpeed;
color = circleColor;
sides = 4;
hollow = true;
stroke = 0f;
strokeTo = circleStroke;
radius = circleRad - 1f;
layer = Layer.effect;
y = circleY;
}},
//outer squares
new ShapePart(){{
progress = circleProgress;
rotateSpeed = -circleRotSpeed;
color = circleColor;
sides = 4;
hollow = true;
stroke = 0f;
strokeTo = circleStroke;
radius = circleRad - 1f;
layer = Layer.effect;
y = circleY;
}},
//inner square
new ShapePart(){{
progress = circleProgress;
rotateSpeed = -circleRotSpeed/2f;
color = circleColor;
sides = 4;
hollow = true;
stroke = 0f;
strokeTo = 2f;
radius = 3f;
layer = Layer.effect;
y = circleY;
}},
//spikes on circle
new HaloPart(){{
progress = circleProgress;
color = circleColor;
tri = true;
shapes = 3;
triLength = 0f;
triLengthTo = 5f;
radius = 6f;
haloRadius = circleRad;
haloRotateSpeed = haloRotSpeed / 2f;
shapeRotation = 180f;
haloRotation = 180f;
layer = Layer.effect;
y = circleY;
}},
//actual turret
new RegionPart("-mouth"){{
heatColor = heatCol;
heatProgress = PartProgress.warmup;
moveY = -8f;
}},
new RegionPart("-end"){{
moveY = 0f;
}},
new RegionPart("-front"){{
heatColor = heatCol;
heatProgress = PartProgress.warmup;
mirror = true;
moveRot = 33f;
moveY = -4f;
moveX = 10f;
}},
new RegionPart("-back"){{
heatColor = heatCol;
heatProgress = PartProgress.warmup;
mirror = true;
moveRot = 10f;
moveX = 2f;
moveY = 5f;
}},
new RegionPart("-mid"){{
heatColor = heatCol;
heatProgress = PartProgress.recoil;
moveY = -9.5f;
}},
new ShapePart(){{
progress = haloProgress;
color = haloColor;
circle = true;
hollow = true;
stroke = 0f;
strokeTo = 2f;
radius = 10f;
layer = Layer.effect;
y = haloY;
}},
new ShapePart(){{
progress = haloProgress;
color = haloColor;
sides = 3;
rotation = 90f;
hollow = true;
stroke = 0f;
strokeTo = 2f;
radius = 4f;
layer = Layer.effect;
y = haloY;
}},
new HaloPart(){{
progress = haloProgress;
color = haloColor;
sides = 3;
shapes = 3;
hollow = true;
stroke = 0f;
strokeTo = 2f;
radius = 3f;
haloRadius = 10f + radius/2f;
haloRotateSpeed = haloRotSpeed;
layer = Layer.effect;
y = haloY;
}},
new HaloPart(){{
progress = haloProgress;
color = haloColor;
tri = true;
shapes = 3;
triLength = 0f;
triLengthTo = 10f;
radius = 6f;
haloRadius = 16f;
haloRotation = 180f;
layer = Layer.effect;
y = haloY;
}},
new HaloPart(){{
progress = haloProgress;
color = haloColor;
tri = true;
shapes = 3;
triLength = 0f;
triLengthTo = 3f;
radius = 6f;
haloRadius = 16f;
shapeRotation = 180f;
haloRotation = 180f;
layer = Layer.effect;
y = haloY;
}},
new HaloPart(){{
progress = haloProgress;
color = haloColor;
sides = 3;
tri = true;
shapes = 3;
triLength = 0f;
triLengthTo = 10f;
shapeRotation = 180f;
radius = 6f;
haloRadius = 16f;
haloRotateSpeed = -haloRotSpeed;
haloRotation = 180f / 3f;
layer = Layer.effect;
y = haloY;
}},
new HaloPart(){{
progress = haloProgress;
color = haloColor;
sides = 3;
tri = true;
shapes = 3;
triLength = 0f;
triLengthTo = 4f;
radius = 6f;
haloRadius = 16f;
haloRotateSpeed = -haloRotSpeed;
haloRotation = 180f / 3f;
layer = Layer.effect;
y = haloY;
}}
);
Color heatCol2 = heatCol.cpy().add(0.1f, 0.1f, 0.1f).mul(1.2f);
for(int i = 1; i < 4; i++){
int fi = i;
parts.add(new RegionPart("-spine"){{
outline = false;
progress = PartProgress.warmup.delay(fi / 5f);
heatProgress = PartProgress.warmup.add(p -> (Mathf.absin(3f, 0.2f) - 0.2f) * p.warmup);
mirror = true;
under = true;
layerOffset = -0.3f;
turretHeatLayer = Layer.turret - 0.2f;
moveY = 9f;
moveX = 1f + fi * 4f;
moveRot = fi * 60f - 130f;
color = Color.valueOf("bb68c3");
heatColor = heatCol2;
moves.add(new PartMove(PartProgress.recoil.delay(fi / 5f), 1f, 0f, 3f));
}});
}
}};
velocityRnd = 0.15f;
heatRequirement = 90f;
maxHeatEfficiency = 2f;
consumePower(5f);
shoot = new ShootSummon(0f, 0f, circleRad, 48f);
minWarmup = 0.96f;
shootWarmupSpeed = 0.03f;
shootY = circleY - 5f;
outlineColor = Pal.darkOutline;
envEnabled |= Env.space;
reload = 8f;
range = 370;
shootCone = 100f;
scaledHealth = 370;
rotateSpeed = 2f;
recoil = 0.5f;
recoilTime = 30f;
shake = 3f;
}};
//endregion
//region units

View File

@@ -161,7 +161,9 @@ public class ErekirTechTree{
node(regenProjector, () -> {
//TODO more tiers of build tower or "support" structures like overdrive projectors
node(buildTower, Seq.with(new OnSector(four)), () -> {
node(shockwaveTower, () -> {
});
});
});
});

View File

@@ -198,6 +198,14 @@ public class Fx{
rect(block.fullIcon, e.x, e.y);
}).layer(Layer.turret - 5f),
pointShockwave = new Effect(20, e -> {
color(e.color);
stroke(e.fout() * 2f);
Lines.circle(e.x, e.y, e.finpow() * e.rotation);
randLenVectors(e.id + 1, 8, 1f + 23f * e.finpow(), (x, y) ->
lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f));
}),
moveCommand = new Effect(20, e -> {
color(Pal.command);
stroke(e.fout() * 5f);
@@ -1611,7 +1619,7 @@ public class Fx{
}
}),
shootSmokeRavage = new Effect(70f, e -> {
shootSmokeSmite = new Effect(70f, e -> {
rand.setSeed(e.id);
for(int i = 0; i < 13; i++){
float a = e.rotation + rand.range(30f);

View File

@@ -30,7 +30,7 @@ public class Items{
cost = 1.5f;
}};
graphite = new Item("graphite", Color.valueOf("95abd9")){{
graphite = new Item("graphite", Color.valueOf("b2c6d2")){{
cost = 1f;
}};

View File

@@ -252,11 +252,11 @@ public class World{
}
public void loadSector(Sector sector){
loadSector(sector, 0);
loadSector(sector, 0, true);
}
public void loadSector(Sector sector, int seedOffset){
setSectorRules(sector);
public void loadSector(Sector sector, int seedOffset, boolean saveInfo){
setSectorRules(sector, saveInfo);
int size = sector.getSize();
loadGenerator(size, size, tiles -> {
@@ -278,14 +278,14 @@ public class World{
}
//reset rules
setSectorRules(sector);
setSectorRules(sector, saveInfo);
if(state.rules.defaultTeam.core() != null){
sector.info.spawnPosition = state.rules.defaultTeam.core().pos();
}
}
private void setSectorRules(Sector sector){
private void setSectorRules(Sector sector, boolean saveInfo){
state.map = new Map(StringMap.of("name", sector.preset == null ? sector.planet.localizedName + "; Sector " + sector.id : sector.preset.localizedName));
state.rules.sector = sector;
state.rules.weather.clear();
@@ -314,7 +314,9 @@ public class World{
sector.planet.applyRules(state.rules);
sector.info.resources = content.toSeq();
sector.info.resources.sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id)));
sector.saveInfo();
if(saveInfo){
sector.saveInfo();
}
}
public Context filterContext(Map map){

View File

@@ -93,7 +93,7 @@ public class SectorGenerateDialog extends BaseDialog{
var preset = sectorobj.preset;
sectorobj.preset = null;
world.loadSector(sectorobj, seed);
world.loadSector(sectorobj, seed, false);
sectorobj.preset = preset;

View File

@@ -6,7 +6,7 @@ import mindustry.entities.*;
import mindustry.gen.*;
public class FlakBulletType extends BasicBulletType{
public float explodeRange = 30f, explodeDelay = 5f;
public float explodeRange = 30f, explodeDelay = 5f, flakInterval = 6f;
public FlakBulletType(float speed, float damage){
super(speed, damage, "shell");
@@ -27,12 +27,12 @@ public class FlakBulletType extends BasicBulletType{
super.update(b);
//don't check for targets if primed to explode
if(b.fdata >= 0 && b.timer(2, 6)){
if(b.fdata >= 0 && b.timer(2, flakInterval)){
Units.nearbyEnemies(b.team, Tmp.r1.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> {
//fadata < 0 means it's primed to explode
if(b.fdata < 0f || !unit.checkTarget(collidesAir, collidesGround)) return;
if(unit.within(b, explodeRange)){
if(unit.within(b, explodeRange + unit.hitSize/2f)){
//mark as primed
b.fdata = -1f;
Time.run(explodeDelay, () -> {

View File

@@ -0,0 +1,26 @@
package mindustry.entities.pattern;
import arc.math.*;
import arc.util.*;
public class ShootSummon extends ShootPattern{
public float x, y, radius, spread;
public ShootSummon(float x, float y, float radius, float spread){
this.x = x;
this.y = y;
this.radius = radius;
this.spread = spread;
}
@Override
public void shoot(int totalShots, BulletHandler handler){
for(int i = 0; i < shots; i++){
Tmp.v1.trns(Mathf.random(360f), Mathf.random(radius));
handler.shoot(x + Tmp.v1.x, y + Tmp.v1.y, Mathf.range(spread), firstShotDelay + shotDelay * i);
}
}
}

View File

@@ -230,7 +230,7 @@ public class Rules{
/** If true, this team has infinite unit ammo. */
public boolean infiniteAmmo;
/** Enables "RTS" unit AI. TODO wip */
/** Enables "RTS" unit AI. */
public boolean rtsAi;
/** Minimum size of attack squads. */
public int rtsMinSquad = 4;

View File

@@ -237,7 +237,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
}
if(unitIds.length > 0 && player == Vars.player){
if(unitIds.length > 0 && player == Vars.player && !state.isPaused()){
if(teamTarget != null){
Fx.attackCommand.at(teamTarget);
}else{
@@ -257,7 +257,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
build.onCommand(target);
Fx.moveCommand.at(target);
if(!state.isPaused() && player == Vars.player){
Fx.moveCommand.at(target);
}
}
@Remote(called = Loc.server, targets = Loc.both, forward = true)
@@ -592,6 +594,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
logicCutsceneZoom = -1f;
}
if(commandBuild != null && !commandBuild.isValid()){
commandBuild = null;
}
if(!commandMode){
commandRect = false;
}

View File

@@ -715,6 +715,7 @@ public class MobileInput extends InputHandler implements GestureListener{
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid());
if(!commandMode){
commandBuild = null;
selectedUnits.clear();
}

View File

@@ -1292,7 +1292,7 @@ public class LExecutor{
if(b instanceof Floor f && tile.floor() != f && !f.isOverlay()) tile.setFloorNet(f);
}
case block -> {
if(!b.isFloor()){
if(!b.isFloor() || b == Blocks.air){
Team t = exec.team(team);
if(t == null) t = Team.derelict;
@@ -1331,8 +1331,7 @@ public class LExecutor{
if(exec.obj(type) instanceof UnitType type && !type.hidden && t != null && Units.canCreate(t, type)){
//random offset to prevent stacking
var unit = type.spawn(t, World.unconv(exec.numf(x)) + Mathf.range(0.01f), World.unconv(exec.numf(y)) + Mathf.range(0.01f));
unit.rotation = exec.numf(rotation);
spawner.spawnEffect(unit);
spawner.spawnEffect(unit, exec.numf(rotation));
exec.setobj(result, unit);
}
}

View File

@@ -11,7 +11,6 @@ import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.LCanvas.*;
import mindustry.logic.LExecutor.*;
import mindustry.type.*;
@@ -1264,7 +1263,7 @@ public class LStatements{
fields(table, unit, str -> unit = str);
if(!clear){
if(!clear && !(content.statusEffect(effect) != null && content.statusEffect(effect).permanent)){
table.add(" for ");

View File

@@ -1,8 +1,6 @@
package mindustry.mod;
import arc.struct.*;
import mindustry.world.blocks.distribution.OverflowDuct.*;
/** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */
@SuppressWarnings("deprecation")
public class ClassMap{
@@ -75,6 +73,7 @@ public class ClassMap{
classes.put("PartParams", mindustry.entities.part.DrawPart.PartParams.class);
classes.put("PartProgress", mindustry.entities.part.DrawPart.PartProgress.class);
classes.put("FlarePart", mindustry.entities.part.FlarePart.class);
classes.put("HaloPart", mindustry.entities.part.HaloPart.class);
classes.put("HoverPart", mindustry.entities.part.HoverPart.class);
classes.put("RegionPart", mindustry.entities.part.RegionPart.class);
classes.put("ShapePart", mindustry.entities.part.ShapePart.class);
@@ -228,7 +227,7 @@ public class ClassMap{
classes.put("DriverState", mindustry.world.blocks.distribution.MassDriver.DriverState.class);
classes.put("MassDriverBuild", mindustry.world.blocks.distribution.MassDriver.MassDriverBuild.class);
classes.put("OverflowDuct", mindustry.world.blocks.distribution.OverflowDuct.class);
classes.put("DuctRouterBuild", OverflowDuctBuild.class);
classes.put("OverflowDuctBuild", mindustry.world.blocks.distribution.OverflowDuct.OverflowDuctBuild.class);
classes.put("OverflowGate", mindustry.world.blocks.distribution.OverflowGate.class);
classes.put("OverflowGateBuild", mindustry.world.blocks.distribution.OverflowGate.OverflowGateBuild.class);
classes.put("Router", mindustry.world.blocks.distribution.Router.class);

View File

@@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
import arc.scene.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.graphics.*;
public class ReqImage extends Stack{
@@ -30,7 +31,7 @@ public class ReqImage extends Stack{
}
public ReqImage(TextureRegion region, Boolp valid){
this(new Image(region), valid);
this(new Image(region).setScaling(Scaling.fit), valid);
}
public boolean valid(){

View File

@@ -13,7 +13,7 @@ import static mindustry.Vars.*;
public class LanguageDialog extends BaseDialog{
public static final ObjectMap<String, String> displayNames = ObjectMap.of(
"id_ID", "Bahasa Indonesia (Indonesia)",
"id_ID", "Bahasa Indonesia",
"da", "Dansk",
"de", "Deutsch",
"et", "Eesti",
@@ -59,7 +59,8 @@ public class LanguageDialog extends BaseDialog{
}
public static String getDisplayName(Locale locale){
return displayNames.get(locale.toString(), locale.toString());
String str = locale.toString().replace("in_ID", "id_ID");
return displayNames.get(str, str);
}
private void setup(){

View File

@@ -373,6 +373,7 @@ public class ConstructBlock extends Block{
this.buildCost = block.buildCost * state.rules.buildCostMultiplier;
this.accumulator = new float[block.requirements.length];
this.totalAccumulator = new float[block.requirements.length];
pathfinder.updateTile(tile);
}
public void setDeconstruct(Block previous){
@@ -386,6 +387,7 @@ public class ConstructBlock extends Block{
this.buildCost = previous.buildCost * state.rules.buildCostMultiplier;
this.accumulator = new float[previous.requirements.length];
this.totalAccumulator = new float[previous.requirements.length];
pathfinder.updateTile(tile);
}
@Override

View File

@@ -0,0 +1,119 @@
package mindustry.world.blocks.defense;
import arc.math.*;
import arc.util.*;
import arc.struct.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.audio.*;
import mindustry.content.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.meta.*;
import mindustry.world.*;
import mindustry.entities.*;
import mindustry.annotations.Annotations.Load;
import static mindustry.Vars.*;
public class ShockwaveTower extends Block{
public int timerCheck = timers ++;
public float range = 90f;
public float reload = 60f * 2f;
public float bulletDamage = 150;
public float falloffCount = 20f;
public float shake = 2f;
//checking for bullets every frame is costly, so only do it at intervals even when ready.
public float checkInterval = 8f;
public Sound shootSound = Sounds.bang;
public Color waveColor = Pal.accent, heatColor = Pal.turretHeat, shapeColor = Color.valueOf("f29c83");
public float cooldownMultiplier = 1f;
public Effect waveEffect = Fx.pointShockwave;
//TODO switch to drawers eventually or something
public float shapeRotateSpeed = 1f, shapeRadius = 6f;
public int shapeSides = 4;
public @Load("@-heat") TextureRegion heatRegion;
public ShockwaveTower(String name){
super(name);
update = true;
solid = true;
}
@Override
public void setStats(){
super.setStats();
stats.add(Stat.damage, bulletDamage, StatUnit.none);
stats.add(Stat.range, range / tilesize, StatUnit.blocks);
stats.add(Stat.reload, 60f / reload, StatUnit.perSecond);
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
super.drawPlace(x, y, rotation, valid);
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, waveColor);
}
public class ShockwaveTowerBuild extends Building{
public float reloadCounter = Mathf.random(reload);
public float heat = 0f;
public Seq<Bullet> targets = new Seq<>();
@Override
public void updateTile(){
if(potentialEfficiency > 0 && (reloadCounter += Time.delta) >= reload && timer(timerCheck, checkInterval)){
targets.clear();
Groups.bullet.intersect(x - range, y - range, range * 2, range * 2, b -> {
if(b.team != team && b.type.hittable){
targets.add(b);
}
});
if(targets.size > 0){
heat = 1f;
reloadCounter = 0f;
waveEffect.at(x, y, range, waveColor);
shootSound.at(this);
Effect.shake(shake, shake, this);
float waveDamage = Math.min(bulletDamage, bulletDamage * falloffCount / targets.size);
for(var target : targets){
if(target.damage > waveDamage){
target.damage -= waveDamage;
}else{
target.remove();
}
}
}
}
heat = Mathf.clamp(heat - Time.delta / reload * cooldownMultiplier);
}
@Override
public float warmup(){
return heat;
}
@Override
public boolean shouldConsume(){
return targets.size != 0;
}
@Override
public void draw(){
super.draw();
Drawf.additive(heatRegion, heatColor, heat, x, y, 0f, Layer.blockAdditive);
Draw.z(Layer.effect);
Draw.color(shapeColor, waveColor, Mathf.pow(heat, 2f));
Fill.poly(x, y, shapeSides, shapeRadius * potentialEfficiency, Time.time * shapeRotateSpeed);
Draw.color();
}
}
}

View File

@@ -11,7 +11,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
/** A turret that fires a continuous beam with a delay between shots. Liquid coolant is required. Yes, this class name is awful. NEEDS RENAME */
/** A turret that fires a continuous beam with a delay between shots. Liquid coolant is required. Yes, this class name is awful. */
public class LaserTurret extends PowerTurret{
public float firingMoveFract = 0.25f;
public float shootDuration = 100f;
@@ -50,7 +50,7 @@ public class LaserTurret extends PowerTurret{
@Override
public boolean shouldConsume(){
//still consumes power when bullet is around
return bullets.any() || isActive();
return bullets.any() || isActive() || isShooting();
}
@Override

View File

@@ -345,9 +345,9 @@ public class Turret extends ReloadTurret{
float warmupTarget = isShooting() && canConsume() ? 1f : 0f;
if(linearWarmup){
shootWarmup = Mathf.approachDelta(shootWarmup, warmupTarget, shootWarmupSpeed);
shootWarmup = Mathf.approachDelta(shootWarmup, warmupTarget, shootWarmupSpeed * (warmupTarget > 0 ? efficiency : 1f));
}else{
shootWarmup = Mathf.lerpDelta(shootWarmup, warmupTarget, shootWarmupSpeed);
shootWarmup = Mathf.lerpDelta(shootWarmup, warmupTarget, shootWarmupSpeed * (warmupTarget > 0 ? efficiency : 1f));
}
wasShooting = false;

View File

@@ -1,5 +1,6 @@
package mindustry.world.blocks.logic;
import arc.audio.*;
import arc.graphics.g2d.*;
import arc.util.io.*;
import mindustry.annotations.Annotations.*;
@@ -8,6 +9,8 @@ import mindustry.world.*;
import mindustry.world.meta.*;
public class SwitchBlock extends Block{
public Sound clickSound = Sounds.click;
public @Load("@-on") TextureRegion onRegion;
public SwitchBlock(String name){
@@ -27,7 +30,7 @@ public class SwitchBlock extends Block{
@Override
public boolean configTapped(){
configure(!enabled);
Sounds.click.at(this);
clickSound.at(this);
return false;
}

View File

@@ -17,6 +17,7 @@ public class ConsumeGenerator extends PowerGenerator{
/** The time in number of ticks during which a single item will produce power. */
public float itemDuration = 120f;
public float warmupSpeed = 0.05f;
public float effectChance = 0.01f;
public Effect generateEffect = Fx.none, consumeEffect = Fx.none;
public float generateEffectRange = 3f;
@@ -86,7 +87,7 @@ public class ConsumeGenerator extends PowerGenerator{
public void updateTile(){
boolean valid = efficiency > 0;
warmup = Mathf.lerpDelta(warmup, valid ? 1f : 0f, 0.05f);
warmup = Mathf.lerpDelta(warmup, valid ? 1f : 0f, warmupSpeed);
productionEfficiency = efficiency * efficiencyMultiplier;
totalTime += warmup * Time.delta;

View File

@@ -2,13 +2,10 @@ package mindustry.world.blocks.power;
import arc.*;
import arc.audio.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.struct.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.game.EventType.*;
@@ -16,6 +13,7 @@ import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.ui.*;
import mindustry.world.draw.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -30,11 +28,6 @@ public class ImpactReactor extends PowerGenerator{
public Effect explodeEffect = Fx.impactReactorExplosion;
public Sound explodeSound = Sounds.explosionbig;
public Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
public @Load("@-bottom") TextureRegion bottomRegion;
public @Load(value = "@-plasma-#", length = 4) TextureRegion[] plasmaRegions;
public ImpactReactor(String name){
super(name);
hasPower = true;
@@ -46,6 +39,8 @@ public class ImpactReactor extends PowerGenerator{
lightRadius = 115f;
emitLight = true;
envEnabled = Env.any;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawPlasma(), new DrawDefault());
}
@Override
@@ -68,11 +63,6 @@ public class ImpactReactor extends PowerGenerator{
}
}
@Override
public TextureRegion[] icons(){
return new TextureRegion[]{bottomRegion, region};
}
public class ImpactReactorBuild extends GeneratorBuild{
public float warmup, totalProgress;
@@ -102,6 +92,11 @@ public class ImpactReactor extends PowerGenerator{
productionEfficiency = Mathf.pow(warmup, 5f);
}
@Override
public float warmup(){
return warmup;
}
@Override
public float totalProgress(){
return totalProgress;
@@ -111,29 +106,6 @@ public class ImpactReactor extends PowerGenerator{
public float ambientVolume(){
return warmup;
}
@Override
public void draw(){
Draw.rect(bottomRegion, x, y);
Draw.blend(Blending.additive);
for(int i = 0; i < plasmaRegions.length; i++){
float r = ((float)plasmaRegions[i].width * Draw.scl - 3f + Mathf.absin(Time.time, 2f + i * 1f, 5f - i * 0.5f));
Draw.color(plasma1, plasma2, (float)i / plasmaRegions.length);
Draw.alpha((0.3f + Mathf.absin(Time.time, 2f + i * 2f, 0.3f + i * 0.05f)) * warmup);
Draw.rect(plasmaRegions[i], x, y, r, r, totalProgress * (12 + i * 6f));
}
Draw.blend();
Draw.color();
Draw.rect(region, x, y);
}
@Override
public void drawLight(){
Drawf.light(x, y, (110f + Mathf.absin(5, 5f)) * warmup, Tmp.c1.set(plasma2).lerp(plasma1, Mathf.absin(7f, 0.2f)), 0.8f * warmup);
}
@Override
public double sense(LAccess sensor){

View File

@@ -76,6 +76,11 @@ public class PowerGenerator extends PowerDistributor{
drawer.draw(this);
}
@Override
public float warmup(){
return productionEfficiency;
}
@Override
public void drawLight(){
super.drawLight();

View File

@@ -2,10 +2,8 @@ package mindustry.world.blocks.power;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.game.*;
@@ -18,16 +16,11 @@ public class ThermalGenerator extends PowerGenerator{
public Effect generateEffect = Fx.none;
public float effectChance = 0.05f;
public float minEfficiency = 0f;
public float spinSpeed = 1f;
public float displayEfficiencyScale = 1f;
public boolean spinners = false;
public boolean displayEfficiency = true;
public @Nullable LiquidStack outputLiquid;
public Attribute attribute = Attribute.heat;
public @Load("@-rotator") TextureRegion rotatorRegion;
public @Load("@-rotator-blur") TextureRegion blurRegion;
public ThermalGenerator(String name){
super(name);
noUpdateDisabled = true;
@@ -72,13 +65,8 @@ public class ThermalGenerator extends PowerGenerator{
return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > minEfficiency;
}
@Override
public TextureRegion[] icons(){
return spinners ? new TextureRegion[]{region, rotatorRegion} : super.icons();
}
public class ThermalGeneratorBuild extends GeneratorBuild{
public float sum, spinRotation;
public float sum;
@Override
public void updateTile(){
@@ -88,8 +76,6 @@ public class ThermalGenerator extends PowerGenerator{
generateEffect.at(x + Mathf.range(3f), y + Mathf.range(3f));
}
spinRotation += productionEfficiency * spinSpeed;
if(outputLiquid != null){
float added = Math.min(productionEfficiency * delta() * outputLiquid.amount, liquidCapacity - liquids.get(outputLiquid.liquid));
liquids.add(outputLiquid.liquid, added);
@@ -97,15 +83,6 @@ public class ThermalGenerator extends PowerGenerator{
}
}
@Override
public void draw(){
super.draw();
if(spinners){
Drawf.spinSprite(blurRegion.found() && enabled && productionEfficiency > 0 ? blurRegion : rotatorRegion, x, y, spinRotation);
}
}
@Override
public void drawLight(){
Drawf.light(x, y, (40f + Mathf.absin(10f, 5f)) * Math.min(productionEfficiency, 2f) * size, Color.scarlet, 0.4f);

View File

@@ -0,0 +1,45 @@
package mindustry.world.draw;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.*;
public class DrawPlasma extends DrawFlame{
public TextureRegion[] regions;
public String suffix = "-plasma-";
public int plasmas = 4;
public Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
@Override
public void load(Block block){
regions = new TextureRegion[plasmas];
for(int i = 0; i < regions.length; i++){
regions[i] = Core.atlas.find(block.name + suffix + i);
}
}
@Override
public void drawLight(Building build){
Drawf.light(build.x, build.y, (110f + Mathf.absin(5, 5f)) * build.warmup(), Tmp.c1.set(plasma2).lerp(plasma1, Mathf.absin(7f, 0.2f)), 0.8f * build.warmup());
}
@Override
public void draw(Building build){
Draw.blend(Blending.additive);
for(int i = 0; i < regions.length; i++){
float r = ((float)regions[i].width * Draw.scl - 3f + Mathf.absin(Time.time, 2f + i * 1f, 5f - i * 0.5f));
Draw.color(plasma1, plasma2, (float)i / regions.length);
Draw.alpha((0.3f + Mathf.absin(Time.time, 2f + i * 2f, 0.3f + i * 0.05f)) * build.warmup());
Draw.rect(regions[i], build.x, build.y, r, r, build.totalProgress() * (12 + i * 6f));
}
Draw.color();
Draw.blend();
}
}