Many small tweaks / Custom rules / Server run files / Balance
@@ -109,7 +109,7 @@ public class RemoteWriteGenerator{
|
|||||||
for(VariableElement var : elem.getParameters()){
|
for(VariableElement var : elem.getParameters()){
|
||||||
//special case: calling local-only methods uses the local player
|
//special case: calling local-only methods uses the local player
|
||||||
if(index == 0 && methodEntry.where == Loc.client){
|
if(index == 0 && methodEntry.where == Loc.client){
|
||||||
results.append("io.anuke.mindustry.Vars.players[0]");
|
results.append("io.anuke.mindustry.Vars.player");
|
||||||
}else{
|
}else{
|
||||||
results.append(var.getSimpleName());
|
results.append(var.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -413,6 +413,7 @@ category.items = Items
|
|||||||
category.crafting = Input/Output
|
category.crafting = Input/Output
|
||||||
category.shooting = Shooting
|
category.shooting = Shooting
|
||||||
category.optional = Optional Enhancements
|
category.optional = Optional Enhancements
|
||||||
|
setting.landscape.name = Lock Landscape
|
||||||
setting.shadows.name = Shadows
|
setting.shadows.name = Shadows
|
||||||
setting.animatedwater.name = Animated Water
|
setting.animatedwater.name = Animated Water
|
||||||
setting.antialias.name = Antialias[LIGHT_GRAY] (requires restart)[]
|
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.pvp.description = Fight against other players locally.
|
||||||
mode.attack.name = Attack
|
mode.attack.name = Attack
|
||||||
mode.attack.description = No waves, with the goal to destroy the enemy base.
|
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.item.name = Items
|
||||||
content.liquid.name = Liquids
|
content.liquid.name = Liquids
|
||||||
content.unit.name = Units
|
content.unit.name = Units
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 509 B After Width: | Height: | Size: 506 B |
|
Before Width: | Height: | Size: 727 KiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 243 KiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 201 KiB |
|
Before Width: | Height: | Size: 255 KiB After Width: | Height: | Size: 316 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 513 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 63 KiB |
@@ -283,6 +283,7 @@
|
|||||||
disabledFontColor: gray,
|
disabledFontColor: gray,
|
||||||
selection: selection,
|
selection: selection,
|
||||||
background: underline,
|
background: underline,
|
||||||
|
invalidBackground: underline-red,
|
||||||
cursor: cursor,
|
cursor: cursor,
|
||||||
messageFont: default-font,
|
messageFont: default-font,
|
||||||
messageFontColor: gray
|
messageFontColor: gray
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class Vars{
|
|||||||
public static EntityGroup<BaseUnit>[] unitGroups;
|
public static EntityGroup<BaseUnit>[] unitGroups;
|
||||||
|
|
||||||
/**all local players, currently only has one player. may be used for local co-op in the future*/
|
/**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(){
|
public static void init(){
|
||||||
Serialization.init();
|
Serialization.init();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class WaveSpawner{
|
|||||||
|
|
||||||
/**@return true if the player is near a ground spawn point.*/
|
/**@return true if the player is near a ground spawn point.*/
|
||||||
public boolean playerNear(){
|
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(){
|
public void spawnEnemies(){
|
||||||
|
|||||||
@@ -1118,8 +1118,8 @@ public class Blocks implements ContentList{
|
|||||||
Items.scrap, Bullets.flakScrap,
|
Items.scrap, Bullets.flakScrap,
|
||||||
Items.lead, Bullets.flakLead
|
Items.lead, Bullets.flakLead
|
||||||
);
|
);
|
||||||
reload = 43f;
|
reload = 33f;
|
||||||
range = 160f;
|
range = 180f;
|
||||||
size = 2;
|
size = 2;
|
||||||
burstSpacing = 5f;
|
burstSpacing = 5f;
|
||||||
shots = 2;
|
shots = 2;
|
||||||
@@ -1141,7 +1141,7 @@ public class Blocks implements ContentList{
|
|||||||
);
|
);
|
||||||
recoil = 0f;
|
recoil = 0f;
|
||||||
reload = 4f;
|
reload = 4f;
|
||||||
range = 53f;
|
range = 60f;
|
||||||
shootCone = 50f;
|
shootCone = 50f;
|
||||||
targetAir = false;
|
targetAir = false;
|
||||||
ammoUseEffect = Fx.none;
|
ammoUseEffect = Fx.none;
|
||||||
|
|||||||
@@ -134,28 +134,32 @@ public class Bullets implements ContentList{
|
|||||||
bulletWidth = bulletHeight = 14f;
|
bulletWidth = bulletHeight = 14f;
|
||||||
collides = true;
|
collides = true;
|
||||||
collidesTiles = true;
|
collidesTiles = true;
|
||||||
splashDamageRadius = 45f;
|
splashDamageRadius = 20f;
|
||||||
splashDamage = 50f;
|
splashDamage = 38f;
|
||||||
backColor = Pal.bulletYellowBack;
|
backColor = Pal.bulletYellowBack;
|
||||||
frontColor = Pal.bulletYellow;
|
frontColor = Pal.bulletYellow;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
flakLead = new FlakBulletType(3.9f, 3){{
|
flakLead = new FlakBulletType(4.2f, 3){{
|
||||||
|
lifetime = 50f;
|
||||||
|
ammoMultiplier = 3f;
|
||||||
shootEffect = Fx.shootSmall;
|
shootEffect = Fx.shootSmall;
|
||||||
bulletWidth = 6f;
|
bulletWidth = 6f;
|
||||||
bulletHeight = 8f;
|
bulletHeight = 8f;
|
||||||
hitEffect = Fx.flakExplosion;
|
hitEffect = Fx.flakExplosion;
|
||||||
splashDamage = 25f;
|
splashDamage = 30f;
|
||||||
splashDamageRadius = 15f;
|
splashDamageRadius = 15f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
flakScrap = new FlakBulletType(3.5f, 3){{
|
flakScrap = new FlakBulletType(4f, 3){{
|
||||||
|
lifetime = 50f;
|
||||||
|
ammoMultiplier = 3f;
|
||||||
shootEffect = Fx.shootSmall;
|
shootEffect = Fx.shootSmall;
|
||||||
reloadMultiplier = 0.5f;
|
reloadMultiplier = 0.5f;
|
||||||
bulletWidth = 6f;
|
bulletWidth = 6f;
|
||||||
bulletHeight = 8f;
|
bulletHeight = 8f;
|
||||||
hitEffect = Fx.flakExplosion;
|
hitEffect = Fx.flakExplosion;
|
||||||
splashDamage = 16f;
|
splashDamage = 24f;
|
||||||
splashDamageRadius = 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;
|
ammoMultiplier = 3f;
|
||||||
hitSize = 7f;
|
hitSize = 7f;
|
||||||
lifetime = 40f;
|
lifetime = 42f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
drag = 0.05f;
|
drag = 0.05f;
|
||||||
statusDuration = 60f * 4;
|
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;
|
ammoMultiplier = 4f;
|
||||||
hitSize = 7f;
|
hitSize = 7f;
|
||||||
lifetime = 40f;
|
lifetime = 42f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
drag = 0.05f;
|
drag = 0.05f;
|
||||||
statusDuration = 60f * 6;
|
statusDuration = 60f * 6;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class UnitTypes implements ContentList{
|
|||||||
hitsize = 10f;
|
hitsize = 10f;
|
||||||
rotatespeed = 0.06f;
|
rotatespeed = 0.06f;
|
||||||
targetAir = false;
|
targetAir = false;
|
||||||
health = 800;
|
health = 750;
|
||||||
weapon = new Weapon("artillery"){{
|
weapon = new Weapon("artillery"){{
|
||||||
length = 1f;
|
length = 1f;
|
||||||
reload = 60f;
|
reload = 60f;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class Control implements ApplicationListener{
|
|||||||
private Interval timer = new Interval(2);
|
private Interval timer = new Interval(2);
|
||||||
private boolean hiscore = false;
|
private boolean hiscore = false;
|
||||||
private boolean wasPaused = false;
|
private boolean wasPaused = false;
|
||||||
private InputHandler[] inputs = {};
|
private InputHandler input;
|
||||||
|
|
||||||
public Control(){
|
public Control(){
|
||||||
IntBuffer buf = BufferUtils.newIntBuffer(1);
|
IntBuffer buf = BufferUtils.newIntBuffer(1);
|
||||||
@@ -80,7 +80,7 @@ public class Control implements ApplicationListener{
|
|||||||
"lastBuild", 0
|
"lastBuild", 0
|
||||||
);
|
);
|
||||||
|
|
||||||
addPlayer(0);
|
createPlayer();
|
||||||
|
|
||||||
saves.load();
|
saves.load();
|
||||||
|
|
||||||
@@ -91,21 +91,17 @@ public class Control implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(PlayEvent.class, event -> {
|
Events.on(PlayEvent.class, event -> {
|
||||||
for(Player player : players){
|
player.add();
|
||||||
player.add();
|
|
||||||
}
|
|
||||||
|
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
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 -> {
|
Events.on(ResetEvent.class, event -> {
|
||||||
for(Player player : players){
|
player.reset();
|
||||||
player.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
hiscore = false;
|
hiscore = false;
|
||||||
|
|
||||||
@@ -139,7 +135,7 @@ public class Control implements ApplicationListener{
|
|||||||
if(state.rules.pvp && !Net.active()){
|
if(state.rules.pvp && !Net.active()){
|
||||||
try{
|
try{
|
||||||
Net.host(port);
|
Net.host(port);
|
||||||
players[0].isAdmin = true;
|
player.isAdmin = true;
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
ui.showError(Core.bundle.format("server.error", Strings.parseException(e, false)));
|
ui.showError(Core.bundle.format("server.error", Strings.parseException(e, false)));
|
||||||
Core.app.post(() -> state.set(State.menu));
|
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(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content));
|
||||||
|
|
||||||
Events.on(BlockBuildEndEvent.class, e -> {
|
Events.on(BlockBuildEndEvent.class, e -> {
|
||||||
if(e.team == players[0].getTeam()){
|
if(e.team == player.getTeam()){
|
||||||
if(e.breaking){
|
if(e.breaking){
|
||||||
state.stats.buildingsDeconstructed++;
|
state.stats.buildingsDeconstructed++;
|
||||||
}else{
|
}else{
|
||||||
@@ -160,13 +156,13 @@ public class Control implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(BlockDestroyEvent.class, e -> {
|
Events.on(BlockDestroyEvent.class, e -> {
|
||||||
if(e.tile.getTeam() == players[0].getTeam()){
|
if(e.tile.getTeam() == player.getTeam()){
|
||||||
state.stats.buildingsDestroyed ++;
|
state.stats.buildingsDestroyed ++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(UnitDestroyEvent.class, e -> {
|
Events.on(UnitDestroyEvent.class, e -> {
|
||||||
if(e.unit.getTeam() != players[0].getTeam()){
|
if(e.unit.getTeam() != player.getTeam()){
|
||||||
state.stats.enemyUnitsDestroyed ++;
|
state.stats.enemyUnitsDestroyed ++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -180,65 +176,29 @@ public class Control implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(int index){
|
void createPlayer(){
|
||||||
if(players.length != index + 1){
|
player = new Player();
|
||||||
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();
|
|
||||||
player.name = Core.settings.getString("name");
|
player.name = Core.settings.getString("name");
|
||||||
player.mech = mobile ? Mechs.starterMobile : Mechs.starterDesktop;
|
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.isLocal = true;
|
||||||
player.playerIndex = index;
|
|
||||||
player.isMobile = mobile;
|
player.isMobile = mobile;
|
||||||
players[index] = player;
|
|
||||||
|
|
||||||
if(setTo != null){
|
if(mobile){
|
||||||
player.set(setTo.x, setTo.y);
|
input = new MobileInput();
|
||||||
|
}else{
|
||||||
|
input = new DesktopInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
player.add();
|
player.add();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputHandler input;
|
|
||||||
|
|
||||||
if(mobile){
|
|
||||||
input = new MobileInput(player);
|
|
||||||
}else{
|
|
||||||
input = new DesktopInput(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs[index] = input;
|
|
||||||
Core.input.addProcessor(input);
|
Core.input.addProcessor(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(){
|
public InputHandler input(){
|
||||||
players[players.length - 1].remove();
|
return input;
|
||||||
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 void playMap(Map map, Rules rules){
|
public void playMap(Map map, Rules rules){
|
||||||
@@ -259,8 +219,6 @@ public class Control implements ApplicationListener{
|
|||||||
content.dispose();
|
content.dispose();
|
||||||
Net.dispose();
|
Net.dispose();
|
||||||
ui.editor.dispose();
|
ui.editor.dispose();
|
||||||
inputs = new InputHandler[]{};
|
|
||||||
players = new Player[]{};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -304,20 +262,16 @@ public class Control implements ApplicationListener{
|
|||||||
public void update(){
|
public void update(){
|
||||||
saves.update();
|
saves.update();
|
||||||
|
|
||||||
for(InputHandler inputHandler : inputs){
|
input.updateController();
|
||||||
inputHandler.updateController();
|
|
||||||
}
|
|
||||||
|
|
||||||
//autosave global data if it's modified
|
//autosave global data if it's modified
|
||||||
data.checkSave();
|
data.checkSave();
|
||||||
|
|
||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
for(InputHandler input : inputs){
|
input.update();
|
||||||
input.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(world.isZone()){
|
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()){
|
for(Item item : content.items()){
|
||||||
if(tile.entity.items.has(item)){
|
if(tile.entity.items.has(item)){
|
||||||
data.unlockContent(item);
|
data.unlockContent(item);
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public class NetClient implements ApplicationListener{
|
|||||||
public NetClient(){
|
public NetClient(){
|
||||||
|
|
||||||
Net.handleClient(Connect.class, packet -> {
|
Net.handleClient(Connect.class, packet -> {
|
||||||
Player player = players[0];
|
|
||||||
|
|
||||||
player.isAdmin = false;
|
player.isAdmin = false;
|
||||||
|
|
||||||
@@ -188,8 +187,8 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
@Remote(variants = Variant.one)
|
@Remote(variants = Variant.one)
|
||||||
public static void onPositionSet(float x, float y){
|
public static void onPositionSet(float x, float y){
|
||||||
players[0].x = x;
|
player.x = x;
|
||||||
players[0].y = y;
|
player.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote
|
@Remote
|
||||||
@@ -333,8 +332,6 @@ public class NetClient implements ApplicationListener{
|
|||||||
void sync(){
|
void sync(){
|
||||||
|
|
||||||
if(timer.get(0, playerSyncTime)){
|
if(timer.get(0, playerSyncTime)){
|
||||||
Player player = players[0];
|
|
||||||
|
|
||||||
BuildRequest[] requests;
|
BuildRequest[] requests;
|
||||||
//limit to 10 to prevent buffer overflows
|
//limit to 10 to prevent buffer overflows
|
||||||
int usedRequests = Math.min(player.getPlaceQueue().size, 10);
|
int usedRequests = Math.min(player.getPlaceQueue().size, 10);
|
||||||
|
|||||||
@@ -113,11 +113,11 @@ public class Renderer implements ApplicationListener{
|
|||||||
if(state.is(State.menu)){
|
if(state.is(State.menu)){
|
||||||
graphics.clear(Color.BLACK);
|
graphics.clear(Color.BLACK);
|
||||||
}else{
|
}else{
|
||||||
Vector2 position = Tmp.v3.set(players[0]);
|
Vector2 position = Tmp.v3.set(player);
|
||||||
|
|
||||||
if(players[0].isDead()){
|
if(player.isDead()){
|
||||||
TileEntity core = players[0].getClosestCore();
|
TileEntity core = player.getClosestCore();
|
||||||
if(core != null && players[0].spawner == null){
|
if(core != null && player.spawner == null){
|
||||||
camera.position.lerpDelta(core.x, core.y, 0.08f);
|
camera.position.lerpDelta(core.x, core.y, 0.08f);
|
||||||
}else{
|
}else{
|
||||||
camera.position.lerpDelta(position, 0.08f);
|
camera.position.lerpDelta(position, 0.08f);
|
||||||
@@ -148,8 +148,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
camera.update();
|
camera.update();
|
||||||
|
|
||||||
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
||||||
camera.position.x = players[0].x;
|
camera.position.x = player.x;
|
||||||
camera.position.y = players[0].y;
|
camera.position.y = player.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.clear(clearColor);
|
graphics.clear(clearColor);
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public class UI implements ApplicationListener{
|
|||||||
public AdminsDialog admins;
|
public AdminsDialog admins;
|
||||||
public TraceDialog traces;
|
public TraceDialog traces;
|
||||||
public ChangelogDialog changelog;
|
public ChangelogDialog changelog;
|
||||||
public LocalPlayerDialog localplayers;
|
|
||||||
public DatabaseDialog database;
|
public DatabaseDialog database;
|
||||||
public ContentInfoDialog content;
|
public ContentInfoDialog content;
|
||||||
public DeployDialog deploy;
|
public DeployDialog deploy;
|
||||||
@@ -175,7 +174,6 @@ public class UI implements ApplicationListener{
|
|||||||
admins = new AdminsDialog();
|
admins = new AdminsDialog();
|
||||||
traces = new TraceDialog();
|
traces = new TraceDialog();
|
||||||
maps = new MapsDialog();
|
maps = new MapsDialog();
|
||||||
localplayers = new LocalPlayerDialog();
|
|
||||||
content = new ContentInfoDialog();
|
content = new ContentInfoDialog();
|
||||||
deploy = new DeployDialog();
|
deploy = new DeployDialog();
|
||||||
tech = new TechTreeDialog();
|
tech = new TechTreeDialog();
|
||||||
@@ -183,7 +181,7 @@ public class UI implements ApplicationListener{
|
|||||||
Group group = Core.scene.root;
|
Group group = Core.scene.root;
|
||||||
|
|
||||||
backfrag.build(group);
|
backfrag.build(group);
|
||||||
control.input(0).getFrag().build(group);
|
control.input().getFrag().build(group);
|
||||||
hudfrag.build(group);
|
hudfrag.build(group);
|
||||||
menufrag.build(group);
|
menufrag.build(group);
|
||||||
chatfrag.container().build(group);
|
chatfrag.container().build(group);
|
||||||
@@ -219,7 +217,7 @@ public class UI implements ApplicationListener{
|
|||||||
cont.margin(30).add(text).padRight(6f);
|
cont.margin(30).add(text).padRight(6f);
|
||||||
TextField field = cont.addField(def, t -> {
|
TextField field = cont.addField(def, t -> {
|
||||||
}).size(170f, 50f).get();
|
}).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);
|
Platform.instance.addDialog(field);
|
||||||
buttons.defaults().size(120, 54).pad(4);
|
buttons.defaults().size(120, 54).pad(4);
|
||||||
buttons.addButton("$ok", () -> {
|
buttons.addButton("$ok", () -> {
|
||||||
|
|||||||
@@ -258,13 +258,13 @@ public class World implements ApplicationListener{
|
|||||||
invalidMap = false;
|
invalidMap = false;
|
||||||
|
|
||||||
if(!headless){
|
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");
|
ui.showError("$map.nospawn");
|
||||||
invalidMap = true;
|
invalidMap = true;
|
||||||
}else if(state.rules.pvp){ //pvp maps need two cores to be valid
|
}else if(state.rules.pvp){ //pvp maps need two cores to be valid
|
||||||
invalidMap = true;
|
invalidMap = true;
|
||||||
for(Team team : Team.all){
|
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;
|
invalidMap = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class EditorTile extends Tile{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(Block type){
|
public void setBlock(Block type){
|
||||||
|
if(type == null) return;
|
||||||
Block previous = wall == null ? Blocks.air : wall;
|
Block previous = wall == null ? Blocks.air : wall;
|
||||||
if(previous == type) return;
|
if(previous == type) return;
|
||||||
super.setBlock(type);
|
super.setBlock(type);
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
saved = true;
|
saved = true;
|
||||||
Platform.instance.beginForceLandscape();
|
if(!Core.settings.getBool("landscape")) Platform.instance.beginForceLandscape();
|
||||||
editor.clearOp();
|
editor.clearOp();
|
||||||
Core.scene.setScrollFocus(view);
|
Core.scene.setScrollFocus(view);
|
||||||
if(!shownWithMap){
|
if(!shownWithMap){
|
||||||
@@ -195,7 +195,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
hidden(() -> {
|
hidden(() -> {
|
||||||
editor.clearOp();
|
editor.clearOp();
|
||||||
Platform.instance.updateRPC();
|
Platform.instance.updateRPC();
|
||||||
Platform.instance.endForceLandscape();
|
if(!Core.settings.getBool("landscape")) Platform.instance.endForceLandscape();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
public SpawnerTrait spawner, lastSpawner;
|
public SpawnerTrait spawner, lastSpawner;
|
||||||
|
|
||||||
public NetConnection con;
|
public NetConnection con;
|
||||||
public int playerIndex = 0;
|
|
||||||
public boolean isLocal = false;
|
public boolean isLocal = false;
|
||||||
public Interval timer = new Interval(4);
|
public Interval timer = new Interval(4);
|
||||||
public TargetTrait target;
|
public TargetTrait target;
|
||||||
@@ -585,7 +584,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
movement.x += xa * speed;
|
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;
|
pointerX = vec.x;
|
||||||
pointerY = vec.y;
|
pointerY = vec.y;
|
||||||
updateShooting();
|
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);
|
rotation = Mathf.slerpDelta(rotation, mech.flying ? velocity.angle() : movement.angle(), 0.13f * baseLerp);
|
||||||
}
|
}
|
||||||
}else{
|
}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);
|
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()){
|
}else if(isShooting()){
|
||||||
Vector2 vec = Core.input.mouseWorld(control.input(playerIndex).getMouseX(),
|
Vector2 vec = Core.input.mouseWorld(control.input().getMouseX(),
|
||||||
control.input(playerIndex).getMouseY());
|
control.input().getMouseY());
|
||||||
pointerX = vec.x;
|
pointerX = vec.x;
|
||||||
pointerY = vec.y;
|
pointerY = vec.y;
|
||||||
|
|
||||||
@@ -808,7 +807,6 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
|
|
||||||
if(isLocal){
|
if(isLocal){
|
||||||
stream.writeByte(mech.id);
|
stream.writeByte(mech.id);
|
||||||
stream.writeByte(playerIndex);
|
|
||||||
stream.writeInt(lastSpawner == null ? noSpawner : lastSpawner.getTile().pos());
|
stream.writeInt(lastSpawner == null ? noSpawner : lastSpawner.getTile().pos());
|
||||||
super.writeSave(stream, false);
|
super.writeSave(stream, false);
|
||||||
}
|
}
|
||||||
@@ -820,14 +818,13 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
|
|
||||||
if(local && !headless){
|
if(local && !headless){
|
||||||
byte mechid = stream.readByte();
|
byte mechid = stream.readByte();
|
||||||
int index = stream.readByte();
|
|
||||||
int spawner = stream.readInt();
|
int spawner = stream.readInt();
|
||||||
if(world.tile(spawner) != null && world.tile(spawner).entity != null && world.tile(spawner).entity instanceof SpawnerTrait){
|
if(world.tile(spawner) != null && world.tile(spawner).entity != null && world.tile(spawner).entity instanceof SpawnerTrait){
|
||||||
lastSpawner = (SpawnerTrait)(world.tile(spawner).entity);
|
lastSpawner = (SpawnerTrait)(world.tile(spawner).entity);
|
||||||
}
|
}
|
||||||
players[index].readSaveSuper(stream);
|
player.readSaveSuper(stream);
|
||||||
players[index].mech = content.getByID(ContentType.mech, mechid);
|
player.mech = content.getByID(ContentType.mech, mechid);
|
||||||
players[index].dead = false;
|
player.dead = false;
|
||||||
}else if(local){
|
}else if(local){
|
||||||
byte mechid = stream.readByte();
|
byte mechid = stream.readByte();
|
||||||
stream.readByte();
|
stream.readByte();
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public class BlockRenderer{
|
|||||||
block.drawShadow(req.tile);
|
block.drawShadow(req.tile);
|
||||||
}else if(req.layer == Layer.block){
|
}else if(req.layer == Layer.block){
|
||||||
block.draw(req.tile);
|
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);
|
block.drawTeam(req.tile);
|
||||||
}
|
}
|
||||||
}else if(req.layer == block.layer){
|
}else if(req.layer == block.layer){
|
||||||
|
|||||||
@@ -25,20 +25,18 @@ public class OverlayRenderer{
|
|||||||
private float buildFadeTime;
|
private float buildFadeTime;
|
||||||
|
|
||||||
public void drawBottom(){
|
public void drawBottom(){
|
||||||
for(Player player : players){
|
InputHandler input = control.input();
|
||||||
InputHandler input = control.input(player.playerIndex);
|
|
||||||
|
|
||||||
if(!input.isDrawing() || player.isDead()) continue;
|
if(!input.isDrawing() || player.isDead()) return;
|
||||||
|
|
||||||
input.drawOutlined();
|
input.drawOutlined();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawTop(){
|
public void drawTop(){
|
||||||
|
|
||||||
if(Core.settings.getBool("indicators")){
|
if(Core.settings.getBool("indicators")){
|
||||||
for(Player player : playerGroup.all()){
|
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)
|
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)){
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
||||||
|
|
||||||
@@ -52,7 +50,7 @@ public class OverlayRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Units.allUnits(unit -> {
|
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);
|
Tmp.v1.set(unit.x, unit.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||||
|
|
||||||
Lines.stroke(1f, unit.getTeam().color);
|
Lines.stroke(1f, unit.getTeam().color);
|
||||||
@@ -62,67 +60,66 @@ public class OverlayRenderer{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Player player : players){
|
if(player.isDead()) return; //dead players don't draw
|
||||||
if(player.isDead()) continue; //dead players don't draw
|
|
||||||
|
|
||||||
InputHandler input = control.input(player.playerIndex);
|
InputHandler input = control.input();
|
||||||
|
|
||||||
//draw config selected block
|
//draw config selected block
|
||||||
if(input.frag.config.isShown()){
|
if(input.frag.config.isShown()){
|
||||||
Tile tile = input.frag.config.getSelectedTile();
|
Tile tile = input.frag.config.getSelectedTile();
|
||||||
tile.block().drawConfigure(tile);
|
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();
|
Draw.reset();
|
||||||
Lines.stroke(buildFadeTime*2f);
|
Lines.stroke(buildFadeTime*2f);
|
||||||
|
|
||||||
if(buildFadeTime > 0.005f){
|
if(buildFadeTime > 0.005f){
|
||||||
for(Team enemy : state.teams.enemiesOf(player.getTeam())){
|
for(Team enemy : state.teams.enemiesOf(player.getTeam())){
|
||||||
for(Tile core : state.teams.get(enemy).cores){
|
for(Tile core : state.teams.get(enemy).cores){
|
||||||
float dst = Mathf.dst(player.x, player.y, core.drawx(), core.drawy());
|
float dst = Mathf.dst(player.x, player.y, core.drawx(), core.drawy());
|
||||||
if(dst < state.rules.enemyCoreBuildRadius * 1.5f){
|
if(dst < state.rules.enemyCoreBuildRadius * 1.5f){
|
||||||
Draw.color(Color.DARK_GRAY);
|
Draw.color(Color.DARK_GRAY);
|
||||||
Lines.poly(core.drawx(), core.drawy() - 2, 200, state.rules.enemyCoreBuildRadius);
|
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));
|
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);
|
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.reset();
|
||||||
|
|
||||||
//draw selected block bars and info
|
Tile tile = world.tileWorld(v.x, v.y);
|
||||||
if(input.block == null && !Core.scene.hasMouse()){
|
if(tile != null) tile = tile.target();
|
||||||
Vector2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
|
||||||
Tile tile = world.tileWorld(vec.x, vec.y);
|
Draw.color(Pal.place);
|
||||||
|
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 1 + Mathf.absin(Time.time(), 5f, 1f));
|
||||||
if(tile != null && tile.block() != Blocks.air && tile.target().getTeam() == players[0].getTeam()){
|
Draw.color();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import io.anuke.arc.math.geom.Geometry;
|
|||||||
import io.anuke.arc.math.geom.Point2;
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
|
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
|
||||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
||||||
@@ -34,10 +33,6 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
private int prevX, prevY, prevRotation;
|
private int prevX, prevY, prevRotation;
|
||||||
|
|
||||||
public DesktopInput(Player player){
|
|
||||||
super(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**Draws a placement icon for a specific block.*/
|
/**Draws a placement icon for a specific block.*/
|
||||||
void drawPlace(int x, int y, Block block, int rotation, int prevX, int prevY, int prevRotation){
|
void drawPlace(int x, int y, Block block, int rotation, int prevX, int prevY, int prevRotation){
|
||||||
if(validPlace(x, y, block, rotation)){
|
if(validPlace(x, y, block, rotation)){
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
/**Distance on the back from where items originate.*/
|
/**Distance on the back from where items originate.*/
|
||||||
final static float backTrns = 3f;
|
final static float backTrns = 3f;
|
||||||
|
|
||||||
public final Player player;
|
|
||||||
public final OverlayFragment frag = new OverlayFragment(this);
|
public final OverlayFragment frag = new OverlayFragment(this);
|
||||||
|
|
||||||
public Block block;
|
public Block block;
|
||||||
@@ -54,10 +53,6 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
protected PlaceDraw placeDraw = new PlaceDraw();
|
protected PlaceDraw placeDraw = new PlaceDraw();
|
||||||
private PlaceLine line = new PlaceLine();
|
private PlaceLine line = new PlaceLine();
|
||||||
|
|
||||||
public InputHandler(Player player){
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
//methods to override
|
//methods to override
|
||||||
|
|
||||||
@Remote(targets = Loc.client, called = Loc.server)
|
@Remote(targets = Loc.client, called = Loc.server)
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import io.anuke.mindustry.core.GameState.State;
|
|||||||
import io.anuke.mindustry.entities.Effects;
|
import io.anuke.mindustry.entities.Effects;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
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.TileEntity;
|
||||||
import io.anuke.mindustry.entities.type.Unit;
|
import io.anuke.mindustry.entities.type.Unit;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
@@ -81,8 +80,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
private int prevX, prevY, prevRotation;
|
private int prevX, prevY, prevRotation;
|
||||||
|
|
||||||
public MobileInput(Player player){
|
public MobileInput(){
|
||||||
super(player);
|
|
||||||
Core.input.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
|
Core.input.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ public class NetworkIO{
|
|||||||
|
|
||||||
public static void loadWorld(InputStream is){
|
public static void loadWorld(InputStream is){
|
||||||
|
|
||||||
Player player = players[0];
|
|
||||||
|
|
||||||
try(DataInputStream stream = new DataInputStream(is)){
|
try(DataInputStream stream = new DataInputStream(is)){
|
||||||
Time.clear();
|
Time.clear();
|
||||||
|
|
||||||
@@ -127,7 +125,7 @@ public class NetworkIO{
|
|||||||
state.teams.get(team).cores.add(world.tile(stream.readInt()));
|
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());
|
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(){
|
public static ByteBuffer writeServerData(){
|
||||||
int maxlen = 32;
|
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();
|
String map = world.getMap() == null ? "None" : world.getMap().name();
|
||||||
|
|
||||||
host = host.substring(0, Math.min(host.length(), maxlen));
|
host = host.substring(0, Math.min(host.length(), maxlen));
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class Weapon{
|
|||||||
if(player == null) return;
|
if(player == null) return;
|
||||||
//clients do not see their own shoot events: they are simulated completely clientside to prevent laggy visuals
|
//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!)
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ public class AboutDialog extends FloatingDialog{
|
|||||||
public AboutDialog(){
|
public AboutDialog(){
|
||||||
super("$about.button");
|
super("$about.button");
|
||||||
|
|
||||||
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
|
if(!ios){
|
||||||
|
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
shown(this::setup);
|
shown(this::setup);
|
||||||
onResize(this::setup);
|
onResize(this::setup);
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import io.anuke.arc.scene.ui.Dialog;
|
|||||||
import io.anuke.arc.scene.ui.ImageButton;
|
import io.anuke.arc.scene.ui.ImageButton;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
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.playerColors;
|
||||||
import static io.anuke.mindustry.Vars.players;
|
|
||||||
|
|
||||||
public class ColorPickDialog extends Dialog{
|
public class ColorPickDialog extends Dialog{
|
||||||
private Consumer<Color> cons;
|
private Consumer<Color> cons;
|
||||||
@@ -29,7 +29,7 @@ public class ColorPickDialog extends Dialog{
|
|||||||
cons.accept(color);
|
cons.accept(color);
|
||||||
hide();
|
hide();
|
||||||
}).size(48).get();
|
}).size(48).get();
|
||||||
button.setChecked(players[0].color.equals(color));
|
button.setChecked(player.color.equals(color));
|
||||||
button.getStyle().imageUpColor = color;
|
button.getStyle().imageUpColor = color;
|
||||||
|
|
||||||
if(i % 4 == 3){
|
if(i % 4 == 3){
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
public class CustomGameDialog extends FloatingDialog{
|
public class CustomGameDialog extends FloatingDialog{
|
||||||
Difficulty difficulty = Difficulty.normal;
|
Difficulty difficulty = Difficulty.normal;
|
||||||
RulePreset lastPreset = RulePreset.survival;
|
RulePreset lastPreset = RulePreset.survival;
|
||||||
|
CustomRulesDialog dialog = new CustomRulesDialog();
|
||||||
|
|
||||||
public CustomGameDialog(){
|
public CustomGameDialog(){
|
||||||
super("$customgame");
|
super("$customgame");
|
||||||
@@ -31,7 +32,9 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
state.rules = lastPreset.get();
|
if(lastPreset == null){
|
||||||
|
lastPreset = RulePreset.survival;
|
||||||
|
}
|
||||||
cont.clear();
|
cont.clear();
|
||||||
|
|
||||||
Table maps = new Table();
|
Table maps = new Table();
|
||||||
@@ -51,12 +54,16 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
|
|
||||||
for(RulePreset mode : RulePreset.values()){
|
for(RulePreset mode : RulePreset.values()){
|
||||||
modes.addButton(mode.toString(), "toggle", () -> {
|
modes.addButton(mode.toString(), "toggle", () -> {
|
||||||
state.rules = mode.get();
|
|
||||||
lastPreset = mode;
|
lastPreset = mode;
|
||||||
}).update(b -> b.setChecked(lastPreset == mode)).group(group).size(140f, 54f);
|
}).update(b -> b.setChecked(lastPreset == mode)).group(group).size(140f, 54f);
|
||||||
if(i++ % 2 == 1) modes.row();
|
if(i++ % 2 == 1) modes.row();
|
||||||
}
|
}
|
||||||
selmode.add(modes);
|
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);
|
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
|
||||||
|
|
||||||
cont.add(selmode);
|
cont.add(selmode);
|
||||||
@@ -86,7 +93,7 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
state.wavetime = difficulty.waveTime;
|
state.wavetime = difficulty.waveTime;
|
||||||
}).width(s);
|
}).width(s);
|
||||||
|
|
||||||
cont.add(sdif);
|
cont.add(sdif).visible(() -> lastPreset != null);
|
||||||
cont.row();
|
cont.row();
|
||||||
|
|
||||||
float images = 146f;
|
float images = 146f;
|
||||||
@@ -114,7 +121,7 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
|
|
||||||
image.clicked(() -> {
|
image.clicked(() -> {
|
||||||
hide();
|
hide();
|
||||||
control.playMap(map, lastPreset.get());
|
control.playMap(map, lastPreset == null ? dialog.rules : lastPreset.get());
|
||||||
});
|
});
|
||||||
|
|
||||||
maps.add(image);
|
maps.add(image);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,12 +6,11 @@ import io.anuke.arc.scene.ui.ImageButton;
|
|||||||
import io.anuke.arc.util.Strings;
|
import io.anuke.arc.util.Strings;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
|
|
||||||
import java.io.IOException;
|
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;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
|
|
||||||
public class HostDialog extends FloatingDialog{
|
public class HostDialog extends FloatingDialog{
|
||||||
@@ -20,8 +19,6 @@ public class HostDialog extends FloatingDialog{
|
|||||||
public HostDialog(){
|
public HostDialog(){
|
||||||
super("$hostserver");
|
super("$hostserver");
|
||||||
|
|
||||||
Player player = players[0];
|
|
||||||
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
cont.table(t -> {
|
cont.table(t -> {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import io.anuke.arc.util.Strings;
|
|||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
|
||||||
import io.anuke.mindustry.game.Version;
|
import io.anuke.mindustry.game.Version;
|
||||||
import io.anuke.mindustry.net.Host;
|
import io.anuke.mindustry.net.Host;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
@@ -185,8 +184,6 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
void setup(){
|
void setup(){
|
||||||
float w = targetWidth();
|
float w = targetWidth();
|
||||||
|
|
||||||
Player player = players[0];
|
|
||||||
|
|
||||||
hosts.clear();
|
hosts.clear();
|
||||||
|
|
||||||
hosts.add(remote).growX();
|
hosts.add(remote).growX();
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,7 @@ import io.anuke.arc.scene.ui.layout.Table;
|
|||||||
import io.anuke.arc.util.Align;
|
import io.anuke.arc.util.Align;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.core.Platform;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
|
|
||||||
@@ -194,6 +195,18 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||||||
if(Core.settings.getBool("fullscreen")){
|
if(Core.settings.getBool("fullscreen")){
|
||||||
Core.graphics.setFullscreenMode(Core.graphics.getDisplayMode());
|
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);
|
graphics.checkPref("fps", false);
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ import io.anuke.mindustry.input.InputHandler;
|
|||||||
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 static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
|
||||||
|
|
||||||
public class BlockConfigFragment extends Fragment{
|
public class BlockConfigFragment extends Fragment{
|
||||||
private Table table = new Table();
|
private Table table = new Table();
|
||||||
@@ -59,7 +58,7 @@ public class BlockConfigFragment extends Fragment{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(configTile != null && configTile.block().shouldHideConfigure(configTile, input.player)){
|
if(configTile != null && configTile.block().shouldHideConfigure(configTile, player)){
|
||||||
hideConfig();
|
hideConfig();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
|
|
||||||
private void rebuild(boolean actions){
|
private void rebuild(boolean actions){
|
||||||
|
|
||||||
Player player = input.player;
|
|
||||||
|
|
||||||
IntSet container = new IntSet();
|
IntSet container = new IntSet();
|
||||||
|
|
||||||
table.clearChildren();
|
table.clearChildren();
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class ChatFragment extends Table{
|
|||||||
fieldlabel.setStyle(fieldlabel.getStyle());
|
fieldlabel.setStyle(fieldlabel.getStyle());
|
||||||
|
|
||||||
chatfield = new TextField("", new TextField.TextFieldStyle(scene.skin.get(TextField.TextFieldStyle.class)));
|
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().background = null;
|
||||||
chatfield.getStyle().font = scene.skin.getFont("default-font-chat");
|
chatfield.getStyle().font = scene.skin.getFont("default-font-chat");
|
||||||
chatfield.getStyle().fontColor = Color.WHITE;
|
chatfield.getStyle().fontColor = Color.WHITE;
|
||||||
@@ -207,7 +207,7 @@ public class ChatFragment extends Table{
|
|||||||
|
|
||||||
history.insert(1, message);
|
history.insert(1, message);
|
||||||
|
|
||||||
Call.sendMessage(players[0], message);
|
Call.sendMessage(player, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggle(){
|
public void toggle(){
|
||||||
|
|||||||
@@ -184,9 +184,9 @@ public class HudFragment extends Fragment{
|
|||||||
t.table("flat", c -> c.add("")
|
t.table("flat", c -> c.add("")
|
||||||
.update(l ->{
|
.update(l ->{
|
||||||
l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f)));
|
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 -> {
|
}).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;
|
}).get().color.a = 0f;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -207,13 +207,13 @@ public class HudFragment extends Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
t.top().visible(() -> {
|
t.top().visible(() -> {
|
||||||
if(state.is(State.menu) || state.teams.get(players[0].getTeam()).cores.size == 0 ||
|
if(state.is(State.menu) || state.teams.get(player.getTeam()).cores.size == 0 ||
|
||||||
state.teams.get(players[0].getTeam()).cores.first().entity == null){
|
state.teams.get(player.getTeam()).cores.first().entity == null){
|
||||||
coreAttackTime = 0f;
|
coreAttackTime = 0f;
|
||||||
return false;
|
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){
|
if(!Float.isNaN(lastCoreHP) && curr < lastCoreHP){
|
||||||
coreAttackTime = notifDuration;
|
coreAttackTime = notifDuration;
|
||||||
}
|
}
|
||||||
@@ -470,13 +470,13 @@ public class HudFragment extends Fragment{
|
|||||||
|
|
||||||
private void addPlayButton(Table table){
|
private void addPlayButton(Table table){
|
||||||
table.right().addImageButton("icon-play", "right", 30f, () -> {
|
table.right().addImageButton("icon-play", "right", 30f, () -> {
|
||||||
if(Net.client() && players[0].isAdmin){
|
if(Net.client() && player.isAdmin){
|
||||||
Call.onAdminRequest(players[0], AdminAction.wave);
|
Call.onAdminRequest(player, AdminAction.wave);
|
||||||
}else{
|
}else{
|
||||||
state.wavetime = 0f;
|
state.wavetime = 0f;
|
||||||
}
|
}
|
||||||
}).growY().fillX().right().width(40f)
|
}).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));
|
&& (!world.spawner.isSpawning() || !state.rules.waveTimer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
|
|
||||||
public PlacementFragment(){
|
public PlacementFragment(){
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
Events.on(WorldLoadEvent.class, event -> {
|
||||||
control.input(0).block = null;
|
control.input().block = null;
|
||||||
rebuild();
|
rebuild();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
full.bottom().right().visible(() -> !state.is(State.menu) && ui.hudfrag.shown());
|
full.bottom().right().visible(() -> !state.is(State.menu) && ui.hudfrag.shown());
|
||||||
|
|
||||||
full.table(frame -> {
|
full.table(frame -> {
|
||||||
InputHandler input = control.input(0);
|
InputHandler input = control.input();
|
||||||
|
|
||||||
//rebuilds the category table with the correct recipes
|
//rebuilds the category table with the correct recipes
|
||||||
Runnable rebuildCategory = () -> {
|
Runnable rebuildCategory = () -> {
|
||||||
@@ -154,7 +154,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
button.getStyle().imageUp = new TextureRegionDrawable(block.icon(Icon.medium));
|
button.getStyle().imageUp = new TextureRegionDrawable(block.icon(Icon.medium));
|
||||||
|
|
||||||
button.update(() -> { //color unplacable things gray
|
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;
|
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : Color.GRAY;
|
||||||
button.forEach(elem -> elem.setColor(color));
|
button.forEach(elem -> elem.setColor(color));
|
||||||
button.setChecked(input.block == block);
|
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.addImage(stack.item.icon(Item.Icon.small)).size(8 * 2);
|
||||||
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
|
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
|
||||||
line.labelWrap(() -> {
|
line.labelWrap(() -> {
|
||||||
TileEntity core = players[0].getClosestCore();
|
TileEntity core = player.getClosestCore();
|
||||||
if(core == null || state.rules.infiniteResources) return "*/*";
|
if(core == null || state.rules.infiniteResources) return "*/*";
|
||||||
|
|
||||||
int amount = core.items.get(stack.item);
|
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.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
|
||||||
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
|
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
|
||||||
}).growX().left();
|
}).growX().left();
|
||||||
if(hoverTile.getTeam() == players[0].getTeam()){
|
if(hoverTile.getTeam() == player.getTeam()){
|
||||||
topTable.row();
|
topTable.row();
|
||||||
topTable.table(t -> {
|
topTable.table(t -> {
|
||||||
t.left().defaults().left();
|
t.left().defaults().left();
|
||||||
@@ -326,8 +326,8 @@ public class PlacementFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//block currently selected
|
//block currently selected
|
||||||
if(control.input(0).block != null){
|
if(control.input().block != null){
|
||||||
toDisplay = control.input(0).block;
|
toDisplay = control.input().block;
|
||||||
}
|
}
|
||||||
|
|
||||||
//block hovered on in build menu
|
//block hovered on in build menu
|
||||||
|
|||||||
@@ -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();
|
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();
|
button.add().growY();
|
||||||
|
|
||||||
float bs = (h) / 2f;
|
float bs = (h) / 2f;
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ public class Block extends BlockStorage{
|
|||||||
|
|
||||||
/**Call when some content is produced. This unlocks the content if it is applicable.*/
|
/**Call when some content is produced. This unlocks the content if it is applicable.*/
|
||||||
public void useContent(Tile tile, UnlockableContent content){
|
public void useContent(Tile tile, UnlockableContent content){
|
||||||
if(!headless && tile.getTeam() == players[0].getTeam()){
|
if(!headless && tile.getTeam() == player.getTeam()){
|
||||||
logic.handleContent(content);
|
logic.handleContent(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class BuildBlock extends Block{
|
|||||||
Core.app.post(() -> tile.block().placed(tile));
|
Core.app.post(() -> tile.block().placed(tile));
|
||||||
|
|
||||||
//last builder was this local client player, call placed()
|
//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()
|
//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
|
//event first before they can recieve the placed() event modification results
|
||||||
Core.app.post(() -> tile.block().playerPlaced(tile));
|
Core.app.post(() -> tile.block().playerPlaced(tile));
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import io.anuke.mindustry.type.Item.Icon;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
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();
|
Array<Item> items = content.items();
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ public interface SelectionTrait{
|
|||||||
for(Item item : items){
|
for(Item item : items){
|
||||||
if(!data.isUnlocked(item) && world.isZone()) continue;
|
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.changed(() -> consumer.accept(button.isChecked() ? item : null));
|
||||||
button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Icon.medium));
|
button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Icon.medium));
|
||||||
button.update(() -> button.setChecked(holder.get() == item));
|
button.update(() -> button.setChecked(holder.get() == item));
|
||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.gen.Call;
|
|||||||
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;
|
||||||
import io.anuke.mindustry.world.blocks.SelectionTrait;
|
import io.anuke.mindustry.world.blocks.ItemSelection;
|
||||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
@@ -21,7 +21,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class Sorter extends Block implements SelectionTrait{
|
public class Sorter extends Block{
|
||||||
private static Item lastItem;
|
private static Item lastItem;
|
||||||
|
|
||||||
public Sorter(String name){
|
public Sorter(String name){
|
||||||
@@ -119,7 +119,7 @@ public class Sorter extends Block implements SelectionTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void buildTable(Tile tile, Table table){
|
public void buildTable(Tile tile, Table table){
|
||||||
SorterEntity entity = tile.entity();
|
SorterEntity entity = tile.entity();
|
||||||
buildItemTable(table, () -> entity.sortItem, item -> {
|
ItemSelection.buildItemTable(table, () -> entity.sortItem, item -> {
|
||||||
lastItem = item;
|
lastItem = item;
|
||||||
Call.setSorterItem(null, tile, item);
|
Call.setSorterItem(null, tile, item);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class LiquidSource extends Block{
|
|||||||
final int f = i;
|
final int f = i;
|
||||||
ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> {
|
ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> {
|
||||||
Call.setLiquidSourceLiquid(null, tile, items.get(f));
|
Call.setLiquidSourceLiquid(null, tile, items.get(f));
|
||||||
control.input(0).frag.config.hideConfig();
|
control.input().frag.config.hideConfig();
|
||||||
}).size(38).group(group).get();
|
}).size(38).group(group).get();
|
||||||
button.getStyle().imageUp = new TextureRegionDrawable(items.get(i).iconRegion);
|
button.getStyle().imageUp = new TextureRegionDrawable(items.get(i).iconRegion);
|
||||||
button.setChecked(entity.source.id == f);
|
button.setChecked(entity.source.id == f);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.gen.Call;
|
|||||||
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;
|
||||||
import io.anuke.mindustry.world.blocks.SelectionTrait;
|
import io.anuke.mindustry.world.blocks.ItemSelection;
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -20,7 +20,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
|
||||||
public class Unloader extends Block implements SelectionTrait{
|
public class Unloader extends Block{
|
||||||
protected float speed = 1f;
|
protected float speed = 1f;
|
||||||
protected final int timerUnload = timers++;
|
protected final int timerUnload = timers++;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class Unloader extends Block implements SelectionTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void buildTable(Tile tile, Table table){
|
public void buildTable(Tile tile, Table table){
|
||||||
SortedUnloaderEntity entity = tile.entity();
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
buildItemTable(table, () -> entity.sortItem, item -> {
|
ItemSelection.buildItemTable(table, () -> entity.sortItem, item -> {
|
||||||
lastItem = item;
|
lastItem = item;
|
||||||
Call.setSortedUnloaderItem(null, tile, item);
|
Call.setSortedUnloaderItem(null, tile, item);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ public class DesktopPlatform extends Platform{
|
|||||||
presence.largeImageText = "Wave " + state.wave;
|
presence.largeImageText = "Wave " + state.wave;
|
||||||
}
|
}
|
||||||
|
|
||||||
presence.state = unitGroups[players[0].getTeam().ordinal()].size() == 1 ? "1 Unit Active" :
|
presence.state = unitGroups[player.getTeam().ordinal()].size() == 1 ? "1 Unit Active" :
|
||||||
(unitGroups[players[0].getTeam().ordinal()].size() + " Units Active");
|
(unitGroups[player.getTeam().ordinal()].size() + " Units Active");
|
||||||
|
|
||||||
if(Net.active()){
|
if(Net.active()){
|
||||||
presence.partyMax = 100;
|
presence.partyMax = 100;
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ sourceSets.main.java.srcDirs = [ "src/" ]
|
|||||||
project.ext.mainClassName = "io.anuke.mindustry.server.ServerLauncher"
|
project.ext.mainClassName = "io.anuke.mindustry.server.ServerLauncher"
|
||||||
project.ext.assetsDir = new File("../core/assets")
|
project.ext.assetsDir = new File("../core/assets")
|
||||||
|
|
||||||
|
ext.getServerFolder = {
|
||||||
|
return "../deploy/${appName}-server-${getVersionString()}"
|
||||||
|
}
|
||||||
|
|
||||||
task run(dependsOn: classes, type: JavaExec) {
|
task run(dependsOn: classes, type: JavaExec) {
|
||||||
main = project.mainClassName
|
main = project.mainClassName
|
||||||
classpath = sourceSets.main.runtimeClasspath
|
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"
|
dependsOn "dist"
|
||||||
|
|
||||||
from "build/libs/server-release.jar"
|
finalizedBy 'dzip'
|
||||||
into "../deploy/"
|
|
||||||
rename ("server-release.jar", appName + "-server-" + getVersionString() + ".jar")
|
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
|
dist.dependsOn classes
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
java -jar server.jar
|
||||||