Compare commits
No commits in common. "master" and "0.2.0" have entirely different histories.
310
Cargo.lock
generated
310
Cargo.lock
generated
@ -77,12 +77,6 @@ dependencies = [
|
|||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "adler2"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahash"
|
name = "ahash"
|
||||||
version = "0.8.11"
|
version = "0.8.11"
|
||||||
@ -740,7 +734,6 @@ dependencies = [
|
|||||||
"bevy_ecs",
|
"bevy_ecs",
|
||||||
"bevy_gizmos",
|
"bevy_gizmos",
|
||||||
"bevy_hierarchy",
|
"bevy_hierarchy",
|
||||||
"bevy_image",
|
|
||||||
"bevy_input",
|
"bevy_input",
|
||||||
"bevy_log",
|
"bevy_log",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
@ -1370,17 +1363,6 @@ version = "3.16.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "buns"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "75f1d46ab84e22a81b97efa9ee5f22a3f3508edf23a0203904f213b4faf32fe2"
|
|
||||||
dependencies = [
|
|
||||||
"deki_proc",
|
|
||||||
"extension-traits",
|
|
||||||
"maflow",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.20.0"
|
version = "1.20.0"
|
||||||
@ -1633,15 +1615,6 @@ dependencies = [
|
|||||||
"const_soft_float",
|
"const_soft_float",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "convert_case"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-segmentation",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
@ -1758,15 +1731,6 @@ dependencies = [
|
|||||||
"windows 0.54.0",
|
"windows 0.54.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crc32fast"
|
|
||||||
version = "1.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.14"
|
version = "0.5.14"
|
||||||
@ -1846,77 +1810,6 @@ version = "2.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deki"
|
|
||||||
version = "0.2.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d99371f8ebec1287967d7316c45cc22490db154e695c40dc697640f5ad07a221"
|
|
||||||
dependencies = [
|
|
||||||
"deki_core",
|
|
||||||
"deki_derive",
|
|
||||||
"deki_lerp",
|
|
||||||
"deki_macros",
|
|
||||||
"deki_proc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deki_core"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6b95a4595bf7b9f83a550c7f3daee5fa03ab7113f8ac9db49cbe91f282089c3a"
|
|
||||||
dependencies = [
|
|
||||||
"buns",
|
|
||||||
"derive-new",
|
|
||||||
"derive_more",
|
|
||||||
"extension-traits",
|
|
||||||
"fastapprox",
|
|
||||||
"fastrand",
|
|
||||||
"maflow",
|
|
||||||
"type_cell",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deki_derive"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7812924b99c75f34230c3cff26a07e0d4253f56b84865d5e3f3750ff0dcb1db6"
|
|
||||||
dependencies = [
|
|
||||||
"derive_preset",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deki_lerp"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b64245eb17aca538ee0fb665909b324eb9219f6df57b029af5c1c53aaada0be5"
|
|
||||||
dependencies = [
|
|
||||||
"deki_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deki_macros"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "058a36abf7e6c386334e058279c3aecc80bb8bd56f4254837d0f9c4eeafaaaa4"
|
|
||||||
dependencies = [
|
|
||||||
"deki_core",
|
|
||||||
"deki_proc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deki_proc"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "47ae1da716b4b85978363cefa6963d63d0896ce9e4295b12c4a1636ad264dee3"
|
|
||||||
dependencies = [
|
|
||||||
"convert_case",
|
|
||||||
"extension-traits",
|
|
||||||
"maflow",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.90",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "delaunator"
|
name = "delaunator"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@ -1926,17 +1819,6 @@ dependencies = [
|
|||||||
"robust",
|
"robust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derive-new"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.90",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_more"
|
name = "derive_more"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@ -1952,23 +1834,12 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"convert_case",
|
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.90",
|
"syn 2.0.90",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derive_preset"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5c676aecfc734fb672c8bf150b6984da6397d05a269a6bbe7308d6ddc91edf7e"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -2185,56 +2056,12 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ext-trait"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "703090345f7d5de48379b391c9dfe69967a3c1694730a3e53bf4c905f71069c0"
|
|
||||||
dependencies = [
|
|
||||||
"ext-trait-proc_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ext-trait-proc_macros"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bd9f3f15f123dee4e8a6b14f033ba22904a48c5935505dc07225ce440e640d8b"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "extension-traits"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "360cbc11ebc403c8ebb731dfb4d3950835d40d3d9a20f0e89a27b17e991d0863"
|
|
||||||
dependencies = [
|
|
||||||
"ext-trait",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fastapprox"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9dfa3c0fd35278e839805680f4c2f673ca71eb91068115b4a611e71429bc0c46"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fdeflate"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
|
|
||||||
dependencies = [
|
|
||||||
"simd-adler32",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fixedbitset"
|
name = "fixedbitset"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@ -2247,16 +2074,6 @@ version = "0.5.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "flate2"
|
|
||||||
version = "1.0.35"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
|
|
||||||
dependencies = [
|
|
||||||
"crc32fast",
|
|
||||||
"miniz_oxide",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foldhash"
|
name = "foldhash"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@ -2324,7 +2141,7 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "forestiles"
|
name = "forestiles"
|
||||||
version = "0.4.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_logger",
|
"android_logger",
|
||||||
"bevy",
|
"bevy",
|
||||||
@ -2333,7 +2150,6 @@ dependencies = [
|
|||||||
"console_log",
|
"console_log",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"log",
|
"log",
|
||||||
"mevy",
|
|
||||||
"noise",
|
"noise",
|
||||||
"rand",
|
"rand",
|
||||||
"voronoice",
|
"voronoice",
|
||||||
@ -2773,7 +2589,6 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
"byteorder-lite",
|
"byteorder-lite",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"png",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2944,12 +2759,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "maflow"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "102d5acb8c2bd7b07a6e5cd3b7f73bc5cd401a96d8f78df86464afa62b962fde"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "malloc_buf"
|
name = "malloc_buf"
|
||||||
version = "0.0.6"
|
version = "0.0.6"
|
||||||
@ -2998,100 +2807,12 @@ dependencies = [
|
|||||||
"paste",
|
"paste",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8802cdd2c9767abb83234d4b016917ab08cdb7fdae97a3a3e0a28a5f80febbd5"
|
|
||||||
dependencies = [
|
|
||||||
"mevy_core",
|
|
||||||
"mevy_ecs",
|
|
||||||
"mevy_ui",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_core"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a388e5018afe90d85cd6e925a8c99a361e503b07aae760d70a432bdd1ab86172"
|
|
||||||
dependencies = [
|
|
||||||
"deki",
|
|
||||||
"mevy_core_syntax 0.1.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_core_syntax"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2bece892cccb973e88cd8c4b686e2525a6f2a5e839e0870ac00e3d8fdd952e0e"
|
|
||||||
dependencies = [
|
|
||||||
"deki",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_core_syntax"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4915267a4ed798a3e9ef2fd1fff1b2cb5d1f356c5d131036e0ecddeae15ee267"
|
|
||||||
dependencies = [
|
|
||||||
"deki",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_ecs"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "407781ab6299ae18ebb9734a4db17ec6a865a31e196c2af926d16e552410f76f"
|
|
||||||
dependencies = [
|
|
||||||
"mevy_ecs_syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_ecs_syntax"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "be2b6d34fd01773ec549d05350d66141e8e2651f5123c41f8828306c8121f6e3"
|
|
||||||
dependencies = [
|
|
||||||
"deki",
|
|
||||||
"mevy_core_syntax 0.2.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_ui"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bcea8c31c0895195aeb830b0edd650d7d0af71bec43721a9ace7723fed3b693c"
|
|
||||||
dependencies = [
|
|
||||||
"deki",
|
|
||||||
"mevy_ui_syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mevy_ui_syntax"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a4cb9b2bb1c24ff7b13aecf3003849b6d6d3f4593b1ef321a8708ed431518d2a"
|
|
||||||
dependencies = [
|
|
||||||
"deki",
|
|
||||||
"mevy_core_syntax 0.2.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minimal-lexical"
|
name = "minimal-lexical"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "miniz_oxide"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
|
|
||||||
dependencies = [
|
|
||||||
"adler2",
|
|
||||||
"simd-adler32",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "22.1.0"
|
version = "22.1.0"
|
||||||
@ -3683,19 +3404,6 @@ version = "0.3.30"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "png"
|
|
||||||
version = "0.17.16"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"crc32fast",
|
|
||||||
"fdeflate",
|
|
||||||
"flate2",
|
|
||||||
"miniz_oxide",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "3.7.3"
|
version = "3.7.3"
|
||||||
@ -4115,12 +3823,6 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simd-adler32"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "skrifa"
|
name = "skrifa"
|
||||||
version = "0.22.3"
|
version = "0.22.3"
|
||||||
@ -4538,16 +4240,6 @@ version = "0.24.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
|
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "type_cell"
|
|
||||||
version = "0.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f6d985656e9b8900f54ed89cce2fccf14f6c1e079f1a519635a3ba3c4a896e1e"
|
|
||||||
dependencies = [
|
|
||||||
"once_cell",
|
|
||||||
"paste",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typeid"
|
name = "typeid"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
|
17
Cargo.toml
17
Cargo.toml
@ -1,13 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "forestiles"
|
name = "forestiles"
|
||||||
version = "0.4.0"
|
version = "0.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "forestiles"
|
name = "forestiles"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
crate-type=[
|
crate-type=[
|
||||||
"cdylib"
|
"staticlib",
|
||||||
|
"cdylib",
|
||||||
|
"rlib"
|
||||||
]
|
]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
@ -32,14 +34,12 @@ bevy = { version = "0.15", default-features = false, features = [
|
|||||||
"sysinfo_plugin",
|
"sysinfo_plugin",
|
||||||
"webgl2",
|
"webgl2",
|
||||||
"wayland",
|
"wayland",
|
||||||
"png"
|
|
||||||
]}
|
]}
|
||||||
bevy-inspector-egui = { version = "0.28", default-features = false, features = [
|
bevy-inspector-egui = { version = "0.28", default-features = false, features = [
|
||||||
"bevy_image",
|
"bevy_image",
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"egui_open_url"
|
"egui_open_url"
|
||||||
]}
|
]}
|
||||||
mevy = "0.1"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
voronoice = "0.2"
|
voronoice = "0.2"
|
||||||
@ -65,12 +65,15 @@ android_logger = "0.14"
|
|||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 1
|
opt-level = 1
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
|
||||||
# Enable a large amount of optimization in the dev profile for dependencies.
|
# Enable a large amount of optimization in the dev profile for dependencies.
|
||||||
# [profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
# opt-level = 1
|
opt-level = 3
|
||||||
|
|
||||||
[package.metadata.android]
|
[package.metadata.android]
|
||||||
package = "org.forestiles.game"
|
package = "org.forestiles.example"
|
||||||
apk_name = "forestiles"
|
apk_name = "forestiles"
|
||||||
strip = "strip"
|
strip = "strip"
|
||||||
# see https://github.com/rust-mobile/cargo-apk
|
# see https://github.com/rust-mobile/cargo-apk
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
@ -1,11 +1,9 @@
|
|||||||
#![feature(duration_constructors)]
|
|
||||||
use bevy::{prelude::*, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}};
|
use bevy::{prelude::*, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}};
|
||||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||||
|
|
||||||
pub mod map;
|
pub mod map;
|
||||||
pub mod camera;
|
pub mod camera;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub mod time;
|
|
||||||
|
|
||||||
#[bevy_main]
|
#[bevy_main]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
@ -16,7 +14,6 @@ pub fn main() {
|
|||||||
camera::Plugin,
|
camera::Plugin,
|
||||||
map::Plugin,
|
map::Plugin,
|
||||||
ui::Plugin,
|
ui::Plugin,
|
||||||
time::Plugin,
|
|
||||||
FrameTimeDiagnosticsPlugin,
|
FrameTimeDiagnosticsPlugin,
|
||||||
LogDiagnosticsPlugin {
|
LogDiagnosticsPlugin {
|
||||||
filter: Some(vec![FrameTimeDiagnosticsPlugin::FPS]),
|
filter: Some(vec![FrameTimeDiagnosticsPlugin::FPS]),
|
||||||
|
126
src/map.rs
126
src/map.rs
@ -1,6 +1,6 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use bevy::{asset::RenderAssetUsages, picking::PickSet, prelude::*, render::mesh::{Indices, PrimitiveTopology}};
|
use bevy::{asset::RenderAssetUsages, picking::PickSet, prelude::*, render::mesh::{Indices, PrimitiveTopology}, utils::HashMap};
|
||||||
use noise::{Fbm, MultiFractal, NoiseFn, Perlin};
|
use noise::{Fbm, MultiFractal, NoiseFn, Perlin};
|
||||||
use rand::{thread_rng, Rng, SeedableRng};
|
use rand::{thread_rng, Rng, SeedableRng};
|
||||||
use voronoice::{BoundingBox, Point, VoronoiBuilder};
|
use voronoice::{BoundingBox, Point, VoronoiBuilder};
|
||||||
@ -9,16 +9,15 @@ mod cells;
|
|||||||
mod picking;
|
mod picking;
|
||||||
use picking::*;
|
use picking::*;
|
||||||
use cells::*;
|
use cells::*;
|
||||||
pub use cells::CellKind;
|
|
||||||
|
|
||||||
use crate::{time::GameTime, ui::CurrentAction};
|
|
||||||
|
|
||||||
pub struct Plugin;
|
pub struct Plugin;
|
||||||
impl bevy::prelude::Plugin for Plugin {
|
impl bevy::prelude::Plugin for Plugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(Startup, setup)
|
app.add_systems(Startup, setup)
|
||||||
|
.insert_resource(Time::<Fixed>::from_seconds(0.25)) // Time for a day
|
||||||
|
.add_systems(FixedUpdate, update_cells)
|
||||||
.add_systems(PreUpdate, picking_backend.in_set(PickSet::Backend))
|
.add_systems(PreUpdate, picking_backend.in_set(PickSet::Backend))
|
||||||
.add_systems(Update, (update_map_mesh, cells_regeneration, expand))
|
.add_systems(Update, update_map_mesh)
|
||||||
.insert_resource(ClearColor(Color::srgb(0., 0., 1.)))
|
.insert_resource(ClearColor(Color::srgb(0., 0., 1.)))
|
||||||
.insert_resource(Seed(thread_rng().gen()));
|
.insert_resource(Seed(thread_rng().gen()));
|
||||||
}
|
}
|
||||||
@ -66,7 +65,7 @@ fn setup(
|
|||||||
.set_lloyd_relaxation_iterations(3)
|
.set_lloyd_relaxation_iterations(3)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut cells = Vec::with_capacity(SIZE);
|
let mut cells_data = Vec::with_capacity(SIZE);
|
||||||
let z_noise = Fbm::<Perlin>::new(seed.0);
|
let z_noise = Fbm::<Perlin>::new(seed.0);
|
||||||
let moisture_noise = Fbm::<Perlin>::new(seed.0+1)
|
let moisture_noise = Fbm::<Perlin>::new(seed.0+1)
|
||||||
.set_frequency(2.);
|
.set_frequency(2.);
|
||||||
@ -90,23 +89,27 @@ fn setup(
|
|||||||
} else {
|
} else {
|
||||||
CellKind::Stone
|
CellKind::Stone
|
||||||
};
|
};
|
||||||
cells.push(Cell {
|
cells_data.push(CellData::new(k, i, (z*255.) as u8, (m*255.) as u8, 0, vec![]));
|
||||||
kind: k,
|
|
||||||
voronoi_id: i,
|
|
||||||
altitude: (z*255.) as u8,
|
|
||||||
vertices: vec![]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let mut poss = Vec::new();
|
let mut poss = Vec::new();
|
||||||
|
let mut colors = Vec::new();
|
||||||
let mut indices = Vec::new();
|
let mut indices = Vec::new();
|
||||||
|
|
||||||
for (c, cd) in voronoi.iter_cells().zip(cells.iter_mut()).filter(|(_,cd)| cd.kind != CellKind::Forest) {
|
for (c, cd) in voronoi.iter_cells().zip(cells_data.iter_mut()).filter(|(_,cd)| cd.kind != CellKind::Forest) {
|
||||||
|
let color = cd.color();
|
||||||
|
// if c.site() == selected_tile {
|
||||||
|
// color[0] = (color[0]+0.4).clamp(0., 1.);
|
||||||
|
// color[1] = (color[1]+0.4).clamp(0., 1.);
|
||||||
|
// color[2] = (color[2]+0.4).clamp(0., 1.);
|
||||||
|
// }
|
||||||
let vs = c.iter_vertices().collect::<Vec<_>>();
|
let vs = c.iter_vertices().collect::<Vec<_>>();
|
||||||
let i = poss.len();
|
let i = poss.len();
|
||||||
for v in vs.iter() {
|
for v in vs.iter() {
|
||||||
poss.push(Vec3::new(v.x as f32, v.y as f32, 0.));
|
poss.push(Vec3::new(v.x as f32, v.y as f32, 0.));// [v.x as f32, v.y as f32, 0.]);
|
||||||
|
// poss.push(Vertex::new_col([v.x as f32, v.y as f32], color, 1));
|
||||||
|
colors.push(color);
|
||||||
}
|
}
|
||||||
for v in 1..(vs.len()-1) {
|
for v in 1..(vs.len()-1) {
|
||||||
indices.extend_from_slice(&[i as u32, (i+v) as u32, (i+v+1) as u32]);
|
indices.extend_from_slice(&[i as u32, (i+v) as u32, (i+v+1) as u32]);
|
||||||
@ -114,7 +117,6 @@ fn setup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let colors = vec![[0.; 4]; poss.len()];
|
|
||||||
let mesh = Mesh::new(PrimitiveTopology::TriangleList, RenderAssetUsages::default())
|
let mesh = Mesh::new(PrimitiveTopology::TriangleList, RenderAssetUsages::default())
|
||||||
// Add 4 vertices, each with its own position attribute (coordinate in
|
// Add 4 vertices, each with its own position attribute (coordinate in
|
||||||
// 3D space), for each of the corners of the parallelogram.
|
// 3D space), for each of the corners of the parallelogram.
|
||||||
@ -128,7 +130,7 @@ fn setup(
|
|||||||
)
|
)
|
||||||
.with_inserted_indices(Indices::U32(indices));
|
.with_inserted_indices(Indices::U32(indices));
|
||||||
|
|
||||||
let mut cells_entities = Vec::with_capacity(cells.len());
|
let mut cells_entities = Vec::with_capacity(cells_data.len());
|
||||||
cmds.spawn((
|
cmds.spawn((
|
||||||
Mesh2d(meshes.add(mesh)),
|
Mesh2d(meshes.add(mesh)),
|
||||||
MeshMaterial2d(materials.add(ColorMaterial::default())),
|
MeshMaterial2d(materials.add(ColorMaterial::default())),
|
||||||
@ -138,61 +140,21 @@ fn setup(
|
|||||||
MeshNeedsUpdate(true),
|
MeshNeedsUpdate(true),
|
||||||
MapMarker
|
MapMarker
|
||||||
)).with_children(|parent| {
|
)).with_children(|parent| {
|
||||||
for cell in cells {
|
for cd in cells_data {
|
||||||
let kind = cell.kind;
|
let mut cmd = parent.spawn((cd, LastUpdate(0)));
|
||||||
let mut cmd = parent.spawn(cell);
|
cmd.observe(|trigger: Trigger<Pointer<Click>>, mut cells: Query<&mut CellData>, mut map_needs_update: Query<&mut MeshNeedsUpdate, With<MapMarker>>| {
|
||||||
match kind {
|
if trigger.duration > Duration::from_millis(100) {
|
||||||
CellKind::Grass | CellKind::Forest => {
|
|
||||||
cmd.insert((Wealth(0), Regeneration {
|
|
||||||
last_update: Duration::ZERO,
|
|
||||||
full_growth_duration: kind.regen_full_growth_duration()
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
cmd.observe(|
|
|
||||||
trigger: Trigger<Pointer<Click>>,
|
|
||||||
mut cells: Query<&mut Cell>,
|
|
||||||
mut map_needs_update: Query<&mut MeshNeedsUpdate, With<MapMarker>>,
|
|
||||||
mut cmds: Commands,
|
|
||||||
ca: Res<CurrentAction>,
|
|
||||||
gt: Res<GameTime>,
|
|
||||||
| {
|
|
||||||
if trigger.duration > Duration::from_millis(200) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
match *ca {
|
let mut cd = cells.get_mut(trigger.target).unwrap();
|
||||||
CurrentAction::ChangeCell(ck) => {
|
match cd.kind {
|
||||||
let mut cell = cells.get_mut(trigger.target).unwrap();
|
CellKind::Dirt | CellKind::Grass => {
|
||||||
match ck {
|
cd.kind = CellKind::Forest;
|
||||||
CellKind::Forest => match cell.kind {
|
map_needs_update.single_mut().0 = true;
|
||||||
CellKind::Dirt | CellKind::Grass => {
|
},
|
||||||
cmds.entity(trigger.target).insert((Wealth(0), Regeneration {
|
|
||||||
last_update: gt.current,
|
|
||||||
full_growth_duration: CellKind::Forest.regen_full_growth_duration()
|
|
||||||
}));
|
|
||||||
cell.kind = CellKind::Forest;
|
|
||||||
map_needs_update.single_mut().0 = true;
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
CellKind::Grass => match cell.kind {
|
|
||||||
CellKind::Dirt => {
|
|
||||||
cmds.entity(trigger.target).insert((Wealth(0), Regeneration {
|
|
||||||
last_update: gt.current,
|
|
||||||
full_growth_duration: CellKind::Grass.regen_full_growth_duration()
|
|
||||||
}));
|
|
||||||
cell.kind = CellKind::Grass;
|
|
||||||
map_needs_update.single_mut().0 = true;
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
dbg!(trigger.duration);
|
||||||
});
|
});
|
||||||
cells_entities.push(cmd.id());
|
cells_entities.push(cmd.id());
|
||||||
}
|
}
|
||||||
@ -200,8 +162,30 @@ fn setup(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct LastUpdate(usize);
|
||||||
|
|
||||||
|
fn update_cells(
|
||||||
|
mut cells: Query<(&mut CellData, &mut LastUpdate)>,
|
||||||
|
mut map_needs_update: Query<&mut MeshNeedsUpdate, With<MapMarker>>
|
||||||
|
) {
|
||||||
|
let mut map_needs_update = map_needs_update.single_mut();
|
||||||
|
for (mut cd, mut lu) in cells.iter_mut() {
|
||||||
|
lu.0 += 1;
|
||||||
|
if lu.0 > match cd.kind {
|
||||||
|
CellKind::Void | CellKind::Sea | CellKind::Beach | CellKind::Dirt | CellKind::Stone => usize::MAX,
|
||||||
|
CellKind::Forest => 100*365/4, // Let's say that a forest takes 100 years to mature
|
||||||
|
CellKind::Grass => 7*7/4 // Let's say that grass takes 7 weaks to reach its max
|
||||||
|
} {
|
||||||
|
lu.0 = 0;
|
||||||
|
cd.resource = (cd.resource + 1).clamp(0, 4);
|
||||||
|
map_needs_update.0 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn update_map_mesh(
|
fn update_map_mesh(
|
||||||
cells: Query<(&Cell, Option<&Wealth>)>,
|
cells: Query<&CellData>,
|
||||||
mut map: Query<(&Mesh2d, &mut MapColors, &mut MeshNeedsUpdate), With<MapMarker>>,
|
mut map: Query<(&Mesh2d, &mut MapColors, &mut MeshNeedsUpdate), With<MapMarker>>,
|
||||||
mut meshes: ResMut<Assets<Mesh>>
|
mut meshes: ResMut<Assets<Mesh>>
|
||||||
) {
|
) {
|
||||||
@ -209,9 +193,9 @@ fn update_map_mesh(
|
|||||||
if needs_update.0 {
|
if needs_update.0 {
|
||||||
if let Some(mesh) = meshes.get_mut(mesh) {
|
if let Some(mesh) = meshes.get_mut(mesh) {
|
||||||
let mut modified = false;
|
let mut modified = false;
|
||||||
for (cell, wealth) in cells.iter() {
|
for cd in cells.iter() {
|
||||||
let col = cell.color(wealth.map(|w| w.0).unwrap_or_default());
|
let col = cd.color();
|
||||||
for id in cell.vertices.iter() {
|
for id in cd.vertices.iter() {
|
||||||
modified = modified || cols.0[*id] != col;
|
modified = modified || cols.0[*id] != col;
|
||||||
cols.0[*id] = col.clone();
|
cols.0[*id] = col.clone();
|
||||||
}
|
}
|
||||||
|
126
src/map/cells.rs
126
src/map/cells.rs
@ -1,14 +1,8 @@
|
|||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use rand::{seq::IteratorRandom, thread_rng, Rng};
|
|
||||||
|
|
||||||
use crate::time::GameTime;
|
|
||||||
|
|
||||||
use super::{CellsEntities, MapMarker, MeshNeedsUpdate, Voronoi};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum CellKind {
|
pub enum CellKind {
|
||||||
|
Void,
|
||||||
Sea,
|
Sea,
|
||||||
Beach,
|
Beach,
|
||||||
Forest,
|
Forest,
|
||||||
@ -16,112 +10,36 @@ pub enum CellKind {
|
|||||||
Stone,
|
Stone,
|
||||||
Grass
|
Grass
|
||||||
}
|
}
|
||||||
impl CellKind {
|
|
||||||
pub fn regen_full_growth_duration(&self) -> Duration {
|
|
||||||
match self {
|
|
||||||
CellKind::Sea | CellKind::Beach | CellKind::Dirt | CellKind::Stone => unreachable!(),
|
|
||||||
CellKind::Forest => Duration::from_days(365*100), // Let's say that a forest takes 100 years to mature
|
|
||||||
CellKind::Grass => Duration::from_weeks(7) // Let's say that grass takes 7 weeks to reach its max
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Component)]
|
#[derive(Debug, Component)]
|
||||||
pub struct Cell {
|
pub struct CellData {
|
||||||
pub kind: CellKind,
|
pub kind: CellKind,
|
||||||
pub voronoi_id: usize,
|
pub cid: usize,
|
||||||
pub altitude: u8,
|
z: u8,
|
||||||
|
pub moisture: u8,
|
||||||
|
pub resource: u8, // How much resource there is (between 0 and 4)
|
||||||
pub vertices: Vec<usize>
|
pub vertices: Vec<usize>
|
||||||
}
|
}
|
||||||
impl Cell {
|
impl CellData {
|
||||||
pub fn color(&self, wealth: u8) -> [f32; 4] {
|
pub fn new(kind: CellKind, cell: usize, z: u8, moisture: u8, resource: u8, vertices: Vec<usize>) -> Self {
|
||||||
|
Self {
|
||||||
|
kind,
|
||||||
|
cid: cell,
|
||||||
|
z,
|
||||||
|
moisture,
|
||||||
|
resource,
|
||||||
|
vertices
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn color(&self) -> [f32; 4] {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
|
CellKind::Void => [0.; 4],
|
||||||
CellKind::Sea => [0., 0., 1., 1.],
|
CellKind::Sea => [0., 0., 1., 1.],
|
||||||
CellKind::Beach => [0.82, 0.84, 0.51, 1.],
|
CellKind::Beach => [0.82, 0.84, 0.51, 1.],
|
||||||
CellKind::Forest => [0., 0.5 - (wealth as f32/255.*0.4), 0., 1.],
|
CellKind::Forest => [0., 0.5 - (self.resource as f32/4.*0.4), 0., 1.],
|
||||||
CellKind::Dirt => [0.53 - (wealth as f32/255.*0.4), 0.38-(wealth as f32/255.*0.4), 0.29-(wealth as f32/255.*0.4), 1.],
|
CellKind::Dirt => [0.53 - (self.resource as f32/4.*0.4), 0.38-(self.resource as f32/4.*0.4), 0.29-(self.resource as f32/4.*0.4), 1.],
|
||||||
CellKind::Stone => [0.5, 0.5, 0.5, 1.],
|
CellKind::Stone => [0.5, 0.5, 0.5, 1.],
|
||||||
CellKind::Grass => [(136./255.) - (wealth as f32/255.*0.15), (154./255.) + (wealth as f32/255.*0.1), (59./255.) - (wealth as f32/255.*0.15), 1.]
|
CellKind::Grass => [(136./255.) - (self.resource as f32/4.*0.4), (204./255.) - (self.resource as f32/4.*0.4), (59./255.) - (self.resource as f32/4.*0.4), 1.]
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct Wealth(pub u8);
|
|
||||||
|
|
||||||
impl Default for Wealth {
|
|
||||||
fn default() -> Self {
|
|
||||||
Wealth(u8::MAX)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
#[require(Wealth)]
|
|
||||||
pub struct Regeneration {
|
|
||||||
pub last_update: Duration,
|
|
||||||
pub full_growth_duration: Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cells_regeneration(
|
|
||||||
mut cells: Query<(&mut Regeneration, &mut Wealth)>,
|
|
||||||
mut map_needs_update: Query<&mut MeshNeedsUpdate, With<MapMarker>>,
|
|
||||||
gt: Res<GameTime>
|
|
||||||
) {
|
|
||||||
let mut map_needs_update = map_needs_update.single_mut();
|
|
||||||
for (mut regen, mut wealth) in cells.iter_mut() {
|
|
||||||
if gt.current - regen.last_update > regen.full_growth_duration/u8::MAX as u32 {
|
|
||||||
regen.last_update = gt.current;
|
|
||||||
wealth.0 = wealth.0.saturating_add(1);
|
|
||||||
map_needs_update.0 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn expand(
|
|
||||||
mut cells: Query<(&mut Cell, Option<&Wealth>)>,
|
|
||||||
map: Query<(&Voronoi, &CellsEntities)>,
|
|
||||||
mut cmds: Commands,
|
|
||||||
t: Res<Time>,
|
|
||||||
gt: Res<GameTime>
|
|
||||||
) {
|
|
||||||
let (voronoi, cells_entities) = map.single();
|
|
||||||
let mut random = thread_rng();
|
|
||||||
let mut changes = Vec::new();
|
|
||||||
for (cell, wealth) in cells.iter() {
|
|
||||||
// TODO: search beter numbers, for now they are arbitrary
|
|
||||||
if cell.kind == CellKind::Forest || cell.kind == CellKind::Grass {
|
|
||||||
let wealth = if cell.kind == CellKind::Forest {
|
|
||||||
1.
|
|
||||||
} else {
|
|
||||||
wealth.unwrap().0 as f64/255.
|
|
||||||
};
|
|
||||||
if random.gen_bool((t.elapsed_secs_f64()*(gt.speed as f64)*wealth/(60.*60.*24.*30.)).min(1.)) { // Let say that grass takes 1 months to expand
|
|
||||||
let target = voronoi.0.cell(cell.voronoi_id).iter_neighbors().choose(&mut random).unwrap();
|
|
||||||
changes.push((target, CellKind::Grass));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if cell.kind == CellKind::Forest {
|
|
||||||
if random.gen_bool((t.elapsed_secs_f64()*(gt.speed as f64)*(wealth.unwrap().0 as f64/255.).sqrt()/(60.*60.*24.*365.*5.)).min(1.)) { // Let say that forest takes 5 years to expand
|
|
||||||
let target = voronoi.0.cell(cell.voronoi_id).iter_neighbors().choose(&mut random).unwrap();
|
|
||||||
changes.push((target, CellKind::Forest));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (v_id, kind) in changes {
|
|
||||||
let target = cells_entities.0[v_id];
|
|
||||||
let (mut cell, _) = cells.get_mut(target).unwrap();
|
|
||||||
if kind == CellKind::Forest && (cell.kind == CellKind::Dirt || cell.kind == CellKind::Grass) {
|
|
||||||
cell.kind = CellKind::Forest;
|
|
||||||
cmds.entity(target).insert((Wealth(0), Regeneration {
|
|
||||||
full_growth_duration: CellKind::Forest.regen_full_growth_duration(),
|
|
||||||
last_update: gt.current
|
|
||||||
}));
|
|
||||||
} else if kind == CellKind::Grass && cell.kind == CellKind::Dirt {
|
|
||||||
cell.kind = CellKind::Grass;
|
|
||||||
cmds.entity(target).insert((Wealth(0), Regeneration {
|
|
||||||
full_growth_duration: CellKind::Grass.regen_full_growth_duration(),
|
|
||||||
last_update: gt.current
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
28
src/time.rs
28
src/time.rs
@ -1,28 +0,0 @@
|
|||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
pub struct Plugin;
|
|
||||||
impl bevy::prelude::Plugin for Plugin {
|
|
||||||
fn build(&self, app: &mut App) {
|
|
||||||
app.insert_resource(GameTime {
|
|
||||||
current: Duration::ZERO,
|
|
||||||
speed: 24. * 60. * 60. * 10.
|
|
||||||
})
|
|
||||||
.add_systems(PreUpdate, update_time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Resource)]
|
|
||||||
pub struct GameTime {
|
|
||||||
pub current: Duration,
|
|
||||||
pub speed: f32 // = game time / real time
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_time(
|
|
||||||
mut gt: ResMut<GameTime>,
|
|
||||||
time: Res<Time>
|
|
||||||
) {
|
|
||||||
let speed = gt.speed;
|
|
||||||
gt.current += Duration::from_secs_f32(time.delta_secs() * speed);
|
|
||||||
}
|
|
180
src/ui.rs
180
src/ui.rs
@ -1,156 +1,80 @@
|
|||||||
use mevy::*;
|
use std::collections::BTreeMap;
|
||||||
use bevy::{asset::embedded_asset, input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::{dbg, HashMap}, window::PrimaryWindow};
|
|
||||||
|
|
||||||
use crate::map::{self, CellKind, MapMarker};
|
use bevy::{input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::HashMap, window::PrimaryWindow};
|
||||||
|
|
||||||
// #77767b
|
use crate::map::{self, MapMarker};
|
||||||
const TABBAR_COLOR: Color = Color::srgb(119./255., 118./255., 123./255.);
|
|
||||||
|
|
||||||
// #E8E8E8
|
|
||||||
const ENABLED_BUTTON_COLOR: Color = Color::srgb(232./255., 232./255., 232./255.);
|
|
||||||
|
|
||||||
pub struct Plugin;
|
pub struct Plugin;
|
||||||
impl bevy::prelude::Plugin for Plugin {
|
impl bevy::prelude::Plugin for Plugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.init_resource::<CurrentAction>()
|
app.add_systems(Startup, setup)
|
||||||
.add_systems(Startup, setup)
|
|
||||||
.add_systems(Update, zoom_with_scroll);
|
.add_systems(Update, zoom_with_scroll);
|
||||||
embedded_asset!(app, "../assets/ui/enabled_tree.png");
|
|
||||||
embedded_asset!(app, "../assets/ui/disabled_tree.png");
|
|
||||||
embedded_asset!(app, "../assets/ui/enabled_grass.png");
|
|
||||||
embedded_asset!(app, "../assets/ui/disabled_grass.png");
|
|
||||||
embedded_asset!(app, "../assets/ui/enabled_cross.png");
|
|
||||||
embedded_asset!(app, "../assets/ui/disabled_cross.png");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Default, PartialEq, Eq)]
|
#[derive(Component)]
|
||||||
pub enum CurrentAction {
|
|
||||||
#[default]
|
|
||||||
None,
|
|
||||||
ChangeCell(CellKind)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component, Debug)]
|
|
||||||
struct PointersDragging(HashMap<PointerId, Vec2>);
|
struct PointersDragging(HashMap<PointerId, Vec2>);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MapUIComponent;
|
pub struct MapUIComponent;
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
mut world: Commands,
|
mut cmds: Commands
|
||||||
asset_server: Res<AssetServer>
|
|
||||||
) {
|
) {
|
||||||
// Spawn all ui elements as children of this one
|
cmds.spawn((
|
||||||
spawn!{
|
Node {
|
||||||
Node {width: 100%, height: 100%, display: Display::Flex, flex_direction: FlexDirection::Column, !};
|
width: Val::Percent(100.0),
|
||||||
|
height: Val::Percent(100.0),
|
||||||
|
align_items: AlignItems::Center,
|
||||||
|
justify_content: JustifyContent::Center,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
PickingBehavior {
|
PickingBehavior {
|
||||||
should_block_lower: false,
|
should_block_lower: false,
|
||||||
is_hoverable: true
|
is_hoverable: true
|
||||||
};
|
},
|
||||||
.observe(|trigger: Trigger<Pointer<DragEnd>>, mut ptrs: Query<&mut PointersDragging>| {
|
MapUIComponent,
|
||||||
if trigger.button == PointerButton::Primary {
|
PointersDragging(HashMap::new())
|
||||||
ptrs.single_mut().0.remove(&trigger.pointer_id);
|
)).observe(|trigger: Trigger<Pointer<DragStart>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||||
}
|
let event = trigger.event();
|
||||||
});
|
// dbg!(event);
|
||||||
.observe(|
|
if event.button == PointerButton::Primary {
|
||||||
trigger: Trigger<Pointer<Drag>>,
|
ptrs.get_mut(event.target).unwrap().0.insert(event.pointer_id, event.pointer_location.position);
|
||||||
mut ptrs: Query<&mut PointersDragging>,
|
}
|
||||||
mut cam: Query<&mut Transform, With<Camera2d>>,
|
}).observe(|trigger: Trigger<Pointer<DragEnd>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||||
| {
|
let event = trigger.event();
|
||||||
if trigger.button == PointerButton::Primary {
|
// dbg!(event);
|
||||||
let mut ptrs = ptrs.single_mut();
|
if event.button == PointerButton::Primary {
|
||||||
if !ptrs.0.contains_key(&trigger.pointer_id) {
|
ptrs.get_mut(event.target).unwrap().0.remove(&event.pointer_id);
|
||||||
return
|
}
|
||||||
}
|
}).observe(|
|
||||||
let mut cam = cam.single_mut();
|
trigger: Trigger<Pointer<Drag>>,
|
||||||
|
mut ptrs: Query<&mut PointersDragging>,
|
||||||
|
mut cam: Query<&mut Transform, With<Camera2d>>,
|
||||||
|
| {
|
||||||
|
let event = trigger.event();
|
||||||
|
// dbg!(event);
|
||||||
|
if event.button == PointerButton::Primary {
|
||||||
|
let mut cam = cam.single_mut();
|
||||||
|
let mut ptrs = ptrs.get_mut(event.target).unwrap();
|
||||||
|
|
||||||
let old_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
let old_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
||||||
let old_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (old_midpoint-pos).norm());
|
let old_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (old_midpoint-pos).norm());
|
||||||
ptrs.0.insert(trigger.pointer_id, trigger.pointer_location.position);
|
ptrs.0.insert(event.pointer_id, event.pointer_location.position);
|
||||||
let new_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
let new_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
||||||
let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
||||||
|
|
||||||
// move camera
|
// move camera
|
||||||
cam.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.scale.x;
|
cam.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.scale.x;
|
||||||
cam.translation.y += (new_midpoint.y - old_midpoint.y)*cam.scale.y;
|
cam.translation.y += (new_midpoint.y - old_midpoint.y)*cam.scale.y;
|
||||||
|
|
||||||
if ptrs.0.len() > 1 {
|
if ptrs.0.len() > 1 {
|
||||||
cam.scale *= old_d_to_midpoint/new_d_to_midpoint;
|
cam.scale *= old_d_to_midpoint/new_d_to_midpoint;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
[map][
|
);
|
||||||
Node{
|
// Spawn all ui elements as children of this one
|
||||||
flex_grow: 1.,
|
|
||||||
!};
|
|
||||||
PointersDragging(HashMap::new());
|
|
||||||
MapUIComponent;
|
|
||||||
PickingBehavior {
|
|
||||||
should_block_lower: false,
|
|
||||||
is_hoverable: true
|
|
||||||
};
|
|
||||||
.observe(|trigger: Trigger<Pointer<DragStart>>, mut ptrs: Query<&mut PointersDragging>| {
|
|
||||||
if trigger.button == PointerButton::Primary {
|
|
||||||
if let Ok(mut ptrs) = ptrs.get_mut(trigger.target) {
|
|
||||||
ptrs.0.insert(trigger.pointer_id, trigger.pointer_location.position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
]
|
|
||||||
[
|
|
||||||
Node{
|
|
||||||
width: 100%,
|
|
||||||
height: 10vh,
|
|
||||||
align_self: AlignSelf::FlexEnd,
|
|
||||||
!};
|
|
||||||
Button;
|
|
||||||
BackgroundColor(TABBAR_COLOR);
|
|
||||||
[forest][
|
|
||||||
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/enabled_tree.png"));
|
|
||||||
Node {
|
|
||||||
// height: 80%,
|
|
||||||
// margin: [>1vh],
|
|
||||||
!};
|
|
||||||
BackgroundColor(TABBAR_COLOR);
|
|
||||||
.observe(move |trigger: Trigger<Pointer<Click>>, mut ca: ResMut<CurrentAction>, mut bg: Query<&mut BackgroundColor>| {
|
|
||||||
if trigger.button == PointerButton::Primary {
|
|
||||||
if *ca == CurrentAction::ChangeCell(CellKind::Forest) {
|
|
||||||
*ca = CurrentAction::None;
|
|
||||||
bg.get_mut(forest).unwrap().0 = TABBAR_COLOR;
|
|
||||||
bg.get_mut(grass).unwrap().0 = TABBAR_COLOR;
|
|
||||||
} else {
|
|
||||||
*ca = CurrentAction::ChangeCell(CellKind::Forest);
|
|
||||||
bg.get_mut(forest).unwrap().0 = ENABLED_BUTTON_COLOR;
|
|
||||||
bg.get_mut(grass).unwrap().0 = TABBAR_COLOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
]
|
|
||||||
[grass][
|
|
||||||
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/enabled_grass.png"));
|
|
||||||
Node {
|
|
||||||
// height: 80%,
|
|
||||||
// margin: [>1vh],
|
|
||||||
!};
|
|
||||||
BackgroundColor(TABBAR_COLOR);
|
|
||||||
.observe(move |trigger: Trigger<Pointer<Click>>, mut ca: ResMut<CurrentAction>, mut bg: Query<&mut BackgroundColor>| {
|
|
||||||
if trigger.button == PointerButton::Primary {
|
|
||||||
if *ca == CurrentAction::ChangeCell(CellKind::Grass) {
|
|
||||||
*ca = CurrentAction::None;
|
|
||||||
bg.get_mut(forest).unwrap().0 = TABBAR_COLOR;
|
|
||||||
bg.get_mut(grass).unwrap().0 = TABBAR_COLOR;
|
|
||||||
} else {
|
|
||||||
*ca = CurrentAction::ChangeCell(CellKind::Grass);
|
|
||||||
bg.get_mut(forest).unwrap().0 = TABBAR_COLOR;
|
|
||||||
bg.get_mut(grass).unwrap().0 = ENABLED_BUTTON_COLOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn zoom_with_scroll(
|
fn zoom_with_scroll(
|
||||||
|
Loading…
Reference in New Issue
Block a user