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