Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
de45368463 | ||
|
6d7567d0ae | ||
|
533cb2fae4 | ||
|
97eb82e009 | ||
|
093ab8f38b | ||
|
a7b4d8c7ab | ||
|
e633d3875d | ||
|
72d6a678bd | ||
|
3e5e4d5254 | ||
|
c1250bbb7f | ||
|
108d6afbd0 | ||
|
62dd037957 | ||
|
bc621ff9c1 |
372
Cargo.lock
generated
372
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"
|
||||||
@ -321,12 +315,6 @@ version = "0.21.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.22.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy"
|
name = "bevy"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
@ -338,9 +326,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy-inspector-egui"
|
name = "bevy-inspector-egui"
|
||||||
version = "0.28.0"
|
version = "0.28.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd64580f4496ed987c6231c6a7d833068914331a9084bf5a3dd9dcbc66fd8a73"
|
checksum = "36172627eb6fd8586600972bcbba2880ed6f59e4e243dcf2ed7ff68d987577ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy-inspector-egui-derive",
|
"bevy-inspector-egui-derive",
|
||||||
"bevy_app",
|
"bevy_app",
|
||||||
@ -354,7 +342,6 @@ dependencies = [
|
|||||||
"bevy_image",
|
"bevy_image",
|
||||||
"bevy_log",
|
"bevy_log",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"bevy_state",
|
"bevy_state",
|
||||||
@ -394,38 +381,6 @@ dependencies = [
|
|||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bevy_animation"
|
|
||||||
version = "0.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ee48f3fc65f583e5e320e38874053e20e7a71205a62aaace5d607446781bd742"
|
|
||||||
dependencies = [
|
|
||||||
"bevy_app",
|
|
||||||
"bevy_asset",
|
|
||||||
"bevy_color",
|
|
||||||
"bevy_core",
|
|
||||||
"bevy_derive",
|
|
||||||
"bevy_ecs",
|
|
||||||
"bevy_hierarchy",
|
|
||||||
"bevy_log",
|
|
||||||
"bevy_math",
|
|
||||||
"bevy_reflect",
|
|
||||||
"bevy_render",
|
|
||||||
"bevy_time",
|
|
||||||
"bevy_transform",
|
|
||||||
"bevy_utils",
|
|
||||||
"blake3",
|
|
||||||
"derive_more",
|
|
||||||
"downcast-rs",
|
|
||||||
"either",
|
|
||||||
"petgraph",
|
|
||||||
"ron",
|
|
||||||
"serde",
|
|
||||||
"smallvec",
|
|
||||||
"thread_local",
|
|
||||||
"uuid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_app"
|
name = "bevy_app"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
@ -675,21 +630,6 @@ dependencies = [
|
|||||||
"encase_derive_impl",
|
"encase_derive_impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bevy_gilrs"
|
|
||||||
version = "0.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "adc3a5f9e872133d7f5c2fab82e17781c19ed0b98f371362a23ed972bb538d20"
|
|
||||||
dependencies = [
|
|
||||||
"bevy_app",
|
|
||||||
"bevy_ecs",
|
|
||||||
"bevy_input",
|
|
||||||
"bevy_time",
|
|
||||||
"bevy_utils",
|
|
||||||
"derive_more",
|
|
||||||
"gilrs",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_gizmos"
|
name = "bevy_gizmos"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
@ -704,7 +644,6 @@ dependencies = [
|
|||||||
"bevy_gizmos_macros",
|
"bevy_gizmos_macros",
|
||||||
"bevy_image",
|
"bevy_image",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"bevy_sprite",
|
"bevy_sprite",
|
||||||
@ -726,38 +665,6 @@ dependencies = [
|
|||||||
"syn 2.0.90",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bevy_gltf"
|
|
||||||
version = "0.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b21ed694796a001a5cf63de9ddc62fc017302b0e2998a361ef1126880ec93555"
|
|
||||||
dependencies = [
|
|
||||||
"base64 0.22.1",
|
|
||||||
"bevy_animation",
|
|
||||||
"bevy_app",
|
|
||||||
"bevy_asset",
|
|
||||||
"bevy_color",
|
|
||||||
"bevy_core",
|
|
||||||
"bevy_core_pipeline",
|
|
||||||
"bevy_ecs",
|
|
||||||
"bevy_hierarchy",
|
|
||||||
"bevy_image",
|
|
||||||
"bevy_math",
|
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_reflect",
|
|
||||||
"bevy_render",
|
|
||||||
"bevy_scene",
|
|
||||||
"bevy_tasks",
|
|
||||||
"bevy_transform",
|
|
||||||
"bevy_utils",
|
|
||||||
"derive_more",
|
|
||||||
"gltf",
|
|
||||||
"percent-encoding",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"smallvec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_hierarchy"
|
name = "bevy_hierarchy"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
@ -789,8 +696,6 @@ dependencies = [
|
|||||||
"derive_more",
|
"derive_more",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"image",
|
"image",
|
||||||
"ktx2",
|
|
||||||
"ruzstd",
|
|
||||||
"serde",
|
"serde",
|
||||||
"wgpu 23.0.1",
|
"wgpu 23.0.1",
|
||||||
]
|
]
|
||||||
@ -818,7 +723,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "d4237e6e9b03902321032f00f931f18a4a211093bd9a7cf81276a0228a2a4417"
|
checksum = "d4237e6e9b03902321032f00f931f18a4a211093bd9a7cf81276a0228a2a4417"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy_a11y",
|
"bevy_a11y",
|
||||||
"bevy_animation",
|
|
||||||
"bevy_app",
|
"bevy_app",
|
||||||
"bevy_asset",
|
"bevy_asset",
|
||||||
"bevy_audio",
|
"bevy_audio",
|
||||||
@ -828,11 +732,8 @@ dependencies = [
|
|||||||
"bevy_derive",
|
"bevy_derive",
|
||||||
"bevy_diagnostic",
|
"bevy_diagnostic",
|
||||||
"bevy_ecs",
|
"bevy_ecs",
|
||||||
"bevy_gilrs",
|
|
||||||
"bevy_gizmos",
|
"bevy_gizmos",
|
||||||
"bevy_gltf",
|
|
||||||
"bevy_hierarchy",
|
"bevy_hierarchy",
|
||||||
"bevy_image",
|
|
||||||
"bevy_input",
|
"bevy_input",
|
||||||
"bevy_log",
|
"bevy_log",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
@ -972,14 +873,12 @@ dependencies = [
|
|||||||
"bevy_hierarchy",
|
"bevy_hierarchy",
|
||||||
"bevy_input",
|
"bevy_input",
|
||||||
"bevy_math",
|
"bevy_math",
|
||||||
"bevy_mesh",
|
|
||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"bevy_time",
|
"bevy_time",
|
||||||
"bevy_transform",
|
"bevy_transform",
|
||||||
"bevy_utils",
|
"bevy_utils",
|
||||||
"bevy_window",
|
"bevy_window",
|
||||||
"crossbeam-channel",
|
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1004,7 +903,6 @@ dependencies = [
|
|||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
"erased-serde",
|
"erased-serde",
|
||||||
"glam",
|
"glam",
|
||||||
"petgraph",
|
|
||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"smol_str",
|
"smol_str",
|
||||||
@ -1058,7 +956,6 @@ dependencies = [
|
|||||||
"futures-lite",
|
"futures-lite",
|
||||||
"image",
|
"image",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"ktx2",
|
|
||||||
"naga 23.1.0",
|
"naga 23.1.0",
|
||||||
"naga_oil",
|
"naga_oil",
|
||||||
"nonmax",
|
"nonmax",
|
||||||
@ -1834,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"
|
||||||
@ -2174,15 +2062,6 @@ 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"
|
||||||
@ -2195,22 +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]]
|
|
||||||
name = "fnv"
|
|
||||||
version = "1.0.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foldhash"
|
name = "foldhash"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@ -2278,7 +2141,7 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "forestiles"
|
name = "forestiles"
|
||||||
version = "0.1.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_logger",
|
"android_logger",
|
||||||
"bevy",
|
"bevy",
|
||||||
@ -2371,40 +2234,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gilrs"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bbb2c998745a3c1ac90f64f4f7b3a54219fd3612d7705e7798212935641ed18f"
|
|
||||||
dependencies = [
|
|
||||||
"fnv",
|
|
||||||
"gilrs-core",
|
|
||||||
"log",
|
|
||||||
"uuid",
|
|
||||||
"vec_map",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gilrs-core"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "495af945e45efd6386227613cd9fb7bd7c43d3c095040e30c5304c489e6abed5"
|
|
||||||
dependencies = [
|
|
||||||
"core-foundation 0.10.0",
|
|
||||||
"inotify",
|
|
||||||
"io-kit-sys",
|
|
||||||
"js-sys",
|
|
||||||
"libc",
|
|
||||||
"libudev-sys",
|
|
||||||
"log",
|
|
||||||
"nix",
|
|
||||||
"uuid",
|
|
||||||
"vec_map",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"web-sys",
|
|
||||||
"windows 0.52.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gl_generator"
|
name = "gl_generator"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@ -2457,42 +2286,6 @@ dependencies = [
|
|||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gltf"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3ce1918195723ce6ac74e80542c5a96a40c2b26162c1957a5cd70799b8cacf7"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
"gltf-json",
|
|
||||||
"lazy_static",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gltf-derive"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "14070e711538afba5d6c807edb74bcb84e5dbb9211a3bf5dea0dfab5b24f4c51"
|
|
||||||
dependencies = [
|
|
||||||
"inflections",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.90",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gltf-json"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e6176f9d60a7eab0a877e8e96548605dedbde9190a7ae1e80bbcc1c9af03ab14"
|
|
||||||
dependencies = [
|
|
||||||
"gltf-derive",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin_wgl_sys"
|
name = "glutin_wgl_sys"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
@ -2796,7 +2589,6 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
"byteorder-lite",
|
"byteorder-lite",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"png",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2818,42 +2610,6 @@ dependencies = [
|
|||||||
"hashbrown 0.14.5",
|
"hashbrown 0.14.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "inflections"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "inotify"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.6.0",
|
|
||||||
"inotify-sys",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "inotify-sys"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "io-kit-sys"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b"
|
|
||||||
dependencies = [
|
|
||||||
"core-foundation-sys",
|
|
||||||
"mach2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@ -2863,12 +2619,6 @@ dependencies = [
|
|||||||
"either",
|
"either",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itoa"
|
|
||||||
version = "1.0.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni"
|
name = "jni"
|
||||||
version = "0.21.1"
|
version = "0.21.1"
|
||||||
@ -2927,32 +2677,12 @@ version = "3.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ktx2"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "87d65e08a9ec02e409d27a0139eaa6b9756b4d81fe7cde71f6941a83730ce838"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lewton"
|
|
||||||
version = "0.10.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "777b48df9aaab155475a83a7df3070395ea1ac6902f5cd062b8f2b028075c030"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
"ogg",
|
|
||||||
"tinyvec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.169"
|
version = "0.2.169"
|
||||||
@ -2986,16 +2716,6 @@ dependencies = [
|
|||||||
"redox_syscall 0.4.1",
|
"redox_syscall 0.4.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libudev-sys"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"pkg-config",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.14"
|
version = "0.4.14"
|
||||||
@ -3093,16 +2813,6 @@ 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"
|
||||||
@ -3570,15 +3280,6 @@ dependencies = [
|
|||||||
"nonmax",
|
"nonmax",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ogg"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6951b4e8bf21c8193da321bcce9c9dd2e13c858fe078bf9054a288b419ae5d6e"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.20.2"
|
version = "1.20.2"
|
||||||
@ -3658,8 +3359,6 @@ checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"fixedbitset 0.4.2",
|
"fixedbitset 0.4.2",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3705,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"
|
||||||
@ -3999,7 +3685,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "6006a627c1a38d37f3d3a85c6575418cfe34a5392d60a686d0071e1c8d427acb"
|
checksum = "6006a627c1a38d37f3d3a85c6575418cfe34a5392d60a686d0071e1c8d427acb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cpal",
|
"cpal",
|
||||||
"lewton",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -4009,7 +3694,7 @@ version = "0.8.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.7",
|
"base64",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@ -4057,21 +3742,6 @@ dependencies = [
|
|||||||
"unicode-script",
|
"unicode-script",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ruzstd"
|
|
||||||
version = "0.7.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f"
|
|
||||||
dependencies = [
|
|
||||||
"twox-hash",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ryu"
|
|
||||||
version = "1.0.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "same-file"
|
name = "same-file"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
@ -4138,18 +3808,6 @@ dependencies = [
|
|||||||
"syn 2.0.90",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_json"
|
|
||||||
version = "1.0.134"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
|
|
||||||
dependencies = [
|
|
||||||
"itoa",
|
|
||||||
"memchr",
|
|
||||||
"ryu",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
@ -4165,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"
|
||||||
@ -4588,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 = "twox-hash"
|
|
||||||
version = "1.6.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"static_assertions",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typeid"
|
name = "typeid"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@ -4703,12 +4345,6 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vec_map"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.5"
|
version = "0.9.5"
|
||||||
|
23
Cargo.toml
23
Cargo.toml
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "forestiles"
|
name = "forestiles"
|
||||||
version = "0.1.0"
|
version = "0.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
@ -20,41 +20,22 @@ name = "forestiles"
|
|||||||
bevy = { version = "0.15", default-features = false, features = [
|
bevy = { version = "0.15", default-features = false, features = [
|
||||||
"android-native-activity",
|
"android-native-activity",
|
||||||
"android_shared_stdcxx",
|
"android_shared_stdcxx",
|
||||||
"animation",
|
|
||||||
"bevy_asset",
|
|
||||||
"bevy_audio",
|
|
||||||
"bevy_color",
|
"bevy_color",
|
||||||
"bevy_core_pipeline",
|
"bevy_core_pipeline",
|
||||||
"bevy_gilrs",
|
|
||||||
"bevy_gizmos",
|
|
||||||
"bevy_gltf",
|
|
||||||
"bevy_mesh_picking_backend",
|
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_picking",
|
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"bevy_scene",
|
|
||||||
"bevy_sprite",
|
|
||||||
"bevy_sprite_picking_backend",
|
|
||||||
"bevy_state",
|
"bevy_state",
|
||||||
"bevy_text",
|
"bevy_text",
|
||||||
"bevy_ui",
|
"bevy_ui",
|
||||||
"bevy_ui_picking_backend",
|
"bevy_ui_picking_backend",
|
||||||
"bevy_window",
|
"bevy_window",
|
||||||
"bevy_winit",
|
"bevy_winit",
|
||||||
"custom_cursor",
|
|
||||||
"default_font",
|
"default_font",
|
||||||
"hdr",
|
|
||||||
"multi_threaded",
|
"multi_threaded",
|
||||||
"png",
|
|
||||||
"smaa_luts",
|
|
||||||
"sysinfo_plugin",
|
"sysinfo_plugin",
|
||||||
"tonemapping_luts",
|
|
||||||
"vorbis",
|
|
||||||
"webgl2",
|
"webgl2",
|
||||||
"wayland",
|
"wayland",
|
||||||
]}
|
]}
|
||||||
bevy-inspector-egui = { version = "0.28", default-features = false, features = [
|
bevy-inspector-egui = { version = "0.28", default-features = false, features = [
|
||||||
"bevy_pbr",
|
|
||||||
"bevy_image",
|
"bevy_image",
|
||||||
"bevy_render",
|
"bevy_render",
|
||||||
"egui_open_url"
|
"egui_open_url"
|
||||||
@ -100,4 +81,4 @@ build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"]
|
|||||||
target_sdk_version = 31
|
target_sdk_version = 31
|
||||||
|
|
||||||
[package.metadata.android.application]
|
[package.metadata.android.application]
|
||||||
label = "Forestiles"
|
label = "Forestiles"
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly"
|
channel = "nightly"
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
use bevy::{math::NormedVectorSpace, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::HashMap, window::PrimaryWindow};
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use bevy::{input::mouse::MouseWheel, math::NormedVectorSpace, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::HashMap, window::PrimaryWindow};
|
||||||
|
|
||||||
use crate::ui;
|
use crate::ui;
|
||||||
|
|
||||||
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);
|
||||||
.add_systems(Update, move_cam)
|
// .add_systems(Update, move_cam)
|
||||||
.init_resource::<Pointers>();
|
// .init_resource::<Pointers>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,40 +17,39 @@ fn setup(mut cmds: Commands, window: Query<&Window>) {
|
|||||||
let zoom = 2./window.single().width().min(window.single().height());
|
let zoom = 2./window.single().width().min(window.single().height());
|
||||||
cmds.spawn((
|
cmds.spawn((
|
||||||
Camera2d,
|
Camera2d,
|
||||||
Transform::from_scale(Vec3::new(zoom, zoom, 1.))
|
Transform::from_scale(Vec3::new(zoom, zoom, zoom))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
struct Pointers(HashMap<PointerId, Vec2>);
|
struct Pointers(HashMap<PointerId, (Vec2, Option<Duration>)>);
|
||||||
|
|
||||||
fn move_cam(
|
fn move_cam(
|
||||||
mut cam: Query<&mut Transform, With<Camera2d>>,
|
mut cam: Query<&mut Transform, With<Camera2d>>,
|
||||||
map_ui_entity: Query<Entity, With<ui::MapUIComponent>>,
|
map_ui_entity: Query<Entity, With<ui::MapUIComponent>>,
|
||||||
mouse_buttons: Res<ButtonInput<MouseButton>>,
|
mouse_buttons: Res<ButtonInput<MouseButton>>,
|
||||||
|
mut ev_scroll: EventReader<MouseWheel>,
|
||||||
touches: Res<Touches>,
|
touches: Res<Touches>,
|
||||||
window: Query<&Window, With<PrimaryWindow>>,
|
window: Query<&Window, With<PrimaryWindow>>,
|
||||||
mut pointers: ResMut<Pointers>,
|
mut pointers: ResMut<Pointers>,
|
||||||
hover_map: Res<HoverMap>
|
hover_map: Res<HoverMap>,
|
||||||
|
time: Res<Time>
|
||||||
) {
|
) {
|
||||||
let window = window.single();
|
let window = window.single();
|
||||||
let mut cam = cam.single_mut();
|
let mut cam = cam.single_mut();
|
||||||
let map_ui_entity = map_ui_entity.single();
|
let map_ui_entity = map_ui_entity.single();
|
||||||
let ps = hover_map.iter().filter_map(|(id, hit_map)| match id {
|
let ps = hover_map.iter().filter_map(|(id, hit_map)| match id {
|
||||||
PointerId::Mouse => window.cursor_position().map(|p| (mouse_buttons.pressed(MouseButton::Left), p, pointers.0.get(id).map(|p| *p).unwrap_or(p))),
|
PointerId::Mouse => window.cursor_position().map(|p|
|
||||||
PointerId::Touch(i) => touches.get_pressed(*i).map(|t| (true, t.position(), t.previous_position())),
|
match pointers.0.get(id) {
|
||||||
|
Some(p_cache) => (p_cache.1.filter(|_| mouse_buttons.pressed(MouseButton::Left)), p, p_cache.0),
|
||||||
|
None => (None, p, p)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
PointerId::Touch(i) => touches.get_pressed(*i).map(|t| (pointers.0.get(id).map(|(pos, start)| (*start).unwrap_or(time.elapsed())), t.position(), t.previous_position())),
|
||||||
_ => None
|
_ => None
|
||||||
}.map(|(pressed,new_pos, old_pos)| (pressed,new_pos,old_pos,id,hit_map))
|
}.map(|(pressed_start,new_pos, old_pos)| (pressed_start,new_pos,old_pos,id,hit_map))
|
||||||
).collect::<Vec<_>>();
|
).collect::<Vec<_>>();
|
||||||
let pressed_on_map = ps.iter().filter(|p| p.0 && p.4.contains_key(&map_ui_entity)).collect::<Vec<_>>();
|
let pressed_on_map = ps.iter().filter(|p| p.0.is_some() && p.4.contains_key(&map_ui_entity)).collect::<Vec<_>>();
|
||||||
// let mut movement = Vec2::ZERO;
|
|
||||||
// for (pressed, new_pos, old_pos, id, hit_map) in pressed_on_map.iter() {
|
|
||||||
// let delta = new_pos - old_pos;
|
|
||||||
// cam.scale += delta.dot(movement)/delta.norm();
|
|
||||||
// movement.x -= delta.x*cam.scale.x/pressed_num as f32;
|
|
||||||
// movement.y += delta.y*cam.scale.y/pressed_num as f32;
|
|
||||||
// pointers.0.insert(**id, *new_pos);
|
|
||||||
// }
|
|
||||||
|
|
||||||
let old_midpoint = pressed_on_map.iter().fold(Vec2::ZERO, |acc, (_, _, old_pos, _, _)| {
|
let old_midpoint = pressed_on_map.iter().fold(Vec2::ZERO, |acc, (_, _, old_pos, _, _)| {
|
||||||
acc + (old_pos/pressed_on_map.len() as f32)
|
acc + (old_pos/pressed_on_map.len() as f32)
|
||||||
@ -56,9 +57,12 @@ fn move_cam(
|
|||||||
let new_midpoint = pressed_on_map.iter().fold(Vec2::ZERO, |acc, (_, new_pos, _, _, _)| {
|
let new_midpoint = pressed_on_map.iter().fold(Vec2::ZERO, |acc, (_, new_pos, _, _, _)| {
|
||||||
acc + (new_pos/pressed_on_map.len() as f32)
|
acc + (new_pos/pressed_on_map.len() as f32)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// multiple fingers zoom
|
||||||
if pressed_on_map.len() > 1 {
|
if pressed_on_map.len() > 1 {
|
||||||
let old_d_to_midpoint = pressed_on_map.iter().fold(0., |acc, (_, _, old_pos, _, _)| {
|
let old_d_to_midpoint = pressed_on_map.iter().fold(0., |acc, (_, _, old_pos, _, _)| {
|
||||||
acc + (old_midpoint-old_pos).norm()
|
acc + (old_midpoint-old_pos).norm()
|
||||||
@ -67,12 +71,22 @@ fn move_cam(
|
|||||||
acc + (new_midpoint-new_pos).norm()
|
acc + (new_midpoint-new_pos).norm()
|
||||||
});
|
});
|
||||||
let zoom = new_d_to_midpoint/old_d_to_midpoint;
|
let zoom = new_d_to_midpoint/old_d_to_midpoint;
|
||||||
dbg!(zoom);
|
cam.scale /= zoom;
|
||||||
cam.scale.x /= zoom;
|
|
||||||
cam.scale.y /= zoom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (_, new_pos, _, id, _) in ps {
|
// mouse scroll zoom
|
||||||
pointers.0.insert(*id, new_pos);
|
for ev in ev_scroll.read() {
|
||||||
|
let scale = (cam.scale.x-(ev.y*0.1/window.width().min(window.height()))).clamp(0.0001, 2./window.width().min(window.height()));
|
||||||
|
cam.scale = Vec3::new(scale, scale, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update cached pointer positions
|
||||||
|
pointers.0.clear();
|
||||||
|
for (pressed_start, new_pos, _, id, _) in ps {
|
||||||
|
match id {
|
||||||
|
PointerId::Mouse => {pointers.0.insert(*id, (new_pos, pressed_start));},
|
||||||
|
PointerId::Touch(_) => {pointers.0.insert(*id, (new_pos, pressed_start));},
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,11 @@
|
|||||||
|
#![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() {
|
||||||
@ -14,6 +16,7 @@ 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]),
|
||||||
|
138
src/map.rs
138
src/map.rs
@ -1,19 +1,25 @@
|
|||||||
use bevy::{asset::RenderAssetUsages, prelude::*, render::mesh::{Indices, PrimitiveTopology}};
|
use std::time::Duration;
|
||||||
|
|
||||||
|
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::{Rng, SeedableRng};
|
use rand::{thread_rng, Rng, SeedableRng};
|
||||||
use voronoice::{BoundingBox, Point, VoronoiBuilder};
|
use voronoice::{BoundingBox, Point, VoronoiBuilder};
|
||||||
|
|
||||||
mod cells;
|
mod cells;
|
||||||
|
mod picking;
|
||||||
|
use picking::*;
|
||||||
use cells::*;
|
use cells::*;
|
||||||
|
|
||||||
|
use crate::time::GameTime;
|
||||||
|
|
||||||
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(PreUpdate, picking_backend.in_set(PickSet::Backend))
|
||||||
.add_systems(FixedUpdate, update_cells)
|
.add_systems(Update, (update_map_mesh, cells_regeneration, expand))
|
||||||
.insert_resource(ClearColor(Color::srgb(0., 0., 1.)))
|
.insert_resource(ClearColor(Color::srgb(0., 0., 1.)))
|
||||||
.insert_resource(Seed(0));
|
.insert_resource(Seed(thread_rng().gen()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +34,7 @@ pub const SIZE: usize = 10000;
|
|||||||
struct Seed(u32);
|
struct Seed(u32);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct Voronoi (voronoice::Voronoi);
|
pub struct Voronoi (voronoice::Voronoi);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MapMarker;
|
pub struct MapMarker;
|
||||||
@ -36,6 +42,12 @@ pub struct MapMarker;
|
|||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct MapColors (Vec<[f32; 4]>);
|
struct MapColors (Vec<[f32; 4]>);
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct CellsEntities (Vec<Entity>);
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct MeshNeedsUpdate(bool);
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
mut cmds: Commands,
|
mut cmds: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
@ -53,7 +65,7 @@ fn setup(
|
|||||||
.set_lloyd_relaxation_iterations(3)
|
.set_lloyd_relaxation_iterations(3)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut cells_data = Vec::with_capacity(SIZE);
|
let mut cells = 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.);
|
||||||
@ -73,31 +85,27 @@ fn setup(
|
|||||||
} else if z <= 0.52 {
|
} else if z <= 0.52 {
|
||||||
CellKind::Beach
|
CellKind::Beach
|
||||||
} else if z < 0.8 {
|
} else if z < 0.8 {
|
||||||
CellKind::Grass
|
CellKind::Dirt
|
||||||
} else {
|
} else {
|
||||||
CellKind::Stone
|
CellKind::Stone
|
||||||
};
|
};
|
||||||
cells_data.push(CellData::new(k, i, (z*255.) as u8, (m*255.) as u8, 0, vec![]));
|
cells.push(Cell {
|
||||||
|
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_data.iter_mut()).filter(|(_,cd)| cd.kind != CellKind::Forest) {
|
for (c, cd) in voronoi.iter_cells().zip(cells.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.));// [v.x as f32, v.y as f32, 0.]);
|
poss.push(Vec3::new(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]);
|
||||||
@ -105,6 +113,7 @@ 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.
|
||||||
@ -118,54 +127,77 @@ fn setup(
|
|||||||
)
|
)
|
||||||
.with_inserted_indices(Indices::U32(indices));
|
.with_inserted_indices(Indices::U32(indices));
|
||||||
|
|
||||||
|
let mut cells_entities = Vec::with_capacity(cells.len());
|
||||||
cmds.spawn((
|
cmds.spawn((
|
||||||
Mesh2d(meshes.add(mesh)),
|
Mesh2d(meshes.add(mesh)),
|
||||||
MeshMaterial2d(materials.add(ColorMaterial::default())),
|
MeshMaterial2d(materials.add(ColorMaterial::default())),
|
||||||
Transform::default(),
|
Transform::default(),
|
||||||
Voronoi(voronoi),
|
Voronoi(voronoi),
|
||||||
MapColors(colors),
|
MapColors(colors),
|
||||||
|
MeshNeedsUpdate(true),
|
||||||
MapMarker
|
MapMarker
|
||||||
)).with_children(|parent| {
|
)).with_children(|parent| {
|
||||||
for cd in cells_data {
|
for cell in cells {
|
||||||
match cd.kind {
|
let kind = cell.kind;
|
||||||
CellKind::Forest | CellKind::Grass => parent.spawn((cd, LastUpdate(0))),
|
let mut cmd = parent.spawn(cell);
|
||||||
_ => parent.spawn(cd)
|
match kind {
|
||||||
};
|
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,
|
||||||
|
gt: Res<GameTime>
|
||||||
|
| {
|
||||||
|
if trigger.duration > Duration::from_millis(200) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let mut cell = cells.get_mut(trigger.target).unwrap();
|
||||||
|
match cell.kind {
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cells_entities.push(cmd.id());
|
||||||
}
|
}
|
||||||
});
|
}).insert(CellsEntities(cells_entities));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
fn update_map_mesh(
|
||||||
pub struct LastUpdate(usize);
|
cells: Query<(&Cell, Option<&Wealth>)>,
|
||||||
|
mut map: Query<(&Mesh2d, &mut MapColors, &mut MeshNeedsUpdate), With<MapMarker>>,
|
||||||
fn update_cells(
|
|
||||||
mut cells: Query<(&mut CellData, &mut LastUpdate)>,
|
|
||||||
mut map: Query<(&Mesh2d, &mut MapColors), With<MapMarker>>,
|
|
||||||
mut meshes: ResMut<Assets<Mesh>>
|
mut meshes: ResMut<Assets<Mesh>>
|
||||||
) {
|
) {
|
||||||
let (mesh, mut cols) = map.single_mut();
|
let (mesh, mut cols, mut needs_update) = map.single_mut();
|
||||||
if let Some(mesh) = meshes.get_mut(mesh) {
|
if needs_update.0 {
|
||||||
// let cols = mesh.attribute_mut(Mesh::ATTRIBUTE_COLOR).unwrap();
|
if let Some(mesh) = meshes.get_mut(mesh) {
|
||||||
let mut modified = false;
|
let mut modified = false;
|
||||||
for (mut cd, mut lu) in cells.iter_mut() {
|
for (cell, wealth) in cells.iter() {
|
||||||
lu.0 += 1;
|
let col = cell.color(wealth.map(|w| w.0).unwrap_or_default());
|
||||||
if lu.0 > match cd.kind {
|
for id in cell.vertices.iter() {
|
||||||
CellKind::Void | CellKind::Sea | CellKind::Beach | CellKind::Dirt | CellKind::Stone => usize::MAX,
|
modified = modified || cols.0[*id] != col;
|
||||||
CellKind::Forest => 100*365/4, // Let's say that a forest takes 100 years to mature
|
cols.0[*id] = col.clone();
|
||||||
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);
|
|
||||||
modified = true;
|
|
||||||
}
|
}
|
||||||
// cd.update();
|
if modified {
|
||||||
let col = cd.color();
|
mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, cols.0.clone());
|
||||||
for id in cd.vertices.iter() {
|
|
||||||
cols.0[*id] = col.clone();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if modified {
|
needs_update.0 = false;
|
||||||
mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, cols.0.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
132
src/map/cells.rs
132
src/map/cells.rs
@ -1,8 +1,14 @@
|
|||||||
|
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,
|
||||||
@ -10,36 +16,112 @@ pub enum CellKind {
|
|||||||
Stone,
|
Stone,
|
||||||
Grass
|
Grass
|
||||||
}
|
}
|
||||||
|
impl CellKind {
|
||||||
#[derive(Debug, Component)]
|
pub fn regen_full_growth_duration(&self) -> Duration {
|
||||||
pub struct CellData {
|
match self {
|
||||||
pub kind: CellKind,
|
CellKind::Sea | CellKind::Beach | CellKind::Dirt | CellKind::Stone => unreachable!(),
|
||||||
pub cid: usize,
|
CellKind::Forest => Duration::from_days(365*100), // Let's say that a forest takes 100 years to mature
|
||||||
z: u8,
|
CellKind::Grass => Duration::from_weeks(7) // Let's say that grass takes 7 weeks to reach its max
|
||||||
pub moisture: u8,
|
|
||||||
pub resource: u8, // How much resource there is (between 0 and 4)
|
|
||||||
pub vertices: Vec<usize>
|
|
||||||
}
|
|
||||||
impl CellData {
|
|
||||||
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] {
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Component)]
|
||||||
|
pub struct Cell {
|
||||||
|
pub kind: CellKind,
|
||||||
|
pub voronoi_id: usize,
|
||||||
|
pub altitude: u8,
|
||||||
|
pub vertices: Vec<usize>
|
||||||
|
}
|
||||||
|
impl Cell {
|
||||||
|
pub fn color(&self, wealth: u8) -> [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 - (self.resource as f32/4.*0.4), 0., 1.],
|
CellKind::Forest => [0., 0.5 - (wealth as f32/255.*0.4), 0., 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::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::Stone => [0.5, 0.5, 0.5, 1.],
|
CellKind::Stone => [0.5, 0.5, 0.5, 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.]
|
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.]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
39
src/map/picking.rs
Normal file
39
src/map/picking.rs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
use bevy::{picking::{backend::{HitData, PointerHits}, pointer::{PointerId, PointerLocation}}, prelude::*, window::PrimaryWindow};
|
||||||
|
use voronoice::Point;
|
||||||
|
|
||||||
|
use super::{CellsEntities, MapMarker, Voronoi};
|
||||||
|
|
||||||
|
pub fn picking_backend(
|
||||||
|
cam: Query<(&Transform, Entity), With<Camera2d>>,
|
||||||
|
window: Query<&Window, With<PrimaryWindow>>,
|
||||||
|
pointers: Query<(&PointerId, &PointerLocation)>,
|
||||||
|
map: Query<(&Voronoi, &CellsEntities, &Transform), With<MapMarker>>,
|
||||||
|
mut output: EventWriter<PointerHits>
|
||||||
|
) {
|
||||||
|
let (cam, cam_id) = cam.single();
|
||||||
|
let window = window.single();
|
||||||
|
let (voronoi, cells_entities, map_pos) = map.single();
|
||||||
|
let mut last_cell = 0;
|
||||||
|
for (id, l) in pointers.iter() {
|
||||||
|
if let Some(mut pos) = l.location().map(|l| l.position) {
|
||||||
|
pos -= window.size()/2.;
|
||||||
|
pos *= cam.scale.xy();
|
||||||
|
pos.x += cam.translation.x;
|
||||||
|
pos.y -= cam.translation.y;
|
||||||
|
if let Some(c) = voronoi.0.cell(last_cell).iter_path(Point { x: pos.x as f64, y: -pos.y as f64 }).last() {
|
||||||
|
last_cell = c;
|
||||||
|
output.send(PointerHits {
|
||||||
|
pointer: *id,
|
||||||
|
picks: vec![(cells_entities.0[c], HitData {
|
||||||
|
camera: cam_id,
|
||||||
|
depth: map_pos.translation.z,
|
||||||
|
position: Some(Vec3 { x: pos.x, y: pos.y, z: map_pos.translation.z }),
|
||||||
|
normal: None
|
||||||
|
})],
|
||||||
|
order: map_pos.translation.z
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
src/time.rs
Normal file
28
src/time.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
}
|
77
src/ui.rs
77
src/ui.rs
@ -1,12 +1,20 @@
|
|||||||
use bevy::prelude::*;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use bevy::{input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::HashMap, window::PrimaryWindow};
|
||||||
|
|
||||||
|
use crate::map::{self, MapMarker};
|
||||||
|
|
||||||
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)
|
||||||
|
.add_systems(Update, zoom_with_scroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
struct PointersDragging(HashMap<PointerId, Vec2>);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MapUIComponent;
|
pub struct MapUIComponent;
|
||||||
|
|
||||||
@ -21,7 +29,68 @@ fn setup(
|
|||||||
justify_content: JustifyContent::Center,
|
justify_content: JustifyContent::Center,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
MapUIComponent
|
PickingBehavior {
|
||||||
));
|
should_block_lower: false,
|
||||||
|
is_hoverable: true
|
||||||
|
},
|
||||||
|
MapUIComponent,
|
||||||
|
PointersDragging(HashMap::new())
|
||||||
|
)).observe(|trigger: Trigger<Pointer<DragStart>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||||
|
let event = trigger.event();
|
||||||
|
// dbg!(event);
|
||||||
|
if event.button == PointerButton::Primary {
|
||||||
|
ptrs.get_mut(event.target).unwrap().0.insert(event.pointer_id, event.pointer_location.position);
|
||||||
|
}
|
||||||
|
}).observe(|trigger: Trigger<Pointer<DragEnd>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||||
|
let event = trigger.event();
|
||||||
|
// dbg!(event);
|
||||||
|
if event.button == PointerButton::Primary {
|
||||||
|
ptrs.get_mut(event.target).unwrap().0.remove(&event.pointer_id);
|
||||||
|
}
|
||||||
|
}).observe(|
|
||||||
|
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_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (old_midpoint-pos).norm());
|
||||||
|
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_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
||||||
|
|
||||||
|
// move camera
|
||||||
|
cam.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.scale.x;
|
||||||
|
cam.translation.y += (new_midpoint.y - old_midpoint.y)*cam.scale.y;
|
||||||
|
|
||||||
|
if ptrs.0.len() > 1 {
|
||||||
|
cam.scale *= old_d_to_midpoint/new_d_to_midpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
// Spawn all ui elements as children of this one
|
// Spawn all ui elements as children of this one
|
||||||
|
}
|
||||||
|
|
||||||
|
fn zoom_with_scroll(
|
||||||
|
mut cam: Query<&mut Transform, With<Camera2d>>,
|
||||||
|
mut ev_scroll: EventReader<MouseWheel>,
|
||||||
|
hover_map: Res<HoverMap>,
|
||||||
|
window: Query<&Window, With<PrimaryWindow>>,
|
||||||
|
map_ui_id: Query<Entity, With<MapUIComponent>>
|
||||||
|
) {
|
||||||
|
let map_ui_id = map_ui_id.single();
|
||||||
|
if hover_map.get(&PointerId::Mouse).and_then(|hovered_ids| hovered_ids.get(&map_ui_id)).is_some() {
|
||||||
|
let window = window.single();
|
||||||
|
let mut cam = cam.single_mut();
|
||||||
|
for ev in ev_scroll.read() {
|
||||||
|
let scale = (cam.scale.x-(ev.y*0.1/window.width().min(window.height()))).clamp(0.0001, 2./window.width().min(window.height()));
|
||||||
|
cam.scale = Vec3::new(scale, scale, scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user