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

 Conflicts:
	core/src/mindustry/content/Blocks.java
This commit is contained in:
Epowerj
2022-08-04 14:55:14 -04:00
67 changed files with 319 additions and 84 deletions

View File

@@ -36,6 +36,7 @@ import mindustry.world.consumers.*;
import mindustry.world.draw.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
import static mindustry.type.ItemStack.*;
public class Blocks{
@@ -119,7 +120,7 @@ public class Blocks{
impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower, diode,
//power - erekir
turbineCondenser, ventCondenser, chemicalCombustionChamber, pyrolysisGenerator, fluxReactor,
turbineCondenser, ventCondenser, chemicalCombustionChamber, pyrolysisGenerator, fluxReactor, neoplasiaReactor,
beamNode, beamTower, beamLink,
//production
@@ -1672,7 +1673,7 @@ public class Blocks{
}};
shieldedWall = new ShieldWall("shielded-wall"){{
requirements(Category.defense, ItemStack.with(Items.phaseFabric, 20, Items.surgeAlloy, 12));
requirements(Category.defense, ItemStack.with(Items.phaseFabric, 20, Items.surgeAlloy, 12, Items.beryllium, 12));
consumePower(3f / 60f);
outputsPower = false;
@@ -2374,7 +2375,6 @@ public class Blocks{
heating = 0.02f;
consumeItem(Items.thorium);
//TODO how to non update
consumeLiquid(Liquids.cryofluid, heating / coolantPower).update(false);
}};
@@ -2449,11 +2449,10 @@ public class Blocks{
researchCost = with(Items.beryllium, 15);
}};
//TODO rename
chemicalCombustionChamber = new ConsumeGenerator("chemical-combustion-chamber"){{
requirements(Category.power, with(Items.graphite, 40, Items.tungsten, 40, Items.oxide, 40f, Items.silicon, 30));
powerProduction = 8f;
researchCost = with(Items.graphite, 2000, Items.tungsten, 1000, Items.oxide, 10, Items.silicon, 1500);
powerProduction = 9f;
consumeLiquids(LiquidStack.with(Liquids.ozone, 2f / 60f, Liquids.arkycite, 40f / 60f));
size = 3;
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawPistons(){{
@@ -2508,6 +2507,7 @@ public class Blocks{
consumeLiquid(Liquids.cyanogen, 9f / 60f);
liquidCapacity = 30f;
explosionMinWarmup = 0.5f;
size = 5;
@@ -2530,6 +2530,70 @@ public class Blocks{
);
}};
//TODO stats
neoplasiaReactor = new HeaterGenerator("neoplasia-reactor"){{
requirements(Category.power, with(Items.tungsten, 1000, Items.carbide, 300, Items.oxide, 150, Items.silicon, 500, Items.phaseFabric, 300, Items.surgeAlloy, 200));
size = 5;
liquidCapacity = 80f;
outputLiquid = new LiquidStack(Liquids.neoplasm, 20f / 60f);
explodeOnFull = true;
heatOutput = 60f;
//TODO arkycite, or nitrogen? both? Decide.
consumeLiquid(Liquids.arkycite, 80f / 60f);
consumeLiquid(Liquids.water, 10f / 60f);
consumeItem(Items.phaseFabric);
itemDuration = 60f * 3f;
itemCapacity = 10;
explosionRadius = 5;
explosionDamage = 500;
explodeEffect = new MultiEffect(Fx.bigShockwave, new WrapEffect(Fx.titanSmoke, Liquids.neoplasm.color), Fx.neoplasmSplat);
explodeSound = Sounds.explosionbig;
powerProduction = 140f;
rebuildable = false;
explosionPuddles = 80;
explosionPuddleRange = tilesize * 7f;
explosionPuddleLiquid = Liquids.neoplasm;
explosionPuddleAmount = 200f;
explosionMinWarmup = 0.5f;
consumeEffect = new RadialEffect(Fx.neoplasiaSmoke, 4, 90f, 54f / 4f);
drawer = new DrawMulti(
new DrawRegion("-bottom"),
new DrawLiquidTile(Liquids.arkycite, 3f),
new DrawCircles(){{
color = Color.valueOf("feb380").a(0.8f);
strokeMax = 3.25f;
radius = 65f / 4f;
amount = 5;
timeScl = 200f;
}},
new DrawRegion("-center"),
new DrawCells(){{
color = Color.valueOf("c33e2b");
particleColorFrom = Color.valueOf("e8803f");
particleColorTo = Color.valueOf("8c1225");
particles = 50;
range = 4f;
}},
new DrawDefault(),
new DrawHeatOutput(),
new DrawGlowRegion("-glow"){{
color = Color.valueOf("70170b");
alpha = 0.7f;
}}
);
}};
//endregion power
//region production

View File

@@ -470,6 +470,26 @@ public class Fx{
}
}).layer(Layer.bullet - 1f),
neoplasmSplat = new Effect(400f, 300f, b -> {
float intensity = 3f;
color(Pal.neoplasm1);
for(int i = 0; i < 4; i++){
rand.setSeed(b.id*2 + i);
float lenScl = rand.random(0.5f, 1f);
int fi = i;
b.scaled(b.lifetime * lenScl, e -> {
randLenVectors(e.id + fi - 1, e.fin(Interp.pow10Out), (int)(5f * intensity), 22f * intensity, (x, y, in, out) -> {
float fout = e.fout(Interp.pow5Out) * rand.random(0.5f, 1f);
float rad = fout * ((2f + intensity) * 1.35f);
Fill.circle(e.x + x, e.y + y, rad);
Drawf.light(e.x + x, e.y + y, rad * 2.5f, b.color, 0.5f);
});
});
}
}).layer(Layer.bullet - 2f),
scatheExplosion = new Effect(60f, 160f, e -> {
color(e.color);
stroke(e.fout() * 5f);
@@ -1698,6 +1718,21 @@ public class Fx{
}
}),
neoplasiaSmoke = new Effect(280f, e -> {
color(Pal.neoplasmMid);
alpha(0.6f);
rand.setSeed(e.id);
for(int i = 0; i < 6; i++){
float len = rand.random(10f), rot = rand.range(120f) + e.rotation;
e.scaled(e.lifetime * rand.random(0.3f, 1f), b -> {
v.trns(rot, len * b.finpow());
Fill.circle(e.x + v.x, e.y + v.y, 3.3f * b.fslope() + 0.2f);
});
}
}),
heatReactorSmoke = new Effect(180f, e -> {
color(Color.gray);

View File

@@ -50,9 +50,9 @@ public class Liquids{
viscosity = 0.85f;
flammability = 0f;
capPuddles = false;
hidden = true;
spreadTarget = Liquids.water;
moveThroughBlocks = true;
incinerable = true;
colorFrom = Color.valueOf("e8803f");
colorTo = Color.valueOf("8c1225");

View File

@@ -131,6 +131,8 @@ public class Planets{
allowLaunchSchematics = true;
enemyCoreSpawnReplace = true;
allowLaunchLoadout = true;
//doesn't play well with configs
prebuildBase = false;
ruleSetter = r -> {
r.waveTeam = Team.crux;
r.placeRangeCheck = false;

View File

@@ -6,7 +6,7 @@ import mindustry.entities.*;
import mindustry.gen.*;
public class FlakBulletType extends BasicBulletType{
public float explodeRange = 30f, explodeDelay = 5f, flakInterval = 6f;
public float explodeRange = 30f, explodeDelay = 5f, flakDelay = 0f, flakInterval = 6f;
public FlakBulletType(float speed, float damage){
super(speed, damage, "shell");
@@ -27,9 +27,9 @@ public class FlakBulletType extends BasicBulletType{
super.update(b);
//don't check for targets if primed to explode
if(b.fdata >= 0 && b.timer(2, flakInterval)){
if(b.time >= flakDelay && 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
//fdata < 0 means it's primed to explode
if(b.fdata < 0f || !unit.checkTarget(collidesAir, collidesGround)) return;
if(unit.within(b, explodeRange + unit.hitSize/2f)){

View File

@@ -166,6 +166,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
(!build.block.underBullets ||
//direct hit on correct tile
(aimTile != null && aimTile.build == build) ||
//same team has no 'under build' mechanics
(build.team == team) ||
//a piercing bullet overshot the aim tile, it's fine to hit things now
(type.pierce && aimTile != null && Mathf.dst(x, y, originX, originY) > aimTile.dst(originX, originY) + 2f) ||
//there was nothing to aim at

View File

@@ -47,7 +47,7 @@ public class Rules{
public boolean schematicsAllowed = true;
/** Whether friendly explosions can occur and set fire/damage other blocks. */
public boolean damageExplosions = true;
/** Whether fire is enabled. */
/** Whether fire (and neoplasm spread) is enabled. */
public boolean fire = true;
/** Whether units use and require ammo. */
public boolean unitAmmo = false;

View File

@@ -35,6 +35,9 @@ public class Layer{
//informal layer used for additive blending overlay, grouped together to reduce draw calls
blockAdditive = 31,
//props such as boulders
blockProp = 32,
//things drawn over blocks (intermediate layer)
blockOver = 35,
@@ -83,7 +86,7 @@ public class Layer{
//shield effects
shields = 125,
//weather effects, e.g. rain and snow TODO draw before overlay UI?
//weather effects, e.g. rain and snow
weather = 130,
//light rendering *shaders used*

View File

@@ -112,6 +112,7 @@ public class Pal{
neoplasmOutline = Color.valueOf("2e191d"),
neoplasm1 = Color.valueOf("f98f4a"),
neoplasmMid = Color.valueOf("e05438"),
neoplasm2 = Color.valueOf("9e172c"),
logicBlocks = Color.valueOf("d4816b"),

View File

@@ -44,23 +44,8 @@ public class NetworkIO{
stream.writeLong(GlobalVars.rand.seed0);
stream.writeLong(GlobalVars.rand.seed1);
Writes write = new Writes(stream);
stream.writeInt(player.id);
player.write(write);
boolean any = !state.rules.fog;
stream.writeInt(any ? Groups.sync.size() : 0);
if(any){
//write all synced entities *immediately*
for(Syncc entity : Groups.sync){
stream.writeInt(entity.id());
stream.writeByte(entity.classId());
entity.writeSync(write);
}
}
player.write(new Writes(stream));
SaveIO.getSaveWriter().writeContentHeader(stream);
SaveIO.getSaveWriter().writeMap(stream);
@@ -93,12 +78,6 @@ public class NetworkIO{
player.id = id;
player.add();
int entities = stream.readInt();
for(int j = 0; j < entities; j++){
NetClient.readSyncEntity(stream, read);
}
SaveIO.getSaveWriter().readContentHeader(stream);
SaveIO.getSaveWriter().readMap(stream, world.context);
SaveIO.getSaveWriter().readTeamBlocks(stream);

View File

@@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
@@ -18,7 +19,7 @@ public class CellLiquid extends Liquid{
public int cells = 8;
public @Nullable Liquid spreadTarget;
public float maxSpread = 0.5f, spreadConversion = 0.5f, spreadDamage = 0.1f;
public float maxSpread = 0.5f, spreadConversion = 1f, spreadDamage = 0.1f, removeScaling = 0.25f;
public CellLiquid(String name, Color color){
super(name, color);
@@ -30,20 +31,32 @@ public class CellLiquid extends Liquid{
@Override
public void update(Puddle puddle){
if(!Vars.state.rules.fire) return;
if(spreadTarget != null){
float scaling = Mathf.pow(Mathf.clamp(puddle.amount / maxLiquid), 2f);
for(var point : Geometry.d4c){
Tile tile = puddle.tile.nearby(point);
if(tile != null && tile.build != null && tile.build.liquids != null && tile.build.liquids.get(spreadTarget) > 0){
if(tile != null && tile.build != null && tile.build.liquids != null && tile.build.liquids.get(spreadTarget) > 0.0001f){
float amount = Math.min(tile.build.liquids.get(spreadTarget), maxSpread * Time.delta * scaling);
tile.build.liquids.remove(spreadTarget, amount);
tile.build.liquids.remove(spreadTarget, amount * removeScaling);
Puddles.deposit(tile, this, amount * spreadConversion);
}
}
//damage thing it is on
if(spreadDamage > 0 && puddle.tile.build != null && puddle.tile.build.liquids != null && puddle.tile.build.liquids.get(spreadTarget) > 0){
if(spreadDamage > 0 && puddle.tile.build != null && puddle.tile.build.liquids != null && puddle.tile.build.liquids.get(spreadTarget) > 0.0001f){
//spread in 4 adjacent directions around thing it is on
float amountSpread = Math.min(puddle.tile.build.liquids.get(spreadTarget) * spreadConversion, maxSpread * Time.delta) / 2f;
for(var dir : Geometry.d4){
Tile other = puddle.tile.nearby(dir);
if(other != null){
Puddles.deposit(puddle.tile, other, puddle.liquid, amountSpread);
}
}
puddle.tile.build.damage(spreadDamage * Time.delta * scaling);
}
@@ -79,7 +92,7 @@ public class CellLiquid extends Liquid{
public void drawPuddle(Puddle puddle){
super.drawPuddle(puddle);
float baseLayer = puddle.tile != null && puddle.tile.build != null ? Layer.blockOver : Layer.debris - 0.5f;
float baseLayer = puddle.tile != null && puddle.tile.block().solid || puddle.tile.build != null ? Layer.blockOver : Layer.debris - 0.5f;
int id = puddle.id;
float amount = puddle.amount, x = puddle.x, y = puddle.y;

View File

@@ -47,6 +47,8 @@ public class Liquid extends UnlockableContent implements Senseable{
public boolean coolant = true;
/** if true, this liquid can move through blocks as a puddle. */
public boolean moveThroughBlocks = false;
/** if true, this liquid can be incinerated in the incinerator block. */
public boolean incinerable = true;
/** The associated status effect. */
public StatusEffect effect = StatusEffects.none;
/** Effect shown in puddles. */

View File

@@ -87,6 +87,11 @@ public class ShieldWall extends Wall{
return breakTimer > 0 || !canConsume();
}
@Override
public void pickedUp(){
shieldRadius = 0f;
}
@Override
public void damage(float damage){
float shieldTaken = broken() ? 0f : Math.min(shield, damage);

View File

@@ -5,9 +5,11 @@ import arc.graphics.g2d.*;
import arc.math.*;
import mindustry.content.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.*;
public class Prop extends Block{
public float layer = Layer.blockProp;
public Prop(String name){
super(name);
@@ -20,6 +22,7 @@ public class Prop extends Block{
@Override
public void drawBase(Tile tile){
Draw.z(layer);
Draw.rect(variants > 0 ? variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))] : region, tile.worldx(), tile.worldy());
}

View File

@@ -0,0 +1,77 @@
package mindustry.world.blocks.power;
import arc.math.*;
import arc.util.io.*;
import mindustry.graphics.*;
import mindustry.ui.*;
import mindustry.world.blocks.heat.*;
import mindustry.world.draw.*;
import mindustry.world.meta.*;
public class HeaterGenerator extends ConsumeGenerator{
public float heatOutput = 10f;
public float warmupRate = 0.15f;
public HeaterGenerator(String name){
super(name);
drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput());
rotateDraw = false;
rotate = true;
canOverdrive = false;
drawArrow = true;
}
@Override
public void setStats(){
super.setStats();
stats.add(Stat.output, heatOutput, StatUnit.heatUnits);
}
@Override
public boolean rotatedOutput(int x, int y){
return false;
}
@Override
public void setBars(){
super.setBars();
addBar("heat", (HeaterGeneratorBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat / heatOutput));
}
public class HeaterGeneratorBuild extends ConsumeGeneratorBuild implements HeatBlock{
public float heat;
@Override
public void updateTile(){
super.updateTile();
//heat approaches target at the same speed regardless of efficiency
heat = Mathf.approachDelta(heat, heatOutput * efficiency, warmupRate * delta());
}
@Override
public float heatFrac(){
return heat / heatOutput;
}
@Override
public float heat(){
return heat;
}
@Override
public void write(Writes write){
super.write(write);
write.f(heat);
}
@Override
public void read(Reads read, byte revision){
super.read(read, revision);
heat = read.f();
}
}
}

View File

@@ -35,6 +35,7 @@ public class PowerGenerator extends PowerDistributor{
public float explosionPuddleRange = tilesize * 2f;
public float explosionPuddleAmount = 100f;
public @Nullable Liquid explosionPuddleLiquid;
public float explosionMinWarmup = 0f;
public float explosionShake = 0f, explosionShakeDuration = 6f;
@@ -110,23 +111,25 @@ public class PowerGenerator extends PowerDistributor{
}
public void createExplosion(){
if(explosionDamage > 0){
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage);
}
explodeEffect.at(this);
explodeSound.at(this);
if(explosionPuddleLiquid != null){
for(int i = 0; i < explosionPuddles; i++){
Tmp.v1.trns(Mathf.random(360f), Mathf.random(explosionPuddleRange));
Tile tile = world.tileWorld(x + Tmp.v1.x, y + Tmp.v1.y);
Puddles.deposit(tile, explosionPuddleLiquid, explosionPuddleAmount);
if(warmup() >= explosionMinWarmup){
if(explosionDamage > 0){
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage);
}
}
if(explosionShake > 0){
Effect.shake(explosionShake, explosionShakeDuration, this);
explodeEffect.at(this);
explodeSound.at(this);
if(explosionPuddleLiquid != null){
for(int i = 0; i < explosionPuddles; i++){
Tmp.v1.trns(Mathf.random(360f), Mathf.random(explosionPuddleRange));
Tile tile = world.tileWorld(x + Tmp.v1.x, y + Tmp.v1.y);
Puddles.deposit(tile, explosionPuddleLiquid, explosionPuddleAmount);
}
}
if(explosionShake > 0){
Effect.shake(explosionShake, explosionShakeDuration, this);
}
}
}

View File

@@ -76,7 +76,7 @@ public class Incinerator extends Block{
@Override
public boolean acceptLiquid(Building source, Liquid liquid){
return heat > 0.5f;
return heat > 0.5f && liquid.incinerable;
}
}
}

View File

@@ -11,9 +11,10 @@ import mindustry.world.*;
public class DrawCells extends DrawBlock{
public TextureRegion middle;
public Color color = Color.white.cpy(), particleColorFrom = Color.black.cpy(), particleColorTo = Color.black.cpy();
public int particles = 12;
public float range = 4f, recurrence = 6f, radius = 3f, lifetime = 60f;
public float range = 4f, recurrence = 2f, radius = 1.8f, lifetime = 60f * 3f;
@Override
public void draw(Building build){
@@ -38,7 +39,6 @@ public class DrawCells extends DrawBlock{
}
Draw.color();
Draw.rect(build.block.region, build.x, build.y);
}
@Override