Compare commits

...

2 commits
main ... wip

Author SHA1 Message Date
836be517a2
WIP 2022-12-11 22:25:09 +01:00
6a7ecc11b6
WIP 2022-12-11 22:24:17 +01:00
16 changed files with 632 additions and 247 deletions

276
Cargo.lock generated
View file

@ -55,9 +55,9 @@ dependencies = [
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.19" version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -131,20 +131,20 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]] [[package]]
name = "ash" name = "ash"
version = "0.37.0+1.3.209" version = "0.37.1+1.3.235"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "006ca68e0f2b03f22d6fa9f2860f85aed430d257fec20f8879b2145e7c7ae1a6" checksum = "911015c962d56e2e4052f40182ca5462ba60a3d2ff04e827c365a0ab3d65726d"
dependencies = [ dependencies = [
"libloading", "libloading",
] ]
[[package]] [[package]]
name = "async-channel" name = "async-channel"
version = "1.7.1" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833"
dependencies = [ dependencies = [
"concurrent-queue 1.2.4", "concurrent-queue 2.0.0",
"event-listener", "event-listener",
"futures-core", "futures-core",
] ]
@ -199,18 +199,18 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]] [[package]]
name = "bevy" name = "bevy"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3654d60973fcde065efcfe0c9066c81a76987d28c45233998b2ccdc581dcd914" checksum = "dae99b246505811f5bc19d2de1e406ec5d2816b421d58fa223779eb576f472c9"
dependencies = [ dependencies = [
"bevy_internal", "bevy_internal",
] ]
[[package]] [[package]]
name = "bevy_app" name = "bevy_app"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7240e455d6976b20d24bf8eda37cd9154116fe9cc2beef7bdc009b4c6fff139" checksum = "536e4d0018347478545ed8b6cb6e57b9279ee984868e81b7c0e78e0fb3222e42"
dependencies = [ dependencies = [
"bevy_derive", "bevy_derive",
"bevy_ecs", "bevy_ecs",
@ -223,9 +223,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_asset" name = "bevy_asset"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86ca05c472cd4939aed5b2980ad9b416a250ae4674824e8c4b569ddf18ab5230" checksum = "6db1bb550168304df69c867c09125e1aae7ff51cf21575396e1598bf293442c4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy_app", "bevy_app",
@ -250,9 +250,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_core" name = "bevy_core"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d344ff340874fb3f1e458f03eca2b731cb8174495e9c0828f5e4569765489cb" checksum = "96299aceb3c8362cb4aa39ff81c7ef758a5f4e768d16b5046a91628eff114ac0"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
@ -265,9 +265,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_core_pipeline" name = "bevy_core_pipeline"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13523e290f9aad62987e04836d66819fb97afeaf794847b6f64121c62a4db916" checksum = "dc128a9860aadf16fb343ae427f2768986fd91dce64d945455acda9759c48014"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -285,9 +285,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_derive" name = "bevy_derive"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a12e50d2ff8423438e971c44a90baefc9e351edd45b50b8d077f9ad4f7a0a2a5" checksum = "7baf73c58d41c353c6fd08e6764a2e7420c9f19e8227b391c50981db6d0282a6"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils",
"quote", "quote",
@ -296,9 +296,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_diagnostic" name = "bevy_diagnostic"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3415f3a220d8706daac84986d744374fd18883add3a22e894af8cddf2cf1c29" checksum = "63bf96ec7980fa25b77ff6c72dfafada477936c0dab76c1edf6c028c0e5fe0e4"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_core", "bevy_core",
@ -310,9 +310,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_ecs" name = "bevy_ecs"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b29e39772df5e8939f7f540ee152569eebeb3c2cc35a68670688ae008ba2cf" checksum = "d4c071d7c6bc9801253485e05d0c257284150de755391902746837ba21c0cf74"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"bevy_ecs_macros", "bevy_ecs_macros",
@ -330,9 +330,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_ecs_macros" name = "bevy_ecs_macros"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10b8e7e7fb3ab9554c77e0f8a2531abd05d40ddb0145a8dfa72434cefa52ee5c" checksum = "c15bd45438eeb681ad74f2d205bb07a5699f98f9524462a30ec764afab2742ce"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils",
"proc-macro2", "proc-macro2",
@ -342,9 +342,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_egui" name = "bevy_egui"
version = "0.17.0" version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33bf9a0085909f3dc3d5ca7be6a6e6792b8b30b98bba9cca13baa49e2f3e3206" checksum = "1cec5fb091ccae94917266fe9b1af8339ef1e47763360b38273a31457598b030"
dependencies = [ dependencies = [
"arboard", "arboard",
"bevy", "bevy",
@ -354,9 +354,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_encase_derive" name = "bevy_encase_derive"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a0773119830d63dde225338c0c556f84cd68e8e69de5b62a1b172fdddc5b915" checksum = "962b6bb0d30e92ec2e6c29837acce9e55b920733a634e7c3c5fd5a514bea7a24"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils",
"encase_derive_impl", "encase_derive_impl",
@ -364,9 +364,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_gltf" name = "bevy_gltf"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd77158983e09cbbb8115a2c629bdf3249cfff58e8e19f1c62861b1e5495eaf1" checksum = "e853e346ba412354e02292c7aa5b9a9dccdfa748e273b1b7ebf8f6a172f89712"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64", "base64",
@ -392,9 +392,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_hierarchy" name = "bevy_hierarchy"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b5181dc3d621c3d18a1209791e82199409d6ddf5376ee19f2e26ad7bfd9b06" checksum = "8dd6d50c48c6e1bcb5e08a768b765323292bb3bf3a439b992754c57ffb85b23a"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_core", "bevy_core",
@ -407,9 +407,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_input" name = "bevy_input"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f72c3037535eb41b863a22c2e58d3845a096401f9b92204b6a240e36a5151b" checksum = "3378b5171284f4c4c0e8307081718a9fe458f846444616bd82d69110dcabca51"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
@ -421,9 +421,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_internal" name = "bevy_internal"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ff89c2c2644c588d72cf505f15ad515479705c82ad7aa359ad2249646995a76" checksum = "4c46014b7e885b1311de06b6039e448454a4db55b8d35464798ba88faa186e11"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -455,9 +455,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_log" name = "bevy_log"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66c1d5f2cbcf5c3ce87d42afb6ba98177f8f758278364cbc79a2b3bf38415f0e" checksum = "6c480bac54cf4ae76edc3ae9ae3fa7c5e1b385e7f2111ef5ec3fd00cf3a7998b"
dependencies = [ dependencies = [
"android_log-sys", "android_log-sys",
"bevy_app", "bevy_app",
@ -471,9 +471,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_macro_utils" name = "bevy_macro_utils"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "656fa7b3434ac5d5c2883dde3c075f834ff51178f2f48ef2454b6f2ada75cb15" checksum = "022bb69196deeea691b6997414af85bbd7f2b34a8914c4aa7a7ff4dfa44f7677"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn",
@ -482,9 +482,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_math" name = "bevy_math"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b26459575a5f9695788e3487aa0a5f9252562e0fc57065e6f35f370dbfac7d4a" checksum = "d434c77ab766c806ed9062ef8a7285b3b02b47df51f188d4496199c3ac062eaf"
dependencies = [ dependencies = [
"glam", "glam",
"serde", "serde",
@ -492,18 +492,18 @@ dependencies = [
[[package]] [[package]]
name = "bevy_mikktspace" name = "bevy_mikktspace"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e67d9caff1be480eb097e1a5ee7332762e19a2ea3d07496017fc8221ea6bc46" checksum = "bbfb5908d33fd613069be516180b8f138aaaf6e41c36b1fd98c6c29c00c24a13"
dependencies = [ dependencies = [
"glam", "glam",
] ]
[[package]] [[package]]
name = "bevy_pbr" name = "bevy_pbr"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2e5069b351743e5660f837671135a7aac585cd2c1d7d0b90d92a2d84c2a1fd" checksum = "310b1f260a475d81445623e138e1b7245759a42310bc1f84b550a3f4ff8763bf"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -523,15 +523,15 @@ dependencies = [
[[package]] [[package]]
name = "bevy_ptr" name = "bevy_ptr"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c36f4d3af0cda50c07e2010d0351ab79594681116edd280592ca394db73ef32b" checksum = "8ec44f7655039546bc5d34d98de877083473f3e9b2b81d560c528d6d74d3eff4"
[[package]] [[package]]
name = "bevy_reflect" name = "bevy_reflect"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c39f74d7786a0016c74b6bfb57f44928d536bef8bf6db7505d4cbe9435aeda7b" checksum = "6deae303a7f69dc243b2fa35b5e193cc920229f448942080c8eb2dbd9de6d37a"
dependencies = [ dependencies = [
"bevy_math", "bevy_math",
"bevy_ptr", "bevy_ptr",
@ -549,9 +549,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_reflect_derive" name = "bevy_reflect_derive"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b2c0aab36b060e88cd93c56710d9ce8ab6107596dc4cbb8a9d84ba98f39c63b" checksum = "a2bf4cb9cd5acb4193f890f36cb63679f1502e2de025e66a63b194b8b133d018"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils",
"bit-set", "bit-set",
@ -563,9 +563,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_render" name = "bevy_render"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14033813fdd9587663ffa6b6d84327f30bd0398b40386677704bd4d608625420" checksum = "2e3282a8f8779d2aced93207fbed73f740937c6c2bd27bd84f0799b081c7fca5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy_app", "bevy_app",
@ -605,9 +605,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_render_macros" name = "bevy_render_macros"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e29db44fb38743a08e71bed324a19b8ce2e9f2853abcb4640e03625dd55cc186" checksum = "b7acae697776ac05bea523e1725cf2660c91c53abe72c66782ea1e1b9eedb572"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils",
"proc-macro2", "proc-macro2",
@ -617,9 +617,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_scene" name = "bevy_scene"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b98c58cba6417961856a57ba1116d78db3364b8e791ac517175f04b9abdb6b" checksum = "ea9c66a628c833d53bae54fe94cbc0d3f12c29e9d2e6c3f2356d45ad57db0c8c"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bevy_app", "bevy_app",
@ -639,9 +639,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_sprite" name = "bevy_sprite"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b135b2ccf7c5eaf9b3e20e39ef80081842f122081c8ce988cb2054afd1af270e" checksum = "5ec01c7db7f698d95bcb70708527c3ae6bcdc78fc247abe74f935cae8f0a1145"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -664,9 +664,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_tasks" name = "bevy_tasks"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5d91d94d2db1476d7452509c1967fe83d66da5f683f5d49ba31e0f455adfcdc" checksum = "680b16b53df9c9f24681dd95f4d772d83760bd19adf8bca00f358a3aad997853"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"async-executor", "async-executor",
@ -679,9 +679,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_text" name = "bevy_text"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe4282d77fb5dd38bb2a7736a770f5e499782b8c546b9f7d73f6893ab04c8041" checksum = "60c74c1bdaabde7db28f6728aa13bc7b1d744a2201b2bbfd83d2224404c57f5c"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"anyhow", "anyhow",
@ -702,9 +702,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_time" name = "bevy_time"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a259a4b04f5ae2d02998247a69e5a711b0754eb22971320bf727c6f4d7bf38fa" checksum = "1a5c38a6d3ea929c7f81e6adf5a6c62cf7e8c40f5106c2174d6057e9d8ea624d"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
@ -715,9 +715,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_transform" name = "bevy_transform"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7b4cdac87f8a58c3ec166b5673dd35565c61eb0ec648e3b0cc30083170c0fb3" checksum = "ba13c57a040b89767191a6f6d720a635b7792793628bfa41a9e38b7026484aec"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
@ -728,9 +728,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_ui" name = "bevy_ui"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da6d85fcefe5a2bf259c2ff58a7a29b6102070242dc385b42a2656f4e8918883" checksum = "60e82ace6156f11fcdf2319102ff8fb8367b82d1e32b7d05d387a1963602f965"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_asset", "bevy_asset",
@ -757,9 +757,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_utils" name = "bevy_utils"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7473635355a99fcf7181091a2ac11df03561706b1696cb0cc72e4ddd010571" checksum = "16750aae52cd35bd7b60eb61cee883420b250e11b4a290b8d44b2b2941795739"
dependencies = [ dependencies = [
"ahash 0.7.6", "ahash 0.7.6",
"getrandom", "getrandom",
@ -771,9 +771,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_window" name = "bevy_window"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07a0d03022a6d1ec0d05c01a77f5592a9602bbc1cfc11ba457788b69f9ca175d" checksum = "0a44d3f3bd54a2261f4f57f614bf7bccc8d2832761493c0cd7dab81d98cc151e"
dependencies = [ dependencies = [
"bevy_app", "bevy_app",
"bevy_ecs", "bevy_ecs",
@ -786,9 +786,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy_winit" name = "bevy_winit"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc7b4e4f83e268dcbd6f9c4e1c18f7382e457f5f1b160da4c85d9a3f489771a" checksum = "c7b7e647ecd0b3577468da37767dcdd7c26ca9f80da0060b2ec4c77336b6d2e1"
dependencies = [ dependencies = [
"approx", "approx",
"bevy_app", "bevy_app",
@ -804,6 +804,15 @@ dependencies = [
"winit", "winit",
] ]
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.5.3" version = "0.5.3"
@ -871,12 +880,12 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]] [[package]]
name = "calloop" name = "calloop"
version = "0.10.2" version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "595eb0438b3c6d262395fe30e6de9a61beb57ea56290b00a07f227fe6e20cbf2" checksum = "19457a0da465234abd76134a5c2a910c14bd3c5558463e4396ab9a37a328e465"
dependencies = [ dependencies = [
"log", "log",
"nix 0.24.2", "nix 0.25.1",
"slotmap", "slotmap",
"thiserror", "thiserror",
"vec_map", "vec_map",
@ -884,9 +893,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.76" version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -911,12 +920,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "cobs"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
[[package]] [[package]]
name = "cocoa" name = "cocoa"
version = "0.24.1" version = "0.24.1"
@ -994,9 +997,9 @@ dependencies = [
[[package]] [[package]]
name = "const_panic" name = "const_panic"
version = "0.2.6" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed2b28323eee4fb66bb824401daa3e46bd445b9a9298a3d382b320710ba69dd" checksum = "58baae561b85ca19b3122a9ddd35c8ec40c3bcd14fe89921824eae73f7baffbf"
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
@ -1060,9 +1063,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.12" version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
@ -1562,9 +1565,9 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.1" version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
@ -1634,9 +1637,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.137" version = "0.2.138"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -1834,9 +1837,9 @@ dependencies = [
[[package]] [[package]]
name = "ndk-sys" name = "ndk-sys"
version = "0.4.0" version = "0.4.1+23.1.7779620"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046" checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"
dependencies = [ dependencies = [
"jni-sys", "jni-sys",
] ]
@ -1856,9 +1859,9 @@ dependencies = [
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.24.2" version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
@ -1866,6 +1869,19 @@ dependencies = [
"memoffset", "memoffset",
] ]
[[package]]
name = "nix"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [
"autocfg",
"bitflags",
"cfg-if",
"libc",
"memoffset",
]
[[package]] [[package]]
name = "nohash-hasher" name = "nohash-hasher"
version = "0.2.0" version = "0.2.0"
@ -2043,9 +2059,9 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot_core" name = "parking_lot_core"
version = "0.9.4" version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -2087,8 +2103,8 @@ name = "planet"
version = "0.3.1" version = "0.3.1"
dependencies = [ dependencies = [
"bevy", "bevy",
"bincode",
"crossbeam-channel", "crossbeam-channel",
"postcard",
"rand", "rand",
"serde", "serde",
] ]
@ -2105,16 +2121,6 @@ dependencies = [
"miniz_oxide 0.3.7", "miniz_oxide 0.3.7",
] ]
[[package]]
name = "postcard"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c2b180dc0bade59f03fd005cb967d3f1e5f69b13922dad0cd6e047cb8af2363"
dependencies = [
"cobs",
"serde",
]
[[package]] [[package]]
name = "pp-rs" name = "pp-rs"
version = "0.2.1" version = "0.2.1"
@ -2309,18 +2315,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.147" version = "1.0.149"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" checksum = "256b9932320c590e707b94576e3cc1f7c9024d0ee6612dfbcf1cb106cbe8e055"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.147" version = "1.0.149"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" checksum = "b4eae9b04cbffdfd550eb462ed33bc6a1b68c935127d008b27444d08380f94e4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2329,9 +2335,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.87" version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -2386,7 +2392,7 @@ dependencies = [
"lazy_static", "lazy_static",
"log", "log",
"memmap2", "memmap2",
"nix 0.24.2", "nix 0.24.3",
"pkg-config", "pkg-config",
"wayland-client", "wayland-client",
"wayland-cursor", "wayland-cursor",
@ -2429,9 +2435,9 @@ checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.103" version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2600,9 +2606,9 @@ checksum = "375812fa44dab6df41c195cd2f7fecb488f6c09fbaafb62807488cefab642bff"
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.15.0" version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
@ -2624,9 +2630,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.2.1" version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"serde", "serde",
@ -2737,7 +2743,7 @@ dependencies = [
"bitflags", "bitflags",
"downcast-rs", "downcast-rs",
"libc", "libc",
"nix 0.24.2", "nix 0.24.3",
"scoped-tls", "scoped-tls",
"wayland-commons", "wayland-commons",
"wayland-scanner", "wayland-scanner",
@ -2750,7 +2756,7 @@ version = "0.29.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902"
dependencies = [ dependencies = [
"nix 0.24.2", "nix 0.24.3",
"once_cell", "once_cell",
"smallvec", "smallvec",
"wayland-sys", "wayland-sys",
@ -2762,7 +2768,7 @@ version = "0.29.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661"
dependencies = [ dependencies = [
"nix 0.24.2", "nix 0.24.3",
"wayland-client", "wayland-client",
"xcursor", "xcursor",
] ]
@ -2818,9 +2824,9 @@ checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.14.0" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2272b17bffc8a0c7d53897435da7c1db587c87d3a14e8dae9cdb8d1d210fc0f" checksum = "81f643110d228fd62a60c5ed2ab56c4d5b3704520bd50561174ec4ec74932937"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"js-sys", "js-sys",
@ -2840,9 +2846,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-core" name = "wgpu-core"
version = "0.14.0" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73d14cad393054caf992ee02b7da6a372245d39a484f7461c1f44f6f6359bd28" checksum = "6000d1284ef8eec6076fd5544a73125fd7eb9b635f18dceeb829d826f41724ca"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-vec", "bit-vec",
@ -3097,9 +3103,9 @@ dependencies = [
[[package]] [[package]]
name = "x11-dl" name = "x11-dl"
version = "2.20.0" version = "2.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c83627bc137605acc00bb399c7b908ef460b621fc37c953db2b09f88c449ea6" checksum = "b1536d6965a5d4e573c7ef73a2c15ebcd0b2de3347bdf526c34c297c00ac40f0"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",

View file

@ -35,7 +35,7 @@ path = "planet"
default-features = false default-features = false
[dependencies.bevy] [dependencies.bevy]
version = "0.9.0" version = "0.9"
default-features = false default-features = false
[dependencies.fxhash] [dependencies.fxhash]

View file

@ -1,18 +1,18 @@
#!/bin/env /bin/sh #!/bin/env /bin/sh
echo "Debug-build with features: minimal" echo "Debug-build with features: minimal"
cargo build --no-default-features --features= && cargo build -j 6 --no-default-features --features= &&
echo "Debug-build with features: logging" && echo "Debug-build with features: logging" &&
cargo build --no-default-features --features=logging && cargo build -j 6 --no-default-features --features=logging &&
echo "Debug-build with features: render" && echo "Debug-build with features: render" &&
cargo build --no-default-features --features=render && cargo build -j 6 --no-default-features --features=render &&
echo "Debug-build with features: logging render" && echo "Debug-build with features: logging render" &&
cargo build --no-default-features --features="logging,render" && cargo build -j 6 --no-default-features --features="logging,render" &&
echo "Release-build with features: minimal" echo "Release-build with features: minimal"
cargo build --release --no-default-features --features= && cargo build -j 6 --release --no-default-features --features= &&
echo "Release-build with features: logging" && echo "Release-build with features: logging" &&
cargo build --release --no-default-features --features=logging && cargo build -j 6 --release --no-default-features --features=logging &&
echo "Release-build with features: render" && echo "Release-build with features: render" &&
cargo build --release --no-default-features --features=render && cargo build -j 6 --release --no-default-features --features=render &&
echo "Release-build with features: logging render" && echo "Release-build with features: logging render" &&
cargo build --release --no-default-features --features="logging,render" && cargo build -j 6 --release --no-default-features --features="logging,render" &&
echo "Done!" echo "Done!"

View file

@ -23,10 +23,8 @@ version = "1.0"
default-features = false default-features = false
features = ["derive"] features = ["derive"]
[dependencies.postcard] [dependencies.bincode]
version = "1.0.2" version = "1.3.3"
default-features = false
features = ["use-std"]
[dependencies.crossbeam-channel] [dependencies.crossbeam-channel]
version = "0.5.6" version = "0.5.6"

View file

@ -1,7 +1,17 @@
use serde::{Deserialize, Serialize}; use {
crate::World,
core::hash::Hash,
serde::{Deserialize, Serialize},
};
#[derive(Serialize, Deserialize)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, Default, Eq, PartialEq, Hash)]
pub struct HumanGroup { pub struct HumanGroup {
pub id: u32, pub id: u32,
pub population: u32, pub population: u32,
} }
impl HumanGroup {
pub fn update(&self, _world: &World) {
// TODO: Anything
}
}

View file

@ -1,6 +1,9 @@
pub mod human_group; pub mod human_group;
pub use human_group::HumanGroup;
pub mod terrain_cell;
pub use terrain_cell::TerrainCell;
pub mod world; pub mod world;
pub use world::{TerrainCell, World, WorldGenError}; pub use world::{World, WorldGenError};
pub mod biome; pub mod biome;
pub use biome::{BiomeStats, BiomeType}; pub use biome::{BiomeStats, BiomeType};
pub mod world_manager; pub mod world_manager;

View file

@ -1,3 +1,5 @@
pub const MAX_PERMUTATION_VALUE: u32 = 16777216;
const PERMUTATION: [u8; 512] = [ const PERMUTATION: [u8; 512] = [
151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69,
142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219,

View file

@ -1,2 +1,2 @@
// pub mod terrain_cell; pub mod terrain_cell;
pub mod world; pub mod world;

View file

@ -0,0 +1,247 @@
use {
crate::{HumanGroup, TerrainCell},
bevy::prelude::{debug, default},
serde::{
de::{Error, MapAccess, SeqAccess, Visitor},
ser::SerializeStruct,
Deserialize,
Serialize,
},
std::{
fmt::{self, Formatter},
sync::Arc,
},
};
impl<'de> Deserialize<'de> for TerrainCell {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(Deserialize)]
#[serde(field_identifier, rename_all = "snake_case")]
enum Field {
Altitude,
Rainfall,
Temperature,
LocalIteration,
BiomePresences,
Height,
Width,
HumanGroups,
}
struct TerrainCellVisitor;
impl<'de> Visitor<'de> for TerrainCellVisitor {
type Value = TerrainCell;
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
formatter.write_str("struct TerrainCell")
}
fn visit_seq<V>(self, mut seq: V) -> Result<Self::Value, V::Error>
where
V: SeqAccess<'de>,
{
std::mem::transmute::<u128>(seq);
let mut length = 0;
let altitude = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let rainfall = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let temperature = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let local_iteration = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let biome_presences = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let height = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let width = seq
.next_element()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
length += 1;
let human_groups = seq
.next_element::<Vec<HumanGroup>>()?
.ok_or_else(|| panic!("Invalid length {length}, expected 8"))?;
// length += 1;
Ok(TerrainCell {
altitude,
rainfall,
temperature,
local_iteration,
biome_presences,
x: default(),
y: default(),
human_groups: human_groups.iter().map(|group| Arc::new(*group)).collect(),
height,
width,
})
}
fn visit_map<V>(self, mut map: V) -> Result<Self::Value, V::Error>
where
V: MapAccess<'de>,
{
let mut altitude = None;
let mut rainfall = None;
let mut temperature = None;
let mut local_iteration = None;
let mut biome_presences = None;
let mut height = None;
let mut width = None;
let mut human_groups: Option<Vec<HumanGroup>> = None;
while let Some(key) = map.next_key()? {
match key {
Field::Altitude => {
if altitude.is_some() {
return Err(Error::duplicate_field("altitude"));
}
altitude = Some(map.next_value()?);
},
Field::Rainfall => {
if rainfall.is_some() {
return Err(Error::duplicate_field("rainfall"));
}
rainfall = Some(map.next_value()?);
},
Field::Temperature => {
if temperature.is_some() {
return Err(Error::duplicate_field("temperature"));
}
temperature = Some(map.next_value()?);
},
Field::LocalIteration => {
if local_iteration.is_some() {
return Err(Error::duplicate_field("local_iteration"));
}
local_iteration = Some(map.next_value()?);
},
Field::BiomePresences => {
if biome_presences.is_some() {
return Err(Error::duplicate_field("biome_presences"));
}
biome_presences = Some(map.next_value()?);
},
Field::Height => {
if height.is_some() {
return Err(Error::duplicate_field("height"));
}
height = Some(map.next_value()?);
},
Field::Width => {
if width.is_some() {
return Err(Error::duplicate_field("width"));
}
width = Some(map.next_value()?);
},
Field::HumanGroups => {
if human_groups.is_some() {
return Err(Error::duplicate_field("human_groups"));
}
human_groups = Some(map.next_value()?);
},
}
}
let altitude = altitude.ok_or_else(|| Error::missing_field("altitude"))?;
let rainfall = rainfall.ok_or_else(|| Error::missing_field("rainfall"))?;
let temperature = temperature.ok_or_else(|| Error::missing_field("temperature"))?;
let local_iteration =
local_iteration.ok_or_else(|| Error::missing_field("local_iteration"))?;
let biome_presences =
biome_presences.ok_or_else(|| Error::missing_field("biome_presences"))?;
let height = height.ok_or_else(|| Error::missing_field("height"))?;
let width = width.ok_or_else(|| Error::missing_field("width"))?;
let human_groups =
human_groups.ok_or_else(|| Error::missing_field("human_groups"))?;
Ok(TerrainCell {
altitude,
rainfall,
temperature,
local_iteration,
biome_presences,
x: default(),
y: default(),
human_groups: human_groups.iter().map(|group| Arc::new(*group)).collect(),
height,
width,
})
}
}
const FIELDS: &'static [&'static str] = &[
"altitude",
"rainfall",
"temperature",
"local_iteration",
"biome_presences",
];
deserializer.deserialize_struct("TerrainCell", FIELDS, TerrainCellVisitor)
}
}
impl Serialize for TerrainCell {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let TerrainCell {
altitude,
rainfall,
temperature,
x: _x,
y: _y,
local_iteration,
biome_presences,
human_groups,
height,
width,
} = self;
let human_groups = &human_groups
.iter()
.map(|group_arc| **group_arc)
.collect::<Vec<_>>();
let mut serialized_struct = serializer.serialize_struct(stringify!(TerrainCell), 10)?;
serialized_struct.serialize_field(stringify!(altitude), altitude)?;
serialized_struct.serialize_field(stringify!(rainfall), rainfall)?;
serialized_struct.serialize_field(stringify!(temperature), temperature)?;
// #[skip]
// serialized_struct.serialize_field(stringify!(x), x)?;
// #[skip]
// serialized_struct.serialize_field(stringify!(y), y)?;
serialized_struct.serialize_field(stringify!(local_iteration), local_iteration)?;
serialized_struct.serialize_field(stringify!(biome_presences), biome_presences)?;
serialized_struct.serialize_field(stringify!(human_groups), human_groups)?;
serialized_struct.serialize_field(stringify!(height), height)?;
serialized_struct.serialize_field(stringify!(width), width)?;
serialized_struct.end()
}
}

View file

@ -1,6 +1,6 @@
use { use {
crate::{TerrainCell, World}, crate::{TerrainCell, World},
bevy::prelude::debug, bevy::{prelude::debug, utils::default},
rand::{rngs::StdRng, SeedableRng}, rand::{rngs::StdRng, SeedableRng},
serde::{ serde::{
de::{Error, MapAccess, SeqAccess, Visitor}, de::{Error, MapAccess, SeqAccess, Visitor},
@ -137,6 +137,7 @@ impl<'de> Deserialize<'de> for World {
rng: StdRng::seed_from_u64(seed as u64), rng: StdRng::seed_from_u64(seed as u64),
iteration, iteration,
human_groups_to_update: default(),
}; };
{ {
let mut y = 0; let mut y = 0;
@ -219,10 +220,10 @@ impl<'de> Deserialize<'de> for World {
let mut terrain: Vec<Vec<TerrainCell>> = let mut terrain: Vec<Vec<TerrainCell>> =
terrain.ok_or_else(|| Error::missing_field("terrain"))?; terrain.ok_or_else(|| Error::missing_field("terrain"))?;
for x in 0..width as usize { for x in 0..width as u32 {
for y in 0..height as usize { for y in 0..height as u32 {
terrain[y][x].x = x; terrain[y as usize][x as usize].x = x;
terrain[y][x].y = y; terrain[y as usize][x as usize].y = y;
} }
} }
@ -279,6 +280,7 @@ impl<'de> Deserialize<'de> for World {
rng: StdRng::seed_from_u64(seed as u64), rng: StdRng::seed_from_u64(seed as u64),
iteration, iteration,
human_groups_to_update: default(),
}; };
{ {
let mut y = 0; let mut y = 0;

View file

@ -0,0 +1,51 @@
use {
crate::{perlin, BiomeType, HumanGroup, World},
std::sync::Arc,
};
#[derive(Debug, Clone, Default)]
pub struct TerrainCell {
pub altitude: f32,
pub rainfall: f32,
pub temperature: f32,
pub x: u32,
pub y: u32,
pub local_iteration: u64,
pub biome_presences: Vec<(BiomeType, f32)>,
pub human_groups: Vec<Arc<HumanGroup>>,
pub height: f32,
pub width: f32,
}
impl TerrainCell {
pub fn get_next_local_random_int(&mut self, world: &World) -> u32 {
let seed = world.seed;
let x = seed as f32 + self.x as f32;
let y = seed as f32 + self.y as f32;
let z = seed as f32 + world.iteration as f32 + (self.local_iteration - 1) as f32;
self.local_iteration += 1;
perlin::permutation_value(x, y, z)
}
pub fn get_next_local_random_float(&mut self, world: &World) -> f32 {
self.get_next_local_random_int(world) as f32 / perlin::MAX_PERMUTATION_VALUE as f32
}
pub fn biome_presence(&self, biome: BiomeType) -> Option<f32> {
if let Some(presence) = self
.biome_presences
.iter()
.find(|biome_presence| biome_presence.0 == biome)
{
Some(presence.1)
} else {
None
}
}
}

View file

@ -10,6 +10,8 @@ use {
perlin, perlin,
BiomeStats, BiomeStats,
BiomeType, BiomeType,
HumanGroup,
TerrainCell,
}, },
bevy::{ bevy::{
log::info, log::info,
@ -19,11 +21,12 @@ use {
}, },
crossbeam_channel::Sender, crossbeam_channel::Sender,
rand::{rngs::StdRng, Rng, SeedableRng}, rand::{rngs::StdRng, Rng, SeedableRng},
serde::{Deserialize, Serialize}, serde::Serialize,
std::{ std::{
error::Error, error::Error,
f32::consts::{PI, TAU}, f32::consts::{PI, TAU},
fmt::{Debug, Display}, fmt::{Debug, Display},
sync::{Arc, Weak},
}, },
}; };
@ -90,40 +93,15 @@ pub struct World {
#[serde(skip)] #[serde(skip)]
pub rng: StdRng, pub rng: StdRng,
pub iteration: usize, pub iteration: usize,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct TerrainCell {
pub altitude: f32,
pub rainfall: f32,
pub temperature: f32,
#[serde(skip)] #[serde(skip)]
pub x: usize, pub human_groups_to_update: Vec<Weak<HumanGroup>>,
#[serde(skip)]
pub y: usize,
pub local_iteration: usize,
pub biome_presences: Vec<(BiomeType, f32)>,
}
impl TerrainCell {
pub fn get_next_local_random_int(&mut self, world: &World) -> f32 {
let seed = world.seed;
let x = seed as f32 + self.x as f32;
let y = seed as f32 + self.y as f32;
let z = seed as f32 + world.iteration as f32 + (self.local_iteration - 1) as f32;
drop(world);
self.local_iteration += 1;
perlin::perlin_value(x, y, z)
}
} }
impl World { impl World {
pub const ALTITUDE_SPAN: f32 = World::MAX_ALTITUDE - World::MIN_ALTITUDE; pub const ALTITUDE_SPAN: f32 = World::MAX_ALTITUDE - World::MIN_ALTITUDE;
/// Circumference - in kilometers
pub const CIRCUMFERENCE: u32 = 40075;
pub const CONTINENT_MAX_SIZE_FACTOR: f32 = 8.7; pub const CONTINENT_MAX_SIZE_FACTOR: f32 = 8.7;
pub const CONTINENT_MIN_SIZE_FACTOR: f32 = 5.7; pub const CONTINENT_MIN_SIZE_FACTOR: f32 = 5.7;
pub const MAX_ALTITUDE: f32 = 15000.0; pub const MAX_ALTITUDE: f32 = 15000.0;
@ -139,6 +117,12 @@ impl World {
pub const TEMPERATURE_ALTITUDE_FACTOR: f32 = 2.05; pub const TEMPERATURE_ALTITUDE_FACTOR: f32 = 2.05;
pub const TEMPERATURE_SPAN: f32 = World::MAX_TEMPERATURE - World::MIN_TEMPERATURE; pub const TEMPERATURE_SPAN: f32 = World::MAX_TEMPERATURE - World::MIN_TEMPERATURE;
#[must_use]
#[inline(always)]
pub fn cell_max_width(&self) -> f32 {
self.width as f32 / World::CIRCUMFERENCE as f32
}
pub fn new(width: u32, height: u32, seed: u32) -> World { pub fn new(width: u32, height: u32, seed: u32) -> World {
World { World {
width, width,
@ -155,25 +139,7 @@ impl World {
min_temperature: World::MAX_TEMPERATURE, min_temperature: World::MAX_TEMPERATURE,
rng: StdRng::seed_from_u64(seed as u64), rng: StdRng::seed_from_u64(seed as u64),
iteration: 0, iteration: 0,
} human_groups_to_update: default(),
}
pub fn async_new(width: u32, height: u32, seed: u32) -> World {
World {
width,
height,
seed,
terrain: vec![vec![default(); width.try_into().unwrap()]; height.try_into().unwrap()],
continent_offsets: [default(); World::NUM_CONTINENTS as usize],
continent_sizes: [default(); World::NUM_CONTINENTS as usize],
max_altitude: World::MIN_ALTITUDE,
min_altitude: World::MAX_ALTITUDE,
max_rainfall: World::MIN_RAINFALL,
min_rainfall: World::MAX_RAINFALL,
max_temperature: World::MIN_TEMPERATURE,
min_temperature: World::MAX_TEMPERATURE,
rng: StdRng::seed_from_u64(seed as u64),
iteration: 0,
} }
} }
@ -197,6 +163,9 @@ impl World {
send_progress(progress_sender, 0.0, "Generating biomes"); send_progress(progress_sender, 0.0, "Generating biomes");
self.generate_biomes(progress_sender); self.generate_biomes(progress_sender);
send_progress(progress_sender, 0.0, "Populating world");
self.set_initial_human_groups(progress_sender);
Ok(()) Ok(())
} }
@ -440,8 +409,10 @@ impl World {
self.min_altitude = altitude; self.min_altitude = altitude;
} }
self.terrain[y][x].x = x; self.terrain[y][x].x = x as u32;
self.terrain[y][x].y = y; self.terrain[y][x].y = y as u32;
self.terrain[y][x].height = f32::sin(alpha) * self.cell_max_width();
self.terrain[y][x].width = self.cell_max_width();
} }
} }
info!("Done generating altitude"); info!("Done generating altitude");
@ -523,10 +494,10 @@ impl World {
let latitude_modifier_2 = f32::cos(latitude_factor); let latitude_modifier_2 = f32::cos(latitude_factor);
let offset_cell_x_1 = let offset_cell_x_1 =
(width + x + f32::floor(latitude_modifier_2 * width as f32 / 20.0) as usize) (width + x + f32::floor(latitude_modifier_2 * width as f32 / 40.0) as usize)
% width; % width;
let offset_cell_x_2 = let offset_cell_x_2 =
(width + x + f32::floor(latitude_modifier_2 * width as f32 / 15.0) as usize) (width + x + f32::floor(latitude_modifier_2 * width as f32 / 20.0) as usize)
% width; % width;
let offset_cell_x_3 = let offset_cell_x_3 =
(width + x + f32::floor(latitude_modifier_2 * width as f32 / 10.0) as usize) (width + x + f32::floor(latitude_modifier_2 * width as f32 / 10.0) as usize)
@ -561,7 +532,7 @@ impl World {
- (offset_altitude_3 * 0.5) - (offset_altitude_3 * 0.5)
- (offset_altitude_4 * 0.4) - (offset_altitude_4 * 0.4)
- (offset_altitude_5 * 0.5) - (offset_altitude_5 * 0.5)
+ (World::MAX_ALTITUDE * 0.18 * random_noise_2) + (World::MAX_ALTITUDE * 0.17 * random_noise_2)
- (altitude_value * 0.25)) - (altitude_value * 0.25))
/ World::MAX_ALTITUDE; / World::MAX_ALTITUDE;
@ -755,9 +726,12 @@ impl World {
} }
#[must_use] #[must_use]
pub fn cell_neighbors(&self, x: usize, y: usize) -> HashMap<CompassDirection, &TerrainCell> { pub fn cell_neighbors(&self, x: u32, y: u32) -> HashMap<CompassDirection, &TerrainCell> {
let mut neighbors = HashMap::new(); let mut neighbors = HashMap::new();
let x = x as usize;
let y = y as usize;
let height = self.height as usize; let height = self.height as usize;
let width = self.width as usize; let width = self.width as usize;
@ -931,6 +905,63 @@ impl World {
} }
return false; return false;
} }
fn set_initial_human_groups(&mut self, progress_sender: &Sender<(f32, String)>) -> () {
const MAX_GROUPS: u8 = 5;
const MINIMUM_PRESENCE: f32 = 0.1;
let mut placed_groups = 0;
let mut tries = 0;
while placed_groups < MAX_GROUPS {
tries += 1;
send_progress(
progress_sender,
placed_groups as f32 / MAX_GROUPS as f32,
format!("Placing initial population: {placed_groups}/{MAX_GROUPS} (try #{tries})"),
);
let x = self.rng.gen_range(0..self.width as usize);
let y = self.rng.gen_range(0..self.height as usize);
let grassland_presence = self.terrain[y][x].biome_presence(BiomeType::Grassland);
match grassland_presence {
Some(presence) => {
if presence < MINIMUM_PRESENCE {
continue;
}
},
None => continue,
}
let new_human_group = Arc::new(HumanGroup {
id: placed_groups as u32,
population: 1000,
});
self.human_groups_to_update
.push(Arc::<HumanGroup>::downgrade(&new_human_group));
self.terrain[y][x].human_groups.push(new_human_group);
placed_groups += 1;
tries = 0;
}
}
pub fn iterate(&mut self) {
for group in self.human_groups_to_update.iter() {
if let Some(group) = group.upgrade() {
group.update(self);
}
}
self.human_groups_to_update.clear();
self.iteration += 1;
}
#[inline(always)]
pub fn add_human_group_to_update(&mut self, group: Weak<HumanGroup>) {
self.human_groups_to_update.push(group);
}
} }
fn send_progress<T: Into<String>>( fn send_progress<T: Into<String>>(

View file

@ -1,3 +1,5 @@
use std::io::{Write, BufReader};
use { use {
crate::{World, WorldGenError}, crate::{World, WorldGenError},
bevy::{ bevy::{
@ -12,7 +14,7 @@ use {
error::Error, error::Error,
fmt::Display, fmt::Display,
fs::File, fs::File,
io::{self, Read, Write}, io::{self, BufWriter},
path::Path, path::Path,
}, },
}; };
@ -20,7 +22,7 @@ use {
#[derive(Debug)] #[derive(Debug)]
pub enum LoadError { pub enum LoadError {
MissingSave(io::Error), MissingSave(io::Error),
InvalidSave(postcard::Error), InvalidSave(bincode::Error),
} }
impl Error for LoadError { impl Error for LoadError {
fn source(&self) -> Option<&(dyn Error + 'static)> { fn source(&self) -> Option<&(dyn Error + 'static)> {
@ -29,15 +31,8 @@ impl Error for LoadError {
LoadError::InvalidSave(error) => Some(error), LoadError::InvalidSave(error) => Some(error),
} }
} }
fn description(&self) -> &str {
"description() is deprecated; use Display"
}
fn cause(&self) -> Option<&dyn Error> {
self.source()
}
} }
impl Display for LoadError { impl Display for LoadError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self { match self {
@ -53,7 +48,7 @@ impl Display for LoadError {
#[derive(Debug)] #[derive(Debug)]
pub enum SaveError { pub enum SaveError {
MissingWorld, MissingWorld,
SerializationError(postcard::Error), SerializationError(bincode::Error),
FailedToWrite(io::Error), FailedToWrite(io::Error),
} }
impl Error for SaveError { impl Error for SaveError {
@ -103,32 +98,31 @@ impl WorldManager {
return Err(SaveError::MissingWorld); return Err(SaveError::MissingWorld);
}; };
let serialized = match postcard::to_stdvec(world) { let save_file = match File::create(path) {
Ok(serialized) => serialized, Ok(save_file) => save_file,
Err(err) => { Err(err) => return Err(SaveError::FailedToWrite(err)),
return Err(SaveError::SerializationError(err));
},
}; };
match File::create(path).unwrap().write_all(serialized.as_slice()) { let serialized = match bincode::serialize(world) {
Ok(serialized) => serialized,
Err(err) => return Err(SaveError::SerializationError(err)),
};
match BufWriter::new(save_file).write(serialized.as_slice()) {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(SaveError::FailedToWrite(err)), Err(err) => Err(SaveError::FailedToWrite(err)),
} }
} }
pub fn load_world<P: AsRef<Path>>(&mut self, path: P) -> Result<(), LoadError> { pub fn load_world<P: AsRef<Path>>(&mut self, path: P) -> Result<(), LoadError> {
let mut file = match File::open(path) { let file = match File::open(path) {
Ok(file) => file, Ok(file) => file,
Err(err) => { Err(err) => {
return Err(LoadError::MissingSave(err)); return Err(LoadError::MissingSave(err));
}, },
}; };
let mut buf = vec![];
if let Err(err) = file.read_to_end(&mut buf) {
return Err(LoadError::MissingSave(err));
};
match postcard::from_bytes(buf.as_slice()) { match bincode::deserialize_from(BufReader::new(file)) {
Ok(world) => { Ok(world) => {
self.world = Some(world); self.world = Some(world);
Ok(()) Ok(())
@ -142,6 +136,11 @@ impl WorldManager {
self.world.as_ref() self.world.as_ref()
} }
#[must_use]
pub fn get_world_mut(&mut self) -> Option<&mut World> {
self.world.as_mut()
}
pub fn set_world(&mut self, world: World) { pub fn set_world(&mut self, world: World) {
self.world = Some(world); self.world = Some(world);
} }
@ -153,7 +152,7 @@ impl WorldManager {
) -> Task<Result<World, WorldGenError>> { ) -> Task<Result<World, WorldGenError>> {
AsyncComputeTaskPool::get().spawn(async move { AsyncComputeTaskPool::get().spawn(async move {
let seed = seed.unwrap_or_else(random); let seed = seed.unwrap_or_else(random);
let mut new_world = World::async_new( let mut new_world = World::new(
WorldManager::NEW_WORLD_WIDTH, WorldManager::NEW_WORLD_WIDTH,
WorldManager::NEW_WORLD_HEIGHT, WorldManager::NEW_WORLD_HEIGHT,
seed, seed,

View file

@ -44,6 +44,9 @@ impl WindowSystem for TileInfo<'_, '_> {
.. ..
} = &world.terrain[cursor_y as usize][cursor_x as usize]; } = &world.terrain[cursor_y as usize][cursor_x as usize];
_ = ui.label("Iteration");
_ = ui.label(format!("{}", world.iteration));
ui.end_row();
_ = ui.label("Coordinates"); _ = ui.label("Coordinates");
_ = ui.label(format!("{x}:{y}")); _ = ui.label(format!("{x}:{y}"));
ui.end_row(); ui.end_row();

View file

@ -232,11 +232,11 @@ fn update_gui(world: &mut World) {
#[cfg(feature = "render")] #[cfg(feature = "render")]
fn redraw_map( fn redraw_map(
mut should_redraw: ResMut<ShouldRedraw>, mut should_redraw: ResMut<ShouldRedraw>,
world_manager: Res<WorldManager>,
mut world_renderer: ResMut<WorldRenderer>, mut world_renderer: ResMut<WorldRenderer>,
render_settings: Res<WorldRenderSettings>,
mut images: ResMut<Assets<Image>>, mut images: ResMut<Assets<Image>>,
mut map_sprite: Query<&mut Sprite>, mut map_sprite: Query<&mut Sprite>,
render_settings: Res<WorldRenderSettings>,
world_manager: Res<WorldManager>,
) { ) {
let Some(world) = world_manager.get_world() else { let Some(world) = world_manager.get_world() else {
#[cfg(feature = "logging")] #[cfg(feature = "logging")]
@ -278,6 +278,12 @@ fn redraw_map(
} }
} }
fn iterate_world(mut world_manager: ResMut<WorldManager>) {
if let Some(world) = world_manager.get_world_mut() {
world.iterate();
};
}
#[cfg(feature = "render")] #[cfg(feature = "render")]
const WORLD_SCALE: i32 = 4; const WORLD_SCALE: i32 = 4;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@ -303,7 +309,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.add_system(update_gui) .add_system(update_gui)
.add_system(update_cursor_map_position) .add_system(update_cursor_map_position)
.add_system(open_tile_info) .add_system(open_tile_info)
.add_system(redraw_map); .add_system(redraw_map)
.add_system(iterate_world);
app.add_plugins(WorldPlugins); app.add_plugins(WorldPlugins);
} }

View file

@ -5,13 +5,20 @@ use {
}; };
iterable_enum_stringify!(WorldView { iterable_enum_stringify!(WorldView {
Population,
Biomes, Biomes,
Topography, Topography,
Coastlines Coastlines,
}); });
impl Default for WorldView {
fn default() -> Self {
WorldView::Population
}
}
iterable_enum_stringify!(WorldOverlay { iterable_enum_stringify!(WorldOverlay {
Temperature, Temperature,
Rainfall Rainfall,
}); });
#[cfg(feature = "render")] #[cfg(feature = "render")]
@ -44,6 +51,29 @@ impl WorldRenderSettings {
} }
} }
#[must_use]
fn population_color(world: &World, cell: &TerrainCell) -> Color {
let cell_population = cell
.human_groups
.iter()
.map(|group| group.population)
.sum::<u32>();
if cell_population > 0 {
debug!(cell.x, cell.y, "Population present");
Color::GREEN
} else {
let color = biome_color(world, cell);
let grey = color.r() + color.g() + color.b();
let r = (color.r() + grey) / 6.0;
let g = (color.g() + grey) / 6.0;
let b = (color.b() + grey) / 6.0;
Color::rgb(r, g, b)
}
}
#[must_use] #[must_use]
fn altitude_contour_color(world: &World, altitude: f32) -> Color { fn altitude_contour_color(world: &World, altitude: f32) -> Color {
let mut color = Color::rgb(1.0, 0.6, 0.0); let mut color = Color::rgb(1.0, 0.6, 0.0);
@ -178,6 +208,7 @@ impl WorldRenderer {
WorldView::Biomes => 0, WorldView::Biomes => 0,
WorldView::Topography => 1, WorldView::Topography => 1,
WorldView::Coastlines => 2, WorldView::Coastlines => 2,
WorldView::Population => 3,
}; };
let mut overlay_num = 0; let mut overlay_num = 0;
for overlay in render_settings.visible_overlays.iter() { for overlay in render_settings.visible_overlays.iter() {
@ -249,6 +280,7 @@ impl WorldRenderer {
WorldView::Biomes => biome_color(world, cell), WorldView::Biomes => biome_color(world, cell),
WorldView::Topography => altitude_contour_color(world, cell.altitude), WorldView::Topography => altitude_contour_color(world, cell.altitude),
WorldView::Coastlines => coastline_color(world, cell), WorldView::Coastlines => coastline_color(world, cell),
WorldView::Population => population_color(world, cell),
}; };
let mut normalizer = 1.0; let mut normalizer = 1.0;
@ -286,9 +318,3 @@ impl WorldRenderer {
Color::rgb(red / normalizer, green / normalizer, blue / normalizer) Color::rgb(red / normalizer, green / normalizer, blue / normalizer)
} }
} }
impl Default for WorldView {
fn default() -> Self {
WorldView::Biomes
}
}