1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-17 11:27:35 +03:00

Many small tweaks / Custom rules / Server run files / Balance

This commit is contained in:
Anuken 2019-03-24 16:29:25 -04:00
parent ea5c78f814
commit f7aa58e385
60 changed files with 4706 additions and 4711 deletions

View File

@ -109,7 +109,7 @@ public class RemoteWriteGenerator{
for(VariableElement var : elem.getParameters()){
//special case: calling local-only methods uses the local player
if(index == 0 && methodEntry.where == Loc.client){
results.append("io.anuke.mindustry.Vars.players[0]");
results.append("io.anuke.mindustry.Vars.player");
}else{
results.append(var.getSimpleName());
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -413,6 +413,7 @@ category.items = Items
category.crafting = Input/Output
category.shooting = Shooting
category.optional = Optional Enhancements
setting.landscape.name = Lock Landscape
setting.shadows.name = Shadows
setting.animatedwater.name = Animated Water
setting.antialias.name = Antialias[LIGHT_GRAY] (requires restart)[]
@ -490,6 +491,18 @@ mode.pvp.name = PvP
mode.pvp.description = Fight against other players locally.
mode.attack.name = Attack
mode.attack.description = No waves, with the goal to destroy the enemy base.
mode.custom = Custom Rules
rules.infiniteresources = Infinite Resources
rules.wavetimer = Wave Timer
rules.waves = Waves
rules.enemyCheat = Infinite AI Resources
rules.pvp = PvP
rules.unitdrops = Unit Drops
rules.enemycorebuildradius = Enemy Core No-Build Radius:[LIGHT_GRAY] (tiles)
rules.respawntime = Respawn Time:[LIGHT_GRAY] (sec)
rules.wavespacing = Wave Spacing:[LIGHT_GRAY] (sec)
content.item.name = Items
content.liquid.name = Liquids
content.unit.name = Units

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

After

Width:  |  Height:  |  Size: 506 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 727 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 218 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 513 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -283,6 +283,7 @@
disabledFontColor: gray,
selection: selection,
background: underline,
invalidBackground: underline-red,
cursor: cursor,
messageFont: default-font,
messageFontColor: gray

View File

@ -142,7 +142,7 @@ public class Vars{
public static EntityGroup<BaseUnit>[] unitGroups;
/**all local players, currently only has one player. may be used for local co-op in the future*/
public static Player[] players = {};
public static Player player;
public static void init(){
Serialization.init();

View File

@ -54,7 +54,7 @@ public class WaveSpawner{
/**@return true if the player is near a ground spawn point.*/
public boolean playerNear(){
return groundSpawns.count(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, players[0].x, players[0].y) < maxShockwaveDst) > 0;
return groundSpawns.count(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < maxShockwaveDst) > 0;
}
public void spawnEnemies(){

View File

@ -1118,8 +1118,8 @@ public class Blocks implements ContentList{
Items.scrap, Bullets.flakScrap,
Items.lead, Bullets.flakLead
);
reload = 43f;
range = 160f;
reload = 33f;
range = 180f;
size = 2;
burstSpacing = 5f;
shots = 2;
@ -1141,7 +1141,7 @@ public class Blocks implements ContentList{
);
recoil = 0f;
reload = 4f;
range = 53f;
range = 60f;
shootCone = 50f;
targetAir = false;
ammoUseEffect = Fx.none;

View File

@ -134,28 +134,32 @@ public class Bullets implements ContentList{
bulletWidth = bulletHeight = 14f;
collides = true;
collidesTiles = true;
splashDamageRadius = 45f;
splashDamage = 50f;
splashDamageRadius = 20f;
splashDamage = 38f;
backColor = Pal.bulletYellowBack;
frontColor = Pal.bulletYellow;
}};
flakLead = new FlakBulletType(3.9f, 3){{
flakLead = new FlakBulletType(4.2f, 3){{
lifetime = 50f;
ammoMultiplier = 3f;
shootEffect = Fx.shootSmall;
bulletWidth = 6f;
bulletHeight = 8f;
hitEffect = Fx.flakExplosion;
splashDamage = 25f;
splashDamage = 30f;
splashDamageRadius = 15f;
}};
flakScrap = new FlakBulletType(3.5f, 3){{
flakScrap = new FlakBulletType(4f, 3){{
lifetime = 50f;
ammoMultiplier = 3f;
shootEffect = Fx.shootSmall;
reloadMultiplier = 0.5f;
bulletWidth = 6f;
bulletHeight = 8f;
hitEffect = Fx.flakExplosion;
splashDamage = 16f;
splashDamage = 24f;
splashDamageRadius = 24f;
}};
@ -454,11 +458,11 @@ public class Bullets implements ContentList{
}
};
basicFlame = new BulletType(2.5f, 5){
basicFlame = new BulletType(3f, 6f){
{
ammoMultiplier = 3f;
hitSize = 7f;
lifetime = 40f;
lifetime = 42f;
pierce = true;
drag = 0.05f;
statusDuration = 60f * 4;
@ -473,11 +477,11 @@ public class Bullets implements ContentList{
}
};
pyraFlame = new BulletType(2.7f, 8){
pyraFlame = new BulletType(3.3f, 9f){
{
ammoMultiplier = 4f;
hitSize = 7f;
lifetime = 40f;
lifetime = 42f;
pierce = true;
drag = 0.05f;
statusDuration = 60f * 6;

View File

@ -91,7 +91,7 @@ public class UnitTypes implements ContentList{
hitsize = 10f;
rotatespeed = 0.06f;
targetAir = false;
health = 800;
health = 750;
weapon = new Weapon("artillery"){{
length = 1f;
reload = 60f;

View File

@ -48,7 +48,7 @@ public class Control implements ApplicationListener{
private Interval timer = new Interval(2);
private boolean hiscore = false;
private boolean wasPaused = false;
private InputHandler[] inputs = {};
private InputHandler input;
public Control(){
IntBuffer buf = BufferUtils.newIntBuffer(1);
@ -80,7 +80,7 @@ public class Control implements ApplicationListener{
"lastBuild", 0
);
addPlayer(0);
createPlayer();
saves.load();
@ -91,21 +91,17 @@ public class Control implements ApplicationListener{
});
Events.on(PlayEvent.class, event -> {
for(Player player : players){
player.add();
}
player.add();
state.set(State.playing);
});
Events.on(WorldLoadEvent.class, event -> {
Core.app.post(() -> Core.camera.position.set(players[0]));
Core.app.post(() -> Core.camera.position.set(player));
});
Events.on(ResetEvent.class, event -> {
for(Player player : players){
player.reset();
}
player.reset();
hiscore = false;
@ -139,7 +135,7 @@ public class Control implements ApplicationListener{
if(state.rules.pvp && !Net.active()){
try{
Net.host(port);
players[0].isAdmin = true;
player.isAdmin = true;
}catch(IOException e){
ui.showError(Core.bundle.format("server.error", Strings.parseException(e, false)));
Core.app.post(() -> state.set(State.menu));
@ -150,7 +146,7 @@ public class Control implements ApplicationListener{
Events.on(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content));
Events.on(BlockBuildEndEvent.class, e -> {
if(e.team == players[0].getTeam()){
if(e.team == player.getTeam()){
if(e.breaking){
state.stats.buildingsDeconstructed++;
}else{
@ -160,13 +156,13 @@ public class Control implements ApplicationListener{
});
Events.on(BlockDestroyEvent.class, e -> {
if(e.tile.getTeam() == players[0].getTeam()){
if(e.tile.getTeam() == player.getTeam()){
state.stats.buildingsDestroyed ++;
}
});
Events.on(UnitDestroyEvent.class, e -> {
if(e.unit.getTeam() != players[0].getTeam()){
if(e.unit.getTeam() != player.getTeam()){
state.stats.enemyUnitsDestroyed ++;
}
});
@ -180,65 +176,29 @@ public class Control implements ApplicationListener{
});
}
public void addPlayer(int index){
if(players.length != index + 1){
Player[] old = players;
players = new Player[index + 1];
System.arraycopy(old, 0, players, 0, old.length);
}
if(inputs.length != index + 1){
InputHandler[] oldi = inputs;
inputs = new InputHandler[index + 1];
System.arraycopy(oldi, 0, inputs, 0, oldi.length);
}
Player setTo = (index == 0 ? null : players[0]);
Player player = new Player();
void createPlayer(){
player = new Player();
player.name = Core.settings.getString("name");
player.mech = mobile ? Mechs.starterMobile : Mechs.starterDesktop;
player.color.set(Core.settings.getInt("color-" + index));
player.color.set(Core.settings.getInt("color-0"));
player.isLocal = true;
player.playerIndex = index;
player.isMobile = mobile;
players[index] = player;
if(setTo != null){
player.set(setTo.x, setTo.y);
if(mobile){
input = new MobileInput();
}else{
input = new DesktopInput();
}
if(!state.is(State.menu)){
player.add();
}
InputHandler input;
if(mobile){
input = new MobileInput(player);
}else{
input = new DesktopInput(player);
}
inputs[index] = input;
Core.input.addProcessor(input);
}
public void removePlayer(){
players[players.length - 1].remove();
inputs[inputs.length - 1].remove();
Player[] old = players;
players = new Player[players.length - 1];
System.arraycopy(old, 0, players, 0, players.length);
InputHandler[] oldi = inputs;
inputs = new InputHandler[inputs.length - 1];
System.arraycopy(oldi, 0, inputs, 0, inputs.length);
}
public InputHandler input(int index){
return inputs[index];
public InputHandler input(){
return input;
}
public void playMap(Map map, Rules rules){
@ -259,8 +219,6 @@ public class Control implements ApplicationListener{
content.dispose();
Net.dispose();
ui.editor.dispose();
inputs = new InputHandler[]{};
players = new Player[]{};
}
@Override
@ -304,20 +262,16 @@ public class Control implements ApplicationListener{
public void update(){
saves.update();
for(InputHandler inputHandler : inputs){
inputHandler.updateController();
}
input.updateController();
//autosave global data if it's modified
data.checkSave();
if(!state.is(State.menu)){
for(InputHandler input : inputs){
input.update();
}
input.update();
if(world.isZone()){
for(Tile tile : state.teams.get(players[0].getTeam()).cores){
for(Tile tile : state.teams.get(player.getTeam()).cores){
for(Item item : content.items()){
if(tile.entity.items.has(item)){
data.unlockContent(item);

View File

@ -63,7 +63,6 @@ public class NetClient implements ApplicationListener{
public NetClient(){
Net.handleClient(Connect.class, packet -> {
Player player = players[0];
player.isAdmin = false;
@ -188,8 +187,8 @@ public class NetClient implements ApplicationListener{
@Remote(variants = Variant.one)
public static void onPositionSet(float x, float y){
players[0].x = x;
players[0].y = y;
player.x = x;
player.y = y;
}
@Remote
@ -333,8 +332,6 @@ public class NetClient implements ApplicationListener{
void sync(){
if(timer.get(0, playerSyncTime)){
Player player = players[0];
BuildRequest[] requests;
//limit to 10 to prevent buffer overflows
int usedRequests = Math.min(player.getPlaceQueue().size, 10);

View File

@ -113,11 +113,11 @@ public class Renderer implements ApplicationListener{
if(state.is(State.menu)){
graphics.clear(Color.BLACK);
}else{
Vector2 position = Tmp.v3.set(players[0]);
Vector2 position = Tmp.v3.set(player);
if(players[0].isDead()){
TileEntity core = players[0].getClosestCore();
if(core != null && players[0].spawner == null){
if(player.isDead()){
TileEntity core = player.getClosestCore();
if(core != null && player.spawner == null){
camera.position.lerpDelta(core.x, core.y, 0.08f);
}else{
camera.position.lerpDelta(position, 0.08f);
@ -148,8 +148,8 @@ public class Renderer implements ApplicationListener{
camera.update();
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
camera.position.x = players[0].x;
camera.position.y = players[0].y;
camera.position.x = player.x;
camera.position.y = player.y;
}
graphics.clear(clearColor);

View File

@ -63,7 +63,6 @@ public class UI implements ApplicationListener{
public AdminsDialog admins;
public TraceDialog traces;
public ChangelogDialog changelog;
public LocalPlayerDialog localplayers;
public DatabaseDialog database;
public ContentInfoDialog content;
public DeployDialog deploy;
@ -175,7 +174,6 @@ public class UI implements ApplicationListener{
admins = new AdminsDialog();
traces = new TraceDialog();
maps = new MapsDialog();
localplayers = new LocalPlayerDialog();
content = new ContentInfoDialog();
deploy = new DeployDialog();
tech = new TechTreeDialog();
@ -183,7 +181,7 @@ public class UI implements ApplicationListener{
Group group = Core.scene.root;
backfrag.build(group);
control.input(0).getFrag().build(group);
control.input().getFrag().build(group);
hudfrag.build(group);
menufrag.build(group);
chatfrag.container().build(group);
@ -219,7 +217,7 @@ public class UI implements ApplicationListener{
cont.margin(30).add(text).padRight(6f);
TextField field = cont.addField(def, t -> {
}).size(170f, 50f).get();
field.setTextFieldFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
field.setFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
Platform.instance.addDialog(field);
buttons.defaults().size(120, 54).pad(4);
buttons.addButton("$ok", () -> {

View File

@ -258,13 +258,13 @@ public class World implements ApplicationListener{
invalidMap = false;
if(!headless){
if(state.teams.get(players[0].getTeam()).cores.size == 0){
if(state.teams.get(player.getTeam()).cores.size == 0){
ui.showError("$map.nospawn");
invalidMap = true;
}else if(state.rules.pvp){ //pvp maps need two cores to be valid
invalidMap = true;
for(Team team : Team.all){
if(state.teams.get(team).cores.size != 0 && team != players[0].getTeam()){
if(state.teams.get(team).cores.size != 0 && team != player.getTeam()){
invalidMap = false;
}
}

View File

@ -49,6 +49,7 @@ public class EditorTile extends Tile{
@Override
public void setBlock(Block type){
if(type == null) return;
Block previous = wall == null ? Blocks.air : wall;
if(previous == type) return;
super.setBlock(type);

View File

@ -181,7 +181,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
shown(() -> {
saved = true;
Platform.instance.beginForceLandscape();
if(!Core.settings.getBool("landscape")) Platform.instance.beginForceLandscape();
editor.clearOp();
Core.scene.setScrollFocus(view);
if(!shownWithMap){
@ -195,7 +195,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
hidden(() -> {
editor.clearOp();
Platform.instance.updateRPC();
Platform.instance.endForceLandscape();
if(!Core.settings.getBool("landscape")) Platform.instance.endForceLandscape();
});
}

View File

@ -66,7 +66,6 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
public SpawnerTrait spawner, lastSpawner;
public NetConnection con;
public int playerIndex = 0;
public boolean isLocal = false;
public Interval timer = new Interval(4);
public TargetTrait target;
@ -585,7 +584,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
movement.x += xa * speed;
}
Vector2 vec = Core.input.mouseWorld(control.input(playerIndex).getMouseX(), control.input(playerIndex).getMouseY());
Vector2 vec = Core.input.mouseWorld(control.input().getMouseX(), control.input().getMouseY());
pointerX = vec.x;
pointerY = vec.y;
updateShooting();
@ -608,7 +607,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
rotation = Mathf.slerpDelta(rotation, mech.flying ? velocity.angle() : movement.angle(), 0.13f * baseLerp);
}
}else{
float angle = control.input(playerIndex).mouseAngle(x, y);
float angle = control.input().mouseAngle(x, y);
this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f * baseLerp);
}
}
@ -727,8 +726,8 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
}
}else if(isShooting()){
Vector2 vec = Core.input.mouseWorld(control.input(playerIndex).getMouseX(),
control.input(playerIndex).getMouseY());
Vector2 vec = Core.input.mouseWorld(control.input().getMouseX(),
control.input().getMouseY());
pointerX = vec.x;
pointerY = vec.y;
@ -808,7 +807,6 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
if(isLocal){
stream.writeByte(mech.id);
stream.writeByte(playerIndex);
stream.writeInt(lastSpawner == null ? noSpawner : lastSpawner.getTile().pos());
super.writeSave(stream, false);
}
@ -820,14 +818,13 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
if(local && !headless){
byte mechid = stream.readByte();
int index = stream.readByte();
int spawner = stream.readInt();
if(world.tile(spawner) != null && world.tile(spawner).entity != null && world.tile(spawner).entity instanceof SpawnerTrait){
lastSpawner = (SpawnerTrait)(world.tile(spawner).entity);
}
players[index].readSaveSuper(stream);
players[index].mech = content.getByID(ContentType.mech, mechid);
players[index].dead = false;
player.readSaveSuper(stream);
player.mech = content.getByID(ContentType.mech, mechid);
player.dead = false;
}else if(local){
byte mechid = stream.readByte();
stream.readByte();

View File

@ -218,7 +218,7 @@ public class BlockRenderer{
block.drawShadow(req.tile);
}else if(req.layer == Layer.block){
block.draw(req.tile);
if(block.synthetic() && req.tile.getTeam() != players[0].getTeam()){
if(block.synthetic() && req.tile.getTeam() != player.getTeam()){
block.drawTeam(req.tile);
}
}else if(req.layer == block.layer){

View File

@ -25,20 +25,18 @@ public class OverlayRenderer{
private float buildFadeTime;
public void drawBottom(){
for(Player player : players){
InputHandler input = control.input(player.playerIndex);
InputHandler input = control.input();
if(!input.isDrawing() || player.isDead()) continue;
if(!input.isDrawing() || player.isDead()) return;
input.drawOutlined();
}
input.drawOutlined();
}
public void drawTop(){
if(Core.settings.getBool("indicators")){
for(Player player : playerGroup.all()){
if(player != players[0] && player.getTeam() == players[0].getTeam()){
if(player != player && player.getTeam() == player.getTeam()){
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
@ -52,7 +50,7 @@ public class OverlayRenderer{
}
Units.allUnits(unit -> {
if(unit != players[0] && unit.getTeam() != players[0].getTeam() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){
if(unit != player && unit.getTeam() != player.getTeam() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){
Tmp.v1.set(unit.x, unit.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
Lines.stroke(1f, unit.getTeam().color);
@ -62,67 +60,66 @@ public class OverlayRenderer{
});
}
for(Player player : players){
if(player.isDead()) continue; //dead players don't draw
if(player.isDead()) return; //dead players don't draw
InputHandler input = control.input(player.playerIndex);
InputHandler input = control.input();
//draw config selected block
if(input.frag.config.isShown()){
Tile tile = input.frag.config.getSelectedTile();
tile.block().drawConfigure(tile);
}
//draw config selected block
if(input.frag.config.isShown()){
Tile tile = input.frag.config.getSelectedTile();
tile.block().drawConfigure(tile);
}
input.drawTop();
input.drawTop();
buildFadeTime = Mathf.lerpDelta(buildFadeTime, input.isPlacing() ? 1f : 0f, 0.06f);
buildFadeTime = Mathf.lerpDelta(buildFadeTime, input.isPlacing() ? 1f : 0f, 0.06f);
Draw.reset();
Lines.stroke(buildFadeTime*2f);
Draw.reset();
Lines.stroke(buildFadeTime*2f);
if(buildFadeTime > 0.005f){
for(Team enemy : state.teams.enemiesOf(player.getTeam())){
for(Tile core : state.teams.get(enemy).cores){
float dst = Mathf.dst(player.x, player.y, core.drawx(), core.drawy());
if(dst < state.rules.enemyCoreBuildRadius * 1.5f){
Draw.color(Color.DARK_GRAY);
Lines.poly(core.drawx(), core.drawy() - 2, 200, state.rules.enemyCoreBuildRadius);
Draw.color(Pal.accent, enemy.color, 0.5f + Mathf.absin(Time.time(), 10f, 0.5f));
Lines.poly(core.drawx(), core.drawy(), 200, state.rules.enemyCoreBuildRadius);
}
if(buildFadeTime > 0.005f){
for(Team enemy : state.teams.enemiesOf(player.getTeam())){
for(Tile core : state.teams.get(enemy).cores){
float dst = Mathf.dst(player.x, player.y, core.drawx(), core.drawy());
if(dst < state.rules.enemyCoreBuildRadius * 1.5f){
Draw.color(Color.DARK_GRAY);
Lines.poly(core.drawx(), core.drawy() - 2, 200, state.rules.enemyCoreBuildRadius);
Draw.color(Pal.accent, enemy.color, 0.5f + Mathf.absin(Time.time(), 10f, 0.5f));
Lines.poly(core.drawx(), core.drawy(), 200, state.rules.enemyCoreBuildRadius);
}
}
}
}
Draw.reset();
//draw selected block bars and info
if(input.block == null && !Core.scene.hasMouse()){
Vector2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
Tile tile = world.tileWorld(vec.x, vec.y);
if(tile != null && tile.block() != Blocks.air && tile.target().getTeam() == player.getTeam()){
Tile target = tile.target();
target.block().drawSelect(target);
}
}
if(input.isDroppingItem()){
Vector2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
float size = 8;
Draw.rect(player.item().item.icon(Item.Icon.large), v.x, v.y, size, size);
Draw.color(Pal.accent);
Lines.circle(v.x, v.y, 6 + Mathf.absin(Time.time(), 5f, 1f));
Draw.reset();
//draw selected block bars and info
if(input.block == null && !Core.scene.hasMouse()){
Vector2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
Tile tile = world.tileWorld(vec.x, vec.y);
if(tile != null && tile.block() != Blocks.air && tile.target().getTeam() == players[0].getTeam()){
Tile target = tile.target();
target.block().drawSelect(target);
}
}
if(input.isDroppingItem()){
Vector2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
float size = 8;
Draw.rect(player.item().item.icon(Item.Icon.large), v.x, v.y, size, size);
Draw.color(Pal.accent);
Lines.circle(v.x, v.y, 6 + Mathf.absin(Time.time(), 5f, 1f));
Draw.reset();
Tile tile = world.tileWorld(v.x, v.y);
if(tile != null) tile = tile.target();
if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
Draw.color(Pal.place);
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 1 + Mathf.absin(Time.time(), 5f, 1f));
Draw.color();
}
Tile tile = world.tileWorld(v.x, v.y);
if(tile != null) tile = tile.target();
if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
Draw.color(Pal.place);
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 1 + Mathf.absin(Time.time(), 5f, 1f));
Draw.color();
}
}
}
}

View File

@ -10,7 +10,6 @@ import io.anuke.arc.math.geom.Geometry;
import io.anuke.arc.math.geom.Point2;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
@ -34,10 +33,6 @@ public class DesktopInput extends InputHandler{
private int prevX, prevY, prevRotation;
public DesktopInput(Player player){
super(player);
}
/**Draws a placement icon for a specific block.*/
void drawPlace(int x, int y, Block block, int rotation, int prevX, int prevY, int prevRotation){
if(validPlace(x, y, block, rotation)){

View File

@ -44,7 +44,6 @@ public abstract class InputHandler implements InputProcessor{
/**Distance on the back from where items originate.*/
final static float backTrns = 3f;
public final Player player;
public final OverlayFragment frag = new OverlayFragment(this);
public Block block;
@ -54,10 +53,6 @@ public abstract class InputHandler implements InputProcessor{
protected PlaceDraw placeDraw = new PlaceDraw();
private PlaceLine line = new PlaceLine();
public InputHandler(Player player){
this.player = player;
}
//methods to override
@Remote(targets = Loc.client, called = Loc.server)

View File

@ -28,7 +28,6 @@ import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.entities.type.Unit;
import io.anuke.mindustry.graphics.Pal;
@ -81,8 +80,7 @@ public class MobileInput extends InputHandler implements GestureListener{
private int prevX, prevY, prevRotation;
public MobileInput(Player player){
super(player);
public MobileInput(){
Core.input.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
}

View File

@ -71,8 +71,6 @@ public class NetworkIO{
public static void loadWorld(InputStream is){
Player player = players[0];
try(DataInputStream stream = new DataInputStream(is)){
Time.clear();
@ -127,7 +125,7 @@ public class NetworkIO{
state.teams.get(team).cores.add(world.tile(stream.readInt()));
}
if(team == players[0].getTeam() && cores > 0){
if(team == player.getTeam() && cores > 0){
Core.camera.position.set(state.teams.get(team).cores.first().drawx(), state.teams.get(team).cores.first().drawy());
}
}
@ -140,7 +138,7 @@ public class NetworkIO{
public static ByteBuffer writeServerData(){
int maxlen = 32;
String host = (headless ? "Server" : players[0].name);
String host = (headless ? "Server" : player.name);
String map = world.getMap() == null ? "None" : world.getMap().name();
host = host.substring(0, Math.min(host.length(), maxlen));

View File

@ -72,7 +72,7 @@ public class Weapon{
if(player == null) return;
//clients do not see their own shoot events: they are simulated completely clientside to prevent laggy visuals
//messing with the firerate or any other stats does not affect the server (take that, script kiddies!)
if(Net.client() && player == Vars.players[0]){
if(Net.client() && player == Vars.player){
return;
}

View File

@ -27,7 +27,9 @@ public class AboutDialog extends FloatingDialog{
public AboutDialog(){
super("$about.button");
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
if(!ios){
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
}
shown(this::setup);
onResize(this::setup);

View File

@ -7,8 +7,8 @@ import io.anuke.arc.scene.ui.Dialog;
import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.player;
import static io.anuke.mindustry.Vars.playerColors;
import static io.anuke.mindustry.Vars.players;
public class ColorPickDialog extends Dialog{
private Consumer<Color> cons;
@ -29,7 +29,7 @@ public class ColorPickDialog extends Dialog{
cons.accept(color);
hide();
}).size(48).get();
button.setChecked(players[0].color.equals(color));
button.setChecked(player.color.equals(color));
button.getStyle().imageUpColor = color;
if(i % 4 == 3){

View File

@ -21,6 +21,7 @@ import static io.anuke.mindustry.Vars.*;
public class CustomGameDialog extends FloatingDialog{
Difficulty difficulty = Difficulty.normal;
RulePreset lastPreset = RulePreset.survival;
CustomRulesDialog dialog = new CustomRulesDialog();
public CustomGameDialog(){
super("$customgame");
@ -31,7 +32,9 @@ public class CustomGameDialog extends FloatingDialog{
}
void setup(){
state.rules = lastPreset.get();
if(lastPreset == null){
lastPreset = RulePreset.survival;
}
cont.clear();
Table maps = new Table();
@ -51,12 +54,16 @@ public class CustomGameDialog extends FloatingDialog{
for(RulePreset mode : RulePreset.values()){
modes.addButton(mode.toString(), "toggle", () -> {
state.rules = mode.get();
lastPreset = mode;
}).update(b -> b.setChecked(lastPreset == mode)).group(group).size(140f, 54f);
if(i++ % 2 == 1) modes.row();
}
selmode.add(modes);
selmode.addButton("$mode.custom", "toggle", () -> {})
.update(b -> b.setChecked(lastPreset == null)).size(108f).group(group).get().tapped(() -> {
lastPreset = null;
dialog.show();
});
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
cont.add(selmode);
@ -86,7 +93,7 @@ public class CustomGameDialog extends FloatingDialog{
state.wavetime = difficulty.waveTime;
}).width(s);
cont.add(sdif);
cont.add(sdif).visible(() -> lastPreset != null);
cont.row();
float images = 146f;
@ -114,7 +121,7 @@ public class CustomGameDialog extends FloatingDialog{
image.clicked(() -> {
hide();
control.playMap(map, lastPreset.get());
control.playMap(map, lastPreset == null ? dialog.rules : lastPreset.get());
});
maps.add(image);

View File

@ -0,0 +1,56 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.function.FloatConsumer;
import io.anuke.arc.function.FloatProvider;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Strings;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Rules;
import static io.anuke.mindustry.Vars.tilesize;
public class CustomRulesDialog extends FloatingDialog{
public final Rules rules = new Rules();
private Table main;
public CustomRulesDialog(){
super("$mode.custom");
setFillParent(true);
shown(this::setup);
addCloseButton();
}
void setup(){
cont.clear();
cont.pane(m -> main = m);
main.margin(10f);
main.left().defaults().fillX().left().pad(5);
main.row();
main.addCheck("$rules.infiniteresources", b -> rules.infiniteResources = b).checked(b -> rules.infiniteResources);
main.row();
main.addCheck("$rules.wavetimer", b -> rules.waveTimer = b).checked(b -> rules.waveTimer);
main.row();
main.addCheck("$rules.waves", b -> rules.waves = b).checked(b -> rules.waves);
main.row();
main.addCheck("$rules.pvp", b -> rules.pvp = b).checked(b -> rules.pvp);
main.row();
main.addCheck("$rules.unitdrops", b -> rules.unitDrops = b).checked(b -> rules.unitDrops);
main.row();
number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f*tilesize, () -> Math.min(rules.enemyCoreBuildRadius/tilesize, 200));
number("$rules.respawntime", f -> rules.respawnTime = f*60f, () -> rules.respawnTime/60f);
number("$rules.wavespacing", f -> rules.waveSpacing = f*60f, () -> rules.waveSpacing/60f);
}
void number(String text, FloatConsumer cons, FloatProvider prov){
main.table(t -> {
t.left();
t.add(text).left().padRight(5);
Platform.instance.addDialog(t.addField((int)prov.get() + "", s -> cons.accept(Strings.parseFloat(s)))
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
});
main.row();
}
}

View File

@ -6,12 +6,11 @@ import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.util.Strings;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.net.Net;
import java.io.IOException;
import static io.anuke.mindustry.Vars.players;
import static io.anuke.mindustry.Vars.player;
import static io.anuke.mindustry.Vars.ui;
public class HostDialog extends FloatingDialog{
@ -20,8 +19,6 @@ public class HostDialog extends FloatingDialog{
public HostDialog(){
super("$hostserver");
Player player = players[0];
addCloseButton();
cont.table(t -> {

View File

@ -14,7 +14,6 @@ import io.anuke.arc.util.Strings;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.net.Host;
import io.anuke.mindustry.net.Net;
@ -185,8 +184,6 @@ public class JoinDialog extends FloatingDialog{
void setup(){
float w = targetWidth();
Player player = players[0];
hosts.clear();
hosts.add(remote).growX();

View File

@ -1,61 +0,0 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.Stack;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Scaling;
import io.anuke.mindustry.entities.type.Player;
import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.players;
public class LocalPlayerDialog extends FloatingDialog{
public LocalPlayerDialog(){
super("$addplayers");
addCloseButton();
shown(this::rebuild);
}
private void rebuild(){
float size = 140f;
cont.clear();
if(players.length > 1){
cont.addImageButton("icon-cancel", 14 * 2, () -> {
control.removePlayer();
rebuild();
}).size(50f, size).pad(5).bottom();
}else{
cont.add().size(50f, size);
}
for(Player player : players){
Table table = new Table();
Stack stack = new Stack();
stack.add(new Image("button"));
Image img = new Image(Core.atlas.find("icon-chat"));
img.setScaling(Scaling.fill);
stack.add(img);
table.add("Player " + (player.playerIndex + 1)).update(label -> label.setColor(player.color));
table.row();
table.add(stack).size(size);
cont.add(table).pad(5);
}
if(players.length < 4){
cont.addImageButton("icon-add", 14 * 2, () -> {
control.addPlayer(players.length);
rebuild();
}).size(50f, size).pad(5).bottom();
}
}
}

View File

@ -14,6 +14,7 @@ import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Align;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.net.Net;
@ -194,6 +195,18 @@ public class SettingsMenuDialog extends SettingsDialog{
if(Core.settings.getBool("fullscreen")){
Core.graphics.setFullscreenMode(Core.graphics.getDisplayMode());
}
}else{
graphics.checkPref("landscape", false, b -> {
if(b){
Platform.instance.beginForceLandscape();
}else{
Platform.instance.endForceLandscape();
}
});
if(Core.settings.getBool("landscape")){
Platform.instance.beginForceLandscape();
}
}
graphics.checkPref("fps", false);

View File

@ -14,8 +14,7 @@ import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.*;
public class BlockConfigFragment extends Fragment{
private Table table = new Table();
@ -59,7 +58,7 @@ public class BlockConfigFragment extends Fragment{
return;
}
if(configTile != null && configTile.block().shouldHideConfigure(configTile, input.player)){
if(configTile != null && configTile.block().shouldHideConfigure(configTile, player)){
hideConfig();
return;
}

View File

@ -87,8 +87,6 @@ public class BlockInventoryFragment extends Fragment{
private void rebuild(boolean actions){
Player player = input.player;
IntSet container = new IntSet();
table.clearChildren();

View File

@ -109,7 +109,7 @@ public class ChatFragment extends Table{
fieldlabel.setStyle(fieldlabel.getStyle());
chatfield = new TextField("", new TextField.TextFieldStyle(scene.skin.get(TextField.TextFieldStyle.class)));
chatfield.setTextFieldFilter((field, c) -> field.getText().length() < Vars.maxTextLength);
chatfield.setFilter((field, c) -> field.getText().length() < Vars.maxTextLength);
chatfield.getStyle().background = null;
chatfield.getStyle().font = scene.skin.getFont("default-font-chat");
chatfield.getStyle().fontColor = Color.WHITE;
@ -207,7 +207,7 @@ public class ChatFragment extends Table{
history.insert(1, message);
Call.sendMessage(players[0], message);
Call.sendMessage(player, message);
}
public void toggle(){

View File

@ -184,9 +184,9 @@ public class HudFragment extends Fragment{
t.table("flat", c -> c.add("")
.update(l ->{
l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - players[0].destructTime) / 60f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - player.destructTime) / 60f)));
}).get().setAlignment(Align.center, Align.center)).margin(6).update(u -> {
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(players[0].isOutOfBounds()), 0.1f);
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(player.isOutOfBounds()), 0.1f);
}).get().color.a = 0f;
});
@ -207,13 +207,13 @@ public class HudFragment extends Fragment{
});
t.top().visible(() -> {
if(state.is(State.menu) || state.teams.get(players[0].getTeam()).cores.size == 0 ||
state.teams.get(players[0].getTeam()).cores.first().entity == null){
if(state.is(State.menu) || state.teams.get(player.getTeam()).cores.size == 0 ||
state.teams.get(player.getTeam()).cores.first().entity == null){
coreAttackTime = 0f;
return false;
}
float curr = state.teams.get(players[0].getTeam()).cores.first().entity.health;
float curr = state.teams.get(player.getTeam()).cores.first().entity.health;
if(!Float.isNaN(lastCoreHP) && curr < lastCoreHP){
coreAttackTime = notifDuration;
}
@ -470,13 +470,13 @@ public class HudFragment extends Fragment{
private void addPlayButton(Table table){
table.right().addImageButton("icon-play", "right", 30f, () -> {
if(Net.client() && players[0].isAdmin){
Call.onAdminRequest(players[0], AdminAction.wave);
if(Net.client() && player.isAdmin){
Call.onAdminRequest(player, AdminAction.wave);
}else{
state.wavetime = 0f;
}
}).growY().fillX().right().width(40f)
.visible(() -> state.rules.waves && ((Net.server() || players[0].isAdmin) || !Net.active()) && state.enemies() == 0
.visible(() -> state.rules.waves && ((Net.server() || player.isAdmin) || !Net.active()) && state.enemies() == 0
&& (!world.spawner.isSpawning() || !state.rules.waveTimer));
}
}

View File

@ -58,7 +58,7 @@ public class PlacementFragment extends Fragment{
public PlacementFragment(){
Events.on(WorldLoadEvent.class, event -> {
control.input(0).block = null;
control.input().block = null;
rebuild();
});
@ -123,7 +123,7 @@ public class PlacementFragment extends Fragment{
full.bottom().right().visible(() -> !state.is(State.menu) && ui.hudfrag.shown());
full.table(frame -> {
InputHandler input = control.input(0);
InputHandler input = control.input();
//rebuilds the category table with the correct recipes
Runnable rebuildCategory = () -> {
@ -154,7 +154,7 @@ public class PlacementFragment extends Fragment{
button.getStyle().imageUp = new TextureRegionDrawable(block.icon(Icon.medium));
button.update(() -> { //color unplacable things gray
TileEntity core = players[0].getClosestCore();
TileEntity core = player.getClosestCore();
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : Color.GRAY;
button.forEach(elem -> elem.setColor(color));
button.setChecked(input.block == block);
@ -211,7 +211,7 @@ public class PlacementFragment extends Fragment{
line.addImage(stack.item.icon(Item.Icon.small)).size(8 * 2);
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
line.labelWrap(() -> {
TileEntity core = players[0].getClosestCore();
TileEntity core = player.getClosestCore();
if(core == null || state.rules.infiniteResources) return "*/*";
int amount = core.items.get(stack.item);
@ -231,7 +231,7 @@ public class PlacementFragment extends Fragment{
t.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
}).growX().left();
if(hoverTile.getTeam() == players[0].getTeam()){
if(hoverTile.getTeam() == player.getTeam()){
topTable.row();
topTable.table(t -> {
t.left().defaults().left();
@ -326,8 +326,8 @@ public class PlacementFragment extends Fragment{
}
//block currently selected
if(control.input(0).block != null){
toDisplay = control.input(0).block;
if(control.input().block != null){
toDisplay = control.input().block;
}
//block hovered on in build menu

View File

@ -98,7 +98,7 @@ public class PlayerListFragment extends Fragment{
button.addImage("icon-admin").size(14 * 2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5).get().updateVisibility();
if((Net.server() || players[0].isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
if((Net.server() || player.isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
button.add().growY();
float bs = (h) / 2f;

View File

@ -267,7 +267,7 @@ public class Block extends BlockStorage{
/**Call when some content is produced. This unlocks the content if it is applicable.*/
public void useContent(Tile tile, UnlockableContent content){
if(!headless && tile.getTeam() == players[0].getTeam()){
if(!headless && tile.getTeam() == player.getTeam()){
logic.handleContent(content);
}
}

View File

@ -66,7 +66,7 @@ public class BuildBlock extends Block{
Core.app.post(() -> tile.block().placed(tile));
//last builder was this local client player, call placed()
if(!headless && builderID == players[0].id){
if(!headless && builderID == player.id){
//this is run delayed, since if this is called on the server, all clients need to recieve the onBuildFinish()
//event first before they can recieve the placed() event modification results
Core.app.post(() -> tile.block().playerPlaced(tile));

View File

@ -12,9 +12,9 @@ import io.anuke.mindustry.type.Item.Icon;
import static io.anuke.mindustry.Vars.*;
public interface SelectionTrait{
public class ItemSelection{
default void buildItemTable(Table table, Supplier<Item> holder, Consumer<Item> consumer){
public static void buildItemTable(Table table, Supplier<Item> holder, Consumer<Item> consumer){
Array<Item> items = content.items();
@ -28,7 +28,7 @@ public interface SelectionTrait{
for(Item item : items){
if(!data.isUnlocked(item) && world.isZone()) continue;
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> control.input(0).frag.config.hideConfig()).group(group).get();
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> control.input().frag.config.hideConfig()).group(group).get();
button.changed(() -> consumer.accept(button.isChecked() ? item : null));
button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Icon.medium));
button.update(() -> button.setChecked(holder.get() == item));

View File

@ -9,7 +9,7 @@ import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.SelectionTrait;
import io.anuke.mindustry.world.blocks.ItemSelection;
import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.scene.ui.layout.Table;
@ -21,7 +21,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.content;
public class Sorter extends Block implements SelectionTrait{
public class Sorter extends Block{
private static Item lastItem;
public Sorter(String name){
@ -119,7 +119,7 @@ public class Sorter extends Block implements SelectionTrait{
@Override
public void buildTable(Tile tile, Table table){
SorterEntity entity = tile.entity();
buildItemTable(table, () -> entity.sortItem, item -> {
ItemSelection.buildItemTable(table, () -> entity.sortItem, item -> {
lastItem = item;
Call.setSorterItem(null, tile, item);
});

View File

@ -74,7 +74,7 @@ public class LiquidSource extends Block{
final int f = i;
ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> {
Call.setLiquidSourceLiquid(null, tile, items.get(f));
control.input(0).frag.config.hideConfig();
control.input().frag.config.hideConfig();
}).size(38).group(group).get();
button.getStyle().imageUp = new TextureRegionDrawable(items.get(i).iconRegion);
button.setChecked(entity.source.id == f);

View File

@ -12,7 +12,7 @@ import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.SelectionTrait;
import io.anuke.mindustry.world.blocks.ItemSelection;
import java.io.DataInput;
import java.io.DataOutput;
@ -20,7 +20,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.content;
public class Unloader extends Block implements SelectionTrait{
public class Unloader extends Block{
protected float speed = 1f;
protected final int timerUnload = timers++;
@ -91,7 +91,7 @@ public class Unloader extends Block implements SelectionTrait{
@Override
public void buildTable(Tile tile, Table table){
SortedUnloaderEntity entity = tile.entity();
buildItemTable(table, () -> entity.sortItem, item -> {
ItemSelection.buildItemTable(table, () -> entity.sortItem, item -> {
lastItem = item;
Call.setSortedUnloaderItem(null, tile, item);
});

View File

@ -60,8 +60,8 @@ public class DesktopPlatform extends Platform{
presence.largeImageText = "Wave " + state.wave;
}
presence.state = unitGroups[players[0].getTeam().ordinal()].size() == 1 ? "1 Unit Active" :
(unitGroups[players[0].getTeam().ordinal()].size() + " Units Active");
presence.state = unitGroups[player.getTeam().ordinal()].size() == 1 ? "1 Unit Active" :
(unitGroups[player.getTeam().ordinal()].size() + " Units Active");
if(Net.active()){
presence.partyMax = 100;

View File

@ -6,6 +6,10 @@ sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "io.anuke.mindustry.server.ServerLauncher"
project.ext.assetsDir = new File("../core/assets")
ext.getServerFolder = {
return "../deploy/${appName}-server-${getVersionString()}"
}
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
@ -43,12 +47,39 @@ task dist(type: Jar) {
}
}
task deploy(type: Copy){
task dzip(type: Zip){
from getServerFolder()
archiveName "$appName-server-${getVersionString()}.zip"
destinationDir(file("../deploy/"))
finalizedBy 'cleanup'
}
task cleanup{
doLast{
delete{
delete getServerFolder()
}
}
}
task deploy{
dependsOn "dist"
from "build/libs/server-release.jar"
into "../deploy/"
rename ("server-release.jar", appName + "-server-" + getVersionString() + ".jar")
finalizedBy 'dzip'
doLast{
copy{
from "build/libs/server-release.jar"
into getServerFolder()
rename("server-release.jar", "server.jar")
}
copy{
from "server_template"
into getServerFolder()
}
}
}
dist.dependsOn classes

View File

@ -0,0 +1,5 @@
@Echo Off
Set "JV="
For /F "Tokens=3" %%A In ('java -version 2^>^&1') Do If Not Defined JV Set "JV=%%~A"
If /I "%JV%"=="not" (Echo Java is not installed, this server requires Java to run.) Else (start java -jar server.jar)
Pause

View File

@ -0,0 +1 @@
java -jar server.jar