~starkingdoms/starkingdoms

ref: 144af6a353933efbedcbfaa3b08db3c52c12dcaf starkingdoms/crates/unified/src/ship_editor/mod.rs -rw-r--r-- 941 bytes
144af6a3ghostly_zsh chore: move ship editor to unified codebase a day ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
pub mod ui;
pub mod input;
pub mod plugins;

use crate::client::colors;
use crate::prelude::*;
use crate::ship_editor::input::input_plugin;
use crate::ship_editor::ui::ui_plugin;

pub struct ShipEditorPlugin;

impl Plugin for ShipEditorPlugin {
    fn build(&self, app: &mut App) {
        app
            .add_systems(Startup, setup)
            .add_plugins(input_plugin)
            .add_plugins(ui_plugin);
    }
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands.insert_resource(ClearColor(colors::BASE));
    commands.spawn((
        Camera2d::default(),
        Transform::from_xyz(0.0, 0.0, 0.0),
    ));
    let rectangle = meshes.add(Rectangle::new(50.0, 50.0));
    commands.spawn((
        Mesh2d(rectangle),
        MeshMaterial2d(materials.add(Color::linear_rgb(0.0, 0.0, 0.0))),
        Transform::from_xyz(0.0, 0.0, 0.0)
    ));
}