Merge branch 'master' of https://github.com/Anuken/Mindustry into schematics
This commit is contained in:
@@ -9,7 +9,7 @@ import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
@@ -29,8 +29,6 @@ import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
import io.anuke.mindustry.world.modules.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Blocks implements ContentList{
|
||||
public static Block
|
||||
|
||||
@@ -716,23 +714,23 @@ public class Blocks implements ContentList{
|
||||
//region sandbox
|
||||
|
||||
powerVoid = new PowerVoid("power-void"){{
|
||||
requirements(Category.power, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.power, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
alwaysUnlocked = true;
|
||||
}};
|
||||
powerSource = new PowerSource("power-source"){{
|
||||
requirements(Category.power, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.power, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
alwaysUnlocked = true;
|
||||
}};
|
||||
itemSource = new ItemSource("item-source"){{
|
||||
requirements(Category.distribution, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.distribution, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
alwaysUnlocked = true;
|
||||
}};
|
||||
itemVoid = new ItemVoid("item-void"){{
|
||||
requirements(Category.distribution, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.distribution, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
alwaysUnlocked = true;
|
||||
}};
|
||||
liquidSource = new LiquidSource("liquid-source"){{
|
||||
requirements(Category.liquid, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.liquid, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
alwaysUnlocked = true;
|
||||
}};
|
||||
message = new MessageBlock("message"){{
|
||||
@@ -745,27 +743,27 @@ public class Blocks implements ContentList{
|
||||
int wallHealthMultiplier = 4;
|
||||
|
||||
scrapWall = new Wall("scrap-wall"){{
|
||||
requirements(Category.defense, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.defense, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
health = 60 * wallHealthMultiplier;
|
||||
variants = 5;
|
||||
}};
|
||||
|
||||
scrapWallLarge = new Wall("scrap-wall-large"){{
|
||||
requirements(Category.defense, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.defense, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
health = 60 * 4 * wallHealthMultiplier;
|
||||
size = 2;
|
||||
variants = 4;
|
||||
}};
|
||||
|
||||
scrapWallHuge = new Wall("scrap-wall-huge"){{
|
||||
requirements(Category.defense, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.defense, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
health = 60 * 9 * wallHealthMultiplier;
|
||||
size = 3;
|
||||
variants = 3;
|
||||
}};
|
||||
|
||||
scrapWallGigantic = new Wall("scrap-wall-gigantic"){{
|
||||
requirements(Category.defense, () -> state.rules.infiniteResources, ItemStack.with());
|
||||
requirements(Category.defense, BuildVisibility.sandboxOnly, ItemStack.with());
|
||||
health = 60 * 16 * wallHealthMultiplier;
|
||||
size = 4;
|
||||
}};
|
||||
@@ -1235,7 +1233,7 @@ public class Blocks implements ContentList{
|
||||
//region storage
|
||||
|
||||
coreShard = new CoreBlock("core-shard"){{
|
||||
requirements(Category.effect, () -> false, ItemStack.with(Items.titanium, 1000));
|
||||
requirements(Category.effect, BuildVisibility.debugOnly, ItemStack.with(Items.titanium, 4000));
|
||||
alwaysUnlocked = true;
|
||||
|
||||
health = 1100;
|
||||
@@ -1244,7 +1242,7 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
coreFoundation = new CoreBlock("core-foundation"){{
|
||||
requirements(Category.effect, () -> false, ItemStack.with(Items.titanium, 1500, Items.silicon, 1000));
|
||||
requirements(Category.effect, BuildVisibility.debugOnly, ItemStack.with(Items.titanium, 400, Items.silicon, 3000));
|
||||
|
||||
health = 2000;
|
||||
itemCapacity = 9000;
|
||||
@@ -1252,7 +1250,7 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
coreNucleus = new CoreBlock("core-nucleus"){{
|
||||
requirements(Category.effect, () -> false, ItemStack.with(Items.titanium, 4000, Items.silicon, 2000, Items.surgealloy, 1000));
|
||||
requirements(Category.effect, BuildVisibility.debugOnly, ItemStack.with(Items.titanium, 4000, Items.silicon, 2000, Items.surgealloy, 3000));
|
||||
|
||||
health = 4000;
|
||||
itemCapacity = 13000;
|
||||
@@ -1277,7 +1275,7 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
launchPad = new LaunchPad("launch-pad"){{
|
||||
requirements(Category.effect, () -> world.isZone(), ItemStack.with(Items.copper, 250, Items.silicon, 75, Items.lead, 100));
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 250, Items.silicon, 75, Items.lead, 100));
|
||||
size = 3;
|
||||
itemCapacity = 100;
|
||||
launchTime = 60f * 16;
|
||||
@@ -1286,7 +1284,7 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
launchPadLarge = new LaunchPad("launch-pad-large"){{
|
||||
requirements(Category.effect, () -> world.isZone(), ItemStack.with(Items.titanium, 200, Items.silicon, 150, Items.lead, 250, Items.plastanium, 75));
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.titanium, 200, Items.silicon, 150, Items.lead, 250, Items.plastanium, 75));
|
||||
size = 4;
|
||||
itemCapacity = 250;
|
||||
launchTime = 60f * 14;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MapResizeDialog extends FloatingDialog{
|
||||
|
||||
buttons.defaults().size(200f, 50f);
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
buttons.addButton("$editor.resize", () -> {
|
||||
buttons.addButton("$ok", () -> {
|
||||
cons.accept(width, height);
|
||||
hide();
|
||||
});
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.anuke.arc.graphics.glutils.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.type.base.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Teams.*;
|
||||
@@ -29,6 +28,7 @@ public class BlockRenderer implements Disposable{
|
||||
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
|
||||
private int requestidx = 0;
|
||||
private int iterateidx = 0;
|
||||
private float brokenFade = 0f;
|
||||
private FrameBuffer shadows = new FrameBuffer(2, 2);
|
||||
private FrameBuffer fog = new FrameBuffer(2, 2);
|
||||
private Array<Tile> outArray = new Array<>();
|
||||
@@ -124,12 +124,18 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
|
||||
public void drawBroken(){
|
||||
if(unitGroups[player.getTeam().ordinal()].all().contains(p -> p instanceof BuilderDrone)){
|
||||
if(control.input.isPlacing() || control.input.isBreaking()){
|
||||
brokenFade = Mathf.lerpDelta(brokenFade, 1f, 0.1f);
|
||||
}else{
|
||||
brokenFade = Mathf.lerpDelta(brokenFade, 0f, 0.1f);
|
||||
}
|
||||
|
||||
if(brokenFade > 0.001f){
|
||||
for(BrokenBlock block : state.teams.get(player.getTeam()).brokenBlocks){
|
||||
Block b = content.block(block.block);
|
||||
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue;
|
||||
|
||||
Draw.alpha(0.5f);
|
||||
Draw.alpha(0.53f * brokenFade);
|
||||
Draw.mixcol(Color.white, 0.2f + Mathf.absin(Time.globalTime(), 6f, 0.2f));
|
||||
Draw.rect(b.icon(Cicon.full), block.x * tilesize + b.offset(), block.y * tilesize + b.offset(), b.rotate ? block.rotation * 90 : 0f);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,11 @@ public class DesktopInput extends InputHandler{
|
||||
cursorType = SystemCursor.arrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBreaking(){
|
||||
return mode == breaking;
|
||||
}
|
||||
|
||||
void pollInput(){
|
||||
Tile selected = tileAt(Core.input.mouseX(), Core.input.mouseY());
|
||||
int cursorX = tileX(Core.input.mouseX());
|
||||
|
||||
@@ -523,6 +523,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
return block != null;
|
||||
}
|
||||
|
||||
public boolean isBreaking(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public float mouseAngle(float x, float y){
|
||||
return Core.input.mouseWorld(getMouseX(), getMouseY()).sub(x, y).angle();
|
||||
}
|
||||
|
||||
@@ -348,6 +348,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
//endregion
|
||||
//region input events
|
||||
|
||||
@Override
|
||||
public boolean isBreaking(){
|
||||
return mode == breaking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(int screenX, int screenY, int pointer, KeyCode button){
|
||||
if(state.is(State.menu) || player.isDead()) return false;
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.anuke.mindustry.mod.Mods.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
@@ -173,9 +174,9 @@ public class ContentParser{
|
||||
TechTree.create(find(ContentType.block, value.get("research").asString()), block);
|
||||
}
|
||||
|
||||
//make block visible
|
||||
if(value.has("requirements")){
|
||||
block.buildVisibility = () -> true;
|
||||
//make block visible by default if there are requirements and no visibility set
|
||||
if(value.has("requirements") && block.buildVisibility == BuildVisibility.hidden){
|
||||
block.buildVisibility = BuildVisibility.shown;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
|
||||
@@ -29,7 +30,7 @@ public class Links{
|
||||
}
|
||||
|
||||
public static class LinkEntry{
|
||||
public final String name, description, link;
|
||||
public final String name, title, description, link;
|
||||
public final Color color;
|
||||
|
||||
public LinkEntry(String name, String link, Color color){
|
||||
@@ -37,6 +38,9 @@ public class Links{
|
||||
this.color = color;
|
||||
this.description = Core.bundle.getNotNull("link." + name + ".description");
|
||||
this.link = link;
|
||||
|
||||
String title = Core.bundle.getOrNull("link." + name + ".title");
|
||||
this.title = title != null ? title : Strings.capitalize(name.replace("-", " "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AboutDialog extends FloatingDialog{
|
||||
}).size(h - 5, h);
|
||||
|
||||
table.table(inset -> {
|
||||
inset.add("[accent]" + Strings.capitalize(link.name.replace("-", " "))).growX().left();
|
||||
inset.add("[accent]" + link.title).growX().left();
|
||||
inset.row();
|
||||
inset.labelWrap(link.description).width(w - 100f).color(Color.lightGray).growX();
|
||||
}).padLeft(8);
|
||||
|
||||
@@ -157,14 +157,14 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
main.row();
|
||||
|
||||
title("$rules.title.player");
|
||||
number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier);
|
||||
number("$rules.playerhealthmultiplier", f -> rules.playerHealthMultiplier = f, () -> rules.playerHealthMultiplier);
|
||||
number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier);
|
||||
|
||||
title("$rules.title.unit");
|
||||
check("$rules.unitdrops", b -> rules.unitDrops = b, () -> rules.unitDrops, () -> true);
|
||||
number("$rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier);
|
||||
number("$rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier);
|
||||
number("$rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier);
|
||||
number("$rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier);
|
||||
|
||||
title("$rules.title.enemy");
|
||||
check("$rules.attack", b -> rules.attackMode = b, () -> rules.attackMode);
|
||||
|
||||
@@ -294,6 +294,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
graphics.checkPref("effects", true);
|
||||
graphics.checkPref("playerchat", true);
|
||||
graphics.checkPref("minimap", !mobile);
|
||||
graphics.checkPref("position", false);
|
||||
graphics.checkPref("fps", false);
|
||||
graphics.checkPref("indicators", true);
|
||||
graphics.checkPref("animatedwater", false);
|
||||
|
||||
@@ -157,7 +157,7 @@ public class ZoneInfoDialog extends FloatingDialog{
|
||||
hide();
|
||||
control.playZone(zone);
|
||||
}
|
||||
}).minWidth(150f).margin(13f).padTop(5).disabled(b -> zone.locked() ? !zone.canUnlock() : !data.hasItems(zone.getLaunchCost())).uniformY().get();
|
||||
}).minWidth(200f).margin(13f).padTop(5).disabled(b -> zone.locked() ? !zone.canUnlock() : !data.hasItems(zone.getLaunchCost())).uniformY().get();
|
||||
|
||||
button.row();
|
||||
button.add(iteminfo);
|
||||
|
||||
@@ -19,15 +19,14 @@ import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.Styles;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -249,9 +248,16 @@ public class HudFragment extends Fragment{
|
||||
info.label(() -> ping.get(netClient.getPing())).visible(net::client).left().style(Styles.outlineLabel);
|
||||
}).top().left();
|
||||
});
|
||||
|
||||
//minimap
|
||||
parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial));
|
||||
|
||||
parent.fill(t -> {
|
||||
//minimap
|
||||
t.add(new Minimap().visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial));
|
||||
t.row();
|
||||
//position
|
||||
t.label(() -> world.toTile(player.x) + "," + world.toTile(player.y))
|
||||
.visible(() -> Core.settings.getBool("position") && !state.rules.tutorial);
|
||||
t.top().right();
|
||||
});
|
||||
|
||||
//spawner warning
|
||||
parent.fill(t -> {
|
||||
|
||||
@@ -39,8 +39,6 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class Block extends BlockStorage{
|
||||
public static final int crackRegions = 8, maxCrackSize = 5;
|
||||
|
||||
private static final BooleanProvider invisible = () -> false;
|
||||
|
||||
/** whether this block has a tile entity that updates */
|
||||
public boolean update;
|
||||
/** whether this block has health and can be destroyed */
|
||||
@@ -124,7 +122,9 @@ public class Block extends BlockStorage{
|
||||
/** Cost of building this block; do not modify directly! */
|
||||
public float buildCost;
|
||||
/** Whether this block is visible and can currently be built. */
|
||||
public BooleanProvider buildVisibility = invisible;
|
||||
public BuildVisibility buildVisibility = BuildVisibility.hidden;
|
||||
/** Multiplier for speed of building this block. */
|
||||
public float buildCostMultiplier = 1f;
|
||||
/** Whether this block has instant transfer.*/
|
||||
public boolean instantTransfer = false;
|
||||
public boolean alwaysUnlocked = false;
|
||||
@@ -155,7 +155,7 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
public boolean isBuildable(){
|
||||
return buildVisibility != invisible;
|
||||
return buildVisibility != BuildVisibility.hidden && buildVisibility != BuildVisibility.debugOnly;
|
||||
}
|
||||
|
||||
public boolean isStatic(){
|
||||
@@ -388,6 +388,7 @@ public class Block extends BlockStorage{
|
||||
for(ItemStack stack : requirements){
|
||||
buildCost += stack.amount * stack.item.cost;
|
||||
}
|
||||
buildCost *= buildCostMultiplier;
|
||||
|
||||
if(consumes.has(ConsumeType.power)) hasPower = true;
|
||||
if(consumes.has(ConsumeType.item)) hasItems = true;
|
||||
@@ -805,7 +806,7 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
public boolean isVisible(){
|
||||
return buildVisibility.get() && !isHidden();
|
||||
return buildVisibility.visible() && !isHidden();
|
||||
}
|
||||
|
||||
public boolean isFloor(){
|
||||
@@ -822,7 +823,7 @@ public class Block extends BlockStorage{
|
||||
|
||||
@Override
|
||||
public boolean isHidden(){
|
||||
return !buildVisibility.get();
|
||||
return !buildVisibility.visible();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -831,21 +832,21 @@ public class Block extends BlockStorage{
|
||||
}
|
||||
|
||||
protected void requirements(Category cat, ItemStack[] stacks, boolean unlocked){
|
||||
requirements(cat, () -> true, stacks);
|
||||
requirements(cat, BuildVisibility.shown, stacks);
|
||||
this.alwaysUnlocked = unlocked;
|
||||
}
|
||||
|
||||
protected void requirements(Category cat, ItemStack[] stacks){
|
||||
requirements(cat, () -> true, stacks);
|
||||
requirements(cat, BuildVisibility.shown, stacks);
|
||||
}
|
||||
|
||||
/** Sets up requirements. Use only this method to set up requirements. */
|
||||
protected void requirements(Category cat, BooleanProvider visible, ItemStack[] stacks){
|
||||
protected void requirements(Category cat, BuildVisibility visible, ItemStack[] stacks){
|
||||
this.category = cat;
|
||||
this.requirements = stacks;
|
||||
this.buildVisibility = visible;
|
||||
|
||||
Arrays.sort(requirements, (a, b) -> Integer.compare(a.item.id, b.item.id));
|
||||
Arrays.sort(requirements, Structs.comparingInt(i -> i.item.id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Wall extends Block{
|
||||
solid = true;
|
||||
destructible = true;
|
||||
group = BlockGroup.walls;
|
||||
buildCostMultiplier = 5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
22
core/src/io/anuke/mindustry/world/meta/BuildVisibility.java
Normal file
22
core/src/io/anuke/mindustry/world/meta/BuildVisibility.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package io.anuke.mindustry.world.meta;
|
||||
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.mindustry.*;
|
||||
|
||||
public enum BuildVisibility{
|
||||
hidden(() -> false),
|
||||
shown(() -> true),
|
||||
debugOnly(() -> false),
|
||||
sandboxOnly(() -> Vars.state.rules.infiniteResources),
|
||||
campaignOnly(() -> Vars.world.isZone());
|
||||
|
||||
private final BooleanProvider visible;
|
||||
|
||||
public boolean visible(){
|
||||
return visible.get();
|
||||
}
|
||||
|
||||
BuildVisibility(BooleanProvider visible){
|
||||
this.visible = visible;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user