Added content mission / Working implementation of preset sectors
This commit is contained in:
@@ -141,12 +141,12 @@ public class Recipes implements ContentList{
|
||||
//DRILLS, PRODUCERS
|
||||
new Recipe(production, ProductionBlocks.mechanicalDrill, new ItemStack(Items.copper, 45)).setAlwaysUnlocked(true);
|
||||
new Recipe(production, ProductionBlocks.pneumaticDrill, new ItemStack(Items.copper, 60), new ItemStack(Items.densealloy, 50));
|
||||
new Recipe(production, ProductionBlocks.laserdrill, new ItemStack(Items.copper, 70), new ItemStack(Items.densealloy, 90), new ItemStack(Items.silicon, 60), new ItemStack(Items.titanium, 50));
|
||||
new Recipe(production, ProductionBlocks.blastdrill, new ItemStack(Items.copper, 130), new ItemStack(Items.densealloy, 180), new ItemStack(Items.silicon, 120), new ItemStack(Items.titanium, 100), new ItemStack(Items.thorium, 60));
|
||||
new Recipe(production, ProductionBlocks.laserDrill, new ItemStack(Items.copper, 70), new ItemStack(Items.densealloy, 90), new ItemStack(Items.silicon, 60), new ItemStack(Items.titanium, 50));
|
||||
new Recipe(production, ProductionBlocks.blastDrill, new ItemStack(Items.copper, 130), new ItemStack(Items.densealloy, 180), new ItemStack(Items.silicon, 120), new ItemStack(Items.titanium, 100), new ItemStack(Items.thorium, 60));
|
||||
|
||||
new Recipe(production, ProductionBlocks.waterextractor, new ItemStack(Items.copper, 50), new ItemStack(Items.densealloy, 50), new ItemStack(Items.lead, 40));
|
||||
new Recipe(production, ProductionBlocks.waterExtractor, new ItemStack(Items.copper, 50), new ItemStack(Items.densealloy, 50), new ItemStack(Items.lead, 40));
|
||||
new Recipe(production, ProductionBlocks.cultivator, new ItemStack(Items.copper, 20), new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 20));
|
||||
new Recipe(production, ProductionBlocks.oilextractor, new ItemStack(Items.copper, 300), new ItemStack(Items.densealloy, 350), new ItemStack(Items.lead, 230), new ItemStack(Items.thorium, 230), new ItemStack(Items.silicon, 150));
|
||||
new Recipe(production, ProductionBlocks.oilExtractor, new ItemStack(Items.copper, 300), new ItemStack(Items.densealloy, 350), new ItemStack(Items.lead, 230), new ItemStack(Items.thorium, 230), new ItemStack(Items.silicon, 150));
|
||||
|
||||
//UNITS
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.world.blocks.production.Fracker;
|
||||
import io.anuke.mindustry.world.blocks.production.SolidPump;
|
||||
|
||||
public class ProductionBlocks extends BlockList implements ContentList{
|
||||
public static Block mechanicalDrill, pneumaticDrill, laserdrill, blastdrill, plasmadrill, waterextractor, oilextractor, cultivator;
|
||||
public static Block mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, plasmaDrill, waterExtractor, oilExtractor, cultivator;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -30,7 +30,7 @@ public class ProductionBlocks extends BlockList implements ContentList{
|
||||
drawMineItem = true;
|
||||
}};
|
||||
|
||||
laserdrill = new Drill("laser-drill"){{
|
||||
laserDrill = new Drill("laser-drill"){{
|
||||
drillTime = 140;
|
||||
size = 2;
|
||||
hasPower = true;
|
||||
@@ -41,7 +41,7 @@ public class ProductionBlocks extends BlockList implements ContentList{
|
||||
consumes.power(0.16f);
|
||||
}};
|
||||
|
||||
blastdrill = new Drill("blast-drill"){{
|
||||
blastDrill = new Drill("blast-drill"){{
|
||||
drillTime = 60;
|
||||
size = 3;
|
||||
drawRim = true;
|
||||
@@ -56,7 +56,7 @@ public class ProductionBlocks extends BlockList implements ContentList{
|
||||
consumes.power(0.3f);
|
||||
}};
|
||||
|
||||
plasmadrill = new Drill("plasma-drill"){{
|
||||
plasmaDrill = new Drill("plasma-drill"){{
|
||||
heatColor = Color.valueOf("ff461b");
|
||||
drillTime = 50;
|
||||
size = 4;
|
||||
@@ -73,7 +73,7 @@ public class ProductionBlocks extends BlockList implements ContentList{
|
||||
consumes.power(0.7f);
|
||||
}};
|
||||
|
||||
waterextractor = new SolidPump("water-extractor"){{
|
||||
waterExtractor = new SolidPump("water-extractor"){{
|
||||
result = Liquids.water;
|
||||
pumpAmount = 0.065f;
|
||||
size = 2;
|
||||
@@ -83,7 +83,7 @@ public class ProductionBlocks extends BlockList implements ContentList{
|
||||
consumes.power(0.13f);
|
||||
}};
|
||||
|
||||
oilextractor = new Fracker("oil-extractor"){{
|
||||
oilExtractor = new Fracker("oil-extractor"){{
|
||||
result = Liquids.oil;
|
||||
updateEffect = BlockFx.pulverize;
|
||||
liquidCapacity = 50f;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Control extends Module{
|
||||
long value = soundMap.get(sound, 0L);
|
||||
|
||||
if(TimeUtils.timeSinceMillis(value) >= minSoundPeriod){
|
||||
threads.run(() -> sound.play(volume));
|
||||
threads.runGraphics(() -> sound.play(volume));
|
||||
soundMap.put(sound, time);
|
||||
}
|
||||
});
|
||||
@@ -159,6 +159,12 @@ public class Control extends Module{
|
||||
});
|
||||
|
||||
Events.on(WorldLoadEvent.class, event -> threads.runGraphics(() -> Events.fire(new WorldLoadGraphicsEvent())));
|
||||
|
||||
Events.on(BlockBuildEvent.class, event -> {
|
||||
if(event.team == players[0].getTeam() && Recipe.getByResult(event.tile.block()) != null){
|
||||
unlocks.handleContentUsed(Recipe.getByResult(event.tile.block()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addPlayer(int index){
|
||||
|
||||
@@ -17,6 +17,14 @@ public class Unlocks{
|
||||
static{
|
||||
Settings.setSerializer(ContentType.class, (stream, t) -> stream.writeInt(t.ordinal()), stream -> ContentType.values()[stream.readInt()]);
|
||||
}
|
||||
|
||||
/**Handles the event of content being used by either the player or some block.*/
|
||||
public void handleContentUsed(UnlockableContent content){
|
||||
if(world.getSector() != null){
|
||||
world.getSector().currentMission().onContentUsed(content);
|
||||
}
|
||||
unlockContent(content);
|
||||
}
|
||||
|
||||
/** Returns whether or not this piece of content is unlocked yet.*/
|
||||
public boolean isUnlocked(UnlockableContent content){
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.blocks.*;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
@@ -24,15 +25,6 @@ public class SectorPresets{
|
||||
Array.with(),
|
||||
1));
|
||||
|
||||
//water mission
|
||||
add(new SectorPreset(-2, 0,
|
||||
Structs.array(
|
||||
Missions.blockRecipe(LiquidBlocks.mechanicalPump),
|
||||
Missions.blockRecipe(ProductionBlocks.cultivator)
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.copper),
|
||||
2));
|
||||
|
||||
//command center mission
|
||||
add(new SectorPreset(2, 0,
|
||||
Structs.array(
|
||||
@@ -45,7 +37,7 @@ public class SectorPresets{
|
||||
Array.with(Items.copper, Items.lead, Items.copper),
|
||||
2));
|
||||
|
||||
//reconstructor mission
|
||||
//pad mission
|
||||
add(new SectorPreset(0, -2,
|
||||
Structs.array(
|
||||
Missions.blockRecipe(mobile ? UpgradeBlocks.tridentPad : UpgradeBlocks.deltaPad),
|
||||
@@ -56,10 +48,13 @@ public class SectorPresets{
|
||||
2));
|
||||
|
||||
//oil mission
|
||||
add(new SectorPreset(0, 1,
|
||||
add(new SectorPreset(-2, 0,
|
||||
Structs.array(
|
||||
Missions.blockRecipe(ProductionBlocks.cultivator),
|
||||
Missions.blockRecipe(CraftingBlocks.biomatterCompressor)
|
||||
Missions.blockRecipe(ProductionBlocks.waterExtractor),
|
||||
new ContentMission(Items.biomatter),
|
||||
Missions.blockRecipe(CraftingBlocks.biomatterCompressor),
|
||||
new ContentMission(Liquids.oil)
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.copper, Items.titanium),
|
||||
2));
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
@@ -71,7 +72,6 @@ public class Sectors{
|
||||
threads.runGraphics(() -> ui.showError("$text.sector.corrupted"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**If a sector is not yet unlocked, returns null.*/
|
||||
@@ -243,7 +243,7 @@ public class Sectors{
|
||||
|
||||
for(int cx = 0; cx < sector.width; cx++){
|
||||
for(int cy = 0; cy < sector.height; cy++){
|
||||
grid.put(x + cx, y + cy, sector);
|
||||
grid.put(sector.x + cx, sector.y + cy, sector);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class FortressGenerator{
|
||||
seeder.get(PowerBlocks.thoriumReactor, tile -> tile.block() instanceof Drill && gen.random.chance(0.2) && gen.drillItem(tile.x, tile.y, (Drill)tile.block()) == Items.thorium && gen.random.chance(0.3)),
|
||||
|
||||
//water extractors
|
||||
seeder.get(ProductionBlocks.waterextractor, tile -> tile.block() instanceof NuclearReactor && gen.random.chance(0.5)),
|
||||
seeder.get(ProductionBlocks.waterExtractor, tile -> tile.block() instanceof NuclearReactor && gen.random.chance(0.5)),
|
||||
|
||||
//mend cores
|
||||
seeder.get(DefenseBlocks.mendProjector, tile -> tile.block() instanceof PowerGenerator && gen.random.chance(0.03)),
|
||||
|
||||
@@ -1,54 +1,12 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.defaultTeam;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
/**A mission in which the player must place a block somewhere.*/
|
||||
public class BlockMission extends Mission{
|
||||
private final Block block;
|
||||
private boolean complete;
|
||||
public class BlockMission extends ContentMission{
|
||||
|
||||
static{
|
||||
Events.on(BlockBuildEvent.class, event -> {
|
||||
if(world.getSector() != null && event.team == defaultTeam){
|
||||
Mission mission = world.getSector().currentMission();
|
||||
if(mission instanceof BlockMission){
|
||||
BlockMission block = (BlockMission)world.getSector().currentMission();
|
||||
if(block.block == event.tile.block()){
|
||||
block.complete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public BlockMission(Block block){
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(){
|
||||
complete = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
return complete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("text.mission.block", block.formalName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getMode(){
|
||||
return GameMode.noWaves;
|
||||
public BlockMission(Block block) {
|
||||
super(Recipe.getByResult(block));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class ContentMission extends Mission {
|
||||
private final UnlockableContent content;
|
||||
private boolean done;
|
||||
|
||||
public ContentMission(UnlockableContent content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentUsed(UnlockableContent content) {
|
||||
if(content == this.content){
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
done = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString() {
|
||||
return Bundles.format("text.mission.create", content.localizedName());
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -43,6 +44,11 @@ public abstract class Mission{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**Called when a specified piece of content is 'used' by a block.*/
|
||||
public void onContentUsed(UnlockableContent content){
|
||||
|
||||
}
|
||||
|
||||
/**Draw mission overlay.*/
|
||||
public void drawOverlay(){
|
||||
|
||||
|
||||
@@ -217,9 +217,9 @@ public class Block extends BaseBlock {
|
||||
}
|
||||
|
||||
/**Call when some content is produced. This unlocks the content if it is applicable.*/
|
||||
public void useContent(UnlockableContent content){
|
||||
if(!headless){
|
||||
control.unlocks().unlockContent(content);
|
||||
public void useContent(Tile tile, UnlockableContent content){
|
||||
if(!headless && tile.getTeam() == players[0].getTeam()){
|
||||
control.unlocks().handleContentUsed(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ public class Drill extends Block{
|
||||
|
||||
offloadNear(tile, entity.dominantItem);
|
||||
|
||||
useContent(entity.dominantItem);
|
||||
useContent(tile, entity.dominantItem);
|
||||
|
||||
entity.index++;
|
||||
entity.progress = 0f;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class GenericCrafter extends Block{
|
||||
|
||||
if(consumes.has(ConsumeItem.class)) tile.entity.items.remove(consumes.item(), consumes.itemAmount());
|
||||
|
||||
useContent(output);
|
||||
useContent(tile, output);
|
||||
|
||||
offloadNear(tile, output);
|
||||
Effects.effect(craftEffect, tile.drawx(), tile.drawy());
|
||||
|
||||
@@ -15,6 +15,8 @@ public class Pump extends LiquidBlock{
|
||||
protected final Array<Tile> drawTiles = new Array<>();
|
||||
protected final Array<Tile> updateTiles = new Array<>();
|
||||
|
||||
protected int timerContentCheck = timers++;
|
||||
|
||||
/**Pump amount per tile this block is on.*/
|
||||
protected float pumpAmount = 1f;
|
||||
/**Maximum liquid tier this pump can use.*/
|
||||
@@ -98,6 +100,10 @@ public class Pump extends LiquidBlock{
|
||||
tile.entity.liquids.add(liquidDrop, maxPump);
|
||||
}
|
||||
|
||||
if(tile.entity.liquids.currentAmount() > 0f && tile.entity.timer.get(timerContentCheck, 10)){
|
||||
useContent(tile, tile.entity.liquids.current());
|
||||
}
|
||||
|
||||
tryDumpLiquid(tile, tile.entity.liquids.current());
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ public class CoreBlock extends StorageBlock{
|
||||
unit.setDead(true);
|
||||
unit.add();
|
||||
|
||||
useContent(droneType);
|
||||
useContent(tile, droneType);
|
||||
|
||||
entity.droneID = unit.id;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class UnitFactory extends Block{
|
||||
entity.buildTime = 0f;
|
||||
|
||||
Call.onUnitFactorySpawn(tile);
|
||||
useContent(type);
|
||||
useContent(tile, type);
|
||||
|
||||
for(ItemStack stack : consumes.items()){
|
||||
entity.items.remove(stack.item, stack.amount);
|
||||
|
||||
Reference in New Issue
Block a user