This commit is contained in:
Anuken
2019-06-07 10:25:14 -04:00
762 changed files with 7110 additions and 7228 deletions

View File

@@ -15,6 +15,7 @@ import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.*;
@@ -59,6 +60,15 @@ public class Logic implements ApplicationListener{
state.set(State.playing);
state.wavetime = state.rules.waveSpacing * 2; //grace period of 2x wave time before game starts
Events.fire(new PlayEvent());
//add starting items
if(!world.isZone()){
for(Tile core : state.teams.get(defaultTeam).cores){
for(ItemStack stack : state.rules.startingItems){
core.entity.items.add(stack.item, stack.amount);
}
}
}
}
public void reset(){

View File

@@ -11,13 +11,20 @@ public class DefaultWaves{
if(spawns == null && UnitTypes.dagger != null){
spawns = Array.with(
new SpawnGroup(UnitTypes.dagger){{
end = 8;
end = 10;
unitScaling = 2f;
}},
new SpawnGroup(UnitTypes.crawler){{
begin = 4;
end = 13;
unitAmount = 2;
unitScaling = 1.5f;
}},
new SpawnGroup(UnitTypes.wraith){{
begin = 12;
end = 14;
end = 16;
unitScaling = 1f;
}},
@@ -29,7 +36,7 @@ public class DefaultWaves{
}},
new SpawnGroup(UnitTypes.titan){{
begin = 9;
begin = 7;
spacing = 3;
unitScaling = 2;
@@ -39,7 +46,7 @@ public class DefaultWaves{
new SpawnGroup(UnitTypes.dagger){{
begin = 8;
unitScaling = 1;
unitAmount = 1;
unitAmount = 4;
spacing = 2;
}},

View File

@@ -2,7 +2,9 @@ package io.anuke.mindustry.game;
import io.anuke.annotations.Annotations.Serialize;
import io.anuke.arc.collection.Array;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.io.JsonIO;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Zone;
/**
@@ -63,6 +65,8 @@ public class Rules{
public boolean attackMode = false;
/** Whether this is the editor gamemode. */
public boolean editor = false;
/** Items that the player starts with here. Not applicable to zones.*/
public Array<ItemStack> startingItems = Array.with(new ItemStack(Items.copper, 200));
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
public Rules copy(){

View File

@@ -5,13 +5,13 @@ import io.anuke.arc.util.serialization.JsonValue;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.game.Rules;
import io.anuke.mindustry.game.SpawnGroup;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.Zone;
import io.anuke.mindustry.type.*;
public class JsonIO{
private static Json json = new Json(){{
setIgnoreUnknownFields(true);
setElementType(Rules.class, "spawns", SpawnGroup.class);
setElementType(Rules.class, "startingItems", ItemStack.class);
setSerializer(Zone.class, new Serializer<Zone>(){
@Override
@@ -24,6 +24,18 @@ public class JsonIO{
return Vars.content.getByName(ContentType.zone, jsonData.asString());
}
});
setSerializer(Item.class, new Serializer<Item>(){
@Override
public void write(Json json, Item object, Class knownType){
json.writeValue(object.name);
}
@Override
public Item read(Json json, JsonValue jsonData, Class type){
return Vars.content.getByName(ContentType.item, jsonData.asString());
}
});
}};
public static String write(Object object){

View File

@@ -18,7 +18,7 @@ import static io.anuke.mindustry.Vars.*;
public class Maps implements Disposable{
/** List of all built-in maps. Filenames only. */
private static final String[] defaultMapNames = {"fortress", "shoreline", "labyrinth", "islands"};
private static final String[] defaultMapNames = {"fortress", "labyrinth", "islands"};
/** All maps stored in an ordered array. */
private Array<Map> maps = new Array<>();
/** Serializer for meta. */

View File

@@ -11,6 +11,11 @@ public class ItemStack implements Comparable<ItemStack>{
this.amount = amount;
}
//serialization only
public ItemStack(){
}
public boolean equals(ItemStack other){
return other != null && other.item == item && other.amount == amount;
}

View File

@@ -42,10 +42,10 @@ public class CustomRulesDialog extends FloatingDialog{
title("$rules.title.waves");
check("$rules.waves", b -> rules.waves = b, () -> rules.waves);
check("$rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer, () -> rules.waves);
check("$rules.waitForWaveToEnd", b -> rules.waitForWaveToEnd = b, () -> rules.waitForWaveToEnd, () -> rules.waves);
number("$rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> rules.waves);
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> rules.waves);
check("$rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer);
check("$rules.waitForWaveToEnd", b -> rules.waitForWaveToEnd = b, () -> rules.waitForWaveToEnd);
number("$rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> true);
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> true);
title("$rules.title.respawns");
check("$rules.limitedRespawns", b -> rules.limitedRespawns = b, () -> rules.limitedRespawns);

View File

@@ -1,5 +1,7 @@
package io.anuke.mindustry.world.blocks;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@@ -28,6 +30,28 @@ public class BlockPart extends Block{
return parts[dx + maxSize/2][dy + maxSize/2];
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
return tile.link().block().acceptItem(item, tile.link(), source);
}
@Override
public void handleItem(Item item, Tile tile, Tile source){
tile.link().block().handleItem(item, tile.link(), source);
}
@Override
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
Block block = tile.link().block();
block.handleLiquid(tile.link(), source, liquid, amount);
}
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
Block block = tile.link().block();
return block.hasLiquids && block.acceptLiquid(tile.link(), source, liquid, amount);
}
@Override
public Tile linked(Tile tile){
return tile.getNearby(-dx, -dy);

View File

@@ -60,6 +60,11 @@ public class ForceProjector extends Block{
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).boost().update(false);
}
@Override
public boolean outputsItems(){
return false;
}
@Override
public void load(){
super.load();

View File

@@ -45,6 +45,11 @@ public class MendProjector extends Block{
hasItems = true;
}
@Override
public boolean outputsItems(){
return false;
}
@Override
public void load(){
super.load();

View File

@@ -43,6 +43,11 @@ public class OverdriveProjector extends Block{
canOverdrive = false;
}
@Override
public boolean outputsItems(){
return false;
}
@Override
public void load(){
super.load();

View File

@@ -42,6 +42,7 @@ public class Junction extends Block{
Item item = content.item(BufferItem.item(l));
Tile dest = tile.getNearby(i);
if(dest != null) dest = dest.link();
//skip blocks that don't want the item, keep waiting until they do
if(dest == null || !dest.block().acceptItem(item, dest, tile)){