Files
tect_gen/src/main.rs
T

48 lines
1.4 KiB
Rust
Raw Normal View History

2025-07-17 13:24:36 +03:00
mod basic;
2026-06-18 12:04:53 +03:00
mod seed_automation;
mod plate_automation;
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
use crate::basic::{IntoImage, Table};
use bevy::asset::io::embedded::GetAssetServer;
use bevy::input::keyboard::keyboard_input_system;
use bevy::prelude::*;
use rand::{Rng, RngExt};
use rand_chacha::ChaCha8Rng;
use rand_chacha::rand_core::SeedableRng;
use seed_automation::SeedAutomation;
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
const RECTANGLE_SIDE: f32 = 500.0;
2025-07-17 13:24:36 +03:00
fn main() {
2026-06-18 12:04:53 +03:00
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.insert_resource(Time::<Fixed>::from_hz(1024.0))
.add_systems(Update, keyboard_input_system)
.add_systems(Update, seed_automation::update_automation_seed)
.add_systems(Update, seed_automation::update_automation_view_seed)
.add_systems(Update, plate_automation::update_automation_plate)
.add_systems(Update, plate_automation::update_automation_view_plate)
.run();
2025-07-17 13:24:36 +03:00
}
2026-06-18 12:04:53 +03:00
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
commands.spawn(Camera2d);
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
let handle = images.add(Image::default());
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
let mut shape = Sprite::from_image(handle);
shape.custom_size = Some(Vec2::new(RECTANGLE_SIDE, RECTANGLE_SIDE));
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
let automation = SeedAutomation {
world: Table::new(false, 16),
};
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
commands.spawn((shape, automation));
2025-07-17 13:24:36 +03:00
2026-06-18 12:04:53 +03:00
let seeded_rng = ChaCha8Rng::seed_from_u64(rand::random());
commands.insert_resource(SeededRng(seeded_rng));
2025-07-17 13:24:36 +03:00
}
2026-06-18 12:04:53 +03:00
#[derive(Resource)]
struct SeededRng(ChaCha8Rng);