Sector preset class / New missions
This commit is contained in:
@@ -9,6 +9,7 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.Waves;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.GridBits;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
@@ -184,7 +185,7 @@ public class WaveSpawner{
|
||||
quadrants = new GridBits(quadWidth(), quadHeight());
|
||||
}
|
||||
|
||||
if(!Mathf.inBounds(quadx, quady, quadWidth(), quadHeight())){
|
||||
if(!Structs.inBounds(quadx, quady, quadWidth(), quadHeight())){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Recipes implements ContentList{
|
||||
new Recipe(distribution, DistributionBlocks.distributor, new ItemStack(Items.densealloy, 8), new ItemStack(Items.copper, 8));
|
||||
new Recipe(distribution, DistributionBlocks.sorter, new ItemStack(Items.densealloy, 4), new ItemStack(Items.copper, 4));
|
||||
new Recipe(distribution, DistributionBlocks.overflowGate, new ItemStack(Items.densealloy, 4), new ItemStack(Items.copper, 8));
|
||||
new Recipe(distribution, DistributionBlocks.bridgeConveyor, new ItemStack(Items.densealloy, 8), new ItemStack(Items.copper, 8));
|
||||
new Recipe(distribution, DistributionBlocks.itemBridge, new ItemStack(Items.densealloy, 8), new ItemStack(Items.copper, 8));
|
||||
new Recipe(distribution, DistributionBlocks.massDriver, new ItemStack(Items.densealloy, 400), new ItemStack(Items.silicon, 300), new ItemStack(Items.lead, 400), new ItemStack(Items.thorium, 250));
|
||||
|
||||
//CRAFTING
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.anuke.mindustry.world.blocks.distribution.*;
|
||||
|
||||
public class DistributionBlocks extends BlockList implements ContentList{
|
||||
public static Block conveyor, titaniumconveyor, distributor, junction,
|
||||
bridgeConveyor, phaseConveyor, sorter, router, overflowGate, massDriver;
|
||||
itemBridge, phaseConveyor, sorter, router, overflowGate, massDriver;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -26,7 +26,7 @@ public class DistributionBlocks extends BlockList implements ContentList{
|
||||
capacity = 32;
|
||||
}};
|
||||
|
||||
bridgeConveyor = new BufferedItemBridge("bridge-conveyor"){{
|
||||
itemBridge = new BufferedItemBridge("bridge-conveyor"){{
|
||||
range = 4;
|
||||
speed = 60f;
|
||||
}};
|
||||
|
||||
@@ -32,6 +32,7 @@ import io.anuke.ucore.entities.trait.Entity;
|
||||
import io.anuke.ucore.io.ByteBufferOutput;
|
||||
import io.anuke.ucore.io.CountableByteArrayOutputStream;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
@@ -188,7 +189,7 @@ public class NetServer extends Module{
|
||||
|
||||
if(state.mode.isPvp){
|
||||
//find team with minimum amount of players and auto-assign player to that.
|
||||
Team min = Mathf.findMin(Team.all, team -> {
|
||||
Team min = Structs.findMin(Team.all, team -> {
|
||||
if(state.teams.isActive(team)){
|
||||
int count = 0;
|
||||
for(Player other : playerGroup.all()){
|
||||
|
||||
@@ -25,7 +25,7 @@ import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
|
||||
import io.anuke.ucore.scene.ui.TooltipManager;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -112,7 +112,7 @@ public class UI extends SceneModule{
|
||||
@Override
|
||||
protected void loadSkin(){
|
||||
skin = new Skin(Gdx.files.internal("ui/uiskin.json"), Core.atlas);
|
||||
Mathf.each(font -> {
|
||||
Structs.each(font -> {
|
||||
font.setUseIntegerPositions(false);
|
||||
font.getData().setScale(Vars.fontScale);
|
||||
font.getData().down += Unit.dp.scl(4f);
|
||||
|
||||
@@ -20,10 +20,7 @@ import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.ThreadArray;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -140,7 +137,7 @@ public class World extends Module{
|
||||
if(tiles == null){
|
||||
return null;
|
||||
}
|
||||
if(!Mathf.inBounds(x, y, tiles)) return null;
|
||||
if(!Structs.inBounds(x, y, tiles)) return null;
|
||||
return tiles[x][y];
|
||||
}
|
||||
|
||||
@@ -235,7 +232,7 @@ public class World extends Module{
|
||||
/**Loads up a sector map. This does not call play(), but calls reset().*/
|
||||
public void loadSector(Sector sector){
|
||||
currentSector = sector;
|
||||
state.mode = sector.missions.peek().getMode();
|
||||
state.mode = sector.mode;
|
||||
state.difficulty = sectors.getDifficulty(sector);
|
||||
Timers.mark();
|
||||
Timers.mark();
|
||||
@@ -337,7 +334,7 @@ public class World extends Module{
|
||||
public int transform(int packed, int oldWidth, int oldHeight, int newWidth, int shiftX, int shiftY){
|
||||
int x = packed % oldWidth;
|
||||
int y = packed / oldWidth;
|
||||
if(!Mathf.inBounds(x, y, oldWidth, oldHeight)) return -1;
|
||||
if(!Structs.inBounds(x, y, oldWidth, oldHeight)) return -1;
|
||||
x += shiftX;
|
||||
y += shiftY;
|
||||
return y*newWidth + x;
|
||||
|
||||
@@ -8,8 +8,8 @@ import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.function.IntPositionConsumer;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
@@ -83,7 +83,7 @@ public enum EditorTool{
|
||||
MapTileData data;
|
||||
|
||||
public void touched(MapEditor editor, int x, int y){
|
||||
if(!Mathf.inBounds(x, y, editor.getMap().width(), editor.getMap().height())) return;
|
||||
if(!Structs.inBounds(x, y, editor.getMap().width(), editor.getMap().height())) return;
|
||||
|
||||
if(editor.getDrawBlock().isMultiblock()){
|
||||
//don't fill multiblocks, thanks
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
||||
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
@@ -124,7 +125,7 @@ public class MapEditor{
|
||||
int worldx = dx + offsetx + x;
|
||||
int worldy = dy + offsety + y;
|
||||
|
||||
if(Mathf.inBounds(worldx, worldy, map.width(), map.height())){
|
||||
if(Structs.inBounds(worldx, worldy, map.width(), map.height())){
|
||||
TileDataMarker prev = getPrev(worldx, worldy, false);
|
||||
|
||||
if(i == 1){
|
||||
@@ -226,7 +227,7 @@ public class MapEditor{
|
||||
for(int dx = 0; dx < block.size; dx++){
|
||||
for(int dy = 0; dy < block.size; dy++){
|
||||
int worldx = x + dx + offsetx, worldy = y + dy + offsety;
|
||||
if(Mathf.inBounds(worldx, worldy, map.width(), map.height())){
|
||||
if(Structs.inBounds(worldx, worldy, map.width(), map.height())){
|
||||
TileDataMarker prev = getPrev(worldx, worldy, false);
|
||||
|
||||
map.write(worldx, worldy, DataPosition.link, (byte) 0);
|
||||
|
||||
@@ -13,9 +13,9 @@ import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.IndexedRenderer;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
@@ -156,7 +156,7 @@ public class MapRenderer implements Disposable{
|
||||
private boolean checkElevation(byte elev, int x, int y){
|
||||
for(GridPoint2 p : Geometry.d4){
|
||||
int wx = x + p.x, wy = y + p.y;
|
||||
if(!Mathf.inBounds(wx, wy, editor.getMap().width(), editor.getMap().height())){
|
||||
if(!Structs.inBounds(wx, wy, editor.getMap().width(), editor.getMap().height())){
|
||||
return true;
|
||||
}
|
||||
byte value = editor.getMap().read(wx, wy, DataPosition.elevation);
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.impl.TimedEntity;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Pooling;
|
||||
@@ -69,7 +70,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
||||
}
|
||||
|
||||
public static boolean has(int x, int y){
|
||||
return Mathf.inBounds(x, y, world.width(), world.height()) && map.containsKey(x + y * world.width());
|
||||
return Structs.inBounds(x, y, world.width(), world.height()) && map.containsKey(x + y * world.width());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public enum UnitCommand{
|
||||
attack, retreat, patrol
|
||||
attack, retreat, patrol;
|
||||
|
||||
private final String localized;
|
||||
|
||||
UnitCommand(){
|
||||
localized = Bundles.get("command." + name());
|
||||
}
|
||||
|
||||
public String localized(){
|
||||
return localized;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,7 @@ import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Shapes;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.ThreadQueue;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -373,7 +370,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
if(entity == null){
|
||||
return;
|
||||
}
|
||||
targetItem = Mathf.findMin(type.toMine, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
|
||||
targetItem = Structs.findMin(type.toMine, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.CacheBatch;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
@@ -89,7 +90,7 @@ public class FloorRenderer{
|
||||
int worldx = camx + x;
|
||||
int worldy = camy + y;
|
||||
|
||||
if(!Mathf.inBounds(worldx, worldy, cache))
|
||||
if(!Structs.inBounds(worldx, worldy, cache))
|
||||
continue;
|
||||
|
||||
Chunk chunk = cache[worldx][worldy];
|
||||
@@ -159,7 +160,7 @@ public class FloorRenderer{
|
||||
int worldx = Mathf.scl(camera.position.x, chunksize * tilesize) + x;
|
||||
int worldy = Mathf.scl(camera.position.y, chunksize * tilesize) + y;
|
||||
|
||||
if(!Mathf.inBounds(worldx, worldy, cache)){
|
||||
if(!Structs.inBounds(worldx, worldy, cache)){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,17 @@ import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.blocks.UnitBlocks;
|
||||
import io.anuke.mindustry.content.blocks.UpgradeBlocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.maps.missions.Mission;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.maps.missions.*;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
@@ -21,10 +24,7 @@ import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.trait.Entity;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -34,17 +34,22 @@ public class Sectors{
|
||||
|
||||
private final GridMap<Sector> grid = new GridMap<>();
|
||||
|
||||
private final GridMap<Array<Mission>> presets = new GridMap<Array<Mission>>(){{
|
||||
put(0, 0, TutorialSector.getMissions());
|
||||
private final GridMap<SectorPreset> presets = new GridMap<SectorPreset>(){{
|
||||
put(0, 0, new SectorPreset(TutorialSector.getMissions(), Array.with(Items.copper), 1));
|
||||
|
||||
//water mission
|
||||
put(-2, 0, Array.with());
|
||||
put(-2, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
|
||||
//command center mission
|
||||
put(0, 1, Array.with());
|
||||
//TODO generate enemy base
|
||||
//TODO make 2x2
|
||||
//TODO more gen info
|
||||
put(0, 1, new SectorPreset(Structs.array(new BlockMission(UnitBlocks.daggerFactory), Missions.blockRecipe(UnitBlocks.commandCenter),
|
||||
new CommandMission(UnitCommand.retreat), new CommandMission(UnitCommand.attack), new BattleMission()), Array.with(Items.copper), 1));
|
||||
//reconstructor mission
|
||||
put(0, -1, Array.with());
|
||||
put(0, -1, new SectorPreset(Structs.array(Missions.blockRecipe(mobile ? UpgradeBlocks.tridentPad : UpgradeBlocks.deltaPad),
|
||||
new MechMission(Mechs.delta)), Array.with(Items.copper), 1));
|
||||
//oil mission
|
||||
put(1, 0, Array.with());
|
||||
put(1, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
|
||||
}};
|
||||
|
||||
public void playSector(Sector sector){
|
||||
@@ -306,7 +311,8 @@ public class Sectors{
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y));
|
||||
|
||||
if(presets.containsKey(sector.x, sector.y)){
|
||||
sector.missions.addAll(presets.get(sector.x, sector.y));
|
||||
SectorPreset p = presets.get(sector.x, sector.y);
|
||||
sector.missions.addAll(p.missions);
|
||||
}else{
|
||||
genMissions(sector);
|
||||
}
|
||||
@@ -363,4 +369,20 @@ public class Sectors{
|
||||
sector.texture = new Texture(pixmap);
|
||||
pixmap.dispose();
|
||||
}
|
||||
|
||||
private class SectorPreset{
|
||||
private final Array<Mission> missions;
|
||||
private final Array<Item> ores;
|
||||
private final int size;
|
||||
|
||||
public SectorPreset(Array<Mission> missions, Array<Item> ores, int size){
|
||||
this.missions = missions;
|
||||
this.ores = ores;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
void generate(Sector sector){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.production.Drill;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.SeedRandom;
|
||||
|
||||
public class Generation{
|
||||
@@ -24,7 +24,7 @@ public class Generation{
|
||||
}
|
||||
|
||||
Tile tile(int x, int y){
|
||||
if(!Mathf.inBounds(x, y, tiles)){
|
||||
if(!Structs.inBounds(x, y, tiles)){
|
||||
return null;
|
||||
}
|
||||
return tiles[x][y];
|
||||
@@ -41,7 +41,7 @@ public class Generation{
|
||||
for(int dy = 0; dy < block.size; dy++){
|
||||
int worldx = dx + offsetx + x;
|
||||
int worldy = dy + offsety + y;
|
||||
if(!Mathf.inBounds(worldx, worldy, tiles)){
|
||||
if(!Structs.inBounds(worldx, worldy, tiles)){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Generation{
|
||||
for(int dy = 0; dy < block.size; dy++){
|
||||
int worldx = dx + offsetx + x;
|
||||
int worldy = dy + offsety + y;
|
||||
if(!Mathf.inBounds(worldx, worldy, tiles) || !tiles[worldx][worldy].block().alwaysReplace){
|
||||
if(!Structs.inBounds(worldx, worldy, tiles) || !tiles[worldx][worldy].block().alwaysReplace){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class Generation{
|
||||
for(int dy = 0; dy < block.size; dy++){
|
||||
int worldx = dx + offsetx + x;
|
||||
int worldy = dy + offsety + y;
|
||||
if(!(worldx == x && worldy == y) && Mathf.inBounds(worldx, worldy, tiles)){
|
||||
if(!(worldx == x && worldy == y) && Structs.inBounds(worldx, worldy, tiles)){
|
||||
Tile toplace = tiles[worldx][worldy];
|
||||
if(toplace != null){
|
||||
toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety));
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
import io.anuke.ucore.noise.RidgedPerlin;
|
||||
import io.anuke.ucore.noise.Simplex;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.SeedRandom;
|
||||
@@ -42,7 +43,7 @@ public class WorldGenerator{
|
||||
private ObjectMap<Block, Block> decoration;
|
||||
|
||||
public WorldGenerator(){
|
||||
decoration = Mathf.map(
|
||||
decoration = Structs.map(
|
||||
Blocks.grass, Blocks.shrub,
|
||||
Blocks.stone, Blocks.rock,
|
||||
Blocks.ice, Blocks.icerock,
|
||||
@@ -203,7 +204,7 @@ public class WorldGenerator{
|
||||
byte elevation = tile.getElevation();
|
||||
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
if(!Mathf.inBounds(x + point.x, y + point.y, width, height)) continue;
|
||||
if(!Structs.inBounds(x + point.x, y + point.y, width, height)) continue;
|
||||
if(tiles[x + point.x][y + point.y].getElevation() < elevation){
|
||||
|
||||
if(sim2.octaveNoise2D(1, 1, 1.0 / 8, x, y) > 0.8){
|
||||
|
||||
@@ -8,8 +8,8 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
//TODO
|
||||
public class AStarPathFinder extends TilePathfinder{
|
||||
@@ -194,7 +194,7 @@ public class AStarPathFinder extends TilePathfinder{
|
||||
if(obstacle(current)) return;
|
||||
for(GridPoint2 p : Geometry.d4){
|
||||
int wx = current.x + p.x, wy = current.y + p.y;
|
||||
Tile n = Mathf.inBounds(wx, wy, tiles) ? tiles[wx][wy] : null;
|
||||
Tile n = Structs.inBounds(wx, wy, tiles) ? tiles[wx][wy] : null;
|
||||
if(!obstacle(n)) cons.accept(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.maps.generation.pathfinding;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
|
||||
public abstract class TilePathfinder{
|
||||
protected Tile[][] tiles;
|
||||
@@ -12,7 +12,7 @@ public abstract class TilePathfinder{
|
||||
}
|
||||
|
||||
protected boolean inBounds(int x, int y){
|
||||
return Mathf.inBounds(x, y, tiles);
|
||||
return Structs.inBounds(x, y, tiles);
|
||||
}
|
||||
|
||||
public abstract void search(Tile start, Tile end, Array<Tile> out);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class CommandMission extends Mission{
|
||||
private final UnitCommand command;
|
||||
|
||||
public CommandMission(UnitCommand command){
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
for(BaseUnit unit : Vars.unitGroups[Vars.defaultTeam.ordinal()].all()){
|
||||
if(unit.isCommanded() && unit.getCommand() == command){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("text.mission.battle", command.localized());
|
||||
}
|
||||
}
|
||||
22
core/src/io/anuke/mindustry/maps/missions/MechMission.java
Normal file
22
core/src/io/anuke/mindustry/maps/missions/MechMission.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class MechMission extends Mission{
|
||||
private final Mech mech;
|
||||
|
||||
public MechMission(Mech mech){
|
||||
this.mech = mech;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("te");
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public abstract class Mission{
|
||||
}
|
||||
|
||||
public GameMode getMode(){
|
||||
return GameMode.noWaves;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**Sets the message displayed on mission begin. Returns this mission for chaining.*/
|
||||
|
||||
22
core/src/io/anuke/mindustry/maps/missions/Missions.java
Normal file
22
core/src/io/anuke/mindustry/maps/missions/Missions.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
|
||||
public class Missions{
|
||||
|
||||
/**Returns an array of missions to obtain the items needed to make this block.
|
||||
* This array includes a mission to place this block.*/
|
||||
public static Array<Mission> blockRecipe(Block block){
|
||||
Recipe recipe = Recipe.getByResult(block);
|
||||
|
||||
Array<Mission> out = new Array<>();
|
||||
for(ItemStack stack : recipe.requirements){
|
||||
out.add(new ItemMission(stack.item, stack.amount));
|
||||
}
|
||||
out.add(new BlockMission(block));
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,13 @@ import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.function.BiPredicate;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Floor extends Block{
|
||||
//TODO implement proper bitmasking
|
||||
protected static IntIntMap bitmask = Mathf.mapInt(2, 1, 8, 2, 10, 3, 11, 4, 16, 5, 18, 6, 22, 7, 24, 8,
|
||||
protected static IntIntMap bitmask = Structs.mapInt(2, 1, 8, 2, 10, 3, 11, 4, 16, 5, 18, 6, 22, 7, 24, 8,
|
||||
26, 9, 27, 10, 30, 11, 31, 12, 64, 13, 66, 14, 72, 15, 74, 16, 75, 17, 80, 18,
|
||||
82, 19, 86, 20, 88, 21, 90, 22, 91, 23, 94, 24, 95, 25, 104, 26, 106, 27, 107, 28,
|
||||
120, 29, 122, 30, 123, 31, 126, 32, 127, 33, 208, 34, 210, 35, 214, 36, 216, 37,
|
||||
|
||||
Reference in New Issue
Block a user