mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 04:28:27 +07:00
Added core recipe, made core destructible
This commit is contained in:
parent
649fc5a0e6
commit
5d309c39cf
@ -30,6 +30,9 @@ import java.util.Arrays;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class Vars{
|
public class Vars{
|
||||||
|
public static final String discordURL = "https://discord.gg/mindustry";
|
||||||
|
public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases";
|
||||||
|
public static final String crashReportURL = "http://mindustry.us.to/report";
|
||||||
//time between waves in frames (on normal mode)
|
//time between waves in frames (on normal mode)
|
||||||
public static final float wavespace = 60 * 60 * 1.5f;
|
public static final float wavespace = 60 * 60 * 1.5f;
|
||||||
//set ridiculously high for now
|
//set ridiculously high for now
|
||||||
@ -38,10 +41,7 @@ public class Vars{
|
|||||||
public static final Team defaultTeam = Team.blue;
|
public static final Team defaultTeam = Team.blue;
|
||||||
//team of the enemy in waves
|
//team of the enemy in waves
|
||||||
public static final Team waveTeam = Team.red;
|
public static final Team waveTeam = Team.red;
|
||||||
|
public static final float unlockResourceScaling = 1.5f;
|
||||||
public static final String discordURL = "https://discord.gg/mindustry";
|
|
||||||
public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases";
|
|
||||||
public static final String crashReportURL = "http://mindustry.us.to/report";
|
|
||||||
public static final int maxTextLength = 150;
|
public static final int maxTextLength = 150;
|
||||||
public static final int maxNameLength = 40;
|
public static final int maxNameLength = 40;
|
||||||
public static final float itemSize = 5f;
|
public static final float itemSize = 5f;
|
||||||
|
@ -122,9 +122,13 @@ public class Recipes implements ContentList{
|
|||||||
new Recipe(power, PowerBlocks.thoriumReactor, new ItemStack(Items.lead, 600), new ItemStack(Items.silicon, 400), new ItemStack(Items.densealloy, 300), new ItemStack(Items.thorium, 300));
|
new Recipe(power, PowerBlocks.thoriumReactor, new ItemStack(Items.lead, 600), new ItemStack(Items.silicon, 400), new ItemStack(Items.densealloy, 300), new ItemStack(Items.thorium, 300));
|
||||||
new Recipe(power, PowerBlocks.rtgGenerator, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 150), new ItemStack(Items.phasematter, 50), new ItemStack(Items.plastanium, 150), new ItemStack(Items.thorium, 100));
|
new Recipe(power, PowerBlocks.rtgGenerator, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 150), new ItemStack(Items.phasematter, 50), new ItemStack(Items.plastanium, 150), new ItemStack(Items.thorium, 100));
|
||||||
|
|
||||||
//new Recipe(distribution, StorageBlocks.core, new ItemStack(Items.densealloy, 50));
|
|
||||||
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 40), new ItemStack(Items.silicon, 50));
|
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 40), new ItemStack(Items.silicon, 50));
|
||||||
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.densealloy, 500), new ItemStack(Items.thorium, 350));
|
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.densealloy, 500), new ItemStack(Items.thorium, 350));
|
||||||
|
new Recipe(distribution, StorageBlocks.core,
|
||||||
|
new ItemStack(Items.copper, 2000), new ItemStack(Items.densealloy, 1500),
|
||||||
|
new ItemStack(Items.silicon, 1500), new ItemStack(Items.thorium, 500),
|
||||||
|
new ItemStack(Items.surgealloy, 500), new ItemStack(Items.phasematter, 750)
|
||||||
|
);
|
||||||
|
|
||||||
//DRILLS, PRODUCERS
|
//DRILLS, PRODUCERS
|
||||||
new Recipe(production, ProductionBlocks.mechanicalDrill, new ItemStack(Items.copper, 50));
|
new Recipe(production, ProductionBlocks.mechanicalDrill, new ItemStack(Items.copper, 50));
|
||||||
|
@ -20,6 +20,7 @@ import io.anuke.mindustry.input.InputHandler;
|
|||||||
import io.anuke.mindustry.input.MobileInput;
|
import io.anuke.mindustry.input.MobileInput;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.Map;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
@ -270,9 +271,14 @@ public class Control extends Module{
|
|||||||
control.database().unlockContent(players[0].inventory.getItem().item);
|
control.database().unlockContent(players[0].inventory.getItem().item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outer:
|
||||||
for(int i = 0; i < content.recipes().size; i ++){
|
for(int i = 0; i < content.recipes().size; i ++){
|
||||||
Recipe recipe = content.recipes().get(i);
|
Recipe recipe = content.recipes().get(i);
|
||||||
if(!recipe.hidden && recipe.requirements != null && entity.items.has(recipe.requirements, 1.4f)){
|
if(!recipe.hidden && recipe.requirements != null){
|
||||||
|
for(ItemStack stack : recipe.requirements){
|
||||||
|
if(!entity.items.has(stack.item, Math.min((int) (stack.amount * unlockResourceScaling), 2000))) continue outer;
|
||||||
|
}
|
||||||
|
|
||||||
if(control.database().unlockContent(recipe)){
|
if(control.database().unlockContent(recipe)){
|
||||||
ui.hudfrag.showUnlock(recipe);
|
ui.hudfrag.showUnlock(recipe);
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,6 @@ public class Block extends BaseBlock {
|
|||||||
public boolean update;
|
public boolean update;
|
||||||
/** whether this block has health and can be destroyed */
|
/** whether this block has health and can be destroyed */
|
||||||
public boolean destructible;
|
public boolean destructible;
|
||||||
/** if true, this block cannot be broken by normal means. */
|
|
||||||
public boolean unbreakable;
|
|
||||||
/** whether this is solid */
|
/** whether this is solid */
|
||||||
public boolean solid;
|
public boolean solid;
|
||||||
/** whether this block CAN be solid. */
|
/** whether this block CAN be solid. */
|
||||||
@ -132,6 +130,10 @@ public class Block extends BaseBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canBreak(Tile tile){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean dropsItem(Item item){
|
public boolean dropsItem(Item item){
|
||||||
return drops != null && drops.item == item;
|
return drops != null && drops.item == item;
|
||||||
}
|
}
|
||||||
@ -158,7 +160,11 @@ public class Block extends BaseBlock {
|
|||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called after the block is placed. */
|
/** Called after the block is placed by this client. */
|
||||||
|
public void playerPlaced(Tile tile){
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called after the block is placed by anyone. */
|
||||||
public void placed(Tile tile){
|
public void placed(Tile tile){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +213,8 @@ public class Build{
|
|||||||
/**Returns whether the tile at this position is breakable by this team*/
|
/**Returns whether the tile at this position is breakable by this team*/
|
||||||
public static boolean validBreak(Team team, int x, int y){
|
public static boolean validBreak(Team team, int x, int y){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
if(tile != null) tile = tile.target();
|
||||||
|
|
||||||
return tile != null && !tile.block().unbreakable
|
return tile != null && tile.block().canBreak(tile) && tile.breakable() && (tile.getTeam() == Team.none || tile.getTeam() == team);
|
||||||
&& (!tile.isLinked() || !tile.getLinked().block().unbreakable) && tile.breakable() && (tile.getTeam() == Team.none || tile.getTeam() == team);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,12 +57,13 @@ public class BuildBlock extends Block{
|
|||||||
tile.setRotation(rotation);
|
tile.setRotation(rotation);
|
||||||
world.setBlock(tile, block, team);
|
world.setBlock(tile, block, team);
|
||||||
Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size);
|
Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size);
|
||||||
|
threads.runDelay(() -> tile.block().placed(tile));
|
||||||
|
|
||||||
//last builder was this local client player, call placed()
|
//last builder was this local client player, call placed()
|
||||||
if(!headless && builderID == players[0].id){
|
if(!headless && builderID == players[0].id){
|
||||||
//this is run delayed, since if this is called on the server, all clients need to recieve the onBuildFinish()
|
//this is run delayed, since if this is called on the server, all clients need to recieve the onBuildFinish()
|
||||||
//event first before they can recieve the placed() event modification results
|
//event first before they can recieve the placed() event modification results
|
||||||
threads.runDelay(() -> tile.block().placed(tile));
|
threads.runDelay(() -> tile.block().playerPlaced(tile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void placed(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
Tile last = world.tile(lastPlaced);
|
Tile last = world.tile(lastPlaced);
|
||||||
if(linkValid(tile, last)){
|
if(linkValid(tile, last)){
|
||||||
ItemBridgeEntity entity = last.entity();
|
ItemBridgeEntity entity = last.entity();
|
||||||
|
@ -86,7 +86,7 @@ public class WarpGate extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void placed(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
Call.setTeleporterColor(null, tile, lastColor);
|
Call.setTeleporterColor(null, tile, lastColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void placed(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
Tile before = world.tile(lastPlaced);
|
Tile before = world.tile(lastPlaced);
|
||||||
if(linkValid(tile, before) && before.block() instanceof PowerNode){
|
if(linkValid(tile, before) && before.block() instanceof PowerNode){
|
||||||
Call.linkPowerDistributors(null, tile, before);
|
Call.linkPowerDistributors(null, tile, before);
|
||||||
|
@ -52,7 +52,6 @@ public class CoreBlock extends StorageBlock{
|
|||||||
solid = false;
|
solid = false;
|
||||||
solidifes = true;
|
solidifes = true;
|
||||||
update = true;
|
update = true;
|
||||||
unbreakable = true;
|
|
||||||
size = 3;
|
size = 3;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
itemCapacity = 2000;
|
itemCapacity = 2000;
|
||||||
@ -82,6 +81,16 @@ public class CoreBlock extends StorageBlock{
|
|||||||
if(entity != null) entity.solid = solid;
|
if(entity != null) entity.solid = solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBreak(Tile tile){
|
||||||
|
return state.teams.get(tile.getTeam()).cores.size > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void placed(Tile tile){
|
||||||
|
state.teams.get(tile.getTeam()).cores.add(tile);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
super.setBars();
|
super.setBars();
|
||||||
|
@ -46,7 +46,7 @@ public class CommandCenter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void placed(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
ObjectSet<Tile> set = world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter);
|
ObjectSet<Tile> set = world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter);
|
||||||
|
|
||||||
if(set.size > 0){
|
if(set.size > 0){
|
||||||
|
@ -46,13 +46,6 @@ public class InventoryModule extends BlockModule{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(ItemStack[] stacks, float amountScaling){
|
|
||||||
for(ItemStack stack : stacks){
|
|
||||||
if(!has(stack.item, (int) (stack.amount * amountScaling))) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this entity has at least one of each item in each stack.
|
* Returns true if this entity has at least one of each item in each stack.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user