More public modules
This commit is contained in:
@@ -159,7 +159,7 @@ public class BlockIndexer{
|
|||||||
* Find the closest ore block relative to a position.
|
* Find the closest ore block relative to a position.
|
||||||
*/
|
*/
|
||||||
public Tile findClosestOre(float xp, float yp, Item item){
|
public Tile findClosestOre(float xp, float yp, Item item){
|
||||||
Tile tile = Geometry.findClosest(xp, yp, world.indexer().getOrePositions(item));
|
Tile tile = Geometry.findClosest(xp, yp, world.indexer.getOrePositions(item));
|
||||||
|
|
||||||
if(tile == null) return null;
|
if(tile == null) return null;
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class Pathfinder{
|
|||||||
|
|
||||||
path.lastSearchTime = TimeUtils.millis();
|
path.lastSearchTime = TimeUtils.millis();
|
||||||
|
|
||||||
Array<Tile> set = world.indexer().getEnemy(team, BlockFlag.target);
|
Array<Tile> set = world.indexer.getEnemy(team, BlockFlag.target);
|
||||||
for(Tile other : set){
|
for(Tile other : set){
|
||||||
path.weights[other.x][other.y] = 0;
|
path.weights[other.x][other.y] = 0;
|
||||||
path.searches[other.x][other.y] = path.search;
|
path.searches[other.x][other.y] = path.search;
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ public class Renderer extends RendererModule{
|
|||||||
ObjectIntMap<Tile> seen = new ObjectIntMap<>();
|
ObjectIntMap<Tile> seen = new ObjectIntMap<>();
|
||||||
|
|
||||||
for(BlockFlag flag : BlockFlag.values()){
|
for(BlockFlag flag : BlockFlag.values()){
|
||||||
for(Tile tile : world.indexer().getEnemy(Team.blue, flag)){
|
for(Tile tile : world.indexer.getEnemy(Team.blue, flag)){
|
||||||
int index = seen.getAndIncrement(tile, 0, 1);
|
int index = seen.getAndIncrement(tile, 0, 1);
|
||||||
Draw.tscl(0.125f);
|
Draw.tscl(0.125f);
|
||||||
Draw.text(flag.name(), tile.drawx(), tile.drawy() + tile.block().size * tilesize / 2f + 4 + index * 3);
|
Draw.text(flag.name(), tile.drawx(), tile.drawy() + tile.block().size * tilesize / 2f + 4 + index * 3);
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
|||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.io.MapIO;
|
import io.anuke.mindustry.io.MapIO;
|
||||||
import io.anuke.mindustry.maps.*;
|
import io.anuke.mindustry.maps.*;
|
||||||
|
import io.anuke.mindustry.maps.generation.WorldGenerator;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.maps.generation.WorldGenerator;
|
|
||||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||||
import io.anuke.ucore.core.Events;
|
import io.anuke.ucore.core.Events;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
@@ -28,12 +28,12 @@ public class World extends Module{
|
|||||||
public final Maps maps = new Maps();
|
public final Maps maps = new Maps();
|
||||||
public final Sectors sectors = new Sectors();
|
public final Sectors sectors = new Sectors();
|
||||||
public final WorldGenerator generator = new WorldGenerator();
|
public final WorldGenerator generator = new WorldGenerator();
|
||||||
|
public final BlockIndexer indexer = new BlockIndexer();
|
||||||
|
public final Pathfinder pathfinder = new Pathfinder();
|
||||||
|
|
||||||
private Map currentMap;
|
private Map currentMap;
|
||||||
private Sector currentSector;
|
private Sector currentSector;
|
||||||
private Tile[][] tiles;
|
private Tile[][] tiles;
|
||||||
private Pathfinder pathfinder = new Pathfinder();
|
|
||||||
private BlockIndexer indexer = new BlockIndexer();
|
|
||||||
|
|
||||||
private Array<Tile> tempTiles = new ThreadArray<>();
|
private Array<Tile> tempTiles = new ThreadArray<>();
|
||||||
private boolean generating, invalidMap;
|
private boolean generating, invalidMap;
|
||||||
@@ -52,26 +52,6 @@ public class World extends Module{
|
|||||||
maps.dispose();
|
maps.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldGenerator generator(){
|
|
||||||
return generator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sectors sectors(){
|
|
||||||
return sectors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Maps maps(){
|
|
||||||
return maps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockIndexer indexer(){
|
|
||||||
return indexer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pathfinder pathfinder(){
|
|
||||||
return pathfinder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInvalidMap(){
|
public boolean isInvalidMap(){
|
||||||
return invalidMap;
|
return invalidMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class Units{
|
|||||||
* Returns the neareset ally tile in a range.
|
* Returns the neareset ally tile in a range.
|
||||||
*/
|
*/
|
||||||
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||||
return world.indexer().findTile(team, x, y, range, pred);
|
return world.indexer.findTile(team, x, y, range, pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +114,7 @@ public class Units{
|
|||||||
*/
|
*/
|
||||||
public static TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
public static TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||||
for(Team enemy : state.teams.enemiesOf(team)){
|
for(Team enemy : state.teams.enemiesOf(team)){
|
||||||
TileEntity entity = world.indexer().findTile(enemy, x, y, range, pred);
|
TileEntity entity = world.indexer.findTile(enemy, x, y, range, pred);
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,12 +99,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCommanded(){
|
public boolean isCommanded(){
|
||||||
return !isWave && world.indexer().getAllied(team, BlockFlag.comandCenter).size != 0;
|
return !isWave && world.indexer.getAllied(team, BlockFlag.comandCenter).size != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitCommand getCommand(){
|
public UnitCommand getCommand(){
|
||||||
if(isCommanded()){
|
if(isCommanded()){
|
||||||
return world.indexer().getAllied(team, BlockFlag.comandCenter).first().<CommandCenterEntity>entity().command;
|
return world.indexer.getAllied(team, BlockFlag.comandCenter).first().<CommandCenterEntity>entity().command;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -180,12 +180,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void targetClosestAllyFlag(BlockFlag flag){
|
public void targetClosestAllyFlag(BlockFlag flag){
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, flag));
|
Tile target = Geometry.findClosest(x, y, world.indexer.getAllied(team, flag));
|
||||||
if(target != null) this.target = target.entity;
|
if(target != null) this.target = target.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void targetClosestEnemyFlag(BlockFlag flag){
|
public void targetClosestEnemyFlag(BlockFlag flag){
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer().getEnemy(team, flag));
|
Tile target = Geometry.findClosest(x, y, world.indexer.getEnemy(team, flag));
|
||||||
if(target != null) this.target = target.entity;
|
if(target != null) this.target = target.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
state.set(attack);
|
state.set(attack);
|
||||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
}else if(!targetHasFlag(BlockFlag.repair)){
|
||||||
retarget(() -> {
|
retarget(() -> {
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair));
|
Tile target = Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair));
|
||||||
if(target != null) FlyingUnit.this.target = target.entity;
|
if(target != null) FlyingUnit.this.target = target.entity;
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
@@ -177,7 +177,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
if(health <= health * type.retreatPercent && !isCommanded() &&
|
if(health <= health * type.retreatPercent && !isCommanded() &&
|
||||||
Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair)) != null){
|
Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
|
||||||
setState(retreat);
|
setState(retreat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
|
|
||||||
if(targetItem == null) return;
|
if(targetItem == null) return;
|
||||||
|
|
||||||
target = world.indexer().findClosestOre(x, y, targetItem);
|
target = world.indexer.findClosestOre(x, y, targetItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(target instanceof Tile){
|
if(target instanceof Tile){
|
||||||
@@ -224,7 +224,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
state.set(attack);
|
state.set(attack);
|
||||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
}else if(!targetHasFlag(BlockFlag.repair)){
|
||||||
if(timer.get(timerTarget, 20)){
|
if(timer.get(timerTarget, 20)){
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair));
|
Tile target = Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair));
|
||||||
if(target != null) Drone.this.target = target.entity;
|
if(target != null) Drone.this.target = target.entity;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -318,7 +318,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
if(health <= health * type.retreatPercent &&
|
if(health <= health * type.retreatPercent &&
|
||||||
Geometry.findClosest(x, y, world.indexer().getAllied(team, BlockFlag.repair)) != null){
|
Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
|
||||||
setState(retreat);
|
setState(retreat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class CommandCenter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playerPlaced(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
ObjectSet<Tile> set = world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter);
|
ObjectSet<Tile> set = world.indexer.getAllied(tile.getTeam(), BlockFlag.comandCenter);
|
||||||
|
|
||||||
if(set.size > 0){
|
if(set.size > 0){
|
||||||
CommandCenterEntity entity = tile.entity();
|
CommandCenterEntity entity = tile.entity();
|
||||||
@@ -92,7 +92,7 @@ public class CommandCenter extends Block{
|
|||||||
public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){
|
public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){
|
||||||
Effects.effect(((CommandCenter)tile.block()).effect, tile);
|
Effects.effect(((CommandCenter)tile.block()).effect, tile);
|
||||||
|
|
||||||
for(Tile center : world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter)){
|
for(Tile center : world.indexer.getAllied(tile.getTeam(), BlockFlag.comandCenter)){
|
||||||
if(center.block() instanceof CommandCenter){
|
if(center.block() instanceof CommandCenter){
|
||||||
CommandCenterEntity entity = center.entity();
|
CommandCenterEntity entity = center.entity();
|
||||||
entity.command = command;
|
entity.command = command;
|
||||||
|
|||||||
Reference in New Issue
Block a user