New build limits, recipe refactoring

This commit is contained in:
Anuken
2018-05-16 14:27:25 -07:00
parent a889571b98
commit 97cac33773
14 changed files with 187 additions and 177 deletions

View File

@@ -49,6 +49,8 @@ public class Vars{
public static final float aheadPathfinding = 60*15;
//how far away from spawn points the player can't place blocks
public static final float enemyspawnspace = 65;
public static final float coreBuildRange = 1000f;
//discord group URL
public static final String discordURL = "https://discord.gg/BKADYds";

View File

@@ -1,159 +1,124 @@
package io.anuke.mindustry.content;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.blocks.*;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Section;
import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.Vars.debug;
import static io.anuke.mindustry.resource.Section.*;
public class Recipes {
private static final Array<Recipe> list = Array.with(
//new Recipe(defense, DefenseBlocks.stonewall, stack(Item.stone, 12)),
new Recipe(defense, DefenseBlocks.ironwall, stack(Items.iron, 12)),
new Recipe(defense, DefenseBlocks.steelwall, stack(Items.steel, 12)),
new Recipe(defense, DefenseBlocks.titaniumwall, stack(Items.titanium, 12)),
new Recipe(defense, DefenseBlocks.diriumwall, stack(Items.densealloy, 12)),
new Recipe(defense, DefenseBlocks.steelwalllarge, stack(Items.steel, 12*4)),
new Recipe(defense, DefenseBlocks.titaniumwalllarge, stack(Items.titanium, 12*4)),
new Recipe(defense, DefenseBlocks.diriumwall, stack(Items.densealloy, 12*4)),
new Recipe(defense, DefenseBlocks.door, stack(Items.steel, 3), stack(Items.iron, 3*4)).setDesktop(),
new Recipe(defense, DefenseBlocks.largedoor, stack(Items.steel, 3*4), stack(Items.iron, 3*4*4)).setDesktop(),
new Recipe(defense, DefenseBlocks.titaniumshieldwall, stack(Items.titanium, 16)),
static {
new Recipe(defense, DefenseBlocks.ironwall, new ItemStack(Items.iron, 12));
new Recipe(defense, DefenseBlocks.steelwall, new ItemStack(Items.steel, 12));
new Recipe(defense, DefenseBlocks.titaniumwall, new ItemStack(Items.titanium, 12));
new Recipe(defense, DefenseBlocks.diriumwall, new ItemStack(Items.densealloy, 12));
new Recipe(defense, DefenseBlocks.steelwalllarge, new ItemStack(Items.steel, 12 * 4));
new Recipe(defense, DefenseBlocks.titaniumwalllarge, new ItemStack(Items.titanium, 12 * 4));
new Recipe(defense, DefenseBlocks.diriumwall, new ItemStack(Items.densealloy, 12 * 4));
new Recipe(defense, DefenseBlocks.door, new ItemStack(Items.steel, 3), new ItemStack(Items.iron, 3 * 4));
new Recipe(defense, DefenseBlocks.largedoor, new ItemStack(Items.steel, 3 * 4), new ItemStack(Items.iron, 3 * 4 * 4));
new Recipe(defense, DefenseBlocks.titaniumshieldwall, new ItemStack(Items.titanium, 16));
new Recipe(distribution, DistributionBlocks.conveyor, stack(Items.iron, 1)),
new Recipe(distribution, DistributionBlocks.steelconveyor, stack(Items.steel, 1)),
new Recipe(distribution, DistributionBlocks.pulseconveyor, stack(Items.densealloy, 1)),
new Recipe(distribution, DistributionBlocks.router, stack(Items.iron, 2)),
new Recipe(distribution, DistributionBlocks.multiplexer, stack(Items.iron, 8)),
new Recipe(distribution, DistributionBlocks.junction, stack(Items.iron, 2)),
new Recipe(distribution, DistributionBlocks.sorter, stack(Items.steel, 2)),
new Recipe(distribution, DistributionBlocks.splitter, stack(Items.steel, 1)),
new Recipe(distribution, DistributionBlocks.overflowgate, stack(Items.steel, 1)),
new Recipe(distribution, StorageBlocks.vault, stack(Items.steel, 50)),
new Recipe(distribution, StorageBlocks.core, stack(Items.steel, 50)),
new Recipe(distribution, StorageBlocks.unloader, stack(Items.steel, 5)),
new Recipe(distribution, StorageBlocks.sortedunloader, stack(Items.steel, 5)),
new Recipe(distribution, DistributionBlocks.bridgeconveyor, stack(Items.steel, 5)),
new Recipe(distribution, DistributionBlocks.laserconveyor, stack(Items.steel, 5)),
new Recipe(distribution, DistributionBlocks.conveyor, new ItemStack(Items.iron, 1));
new Recipe(distribution, DistributionBlocks.steelconveyor, new ItemStack(Items.steel, 1));
new Recipe(distribution, DistributionBlocks.pulseconveyor, new ItemStack(Items.densealloy, 1));
new Recipe(distribution, DistributionBlocks.router, new ItemStack(Items.iron, 2));
new Recipe(distribution, DistributionBlocks.multiplexer, new ItemStack(Items.iron, 8));
new Recipe(distribution, DistributionBlocks.junction, new ItemStack(Items.iron, 2));
new Recipe(distribution, DistributionBlocks.sorter, new ItemStack(Items.steel, 2));
new Recipe(distribution, DistributionBlocks.splitter, new ItemStack(Items.steel, 1));
new Recipe(distribution, DistributionBlocks.overflowgate, new ItemStack(Items.steel, 1));
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.steel, 50));
new Recipe(distribution, StorageBlocks.core, new ItemStack(Items.steel, 50));
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.steel, 5));
new Recipe(distribution, StorageBlocks.sortedunloader, new ItemStack(Items.steel, 5));
new Recipe(distribution, DistributionBlocks.bridgeconveyor, new ItemStack(Items.steel, 5));
new Recipe(distribution, DistributionBlocks.laserconveyor, new ItemStack(Items.steel, 5));
new Recipe(weapon, WeaponBlocks.doubleturret, stack(Items.iron, 7)),
new Recipe(weapon, WeaponBlocks.gatlingturret, stack(Items.iron, 8)),
new Recipe(weapon, WeaponBlocks.flameturret, stack(Items.iron, 12), stack(Items.steel, 9)),
new Recipe(weapon, WeaponBlocks.railgunturret, stack(Items.iron, 15), stack(Items.steel, 10)),
new Recipe(weapon, WeaponBlocks.laserturret, stack(Items.steel, 12), stack(Items.titanium, 12)),
new Recipe(weapon, WeaponBlocks.flakturret, stack(Items.steel, 25), stack(Items.titanium, 15)),
new Recipe(weapon, WeaponBlocks.teslaturret, stack(Items.steel, 20), stack(Items.titanium, 25), stack(Items.densealloy, 15)),
new Recipe(weapon, WeaponBlocks.liquidturret, stack(Items.steel, 80), stack(Items.titanium, 70), stack(Items.densealloy, 60)),
new Recipe(weapon, WeaponBlocks.chainturret, stack(Items.steel, 50), stack(Items.titanium, 25), stack(Items.densealloy, 40)),
new Recipe(weapon, WeaponBlocks.titanturret, stack(Items.steel, 70), stack(Items.titanium, 50), stack(Items.densealloy, 55)),
new Recipe(weapon, WeaponBlocks.missileturret, stack(Items.steel, 70), stack(Items.titanium, 50), stack(Items.densealloy, 55)),
new Recipe(weapon, WeaponBlocks.fornaxcannon, stack(Items.steel, 70), stack(Items.titanium, 50), stack(Items.densealloy, 55)),
new Recipe(weapon, WeaponBlocks.doubleturret, new ItemStack(Items.iron, 7));
new Recipe(weapon, WeaponBlocks.gatlingturret, new ItemStack(Items.iron, 8));
new Recipe(weapon, WeaponBlocks.flameturret, new ItemStack(Items.iron, 12), new ItemStack(Items.steel, 9));
new Recipe(weapon, WeaponBlocks.railgunturret, new ItemStack(Items.iron, 15), new ItemStack(Items.steel, 10));
new Recipe(weapon, WeaponBlocks.laserturret, new ItemStack(Items.steel, 12), new ItemStack(Items.titanium, 12));
new Recipe(weapon, WeaponBlocks.flakturret, new ItemStack(Items.steel, 25), new ItemStack(Items.titanium, 15));
new Recipe(weapon, WeaponBlocks.teslaturret, new ItemStack(Items.steel, 20), new ItemStack(Items.titanium, 25), new ItemStack(Items.densealloy, 15));
new Recipe(weapon, WeaponBlocks.liquidturret, new ItemStack(Items.steel, 80), new ItemStack(Items.titanium, 70), new ItemStack(Items.densealloy, 60));
new Recipe(weapon, WeaponBlocks.chainturret, new ItemStack(Items.steel, 50), new ItemStack(Items.titanium, 25), new ItemStack(Items.densealloy, 40));
new Recipe(weapon, WeaponBlocks.titanturret, new ItemStack(Items.steel, 70), new ItemStack(Items.titanium, 50), new ItemStack(Items.densealloy, 55));
new Recipe(weapon, WeaponBlocks.missileturret, new ItemStack(Items.steel, 70), new ItemStack(Items.titanium, 50), new ItemStack(Items.densealloy, 55));
new Recipe(weapon, WeaponBlocks.fornaxcannon, new ItemStack(Items.steel, 70), new ItemStack(Items.titanium, 50), new ItemStack(Items.densealloy, 55));
new Recipe(crafting, CraftingBlocks.smelter, stack(Items.iron, 40)),
new Recipe(crafting, CraftingBlocks.alloysmelter, stack(Items.titanium, 50), stack(Items.steel, 50)),
new Recipe(crafting, CraftingBlocks.powersmelter, stack(Items.steel, 30), stack(Items.iron, 30)),
new Recipe(crafting, CraftingBlocks.poweralloysmelter, stack(Items.steel, 30), stack(Items.iron, 30)),
new Recipe(crafting, CraftingBlocks.separator, stack(Items.steel, 30), stack(Items.iron, 30)),
new Recipe(crafting, CraftingBlocks.centrifuge, stack(Items.steel, 30), stack(Items.iron, 30)),
new Recipe(crafting, CraftingBlocks.siliconsmelter, stack(Items.steel, 30), stack(Items.iron, 30)),
new Recipe(crafting, CraftingBlocks.oilRefinery, stack(Items.steel, 15), stack(Items.iron, 15)),
new Recipe(crafting, CraftingBlocks.biomatterCompressor, stack(Items.steel, 15), stack(Items.iron, 15)),
new Recipe(crafting, CraftingBlocks.plasticFormer, stack(Items.steel, 30), stack(Items.titanium, 15)),
new Recipe(crafting, CraftingBlocks.cryofluidmixer, stack(Items.steel, 30), stack(Items.titanium, 15)),
new Recipe(crafting, CraftingBlocks.pulverizer, stack(Items.steel, 10), stack(Items.iron, 10)),
new Recipe(crafting, CraftingBlocks.stoneFormer, stack(Items.steel, 10), stack(Items.iron, 10)),
new Recipe(crafting, CraftingBlocks.melter, stack(Items.steel, 30), stack(Items.titanium, 15)),
new Recipe(crafting, CraftingBlocks.incinerator, stack(Items.steel, 60), stack(Items.iron, 60)),
new Recipe(crafting, CraftingBlocks.weaponFactory, stack(Items.steel, 60), stack(Items.iron, 60)).setDesktop(),
new Recipe(crafting, CraftingBlocks.smelter, new ItemStack(Items.iron, 40));
new Recipe(crafting, CraftingBlocks.alloysmelter, new ItemStack(Items.titanium, 50), new ItemStack(Items.steel, 50));
new Recipe(crafting, CraftingBlocks.powersmelter, new ItemStack(Items.steel, 30), new ItemStack(Items.iron, 30));
new Recipe(crafting, CraftingBlocks.poweralloysmelter, new ItemStack(Items.steel, 30), new ItemStack(Items.iron, 30));
new Recipe(crafting, CraftingBlocks.separator, new ItemStack(Items.steel, 30), new ItemStack(Items.iron, 30));
new Recipe(crafting, CraftingBlocks.centrifuge, new ItemStack(Items.steel, 30), new ItemStack(Items.iron, 30));
new Recipe(crafting, CraftingBlocks.siliconsmelter, new ItemStack(Items.steel, 30), new ItemStack(Items.iron, 30));
new Recipe(crafting, CraftingBlocks.oilRefinery, new ItemStack(Items.steel, 15), new ItemStack(Items.iron, 15));
new Recipe(crafting, CraftingBlocks.biomatterCompressor, new ItemStack(Items.steel, 15), new ItemStack(Items.iron, 15));
new Recipe(crafting, CraftingBlocks.plasticFormer, new ItemStack(Items.steel, 30), new ItemStack(Items.titanium, 15));
new Recipe(crafting, CraftingBlocks.cryofluidmixer, new ItemStack(Items.steel, 30), new ItemStack(Items.titanium, 15));
new Recipe(crafting, CraftingBlocks.pulverizer, new ItemStack(Items.steel, 10), new ItemStack(Items.iron, 10));
new Recipe(crafting, CraftingBlocks.stoneFormer, new ItemStack(Items.steel, 10), new ItemStack(Items.iron, 10));
new Recipe(crafting, CraftingBlocks.melter, new ItemStack(Items.steel, 30), new ItemStack(Items.titanium, 15));
new Recipe(crafting, CraftingBlocks.incinerator, new ItemStack(Items.steel, 60), new ItemStack(Items.iron, 60));
new Recipe(crafting, CraftingBlocks.weaponFactory, new ItemStack(Items.steel, 60), new ItemStack(Items.iron, 60)).setDesktop();
new Recipe(production, ProductionBlocks.ironDrill, stack(Items.iron, 25)),
new Recipe(production, ProductionBlocks.reinforcedDrill, stack(Items.iron, 25)),
new Recipe(production, ProductionBlocks.steelDrill, stack(Items.iron, 25)),
new Recipe(production, ProductionBlocks.titaniumDrill, stack(Items.iron, 25)),
new Recipe(production, ProductionBlocks.laserdrill, stack(Items.titanium, 40), stack(Items.densealloy, 40)),
new Recipe(production, ProductionBlocks.nucleardrill, stack(Items.titanium, 40), stack(Items.densealloy, 40)),
new Recipe(production, ProductionBlocks.plasmadrill, stack(Items.titanium, 40), stack(Items.densealloy, 40)),
new Recipe(production, ProductionBlocks.cultivator, stack(Items.titanium, 40), stack(Items.densealloy, 40)),
new Recipe(production, ProductionBlocks.waterextractor, stack(Items.titanium, 40), stack(Items.densealloy, 40)),
new Recipe(production, ProductionBlocks.oilextractor, stack(Items.titanium, 40), stack(Items.densealloy, 40)),
new Recipe(production, ProductionBlocks.ironDrill, new ItemStack(Items.iron, 25));
new Recipe(production, ProductionBlocks.reinforcedDrill, new ItemStack(Items.iron, 25));
new Recipe(production, ProductionBlocks.steelDrill, new ItemStack(Items.iron, 25));
new Recipe(production, ProductionBlocks.titaniumDrill, new ItemStack(Items.iron, 25));
new Recipe(production, ProductionBlocks.laserdrill, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40));
new Recipe(production, ProductionBlocks.nucleardrill, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40));
new Recipe(production, ProductionBlocks.plasmadrill, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40));
new Recipe(production, ProductionBlocks.cultivator, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40));
new Recipe(production, ProductionBlocks.waterextractor, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40));
new Recipe(production, ProductionBlocks.oilextractor, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40));
new Recipe(power, PowerBlocks.powernode, stack(Items.steel, 3), stack(Items.iron, 3)),
new Recipe(power, PowerBlocks.powernodelarge, stack(Items.steel, 3), stack(Items.iron, 3)),
new Recipe(power, PowerBlocks.battery, stack(Items.steel, 5), stack(Items.iron, 5)),
new Recipe(power, PowerBlocks.batteryLarge, stack(Items.steel, 5), stack(Items.iron, 5)),
new Recipe(power, PowerBlocks.combustiongenerator, stack(Items.iron, 30)),
new Recipe(power, PowerBlocks.liquidcombustiongenerator, stack(Items.iron, 30)),
new Recipe(power, PowerBlocks.thermalgenerator, stack(Items.steel, 30)),
new Recipe(power, PowerBlocks.rtgenerator, stack(Items.titanium, 20), stack(Items.steel, 20)),
new Recipe(power, PowerBlocks.solarpanel, stack(Items.iron, 30), stack(Items.silicon, 20)),
new Recipe(power, PowerBlocks.largesolarpanel, stack(Items.iron, 30), stack(Items.silicon, 20)),
new Recipe(power, PowerBlocks.nuclearReactor, stack(Items.titanium, 40), stack(Items.densealloy, 40), stack(Items.steel, 50)),
new Recipe(power, PowerBlocks.fusionReactor, stack(Items.titanium, 40), stack(Items.densealloy, 40), stack(Items.steel, 50)),
new Recipe(power, PowerBlocks.powernode, new ItemStack(Items.steel, 3), new ItemStack(Items.iron, 3));
new Recipe(power, PowerBlocks.powernodelarge, new ItemStack(Items.steel, 3), new ItemStack(Items.iron, 3));
new Recipe(power, PowerBlocks.battery, new ItemStack(Items.steel, 5), new ItemStack(Items.iron, 5));
new Recipe(power, PowerBlocks.batteryLarge, new ItemStack(Items.steel, 5), new ItemStack(Items.iron, 5));
new Recipe(power, PowerBlocks.combustiongenerator, new ItemStack(Items.iron, 30));
new Recipe(power, PowerBlocks.liquidcombustiongenerator, new ItemStack(Items.iron, 30));
new Recipe(power, PowerBlocks.thermalgenerator, new ItemStack(Items.steel, 30));
new Recipe(power, PowerBlocks.rtgenerator, new ItemStack(Items.titanium, 20), new ItemStack(Items.steel, 20));
new Recipe(power, PowerBlocks.solarpanel, new ItemStack(Items.iron, 30), new ItemStack(Items.silicon, 20));
new Recipe(power, PowerBlocks.largesolarpanel, new ItemStack(Items.iron, 30), new ItemStack(Items.silicon, 20));
new Recipe(power, PowerBlocks.nuclearReactor, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40), new ItemStack(Items.steel, 50));
new Recipe(power, PowerBlocks.fusionReactor, new ItemStack(Items.titanium, 40), new ItemStack(Items.densealloy, 40), new ItemStack(Items.steel, 50));
new Recipe(power, PowerBlocks.shieldgenerator, stack(Items.titanium, 30), stack(Items.densealloy, 30)),
new Recipe(power, PowerBlocks.shieldgenerator, new ItemStack(Items.titanium, 30), new ItemStack(Items.densealloy, 30));
new Recipe(distribution, PowerBlocks.teleporter, stack(Items.steel, 30), stack(Items.densealloy, 40)),
new Recipe(distribution, PowerBlocks.teleporter, new ItemStack(Items.steel, 30), new ItemStack(Items.densealloy, 40));
new Recipe(power, PowerBlocks.repairturret, stack(Items.iron, 30)),
new Recipe(power, PowerBlocks.megarepairturret, stack(Items.iron, 20), stack(Items.steel, 30)),
new Recipe(power, PowerBlocks.repairturret, new ItemStack(Items.iron, 30));
new Recipe(power, PowerBlocks.megarepairturret, new ItemStack(Items.iron, 20), new ItemStack(Items.steel, 30));
new Recipe(liquid, LiquidBlocks.conduit, stack(Items.steel, 1)),
new Recipe(liquid, LiquidBlocks.pulseconduit, stack(Items.titanium, 1), stack(Items.steel, 1)),
new Recipe(liquid, LiquidBlocks.liquidrouter, stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.liquidtank, stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.liquidjunction, stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.bridgeconduit, stack(Items.titanium, 2), stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.laserconduit, stack(Items.titanium, 2), stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.conduit, new ItemStack(Items.steel, 1));
new Recipe(liquid, LiquidBlocks.pulseconduit, new ItemStack(Items.titanium, 1), new ItemStack(Items.steel, 1));
new Recipe(liquid, LiquidBlocks.liquidrouter, new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.liquidtank, new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.liquidjunction, new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.bridgeconduit, new ItemStack(Items.titanium, 2), new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.laserconduit, new ItemStack(Items.titanium, 2), new ItemStack(Items.steel, 2));
new Recipe(liquid, LiquidBlocks.pump, stack(Items.steel, 10)),
new Recipe(liquid, LiquidBlocks.fluxpump, stack(Items.steel, 10), stack(Items.densealloy, 5)),
new Recipe(liquid, LiquidBlocks.pump, new ItemStack(Items.steel, 10));
new Recipe(liquid, LiquidBlocks.fluxpump, new ItemStack(Items.steel, 10), new ItemStack(Items.densealloy, 5));
new Recipe(units, UnitBlocks.repairPoint, stack(Items.steel, 10)),
new Recipe(units, UnitBlocks.resupplyPoint, stack(Items.steel, 10)),
new Recipe(units, UnitBlocks.repairPoint, new ItemStack(Items.steel, 10));
new Recipe(units, UnitBlocks.resupplyPoint, new ItemStack(Items.steel, 10));
//new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)),
//new Recipe(units, UnitBlocks.vtolFactory, stack(Items.steel, 10)),
//new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)),
//new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)),
//new Recipe(units, UnitBlocks.walkerFactory, stack(Items.steel, 10)),
//new Recipe(units, UnitBlocks.droneFactory, new ItemStack(Items.steel, 10));
//new Recipe(units, UnitBlocks.vtolFactory, new ItemStack(Items.steel, 10));
//new Recipe(units, UnitBlocks.droneFactory, new ItemStack(Items.steel, 10));
//new Recipe(units, UnitBlocks.droneFactory, new ItemStack(Items.steel, 10));
//new Recipe(units, UnitBlocks.walkerFactory, new ItemStack(Items.steel, 10));
new Recipe(units, DebugBlocks.itemSource, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.itemVoid, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.liquidSource, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.powerVoid, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.powerInfinite, stack(Items.steel, 10), stack(Items.densealloy, 5)).setDebug()
);
private static ItemStack stack(Item item, int amount){
return new ItemStack(item, amount);
}
public static Array<Recipe> all(){
return list;
}
public static Recipe getByResult(Block block){
for(Recipe recipe : list){
if(recipe.result == block){
return recipe;
}
}
return null;
}
public static Array<Recipe> getBy(Section section, Array<Recipe> r){
for(Recipe recipe : list){
if(recipe.section == section && !(Vars.mobile && recipe.desktopOnly) && !(!debug && recipe.debugOnly)) {
r.add(recipe);
}
}
return r;
}
new Recipe(units, DebugBlocks.itemSource, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.itemVoid, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.liquidSource, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.powerVoid, new ItemStack(Items.steel, 10)).setDebug();
new Recipe(units, DebugBlocks.powerInfinite, new ItemStack(Items.steel, 10), new ItemStack(Items.densealloy, 5)).setDebug();
}
}

View File

@@ -3,7 +3,6 @@ package io.anuke.mindustry.core;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.IntSet;
import com.badlogic.gdx.utils.reflect.ReflectionException;
import io.anuke.mindustry.content.UpgradeRecipes;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.BulletType;
@@ -15,9 +14,9 @@ import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.NetworkIO;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Placement;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
@@ -164,12 +163,12 @@ public class NetClient extends Module {
Net.handleClient(PlacePacket.class, (packet) -> {
Player placer = playerGroup.getByID(packet.playerid);
Placement.placeBlock(placer, packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, Timers.get("placeblocksound", 10));
Placement.placeBlock(placer, packet.x, packet.y, Recipe.getByID(packet.recipe), packet.rotation, true, Timers.get("placeblocksound", 10));
for(Player player : players) {
if (packet.playerid == player.id) {
Tile tile = world.tile(packet.x, packet.y);
if (tile != null) Block.getByID(packet.block).placed(tile);
if (tile != null) Recipe.getByID(packet.recipe).result.placed(tile);
break;
}
}

View File

@@ -5,7 +5,6 @@ import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Mechs;
import io.anuke.mindustry.content.Recipes;
import io.anuke.mindustry.content.UpgradeRecipes;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.BulletType;
@@ -196,12 +195,11 @@ public class NetServer extends Module{
Player placer = connections.get(id);
packet.playerid = placer.id;
Block block = Block.getByID(packet.block);
Recipe recipe = Recipe.getByID(packet.recipe);
Block block = recipe.result;
if(!Placement.validPlace(placer.team, packet.x, packet.y, block, packet.rotation)) return;
Recipe recipe = Recipes.getByResult(block);
if(recipe == null || recipe.debugOnly != debug) return;
Tile tile = world.tile(packet.x, packet.y);
@@ -214,7 +212,7 @@ public class NetServer extends Module{
state.inventory.removeItems(recipe.requirements);
Placement.placeBlock(placer, packet.x, packet.y, block, packet.rotation, true, false);
Placement.placeBlock(placer, packet.x, packet.y, recipe, packet.rotation, true, false);
TraceInfo trace = admins.getTraceByID(getUUID(id));

View File

@@ -38,8 +38,8 @@ import static io.anuke.mindustry.Vars.*;
public class Player extends Unit implements BlockPlacer{
static final float speed = 1.1f;
static final float dashSpeed = 1.8f;
static final float placeDistance = 80f;
static final int maxPlacing = 5;
public static final float placeDistance = 80f;
public static final int maxPlacing = 5;
static final int timerDash = 0;
static final int timerRegen = 3;

View File

@@ -176,7 +176,7 @@ public class AndroidInput extends InputHandler{
validPlace(x, y, recipe.result) && cursorNear() &&
state.inventory.hasItems(recipe.requirements)){
placeBlock(x, y, recipe.result, rotation, true, sound);
placeBlock(x, y, recipe, rotation, true, sound);
for(ItemStack stack : recipe.requirements){
state.inventory.removeItem(stack);

View File

@@ -162,7 +162,7 @@ public abstract class InputHandler extends InputAdapter{
validPlace(x, y, recipe.result) && !ui.hasMouse() && cursorNear() &&
state.inventory.hasItems(recipe.requirements)){
placeBlock(x, y, recipe.result, rotation, true, sound);
placeBlock(x, y, recipe, rotation, true, sound);
for(ItemStack stack : recipe.requirements){
state.inventory.removeItem(stack);
@@ -186,20 +186,27 @@ public abstract class InputHandler extends InputAdapter{
}
public boolean validPlace(int x, int y, Block type){
return Placement.validPlace(player.team, x, y, type, rotation);
for(Tile tile : state.teams.get(player.team).cores){
if(tile.distanceTo(x * tilesize, y * tilesize) < coreBuildRange){
return Placement.validPlace(player.team, x, y, type, rotation) &&
Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
}
}
return false;
}
public boolean validBreak(int x, int y){
return Placement.validBreak(player.team, x, y);
}
public void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
public void placeBlock(int x, int y, Recipe recipe, int rotation, boolean effects, boolean sound){
if(!Net.client()){ //is server or singleplayer
threads.run(() -> Placement.placeBlock(player, x, y, result, rotation, effects, sound));
threads.run(() -> Placement.placeBlock(player, x, y, recipe, rotation, effects, sound));
}
if(Net.active()){
NetEvents.handlePlace(player, x, y, result, rotation);
NetEvents.handlePlace(player, x, y, recipe, rotation);
}
//todo fix this, call placed()

View File

@@ -7,14 +7,11 @@ import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.CallEvent;
import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.entities.Entity;
import static io.anuke.mindustry.Vars.*;
@@ -102,13 +99,13 @@ public class NetEvents {
Net.send(packet, SendMode.udp);
}
public static void handlePlace(Player player, int x, int y, Block block, int rotation){
public static void handlePlace(Player player, int x, int y, Recipe recipe, int rotation){
PlacePacket packet = Pools.obtain(PlacePacket.class);
packet.x = (short)x;
packet.y = (short)y;
packet.rotation = (byte)rotation;
packet.playerid = player.id;
packet.block = block.id;
packet.recipe = (byte)recipe.id;
Net.send(packet, SendMode.tcp);
}

View File

@@ -3,7 +3,6 @@ package io.anuke.mindustry.net;
import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.TimeUtils;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.Method;
import com.badlogic.gdx.utils.reflect.ReflectionException;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player;
@@ -220,7 +219,7 @@ public class Packets {
public int playerid;
public byte rotation;
public short x, y;
public int block;
public byte recipe;
@Override
public void write(ByteBuffer buffer) {
@@ -228,7 +227,7 @@ public class Packets {
buffer.put(rotation);
buffer.putShort(x);
buffer.putShort(y);
buffer.putInt(block);
buffer.put(recipe);
}
@Override
@@ -237,7 +236,7 @@ public class Packets {
rotation = buffer.get();
x = buffer.getShort();
y = buffer.getShort();
block = buffer.getInt();
recipe = buffer.get();
}
}

View File

@@ -1,17 +1,32 @@
package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.world.Block;
import static io.anuke.mindustry.Vars.debug;
public class Recipe {
public Block result;
public ItemStack[] requirements;
public Section section;
private static int lastid;
private static Array<Recipe> allRecipes = new Array<>();
private static ObjectMap<Block, Recipe> recipeMap = new ObjectMap<>();
public final int id;
public final Block result;
public final ItemStack[] requirements;
public final Section section;
public boolean desktopOnly = false, debugOnly = false;
public Recipe(Section section, Block result, ItemStack... requirements){
this.id = lastid ++;
this.result = result;
this.requirements = requirements;
this.section = section;
allRecipes.add(this);
recipeMap.put(result, this);
}
public Recipe setDesktop(){
@@ -23,4 +38,30 @@ public class Recipe {
debugOnly = true;
return this;
}
public static Array<Recipe> getBySection(Section section, Array<Recipe> r){
for(Recipe recipe : allRecipes){
if(recipe.section == section && !(Vars.mobile && recipe.desktopOnly) && !(!debug && recipe.debugOnly)) {
r.add(recipe);
}
}
return r;
}
public static Array<Recipe> all(){
return allRecipes;
}
public static Recipe getByResult(Block block){
return recipeMap.get(block);
}
public static Recipe getByID(int id){
if(id < 0 || id >= allRecipes.size){
return null;
}else{
return allRecipes.get(id);
}
}
}

View File

@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.IntSet;
import io.anuke.mindustry.content.Recipes;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.input.InputHandler;
@@ -98,7 +97,7 @@ public class BlocksFragment implements Fragment{
for (Section sec : Section.values()) {
recipes.clear();
io.anuke.mindustry.content.Recipes.getBy(sec, recipes);
Recipe.getBySection(sec, recipes);
maxcol = Math.max((int) ((float) recipes.size / rows + 1), maxcol);
}
@@ -106,7 +105,7 @@ public class BlocksFragment implements Fragment{
int secrows = 4;
recipes.clear();
Recipes.getBy(sec, recipes);
Recipe.getBySection(sec, recipes);
Table table = new Table();

View File

@@ -3,7 +3,6 @@ package io.anuke.mindustry.world;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.Recipes;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.BlockPlacer;
@@ -28,7 +27,7 @@ public class Placement {
if(tile == null) return null;
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
Recipe result = Recipes.getByResult(block);
Recipe result = Recipe.getByResult(block);
if(result != null){
for(ItemStack stack : result.requirements){
@@ -58,9 +57,10 @@ public class Placement {
return block;
}
public static void placeBlock(BlockPlacer placer, int x, int y, Block result, int rotation, boolean effects, boolean sound){
public static void placeBlock(BlockPlacer placer, int x, int y, Recipe recipe, int rotation, boolean effects, boolean sound){
Tile tile = world.tile(x, y);
Team team = placer.getTeam();
Block result = recipe.result;
//just in case
if(tile == null) return;
@@ -98,7 +98,7 @@ public class Placement {
}
public static boolean validPlace(Team team, int x, int y, Block type, int rotation){
Recipe recipe = Recipes.getByResult(type);
Recipe recipe = Recipe.getByResult(type);
if(recipe == null || !state.inventory.hasItems(recipe.requirements)){
return false;

View File

@@ -2,19 +2,20 @@ package io.anuke.mindustry.world.blocks.types;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.fx.ExplosionFx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.effect.Rubble;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.world.BarType;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.BlockBar;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.mindustry.content.fx.*;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.graphics.Draw;
import io.anuke.mindustry.entities.effect.*;
public class BuildBlock extends Block {
private static final float decaySpeedScl = 4f;
@@ -89,6 +90,7 @@ public class BuildBlock extends Block {
public class BuildEntity extends TileEntity{
public Block result;
public Recipe recipe;
public float progress = 0.05f;
}
}