diff --git a/core/assets-raw/sprites/blocks/blackrock1.png b/core/assets-raw/sprites/blocks/blackrock1.png new file mode 100644 index 0000000000..8a3b7f166b Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackrock1.png differ diff --git a/core/assets-raw/sprites/blocks/blackrockshadow1.png b/core/assets-raw/sprites/blocks/blackrockshadow1.png new file mode 100644 index 0000000000..fcf89d8970 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackrockshadow1.png differ diff --git a/core/assets-raw/sprites/blocks/blackstone1.png b/core/assets-raw/sprites/blocks/blackstone1.png new file mode 100644 index 0000000000..42266645c8 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstone1.png differ diff --git a/core/assets-raw/sprites/blocks/blackstone2.png b/core/assets-raw/sprites/blocks/blackstone2.png new file mode 100644 index 0000000000..e62cc82c15 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstone2.png differ diff --git a/core/assets-raw/sprites/blocks/blackstone3.png b/core/assets-raw/sprites/blocks/blackstone3.png new file mode 100644 index 0000000000..10f3b44734 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstone3.png differ diff --git a/core/assets-raw/sprites/blocks/blackstoneblock1.png b/core/assets-raw/sprites/blocks/blackstoneblock1.png new file mode 100644 index 0000000000..ceac507a11 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstoneblock1.png differ diff --git a/core/assets-raw/sprites/blocks/blackstoneblock2.png b/core/assets-raw/sprites/blocks/blackstoneblock2.png new file mode 100644 index 0000000000..0e804da468 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstoneblock2.png differ diff --git a/core/assets-raw/sprites/blocks/blackstoneblock3.png b/core/assets-raw/sprites/blocks/blackstoneblock3.png new file mode 100644 index 0000000000..ebe4fb638d Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstoneblock3.png differ diff --git a/core/assets-raw/sprites/blocks/blackstoneedge.png b/core/assets-raw/sprites/blocks/blackstoneedge.png new file mode 100644 index 0000000000..945f4efdd8 Binary files /dev/null and b/core/assets-raw/sprites/blocks/blackstoneedge.png differ diff --git a/core/assets-raw/sprites/blocks/grassblock-edge-0.png b/core/assets-raw/sprites/blocks/grassblock-edge-0.png new file mode 100644 index 0000000000..637f3bbab0 Binary files /dev/null and b/core/assets-raw/sprites/blocks/grassblock-edge-0.png differ diff --git a/core/assets-raw/sprites/blocks/grassblock-edge-1.png b/core/assets-raw/sprites/blocks/grassblock-edge-1.png new file mode 100644 index 0000000000..f5b8c5f503 Binary files /dev/null and b/core/assets-raw/sprites/blocks/grassblock-edge-1.png differ diff --git a/core/assets-raw/sprites/blocks/grassblock-edge-2.png b/core/assets-raw/sprites/blocks/grassblock-edge-2.png new file mode 100644 index 0000000000..88860d981f Binary files /dev/null and b/core/assets-raw/sprites/blocks/grassblock-edge-2.png differ diff --git a/core/assets-raw/sprites/blocks/grassblock-edge-3.png b/core/assets-raw/sprites/blocks/grassblock-edge-3.png new file mode 100644 index 0000000000..b087d0c2f2 Binary files /dev/null and b/core/assets-raw/sprites/blocks/grassblock-edge-3.png differ diff --git a/core/assets-raw/sprites/blocks/grassblock.png b/core/assets-raw/sprites/blocks/grassblock1.png similarity index 51% rename from core/assets-raw/sprites/blocks/grassblock.png rename to core/assets-raw/sprites/blocks/grassblock1.png index 1263fd50b9..9738aee34f 100644 Binary files a/core/assets-raw/sprites/blocks/grassblock.png and b/core/assets-raw/sprites/blocks/grassblock1.png differ diff --git a/core/assets-raw/sprites/blocks/rock.png b/core/assets-raw/sprites/blocks/rock1.png similarity index 100% rename from core/assets-raw/sprites/blocks/rock.png rename to core/assets-raw/sprites/blocks/rock1.png diff --git a/core/assets-raw/sprites/blocks/rockshadow.png b/core/assets-raw/sprites/blocks/rockshadow1.png similarity index 100% rename from core/assets-raw/sprites/blocks/rockshadow.png rename to core/assets-raw/sprites/blocks/rockshadow1.png diff --git a/core/assets-raw/sprites/blocks/rock2shadow.png b/core/assets-raw/sprites/blocks/rockshadow2.png similarity index 100% rename from core/assets-raw/sprites/blocks/rock2shadow.png rename to core/assets-raw/sprites/blocks/rockshadow2.png diff --git a/core/assets-raw/sprites/blocks/stone1.png b/core/assets-raw/sprites/blocks/stone1.png index 71457fcfff..ba1dd7c5a7 100644 Binary files a/core/assets-raw/sprites/blocks/stone1.png and b/core/assets-raw/sprites/blocks/stone1.png differ diff --git a/core/assets-raw/sprites/blocks/stone2.png b/core/assets-raw/sprites/blocks/stone2.png index c655c1abd4..19f4ea319e 100644 Binary files a/core/assets-raw/sprites/blocks/stone2.png and b/core/assets-raw/sprites/blocks/stone2.png differ diff --git a/core/assets-raw/sprites/blocks/stoneblock-edge-0.png b/core/assets-raw/sprites/blocks/stoneblock-edge-0.png new file mode 100644 index 0000000000..6a3a9bb5fc Binary files /dev/null and b/core/assets-raw/sprites/blocks/stoneblock-edge-0.png differ diff --git a/core/assets-raw/sprites/blocks/stoneblock-edge-1.png b/core/assets-raw/sprites/blocks/stoneblock-edge-1.png new file mode 100644 index 0000000000..ac7dc1b2bc Binary files /dev/null and b/core/assets-raw/sprites/blocks/stoneblock-edge-1.png differ diff --git a/core/assets-raw/sprites/blocks/stoneblock-edge-2.png b/core/assets-raw/sprites/blocks/stoneblock-edge-2.png new file mode 100644 index 0000000000..f04fc23d9c Binary files /dev/null and b/core/assets-raw/sprites/blocks/stoneblock-edge-2.png differ diff --git a/core/assets-raw/sprites/blocks/stoneblock-edge-3.png b/core/assets-raw/sprites/blocks/stoneblock-edge-3.png new file mode 100644 index 0000000000..4ab05cd11e Binary files /dev/null and b/core/assets-raw/sprites/blocks/stoneblock-edge-3.png differ diff --git a/core/assets-raw/sprites/blocks/stoneblock-smooth1.png b/core/assets-raw/sprites/blocks/stoneblock-smooth1.png new file mode 100644 index 0000000000..181d85bcd0 Binary files /dev/null and b/core/assets-raw/sprites/blocks/stoneblock-smooth1.png differ diff --git a/core/assets-raw/sprites/blocks/stoneblock.png b/core/assets-raw/sprites/blocks/stoneblock.png deleted file mode 100644 index 37510d29e5..0000000000 Binary files a/core/assets-raw/sprites/blocks/stoneblock.png and /dev/null differ diff --git a/core/assets-raw/sprites/blocks/stoneblock1.png b/core/assets-raw/sprites/blocks/stoneblock1.png new file mode 100644 index 0000000000..0783b4b26f Binary files /dev/null and b/core/assets-raw/sprites/blocks/stoneblock1.png differ diff --git a/core/assets/maps/canyon.png b/core/assets/maps/canyon.png index ab4521e23d..7240a5a5f5 100644 Binary files a/core/assets/maps/canyon.png and b/core/assets/maps/canyon.png differ diff --git a/core/assets/maps/volcano.png b/core/assets/maps/volcano.png new file mode 100644 index 0000000000..77b5212411 Binary files /dev/null and b/core/assets/maps/volcano.png differ diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 4f7cbdb16d..6b1f113a62 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -13,18 +13,81 @@ backgrounds/background index: -1 blank rotate: false - xy: 383, 391 + xy: 473, 386 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 -blocks/block +blocks/blackrock1 + rotate: false + xy: 230, 67 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackrockshadow1 rotate: false xy: 240, 67 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 +blocks/blackstone1 + rotate: false + xy: 450, 480 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackstone2 + rotate: false + xy: 343, 199 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackstone3 + rotate: false + xy: 450, 470 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackstoneblock1 + rotate: false + xy: 333, 197 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackstoneblock2 + rotate: false + xy: 343, 189 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackstoneblock3 + rotate: false + xy: 333, 187 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/blackstoneedge + rotate: false + xy: 499, 499 + size: 12, 12 + orig: 12, 12 + offset: 0, 0 + index: -1 +blocks/block + rotate: false + xy: 443, 303 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 blocks/block-2x2 rotate: false xy: 194, 15 @@ -55,98 +118,98 @@ blocks/chainturret-icon index: -1 blocks/coal1 rotate: false - xy: 343, 199 + xy: 443, 283 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal2 rotate: false - xy: 450, 470 + xy: 439, 273 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal3 rotate: false - xy: 333, 197 + xy: 439, 263 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coaldrill rotate: false - xy: 343, 189 + xy: 439, 253 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator rotate: false - xy: 333, 187 + xy: 232, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalpurifier rotate: false - xy: 457, 355 + xy: 232, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/combustiongenerator rotate: false - xy: 467, 355 + xy: 242, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/compositewall rotate: false - xy: 443, 313 + xy: 242, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduit rotate: false - xy: 443, 303 + xy: 469, 355 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitbottom rotate: false - xy: 443, 293 + xy: 449, 273 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitliquid rotate: false - xy: 443, 283 + xy: 449, 263 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduittop rotate: false - xy: 439, 273 + xy: 449, 253 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyor rotate: false - xy: 439, 263 + xy: 476, 415 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyormove rotate: false - xy: 439, 253 + xy: 476, 405 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -160,70 +223,70 @@ blocks/core index: -1 blocks/cross rotate: false - xy: 232, 11 + xy: 476, 395 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/crucible rotate: false - xy: 232, 1 + xy: 476, 385 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/deepwater rotate: false - xy: 242, 13 + xy: 473, 375 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt1 rotate: false - xy: 242, 3 + xy: 473, 365 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt2 rotate: false - xy: 470, 431 + xy: 479, 355 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt3 rotate: false - xy: 480, 431 + xy: 367, 174 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirtblock rotate: false - xy: 449, 273 + xy: 483, 375 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirtedge rotate: false - xy: 499, 499 + xy: 499, 485 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/doubleturret rotate: false - xy: 470, 453 + xy: 456, 425 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/duriumwall rotate: false - xy: 449, 263 + xy: 483, 365 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -237,112 +300,140 @@ blocks/duriumwall-large index: -1 blocks/duriumwall-large-icon rotate: false - xy: 449, 253 + xy: 489, 355 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/flameturret rotate: false - xy: 456, 425 + xy: 452, 413 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/fluxpump rotate: false - xy: 476, 411 + xy: 415, 198 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass1 rotate: false - xy: 476, 401 + xy: 427, 217 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass2 rotate: false - xy: 476, 391 + xy: 425, 207 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass3 rotate: false - xy: 490, 431 + xy: 425, 197 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/grassblock +blocks/grassblock-edge-0 rotate: false - xy: 486, 421 + xy: 413, 178 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/grassblock-edge-1 + rotate: false + xy: 423, 177 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/grassblock-edge-2 + rotate: false + xy: 443, 341 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/grassblock-edge-3 + rotate: false + xy: 453, 343 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/grassblock1 + rotate: false + xy: 415, 188 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock2 rotate: false - xy: 486, 411 + xy: 425, 187 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassedge rotate: false - xy: 353, 195 + xy: 353, 181 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/iron1 rotate: false - xy: 473, 369 + xy: 503, 431 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 483, 381 + xy: 503, 421 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 483, 371 + xy: 503, 411 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 493, 381 + xy: 503, 401 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 503, 381 + xy: 503, 391 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 493, 371 + xy: 503, 381 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/laserturret rotate: false - xy: 449, 365 + xy: 317, 131 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -356,70 +447,70 @@ blocks/lava index: -1 blocks/lavaedge rotate: false - xy: 353, 181 + xy: 399, 179 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/lavasmelter rotate: false - xy: 415, 215 + xy: 503, 361 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquiditemjunction rotate: false - xy: 415, 205 + xy: 503, 351 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidjunction rotate: false - xy: 415, 195 + xy: 503, 341 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidrouter rotate: false - xy: 425, 217 + xy: 493, 443 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/machineturret rotate: false - xy: 445, 353 + xy: 329, 131 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/megarepairturret rotate: false - xy: 317, 131 + xy: 341, 131 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mortarturret rotate: false - xy: 329, 131 + xy: 230, 21 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mossblock rotate: false - xy: 425, 197 + xy: 493, 423 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 425, 197 + xy: 493, 423 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -433,7 +524,7 @@ blocks/nuclearreactor index: -1 blocks/nuclearreactor-icon rotate: false - xy: 343, 159 + xy: 493, 403 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -447,224 +538,224 @@ blocks/nuclearreactor-small index: -1 blocks/oil rotate: false - xy: 409, 169 + xy: 493, 393 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/oiledge rotate: false - xy: 399, 179 + xy: 460, 465 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/oilrefinery rotate: false - xy: 443, 341 + xy: 493, 383 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 301, 124 + xy: 493, 373 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/plasmaturret rotate: false - xy: 341, 131 + xy: 242, 23 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/powerbooster rotate: false - xy: 439, 243 + xy: 301, 124 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyor rotate: false - xy: 449, 243 + xy: 439, 243 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyormove rotate: false - xy: 433, 233 + xy: 449, 243 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaser rotate: false - xy: 443, 233 + xy: 433, 233 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaserrouter rotate: false - xy: 453, 233 + xy: 443, 233 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduit rotate: false - xy: 435, 223 + xy: 453, 233 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduitbottom rotate: false - xy: 435, 213 + xy: 437, 223 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduittop rotate: false - xy: 445, 223 + xy: 447, 223 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 435, 203 + xy: 437, 213 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/repairturret rotate: false - xy: 230, 21 + xy: 464, 413 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 -blocks/rock +blocks/rock1 rotate: false - xy: 445, 203 + xy: 435, 203 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 - rotate: false - xy: 455, 223 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/rock2shadow - rotate: false - xy: 455, 213 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/rockshadow - rotate: false - xy: 455, 203 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/router rotate: false xy: 435, 193 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/rtgenerator +blocks/rockshadow1 + rotate: false + xy: 445, 203 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/rockshadow2 rotate: false xy: 445, 193 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 +blocks/router + rotate: false + xy: 457, 223 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/rtgenerator + rotate: false + xy: 457, 213 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 blocks/shadow - rotate: false - xy: 242, 23 - size: 10, 10 - orig: 10, 10 - offset: 0, 0 - index: -1 -blocks/shieldgenerator - rotate: false - xy: 425, 187 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/shotgunturret - rotate: false - xy: 464, 413 - size: 10, 10 - orig: 10, 10 - offset: 0, 0 - index: -1 -blocks/shrub - rotate: false - xy: 445, 183 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/shrubshadow - rotate: false - xy: 455, 183 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/smelter - rotate: false - xy: 425, 177 - size: 8, 8 - orig: 8, 8 - offset: 0, 0 - index: -1 -blocks/sniperturret rotate: false xy: 464, 401 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 +blocks/shieldgenerator + rotate: false + xy: 455, 193 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/shotgunturret + rotate: false + xy: 464, 389 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 +blocks/shrub + rotate: false + xy: 455, 183 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/shrubshadow + rotate: false + xy: 433, 173 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/smelter + rotate: false + xy: 443, 173 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/sniperturret + rotate: false + xy: 461, 377 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 blocks/sorter rotate: false - xy: 435, 173 + xy: 453, 173 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyor rotate: false - xy: 445, 173 + xy: 252, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 455, 173 + xy: 252, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 252, 13 + xy: 343, 165 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -678,105 +769,140 @@ blocks/steelwall-large index: -1 blocks/steelwall-large-icon rotate: false - xy: 252, 3 + xy: 353, 171 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone rotate: false - xy: 474, 465 + xy: 456, 451 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/stone1 rotate: false - xy: 457, 345 + xy: 353, 161 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 467, 345 + xy: 353, 151 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 477, 359 + xy: 353, 141 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/stoneblock +blocks/stoneblock-edge-0 rotate: false - xy: 477, 349 + xy: 363, 144 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/stoneblock-edge-1 + rotate: false + xy: 363, 134 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/stoneblock-edge-2 + rotate: false + xy: 373, 164 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/stoneblock-edge-3 + rotate: false + xy: 373, 154 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/stoneblock-smooth1 + rotate: false + xy: 373, 144 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 +blocks/stoneblock1 + rotate: false + xy: 353, 131 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 487, 361 + xy: 363, 164 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 487, 351 + xy: 363, 154 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 497, 361 + xy: 373, 134 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneedge rotate: false - xy: 456, 451 + xy: 456, 437 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/stoneformer rotate: false - xy: 497, 351 + xy: 383, 167 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonewall rotate: false - xy: 477, 339 + xy: 383, 157 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter rotate: false - xy: 487, 341 + xy: 383, 147 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter-top rotate: false - xy: 497, 341 + xy: 383, 137 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/thermalgenerator rotate: false - xy: 419, 167 + xy: 393, 167 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -790,56 +916,56 @@ blocks/titancannon index: -1 blocks/titancannon-icon rotate: false - xy: 464, 389 + xy: 461, 365 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 487, 331 + xy: 393, 157 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 497, 331 + xy: 393, 147 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 246, 121 + xy: 393, 137 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 256, 122 + xy: 403, 169 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumpurifier rotate: false - xy: 266, 122 + xy: 413, 168 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumshieldwall rotate: false - xy: 276, 122 + xy: 423, 167 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 286, 122 + xy: 403, 159 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -853,70 +979,70 @@ blocks/titaniumwall-large index: -1 blocks/titaniumwall-large-icon rotate: false - xy: 311, 121 + xy: 403, 149 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/turret rotate: false - xy: 461, 377 + xy: 457, 353 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/uranium1 rotate: false - xy: 341, 121 + xy: 413, 148 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium2 rotate: false - xy: 351, 121 + xy: 423, 157 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium3 rotate: false - xy: 256, 112 + xy: 433, 163 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uraniumdrill rotate: false - xy: 266, 112 + xy: 443, 163 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/water rotate: false - xy: 276, 112 + xy: 453, 163 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/wateredge rotate: false - xy: 456, 437 + xy: 470, 451 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 blocks/waveturret rotate: false - xy: 461, 365 + xy: 468, 425 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 bullet rotate: false - xy: 450, 480 + xy: 443, 293 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1000,14 +1126,14 @@ enemies/targetenemy-t1 index: -1 enemies/enemy-t2 rotate: false - xy: 499, 485 + xy: 499, 471 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 enemies/enemy-t3 rotate: false - xy: 499, 471 + xy: 353, 195 size: 12, 12 orig: 12, 12 offset: 0, 0 @@ -1161,56 +1287,56 @@ enemies/titanenemy-t3 index: -1 enemyarrow rotate: false - xy: 367, 175 + xy: 417, 218 size: 8, 7 orig: 8, 7 offset: 0, 0 index: -1 icon-coal rotate: false - xy: 486, 401 + xy: 463, 343 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-dirium rotate: false - xy: 486, 391 + xy: 473, 345 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-iron rotate: false - xy: 496, 421 + xy: 483, 345 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-steel rotate: false - xy: 496, 411 + xy: 493, 345 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-stone rotate: false - xy: 496, 401 + xy: 503, 461 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-titanium rotate: false - xy: 496, 391 + xy: 503, 451 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-uranium rotate: false - xy: 473, 379 + xy: 503, 441 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1231,35 +1357,35 @@ laserend index: -1 mechs/player rotate: false - xy: 460, 465 + xy: 474, 465 size: 12, 12 orig: 12, 12 offset: 0, 0 index: -1 shell rotate: false - xy: 455, 193 + xy: 455, 203 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot rotate: false - xy: 415, 185 + xy: 435, 183 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot-long rotate: false - xy: 435, 183 + xy: 445, 183 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 titanshell rotate: false - xy: 321, 121 + xy: 413, 158 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1358,21 +1484,21 @@ ui/clear index: -1 ui/cursor rotate: false - xy: 468, 425 + xy: 377, 178 size: 4, 4 orig: 4, 4 offset: 0, 0 index: -1 ui/icon-arrow-left rotate: false - xy: 452, 413 + xy: 470, 439 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-arrow-right rotate: false - xy: 470, 441 + xy: 452, 401 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1414,35 +1540,35 @@ ui/icon-close-over index: -1 ui/icon-crafting rotate: false - xy: 452, 401 + xy: 452, 389 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-cursor rotate: false - xy: 452, 389 + xy: 449, 377 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-defense rotate: false - xy: 449, 377 + xy: 333, 175 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-distribution rotate: false - xy: 333, 175 + xy: 435, 323 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-info rotate: false - xy: 435, 323 + xy: 431, 311 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1456,21 +1582,21 @@ ui/icon-load index: -1 ui/icon-menu rotate: false - xy: 431, 311 + xy: 431, 299 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-pause rotate: false - xy: 431, 299 + xy: 431, 287 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-play rotate: false - xy: 431, 287 + xy: 427, 275 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1484,14 +1610,14 @@ ui/icon-play-2 index: -1 ui/icon-power rotate: false - xy: 427, 275 + xy: 427, 263 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icon-production rotate: false - xy: 427, 263 + xy: 427, 251 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1512,7 +1638,7 @@ ui/icon-rotate-arrow index: -1 ui/icon-settings rotate: false - xy: 427, 251 + xy: 484, 453 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1526,7 +1652,7 @@ ui/icon-tools index: -1 ui/icon-touch rotate: false - xy: 482, 453 + xy: 449, 365 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1540,7 +1666,7 @@ ui/icon-tutorial index: -1 ui/icon-weapon rotate: false - xy: 482, 441 + xy: 445, 353 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1611,14 +1737,14 @@ ui/scroll-knob-vertical index: -1 ui/selection rotate: false - xy: 311, 131 + xy: 383, 391 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 ui/separator rotate: false - xy: 314, 131 + xy: 194, 35 size: 1, 1 orig: 1, 1 offset: 0, 0 @@ -1755,42 +1881,42 @@ ui/window-empty index: -1 weapons/blaster rotate: false - xy: 230, 67 + xy: 443, 313 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/flamer rotate: false - xy: 476, 421 + xy: 415, 208 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/mortar rotate: false - xy: 425, 207 + xy: 493, 433 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/multigun rotate: false - xy: 399, 169 + xy: 493, 413 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/railgun rotate: false - xy: 445, 213 + xy: 447, 213 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/triblaster rotate: false - xy: 331, 121 + xy: 403, 139 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index bd59694131..19b547ce51 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 172d84d5e9..50a17523c1 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -9,6 +9,7 @@ import io.anuke.mindustry.core.*; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.io.Formatter; import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.*; import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; @@ -41,6 +42,7 @@ public class Mindustry extends ModuleCore { @Override public void init(){ + module(Vars.world = new World()); module(Vars.control = new Control()); module(Vars.renderer = new Renderer()); module(Vars.ui = new UI()); diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index b4edd72ee3..a414bb24f4 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -7,6 +7,7 @@ import io.anuke.mindustry.core.Control; import io.anuke.mindustry.core.Renderer; import io.anuke.mindustry.core.UI; import io.anuke.mindustry.entities.Player; +import io.anuke.mindustry.world.World; import io.anuke.ucore.scene.ui.layout.Unit; public class Vars{ @@ -59,6 +60,7 @@ public class Vars{ public static Control control; public static Renderer renderer; public static UI ui; + public static World world; public static Player player; diff --git a/core/src/io/anuke/mindustry/ai/MHueristic.java b/core/src/io/anuke/mindustry/ai/MHueristic.java index 9b663363ad..fed6e45b61 100644 --- a/core/src/io/anuke/mindustry/ai/MHueristic.java +++ b/core/src/io/anuke/mindustry/ai/MHueristic.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.ai.pfa.Heuristic; import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; public class MHueristic implements Heuristic{ //so this means that the cost of going through solids is 10x going through non solids @@ -23,7 +22,7 @@ public class MHueristic implements Heuristic{ if(other.breakable() && other.block().solid) cost += Vars.tilesize*multiplier; for(int dx = -1; dx <= 1; dx ++){ for(int dy = -1; dy <= 1; dy ++){ - Tile tile = World.tile(node.x + dx, node.y + dy); + Tile tile = Vars.world.tile(node.x + dx, node.y + dy); if(tile != null && tile.solid()){ cost += Vars.tilesize*5; } diff --git a/core/src/io/anuke/mindustry/ai/PassTileGraph.java b/core/src/io/anuke/mindustry/ai/PassTileGraph.java index 161d245390..e04f8471cf 100644 --- a/core/src/io/anuke/mindustry/ai/PassTileGraph.java +++ b/core/src/io/anuke/mindustry/ai/PassTileGraph.java @@ -4,8 +4,8 @@ import com.badlogic.gdx.ai.pfa.Connection; import com.badlogic.gdx.ai.pfa.indexed.IndexedGraph; import com.badlogic.gdx.utils.Array; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; /**Tilegraph that ignores player-made tiles.*/ public class PassTileGraph implements IndexedGraph{ private Array> tempConnections = new Array>(); @@ -27,11 +27,11 @@ public class PassTileGraph implements IndexedGraph{ @Override public int getIndex(Tile node){ - return node.x+node.y*World.worldsize; + return node.id(); } @Override public int getNodeCount(){ - return World.worldsize*World.worldsize; + return Vars.world.width() * Vars.world.height(); } } diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index 4e7b3a6e00..3f2b34cdaf 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -1,40 +1,41 @@ package io.anuke.mindustry.ai; -import com.badlogic.gdx.ai.pfa.PathFinder; +import com.badlogic.gdx.ai.pfa.PathFinderRequest; import com.badlogic.gdx.ai.pfa.PathSmoother; import com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder; 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.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.Enemy; +import io.anuke.mindustry.world.SpawnPoint; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; -import io.anuke.ucore.core.Effects; import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Tmp; + public class Pathfind{ - static MHueristic heuristic = new MHueristic(); - static PassTileGraph passgraph = new PassTileGraph(); - static PathFinder passpathfinder; - static Array paths = new Array<>(); - static Tile[][] pathSequences; - static PathSmoother smoother = new PathSmoother(new Raycaster()); - static Vector2 vector = new Vector2(); + private static final long ms = 1000000; - static public Vector2 find(Enemy enemy){ + MHueristic heuristic = new MHueristic(); + PassTileGraph graph = new PassTileGraph(); + PathSmoother smoother = new PathSmoother(new Raycaster()); + Vector2 vector = new Vector2(); + + public Vector2 find(Enemy enemy){ if(enemy.node == -1){ findNode(enemy); } + if(enemy.path == null){ + return vector.set(enemy.x, enemy.y); + } + //-1 is only possible here if both pathfindings failed, which should NOT happen //check graph code Tile[] path = enemy.path; - //REPRODUCE BUG: load in test map, then load save 1 + //REPRODUCE BUG: load in test map, then load save 1? Tile prev = path[enemy.node - 1]; Tile target = path[enemy.node]; @@ -77,19 +78,41 @@ public class Pathfind{ } - static public void reset(){ - paths.clear(); - pathSequences = null; - passpathfinder = new IndexedAStarPathFinder(passgraph); + public void update(){ + + for(SpawnPoint point : Vars.control.getSpawnPoints()){ + if(!point.request.pathFound){ + if(point.finder.search(point.request, ms*2)){ + smoother.smoothPath(point.path); + point.pathTiles = point.path.nodes.toArray(Tile.class); + } + } + } } - static public void updatePath(){ + public void updatePath(){ + for(SpawnPoint point : Vars.control.getSpawnPoints()){ + if(point.finder == null){ + point.finder = new IndexedAStarPathFinder(graph); + } + + point.path.clear(); + + point.pathTiles = null; + + point.request = new PathFinderRequest(point.start, Vars.control.getCore(), heuristic, point.path); + point.request.statusChanged = true; //IMPORTANT! + } + + /* if(paths.size == 0 || paths.size != World.spawnpoints.size){ paths.clear(); + finders.clear(); pathSequences = new Tile[World.spawnpoints.size][0]; for(int i = 0; i < World.spawnpoints.size; i ++){ SmoothGraphPath path = new SmoothGraphPath(); paths.add(path); + finders.add(new IndexedAStarPathFinder(graph)); } } @@ -97,7 +120,7 @@ public class Pathfind{ SmoothGraphPath path = paths.get(i); path.clear(); - passpathfinder.searchNodePath( + finders.get(i).searchNodePath( World.spawnpoints.get(i), World.core, heuristic, path); @@ -117,11 +140,15 @@ public class Pathfind{ Effects.effect(Fx.ind, tile.worldx(), tile.worldy()); } - } + }*/ } - static void findNode(Enemy enemy){ - enemy.path = pathSequences[enemy.spawn]; + void findNode(Enemy enemy){ + if(Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles == null){ + return; + } + + enemy.path = Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles; Tile[] path = enemy.path; Tile closest = null; float ldst = 0f; diff --git a/core/src/io/anuke/mindustry/ai/Raycaster.java b/core/src/io/anuke/mindustry/ai/Raycaster.java index f8b5d3226d..e012820ee9 100644 --- a/core/src/io/anuke/mindustry/ai/Raycaster.java +++ b/core/src/io/anuke/mindustry/ai/Raycaster.java @@ -7,7 +7,6 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.util.Geometry; import io.anuke.ucore.util.Mathf; @@ -72,7 +71,7 @@ public class Raycaster implements RaycastCollisionDetector{ } private boolean solid(float x, float y){ - Tile tile = World.tile(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize)); + Tile tile = Vars.world.tile(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize)); if(tile == null || tile.solid()) return true; diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 61d67248cb..2495cd0f09 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -13,7 +13,6 @@ import com.badlogic.gdx.utils.reflect.Constructor; import io.anuke.mindustry.Mindustry; import io.anuke.mindustry.Vars; -import io.anuke.mindustry.ai.Pathfind; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.effect.Fx; @@ -53,6 +52,9 @@ public class Control extends Module{ float extrawavetime; int enemies = 0; + Tile core; + Array spawnpoints = new Array<>(); + float respawntime; public Control(){ @@ -87,8 +89,6 @@ public class Control extends Module{ Musics.load("1.mp3", "2.mp3", "3.mp3", "4.mp3"); - World.loadMaps(); - KeyBinds.defaults( "up", Keys.W, "left", Keys.A, @@ -178,7 +178,7 @@ public class Control extends Module{ player.heal(); clearItems(); - World.spawnpoints.clear(); + spawnpoints.clear(); respawntime = -1; hiscore = false; @@ -189,8 +189,8 @@ public class Control extends Module{ public void play(){ Vars.renderer.clearTiles(); - player.x = World.core.worldx(); - player.y = World.core.worldy() - Vars.tilesize*2 - ((int)(Gdx.graphics.getWidth() / (float)Core.cameraScale * 2) % 2 == 0 ? 0.5f : 0); + player.x = core.worldx(); + player.y = core.worldy() - Vars.tilesize*2 - ((int)(Gdx.graphics.getWidth() / (float)Core.cameraScale * 2) % 2 == 0 ? 0.5f : 0); Core.camera.position.set(player.x, player.y, 0); @@ -200,17 +200,35 @@ public class Control extends Module{ GameState.set(State.playing); } + public Tile getCore(){ + return core; + } + + public Array getSpawnPoints(){ + return spawnpoints; + } + + public void setCore(Tile tile){ + this.core = tile; + } + + public void addSpawnPoint(Tile tile){ + SpawnPoint point = new SpawnPoint(); + point.start = tile; + spawnpoints.add(point); + } + public void playMap(Map map){ Vars.ui.showLoading(); Timers.run(16, ()->{ - Vars.control.reset(); - World.loadMap(map); - Vars.control.play(); + reset(); + world.loadMap(map); + play(); }); Timers.run(18, ()->{ - Vars.ui.hideLoading(); + ui.hideLoading(); }); } @@ -236,12 +254,12 @@ public class Control extends Module{ public void runWave(){ Sounds.play("spawn"); - Pathfind.updatePath(); + world.pathfinder().updatePath(); for(EnemySpawn spawn : spawns){ - for(int lane = 0; lane < World.spawnpoints.size; lane ++){ + for(int lane = 0; lane < spawnpoints.size; lane ++){ int fl = lane; - Tile tile = World.spawnpoints.get(lane); + Tile tile = spawnpoints.get(lane).start; int spawnamount = spawn.evaluate(wave, lane); for(int i = 0; i < spawnamount; i ++){ @@ -268,10 +286,10 @@ public class Control extends Module{ wave ++; - int last = Settings.getInt("hiscore" + World.getMap().name()); + int last = Settings.getInt("hiscore" + world.getMap().name()); if(wave > last){ - Settings.putInt("hiscore" + World.getMap().name(), wave); + Settings.putInt("hiscore" + world.getMap().name(), wave); Settings.save(); hiscore = true; } @@ -301,7 +319,6 @@ public class Control extends Module{ public void coreDestroyed(){ Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y); Sounds.play("corexplode"); - Tile core = World.core; for(int i = 0; i < 16; i ++){ Timers.run(i*2, ()->{ Effects.effect(Fx.explosion, core.worldx()+Mathf.range(40), core.worldy()+Mathf.range(40)); @@ -401,7 +418,7 @@ public class Control extends Module{ Entities.initPhysics(); Entities.setCollider(tilesize, (x, y)->{ - return World.solid(x, y); + return world.solid(x, y); }); } @@ -454,7 +471,7 @@ public class Control extends Module{ respawntime -= delta(); if(respawntime <= 0){ - player.set(World.core.worldx(), World.core.worldy()-Vars.tilesize*2); + player.set(core.worldx(), core.worldy()-Vars.tilesize*2); player.heal(); player.add(); Effects.sound("respawn"); @@ -497,10 +514,5 @@ public class Control extends Module{ } } } - - @Override - public void dispose(){ - World.disposeMaps(); - } } diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index db0db64071..032012f65c 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -20,8 +20,8 @@ import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.Input; import io.anuke.mindustry.input.PlaceMode; +import io.anuke.mindustry.world.SpawnPoint; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.ProductionBlocks; import io.anuke.ucore.UCore; @@ -80,7 +80,7 @@ public class Renderer extends RendererModule{ }else{ boolean smoothcam = Settings.getBool("smoothcam"); - if(World.core.block() == ProductionBlocks.core){ + if(control.core.block() == ProductionBlocks.core){ if(!smoothcam){ setCamera(player.x, player.y); @@ -88,7 +88,7 @@ public class Renderer extends RendererModule{ smoothCamera(player.x, player.y, android ? 0.3f : 0.14f); } }else{ - smoothCamera(World.core.worldx(), World.core.worldy(), 0.4f); + smoothCamera(control.core.worldx(), control.core.worldy(), 0.4f); } if(Settings.getBool("pixelate")) @@ -98,7 +98,8 @@ public class Renderer extends RendererModule{ updateShake(0.75f); float prevx = camera.position.x, prevy = camera.position.y; - clampCamera(-tilesize / 2f, -tilesize / 2f + 1, World.pixsize - tilesize / 2f, World.pixsize - tilesize / 2f); + clampCamera(-tilesize / 2f, -tilesize / 2f + 1, world.width() * tilesize - tilesize / 2f, + world.height() * tilesize - tilesize / 2f); float deltax = camera.position.x - prex, deltay = camera.position.y - prey; @@ -212,7 +213,7 @@ public class Renderer extends RendererModule{ } void renderTiles(){ - int chunksx = World.width() / chunksize, chunksy = World.height() / chunksize; + int chunksx = world.width() / chunksize, chunksy = world.height() / chunksize; //render the entire map if(floorCache == null || floorCache.length != chunksx || floorCache[0].length != chunksy){ @@ -271,11 +272,11 @@ public class Renderer extends RendererModule{ int worldx = Mathf.scl(camera.position.x, tilesize) + x; int worldy = Mathf.scl(camera.position.y, tilesize) + y; - if(World.tile(worldx, worldy) != null){ - Tile tile = World.tile(worldx, worldy); + if(world.tile(worldx, worldy) != null){ + Tile tile = world.tile(worldx, worldy); if(l == 0){ - if(tile.block() != Blocks.air && World.isAccessible(worldx, worldy)){ - Draw.rect(tile.block().shadow, worldx * tilesize, worldy * tilesize); + if(tile.block() != Blocks.air && world.isAccessible(worldx, worldy)){ + tile.block().drawShadow(tile); } }else if(l == 1){ tile.block().draw(tile); @@ -315,7 +316,7 @@ public class Renderer extends RendererModule{ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ - Tile tile = World.tile(tilex, tiley); + Tile tile = world.tile(tilex, tiley); tile.floor().drawCache(tile); } @@ -332,8 +333,8 @@ public class Renderer extends RendererModule{ //draw tutorial placement point if(Vars.control.tutorial.showBlock()){ - int x = World.core.x + Vars.control.tutorial.getPlacePoint().x; - int y = World.core.y + Vars.control.tutorial.getPlacePoint().y; + int x = control.core.x + Vars.control.tutorial.getPlacePoint().x; + int y = control.core.y + Vars.control.tutorial.getPlacePoint().y; int rot = Vars.control.tutorial.getPlaceRotation(); Draw.thick(1f); @@ -368,7 +369,7 @@ public class Renderer extends RendererModule{ x = tilex * tilesize; y = tiley * tilesize; - boolean valid = World.validPlace(tilex, tiley, player.recipe.result) && (android || Input.cursorNear()); + boolean valid = world.validPlace(tilex, tiley, player.recipe.result) && (android || Input.cursorNear()); Vector2 offset = player.recipe.result.getPlaceOffset(); @@ -388,8 +389,8 @@ public class Renderer extends RendererModule{ Draw.thickness(1f); Draw.color("scarlet"); - for(Tile spawn : World.spawnpoints){ - Draw.dashcircle(spawn.worldx(), spawn.worldy(), enemyspawnspace); + for(SpawnPoint spawn : control.getSpawnPoints()){ + Draw.dashcircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace); } if(valid) @@ -401,8 +402,8 @@ public class Renderer extends RendererModule{ } //block breaking - if(Inputs.buttonDown(Buttons.RIGHT) && World.validBreak(Input.tilex(), Input.tiley())){ - Tile tile = World.tile(Input.tilex(), Input.tiley()); + if(Inputs.buttonDown(Buttons.RIGHT) && world.validBreak(Input.tilex(), Input.tiley())){ + Tile tile = world.tile(Input.tilex(), Input.tiley()); if(tile.isLinked()) tile = tile.getLinked(); Vector2 offset = tile.block().getPlaceOffset(); @@ -413,8 +414,8 @@ public class Renderer extends RendererModule{ }else if(android && player.breaktime > 0){ //android block breaking Vector2 vec = Graphics.world(Gdx.input.getX(0), Gdx.input.getY(0)); - if(World.validBreak(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize))){ - Tile tile = World.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); + if(world.validBreak(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize))){ + Tile tile = world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); float fract = player.breaktime / tile.getBreakTime(); Draw.color(Color.YELLOW, Color.SCARLET, fract); @@ -425,7 +426,7 @@ public class Renderer extends RendererModule{ //draw selected block health if(player.recipe == null && !ui.hasMouse()){ - Tile tile = World.tile(Input.tilex(), Input.tiley()); + Tile tile = world.tile(Input.tilex(), Input.tiley()); if(tile != null && tile.block() != Blocks.air){ Tile target = tile; diff --git a/core/src/io/anuke/mindustry/core/Tutorial.java b/core/src/io/anuke/mindustry/core/Tutorial.java index 3401e1f643..5dfb28cd49 100644 --- a/core/src/io/anuke/mindustry/core/Tutorial.java +++ b/core/src/io/anuke/mindustry/core/Tutorial.java @@ -1,12 +1,16 @@ package io.anuke.mindustry.core; +import static io.anuke.mindustry.Vars.*; + import com.badlogic.gdx.math.GridPoint2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Weapon; -import io.anuke.mindustry.world.*; +import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.Map; +import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.*; import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.builders.button; @@ -29,7 +33,7 @@ public class Tutorial{ } public boolean active(){ - return World.getMap() == Map.tutorial && !GameState.is(State.menu); + return world.getMap() == Map.tutorial && !GameState.is(State.menu); } public void buildUI(table table){ @@ -71,7 +75,7 @@ public class Tutorial{ //info.setText(stage.text); if(stage.showBlock){ - Tile tile = World.tile(World.core.x + stage.blockPlaceX, World.core.y + stage.blockPlaceY); + 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)){ move(true); @@ -151,9 +155,9 @@ public class Tutorial{ } public void setDefaultBlocks(int corex, int corey){ - World.tile(corex, corey - 1).setBlock(Blocks.air); - World.tile(corex, corey - 2).setBlock(Blocks.air); - World.tile(corex, corey - 2).setFloor(Blocks.stone); + world.tile(corex, corey - 1).setBlock(Blocks.air); + world.tile(corex, corey - 2).setBlock(Blocks.air); + world.tile(corex, corey - 2).setFloor(Blocks.stone); } enum Stage{ @@ -288,11 +292,11 @@ public class Tutorial{ void onSwitch(){ for(int flip : new int[]{1, -1}){ - World.tile(World.core.x + flip, World.core.y - 1).setBlock(DistributionBlocks.conveyor, 2 * flip); - World.tile(World.core.x + flip*2, World.core.y - 1).setBlock(DistributionBlocks.conveyor, 2 * flip); - World.tile(World.core.x + flip*2, World.core.y - 2).setBlock(DistributionBlocks.conveyor, 1); - World.tile(World.core.x + flip*2, World.core.y - 3).setFloor(Blocks.stone); - World.tile(World.core.x + flip*2, World.core.y - 3).setBlock(ProductionBlocks.stonedrill); + world.tile(control.core.x + flip, control.core.y - 1).setBlock(DistributionBlocks.conveyor, 2 * flip); + world.tile(control.core.x + flip*2, control.core.y - 1).setBlock(DistributionBlocks.conveyor, 2 * flip); + world.tile(control.core.x + flip*2, control.core.y - 2).setBlock(DistributionBlocks.conveyor, 1); + world.tile(control.core.x + flip*2, control.core.y - 3).setFloor(Blocks.stone); + world.tile(control.core.x + flip*2, control.core.y - 3).setBlock(ProductionBlocks.stonedrill); } } @@ -463,7 +467,7 @@ public class Tutorial{ void onSwitch(){ Vars.ui.find("sectionbuttondistribution").fireClick(); - World.tile(blockPlaceX + World.core.x, blockPlaceY + World.core.y).setBlock(Blocks.air); + world.tile(blockPlaceX + control.core.x, blockPlaceY + control.core.y).setBlock(Blocks.air); } }, conduitUse2{ @@ -480,7 +484,7 @@ public class Tutorial{ } void onSwitch(){ - World.tile(blockPlaceX + World.core.x, blockPlaceY + World.core.y).setBlock(Blocks.air); + world.tile(blockPlaceX + control.core.x, blockPlaceY + control.core.y).setBlock(Blocks.air); } }, conduitUse3{ @@ -497,7 +501,7 @@ public class Tutorial{ } void onSwitch(){ - World.tile(blockPlaceX + World.core.x, blockPlaceY + World.core.y).setBlock(Blocks.air); + world.tile(blockPlaceX + control.core.x, blockPlaceY + control.core.y).setBlock(Blocks.air); } }, extractor{ @@ -513,7 +517,7 @@ public class Tutorial{ } void onSwitch(){ - World.tile(blockPlaceX + World.core.x, blockPlaceY + World.core.y).setBlock(Blocks.air); + world.tile(blockPlaceX + control.core.x, blockPlaceY + control.core.y).setBlock(Blocks.air); Vars.ui.find("sectionbuttonproduction").fireClick(); Vars.control.addItem(Item.steel, 60); Vars.control.addItem(Item.iron, 60); @@ -527,19 +531,19 @@ public class Tutorial{ void onSwitch(){ for(int i = -2; i <= 2; i ++){ - World.tile(World.core.x + i + 4, World.core.y + 2).setBlock(ProductionBlocks.stonedrill); - World.tile(World.core.x + i + 4, World.core.y + 2).setFloor(Blocks.stone); + world.tile(control.core.x + i + 4, control.core.y + 2).setBlock(ProductionBlocks.stonedrill); + world.tile(control.core.x + i + 4, control.core.y + 2).setFloor(Blocks.stone); } for(int i = 0; i < 3; i ++){ - World.tile(World.core.x + 4 - 1 - i, World.core.y).setBlock(DistributionBlocks.conveyor, 2); + world.tile(control.core.x + 4 - 1 - i, control.core.y).setBlock(DistributionBlocks.conveyor, 2); } - World.tile(World.core.x + 2, World.core.y + 1).setBlock(DistributionBlocks.conveyor, 0); - World.tile(World.core.x + 3, World.core.y + 1).setBlock(DistributionBlocks.conveyor, 0); - World.tile(World.core.x + 4, World.core.y + 1).setBlock(DistributionBlocks.conveyor, 3); - World.tile(World.core.x + 5, World.core.y + 1).setBlock(DistributionBlocks.conveyor, 2); - World.tile(World.core.x + 6, World.core.y + 1).setBlock(DistributionBlocks.conveyor, 2); + world.tile(control.core.x + 2, control.core.y + 1).setBlock(DistributionBlocks.conveyor, 0); + world.tile(control.core.x + 3, control.core.y + 1).setBlock(DistributionBlocks.conveyor, 0); + world.tile(control.core.x + 4, control.core.y + 1).setBlock(DistributionBlocks.conveyor, 3); + world.tile(control.core.x + 5, control.core.y + 1).setBlock(DistributionBlocks.conveyor, 2); + world.tile(control.core.x + 6, control.core.y + 1).setBlock(DistributionBlocks.conveyor, 2); } }, diff --git a/core/src/io/anuke/mindustry/entities/Bullet.java b/core/src/io/anuke/mindustry/entities/Bullet.java index 768cfcadb6..15caff6d00 100644 --- a/core/src/io/anuke/mindustry/entities/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/Bullet.java @@ -2,8 +2,8 @@ package io.anuke.mindustry.entities; import static io.anuke.mindustry.Vars.tilesize; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.entities.*; import io.anuke.ucore.util.Mathf; @@ -29,7 +29,7 @@ public class Bullet extends BulletEntity{ int tilex = Mathf.scl2(x, tilesize); int tiley = Mathf.scl2(y, tilesize); - Tile tile = World.tile(tilex, tiley); + Tile tile = Vars.world.tile(tilex, tiley); TileEntity targetEntity = null; if(tile != null){ diff --git a/core/src/io/anuke/mindustry/entities/effect/DamageArea.java b/core/src/io/anuke/mindustry/entities/effect/DamageArea.java index e90673946d..0a270326c0 100644 --- a/core/src/io/anuke/mindustry/entities/effect/DamageArea.java +++ b/core/src/io/anuke/mindustry/entities/effect/DamageArea.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.entities.Entities; import io.anuke.ucore.util.Mathf; @@ -29,7 +28,7 @@ public class DamageArea{ int trad = (int)(radius / Vars.tilesize); for(int dx = -trad; dx <= trad; dx ++){ for(int dy= -trad; dy <= trad; dy ++){ - Tile tile = World.tile(Mathf.scl2(x, Vars.tilesize) + dx, Mathf.scl2(y, Vars.tilesize) + dy); + Tile tile = Vars.world.tile(Mathf.scl2(x, Vars.tilesize) + dx, Mathf.scl2(y, Vars.tilesize) + dy); if(tile != null && tile.entity != null && Vector2.dst(dx, dy, 0, 0) <= trad){ int amount = calculateDamage(x, y, tile.worldx(), tile.worldy(), radius, damage); tile.entity.damage(amount); diff --git a/core/src/io/anuke/mindustry/entities/effect/EMP.java b/core/src/io/anuke/mindustry/entities/effect/EMP.java index 2f0847c924..a079c7d38d 100644 --- a/core/src/io/anuke/mindustry/entities/effect/EMP.java +++ b/core/src/io/anuke/mindustry/entities/effect/EMP.java @@ -6,7 +6,6 @@ import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.types.PowerAcceptor; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; @@ -36,7 +35,7 @@ public class EMP extends TimedEntity{ for(int dx = -radius; dx <= radius; dx ++){ for(int dy = -radius; dy <= radius; dy ++){ if(Vector2.dst(dx, dy, 0, 0) < radius){ - Tile tile = World.tile(worldx + dx, worldy + dy); + Tile tile = Vars.world.tile(worldx + dx, worldy + dy); if(tile != null && tile.block().destructible){ array.add(tile); diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 59a1be0e52..e510681f7a 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -5,14 +5,12 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.reflect.ClassReflection; import io.anuke.mindustry.Vars; -import io.anuke.mindustry.ai.Pathfind; import io.anuke.mindustry.entities.Bullet; import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.effect.Shaders; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.core.*; import io.anuke.ucore.entities.*; import io.anuke.ucore.util.Mathf; @@ -57,15 +55,17 @@ public class Enemy extends DestructibleEntity{ } void move(){ - boolean nearCore = distanceTo(World.core.worldx(), World.core.worldy()) <= range - 18f; + Tile core = Vars.control.getCore(); + + boolean nearCore = distanceTo(core.worldx(), core.worldy()) <= range - 18f; Vector2 vec; if(nearCore){ vec = Tmp.v2.setZero(); - target = World.core.entity; + target = core.entity; }else{ - vec = Pathfind.find(this); + vec = Vars.world.pathfinder().find(this); vec.sub(x, y).setLength(speed); } @@ -94,8 +94,13 @@ public class Enemy extends DestructibleEntity{ move(vec.x * Timers.delta(), vec.y * Timers.delta()); + + updateTargeting(nearCore); + } + + void updateTargeting(boolean nearCore){ if(Timers.get(this, "target", 15) && !nearCore){ - target = World.findTileTarget(x, y, null, range, false); + target = Vars.world.findTileTarget(x, y, null, range, false); //no tile found if(target == null){ @@ -126,7 +131,7 @@ public class Enemy extends DestructibleEntity{ } public void findClosestNode(){ - Pathfind.find(this); + Vars.world.pathfinder().find(this); int index = 0; int cindex = -1; @@ -150,7 +155,7 @@ public class Enemy extends DestructibleEntity{ int x2 = path[node].x, y2 = path[node].y; //if the enemy can't move to that node right now, set its position to it - if(World.raycast(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), x2, y2) != null){ + if(Vars.world.raycast(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), x2, y2) != null){ Timers.run(Mathf.random(15f), () -> { set(x2 * Vars.tilesize, y2 * Vars.tilesize); }); diff --git a/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java index a9591ccc04..7f46b9c607 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java @@ -1,11 +1,11 @@ package io.anuke.mindustry.entities.enemies; import com.badlogic.gdx.math.MathUtils; -import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.ai.Pathfind; import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.effect.Shaders; import io.anuke.ucore.core.Draw; +import io.anuke.ucore.core.Graphics; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entities; import io.anuke.ucore.graphics.Hue; @@ -28,12 +28,7 @@ public class HealerEnemy extends Enemy{ } @Override - void move(){ - Vector2 vec = Pathfind.find(this); - vec.sub(x, y).setLength(speed); - - move(vec.x*Timers.delta(), vec.y*Timers.delta()); - + void updateTargeting(boolean nearCore){ if(Timers.get(this, "target", 15)){ target = Entities.getClosest(Entities.getGroup(Enemy.class), x, y, range, e -> e instanceof Enemy && e != this && ((Enemy)e).healthfrac() < 1f); @@ -62,12 +57,14 @@ public class HealerEnemy extends Enemy{ Angles.translation(this.angleTo(enemy), 5f); + Graphics.shader(); if(enemy != null && enemy.health < enemy.maxhealth){ Draw.color(Hue.rgb(138, 244, 138, (MathUtils.sin(Timers.time()) + 1f) / 13f)); Draw.alpha(0.9f); Draw.laser("laser", "laserend", x + Angles.x(), y + Angles.y(), enemy.x - Angles.x()/1.5f, enemy.y - Angles.y()/1.5f); Draw.color(); } + Graphics.shader(Shaders.outline); } } diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index b6cfc77334..9659f8e3ab 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -10,7 +10,6 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.core.Graphics; import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.ui.layout.Unit; @@ -51,7 +50,7 @@ public class AndroidInput extends InputAdapter{ public static Tile selected(){ Vector2 vec = Graphics.world(mousex, mousey); - return World.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); + return Vars.world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); } public static void breakBlock(){ @@ -60,7 +59,7 @@ public class AndroidInput extends InputAdapter{ if(player.breaktime >= tile.block().breaktime){ brokeBlock = true; - World.breakBlock(tile.x, tile.y); + Vars.world.breakBlock(tile.x, tile.y); player.breaktime = 0f; } } @@ -72,9 +71,9 @@ public class AndroidInput extends InputAdapter{ int tiley = Mathf.scl2(vec.y, tilesize); if(player.recipe != null && - World.validPlace(tilex, tiley, player.recipe.result)){ + Vars.world.validPlace(tilex, tiley, player.recipe.result)){ - World.placeBlock(tilex, tiley, player.recipe.result, player.rotation); + Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation); for(ItemStack stack : player.recipe.requirements){ Vars.control.removeItem(stack); @@ -97,7 +96,7 @@ public class AndroidInput extends InputAdapter{ if(sel == null) return; - if(warmup > warmupDelay && World.validBreak(sel.x, sel.y)){ + if(warmup > warmupDelay && Vars.world.validBreak(sel.x, sel.y)){ player.breaktime += Timers.delta(); if(player.breaktime > selected().block().breaktime){ diff --git a/core/src/io/anuke/mindustry/input/Input.java b/core/src/io/anuke/mindustry/input/Input.java index c05aa00d1f..197f10371d 100644 --- a/core/src/io/anuke/mindustry/input/Input.java +++ b/core/src/io/anuke/mindustry/input/Input.java @@ -10,7 +10,6 @@ import io.anuke.mindustry.Vars; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.types.Configurable; import io.anuke.ucore.core.Graphics; import io.anuke.ucore.core.Inputs; @@ -46,13 +45,13 @@ public class Input{ } } - Tile cursor = World.tile(tilex(), tiley()); + Tile cursor = Vars.world.tile(tilex(), tiley()); if(Inputs.buttonUp(Buttons.LEFT) && player.recipe != null && - World.validPlace(tilex(), tiley(), player.recipe.result) && !ui.hasMouse() && cursorNear() && + Vars.world.validPlace(tilex(), tiley(), player.recipe.result) && !ui.hasMouse() && cursorNear() && Vars.control.hasItems(player.recipe.requirements)){ - World.placeBlock(tilex(), tiley(), player.recipe.result, player.rotation); + Vars.world.placeBlock(tilex(), tiley(), player.recipe.result, player.rotation); for(ItemStack stack : player.recipe.requirements){ Vars.control.removeItem(stack); @@ -80,11 +79,11 @@ public class Input{ } //block breaking - if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && World.validBreak(tilex(), tiley())){ + if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && Vars.world.validBreak(tilex(), tiley())){ Tile tile = cursor; player.breaktime += Timers.delta(); if(player.breaktime >= tile.getBreakTime()){ - World.breakBlock(cursor.x, cursor.y); + Vars.world.breakBlock(cursor.x, cursor.y); player.breaktime = 0f; } }else{ diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index 5f38483f1a..bdfbf2bddc 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -19,7 +19,9 @@ import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.enemies.*; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Weapon; -import io.anuke.mindustry.world.*; +import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.Map; +import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.ucore.core.Core; import io.anuke.ucore.entities.Entities; @@ -203,16 +205,16 @@ public class SaveIO{ //--MAP DATA-- //map ID - stream.writeByte(World.getMap().ordinal()); + stream.writeByte(Vars.world.getMap().ordinal()); //seed - stream.writeInt(World.getSeed()); + stream.writeInt(Vars.world.getSeed()); int totalblocks = 0; - for(int x = 0; x < World.width(); x ++){ - for(int y = 0; y < World.height(); y ++){ - Tile tile = World.tile(x, y); + for(int x = 0; x < Vars.world.width(); x ++){ + for(int y = 0; y < Vars.world.height(); y ++){ + Tile tile = Vars.world.tile(x, y); if(tile.breakable()){ totalblocks ++; @@ -223,13 +225,13 @@ public class SaveIO{ //tile amount stream.writeInt(totalblocks); - for(int x = 0; x < World.width(); x ++){ - for(int y = 0; y < World.height(); y ++){ - Tile tile = World.tile(x, y); + for(int x = 0; x < Vars.world.width(); x ++){ + for(int y = 0; y < Vars.world.height(); y ++){ + Tile tile = Vars.world.tile(x, y); if(tile.breakable()){ - stream.writeInt(x + y*World.width()); //tile pos + stream.writeInt(x + y*Vars.world.width()); //tile pos stream.writeByte(tile.link); stream.writeBoolean(tile.entity != null); //whether it has a tile entity stream.writeInt(tile.block().id); //block ID @@ -349,20 +351,20 @@ public class SaveIO{ int seed = stream.readInt(); int tiles = stream.readInt(); - World.loadMap(Map.values()[mapid], seed); + Vars.world.loadMap(Map.values()[mapid], seed); Vars.renderer.clearTiles(); for(Enemy enemy : enemiesToUpdate){ enemy.findClosestNode(); } - for(int x = 0; x < World.width(); x ++){ - for(int y = 0; y < World.height(); y ++){ - Tile tile = World.tile(x, y); + for(int x = 0; x < Vars.world.width(); x ++){ + for(int y = 0; y < Vars.world.height(); y ++){ + Tile tile = Vars.world.tile(x, y); //remove breakables like rocks if(tile.breakable()){ - World.tile(x, y).setBlock(Blocks.air); + Vars.world.tile(x, y).setBlock(Blocks.air); } } } @@ -373,7 +375,7 @@ public class SaveIO{ boolean hasEntity = stream.readBoolean(); int blockid = stream.readInt(); - Tile tile = World.tile(pos % World.width(), pos / World.width()); + Tile tile = Vars.world.tile(pos % Vars.world.width(), pos / Vars.world.width()); tile.setBlock(Block.getByID(blockid)); tile.link = link; diff --git a/core/src/io/anuke/mindustry/ui/LevelDialog.java b/core/src/io/anuke/mindustry/ui/LevelDialog.java index 65a22ac19e..a6cd5f6c85 100644 --- a/core/src/io/anuke/mindustry/ui/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/LevelDialog.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Map; -import io.anuke.mindustry.world.World; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Timers; @@ -50,7 +49,7 @@ public class LevelDialog extends FloatingDialog{ float images = 154f; - ImageButton image = new ImageButton(new TextureRegion(World.getTexture(map)), "togglemap"); + ImageButton image = new ImageButton(new TextureRegion(Vars.world.getTexture(map)), "togglemap"); image.row(); image.add(inset).width(images+6).units(Unit.dp); image.clicked(()->{ diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 6d2e4dda46..33ae7b7288 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -15,6 +15,7 @@ import io.anuke.mindustry.resource.Liquid; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects.Effect; +import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; public class Block{ private static int lastid; @@ -48,10 +49,12 @@ public class Block{ public int health = 40; /**the shadow drawn under the block*/ public String shadow = "shadow"; + /**whether to display a different shadow per variant*/ + public boolean varyShadow = false; /**edge fallback, used mainly for ores*/ public String edge = "stone"; - /**whether this block has 3 variants*/ - public boolean vary = true; + /**number of block variants, 0 to disable*/ + public int variants = 0; /**stuff that drops when broken*/ public ItemStack drops = null; /**liquids that drop from this block, used for pumps*/ @@ -203,10 +206,12 @@ public class Block{ public void draw(Tile tile){ //note: multiblocks do not support rotation if(!isMultiblock()){ - Draw.rect(name(), tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0); + Draw.rect(variants > 0 ? (name() + Mathf.randomSeed(tile.id(), 1, variants)) : name(), + tile.worldx(), tile.worldy(), rotate ? tile.rotation * 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(); + Draw.rect(name(), tile.worldx() + offset.x, tile.worldy() + offset.y); } @@ -216,6 +221,15 @@ public class Block{ } } + public void drawShadow(Tile tile){ + + if(varyShadow && variants > 0){ + Draw.rect(shadow + (Mathf.randomSeed(tile.id(), 1, variants)), tile.worldx(), tile.worldy()); + }else{ + Draw.rect(shadow, tile.worldx(), tile.worldy()); + } + } + /**Offset for placing and drawing multiblocks.*/ public Vector2 getPlaceOffset(){ return Tmp.v3.set(((width + 1) % 2) * Vars.tilesize/2, ((height + 1) % 2) * Vars.tilesize/2); diff --git a/core/src/io/anuke/mindustry/world/Generator.java b/core/src/io/anuke/mindustry/world/Generator.java index fe671abef5..9cabc98a47 100644 --- a/core/src/io/anuke/mindustry/world/Generator.java +++ b/core/src/io/anuke/mindustry/world/Generator.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.ObjectMap; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.enemies.TargetEnemy; import io.anuke.mindustry.world.blocks.Blocks; +import io.anuke.mindustry.world.blocks.types.Floor; import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.noise.Noise; import io.anuke.ucore.util.Mathf; @@ -23,14 +24,16 @@ public class Generator{ Hue.rgb(110, 80, 30), Blocks.dirt, Hue.rgb(160, 120, 70), Blocks.dirtblock, Hue.rgb(100, 100, 100), Blocks.stoneblock, + Color.valueOf("414141"), Blocks.blackstoneblock, + Color.valueOf("252525"), Blocks.blackstone, Color.valueOf("ed5334"), Blocks.lava, Color.valueOf("292929"), Blocks.oil ); /**Returns world size.*/ - public static void generate(Pixmap pixmap){ + public static void generate(Pixmap pixmap, Tile[][] tiles){ - Noise.setSeed(World.getSeed()); + Noise.setSeed(Vars.world.getSeed()); for(int x = 0; x < pixmap.getWidth(); x ++){ for(int y = 0; y < pixmap.getHeight(); y ++){ @@ -41,23 +44,29 @@ public class Generator{ if(colors.containsKey(color)){ //TODO less hacky method - if(colors.get(color).name().contains("block")){ + if(!(colors.get(color) instanceof Floor)){ block = colors.get(color); }else{ floor = colors.get(color); } }else if(color == start){ - World.core = World.tile(x, y); + Vars.control.setCore(Vars.world.tile(x, y)); }else if(color == spawn){ - World.spawnpoints.add(World.tile(x, y)); + Vars.control.addSpawnPoint(Vars.world.tile(x, y)); floor = Blocks.dirt; - }else{ - if(Mathf.chance(0.02)){ - block = Mathf.choose(Blocks.rock, Blocks.rock2); + } + + if(block == Blocks.air){ + if(floor == Blocks.stone && Mathf.chance(0.02)){ + block = Blocks.rock; + } + + if(floor == Blocks.blackstone && Mathf.chance(0.03)){ + block = Blocks.blackrock; } } - if(floor == Blocks.stone || floor == Blocks.grass){ + if(floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone){ if(Noise.nnoise(x, y, 8, 1) > 0.2){ floor = Blocks.iron; } @@ -77,11 +86,6 @@ public class Generator{ if(block == Blocks.grassblock){ floor = Blocks.grass; - block = Mathf.choose(Blocks.grassblock, Blocks.grassblock2); - } - - if(block == Blocks.stoneblock){ - block = Mathf.choose(Blocks.stoneblock, Blocks.stoneblock2, Blocks.stoneblock3); } if(floor == Blocks.grass && Mathf.chance(0.02) && block == Blocks.air){ @@ -98,10 +102,8 @@ public class Generator{ // block = Mathf.choose(ProductionBlocks.stonedrill, DistributionBlocks.conveyor); //} - World.tile(x, y).setBlock(block); - World.tile(x, y).setFloor(floor); - - + tiles[x][y].setBlock(block, 0); + tiles[x][y].setFloor(floor); } } } diff --git a/core/src/io/anuke/mindustry/world/Map.java b/core/src/io/anuke/mindustry/world/Map.java index adbb95431f..e393da1344 100644 --- a/core/src/io/anuke/mindustry/world/Map.java +++ b/core/src/io/anuke/mindustry/world/Map.java @@ -2,27 +2,31 @@ package io.anuke.mindustry.world; public enum Map{ delta("Starting map."), - canyon("Badly drawn map."), pit("Eck."), - maze("it's okay."), - maze2("test"), - maze3("test"), - maze4("test"), - maze5("test"), + maze("it's okay."), + volcano("desc"), tutorial(false), test1(false), test2(false); public final boolean visible; + public final boolean sandbox; public final String description; + public int width, height; private Map(boolean visible){ this.visible = visible; + this.sandbox = false; this.description = "Test map!"; } private Map(String description){ + this(description, false); + } + + private Map(String description, boolean sandbox){ this.visible = true; + this.sandbox = sandbox; this.description = description; } } diff --git a/core/src/io/anuke/mindustry/world/SpawnPoint.java b/core/src/io/anuke/mindustry/world/SpawnPoint.java new file mode 100644 index 0000000000..9735946ecd --- /dev/null +++ b/core/src/io/anuke/mindustry/world/SpawnPoint.java @@ -0,0 +1,14 @@ +package io.anuke.mindustry.world; + +import com.badlogic.gdx.ai.pfa.PathFinder; +import com.badlogic.gdx.ai.pfa.PathFinderRequest; + +import io.anuke.mindustry.ai.SmoothGraphPath; + +public class SpawnPoint{ + public Tile start; + public Tile[] pathTiles; + public PathFinder finder; + public SmoothGraphPath path = new SmoothGraphPath(); + public PathFinderRequest request; +} diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index f84df0edf0..85332d1627 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -5,6 +5,7 @@ import static io.anuke.mindustry.Vars.tilesize; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.ucore.util.Bits; @@ -52,7 +53,7 @@ public class Tile{ float dst = Vector2.dst(dx, dy, 0, 0); if(dst > rad || (dx == 0 && dy == 0)) continue; - Tile other = World.tile(x + dx, y + dy); + Tile other = Vars.world.tile(x + dx, y + dy); if(other.entity != null){ other.entity.damage((int)(amount * Mathf.lerp(1f-dst/rad, 1f, falloff))); } @@ -61,7 +62,7 @@ public class Tile{ } public int id(){ - return x + y * World.worldsize; + return x + y * Vars.world.width(); } public float worldx(){ @@ -139,7 +140,7 @@ public class Tile{ int offsety = -(block.height-1)/2; for(int dx = 0; dx < block.width; dx ++){ for(int dy = 0; dy < block.height; dy ++){ - Tile other = World.tile(x + dx + offsetx, y + dy + offsety); + Tile other = Vars.world.tile(x + dx + offsetx, y + dy + offsety); tmpArray.add(other); } } @@ -154,12 +155,12 @@ public class Tile{ }else{ byte dx = Bits.getLeftByte(link); byte dy = Bits.getRightByte(link); - return World.tile(x - (dx - 8), y - (dy - 8)); + return Vars.world.tile(x - (dx - 8), y - (dy - 8)); } } public Tile[] getNearby(){ - return World.getNearby(x, y); + return Vars.world.getNearby(x, y); } public void changed(){ diff --git a/core/src/io/anuke/mindustry/world/World.java b/core/src/io/anuke/mindustry/world/World.java index e5b6597b0f..34a80075d6 100644 --- a/core/src/io/anuke/mindustry/world/World.java +++ b/core/src/io/anuke/mindustry/world/World.java @@ -18,61 +18,81 @@ 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.Tmp; -public class World{ - public static int worldsize = 128; - public static int pixsize = worldsize*tilesize; - private static int seed; +public class World extends Module{ + private int seed; - private static Pixmap[] mapPixmaps; - private static Texture[] mapTextures; - private static Map currentMap; - private static Tile[][] tiles = new Tile[worldsize][worldsize]; - private static Tile[] temptiles = new Tile[4]; + private Pixmap[] mapPixmaps; + private Texture[] mapTextures; + private Map currentMap; + private Tile[][] tiles; + private Tile[] temptiles = new Tile[4]; + private Pathfind pathfind = new Pathfind(); - public static Tile core; - //TODO move this to control? - public static Array spawnpoints = new Array(); + public World(){ + loadMaps(); + } - public static boolean solid(int x, int y){ + @Override + public void update(){ + pathfind.update(); + } + + @Override + public void dispose(){ + for(Texture texture : mapTextures){ + texture.dispose(); + } + + for(Pixmap pix : mapPixmaps){ + pix.dispose(); + } + } + + public Pathfind pathfinder(){ + return pathfind; + } + + public boolean solid(int x, int y){ Tile tile = tile(x, y); return tile == null || tile.block().solid || (tile.floor().solid && (tile.block() == Blocks.air)); } - public static boolean wallSolid(int x, int y){ + public boolean wallSolid(int x, int y){ Tile tile = tile(x, y); return tile == null || tile.block().solid; } - public static boolean isAccessible(int x, int y){ + public boolean isAccessible(int x, int y){ return !wallSolid(x, y-1) || !wallSolid(x, y+1) || !wallSolid(x-1, y) ||!wallSolid(x+1, y); } - public static Map getMap(){ + public Map getMap(){ return currentMap; } - public static int width(){ - return mapPixmaps[currentMap.ordinal()].getWidth(); + public int width(){ + return currentMap.width; } - public static int height(){ - return mapPixmaps[currentMap.ordinal()].getHeight(); + public int height(){ + return currentMap.height; } - public static Tile tile(int x, int y){ + public Tile tile(int x, int y){ if(!Mathf.inBounds(x, y, tiles)) return null; return tiles[x][y]; } - public static Tile tileWorld(float x, float y){ + public Tile tileWorld(float x, float y){ return tile(Mathf.scl2(x, tilesize), Mathf.scl2(y, tilesize)); } - public static Tile[] getNearby(int x, int y){ + public Tile[] getNearby(int x, int y){ temptiles[0] = tile(x+1, y); temptiles[1] = tile(x, y+1); temptiles[2] = tile(x-1, y); @@ -80,11 +100,11 @@ public class World{ return temptiles; } - public static Texture getTexture(Map map){ + public Texture getTexture(Map map){ return mapTextures[map.ordinal()]; } - public static void loadMaps(){ + public void loadMaps(){ Map[] maps = Map.values(); mapPixmaps = new Pixmap[maps.length]; @@ -94,10 +114,12 @@ public class World{ Pixmap pix = new Pixmap(Gdx.files.internal("maps/"+maps[i]+".png")); mapPixmaps[i] = pix; mapTextures[i] = new Texture(pix); + maps[i].width = pix.getWidth(); + maps[i].height = pix.getHeight(); } } - private static void createTiles(){ + private void createTiles(){ for(int x = 0; x < tiles.length; x ++){ for(int y = 0; y < tiles[0].length; y ++){ if(tiles[x][y] == null){ @@ -107,7 +129,7 @@ public class World{ } } - private static void clearTileEntities(){ + private void clearTileEntities(){ for(int x = 0; x < tiles.length; x ++){ for(int y = 0; y < tiles[0].length; y ++){ if(tiles[x][y] != null && tiles[x][y].entity != null){ @@ -117,57 +139,48 @@ public class World{ } } - public static void loadMap(Map map){ + public void loadMap(Map map){ loadMap(map, MathUtils.random(0, 99999)); } - public static void loadMap(Map map, int seed){ - - spawnpoints.clear(); - - int size = mapPixmaps[map.ordinal()].getWidth(); - worldsize = size; - pixsize = worldsize*tilesize; + public void loadMap(Map map, int seed){ currentMap = map; if(tiles != null){ clearTileEntities(); - if(tiles.length != worldsize || tiles[0].length != worldsize){ - tiles = new Tile[worldsize][worldsize]; + if(tiles.length != map.width || tiles[0].length != map.height){ + tiles = new Tile[map.width][map.height]; } createTiles(); }else{ - tiles = new Tile[worldsize][worldsize]; + tiles = new Tile[map.width][map.height]; createTiles(); } - Entities.resizeTree(0, 0, pixsize, pixsize); + Entities.resizeTree(0, 0, map.width * tilesize, map.height * tilesize); - World.seed = seed; - Generator.generate(mapPixmaps[map.ordinal()]); - - Pathfind.reset(); + this.seed = seed; + Generator.generate(mapPixmaps[map.ordinal()], tiles); //TODO multiblock core - placeBlock(core.x, core.y, ProductionBlocks.core, 0); + placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0); if(map != Map.tutorial){ setDefaultBlocks(); }else{ - Vars.control.getTutorial().setDefaultBlocks(core.x, core.y); + Vars.control.getTutorial().setDefaultBlocks(control.getCore().x, control.getCore().y); } - Pathfind.updatePath(); + pathfind.updatePath(); } - static void setDefaultBlocks(){ - int x = core.x, y = core.y; + void setDefaultBlocks(){ + int x = control.getCore().x, y = control.getCore().y; - //set(x, y-1, DistributionBlocks.conveyor, 1); set(x, y-2, DistributionBlocks.conveyor, 1); set(x, y-3, DistributionBlocks.conveyor, 1); @@ -183,28 +196,26 @@ public class World{ set(x+2*d, y-3, DistributionBlocks.conveyor, 2*d); set(x+2*d, y-4, DistributionBlocks.conveyor, 1); set(x+2*d, y-5, DistributionBlocks.conveyor, 1); - //set(x+2*d, y-6, DistributionBlocks.conveyor, 1); - //set(x+3*d, y-6, ProductionBlocks.stonedrill, 0); set(x+3*d, y-5, ProductionBlocks.stonedrill, 0); set(x+3*d, y-4, ProductionBlocks.stonedrill, 0); set(x+3*d, y-3, ProductionBlocks.stonedrill, 0); } } - static void set(int x, int y, Block type, int rot){ + void set(int x, int y, Block type, int rot){ if(type == ProductionBlocks.stonedrill){ tiles[x][y].setFloor(Blocks.stone); } tiles[x][y].setBlock(type, rot); } - public static int getSeed(){ + public int getSeed(){ return seed; } //TODO move to control or player? - public static void placeBlock(int x, int y, Block result, int rotation){ + public void placeBlock(int x, int y, Block result, int rotation){ Tile tile = tile(x, y); //just in case @@ -239,10 +250,10 @@ public class World{ } //TODO move this to control? - public static boolean validPlace(int x, int y, Block type){ + public boolean validPlace(int x, int y, Block type){ - for(Tile spawn : spawnpoints){ - if(Vector2.dst(x * tilesize, y * tilesize, spawn.worldx(), spawn.worldy()) < enemyspawnspace){ + for(SpawnPoint spawn : control.getSpawnPoints()){ + if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){ return false; } } @@ -270,7 +281,8 @@ public class World{ int rotation = Vars.control.getTutorial().getPlaceRotation(); Block block = Vars.control.getTutorial().getPlaceBlock(); - if(type != block || point.x != x - core.x || point.y != y - core.y || (rotation != -1 && rotation != Vars.player.rotation)){ + 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()){ @@ -298,7 +310,7 @@ public class World{ } } - public static void breakBlock(int x, int y){ + public void breakBlock(int x, int y){ Tile tile = tile(x, y); if(tile == null) return; @@ -324,7 +336,7 @@ public class World{ } } - public static boolean validBreak(int x, int y){ + public boolean validBreak(int x, int y){ Tile tile = tile(x, y); if(tile == null || tile.block() == ProductionBlocks.core) return false; @@ -340,7 +352,8 @@ public class World{ int rotation = Vars.control.getTutorial().getPlaceRotation(); Block block = Vars.control.getTutorial().getPlaceBlock(); - if(block != Blocks.air || point.x != x - core.x || point.y != y - core.y || (rotation != -1 && rotation != Vars.player.rotation)){ + 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{ @@ -351,11 +364,7 @@ public class World{ return tile.breakable(); } - //public static Rectangle getCollider(int x, int y){ - // return Rectangle.tmp2.setSize(tilesize).setCenter(x * tilesize, y * tilesize); - //} - - public static TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){ + public TileEntity findTileTarget(float x, float y, Tile tile, float range, boolean damaged){ Entity closest = null; float dst = 0; @@ -389,21 +398,11 @@ public class World{ return (TileEntity) closest; } - public static void disposeMaps(){ - for(Pixmap pixmap : mapPixmaps){ - pixmap.dispose(); - } - - for(Texture texture : mapTextures){ - texture.dispose(); - } - } - /** * Input is in block coordinates, not world coordinates. * @return null if no collisions found, block position otherwise. */ - public static Vector2 raycast(int x0f, int y0f, int x1f, int y1f){ + public Vector2 raycast(int x0f, int y0f, int x1f, int y1f){ int x0 = (int)x0f; int y0 = (int)y0f; int x1 = (int)x1f; diff --git a/core/src/io/anuke/mindustry/world/blocks/Blocks.java b/core/src/io/anuke/mindustry/world/blocks/Blocks.java index 2dc1cd8612..73c50db859 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/Blocks.java @@ -31,20 +31,20 @@ public class Blocks{ blockpart = new BlockPart(), deepwater = new Floor("deepwater"){{ - vary = false; + variants = 0; solid = true; liquidDrop = Liquid.water; }}, water = new Floor("water"){{ - vary = false; + variants = 0; solid = true; liquidDrop = Liquid.water; }}, lava = new Floor("lava"){ { - vary = false; + variants = 0; solid = true; liquidDrop = Liquid.lava; } @@ -63,7 +63,7 @@ public class Blocks{ oil = new Floor("oil"){ { - vary = false; + variants = 0; solid = true; liquidDrop = Liquid.oil; } @@ -80,6 +80,10 @@ public class Blocks{ drops = new ItemStack(Item.stone, 1); }}, + blackstone = new Floor("blackstone"){{ + drops = new ItemStack(Item.stone, 1); + }}, + iron = new Floor("iron"){{ drops = new ItemStack(Item.iron, 1); }}, @@ -100,24 +104,38 @@ public class Blocks{ grass = new Floor("grass"), - stoneblock = new Block("stoneblock"){{ - solid = true; - }}, + stoneblock = new Block("stoneblock"){ + { + solid = true; + variants = 3; + } + + @Override + public void draw(Tile tile){ + // Draw.colorl(0.9f + Mathf.randomSeed(tile.id()*9999, 1, 10)/10f / 10f); + super.draw(tile); + // Draw.color(); + } + }, - stoneblock2 = new Block("stoneblock2"){{ - solid = true; - }}, - - stoneblock3 = new Block("stoneblock3"){{ - solid = true; - }}, + blackstoneblock = new Block("blackstoneblock"){ + { + solid = true; + variants = 3; + } + + @Override + public void draw(Tile tile){ + // float f = 0.15f; + // Draw.colorl(1f - f + Mathf.randomSeed(tile.id()*9999, 1, 10)/10f / (1f / f)); + super.draw(tile); + // Draw.color(); + } + }, grassblock = new Block("grassblock"){{ solid = true; - }}, - - grassblock2 = new Block("grassblock2"){{ - solid = true; + variants = 2; }}, mossblock = new Block("mossblock"){{ @@ -134,13 +152,17 @@ public class Blocks{ shadow = "rockshadow"; breakable = true; breaktime = 15; + variants = 2; + varyShadow = true; drops = new ItemStack(Item.stone, 3); }}, - - rock2 = new Block("rock2"){{ - shadow = "rock2shadow"; + + blackrock = new Block("blackrock"){{ + shadow = "blackrockshadow"; breakable = true; breaktime = 15; + variants = 1; + varyShadow = true; drops = new ItemStack(Item.stone, 3); }}, diff --git a/core/src/io/anuke/mindustry/world/blocks/types/BlendBlock.java b/core/src/io/anuke/mindustry/world/blocks/types/BlendBlock.java new file mode 100644 index 0000000000..31ea497749 --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/types/BlendBlock.java @@ -0,0 +1,31 @@ +package io.anuke.mindustry.world.blocks.types; + +import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.Tile; +import io.anuke.ucore.core.Draw; +import io.anuke.ucore.function.Predicate; +import io.anuke.ucore.util.Mathf; + +public class BlendBlock extends Block{ + protected String edge; + protected Predicate blend = block -> block == this; + + public BlendBlock(String name) { + super(name); + edge = name + "-edge"; + } + + @Override + public void draw(Tile tile){ + Draw.rect(variants > 0 ? (name() + Mathf.randomSeed(tile.id(), 1, variants)) : name(), + tile.worldx(), tile.worldy()); + + Tile[] nearby = tile.getNearby(); + + for(int i = 0; i < 4; i ++){ + if(nearby[i] != null && !blend.test(nearby[i].block())){ + Draw.rect(edge + "-" + i, tile.worldx(), tile.worldy()); + } + } + } +} diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Floor.java b/core/src/io/anuke/mindustry/world/blocks/types/Floor.java index 68033ccc4c..83f524c0a0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Floor.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Floor.java @@ -3,9 +3,9 @@ package io.anuke.mindustry.world.blocks.types; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.core.Draw; import io.anuke.ucore.graphics.Caches; import io.anuke.ucore.util.Mathf; @@ -14,20 +14,21 @@ public class Floor extends Block{ public Floor(String name) { super(name); + variants = 3; } @Override public void drawCache(Tile tile){ MathUtils.random.setSeed(tile.id()); - Caches.draw(vary ? (name() + MathUtils.random(1, 3)) : name(), tile.worldx(), tile.worldy()); + Caches.draw(variants > 0 ? (name() + MathUtils.random(1, variants)) : name(), tile.worldx(), tile.worldy()); for(int dx = -1; dx <= 1; dx ++){ for(int dy = -1; dy <= 1; dy ++){ if(dx == 0 && dy == 0) continue; - Tile other = World.tile(tile.x+dx, tile.y+dy); + Tile other = Vars.world.tile(tile.x+dx, tile.y+dy); if(other == null) continue; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java new file mode 100644 index 0000000000..123b3b44a9 --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java @@ -0,0 +1,11 @@ +package io.anuke.mindustry.world.blocks.types.defense; + +import io.anuke.mindustry.world.blocks.types.Wall; + +public class Door extends Wall{ + + public Door(String name) { + super(name); + } + +} diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java index ce76ef65a2..13d48f0b07 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java @@ -4,8 +4,8 @@ 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.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Hue; @@ -39,7 +39,7 @@ public class RepairTurret extends PowerTurret{ TurretEntity entity = tile.entity(); if(Timers.get(entity, "blocktarget", targetInterval)){ - entity.blockTarget = World.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true); + entity.blockTarget = Vars.world.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true); } if(entity.blockTarget != null){ 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 7f38024cbf..ec2c00fbbe 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 @@ -8,7 +8,6 @@ import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.types.PowerAcceptor; import io.anuke.mindustry.world.blocks.types.PowerBlock; import io.anuke.ucore.core.Draw; @@ -140,7 +139,7 @@ public class Generator extends PowerBlock{ int i = 0; for(i = 1; i < laserRange; i++){ - Tile other = World.tile(tile.x + i * point.x, tile.y + i * point.y); + Tile other = Vars.world.tile(tile.x + i * point.x, tile.y + i * point.y); if(other != null && other.block() instanceof PowerAcceptor){ Tile linked = other.getLinked(); @@ -173,7 +172,7 @@ public class Generator extends PowerBlock{ } if(Vector2.dst(x, y, 0, 0) < powerRange){ - Tile dest = World.tile(tile.x + x, tile.y + y); + Tile dest = Vars.world.tile(tile.x + x, tile.y + y); if(dest != null && dest.block() instanceof PowerAcceptor && ((PowerAcceptor) dest.block()).acceptsPower(dest)){ if(i == 1){ PowerAcceptor block = (PowerAcceptor) dest.block();