add aeronet

This commit is contained in:
Mitchell Marino 2026-02-09 15:34:40 -06:00
parent e09b7d2537
commit 25896a5a92
3 changed files with 288 additions and 2 deletions

186
Cargo.lock generated
View File

@ -81,6 +81,71 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aeronet"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "745a8013cf5cf00933422a43ddd500bcdf50e48de2f5ddfa54b89e80ca98b176"
dependencies = [
"aeronet_io",
"aeronet_transport",
"bevy_app",
]
[[package]]
name = "aeronet_io"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f05b43f128690e5eb9636b8a227078b2a4e577450da145d26ea1cd14688d80bc"
dependencies = [
"anyhow",
"bevy_app",
"bevy_ecs",
"bevy_platform",
"bevy_reflect",
"bytes",
"derive_more",
"log",
]
[[package]]
name = "aeronet_replicon"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4970822b3030b79c6dcba0933929176c5310836e67d707cc80cac6d29fe90c5a"
dependencies = [
"aeronet_io",
"aeronet_transport",
"bevy_app",
"bevy_ecs",
"bevy_platform",
"bevy_reflect",
"bevy_replicon",
"bevy_state",
"log",
]
[[package]]
name = "aeronet_transport"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd63172db760f378f31e1d546fc581b79c2ba3f084a9dfe73ce65c07c4527b9b"
dependencies = [
"aeronet_io",
"bevy_app",
"bevy_ecs",
"bevy_platform",
"bevy_reflect",
"bevy_time",
"bit-vec",
"derive_more",
"either",
"log",
"octs",
"ringbuf",
"typesize",
]
[[package]]
name = "ahash"
version = "0.8.12"
@ -173,6 +238,12 @@ dependencies = [
"libc",
]
[[package]]
name = "anyhow"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea"
[[package]]
name = "approx"
version = "0.5.1"
@ -1291,6 +1362,26 @@ dependencies = [
"syn",
]
[[package]]
name = "bevy_replicon"
version = "0.38.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aee12260a021e0d9e4437ba9a325deb4ca05c98ef29d670fc63b366799ecaad0"
dependencies = [
"bevy",
"bitflags 2.10.0",
"bytes",
"deterministic-hash",
"log",
"petgraph",
"postcard",
"serde",
"smallbitvec",
"typeid",
"variadics_please",
"xxhash-rust",
]
[[package]]
name = "bevy_scene"
version = "0.18.0"
@ -1773,6 +1864,9 @@ name = "bytes"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
dependencies = [
"portable-atomic",
]
[[package]]
name = "calloop"
@ -1850,6 +1944,15 @@ dependencies = [
"libloading",
]
[[package]]
name = "cobs"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
dependencies = [
"thiserror 2.0.17",
]
[[package]]
name = "codespan-reporting"
version = "0.12.0"
@ -2198,6 +2301,12 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "deterministic-hash"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11277822c27bde750de02c5dc5159b91e88bf2661a2c1d98106f2fb1c5c6f590"
[[package]]
name = "dispatch"
version = "0.2.0"
@ -3818,6 +3927,15 @@ dependencies = [
"cc",
]
[[package]]
name = "octs"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3beef54705459f4a421ff43b6c9b8381f5b84769e4ae69942783dd8918837b7"
dependencies = [
"bytes",
]
[[package]]
name = "offset-allocator"
version = "0.2.0"
@ -4070,6 +4188,28 @@ dependencies = [
"portable-atomic",
]
[[package]]
name = "postcard"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24"
dependencies = [
"cobs",
"postcard-derive",
"serde",
]
[[package]]
name = "postcard-derive"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0232bd009a197ceec9cc881ba46f727fcd8060a2d8d6a9dde7a69030a6fe2bb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "pp-rs"
version = "0.2.1"
@ -4351,6 +4491,17 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
[[package]]
name = "ringbuf"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe47b720588c8702e34b5979cb3271a8b1842c7cb6f57408efa70c779363488c"
dependencies = [
"crossbeam-utils",
"portable-atomic",
"portable-atomic-util",
]
[[package]]
name = "robust"
version = "1.2.0"
@ -4622,6 +4773,12 @@ dependencies = [
"version_check",
]
[[package]]
name = "smallbitvec"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d31d263dd118560e1a492922182ab6ca6dc1d03a3bf54e7699993f31a4150e3f"
[[package]]
name = "smallvec"
version = "1.15.1"
@ -4844,8 +5001,11 @@ dependencies = [
name = "time_travel"
version = "0.1.0"
dependencies = [
"aeronet",
"aeronet_replicon",
"avian2d",
"bevy",
"bevy_replicon",
]
[[package]]
@ -5029,6 +5189,26 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
[[package]]
name = "typesize"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da66c62c5b7017a2787e77373c03e6a5aafde77a73bff1ff96e91cd2e128179"
dependencies = [
"typesize-derive",
]
[[package]]
name = "typesize-derive"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "536b6812192bda8551cfa0e52524e328c6a951b48e66529ee4522d6c721243d6"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "typewit"
version = "1.14.2"
@ -6094,6 +6274,12 @@ version = "0.8.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f"
[[package]]
name = "xxhash-rust"
version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3"
[[package]]
name = "yazi"
version = "0.2.1"

View File

@ -4,5 +4,8 @@ version = "0.1.0"
edition = "2024"
[dependencies]
aeronet = "0.19.0"
aeronet_replicon = { version = "0.19.0", features = ["client", "server"] }
avian2d = "0.5.0"
bevy = "0.18.0"
bevy_replicon = "0.38.2"

View File

@ -4,10 +4,19 @@ use avian2d::{
math::Vector,
prelude::{Collider, Gravity, RigidBody},
};
use bevy::{camera::ScalingMode, color::palettes::css::GREEN, prelude::*};
use bevy::{
camera::ScalingMode,
color::palettes::css::{GREEN, RED},
input_focus::InputFocus,
prelude::*,
};
pub mod avian;
const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15);
const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25);
const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35);
fn main() {
App::new()
.add_plugins((
@ -19,11 +28,97 @@ fn main() {
))
.add_systems(Startup, setup)
.add_systems(Update, debug_border)
.add_systems(Update, do_menu)
.insert_resource(Gravity(Vector::ZERO))
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
fn do_menu(
mut input_focus: ResMut<InputFocus>,
mut interaction_query: Query<
(
Entity,
&Interaction,
&mut BackgroundColor,
&mut BorderColor,
&mut Button,
&Children,
),
Changed<Interaction>,
>,
mut text_query: Query<&mut Text>,
) {
for (entity, interaction, mut color, mut border_color, mut button, children) in
&mut interaction_query
{
let mut text = text_query.get_mut(children[0]).unwrap();
match *interaction {
Interaction::Pressed => {
input_focus.set(entity);
**text = "Press".to_string();
*color = PRESSED_BUTTON.into();
*border_color = BorderColor::all(RED);
// The accessibility system's only update the button's state when the `Button` component is marked as changed.
button.set_changed();
}
Interaction::Hovered => {
input_focus.set(entity);
**text = "Hover".to_string();
*color = HOVERED_BUTTON.into();
*border_color = BorderColor::all(Color::WHITE);
button.set_changed();
}
Interaction::None => {
input_focus.clear();
**text = "Button".to_string();
*color = NORMAL_BUTTON.into();
*border_color = BorderColor::all(Color::BLACK);
}
}
}
}
fn button(asset_server: &AssetServer) -> impl Bundle {
(
Node {
width: percent(100),
height: percent(100),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},
children![(
Button,
Node {
width: px(150),
height: px(65),
border: UiRect::all(px(5)),
// horizontally center child text
justify_content: JustifyContent::Center,
// vertically center child text
align_items: AlignItems::Center,
border_radius: BorderRadius::MAX,
..default()
},
BorderColor::all(Color::WHITE),
BackgroundColor(Color::BLACK),
children![(
Text::new("Button"),
TextFont {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 33.0,
..default()
},
TextColor(Color::srgb(0.9, 0.9, 0.9)),
TextShadow::default(),
)]
)],
)
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, assets: Res<AssetServer>) {
let mut projection = OrthographicProjection::default_2d();
projection.scaling_mode = ScalingMode::AutoMin {
min_width: 1920.,
@ -49,6 +144,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
RigidBody::Dynamic,
Collider::rectangle(30.0, 30.0),
));
commands.spawn(button(&assets));
}
fn debug_border(mut gizmos: Gizmos) {