Env rules for many various blocks

This commit is contained in:
Anuken
2021-06-17 11:08:01 -04:00
parent afe963ca5d
commit 016e5ab97e
19 changed files with 64 additions and 22 deletions

View File

@@ -730,6 +730,7 @@ public class Blocks implements ContentList{
solid = true;
outputsLiquid = true;
drawer = new DrawMixer();
envEnabled = Env.any;
consumes.power(1f);
consumes.item(Items.titanium);

View File

@@ -6,15 +6,10 @@ import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.graphics.g3d.*;
import mindustry.graphics.g3d.PlanetGrid.*;
import mindustry.maps.generators.*;
import mindustry.maps.planet.*;
import mindustry.type.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class Planets implements ContentList{
public static Planet
@@ -70,23 +65,7 @@ public class Planets implements ContentList{
drawOrbit = false;
orbitOffset = offsets[fi];
generator = new BlankPlanetGenerator(){
@Override
public void generate(){
pass((x, y) -> {
floor = Blocks.space;
});
Schematics.placeLaunchLoadout(width/2, height/2);
state.rules.environment = Env.space;
}
@Override
public int getSectorSize(Sector sector){
return 300;
}
};
generator = new AsteroidGenerator();
meshLoader = () -> {
Seq<GenericMesh> meshes = new Seq<>();

View File

@@ -0,0 +1,37 @@
package mindustry.maps.planet;
import arc.math.*;
import arc.util.noise.*;
import mindustry.content.*;
import mindustry.game.*;
import mindustry.maps.generators.*;
import mindustry.type.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class AsteroidGenerator extends BlankPlanetGenerator{
@Override
public void generate(){
int seed = state.rules.sector.planet.id;
int sx = width/2, sy = height/2;
pass((x, y) -> {
floor = Blocks.space;
if(Simplex.noise2d(seed, 5, 0.6f, 1f/ 100f, x, y) + Mathf.dst(x, y, sx, sy) / (float)width / 2f > 0.7f){
floor = Blocks.stone;
}
});
Schematics.placeLaunchLoadout(sx, sy);
state.rules.environment = Env.space;
}
@Override
public int getSectorSize(Sector sector){
return 450;
}
}

View File

@@ -36,6 +36,9 @@ public class Wall extends Block{
buildCostMultiplier = 6f;
canOverdrive = false;
drawDisabled = false;
//it's a wall of course it's supported everywhere
envEnabled = Env.any;
}
@Override

View File

@@ -12,6 +12,7 @@ public class PowerTurret extends Turret{
public PowerTurret(String name){
super(name);
hasPower = true;
envEnabled |= Env.space;
}
@Override

View File

@@ -18,6 +18,7 @@ import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.distribution.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;

View File

@@ -19,6 +19,7 @@ public class LiquidBlock extends Block{
hasLiquids = true;
group = BlockGroup.liquids;
outputsLiquid = true;
envEnabled |= Env.space | Env.underwater;
}
@Override

View File

@@ -42,6 +42,9 @@ public class LogicBlock extends Block{
group = BlockGroup.logic;
schematicPriority = 5;
//universal, no real requirements
envEnabled = Env.any;
config(byte[].class, (LogicBuild build, byte[] data) -> build.readCompressed(data, true));
config(Integer.class, (LogicBuild entity, Integer pos) -> {

View File

@@ -21,6 +21,8 @@ public class Battery extends PowerDistributor{
outputsPower = true;
consumesPower = true;
flags = EnumSet.of(BlockFlag.battery);
//TODO could be supported everywhere...
envEnabled |= Env.space;
}
public class BatteryBuild extends Building{

View File

@@ -1,6 +1,7 @@
package mindustry.world.blocks.power;
import mindustry.type.*;
import mindustry.world.meta.*;
public class DecayGenerator extends ItemLiquidGenerator{
@@ -8,6 +9,7 @@ public class DecayGenerator extends ItemLiquidGenerator{
super(true, false, name);
hasItems = true;
hasLiquids = false;
envEnabled = Env.any;
}
@Override

View File

@@ -43,6 +43,7 @@ public class ImpactReactor extends PowerGenerator{
flags = EnumSet.of(BlockFlag.reactor, BlockFlag.generator);
lightRadius = 115f;
emitLight = true;
envEnabled = Env.any;
}
@Override

View File

@@ -56,6 +56,7 @@ public class NuclearReactor extends PowerGenerator{
rebuildable = false;
flags = EnumSet.of(BlockFlag.reactor, BlockFlag.generator);
schematicPriority = -5;
envEnabled = Env.any;
}
@Override

View File

@@ -45,6 +45,7 @@ public class PowerNode extends PowerBlock{
swapDiagonalPlacement = true;
schematicPriority = -10;
drawDisabled = false;
envEnabled |= Env.space;
config(Integer.class, (entity, value) -> {
PowerModule power = entity.power;

View File

@@ -12,6 +12,7 @@ public class SolarGenerator extends PowerGenerator{
super(name);
//remove the BlockFlag.generator flag to make this a lower priority target than other generators.
flags = EnumSet.of();
envEnabled = Env.any;
}
@Override

View File

@@ -14,6 +14,7 @@ import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -37,6 +38,8 @@ public class BeamDrill extends Block{
update = true;
solid = true;
drawArrow = false;
envEnabled |= Env.space;
}
@Override

View File

@@ -31,6 +31,8 @@ public class SolidPump extends Pump{
public SolidPump(String name){
super(name);
hasPower = true;
//only supports ground by default
envEnabled = Env.terrestrial;
}
@Override

View File

@@ -22,6 +22,7 @@ public class StorageBlock extends Block{
destructible = true;
group = BlockGroup.transportation;
flags = EnumSet.of(BlockFlag.storage);
envEnabled = Env.any;
}
@Override

View File

@@ -28,6 +28,7 @@ public class Unloader extends Block{
itemCapacity = 0;
noUpdateDisabled = true;
unloadable = false;
envEnabled = Env.any;
config(Item.class, (UnloaderBuild tile, Item item) -> tile.sortItem = item);
configClear((UnloaderBuild tile) -> tile.sortItem = null);

View File

@@ -36,6 +36,7 @@ public class CommandCenter extends Block{
configurable = true;
drawDisabled = false;
logicConfigurable = true;
envEnabled = Env.any;
config(UnitCommand.class, (CommandBuild build, UnitCommand command) -> {
if(build.team.data().command != command){