diff --git a/README.md b/README.md index 60f33804ab..4b00672d58 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,6 @@ After building, the output .JAR file should be in the output JAR file should be - + diff --git a/build.gradle b/build.gradle index e1039633e4..079862f896 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.Anuken:ucore:a1a3bd9' + compile 'com.github.Anuken:ucore:6eea0a3' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets-raw/sprites/ui/icon-areaDelete.png b/core/assets-raw/sprites/ui/icon-areaDelete.png new file mode 100644 index 0000000000..97b95ea94f Binary files /dev/null and b/core/assets-raw/sprites/ui/icon-areaDelete.png differ diff --git a/core/assets-raw/sprites/ui/icon-hold.png b/core/assets-raw/sprites/ui/icon-hold.png new file mode 100644 index 0000000000..43e6c78ba1 Binary files /dev/null and b/core/assets-raw/sprites/ui/icon-hold.png differ diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 7f61e0a159..c5334ab861 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -34,42 +34,42 @@ blocks/blackrockshadow1 index: -1 blocks/blackstone1 rotate: false - xy: 734, 406 + xy: 724, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstone2 rotate: false - xy: 734, 396 + xy: 724, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstone3 rotate: false - xy: 724, 371 + xy: 724, 351 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock1 rotate: false - xy: 724, 361 + xy: 498, 110 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock2 rotate: false - xy: 724, 351 + xy: 508, 110 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock3 rotate: false - xy: 498, 110 + xy: 704, 265 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -83,7 +83,7 @@ blocks/blackstoneedge index: -1 blocks/block rotate: false - xy: 704, 265 + xy: 702, 245 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -118,112 +118,112 @@ blocks/chainturret-icon index: -1 blocks/coal1 rotate: false - xy: 702, 245 + xy: 416, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal2 rotate: false - xy: 734, 386 + xy: 165, 76 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal3 rotate: false - xy: 734, 376 + xy: 224, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coaldrill rotate: false - xy: 734, 366 + xy: 234, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator rotate: false - xy: 734, 356 + xy: 244, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator-top rotate: false - xy: 734, 346 + xy: 254, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalpurifier rotate: false - xy: 406, 99 + xy: 264, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/combustiongenerator rotate: false - xy: 416, 99 + xy: 274, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/compositewall rotate: false - xy: 165, 76 + xy: 284, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduit rotate: false - xy: 175, 79 + xy: 294, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitbottom rotate: false - xy: 185, 79 + xy: 304, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitliquid rotate: false - xy: 195, 79 + xy: 314, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduittop rotate: false - xy: 205, 79 + xy: 324, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyor rotate: false - xy: 215, 79 + xy: 334, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyormove rotate: false - xy: 225, 83 + xy: 344, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyortunnel rotate: false - xy: 235, 83 + xy: 354, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -237,42 +237,42 @@ blocks/core index: -1 blocks/cross rotate: false - xy: 245, 83 + xy: 364, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/crucible rotate: false - xy: 255, 83 + xy: 374, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/deepwater rotate: false - xy: 265, 83 + xy: 384, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt1 rotate: false - xy: 275, 83 + xy: 394, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt2 rotate: false - xy: 285, 83 + xy: 404, 89 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt3 rotate: false - xy: 295, 83 + xy: 414, 89 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -286,7 +286,7 @@ blocks/dirtedge index: -1 blocks/door rotate: false - xy: 305, 83 + xy: 404, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -300,7 +300,7 @@ blocks/door-large index: -1 blocks/door-large-icon rotate: false - xy: 315, 83 + xy: 414, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -314,7 +314,7 @@ blocks/door-large-open index: -1 blocks/door-open rotate: false - xy: 325, 83 + xy: 115, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -328,7 +328,7 @@ blocks/doubleturret index: -1 blocks/duriumwall rotate: false - xy: 335, 83 + xy: 163, 30 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -342,7 +342,7 @@ blocks/duriumwall-large index: -1 blocks/duriumwall-large-icon rotate: false - xy: 345, 83 + xy: 163, 20 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -356,42 +356,42 @@ blocks/flameturret index: -1 blocks/fluxpump rotate: false - xy: 365, 83 + xy: 732, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass1 rotate: false - xy: 375, 83 + xy: 734, 371 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass2 rotate: false - xy: 385, 83 + xy: 734, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass3 rotate: false - xy: 395, 83 + xy: 734, 351 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock1 rotate: false - xy: 115, 4 + xy: 428, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock2 rotate: false - xy: 163, 30 + xy: 438, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -405,21 +405,21 @@ blocks/grassedge index: -1 blocks/ice1 rotate: false - xy: 163, 20 + xy: 448, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ice2 rotate: false - xy: 167, 10 + xy: 458, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ice3 rotate: false - xy: 428, 103 + xy: 468, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -433,98 +433,98 @@ blocks/iceedge index: -1 blocks/icerock1 rotate: false - xy: 438, 103 + xy: 518, 114 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerock2 rotate: false - xy: 448, 103 + xy: 175, 76 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerockshadow1 rotate: false - xy: 458, 103 + xy: 185, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow1 rotate: false - xy: 458, 103 + xy: 185, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerockshadow2 rotate: false - xy: 468, 103 + xy: 195, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow2 rotate: false - xy: 468, 103 + xy: 195, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron1 rotate: false - xy: 285, 73 + xy: 498, 90 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 295, 73 + xy: 508, 90 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 305, 73 + xy: 518, 94 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 315, 73 + xy: 518, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 325, 73 + xy: 592, 238 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 335, 73 + xy: 602, 238 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/laserturret rotate: false - xy: 380, 93 + xy: 131, 8 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/lava rotate: false - xy: 345, 73 + xy: 612, 238 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -538,63 +538,63 @@ blocks/lavaedge index: -1 blocks/lavasmelter rotate: false - xy: 355, 73 + xy: 622, 238 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquiditemjunction rotate: false - xy: 365, 73 + xy: 632, 238 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidjunction rotate: false - xy: 375, 73 + xy: 642, 238 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidrouter rotate: false - xy: 385, 73 + xy: 591, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/machineturret rotate: false - xy: 392, 93 + xy: 143, 8 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/megarepairturret rotate: false - xy: 131, 8 + xy: 155, 8 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mortarturret rotate: false - xy: 143, 8 + xy: 709, 279 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mossblock rotate: false - xy: 478, 103 + xy: 611, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 478, 103 + xy: 611, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -615,7 +615,7 @@ blocks/nuclearreactor-center index: -1 blocks/nuclearreactor-icon rotate: false - xy: 498, 100 + xy: 631, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -636,7 +636,7 @@ blocks/nuclearreactor-small index: -1 blocks/oil rotate: false - xy: 508, 100 + xy: 641, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -650,175 +650,175 @@ blocks/oiledge index: -1 blocks/oilrefinery rotate: false - xy: 518, 104 + xy: 595, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 488, 95 + xy: 605, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/plasmaturret rotate: false - xy: 155, 8 + xy: 721, 281 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/powerbooster rotate: false - xy: 498, 90 + xy: 615, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyor rotate: false - xy: 508, 90 + xy: 625, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyormove rotate: false - xy: 518, 94 + xy: 635, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaser rotate: false - xy: 518, 84 + xy: 645, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlasercorner rotate: false - xy: 592, 238 + xy: 651, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaserrouter rotate: false - xy: 602, 238 + xy: 655, 218 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduit rotate: false - xy: 612, 238 + xy: 661, 234 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduitbottom rotate: false - xy: 622, 238 + xy: 671, 234 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduittop rotate: false - xy: 632, 238 + xy: 681, 234 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 642, 238 + xy: 691, 235 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/repairturret rotate: false - xy: 709, 279 + xy: 541, 177 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/rock1 rotate: false - xy: 601, 228 + xy: 665, 224 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 611, 228 + xy: 675, 224 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 621, 228 + xy: 665, 214 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator rotate: false - xy: 631, 228 + xy: 675, 214 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator-top rotate: false - xy: 641, 228 + xy: 685, 224 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand1 rotate: false - xy: 595, 218 + xy: 685, 214 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand2 rotate: false - xy: 605, 218 + xy: 695, 225 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand3 rotate: false - xy: 615, 218 + xy: 695, 215 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock1 rotate: false - xy: 625, 218 + xy: 705, 225 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock2 rotate: false - xy: 635, 218 + xy: 705, 215 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock3 rotate: false - xy: 645, 218 + xy: 711, 235 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -832,91 +832,91 @@ blocks/sandedge index: -1 blocks/shadow rotate: false - xy: 721, 281 + xy: 722, 415 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shieldgenerator rotate: false - xy: 655, 218 + xy: 715, 225 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shotgunturret rotate: false - xy: 541, 177 + xy: 722, 403 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shrub rotate: false - xy: 681, 234 + xy: 725, 225 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 691, 235 + xy: 725, 215 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 701, 235 + xy: 742, 382 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sniperturret rotate: false - xy: 722, 415 + xy: 722, 391 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/snow1 rotate: false - xy: 665, 224 + xy: 744, 372 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snow2 rotate: false - xy: 675, 224 + xy: 744, 362 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snow3 rotate: false - xy: 665, 214 + xy: 744, 352 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock1 rotate: false - xy: 675, 214 + xy: 185, 69 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock2 rotate: false - xy: 685, 224 + xy: 195, 69 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock3 rotate: false - xy: 685, 214 + xy: 205, 69 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -930,28 +930,28 @@ blocks/snowedge index: -1 blocks/sorter rotate: false - xy: 695, 225 + xy: 595, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyor rotate: false - xy: 695, 215 + xy: 605, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 705, 225 + xy: 615, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 705, 215 + xy: 625, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -965,56 +965,56 @@ blocks/steelwall-large index: -1 blocks/steelwall-large-icon rotate: false - xy: 711, 235 + xy: 635, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone1 rotate: false - xy: 712, 245 + xy: 645, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 715, 225 + xy: 655, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 715, 215 + xy: 665, 204 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock1 rotate: false - xy: 721, 235 + xy: 675, 204 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 725, 225 + xy: 685, 204 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 725, 215 + xy: 695, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 175, 69 + xy: 705, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1028,35 +1028,35 @@ blocks/stoneedge index: -1 blocks/stoneformer rotate: false - xy: 185, 69 + xy: 715, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonewall rotate: false - xy: 195, 69 + xy: 725, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter rotate: false - xy: 205, 69 + xy: 714, 269 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter-top rotate: false - xy: 215, 69 + xy: 714, 259 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/thermalgenerator rotate: false - xy: 171, 59 + xy: 724, 271 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1070,56 +1070,56 @@ blocks/titancannon index: -1 blocks/titancannon-icon rotate: false - xy: 722, 403 + xy: 734, 416 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 171, 49 + xy: 724, 261 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 181, 59 + xy: 899, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 181, 49 + xy: 909, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 191, 59 + xy: 919, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumpurifier rotate: false - xy: 191, 49 + xy: 929, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumshieldwall rotate: false - xy: 201, 59 + xy: 939, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 201, 49 + xy: 949, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1133,49 +1133,49 @@ blocks/titaniumwall-large index: -1 blocks/titaniumwall-large-icon rotate: false - xy: 211, 59 + xy: 959, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/turret rotate: false - xy: 722, 391 + xy: 734, 404 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/uranium1 rotate: false - xy: 235, 63 + xy: 989, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium2 rotate: false - xy: 245, 63 + xy: 999, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium3 rotate: false - xy: 255, 63 + xy: 781, 446 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uraniumdrill rotate: false - xy: 265, 63 + xy: 781, 436 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/water rotate: false - xy: 275, 63 + xy: 791, 446 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1189,14 +1189,14 @@ blocks/wateredge index: -1 blocks/waveturret rotate: false - xy: 734, 416 + xy: 734, 392 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 bullet rotate: false - xy: 704, 255 + xy: 406, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1469,49 +1469,49 @@ enemyarrow index: -1 icon-coal rotate: false - xy: 518, 114 + xy: 205, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-dirium rotate: false - xy: 225, 73 + xy: 478, 103 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-iron rotate: false - xy: 235, 73 + xy: 488, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-steel rotate: false - xy: 245, 73 + xy: 498, 100 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-stone rotate: false - xy: 255, 73 + xy: 508, 100 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-titanium rotate: false - xy: 265, 73 + xy: 518, 104 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-uranium rotate: false - xy: 275, 73 + xy: 488, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1546,28 +1546,28 @@ mechs/mech-standard index: -1 shell rotate: false - xy: 651, 228 + xy: 712, 245 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot rotate: false - xy: 661, 234 + xy: 715, 215 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot-long rotate: false - xy: 671, 234 + xy: 721, 235 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 titanshell rotate: false - xy: 211, 49 + xy: 969, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1671,20 +1671,27 @@ ui/cursor orig: 4, 4 offset: 0, 0 index: -1 -ui/icon-arrow-left +ui/icon-areaDelete rotate: false xy: 200, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 -ui/icon-arrow-right +ui/icon-arrow-left rotate: false xy: 212, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 +ui/icon-arrow-right + rotate: false + xy: 224, 93 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 ui/icon-cancel rotate: false xy: 597, 280 @@ -1722,28 +1729,28 @@ ui/icon-close-over index: -1 ui/icon-crafting rotate: false - xy: 224, 93 + xy: 236, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-cursor rotate: false - xy: 236, 93 + xy: 248, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-defense rotate: false - xy: 248, 93 + xy: 260, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-distribution rotate: false - xy: 260, 93 + xy: 272, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1755,9 +1762,16 @@ ui/icon-donate orig: 14, 14 offset: 0, 0 index: -1 +ui/icon-hold + rotate: false + xy: 284, 93 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 ui/icon-info rotate: false - xy: 272, 93 + xy: 296, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1771,21 +1785,21 @@ ui/icon-load index: -1 ui/icon-menu rotate: false - xy: 284, 93 + xy: 308, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-pause rotate: false - xy: 296, 93 + xy: 320, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-play rotate: false - xy: 308, 93 + xy: 332, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1799,14 +1813,14 @@ ui/icon-play-2 index: -1 ui/icon-power rotate: false - xy: 320, 93 + xy: 344, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-production rotate: false - xy: 332, 93 + xy: 356, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1841,7 +1855,7 @@ ui/icon-save index: -1 ui/icon-settings rotate: false - xy: 344, 93 + xy: 368, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1855,7 +1869,7 @@ ui/icon-tools index: -1 ui/icon-touch rotate: false - xy: 356, 93 + xy: 380, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1869,7 +1883,7 @@ ui/icon-tutorial index: -1 ui/icon-weapon rotate: false - xy: 368, 93 + xy: 392, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1947,7 +1961,7 @@ ui/selection index: -1 ui/separator rotate: false - xy: 169, 86 + xy: 179, 86 size: 1, 1 orig: 1, 1 offset: 0, 0 @@ -1982,7 +1996,7 @@ ui/slider-knob-over index: -1 ui/slider-vertical rotate: false - xy: 724, 348 + xy: 169, 86 size: 8, 1 orig: 8, 1 offset: 0, 0 @@ -2084,42 +2098,42 @@ ui/window-empty index: -1 weapons/blaster rotate: false - xy: 508, 110 + xy: 704, 255 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/flamer rotate: false - xy: 355, 83 + xy: 167, 10 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/mortar rotate: false - xy: 395, 73 + xy: 601, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/multigun rotate: false - xy: 488, 105 + xy: 621, 228 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/railgun rotate: false - xy: 591, 228 + xy: 701, 235 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/triblaster rotate: false - xy: 225, 63 + xy: 979, 487 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 90d1fa32f7..56c1f842b0 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index 8013577925..90512df26f 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -2,7 +2,6 @@ package io.anuke.mindustry; import java.util.Date; -import com.badlogic.gdx.graphics.profiling.GLProfiler; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.core.*; @@ -14,7 +13,6 @@ import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; import io.anuke.ucore.function.Callable; import io.anuke.ucore.modules.ModuleCore; -import io.anuke.ucore.util.Profiler; public class Mindustry extends ModuleCore { public static Callable donationsCallable; @@ -43,15 +41,11 @@ public class Mindustry extends ModuleCore { @Override public void postInit(){ - if(Vars.debug && Vars.debugGL){ - GLProfiler.enable(); - } Vars.control.reset(); } @Override public void render(){ - Profiler.begin("total"); try{ super.render(); @@ -66,7 +60,5 @@ public class Mindustry extends ModuleCore { } Inputs.update(); - - Profiler.end("total"); } } diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 75f9fffaf0..feb127324a 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.Player; import io.anuke.ucore.scene.ui.layout.Unit; public class Vars{ - public static final boolean testAndroid = false; + public static final boolean testAndroid = true; //shorthand for whether or not this is running on android public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid; //shorthand for whether or not this is running on GWT @@ -34,10 +34,6 @@ public class Vars{ public static final int zoomScale = Math.round(Unit.dp.inPixels(1)); //if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available public static boolean debug = false; - //whether to debug openGL info - public static boolean debugGL = false; - //whether profiling is shown - public static boolean profile = false; //whether the player can clip through walls public static boolean noclip = false; //whether to draw chunk borders diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 20dbe4403b..4258c8df6a 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -19,7 +19,7 @@ import io.anuke.mindustry.entities.enemies.BlastEnemy; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.HealerEnemy; import io.anuke.mindustry.input.AndroidInput; -import io.anuke.mindustry.input.Input; +import io.anuke.mindustry.input.DesktopInput; import io.anuke.mindustry.input.InputHandler; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.ItemStack; @@ -32,7 +32,6 @@ import io.anuke.ucore.entities.EntityGroup; import io.anuke.ucore.graphics.Atlas; import io.anuke.ucore.modules.Module; import io.anuke.ucore.util.Mathf; -import io.anuke.ucore.util.Profiler; public class Control extends Module{ int targetscale = baseCameraScale; @@ -65,10 +64,6 @@ public class Control extends Module{ public Control(){ if(Mindustry.args.contains("-debug", false)) Vars.debug = true; - if(Mindustry.args.contains("-profile", false)) - Vars.profile = true; - if(Mindustry.args.contains("-debugGL", false)) - Vars.debugGL = true; UCore.log("Total blocks loaded: " + Block.getAllBlocks().size); @@ -83,7 +78,7 @@ public class Control extends Module{ if(android){ input = new AndroidInput(); }else{ - input = new Input(); + input = new DesktopInput(); } Inputs.addProcessor(input); @@ -111,7 +106,8 @@ public class Control extends Module{ "pause", Keys.SPACE, "dash", Keys.SHIFT_LEFT, "rotate_right", Keys.R, - "rotate_left", Keys.E + "rotate_left", Keys.E, + "area_delete_mode", Keys.Q ); for(int i = 0; i < Vars.saveSlots; i ++){ @@ -165,7 +161,7 @@ public class Control extends Module{ renderer.clearTiles(); player.x = core.worldx(); - player.y = core.worldy() - Vars.tilesize*2 - ((int)(Gdx.graphics.getWidth() / (float)Core.cameraScale * 2) % 2 == 0 ? 0.5f : 0); + player.y = core.worldy() - Vars.tilesize*2; Core.camera.position.set(player.x, player.y, 0); @@ -282,7 +278,7 @@ public class Control extends Module{ int last = Settings.getInt("hiscore" + world.getMap().name()); - if(wave > last){ + if(wave > last && mode != GameMode.sandbox){ Settings.putInt("hiscore" + world.getMap().name(), wave); Settings.save(); hiscore = true; @@ -522,10 +518,7 @@ public class Control extends Module{ if(wavetime <= 0){ runWave(); } - - Profiler.begin("entityUpdate"); - //TODO Entities.update(Entities.defaultGroup()); Entities.update(bulletGroup); Entities.update(enemyGroup); @@ -533,8 +526,6 @@ public class Control extends Module{ Entities.collideGroups(enemyGroup, bulletGroup); Entities.collideGroups(Entities.defaultGroup(), bulletGroup); - - Profiler.end("entityUpdate"); } } } diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index c43b4dbcf5..d99fac4c12 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -1,11 +1,12 @@ package io.anuke.mindustry.core; import static io.anuke.mindustry.Vars.*; -import static io.anuke.ucore.core.Core.camera; +import static io.anuke.ucore.core.Core.*; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.*; -import com.badlogic.gdx.graphics.profiling.GLProfiler; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.FloatArray; @@ -22,16 +23,18 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.ProductionBlocks; import io.anuke.mindustry.world.blocks.types.StaticBlock; -import io.anuke.ucore.UCore; import io.anuke.ucore.core.*; import io.anuke.ucore.entities.DestructibleEntity; import io.anuke.ucore.entities.EffectEntity; import io.anuke.ucore.entities.Entities; import io.anuke.ucore.graphics.CacheBatch; +import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.graphics.Surface; import io.anuke.ucore.modules.RendererModule; import io.anuke.ucore.scene.ui.layout.Unit; -import io.anuke.ucore.util.*; +import io.anuke.ucore.util.Angles; +import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Tmp; public class Renderer extends RendererModule{ private final static int chunksize = 32; @@ -56,6 +59,8 @@ public class Renderer extends RendererModule{ } } }); + + clearColor = Hue.lightness(0.4f); } @Override @@ -131,7 +136,7 @@ public class Renderer extends RendererModule{ if(Vars.snapCamera && smoothcam && Settings.getBool("pixelate")){ camera.position.set((int) camera.position.x, (int) camera.position.y, 0); } - + if(Gdx.graphics.getHeight() / Core.cameraScale % 2 == 1){ camera.position.add(0, -0.5f, 0); } @@ -139,47 +144,82 @@ public class Renderer extends RendererModule{ if(Gdx.graphics.getWidth() / Core.cameraScale % 2 == 1){ camera.position.add(-0.5f, 0, 0); } - - Profiler.begin("draw"); - - drawDefault(); - - Profiler.end("draw"); - if(Profiler.updating()) - Profiler.getTimes().put("draw", Profiler.getTimes().get("draw") - Profiler.getTimes().get("blockDraw") - Profiler.getTimes().get("entityDraw")); - - if(Vars.debug && Vars.debugGL && Timers.get("profile", 60)){ - UCore.log("shaders: " + GLProfiler.shaderSwitches, "calls: " + GLProfiler.drawCalls, "bindings: " + GLProfiler.textureBindings, "vertices: " + GLProfiler.vertexCount.average); - } + + draw(); camera.position.set(lastx - deltax, lasty - deltay, 0); record(); //this only does something if GdxGifRecorder is on the class path, which it usually isn't } } + FrameBuffer buffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); + + void drawTest(){ + camera.update(); + + clearScreen(clearColor); + + Core.batch.setProjectionMatrix(camera.combined); + + Graphics.surface(pixelSurface, false); + + Draw.color(1f, 1f, 1f, Mathf.absin(Timers.time(), 10f, 1f)); + Draw.rect("blank", camera.position.x, camera.position.y, camera.viewportWidth, camera.viewportHeight); + Draw.color(); + + Graphics.surface(shadowSurface); + Draw.color(Color.RED); + Draw.alpha(0.5f); + Draw.rect("blank", camera.position.x, camera.position.y, 100, 100); + Draw.color(); + Graphics.flushSurface(); + + Graphics.flushSurface(); + Graphics.end(); + } + + void drawTest2(){ + camera.update(); + + clearScreen(clearColor); + Core.batch.setProjectionMatrix(camera.combined); + + Graphics.surface(pixelSurface, false); + + Draw.color(1f, 1f, 1f, 0.3f); + Draw.rect("blank", camera.position.x, camera.position.y, camera.viewportWidth, camera.viewportHeight); + Draw.color(); + + Graphics.flushSurface(); + } @Override public void draw(){ + camera.update(); + + clearScreen(clearColor); + + batch.setProjectionMatrix(camera.combined); + + if(pixelate) + Graphics.surface(pixelSurface, false); + else + batch.begin(); + //clears shield surface Graphics.surface(shieldSurface); Graphics.surface(); boolean optimize = false; - - Profiler.begin("blockDraw"); + drawFloor(); drawBlocks(false, optimize); - Profiler.end("blockDraw"); - - Profiler.begin("entityDraw"); Graphics.shader(Shaders.outline, false); Entities.draw(control.enemyGroup); Graphics.shader(); Entities.draw(Entities.defaultGroup()); - - Profiler.end("entityDraw"); if(!optimize) drawBlocks(true, false); @@ -192,6 +232,12 @@ public class Renderer extends RendererModule{ if(Settings.getBool("indicators") && Vars.showUI){ drawEnemyMarkers(); } + + + if(pixelate) + Graphics.flushSurface(); + + batch.end(); } @Override @@ -476,9 +522,10 @@ public class Renderer extends RendererModule{ int tiley = control.input.getBlockY(); //draw placement box - if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android)){ + if((player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android) + && control.input.drawPlace()) || (player.placeMode.delete && Inputs.keyDown("area_delete_mode"))){ - player.placeMode.draw(tilex, tiley, control.input.getBlockEndX(), control.input.getBlockEndY()); //TODO proper end points + player.placeMode.draw(tilex, tiley, control.input.getBlockEndX(), control.input.getBlockEndY()); Draw.thickness(1f); Draw.color(Color.SCARLET); diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 6057a492da..30408bf64d 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -32,7 +32,6 @@ 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; @@ -99,6 +98,12 @@ public class UI extends SceneModule{ Colors.put("healthstats", Color.SCARLET); Colors.put("interact", Color.ORANGE); Colors.put("accent", Color.valueOf("f4ba6e")); + Colors.put("place", Color.PURPLE); + Colors.put("placeInvalid", Color.RED); + Colors.put("placeRotate", Color.ORANGE); + Colors.put("break", Color.CORAL); + Colors.put("breakStart", Color.YELLOW); + Colors.put("breakInvalid", Color.RED); } protected void loadSkin(){ @@ -133,8 +138,6 @@ public class UI extends SceneModule{ public void update(){ if(Vars.debug && !Vars.showUI) return; - Profiler.begin("ui"); - if(nplay.visible()){ scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); scene.getBatch().begin(); @@ -144,9 +147,8 @@ public class UI extends SceneModule{ scene.getBatch().end(); } - super.update(); - - Profiler.end("ui"); + scene.act(); + scene.draw(); } @Override diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index 81bd39c401..99e3996a42 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -5,26 +5,21 @@ import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.math.*; +import com.badlogic.gdx.math.GridPoint2; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.Vars; import io.anuke.mindustry.ai.Pathfind; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.TileEntity; -import io.anuke.mindustry.entities.effect.Fx; -import io.anuke.mindustry.resource.ItemStack; -import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.blocks.*; -import io.anuke.ucore.core.Effects; -import io.anuke.ucore.core.Sounds; import io.anuke.ucore.entities.Entities; 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{ @@ -43,9 +38,7 @@ public class World extends Module{ @Override public void update(){ - Profiler.begin("pathfind"); pathfind.update(); - Profiler.end("pathfind"); } @Override @@ -190,7 +183,7 @@ public class World extends Module{ Generator.generate(mapPixmaps[map.ordinal()], tiles); //TODO multiblock core - placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false); + control.getInput().placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false); if(map != Map.tutorial){ setDefaultBlocks(); @@ -239,146 +232,6 @@ public class World extends Module{ return seed; } - //TODO move to control or player? - public void placeBlock(int x, int y, Block result, int rotation, boolean effects){ - Tile tile = tile(x, y); - - //just in case - if(tile == null) - return; - - tile.setBlock(result, rotation); - - if(result.isMultiblock()){ - int offsetx = -(result.width-1)/2; - int offsety = -(result.height-1)/2; - - for(int dx = 0; dx < result.width; dx ++){ - for(int dy = 0; dy < result.height; dy ++){ - int worldx = dx + offsetx + x; - int worldy = dy + offsety + y; - if(!(worldx == x && worldy == y)){ - Tile toplace = tile(worldx, worldy); - toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety)); - } - - if(effects) Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize); - } - } - }else{ - if(effects) Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize); - } - - //Effects.shake(2f, 2f, player); - if(effects) Sounds.play("place"); - } - - //TODO move this to control? - public boolean validPlace(int x, int y, Block type){ - - for(SpawnPoint spawn : control.getSpawnPoints()){ - if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){ - return false; - } - } - - Tmp.r2.setSize(type.width * Vars.tilesize, type.height * Vars.tilesize); - Vector2 offset = type.getPlaceOffset(); - Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize); - - for(SolidEntity e : Entities.getNearby(control.enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){ - Rectangle rect = e.hitbox.getRect(e.x, e.y); - - if(Tmp.r2.overlaps(rect)){ - return false; - } - } - - if(!Vars.android && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){ - return false; - } - - Tile tile = tile(x, y); - - if(tile == null) return false; - - if(!type.isMultiblock() && Vars.control.getTutorial().active() && - Vars.control.getTutorial().showBlock()){ - - GridPoint2 point = Vars.control.getTutorial().getPlacePoint(); - int rotation = Vars.control.getTutorial().getPlaceRotation(); - Block block = Vars.control.getTutorial().getPlaceBlock(); - - if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y - || (rotation != -1 && rotation != Vars.player.rotation)){ - return false; - } - }else if(Vars.control.getTutorial().active()){ - return false; - } - - if(type.isMultiblock()){ - int offsetx = -(type.width-1)/2; - int offsety = -(type.height-1)/2; - for(int dx = 0; dx < type.width; dx ++){ - for(int dy = 0; dy < type.height; dy ++){ - Tile other = tile(x + dx + offsetx, y + dy + offsety); - if(other == null || other.block() != Blocks.air){ - return false; - } - } - } - return true; - }else{ - if(tile.block() != type && type.canReplace(tile.block()) && tile.block().isMultiblock() == type.isMultiblock()){ - return true; - } - return tile != null && tile.block() == Blocks.air; - } - } - - public void breakBlock(int x, int y){ - Tile tile = tile(x, y); - - if(tile == null) return; - - Block block = tile.isLinked() ? tile.getLinked().block() : tile.block(); - Recipe result = null; - - for(Recipe recipe : Recipe.values()){ - if(recipe.result == block){ - result = recipe; - break; - } - } - - if(result != null){ - for(ItemStack stack : result.requirements){ - Vars.control.addItem(stack.item, (int)(stack.amount * Vars.breakDropAmount)); - } - } - - if(tile.block().drops != null){ - Vars.control.addItem(tile.block().drops.item, tile.block().drops.amount); - } - - Effects.shake(3f, 1f, player); - Sounds.play("break"); - - if(!tile.block().isMultiblock() && !tile.isLinked()){ - tile.setBlock(Blocks.air); - Effects.effect(Fx.breakBlock, tile.worldx(), tile.worldy()); - }else{ - Tile target = tile.isLinked() ? tile.getLinked() : tile; - Array removals = target.getLinkedTiles(); - for(Tile toremove : removals){ - //note that setting a new block automatically unlinks it - toremove.setBlock(Blocks.air); - Effects.effect(Fx.breakBlock, toremove.worldx(), toremove.worldy()); - } - } - } - public void removeBlock(Tile tile){ if(!tile.block().isMultiblock() && !tile.isLinked()){ tile.setBlock(Blocks.air); @@ -392,34 +245,6 @@ public class World extends Module{ } } - public boolean validBreak(int x, int y){ - Tile tile = tile(x, y); - - if(tile == null || tile.block() == ProductionBlocks.core) return false; - - if(tile.isLinked() && tile.getLinked().block() == ProductionBlocks.core){ - return false; - } - - if(Vars.control.getTutorial().active()){ - - if(Vars.control.getTutorial().showBlock()){ - GridPoint2 point = Vars.control.getTutorial().getPlacePoint(); - int rotation = Vars.control.getTutorial().getPlaceRotation(); - Block block = Vars.control.getTutorial().getPlaceBlock(); - - if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y - || (rotation != -1 && rotation != Vars.player.rotation)){ - return false; - } - }else{ - return false; - } - } - - return tile.breakable(); - } - public TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){ Entity closest = null; float dst = 0; diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 75829d569f..ae6b0c920b 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -26,7 +26,7 @@ public class Player extends DestructibleEntity{ public transient float breaktime = 0; public transient Recipe recipe; public transient int rotation; - public transient PlaceMode placeMode = PlaceMode.touch; + public transient PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold; public Player(){ hitbox.setSize(5); @@ -86,7 +86,7 @@ public class Player extends DestructibleEntity{ vector.x += speed; boolean shooting = !Inputs.keyDown("dash") && Inputs.buttonDown(Buttons.LEFT) && recipe == null - && !ui.hasMouse() && !control.getInput().onConfigurable(); + && !ui.hasMouse() && !control.getInput().onConfigurable() && !Inputs.keyDown("area_delete_mode"); if(shooting && Timers.get(this, "reload", weapon.reload)){ weapon.shoot(this); @@ -108,7 +108,8 @@ public class Player extends DestructibleEntity{ } if(!shooting){ - angle = Mathf.lerpAngDelta(angle, vector.angle(), 0.13f); + if(!vector.isZero()) + angle = Mathf.lerpAngDelta(angle, vector.angle(), 0.13f); }else{ float angle = Angles.mouseAngle(x, y); this.angle = Mathf.lerpAngDelta(this.angle, angle, 0.1f); diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index 0f66669ea4..ba7aa18447 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -7,7 +7,6 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.input.GestureDetector; import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.ItemStack; @@ -20,9 +19,10 @@ import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.util.Mathf; public class AndroidInput extends InputHandler{ + public float lmousex, lmousey; public float mousex, mousey; public boolean brokeBlock = false; - private float lmousex, lmousey; + private boolean placing = true; private float warmup; private float warmupDelay = 20; @@ -34,11 +34,12 @@ public class AndroidInput extends InputHandler{ @Override public float getCursorEndY(){ return Gdx.input.getY(0); } @Override public float getCursorX(){ return mousex; } @Override public float getCursorY(){ return mousey; } + @Override public boolean drawPlace(){ return placing; } @Override public boolean keyDown(int keycode){ if(keycode == Keys.E){ - place(); + } return false; } @@ -46,26 +47,43 @@ public class AndroidInput extends InputHandler{ @Override public boolean touchUp(int screenX, int screenY, int pointer, int button){ brokeBlock = false; + if(placing && pointer == 0 && !player.placeMode.pan){ + player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY()); + placing = false; + } return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button){ + if(ui.hasMouse()) return false; + ui.hideTooltip(); - if(pointer == 0){ - lmousex = screenX; - lmousey = screenY; + lmousex = screenX; + lmousey = screenY; + + if(!player.placeMode.pan){ + if(pointer == 0){ + placing = true; + + mousex = screenX; + mousey = screenY; + + }else{ + placing = false; + } } + warmup = 0; if(!GameState.is(State.menu)){ - Tile cursor = Vars.world.tile(Mathf.scl2(Graphics.mouseWorld().x, tilesize), Mathf.scl2(Graphics.mouseWorld().y, tilesize)); - if(cursor != null && !Vars.ui.hasMouse()){ + Tile cursor = world.tile(Mathf.scl2(Graphics.mouseWorld().x, tilesize), Mathf.scl2(Graphics.mouseWorld().y, tilesize)); + if(cursor != null && !ui.hasMouse()){ Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor; if(linked != null && linked.block() instanceof Configurable){ - Vars.ui.showConfig(linked); - }else if(!Vars.ui.hasConfigMouse()){ - Vars.ui.hideConfig(); + ui.showConfig(linked); + }else if(!ui.hasConfigMouse()){ + ui.hideConfig(); } } } @@ -85,7 +103,7 @@ public class AndroidInput extends InputHandler{ public Tile selected(){ Vector2 vec = Graphics.world(mousex, mousey); - return Vars.world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); + return world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); } public void breakBlock(){ @@ -94,23 +112,18 @@ public class AndroidInput extends InputHandler{ if(player.breaktime >= tile.block().breaktime){ brokeBlock = true; - Vars.world.breakBlock(tile.x, tile.y); + breakBlock(tile.x, tile.y); player.breaktime = 0f; } } + + public void tryPlaceBlock(int tilex, int tiley){ + if(player.recipe != null && control.hasItems(player.recipe.requirements) && validPlace(tilex, tiley, player.recipe.result)){ - public void place(){ - Vector2 vec = Graphics.world(mousex, mousey); - - int tilex = Mathf.scl2(vec.x, tilesize); - int tiley = Mathf.scl2(vec.y, tilesize); - - if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && Vars.world.validPlace(tilex, tiley, player.recipe.result)){ - - Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation, true); + placeBlock(tilex, tiley, player.recipe.result, player.rotation, true); for(ItemStack stack : player.recipe.requirements){ - Vars.control.removeItem(stack); + control.removeItem(stack); } } } @@ -132,7 +145,7 @@ public class AndroidInput extends InputHandler{ if(sel == null) return; - if(warmup > warmupDelay && Vars.world.validBreak(sel.x, sel.y)){ + if(warmup > warmupDelay && validBreak(sel.x, sel.y)){ player.breaktime += Timers.delta(); if(player.breaktime > selected().block().breaktime){ @@ -145,8 +158,6 @@ public class AndroidInput extends InputHandler{ mousey = ly; }else{ warmup = 0; - //lmousex = Gdx.input.getX(0); - //lmousey = Gdx.input.getY(0); player.breaktime = 0; mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth()); diff --git a/core/src/io/anuke/mindustry/input/Input.java b/core/src/io/anuke/mindustry/input/DesktopInput.java similarity index 71% rename from core/src/io/anuke/mindustry/input/Input.java rename to core/src/io/anuke/mindustry/input/DesktopInput.java index ab3556f007..35dd95f448 100644 --- a/core/src/io/anuke/mindustry/input/Input.java +++ b/core/src/io/anuke/mindustry/input/DesktopInput.java @@ -7,7 +7,6 @@ import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.ItemStack; @@ -20,27 +19,27 @@ import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.utils.Cursors; import io.anuke.ucore.util.Mathf; -public class Input extends InputHandler{ - float mousex, mousey; - float endx, endy; +public class DesktopInput extends InputHandler{ + int mousex, mousey; + int endx, endy; @Override public float getCursorEndX(){ return endx; } @Override public float getCursorEndY(){ return endy; } - @Override public float getCursorX(){ return Graphics.screen(mousex, mousey).x; } - @Override public float getCursorY(){ return Gdx.graphics.getHeight() - Graphics.screen(mousex, mousey).y; } + @Override public float getCursorX(){ return (int)(Graphics.screen(mousex, mousey).x + 2); } + @Override public float getCursorY(){ return (int)(Gdx.graphics.getHeight() - 1 - Graphics.screen(mousex, mousey).y); } @Override public boolean touchDown (int screenX, int screenY, int pointer, int button){ if(button == Buttons.LEFT){ Vector2 vec = Graphics.world(screenX, screenY); - mousex = vec.x; - mousey = vec.y; + mousex = (int)vec.x; + mousey = (int)vec.y; } return false; } public boolean touchUp(int screenX, int screenY, int pointer, int button){ - player.placeMode.tapped(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY()); + player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY()); return false; } @@ -49,15 +48,14 @@ public class Input extends InputHandler{ if(player.isDead()) return; if(!Inputs.buttonDown(Buttons.LEFT)){ - Vector2 vec = Graphics.world(Gdx.input.getX(), Gdx.input.getY()); - mousex = vec.x; - mousey = vec.y; + mousex = (int)Graphics.mouseWorld().x; + mousey = (int)Graphics.mouseWorld().y; } endx = Gdx.input.getX(); endy = Gdx.input.getY(); - if(Inputs.scrolled() && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !Vars.ui.onDialog()){ - Vars.renderer.scaleCamera(Inputs.scroll()); + if(Inputs.scrolled() && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !ui.onDialog()){ + renderer.scaleCamera(Inputs.scroll()); } if(Inputs.scrolled()){ @@ -72,6 +70,12 @@ public class Input extends InputHandler{ player.rotation ++; } + if(Inputs.keyDown("area_delete_mode")){ + player.placeMode = PlaceMode.areaDelete; + }else{ + player.placeMode = PlaceMode.hold; + } + player.rotation = Mathf.mod(player.rotation, 4); for(int i = 0; i < 9; i ++){ @@ -81,19 +85,19 @@ public class Input extends InputHandler{ } } - Tile cursor = Vars.world.tile(tilex(), tiley()); + Tile cursor = world.tile(tilex(), tiley()); if(Inputs.buttonUp(Buttons.LEFT) && cursor != null){ Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor; if(linked != null && linked.block() instanceof Configurable){ - Vars.ui.showConfig(linked); - }else if(!Vars.ui.hasConfigMouse()){ - Vars.ui.hideConfig(); + ui.showConfig(linked); + }else if(!ui.hasConfigMouse()){ + ui.hideConfig(); } } if(Inputs.buttonUp(Buttons.RIGHT)){ - Vars.ui.hideConfig(); + ui.hideConfig(); } if(player.recipe != null && Inputs.buttonUp(Buttons.RIGHT)){ @@ -102,11 +106,11 @@ public class Input extends InputHandler{ } //block breaking - if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && Vars.world.validBreak(tilex(), tiley())){ + if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && validBreak(tilex(), tiley())){ Tile tile = cursor; player.breaktime += Timers.delta(); if(player.breaktime >= tile.getBreakTime()){ - Vars.world.breakBlock(cursor.x, cursor.y); + breakBlock(cursor.x, cursor.y); player.breaktime = 0f; } }else{ @@ -117,16 +121,16 @@ public class Input extends InputHandler{ public void tryPlaceBlock(int x, int y){ if(player.recipe != null && - Vars.world.validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() && - Vars.control.hasItems(player.recipe.requirements)){ + validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() && + control.hasItems(player.recipe.requirements)){ - Vars.world.placeBlock(x, y, player.recipe.result, player.rotation, true); + placeBlock(x, y, player.recipe.result, player.rotation, true); for(ItemStack stack : player.recipe.requirements){ - Vars.control.removeItem(stack); + control.removeItem(stack); } - if(!Vars.control.hasItems(player.recipe.requirements)){ + if(!control.hasItems(player.recipe.requirements)){ Cursors.restoreCursor(); } } diff --git a/core/src/io/anuke/mindustry/input/GestureHandler.java b/core/src/io/anuke/mindustry/input/GestureHandler.java index 50117222f8..bc2274eb8a 100644 --- a/core/src/io/anuke/mindustry/input/GestureHandler.java +++ b/core/src/io/anuke/mindustry/input/GestureHandler.java @@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.ucore.core.Core; import io.anuke.ucore.scene.ui.layout.Unit; -import io.anuke.ucore.util.Mathf; public class GestureHandler extends GestureAdapter{ AndroidInput input; @@ -29,14 +28,10 @@ public class GestureHandler extends GestureAdapter{ @Override public boolean tap (float x, float y, int count, int button) { - if(!ui.hasMouse() && player.recipe != null && - Vars.control.hasItems(player.recipe.requirements) && !Vars.ui.hasMouse() && !input.brokeBlock){ - - player.placeMode.tapped(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize)); - + if(!player.placeMode.pan){ input.mousex = x; input.mousey = y; - return true; + player.placeMode.tapped(input.getBlockX(), input.getBlockY()); } return false; } diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index d77fa356fc..f5c83e089b 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -3,15 +3,29 @@ package io.anuke.mindustry.input; import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.InputAdapter; +import com.badlogic.gdx.math.GridPoint2; +import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.ItemStack; +import io.anuke.mindustry.resource.Recipe; +import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.SpawnPoint; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.Blocks; +import io.anuke.mindustry.world.blocks.ProductionBlocks; import io.anuke.mindustry.world.blocks.types.Configurable; +import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Graphics; +import io.anuke.ucore.core.Sounds; +import io.anuke.ucore.entities.Entities; +import io.anuke.ucore.entities.SolidEntity; import io.anuke.ucore.scene.utils.Cursors; import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Tmp; public abstract class InputHandler extends InputAdapter{ public abstract void update(); @@ -24,6 +38,7 @@ public abstract class InputHandler extends InputAdapter{ public int getBlockEndX(){ return Mathf.sclb(Graphics.world(getCursorEndX(), getCursorEndY()).x, Vars.tilesize, round2()); } public int getBlockEndY(){ return Mathf.sclb(Graphics.world(getCursorEndX(), getCursorEndY()).y, Vars.tilesize, round2()); } public void resetCursor(){} + public boolean drawPlace(){ return true; } public boolean onConfigurable(){ Tile tile = Vars.world.tile(getBlockX(), getBlockY()); @@ -36,10 +51,10 @@ public abstract class InputHandler extends InputAdapter{ public void tryPlaceBlock(int x, int y){ if(player.recipe != null && - Vars.world.validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() && + validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() && Vars.control.hasItems(player.recipe.requirements)){ - Vars.world.placeBlock(x, y, player.recipe.result, player.rotation, true); + placeBlock(x, y, player.recipe.result, player.rotation, true); for(ItemStack stack : player.recipe.requirements){ Vars.control.removeItem(stack); @@ -51,7 +66,178 @@ public abstract class InputHandler extends InputAdapter{ } } + public void tryDeleteBlock(int x, int y){ + if(cursorNear() && validBreak(x, y)){ + breakBlock(x, y); + } + } + public boolean round2(){ return !(player.recipe != null && player.recipe.result.isMultiblock() && player.recipe.result.height % 2 == 0); } + + public boolean validPlace(int x, int y, Block type){ + + for(SpawnPoint spawn : control.getSpawnPoints()){ + if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){ + return false; + } + } + + Tmp.r2.setSize(type.width * Vars.tilesize, type.height * Vars.tilesize); + Vector2 offset = type.getPlaceOffset(); + Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize); + + for(SolidEntity e : Entities.getNearby(control.enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){ + Rectangle rect = e.hitbox.getRect(e.x, e.y); + + if(Tmp.r2.overlaps(rect)){ + return false; + } + } + + if(!Vars.android && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){ + return false; + } + + Tile tile = world.tile(x, y); + + if(tile == null) return false; + + if(!type.isMultiblock() && Vars.control.getTutorial().active() && + Vars.control.getTutorial().showBlock()){ + + GridPoint2 point = Vars.control.getTutorial().getPlacePoint(); + int rotation = Vars.control.getTutorial().getPlaceRotation(); + Block block = Vars.control.getTutorial().getPlaceBlock(); + + if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y + || (rotation != -1 && rotation != Vars.player.rotation)){ + return false; + } + }else if(Vars.control.getTutorial().active()){ + return false; + } + + if(type.isMultiblock()){ + int offsetx = -(type.width-1)/2; + int offsety = -(type.height-1)/2; + for(int dx = 0; dx < type.width; dx ++){ + for(int dy = 0; dy < type.height; dy ++){ + Tile other = world.tile(x + dx + offsetx, y + dy + offsety); + if(other == null || other.block() != Blocks.air){ + return false; + } + } + } + return true; + }else{ + if(tile.block() != type && type.canReplace(tile.block()) && tile.block().isMultiblock() == type.isMultiblock()){ + return true; + } + return tile != null && tile.block() == Blocks.air; + } + } + + public boolean validBreak(int x, int y){ + Tile tile = world.tile(x, y); + + if(tile == null || tile.block() == ProductionBlocks.core) return false; + + if(tile.isLinked() && tile.getLinked().block() == ProductionBlocks.core){ + return false; + } + + if(Vars.control.getTutorial().active()){ + + if(Vars.control.getTutorial().showBlock()){ + GridPoint2 point = Vars.control.getTutorial().getPlacePoint(); + int rotation = Vars.control.getTutorial().getPlaceRotation(); + Block block = Vars.control.getTutorial().getPlaceBlock(); + + if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y + || (rotation != -1 && rotation != Vars.player.rotation)){ + return false; + } + }else{ + return false; + } + } + + return tile.breakable(); + } + + public void placeBlock(int x, int y, Block result, int rotation, boolean effects){ + Tile tile = world.tile(x, y); + + //just in case + if(tile == null) + return; + + tile.setBlock(result, rotation); + + if(result.isMultiblock()){ + int offsetx = -(result.width-1)/2; + int offsety = -(result.height-1)/2; + + for(int dx = 0; dx < result.width; dx ++){ + for(int dy = 0; dy < result.height; dy ++){ + int worldx = dx + offsetx + x; + int worldy = dy + offsety + y; + if(!(worldx == x && worldy == y)){ + Tile toplace = world.tile(worldx, worldy); + toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety)); + } + + if(effects) Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize); + } + } + }else{ + if(effects) Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize); + } + + if(effects) Sounds.play("place"); + } + + public void breakBlock(int x, int y){ + Tile tile = world.tile(x, y); + + if(tile == null) return; + + Block block = tile.isLinked() ? tile.getLinked().block() : tile.block(); + Recipe result = null; + + for(Recipe recipe : Recipe.values()){ + if(recipe.result == block){ + result = recipe; + break; + } + } + + if(result != null){ + for(ItemStack stack : result.requirements){ + Vars.control.addItem(stack.item, (int)(stack.amount * Vars.breakDropAmount)); + } + } + + if(tile.block().drops != null){ + Vars.control.addItem(tile.block().drops.item, tile.block().drops.amount); + } + + Effects.shake(3f, 1f, player); + Sounds.play("break"); + + if(!tile.block().isMultiblock() && !tile.isLinked()){ + tile.setBlock(Blocks.air); + Effects.effect(Fx.breakBlock, tile.worldx(), tile.worldy()); + }else{ + Tile target = tile.isLinked() ? tile.getLinked() : tile; + Array removals = target.getLinkedTiles(); + for(Tile toremove : removals){ + //note that setting a new block automatically unlinks it + toremove.setBlock(Blocks.air); + Effects.effect(Fx.breakBlock, toremove.worldx(), toremove.worldy()); + } + } + } } diff --git a/core/src/io/anuke/mindustry/input/PlaceMode.java b/core/src/io/anuke/mindustry/input/PlaceMode.java index 2ef562b6a2..35c9d207d2 100644 --- a/core/src/io/anuke/mindustry/input/PlaceMode.java +++ b/core/src/io/anuke/mindustry/input/PlaceMode.java @@ -2,12 +2,15 @@ package io.anuke.mindustry.input; import static io.anuke.mindustry.Vars.*; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Colors; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Inputs; @@ -18,25 +21,32 @@ import io.anuke.ucore.util.Tmp; public enum PlaceMode{ cursor{ + { + shown = true; + lockCamera = true; + pan = true; + } + public void draw(int tilex, int tiley, int endx, int endy){ float x = tilex * Vars.tilesize; float y = tiley * Vars.tilesize; - boolean valid = world.validPlace(tilex, tiley, player.recipe.result) && (android || control.getInput().cursorNear()); + boolean valid = control.getInput().validPlace(tilex, tiley, player.recipe.result) && (android || control.getInput().cursorNear()); Vector2 offset = player.recipe.result.getPlaceOffset(); - float si = MathUtils.sin(Timers.time() / 6f) + 1; + float si = MathUtils.sin(Timers.time() / 6f) + 1.5f; - Draw.color(valid ? Color.PURPLE : Color.SCARLET); + Draw.color(valid ? Colors.get("place") : Colors.get("placeInvalid")); Draw.thickness(2f); - Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si, tilesize * player.recipe.result.height + si); + Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si, + tilesize * player.recipe.result.height + si); player.recipe.result.drawPlace(tilex, tiley, player.rotation, valid); Draw.thickness(2f); if(player.recipe.result.rotate){ - Draw.color(Color.ORANGE); + Draw.color(Colors.get("placeRotate")); Tmp.v1.set(7, 0).rotate(player.rotation * 90); Draw.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y); } @@ -46,24 +56,42 @@ public enum PlaceMode{ else Cursors.restoreCursor(); } - }, + + public void tapped(int tilex, int tiley){ + System.out.println("tap " + tilex + " " + tiley); + control.getInput().tryPlaceBlock(tilex, tiley); + } + }, touch{ + { + shown = true; + lockCamera = false; + showRotate = true; + showCancel = true; + } + + public void tapped(int x, int y){ + control.getInput().tryPlaceBlock(x, y); + } + }, + areaDelete{ int maxlen = 10; int tilex; int tiley; int endx; int endy; - int rotation; { + shown = true; lockCamera = true; + delete = true; } public void draw(int tilex, int tiley, int endx, int endy){ - float t = Vars.tilesize; + float t = tilesize; process(tilex, tiley, endx, endy); - int tx = tilex, ty = tiley, ex = endx, ey = endy; + tilex = this.tilex; tiley = this.tiley; endx = this.endx; endy = this.endy; float x = this.tilex * t, y = this.tiley * t, @@ -79,16 +107,124 @@ public enum PlaceMode{ y2 += t/2; } + Draw.color(Colors.get("break")); + Draw.thick(1f); + for(int cx = tilex; cx <= endx; cx ++){ + for(int cy = tiley; cy <= endy; cy ++){ + Tile tile = Vars.world.tile(cx, cy); + if(tile != null && tile.getLinked() != null) + tile = tile.getLinked(); + if(tile != null && control.getInput().validBreak(tile.x, tile.y)){ + Vector2 offset = tile.block().getPlaceOffset(); + Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, + tile.block().width * t, tile.block().height * t); + } + } + } + + Draw.thick(2f); + Draw.color(control.getInput().cursorNear() ? Colors.get("break") : Colors.get("breakInvalid")); + Draw.linerect(x, y, x2 - x, y2 - y); + Draw.alpha(0.3f); + Draw.crect("blank", x, y, x2 - x, y2 - y); + Draw.reset(); + } + + public void released(int tilex, int tiley, int endx, int endy){ + process(tilex, tiley, endx, endy); + tilex = this.tilex; tiley = this.tiley; + endx = this.endx; endy = this.endy; + + for(int cx = tilex; cx <= endx; cx ++){ + for(int cy = tiley; cy <= endy; cy ++){ + control.getInput().tryDeleteBlock(cx, cy); + } + } + } + + void process(int tilex, int tiley, int endx, int endy){ + + if(Math.abs(endx - tilex) > maxlen){ + endx = Mathf.sign(endx - tilex) * maxlen + tilex; + } + + if(Math.abs(endy - tiley) > maxlen){ + endy = Mathf.sign(endy - tiley) * maxlen + tiley; + } + + if(endx < tilex){ + int t = endx; + endx = tilex; + tilex = t; + } + if(endy < tiley){ + int t = endy; + endy = tiley; + tiley = t; + } + + this.endx = endx; + this.endy = endy; + this.tilex = tilex; + this.tiley = tiley; + } + }, + hold{ //TODO multiblock support! + int maxlen = 10; + int tilex; + int tiley; + int endx; + int endy; + int rotation; + + { + lockCamera = true; + shown = true; + showCancel = true; + showRotate = true; + } + + public void draw(int tilex, int tiley, int endx, int endy){ + if(Vars.android && !Gdx.input.isTouched(0)){ + return; + } + + float t = Vars.tilesize; + Block block = player.recipe.result; + Vector2 offset = block.getPlaceOffset(); + + process(tilex, tiley, endx, endy); + int tx = tilex, ty = tiley, ex = endx, ey = endy; + tilex = this.tilex; tiley = this.tiley; + endx = this.endx; endy = this.endy; + float x = this.tilex * t, y = this.tiley * t, + x2 = this.endx * t, y2 = this.endy * t; + + if(x2 >= x){ + x -= block.width * t/2; + x2 += block.width * t/2; + } + + if(y2 >= y){ + y -= block.height * t/2; + y2 += block.height * t/2; + } + + x += offset.x; + y += offset.y; + x2 += offset.x; + y2 += offset.y; + if(tilex == endx && tiley == endy){ cursor.draw(tilex, tiley, endx, endy); }else{ Draw.thick(2f); - Draw.color(control.getInput().cursorNear() ? Color.PURPLE : Color.RED); + Draw.color(control.getInput().cursorNear() ? Colors.get("place") : Colors.get("placeInvalid")); Draw.linerect(x, y, x2 - x, y2 - y); Draw.alpha(0.3f); Draw.crect("blank", x, y, x2 - x, y2 - y); - - Draw.color(Color.RED); + + Draw.color(Colors.get("placeInvalid")); int amount = 1; for(int cx = 0; cx <= Math.abs(endx - tilex); cx ++){ @@ -96,17 +232,17 @@ public enum PlaceMode{ int px = tx + cx * Mathf.sign(ex - tx), py = ty + cy * Mathf.sign(ey - ty); - if(!world.validPlace(px, py, player.recipe.result) + if(!control.getInput().validPlace(px, py, player.recipe.result) || !control.hasItems(player.recipe.requirements, amount)){ - Draw.square(px * t, py * t, t/2); + Draw.linecrect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height); } amount ++; } } if(player.recipe.result.rotate){ - float cx = tilex * t, cy = tiley * t; - Draw.color(Color.ORANGE); + float cx = tx * t, cy = ty * t; + Draw.color(Colors.get("placeRotate")); Tmp.v1.set(7, 0).rotate(rotation * 90); Draw.line(cx, cy, cx + Tmp.v1.x, cy + Tmp.v1.y); } @@ -114,11 +250,8 @@ public enum PlaceMode{ } } - public void tapped(int tilex, int tiley, int endx, int endy){ - int prev = player.rotation; + public void released(int tilex, int tiley, int endx, int endy){ process(tilex, tiley, endx, endy); - //tilex = this.tilex; tiley = this.tiley; - //endx = this.endx; endy = this.endy; player.rotation = this.rotation; @@ -129,9 +262,6 @@ public enum PlaceMode{ tiley + y * Mathf.sign(endy - tiley)); } } - - player.rotation = prev; - } void process(int tilex, int tiley, int endx, int endy){ @@ -181,7 +311,7 @@ public enum PlaceMode{ public void draw(int tilex, int tiley, int endx, int endy){ Tile tile = world.tile(tilex, tiley); - if(tile != null && world.validBreak(tilex, tiley)){ + if(tile != null && control.getInput().validBreak(tilex, tiley)){ if(tile.isLinked()) tile = tile.getLinked(); Vector2 offset = tile.block().getPlaceOffset(); @@ -191,20 +321,29 @@ public enum PlaceMode{ Draw.color(Color.YELLOW, Color.SCARLET, fract); Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize); }else if(android && player.breaktime > 0){ - Draw.color(Color.YELLOW, Color.SCARLET, fract); - Draw.circle(tile.worldx(), tile.worldy(), 4 + (1f - fract) * 26); + Draw.color(Colors.get("breakStart"), Colors.get("break"), fract); + Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26); } Draw.reset(); } } }; public boolean lockCamera; + public boolean pan = false; + public boolean shown = false; + public boolean showRotate; + public boolean showCancel; + public boolean delete = false; public void draw(int tilex, int tiley, int endx, int endy){ } - public void tapped(int tilex, int tiley, int endx, int endy){ + public void released(int tilex, int tiley, int endx, int endy){ + + } + + public void tapped(int x, int y){ } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index e276f1e2b9..897b33de25 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -14,7 +14,6 @@ import io.anuke.mindustry.world.GameMode; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Settings; -import io.anuke.ucore.function.StringSupplier; import io.anuke.ucore.scene.actions.Actions; import io.anuke.ucore.scene.builders.imagebutton; import io.anuke.ucore.scene.builders.label; @@ -25,7 +24,6 @@ import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.layout.Cell; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Unit; -import io.anuke.ucore.util.Profiler; public class HudFragment implements Fragment{ private Table itemtable, respawntable; @@ -137,26 +135,14 @@ public class HudFragment implements Fragment{ new table(){{ abottom(); aleft(); - new label((StringSupplier)()->"[purple]tiles: " + Vars.control.tileGroup.amount()).left(); + new label(()->"[purple]tiles: " + Vars.control.tileGroup.amount()).left(); row(); - new label((StringSupplier)()->"[purple]enemies: " + Vars.control.enemyGroup.amount()).left(); + new label(()->"[purple]enemies: " + Vars.control.enemyGroup.amount()).left(); row(); - new label((StringSupplier)()->"[orange]noclip: " + Vars.noclip).left(); + new label(()->"[orange]noclip: " + Vars.noclip).left(); row(); new label("[red]DEBUG MODE").scale(0.5f).left(); }}.end(); - - if(profile){ - new table(){{ - atop(); - new table("button"){{ - defaults().left().growX(); - atop(); - aleft(); - new label((StringSupplier)()->Profiler.formatDisplayTimes()); - }}.width(400f).units(Unit.dp).end(); - }}.end(); - } } } @@ -188,8 +174,6 @@ public class HudFragment implements Fragment{ }}.left().end(); playButton(uheight); - //get().padTop(Unit.dp.inPixels(1)); - //get().padBottom(Unit.dp.inPixels(1)); }}.height(uheight).units(Unit.dp).fillX().expandX().end(); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 9b1bd0c0ca..4e20bc3c12 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -8,7 +8,6 @@ import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.input.PlaceMode; import io.anuke.ucore.scene.builders.imagebutton; -import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.ui.ButtonGroup; @@ -28,8 +27,8 @@ public class PlacementFragment implements Fragment{ new table("pane"){{ get().setTouchable(Touchable.enabled); - new label(()->"Placement Mode: [orange]" + player.placeMode.name()).pad(4).units(Unit.dp); - row(); + //new label(()->"Placement Mode: [orange]" + player.placeMode.name()).pad(4).units(Unit.dp); + //row(); aleft(); @@ -37,19 +36,28 @@ public class PlacementFragment implements Fragment{ aleft(); ButtonGroup group = new ButtonGroup<>(); - defaults().size(58, 62).pad(6).units(Unit.dp); + defaults().size(52, 56).pad(0).units(Unit.dp); + + int d = 0; for(PlaceMode mode : PlaceMode.values()){ + if(!mode.shown) continue; + new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.inPixels(10*3), ()->{ + control.getInput().resetCursor(); player.placeMode = mode; }){{ group.add(get()); - }}; + }}.padBottom(-5.5f).units(Unit.dp); + + if(++d % 2 == 0){ + row(); + } } new imagebutton("icon-cancel", Unit.dp.inPixels(14*3), ()->{ player.recipe = null; - }).visible(()->player.recipe != null && player.placeMode == PlaceMode.touch); + }).visible(()->player.recipe != null && player.placeMode.showCancel); new imagebutton("icon-rotate-arrow", Unit.dp.inPixels(14*3), ()->{ player.rotation ++; @@ -57,7 +65,7 @@ public class PlacementFragment implements Fragment{ }).update(i->{ i.getImage().setOrigin(Align.center); i.getImage().setRotation(player.rotation*90); - }).visible(()->player.recipe != null && player.placeMode == PlaceMode.touch + }).visible(() -> player.recipe != null && player.placeMode.showRotate && player.recipe.result.rotate); }}.left().end(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java index 6bd0a66536..743eddec8e 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java @@ -27,8 +27,7 @@ public class ToolFragment implements Fragment{ }); tools.addIButton("icon-check", Unit.dp.inPixels(42), ()->{ - player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY(), - control.getInput().getBlockEndX(), control.getInput().getBlockEndY()); + player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY()); }); Core.scene.add(tools); 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 74e9e6dc2e..6ab0c04e03 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 @@ -17,7 +17,6 @@ import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; -//TODO public class Sorter extends Junction implements Configurable{ public Sorter(String name) {