Implemented multi-mission sectors / Various bugfixes
This commit is contained in:
@@ -71,9 +71,16 @@ public class Items implements ContentList{
|
||||
cost = 1.5f;
|
||||
}};
|
||||
|
||||
surgealloy = new Item("surge-alloy", Color.valueOf("b4d5c7")){{
|
||||
type = ItemType.material;
|
||||
}};
|
||||
surgealloy = new Item("surge-alloy", Color.valueOf("b4d5c7")){
|
||||
{
|
||||
type = ItemType.material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
biomatter = new Item("biomatter", Color.valueOf("648b55")){{
|
||||
flammability = 0.4f;
|
||||
|
||||
@@ -363,11 +363,18 @@ public class Control extends Module{
|
||||
}
|
||||
|
||||
//check unlocked sectors
|
||||
if(world.getSector() != null && world.getSector().mission.isComplete() && !world.getSector().complete){
|
||||
world.sectors().completeSector(world.getSector().x, world.getSector().y);
|
||||
world.sectors().save();
|
||||
if(!headless){
|
||||
ui.showInfoFade("$text.sector.unlocked");
|
||||
if(world.getSector() != null && !world.getSector().complete){
|
||||
//all assigned missions are complete
|
||||
if(world.getSector().completedMissions >= world.getSector().missions.size){
|
||||
|
||||
world.sectors().completeSector(world.getSector().x, world.getSector().y);
|
||||
world.sectors().save();
|
||||
if(!headless){
|
||||
ui.showInfoFade("$text.sector.unlocked");
|
||||
}
|
||||
}else if(world.getSector().missions.get(world.getSector().completedMissions).isComplete()){
|
||||
//increment completed missions, check next index next frame
|
||||
world.getSector().completedMissions ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,7 @@ public class TileEntity extends BaseEntity implements TargetTrait{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when nothing is happening to the entity.
|
||||
* This increments the internal sleep timer.
|
||||
*/
|
||||
/**Call when nothing is happening to the entity. This increments the internal sleep timer.*/
|
||||
public void sleep(){
|
||||
sleepTime += Timers.delta();
|
||||
if(!sleeping && sleepTime >= timeToSleep){
|
||||
@@ -97,20 +94,6 @@ public class TileEntity extends BaseEntity implements TargetTrait{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when something just happened to the entity.
|
||||
* If the entity was sleeping, this enables it. This also resets the sleep timer.
|
||||
*/
|
||||
public void wakeUp(){
|
||||
noSleep();
|
||||
|
||||
for(Tile tile : proximity){
|
||||
if(tile.entity.isSleeping()){
|
||||
tile.entity.wakeUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**Call when this entity is updating. This wakes it up.*/
|
||||
public void noSleep(){
|
||||
sleepTime = 0f;
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.maps.missions.Mission;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
|
||||
@@ -20,10 +19,12 @@ public class Sector{
|
||||
public int saveID = -1;
|
||||
/**Sector size; if more than 1, the coordinates are the bottom left corner.*/
|
||||
public int size = 1;
|
||||
/**Num of missions in this sector that have been completed so far.*/
|
||||
public int completedMissions;
|
||||
/**Display texture. Needs to be disposed.*/
|
||||
public transient Texture texture;
|
||||
/**Mission of this sector-- what needs to be accomplished to unlock it.*/
|
||||
public transient Mission mission = new WaveMission(30);
|
||||
/**Missions of this sector-- what needs to be accomplished to unlock it.*/
|
||||
public transient Array<Mission> missions = new Array<>();
|
||||
/**Enemies spawned at this sector.*/
|
||||
public transient Array<SpawnGroup> spawns = new Array<>();
|
||||
/**Ores that appear in this sector.*/
|
||||
|
||||
@@ -134,12 +134,12 @@ public class Sectors{
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y)/2);
|
||||
|
||||
if(sector.difficulty < 1){
|
||||
sector.mission = new WaveMission(30);
|
||||
sector.missions.add(new WaveMission(30));
|
||||
}else{
|
||||
sector.mission = Mathf.choose(
|
||||
sector.missions.add(Mathf.choose(
|
||||
new BattleMission(sector.difficulty),
|
||||
new WaveMission(30 + sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 5)*5)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//add all ores for now since material differences aren't well handled yet
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.MapTileData;
|
||||
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.maps.missions.Mission;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -35,7 +36,6 @@ public class WorldGenerator{
|
||||
private Simplex sim3 = new Simplex(baseSeed + 2);
|
||||
private RidgedPerlin rid = new RidgedPerlin(baseSeed + 4, 1);
|
||||
private VoronoiNoise vn = new VoronoiNoise(baseSeed + 2, (short)0);
|
||||
|
||||
private SeedRandom random = new SeedRandom(baseSeed + 3);
|
||||
|
||||
private GenResult result = new GenResult();
|
||||
@@ -212,7 +212,9 @@ public class WorldGenerator{
|
||||
tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
tiles[coreX][coreY].setTeam(Team.blue);
|
||||
|
||||
sector.mission.generate(tiles, sector);
|
||||
for(Mission mission : sector.missions){
|
||||
mission.generate(tiles, sector);
|
||||
}
|
||||
|
||||
prepareTiles(tiles, sector.getSeed(), true, sector.ores);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SectorsDialog extends FloatingDialog{
|
||||
+ (selected.saveID == -1 ? " " + Bundles.get("text.sector.unexplored") :
|
||||
(selected.hasSave() ? " [accent]/[white] " + Bundles.format("text.sector.time", selected.getSave().getPlayTime()) : ""))));
|
||||
content().row();
|
||||
content().label(() -> Bundles.format("text.mission", selected == null ? Bundles.get("text.none") : selected.mission.displayString()));
|
||||
content().label(() -> Bundles.format("text.mission", selected == null || selected.completedMissions >= selected.missions.size ? Bundles.get("text.none") : selected.missions.get(selected.completedMissions).displayString()));
|
||||
content().row();
|
||||
content().add(new SectorView()).grow();
|
||||
content().row();
|
||||
|
||||
@@ -55,14 +55,14 @@ public abstract class BaseBlock{
|
||||
* Remove a stack from this inventory, and return the amount removed.
|
||||
*/
|
||||
public int removeStack(Tile tile, Item item, int amount){
|
||||
tile.entity.wakeUp();
|
||||
tile.entity.noSleep();
|
||||
tile.entity.items.remove(item, amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**Handle a stack input.*/
|
||||
public void handleStack(Item item, int amount, Tile tile, Unit source){
|
||||
tile.entity.wakeUp();
|
||||
tile.entity.noSleep();
|
||||
tile.entity.items.add(item, amount);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class Conduit extends LiquidBlock{
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
tile.entity.wakeUp();
|
||||
tile.entity.noSleep();
|
||||
return super.acceptLiquid(tile, source, liquid, amount) && ((2 + source.relativeTo(tile.x, tile.y)) % 4 != tile.getRotation());
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,6 @@ public class Conveyor extends Block{
|
||||
|
||||
int minremove = Integer.MAX_VALUE;
|
||||
float speed = Math.max(this.speed - (1f - (carryCapacity - entity.carrying) / carryCapacity), 0f);
|
||||
float totalMoved = 0f;
|
||||
|
||||
for(int i = entity.convey.size - 1; i >= 0; i--){
|
||||
long value = entity.convey.get(i);
|
||||
@@ -221,7 +220,6 @@ public class Conveyor extends Block{
|
||||
break;
|
||||
}
|
||||
|
||||
float prev = pos.y;
|
||||
float nextpos = (i == entity.convey.size - 1 ? 100f : pos2.set(entity.convey.get(i + 1), ItemPos.updateShorts).y) - itemSpace;
|
||||
if(entity.minCarry >= pos.y && entity.minCarry <= nextpos){
|
||||
nextpos = entity.minCarry;
|
||||
@@ -236,11 +234,9 @@ public class Conveyor extends Block{
|
||||
}
|
||||
|
||||
pos.y = Mathf.clamp(pos.y);
|
||||
totalMoved += (pos.y - prev);
|
||||
|
||||
if(pos.y >= 0.9999f && offloadDir(tile, pos.item)){
|
||||
minremove = Math.min(i, minremove);
|
||||
totalMoved = 1f;
|
||||
tile.entity.items.remove(pos.item, 1);
|
||||
}else{
|
||||
value = pos.pack();
|
||||
@@ -260,9 +256,7 @@ public class Conveyor extends Block{
|
||||
entity.carrying = 0f;
|
||||
entity.minCarry = 2f;
|
||||
|
||||
Tile next = tile.getNearby(tile.getRotation());
|
||||
|
||||
if((next != null && next.block() instanceof Conveyor) && totalMoved/Timers.delta() <= 0.0001f){
|
||||
if(entity.items.total() == 0){
|
||||
entity.sleep();
|
||||
}else{
|
||||
entity.noSleep();
|
||||
@@ -279,7 +273,7 @@ public class Conveyor extends Block{
|
||||
@Override
|
||||
public synchronized int removeStack(Tile tile, Item item, int amount){
|
||||
ConveyorEntity entity = tile.entity();
|
||||
entity.wakeUp();
|
||||
entity.noSleep();
|
||||
int removed = 0;
|
||||
|
||||
for(int j = 0; j < amount; j++){
|
||||
@@ -315,7 +309,7 @@ public class Conveyor extends Block{
|
||||
long result = ItemPos.packItem(item, 0f, 0f, (byte) Mathf.random(255));
|
||||
entity.convey.insert(0, result);
|
||||
entity.items.add(item, 1);
|
||||
entity.wakeUp();
|
||||
entity.noSleep();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -337,7 +331,7 @@ public class Conveyor extends Block{
|
||||
float y = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
||||
|
||||
ConveyorEntity entity = tile.entity();
|
||||
entity.wakeUp();
|
||||
entity.noSleep();
|
||||
long result = ItemPos.packItem(item, y * 0.9f, pos, (byte) Mathf.random(255));
|
||||
boolean inserted = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user