mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-14 01:37:36 +07:00
Large-scale bugfix: fixed #76, as well as many other timer bugs
This commit is contained in:
@ -34,7 +34,7 @@ import static io.anuke.ucore.util.Log.*;
|
||||
|
||||
public class ServerControl extends Module {
|
||||
private final CommandHandler handler = new CommandHandler("");
|
||||
private ShuffleMode mode = ShuffleMode.both;
|
||||
private ShuffleMode mode;
|
||||
|
||||
public ServerControl(){
|
||||
Settings.defaults("shufflemode", "normal");
|
||||
|
@ -0,0 +1,95 @@
|
||||
package io.anuke.mindustry.server.mapgen;
|
||||
|
||||
public class GenProperties {
|
||||
public long seed;
|
||||
public SpawnStyle spawns;
|
||||
public MapStyle maps;
|
||||
public OreStyle ores;
|
||||
public RiverType riverType;
|
||||
public RiverStyle rivers;
|
||||
public TerrainStyle terrains;
|
||||
public FoliageStyle foliage;
|
||||
public EnvironmentStyle environment;
|
||||
|
||||
enum SpawnStyle{
|
||||
/**spawn in a wide arc with branching paths*/
|
||||
arc,
|
||||
/**spawn in one big group*/
|
||||
grouped,
|
||||
/**surround player spawn*/
|
||||
surround
|
||||
}
|
||||
|
||||
enum MapStyle{
|
||||
/**256x512*/
|
||||
longY,
|
||||
/**128x256*/
|
||||
smallY,
|
||||
/**128x128*/
|
||||
small,
|
||||
/**256x256*/
|
||||
normal
|
||||
}
|
||||
|
||||
enum OreStyle{
|
||||
/**'vanilla' noise-distributed ores*/
|
||||
normal,
|
||||
/**ores hug the walls*/
|
||||
nearWalls,
|
||||
/**ores hug all liquid rivers*/
|
||||
nearRivers,
|
||||
/**large veins*/
|
||||
largeVeins
|
||||
}
|
||||
|
||||
enum RiverType{
|
||||
lava,
|
||||
water,
|
||||
oil,
|
||||
none
|
||||
}
|
||||
|
||||
enum RiverStyle{
|
||||
/**long thin river spanning entire map*/
|
||||
longThin,
|
||||
/**long river branching into many others*/
|
||||
longBranch,
|
||||
/**one long, thick river*/
|
||||
longThick,
|
||||
/**short, thick river that ends in a lake*/
|
||||
shortLake
|
||||
}
|
||||
|
||||
enum TerrainStyle{
|
||||
/**bordered around by the normal material*/
|
||||
normal,
|
||||
/**everything is islands*/
|
||||
waterIslands,
|
||||
/**everything is islands: lava edition*/
|
||||
lavaIslands
|
||||
}
|
||||
|
||||
enum FoliageStyle{
|
||||
patches,
|
||||
veins,
|
||||
blobs,
|
||||
ridges
|
||||
}
|
||||
|
||||
enum FoilageType{
|
||||
grass,
|
||||
sand,
|
||||
darkStone,
|
||||
ice,
|
||||
}
|
||||
|
||||
enum EnvironmentStyle{
|
||||
desert,
|
||||
stoneDesert,
|
||||
grassy,
|
||||
dark,
|
||||
darkStone,
|
||||
stone,
|
||||
icy,
|
||||
}
|
||||
}
|
55
server/src/io/anuke/mindustry/server/mapgen/MapImage.java
Normal file
55
server/src/io/anuke/mindustry/server/mapgen/MapImage.java
Normal file
@ -0,0 +1,55 @@
|
||||
package io.anuke.mindustry.server.mapgen;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.ColorMapper.BlockPair;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class MapImage {
|
||||
public final Pixmap pixmap;
|
||||
public final int width, height;
|
||||
|
||||
public MapImage(Pixmap pixmap){
|
||||
this.pixmap = pixmap;
|
||||
this.width = pixmap.getWidth();
|
||||
this.height = pixmap.getHeight();
|
||||
}
|
||||
|
||||
public MapImage(int width, int height){
|
||||
this(new Pixmap(width, height, Format.RGBA8888));
|
||||
}
|
||||
|
||||
public Block wall(int x, int y){
|
||||
BlockPair pair = ColorMapper.get(pixmap.getPixel(x, y));
|
||||
return pair.wall;
|
||||
}
|
||||
|
||||
public Block floor(int x, int y){
|
||||
BlockPair pair = ColorMapper.get(pixmap.getPixel(x, y));
|
||||
return pair.floor;
|
||||
}
|
||||
|
||||
public void set(int x, int y, Block block){
|
||||
pixmap.drawPixel(x, y, ColorMapper.getColor(block));
|
||||
}
|
||||
|
||||
public Block get(int x, int y){
|
||||
BlockPair pair = ColorMapper.get(pixmap.getPixel(x, y));
|
||||
return pair.dominant();
|
||||
}
|
||||
|
||||
public boolean solid(int x, int y){
|
||||
BlockPair pair = ColorMapper.get(pixmap.getPixel(x, y));
|
||||
return pair.dominant().solid;
|
||||
}
|
||||
|
||||
public boolean has(int x, int y){
|
||||
return Mathf.inBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
public int pack(int x, int y){
|
||||
return x + y*width;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.anuke.mindustry.server.mapgen;
|
||||
|
||||
import com.badlogic.gdx.ai.pfa.Connection;
|
||||
import com.badlogic.gdx.ai.pfa.DefaultGraphPath;
|
||||
import com.badlogic.gdx.ai.pfa.Heuristic;
|
||||
import com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder;
|
||||
import com.badlogic.gdx.ai.pfa.indexed.IndexedGraph;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
|
||||
public class MapPathfinder {
|
||||
private IndexedGraph<Integer> graph = new MapGraph();
|
||||
private DefaultGraphPath<Integer> path = new DefaultGraphPath<>();
|
||||
private IndexedAStarPathFinder<Integer> finder = new IndexedAStarPathFinder<>(graph);
|
||||
private Heuristic<Integer> heuristic;
|
||||
private MapImage image;
|
||||
|
||||
public Array<GridPoint2> find(int startx, int starty, int endx, int endy, Evaluator eval){
|
||||
finder.searchNodePath(image.pack(startx, starty), image.pack(endx, endy),
|
||||
(heuristic = (node, endNode) ->
|
||||
eval.cost(image.get(node % image.width, node / image.width),
|
||||
node % image.width,
|
||||
node / image.width)), path);
|
||||
|
||||
Array<GridPoint2> arr = new Array<>();
|
||||
|
||||
for(int i : path.nodes){
|
||||
arr.add(new GridPoint2(i % image.width, i / image.width));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
private class MapGraph extends DefaultGraphPath<Integer> implements IndexedGraph<Integer>{
|
||||
private Array<Connection<Integer>> cons = new Array<>();
|
||||
|
||||
@Override
|
||||
public int getIndex(Integer node) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeCount() {
|
||||
return image.width * image.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<Connection<Integer>> getConnections(Integer fromNode) {
|
||||
int x = fromNode % image.width;
|
||||
int y = fromNode / image.width;
|
||||
cons.clear();
|
||||
for(GridPoint2 p : Geometry.d4){
|
||||
if(image.has(x + p.x, y + p.y)){
|
||||
cons.add(new MapConnection(fromNode, image.pack(x + p.x, y + p.y)));
|
||||
}
|
||||
}
|
||||
return cons;
|
||||
}
|
||||
}
|
||||
|
||||
private class MapConnection implements Connection<Integer>{
|
||||
int from, to;
|
||||
|
||||
MapConnection(int from, int to){
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCost() {
|
||||
return heuristic.estimate(from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getFromNode() {
|
||||
return from;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getToNode() {
|
||||
return to;
|
||||
}
|
||||
}
|
||||
|
||||
interface Evaluator{
|
||||
int cost(Block block, int x, int y);
|
||||
}
|
||||
}
|
14
server/src/io/anuke/mindustry/server/mapgen/ProcGen.java
Normal file
14
server/src/io/anuke/mindustry/server/mapgen/ProcGen.java
Normal file
@ -0,0 +1,14 @@
|
||||
package io.anuke.mindustry.server.mapgen;
|
||||
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.ucore.noise.RidgedPerlin;
|
||||
import io.anuke.ucore.noise.Simplex;
|
||||
|
||||
public class ProcGen {
|
||||
public RidgedPerlin rid = new RidgedPerlin(1, 1, 1);
|
||||
public Simplex sim = new Simplex();
|
||||
|
||||
public Map generate(GenProperties props){
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user