diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index 1a9b86b774..56d9e94a47 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -9,9 +9,12 @@ import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import android.annotation.SuppressLint; import android.os.Bundle; +import android.util.DisplayMetrics; import io.anuke.mindustry.io.Formatter; +import io.anuke.ucore.scene.ui.layout.Unit; public class AndroidLauncher extends AndroidApplication { + @SuppressLint("SimpleDateFormat") @Override protected void onCreate (Bundle savedInstanceState) { @@ -34,6 +37,22 @@ public class AndroidLauncher extends AndroidApplication { } }; + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + + float yInches= metrics.heightPixels/metrics.ydpi; + float xInches= metrics.widthPixels/metrics.xdpi; + double diagonalInches = Math.sqrt(xInches*xInches + yInches*yInches); + if (diagonalInches>=6.5){ + // 6.5inch device or bigger + Unit.dp.multiplier = 2f; + }else{ + // smaller device + Unit.dp.multiplier = 1f; + } + + Mindustry.args.add("-debug"); + initialize(new Mindustry(), config); } } diff --git a/build.gradle b/build.gradle index 4a747dafd5..d4fa2d5114 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,8 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.Anuken:ucore:7752d632e1' + compile 'com.github.Anuken:ucore:d43f3b48ec' + //compile fileTree(dir: '../core/lib', include: '*.jar') compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets-raw/sprites/ui/border.9.png b/core/assets-raw/sprites/ui/border.9.png index c59f82205b..7987b86920 100644 Binary files a/core/assets-raw/sprites/ui/border.9.png and b/core/assets-raw/sprites/ui/border.9.png differ diff --git a/core/assets-raw/sprites/ui/scroll-knob-horizontal.9.png b/core/assets-raw/sprites/ui/scroll-knob-horizontal.9.png index 2b898da798..87f546a539 100644 Binary files a/core/assets-raw/sprites/ui/scroll-knob-horizontal.9.png and b/core/assets-raw/sprites/ui/scroll-knob-horizontal.9.png differ diff --git a/core/assets-raw/sprites/ui/scroll-knob-vertical.9.png b/core/assets-raw/sprites/ui/scroll-knob-vertical.9.png index 36f994e9c9..c5ac231c50 100644 Binary files a/core/assets-raw/sprites/ui/scroll-knob-vertical.9.png and b/core/assets-raw/sprites/ui/scroll-knob-vertical.9.png differ diff --git a/core/assets-raw/sprites/ui/scroll.9.png b/core/assets-raw/sprites/ui/scroll.9.png index efbaeea0e3..e83e20b63b 100644 Binary files a/core/assets-raw/sprites/ui/scroll.9.png and b/core/assets-raw/sprites/ui/scroll.9.png differ diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index adb28767e7..cb64244d5c 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -13,28 +13,28 @@ backgrounds/background index: -1 blank rotate: false - xy: 308, 147 + xy: 232, 1 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 blocks/blackrock1 rotate: false - xy: 415, 313 + xy: 450, 480 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackrockshadow1 rotate: false - xy: 450, 480 + xy: 348, 231 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstone1 rotate: false - xy: 348, 231 + xy: 348, 221 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -48,42 +48,42 @@ blocks/blackstone2 index: -1 blocks/blackstone3 rotate: false - xy: 348, 221 + xy: 312, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock1 rotate: false - xy: 374, 222 + xy: 439, 377 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock2 rotate: false - xy: 374, 212 + xy: 439, 367 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock3 rotate: false - xy: 325, 197 + xy: 449, 379 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneedge rotate: false - xy: 206, 1 + xy: 234, 60 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/block rotate: false - xy: 337, 211 + xy: 439, 357 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -97,7 +97,7 @@ blocks/block-2x2 index: -1 blocks/block-3x3 rotate: false - xy: 385, 267 + xy: 263, 150 size: 24, 24 orig: 24, 24 offset: 0, 0 @@ -111,952 +111,952 @@ blocks/chainturret index: -1 blocks/chainturret-icon rotate: false - xy: 230, 67 + xy: 411, 244 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/coal1 rotate: false - xy: 327, 168 + xy: 437, 347 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal2 rotate: false - xy: 327, 158 + xy: 437, 337 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal3 rotate: false - xy: 327, 148 + xy: 437, 327 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coaldrill rotate: false - xy: 431, 311 + xy: 437, 317 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator rotate: false - xy: 431, 301 + xy: 426, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalpurifier rotate: false - xy: 441, 309 + xy: 459, 379 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/combustiongenerator rotate: false - xy: 451, 309 + xy: 459, 369 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/compositewall rotate: false - xy: 461, 309 + xy: 459, 359 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduit rotate: false - xy: 471, 309 + xy: 436, 220 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitbottom rotate: false - xy: 481, 309 + xy: 480, 431 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitliquid rotate: false - xy: 441, 299 + xy: 468, 422 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduittop rotate: false - xy: 451, 299 + xy: 478, 421 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyor rotate: false - xy: 461, 299 + xy: 464, 412 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyormove rotate: false - xy: 471, 299 + xy: 464, 402 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/core rotate: false - xy: 233, 150 + xy: 413, 361 size: 24, 24 orig: 24, 24 offset: 0, 0 index: -1 blocks/cross rotate: false - xy: 481, 299 + xy: 464, 392 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/crucible rotate: false - xy: 431, 291 + xy: 474, 411 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/deepwater rotate: false - xy: 441, 289 + xy: 474, 401 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt1 rotate: false - xy: 451, 289 + xy: 474, 391 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt2 rotate: false - xy: 461, 289 + xy: 494, 435 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt3 rotate: false - xy: 471, 289 + xy: 327, 145 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirtblock rotate: false - xy: 481, 289 + xy: 443, 234 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirtedge rotate: false - xy: 220, 1 + xy: 423, 242 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/doubleturret rotate: false - xy: 308, 132 + xy: 470, 453 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/duriumwall rotate: false - xy: 427, 281 + xy: 484, 411 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/duriumwall-large rotate: false - xy: 247, 116 + xy: 419, 272 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 blocks/duriumwall-large-icon rotate: false - xy: 427, 271 + xy: 484, 401 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/flameturret rotate: false - xy: 320, 132 + xy: 456, 425 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/fluxpump rotate: false - xy: 437, 279 + xy: 488, 421 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass1 rotate: false - xy: 447, 279 + xy: 494, 411 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass2 rotate: false - xy: 437, 269 + xy: 494, 401 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass3 rotate: false - xy: 457, 279 + xy: 494, 391 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock-edge-0 rotate: false - xy: 457, 269 + xy: 324, 113 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock-edge-1 rotate: false - xy: 477, 279 + xy: 324, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock-edge-2 rotate: false - xy: 467, 269 + xy: 324, 93 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock-edge-3 rotate: false - xy: 477, 269 + xy: 324, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock1 rotate: false - xy: 447, 269 + xy: 324, 133 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock2 rotate: false - xy: 467, 279 + xy: 324, 123 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassedge rotate: false - xy: 411, 247 + xy: 384, 214 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/iron1 rotate: false - xy: 355, 186 + xy: 489, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 355, 176 + xy: 479, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 487, 279 + xy: 489, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 487, 269 + xy: 489, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 264, 46 + xy: 499, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 262, 36 + xy: 499, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/laserturret rotate: false - xy: 459, 331 + xy: 437, 244 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/lava rotate: false - xy: 472, 439 + xy: 499, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/lavaedge rotate: false - xy: 417, 233 + xy: 398, 214 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/lavasmelter rotate: false - xy: 472, 429 + xy: 446, 224 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquiditemjunction rotate: false - xy: 472, 419 + xy: 446, 214 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidjunction rotate: false - xy: 490, 459 + xy: 436, 210 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidrouter rotate: false - xy: 500, 459 + xy: 432, 200 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/machineturret rotate: false - xy: 457, 319 + xy: 431, 230 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/megarepairturret rotate: false - xy: 473, 355 + xy: 384, 202 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mortarturret rotate: false - xy: 473, 343 + xy: 396, 202 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mossblock rotate: false - xy: 485, 449 + xy: 349, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 485, 449 + xy: 349, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/nuclearreactor rotate: false - xy: 259, 150 + xy: 411, 335 size: 24, 24 orig: 24, 24 offset: 0, 0 index: -1 blocks/nuclearreactor-icon rotate: false - xy: 495, 449 + xy: 349, 185 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/nuclearreactor-small rotate: false - xy: 265, 118 + xy: 228, 128 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 blocks/oil rotate: false - xy: 482, 429 + xy: 349, 175 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/oiledge rotate: false - xy: 417, 219 + xy: 412, 214 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/oilrefinery rotate: false - xy: 492, 439 + xy: 359, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 482, 419 + xy: 359, 198 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/plasmaturret rotate: false - xy: 471, 331 + xy: 408, 202 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/powerbooster rotate: false - xy: 492, 429 + xy: 359, 188 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyor rotate: false - xy: 492, 419 + xy: 359, 178 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyormove rotate: false - xy: 480, 409 + xy: 369, 198 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaser rotate: false - xy: 480, 399 + xy: 369, 188 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaserrouter rotate: false - xy: 490, 409 + xy: 369, 178 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduit rotate: false - xy: 480, 389 + xy: 379, 192 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduitbottom rotate: false - xy: 480, 379 + xy: 379, 182 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduittop rotate: false - xy: 490, 399 + xy: 389, 192 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 490, 389 + xy: 389, 182 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/repairturret rotate: false - xy: 469, 319 + xy: 420, 202 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/rock1 rotate: false - xy: 489, 369 + xy: 399, 182 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 367, 202 + xy: 409, 192 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow1 rotate: false - xy: 377, 202 + xy: 409, 182 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow2 rotate: false - xy: 387, 203 + xy: 419, 192 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 397, 203 + xy: 419, 182 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator rotate: false - xy: 367, 192 + xy: 429, 190 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shadow rotate: false - xy: 477, 367 + xy: 315, 143 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shieldgenerator rotate: false - xy: 387, 193 + xy: 379, 172 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shotgunturret rotate: false - xy: 485, 355 + xy: 312, 131 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shrub rotate: false - xy: 375, 182 + xy: 409, 172 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 365, 172 + xy: 419, 172 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 375, 172 + xy: 429, 170 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sniperturret rotate: false - xy: 485, 343 + xy: 312, 119 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/sorter rotate: false - xy: 502, 439 + xy: 439, 190 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyor rotate: false - xy: 502, 429 + xy: 439, 180 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 502, 419 + xy: 439, 170 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 500, 409 + xy: 359, 168 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall-large rotate: false - xy: 290, 132 + xy: 228, 110 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 blocks/steelwall-large-icon rotate: false - xy: 500, 399 + xy: 369, 168 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone rotate: false - xy: 431, 233 + xy: 474, 465 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/stone1 rotate: false - xy: 500, 389 + xy: 349, 165 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 500, 379 + xy: 331, 155 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 499, 369 + xy: 379, 162 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock-edge-0 rotate: false - xy: 495, 329 + xy: 419, 162 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock-edge-1 rotate: false - xy: 493, 319 + xy: 429, 160 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock-edge-2 rotate: false - xy: 503, 319 + xy: 439, 160 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock-edge-3 rotate: false - xy: 491, 309 + xy: 337, 145 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock-smooth1 rotate: false - xy: 491, 299 + xy: 334, 135 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock1 rotate: false - xy: 497, 359 + xy: 389, 162 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 497, 349 + xy: 399, 162 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 497, 339 + xy: 409, 162 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 491, 289 + xy: 334, 125 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneedge rotate: false - xy: 431, 219 + xy: 456, 451 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/stoneformer rotate: false - xy: 501, 309 + xy: 334, 115 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonewall rotate: false - xy: 501, 299 + xy: 334, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter rotate: false - xy: 501, 289 + xy: 334, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter-top rotate: false - xy: 497, 279 + xy: 334, 85 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/thermalgenerator rotate: false - xy: 497, 269 + xy: 341, 155 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titancannon rotate: false - xy: 285, 150 + xy: 411, 309 size: 24, 24 orig: 24, 24 offset: 0, 0 index: -1 blocks/titancannon-icon rotate: false - xy: 483, 331 + xy: 312, 107 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 265, 108 + xy: 351, 155 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 264, 98 + xy: 347, 145 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 264, 88 + xy: 344, 135 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 274, 46 + xy: 344, 125 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumpurifier rotate: false - xy: 272, 36 + xy: 344, 115 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumshieldwall rotate: false - xy: 270, 26 + xy: 344, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 439, 259 + xy: 344, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall-large rotate: false - xy: 230, 79 + xy: 230, 74 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 blocks/titaniumwall-large-icon rotate: false - xy: 449, 259 + xy: 344, 85 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/turret rotate: false - xy: 481, 319 + xy: 312, 95 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/uranium1 rotate: false - xy: 449, 249 + xy: 354, 135 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium2 rotate: false - xy: 469, 259 + xy: 354, 125 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium3 rotate: false - xy: 459, 249 + xy: 354, 115 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uraniumdrill rotate: false - xy: 479, 259 + xy: 354, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/water rotate: false - xy: 469, 249 + xy: 354, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/wateredge rotate: false - xy: 250, 53 + xy: 456, 437 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/waveturret rotate: false - xy: 325, 207 + xy: 312, 83 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 bullet rotate: false - xy: 347, 211 + xy: 449, 359 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 chainbullet rotate: false - xy: 325, 178 + xy: 470, 432 size: 8, 7 orig: 8, 7 offset: 0, 0 index: -1 circle rotate: false - xy: 228, 115 + xy: 419, 290 size: 17, 17 orig: 17, 17 offset: 0, 0 @@ -1070,112 +1070,112 @@ circle2 index: -1 enemies/blastenemy-t1 rotate: false - xy: 248, 100 + xy: 248, 94 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/blastenemy-t2 rotate: false - xy: 248, 84 + xy: 248, 78 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/blastenemy-t3 rotate: false - xy: 385, 225 + xy: 385, 228 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/empenemy-t1 rotate: false - xy: 401, 225 + xy: 264, 134 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/empenemy-t2 rotate: false - xy: 413, 353 + xy: 264, 118 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/empenemy-t3 rotate: false - xy: 429, 353 + xy: 280, 134 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/enemy-t1 rotate: false - xy: 411, 337 + xy: 264, 102 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/targetenemy-t1 rotate: false - xy: 411, 337 + xy: 264, 102 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/enemy-t2 rotate: false - xy: 411, 323 + xy: 417, 228 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 enemies/enemy-t3 rotate: false - xy: 476, 465 + xy: 358, 218 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 enemies/fastenemy-t1 rotate: false - xy: 427, 337 + xy: 280, 118 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/fastenemy-t2 rotate: false - xy: 425, 321 + xy: 296, 134 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/fastenemy-t3 rotate: false - xy: 234, 51 + xy: 264, 86 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/flamerenemy-t1 rotate: false - xy: 234, 35 + xy: 280, 102 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/flamerenemy-t2 rotate: false - xy: 283, 116 + xy: 296, 118 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/flamerenemy-t3 rotate: false - xy: 299, 116 + xy: 280, 86 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -1203,168 +1203,168 @@ enemies/fortressenemy-t3 index: -1 enemies/healerenemy-t1 rotate: false - xy: 415, 297 + xy: 296, 102 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/healerenemy-t2 rotate: false - xy: 311, 160 + xy: 296, 86 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/healerenemy-t3 rotate: false - xy: 311, 144 + xy: 317, 203 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/mortarenemy-t1 rotate: false - xy: 449, 367 + xy: 280, 70 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/mortarenemy-t2 rotate: false - xy: 445, 351 + xy: 296, 70 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/mortarenemy-t3 rotate: false - xy: 443, 335 + xy: 248, 62 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/rapidenemy-t1 rotate: false - xy: 441, 319 + xy: 234, 44 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/rapidenemy-t2 rotate: false - xy: 358, 216 + xy: 250, 46 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/rapidenemy-t3 rotate: false - xy: 230, 17 + xy: 234, 28 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/tankenemy-t1 rotate: false - xy: 234, 1 + xy: 250, 30 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/tankenemy-t2 rotate: false - xy: 411, 277 + xy: 411, 256 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/tankenemy-t3 rotate: false - xy: 411, 261 + xy: 427, 256 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 enemies/titanenemy-t1 rotate: false - xy: 413, 369 + xy: 246, 128 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 enemies/titanenemy-t2 rotate: false - xy: 431, 369 + xy: 246, 110 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 enemies/titanenemy-t3 rotate: false - xy: 230, 97 + xy: 230, 92 size: 16, 16 orig: 16, 16 offset: 0, 0 index: -1 enemyarrow rotate: false - xy: 337, 202 + xy: 312, 64 size: 8, 7 orig: 8, 7 offset: 0, 0 index: -1 icon-coal rotate: false - xy: 347, 201 + xy: 322, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-dirium rotate: false - xy: 357, 206 + xy: 322, 63 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-iron rotate: false - xy: 335, 192 + xy: 469, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-steel rotate: false - xy: 335, 182 + xy: 469, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-stone rotate: false - xy: 345, 191 + xy: 479, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-titanium rotate: false - xy: 345, 181 + xy: 469, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-uranium rotate: false - xy: 357, 196 + xy: 479, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 laser rotate: false - xy: 472, 449 + xy: 488, 465 size: 1, 12 orig: 1, 12 offset: 0, 0 @@ -1378,35 +1378,35 @@ laserend index: -1 mechs/player rotate: false - xy: 425, 247 + xy: 460, 465 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 shell rotate: false - xy: 377, 192 + xy: 429, 180 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot rotate: false - xy: 397, 193 + xy: 389, 172 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot-long rotate: false - xy: 365, 182 + xy: 399, 172 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 titanshell rotate: false - xy: 439, 249 + xy: 361, 158 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1415,7 +1415,7 @@ ui/border rotate: false xy: 204, 67 size: 24, 40 - split: 6, 6, 6, 10 + split: 5, 5, 5, 10 orig: 24, 40 offset: 0, 0 index: -1 @@ -1469,7 +1469,7 @@ ui/button-map-over index: -1 ui/button-select rotate: false - xy: 385, 241 + xy: 289, 150 size: 24, 24 split: 4, 4, 4, 4 orig: 24, 24 @@ -1498,42 +1498,42 @@ ui/check-over index: -1 ui/clear rotate: false - xy: 242, 67 + xy: 372, 220 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/cursor rotate: false - xy: 411, 241 + xy: 349, 215 size: 4, 4 orig: 4, 4 offset: 0, 0 index: -1 ui/icon-arrow-left rotate: false - xy: 250, 41 + xy: 452, 413 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-arrow-right rotate: false - xy: 250, 29 + xy: 470, 441 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-cancel rotate: false - xy: 254, 68 + xy: 317, 187 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-check rotate: false - xy: 315, 116 + xy: 333, 205 size: 14, 14 orig: 14, 14 offset: 0, 0 @@ -1561,133 +1561,133 @@ ui/icon-close-over index: -1 ui/icon-crafting rotate: false - xy: 246, 17 + xy: 452, 401 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-cursor rotate: false - xy: 250, 5 + xy: 452, 389 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-defense rotate: false - xy: 258, 17 + xy: 482, 453 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-distribution rotate: false - xy: 262, 5 + xy: 482, 441 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-info rotate: false - xy: 264, 56 + xy: 230, 16 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-load rotate: false - xy: 460, 463 + xy: 333, 189 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-menu rotate: false - xy: 384, 213 + xy: 232, 4 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-pause rotate: false - xy: 396, 213 + xy: 242, 16 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-play rotate: false - xy: 468, 403 + xy: 254, 18 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-play-2 rotate: false - xy: 456, 447 + xy: 317, 171 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-power rotate: false - xy: 468, 391 + xy: 244, 4 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-production rotate: false - xy: 468, 379 + xy: 372, 208 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-rotate rotate: false - xy: 456, 431 + xy: 333, 173 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-rotate-arrow rotate: false - xy: 456, 415 + xy: 315, 155 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-settings rotate: false - xy: 465, 367 + xy: 494, 457 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-tools rotate: false - xy: 452, 399 + xy: 401, 228 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-touch rotate: false - xy: 461, 355 + xy: 494, 445 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-tutorial rotate: false - xy: 452, 383 + xy: 264, 70 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 ui/icon-weapon rotate: false - xy: 461, 343 + xy: 256, 6 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1708,7 +1708,7 @@ ui/logotext-gray index: -1 ui/pane rotate: false - xy: 385, 323 + xy: 385, 281 size: 24, 36 split: 10, 10, 5, 5 orig: 24, 36 @@ -1724,10 +1724,10 @@ ui/pane-button index: -1 ui/scroll rotate: false - xy: 228, 134 - size: 34, 6 - split: 4, 4, 2, 2 - orig: 34, 6 + xy: 385, 244 + size: 24, 35 + split: 10, 10, 6, 5 + orig: 24, 35 offset: 0, 0 index: -1 ui/scroll-horizontal @@ -1741,7 +1741,7 @@ ui/scroll-horizontal index: -1 ui/scroll-knob-horizontal rotate: false - xy: 317, 183 + xy: 411, 273 size: 6, 34 split: 2, 2, 0, 34 pad: 0, 5, 13, 12 @@ -1750,29 +1750,29 @@ ui/scroll-knob-horizontal index: -1 ui/scroll-knob-vertical rotate: false - xy: 228, 142 - size: 34, 6 - split: 12, 12, 2, 2 - orig: 34, 6 + xy: 385, 319 + size: 24, 40 + split: 10, 10, 6, 10 + orig: 24, 40 offset: 0, 0 index: -1 ui/selection rotate: false - xy: 308, 144 + xy: 491, 466 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 ui/separator rotate: false - xy: 465, 380 + xy: 312, 147 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 ui/slider rotate: false - xy: 452, 415 + xy: 490, 431 size: 1, 8 orig: 1, 8 offset: 0, 0 @@ -1807,7 +1807,7 @@ ui/slider-vertical index: -1 ui/text-exit rotate: false - xy: 264, 136 + xy: 206, 1 size: 24, 12 orig: 24, 12 offset: 0, 0 @@ -1863,7 +1863,7 @@ ui/text-tutorial index: -1 ui/textfield rotate: false - xy: 385, 293 + xy: 233, 146 size: 28, 28 split: 6, 6, 6, 6 orig: 28, 28 @@ -1879,7 +1879,7 @@ ui/textfield-over index: -1 ui/white rotate: false - xy: 228, 150 + xy: 383, 399 size: 3, 3 orig: 3, 3 offset: 0, 0 @@ -1902,42 +1902,42 @@ ui/window-empty index: -1 weapons/blaster rotate: false - xy: 325, 187 + xy: 449, 369 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/flamer rotate: false - xy: 427, 261 + xy: 484, 391 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/mortar rotate: false - xy: 475, 449 + xy: 446, 204 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/multigun rotate: false - xy: 482, 439 + xy: 349, 195 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/railgun rotate: false - xy: 490, 379 + xy: 399, 192 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/triblaster rotate: false - xy: 459, 259 + xy: 357, 145 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 4c9e7658ba..285a94889c 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/assets/ui/uiskin.json b/core/assets/ui/uiskin.json index 7ced1acdee..76dd8d588f 100644 --- a/core/assets/ui/uiskin.json +++ b/core/assets/ui/uiskin.json @@ -47,7 +47,7 @@ io.anuke.ucore.scene.ui.ImageTextButton$ImageTextButtonStyle: { toggle: {checked: button-down, down: button-down, up: button, font: default-font, fontColor: white, over: button-over, disabled: button, disabledFontColor: grey } }, io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: { - default: {background: border} + default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical} }, io.anuke.ucore.scene.ui.Window$WindowStyle: { default: {titleFont: default-font, background: window, titleFontColor: orange }, diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index c8199f1e23..6b28151904 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -81,10 +81,9 @@ public class Pathfind{ } public void update(){ - for(SpawnPoint point : Vars.control.getSpawnPoints()){ if(!point.request.pathFound){ - if(point.finder.search(point.request, ms)){ + if(point.finder.search(point.request, ms * 2)){ smoother.smoothPath(point.path); point.pathTiles = point.path.nodes.toArray(Tile.class); } diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 032012f65c..eba3b1d418 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -447,7 +447,8 @@ public class Renderer extends RendererModule{ drawHealth(entity); } - drawHealth(player); + if(!Vars.android) + drawHealth(player); } void drawHealth(DestructibleEntity dest){ diff --git a/core/src/io/anuke/mindustry/core/Tutorial.java b/core/src/io/anuke/mindustry/core/Tutorial.java index 5dfb28cd49..b193a15815 100644 --- a/core/src/io/anuke/mindustry/core/Tutorial.java +++ b/core/src/io/anuke/mindustry/core/Tutorial.java @@ -77,7 +77,7 @@ public class Tutorial{ if(stage.showBlock){ Tile tile = world.tile(control.core.x + stage.blockPlaceX, control.core.y + stage.blockPlaceY); - if(tile.block() == stage.targetBlock && (tile.rotation == stage.blockRotation || stage.blockRotation == -1)){ + if(tile.block() == stage.targetBlock && (tile.getRotation() == stage.blockRotation || stage.blockRotation == -1)){ move(true); } } diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 0914b421b4..45a9cd61bb 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -32,6 +32,7 @@ import io.anuke.ucore.scene.ui.*; import io.anuke.ucore.scene.ui.Window.WindowStyle; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Unit; +import io.anuke.ucore.util.Profiler; public class UI extends SceneModule{ Table loadingtable, desctable, configtable; @@ -132,7 +133,8 @@ public class UI extends SceneModule{ @Override public void update(){ - + Profiler.begin("ui"); + if(nplay.visible()){ scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); scene.getBatch().begin(); @@ -143,6 +145,8 @@ public class UI extends SceneModule{ } super.update(); + + Profiler.end("ui"); } @Override diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index 487e249d0c..5d087d919e 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -68,9 +68,9 @@ import io.anuke.ucore.entities.Entities; * Amount of tiles (int) * (tile list) * Tile position, as a single integer, in the format x+y*width - * Tile link - byte + * Tile link - (byte) * Tile type (boolean)- whether the block has a tile entity attached - * Block ID - the block ID + * Block ID - the block ID (byte) * (the following only applies to tile entity blocks) * Block rotation (byte) * Block health (int) @@ -263,7 +263,7 @@ public class SaveIO{ stream.writeInt(tile.block().id); //block ID if(tile.entity != null){ - stream.writeByte(tile.rotation); //rotation + stream.writeByte(tile.getRotation()); //rotation stream.writeInt(tile.entity.health); //health stream.writeByte(tile.entity.items.size); //amount of items @@ -413,7 +413,7 @@ public class SaveIO{ int items = stream.readByte(); tile.entity.health = health; - tile.rotation = rotation; + tile.setRotation(rotation); for(int j = 0; j < items; j ++){ int itemid = stream.readByte(); diff --git a/core/src/io/anuke/mindustry/ui/LevelDialog.java b/core/src/io/anuke/mindustry/ui/LevelDialog.java index e19f697798..7b08341262 100644 --- a/core/src/io/anuke/mindustry/ui/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/LevelDialog.java @@ -29,6 +29,7 @@ public class LevelDialog extends FloatingDialog{ addCloseButton(); Table maps = new Table(); ScrollPane pane = new ScrollPane(maps); + pane.setFadeScrollBars(false); int maxwidth = 4; @@ -75,6 +76,8 @@ public class LevelDialog extends FloatingDialog{ }); image.getImageCell().size(images).units(Unit.dp); maps.add(image).width(170).pad(4f).units(Unit.dp); + + maps.padRight(Unit.dp.inPixels(26)); } content().add(pane).uniformX(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index e6df62fe3c..5a9ebcc900 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -156,7 +156,7 @@ public class HudFragment implements Fragment{ atop(); aleft(); new label((StringSupplier)()->Profiler.formatDisplayTimes()); - }}.width(400f).end(); + }}.width(400f).units(Unit.dp).end(); }}.end(); } } diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 33ae7b7288..9340af1b92 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -127,8 +127,8 @@ public class Block{ * Tries to put this item into a nearby container, if there are no available * containers, it gets added to the block's inventory.*/ protected void offloadNear(Tile tile, Item item){ - int i = tile.dump; - int pdump = tile.dump; + byte i = tile.getDump(); + byte pdump = tile.getDump(); Tile[] tiles = tile.getNearby(); @@ -136,16 +136,16 @@ public class Block{ Tile other = tiles[i]; if(other != null && other.block().acceptItem(item, other, tile) //don't output to things facing this thing - && !(other.block().rotate && (other.rotation + 2) % 4 == i)){ + && !(other.block().rotate && (other.getRotation() + 2) % 4 == i)){ other.block().handleItem(item, other, tile); - tile.dump = (byte)((i+1)%4); + tile.setDump((byte)((i+1)%4)); return; } i++; i %= 4; } - tile.dump = (byte)pdump; + tile.setDump((byte)pdump); handleItem(item, tile, tile); } @@ -158,7 +158,7 @@ public class Block{ * Try dumping any item near the tile. -1 = any direction */ protected boolean tryDump(Tile tile, int direction, Item todump){ - int i = tile.dump; + int i = tile.getDump(); Tile[] tiles = tile.getNearby(); @@ -172,10 +172,10 @@ public class Block{ if(tile.entity.hasItem(item) && other != null && other.block().acceptItem(item, other, tile) && //don't output to things facing this thing - !(other.block().rotate && (other.rotation + 2) % 4 == i)){ + !(other.block().rotate && (other.getRotation() + 2) % 4 == i)){ other.block().handleItem(item, other, tile); tile.entity.removeItem(item, 1); - tile.dump = (byte)((i+1)%4); + tile.setDump((byte)((i+1)%4)); return true; } } @@ -190,7 +190,7 @@ public class Block{ * Try offloading an item to a nearby container. Returns true if success. */ protected boolean offloadDir(Tile tile, Item item){ - Tile other = tile.getNearby()[tile.rotation]; + Tile other = tile.getNearby()[tile.getRotation()]; if(other != null && other.block().acceptItem(item, other, tile)){ other.block().handleItem(item, other, tile); //other.entity.addCovey(item, ch == 1 ? 0.5f : ch ==2 ? 1f : 0f); @@ -207,7 +207,7 @@ public class Block{ //note: multiblocks do not support rotation if(!isMultiblock()){ Draw.rect(variants > 0 ? (name() + Mathf.randomSeed(tile.id(), 1, variants)) : name(), - tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0); + tile.worldx(), tile.worldy(), rotate ? tile.getRotation() * 90 : 0); }else{ //if multiblock, make sure to draw even block sizes offset, since the core block is at the BOTTOM LEFT Vector2 offset = getPlaceOffset(); diff --git a/core/src/io/anuke/mindustry/world/Map.java b/core/src/io/anuke/mindustry/world/Map.java index e393da1344..95bbdf52f7 100644 --- a/core/src/io/anuke/mindustry/world/Map.java +++ b/core/src/io/anuke/mindustry/world/Map.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.world; public enum Map{ delta("Starting map."), pit("Eck."), + canyon("the canyon"), maze("it's okay."), volcano("desc"), tutorial(false), diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index 85332d1627..da2b525863 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -15,14 +15,15 @@ import io.anuke.ucore.util.Mathf; public class Tile{ private static final Array tmpArray = new Array<>(); - private Block floor = Blocks.air; - private Block block = Blocks.air; + /**Packed block data. Left is floor, right is block.*/ + private short blocks; + /**Packed data. Left is rotation, right is dump.*/ + private short data; /**The coordinates of the core tile this is linked to, in the form of two bytes packed into one. * This is relative to the block it is linked to; negate coords to find the link.*/ public byte link = 0; - public TileEntity entity; public short x, y; - public byte rotation, dump; + public TileEntity entity; public Tile(int x, int y){ this.x = (short)x; @@ -31,7 +32,25 @@ public class Tile{ public Tile(int x, int y, Block floor){ this(x, y); - this.floor = floor; + iSetFloor(floor); + } + + private void iSetFloor(Block floor){ + byte id = (byte)floor.id; + blocks = Bits.packShort(id, getWallID()); + } + + private void iSetBlock(Block wall){ + byte id = (byte)wall.id; + blocks = Bits.packShort(getFloorID(), id); + } + + public byte getWallID(){ + return Bits.getRightByte(blocks); + } + + public byte getFloorID(){ + return Bits.getLeftByte(blocks); } public int relativeTo(int cx, int cy){ @@ -74,46 +93,68 @@ public class Tile{ } public Block floor(){ - return floor; + return Block.getByID(getFloorID()); } public Block block(){ - return block; + return Block.getByID(getWallID()); } /**Returns the breaktime of the block, or the breaktime of the linked block, if this tile is linked.*/ public float getBreakTime(){ - return link == 0 ? block.breaktime : getLinked().block.breaktime; + Block block = block(); + return link == 0 ? block.breaktime : getLinked().block().breaktime; } public void setBlock(Block type, int rotation){ if(rotation < 0) rotation = (-rotation + 2); rotation %= 4; - this.block = type; - this.rotation = (byte)rotation; + iSetBlock(type); + setRotation((byte)rotation); this.link = 0; changed(); } public void setBlock(Block type){ - this.block = type; + iSetBlock(type); this.link = 0; changed(); } public void setFloor(Block type){ - this.floor = type; + iSetFloor(type); + } + + public void setRotation(byte rotation){ + data = Bits.packShort(rotation, getDump()); + } + + public void setDump(byte dump){ + data = Bits.packShort(getRotation(), dump); + } + + public byte getRotation(){ + return Bits.getLeftByte(data); + } + + public byte getDump(){ + return Bits.getRightByte(data); } public boolean passable(){ + Block block = block(); + Block floor = floor(); return isLinked() || !(floor.solid || (block.solid && (!block.destructible && !block.update))); } public boolean solid(){ + Block block = block(); + Block floor = floor(); return block.solid || floor.solid; } public boolean breakable(){ + Block block = block(); if(link == 0){ return (block.destructible || block.breakable || block.update); }else{ @@ -134,6 +175,7 @@ public class Tile{ /**Returns the list of all tiles linked to this multiblock, or an empty array if it's not a multiblock. * This array contains all linked tiles, including this tile itself.*/ public Array getLinkedTiles(){ + Block block = block(); tmpArray.clear(); if(!(block.width == 1 && block.height == 1)){ int offsetx = -(block.width-1)/2; @@ -169,6 +211,8 @@ public class Tile{ entity = null; } + Block block = block(); + if(block.destructible || block.update){ entity = block.getEntity().init(this, block.update); } @@ -176,6 +220,9 @@ public class Tile{ @Override public String toString(){ + Block block = block(); + Block floor = floor(); + return floor.name() + ":" + block.name() + (link != 0 ? " link=[" + (Bits.getLeftByte(link) - 8) + ", " + (Bits.getRightByte(link) - 8) + "]" : ""); } diff --git a/core/src/io/anuke/mindustry/world/World.java b/core/src/io/anuke/mindustry/world/World.java index 3d92e17c57..0891df8193 100644 --- a/core/src/io/anuke/mindustry/world/World.java +++ b/core/src/io/anuke/mindustry/world/World.java @@ -20,6 +20,7 @@ import io.anuke.ucore.entities.Entity; import io.anuke.ucore.entities.SolidEntity; import io.anuke.ucore.modules.Module; import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Profiler; import io.anuke.ucore.util.Tmp; public class World extends Module{ @@ -38,7 +39,9 @@ public class World extends Module{ @Override public void update(){ + Profiler.begin("pathfind"); pathfind.update(); + Profiler.end("pathfind"); } @Override @@ -223,8 +226,7 @@ public class World extends Module{ if(tile == null) return; - tile.setBlock(result); - tile.rotation = (byte)rotation; + tile.setBlock(result, rotation); if(result.isMultiblock()){ int offsetx = -(result.width-1)/2; diff --git a/core/src/io/anuke/mindustry/world/blocks/Blocks.java b/core/src/io/anuke/mindustry/world/blocks/Blocks.java index 73c50db859..c7c57d5ca6 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/Blocks.java @@ -55,7 +55,7 @@ public class Blocks{ Effects.effect(Fx.lava, tile.worldx() + Mathf.range(5f), tile.worldy() + Mathf.range(5f)); } - if(Mathf.chance(0.003 * Timers.delta())){ + if(Mathf.chance(0.002 * Timers.delta())){ Effects.effect(Fx.lavabubble, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f)); } } @@ -70,7 +70,7 @@ public class Blocks{ @Override public void update(Tile tile){ - if(Mathf.chance(0.0025 * Timers.delta())){ + if(Mathf.chance(0.0022 * Timers.delta())){ Effects.effect(Fx.oilbubble, tile.worldx() + Mathf.range(2f), tile.worldy() + Mathf.range(2f)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/LiquidBlock.java b/core/src/io/anuke/mindustry/world/blocks/types/LiquidBlock.java index e04b6b2942..75d958b932 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/LiquidBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/LiquidBlock.java @@ -12,6 +12,7 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Timers; +import io.anuke.ucore.util.Mathf; public class LiquidBlock extends Block implements LiquidAcceptor{ protected float liquidCapacity = 10f; @@ -34,16 +35,16 @@ public class LiquidBlock extends Block implements LiquidAcceptor{ public void draw(Tile tile){ LiquidEntity entity = tile.entity(); - Draw.rect(name() + "bottom", tile.worldx(), tile.worldy(), tile.rotation * 90); + Draw.rect(name() + "bottom", tile.worldx(), tile.worldy(), tile.getRotation() * 90); if(entity.liquid != null && entity.liquidAmount > 0.01f){ Draw.color(entity.liquid.color); Draw.alpha(entity.liquidAmount / liquidCapacity); - Draw.rect("conduitliquid", tile.worldx(), tile.worldy(), tile.rotation * 90); + Draw.rect("conduitliquid", tile.worldx(), tile.worldy(), tile.getRotation() * 90); Draw.color(); } - Draw.rect(name() + "top", tile.worldx(), tile.worldy(), tile.rotation * 90); + Draw.rect(name() + "top", tile.worldx(), tile.worldy(), tile.getRotation() * 90); } @@ -57,7 +58,7 @@ public class LiquidBlock extends Block implements LiquidAcceptor{ LiquidEntity entity = tile.entity(); if(entity.liquidAmount > 0.01f && Timers.get(entity, "flow", 3)){ - tryMoveLiquid(tile, tile.getNearby()[tile.rotation]); + tryMoveLiquid(tile, tile.getNearby()[tile.getRotation()]); } } @@ -66,9 +67,8 @@ public class LiquidBlock extends Block implements LiquidAcceptor{ LiquidEntity entity = tile.entity(); if(entity.liquidAmount > 0.01f){ - tryMoveLiquid(tile, tile.getNearby()[tile.dump]); - tile.dump ++; - tile.dump %= 4; + tryMoveLiquid(tile, tile.getNearby()[tile.getDump()]); + tile.setDump((byte)Mathf.mod(tile.getDump() + 1, 4)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java index c3ccc55a11..ade4802b12 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Conveyor.java @@ -47,14 +47,16 @@ public class Conveyor extends Block{ public void draw(Tile tile){ ConveyorEntity entity = tile.entity(); + byte rotation = tile.getRotation(); + Draw.rect(name() + - (Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed && acceptItem(Item.stone, tile, null) ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90); + (Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed && acceptItem(Item.stone, tile, null) ? "" : "move"), tile.worldx(), tile.worldy(), rotation * 90); for(int i = 0; i < entity.convey.size; i ++){ ItemPos pos = pos1.set(entity.convey.get(i)); - Tmp.v1.set(tilesize, 0).rotate(tile.rotation * 90); - Tmp.v2.set(-tilesize / 2, pos.x*tilesize/2).rotate(tile.rotation * 90); + Tmp.v1.set(tilesize, 0).rotate(rotation * 90); + Tmp.v2.set(-tilesize / 2, pos.x*tilesize/2).rotate(rotation * 90); Draw.rect("icon-" + pos.item.name(), tile.x * tilesize + Tmp.v1.x * pos.y + Tmp.v2.x, @@ -115,7 +117,7 @@ public class Conveyor extends Block{ @Override public boolean acceptItem(Item item, Tile dest, Tile source){ - int direction = source == null ? 0 : Math.abs(source.relativeTo(dest.x, dest.y) - dest.rotation); + int direction = source == null ? 0 : Math.abs(source.relativeTo(dest.x, dest.y) - dest.getRotation()); float minitem = dest.entity().minitem; return ((direction == 0) && minitem > 0.05f) || ((direction %2 == 1) && minitem > 0.5f); @@ -123,8 +125,10 @@ public class Conveyor extends Block{ @Override public void handleItem(Item item, Tile tile, Tile source){ - int ch = Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation); - int ang = ((source.relativeTo(tile.x, tile.y) - tile.rotation)); + byte rotation = tile.getRotation(); + + int ch = Math.abs(source.relativeTo(tile.x, tile.y) - rotation); + int ang = ((source.relativeTo(tile.x, tile.y) - rotation)); float pos = ch == 0 ? 0 : ch % 2 == 1 ? 0.5f : 1f; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java index 76fb6ea299..b3f5ea09e9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java @@ -16,7 +16,7 @@ public class LiquidItemJunction extends LiquidBlock{ @Override public void draw(Tile tile){ - Draw.rect(name(), tile.worldx(), tile.worldy(), tile.rotation * 90); + Draw.rect(name(), tile.worldx(), tile.worldy(), tile.getRotation() * 90); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidRouter.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidRouter.java index 2e1037b034..df8079c55c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidRouter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidRouter.java @@ -22,12 +22,11 @@ public class LiquidRouter extends LiquidBlock{ LiquidEntity entity = tile.entity(); if(Timers.get(tile, "dump", 2) && entity.liquidAmount > 0){ - if(lastmap.get(tile, (byte)-1) != tile.rotation){ - tryMoveLiquid(tile, tile.getNearby()[tile.rotation]); + if(lastmap.get(tile, (byte)-1) != tile.getRotation()){ + tryMoveLiquid(tile, tile.getNearby()[tile.getRotation()]); } - tile.rotation ++; - tile.rotation %= 4; + tile.setRotation((byte)((tile.getRotation() + 1) % 4)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Router.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Router.java index f667ad8efd..baa43f5e1e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Router.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Router.java @@ -35,13 +35,12 @@ public class Router extends Block{ @Override public void update(Tile tile){ if(Timers.get(tile, "dump", 2) && tile.entity.totalItems() > 0){ - if(lastmap.get(tile, (byte)-1) != tile.rotation + if(lastmap.get(tile, (byte)-1) != tile.getRotation() || Mathf.chance(0.3)){ //sometimes dump backwards at a 1/4 chance... this somehow works? - tryDump(tile, tile.rotation, null); + tryDump(tile, tile.getRotation(), null); } - tile.rotation ++; - tile.rotation %= 4; + tile.setRotation((byte)((tile.getRotation() + 1) % 4)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Sorter.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Sorter.java index 4943edec27..e2b264ae8a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Sorter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Sorter.java @@ -73,14 +73,14 @@ public class Sorter extends Junction implements Configurable{ }else if(bc && !ac){ to = b; }else{ - if(dest.dump == 0){ + if(dest.getDump() == 0){ to = a; if(flip) - dest.dump = 1; + dest.setDump((byte)1); }else{ to = b; if(flip) - dest.dump = 0; + dest.setDump((byte)0); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java index ec2c00fbbe..c981f35f5d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java @@ -86,7 +86,7 @@ public class Generator extends PowerBlock{ } for(int i = 0; i < laserDirections; i++){ - drawLaserTo(tile, (tile.rotation + i) - laserDirections/2); + drawLaserTo(tile, (tile.getRotation() + i) - laserDirections/2); } } @@ -99,7 +99,7 @@ public class Generator extends PowerBlock{ PowerEntity entity = tile.entity(); for(int i = 0; i < laserDirections; i++){ - Tile target = laserTarget(tile, (tile.rotation + i) - laserDirections/2); + Tile target = laserTarget(tile, (tile.getRotation() + i) - laserDirections/2); if(target == null) continue; diff --git a/desktop/mindustry-saves/1.mins b/desktop/mindustry-saves/1.mins index 21c0483e4c..508e5b9409 100644 Binary files a/desktop/mindustry-saves/1.mins and b/desktop/mindustry-saves/1.mins differ