Starting items / No editor unlocks / Fixed Block#synthetic()

This commit is contained in:
Anuken
2019-01-16 19:36:30 -05:00
parent 733a064c79
commit 6510d83524
17 changed files with 508 additions and 528 deletions

View File

@@ -31,7 +31,7 @@ public class Blocks implements ContentList{
//environment
air, blockpart, spawn, space, metalfloor, deepwater, water, tar, stone, blackstone, dirt, sand, ice, snow,
grass, shrub, rock, icerock, blackrock, rocksSmall, rocksMedium,
grass, shrub, rock, icerock, blackrock, rocks,
//crafting
siliconSmelter, plastaniumCompressor, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
@@ -210,17 +210,11 @@ public class Blocks implements ContentList{
variants = 1;
}};
rocksSmall = new Rock("rocks-small"){{
rocks = new Rock("rocks"){{
variants = 2;
breakable = alwaysReplace = false;
solid = true;
}};
rocksMedium = new Rock("rocks-medium"){{
variants = 2;
breakable = alwaysReplace = false;
solid = true;
}};
//endregion
//region crafting

View File

@@ -12,9 +12,10 @@ public class Zones implements ContentList{
@Override
public void load(){
wasteland = new Zone("wasteland", new BasicGenerator(256, 256, Items.lead, Items.copper)){{
wasteland = new Zone("wasteland", new BasicGenerator(256, 256, Items.copper)){{
deployCost = ItemStack.with(Items.copper, 100);
startingItems = ItemStack.with(Items.copper, 50);
alwaysUnlocked = true;
rules = () -> new Rules(){{
waves = true;
waveTimer = true;

View File

@@ -18,14 +18,12 @@ import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.scene.utils.UIUtils;
import io.anuke.arc.util.*;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.io.MapIO;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.maps.MapMeta;
import io.anuke.mindustry.maps.MapTileData;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.mindustry.world.Block;
@@ -501,14 +499,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
for(Block block : Vars.content.blocks()){
TextureRegion[] regions = block.getCompactIcon();
if((block.synthetic() && (Recipe.getByResult(block) == null || !data.isUnlocked(Recipe.getByResult(block))))
&& block != Blocks.core){
continue;
}
if(Recipe.getByResult(block) != null && !Recipe.getByResult(block).visibility.shown()){
continue;
}
if(regions.length == 0 || regions[0] == Core.atlas.find("jjfgj")) continue;

View File

@@ -6,6 +6,7 @@ import io.anuke.arc.collection.ObjectIntMap;
import io.anuke.arc.collection.ObjectMap;
import io.anuke.arc.collection.ObjectSet;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.game.EventType.UnlockEvent;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.Item;
@@ -48,8 +49,8 @@ public class GlobalData{
/** Returns whether or not this piece of content is unlocked yet.*/
public boolean isUnlocked(UnlockableContent content){
return true;
//return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.getContentName());
//return true;
return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.getContentName());
}
/**
@@ -93,6 +94,11 @@ public class GlobalData{
for(Item item : Vars.content.items()){
items.put(item, Core.settings.getInt("item-" + item.name, 0));
}
//set up default values
if(!Core.settings.has("item-" + Items.copper)){
addItem(Items.copper, 1000);
}
}
public void save(){

View File

@@ -53,7 +53,7 @@ public class BasicGenerator extends RandomGenerator{
}
if(rocks > 0.64){
block = Blocks.rocksSmall;
block = Blocks.rocks;
}
}
}

View File

@@ -14,12 +14,18 @@ public class Zone extends UnlockableContent{
public ItemStack[] deployCost = {};
public ItemStack[] startingItems = {};
public Supplier<Rules> rules = Rules::new;
public boolean alwaysUnlocked;
public Zone(String name, Generator generator){
this.name = name;
this.generator = generator;
}
@Override
public boolean alwaysUnlocked(){
return alwaysUnlocked;
}
@Override
public boolean isHidden(){
return true;

View File

@@ -76,7 +76,7 @@ public class HudFragment extends Fragment{
if(Net.active()){
i.getStyle().imageUp = Core.scene.skin.getDrawable("icon-players");
}else{
i.setDisabled(Net.active());
i.setDisabled(false);
i.getStyle().imageUp = Core.scene.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
}
}).get();
@@ -131,7 +131,6 @@ public class HudFragment extends Fragment{
//fps display
infolabel = cont.table(t -> {
IntFormat fps = new IntFormat("fps");
IntFormat tps = new IntFormat("tps");
IntFormat ping = new IntFormat("ping");
t.label(() -> fps.get(Core.graphics.getFramesPerSecond())).padRight(10);
t.row();
@@ -364,20 +363,32 @@ public class HudFragment extends Fragment{
IntFormat wavef = new IntFormat("wave");
IntFormat enemyf = new IntFormat("wave.enemy");
IntFormat enemiesf = new IntFormat("wave.enemies");
IntFormat waitingf = new IntFormat("wave.waiting");
table.clearChildren();
table.touchable(Touchable.enabled);
table.labelWrap(() ->
(state.enemies() > 0 && !state.rules.waveTimer ?
wavef.get(state.wave) + "\n" + (state.enemies() == 1 ?
enemyf.get(state.enemies()) :
enemiesf.get(state.enemies())) :
wavef.get(state.wave) + "\n" +
(state.rules.waveTimer ?
Core.bundle.format("wave.waiting", (int)(state.wavetime/60)) :
Core.bundle.get("waiting")))
).growX().pad(8f);
StringBuilder builder = new StringBuilder();
table.labelWrap(() -> {
builder.setLength(0);
builder.append(wavef.get(state.wave));
builder.append("\n");
if(state.enemies() > 0 && !state.rules.waveTimer){
if(state.enemies() == 1){
builder.append(enemyf.get(state.enemies()));
}else{
builder.append(enemiesf.get(state.enemies()));
}
}else if(state.rules.waveTimer){
builder.append(waitingf.get((int)(state.wavetime/60)));
}else{
builder.append(Core.bundle.get("waiting"));
}
return builder;
}).growX().pad(8f);
table.setDisabled(true);
table.visible(() -> state.rules.waves);

View File

@@ -314,7 +314,7 @@ public class Block extends BaseBlock {
}
public boolean synthetic(){
return update || destructible || solid;
return update || destructible;
}
public void drawConfigure(Tile tile){