use bevy_ecs::{bundle::Bundle, component::Component, event::Event, system::Resource};
use nalgebra::{Matrix4, Rotation2, Scale3, Translation3};
use starkingdoms_common::packet::Packet;
#[derive(Component, Debug)]
pub struct Texture {
pub name: String,
}
#[derive(Component, Debug)]
pub struct Transform {
pub translation: Translation3<f32>,
pub rotation: Rotation2<f32>,
pub scale: Scale3<f32>,
}
impl Transform {
pub fn to_matrix(&self) -> Matrix4<f32> {
self.translation.to_homogeneous() * self.rotation.to_homogeneous().to_homogeneous() * self.scale.to_homogeneous()
}
}
#[derive(Bundle, Debug)]
pub struct SpriteBundle {
pub transform: Transform,
pub texture: Texture,
}
#[derive(Resource, Debug)]
pub struct Camera {
pub x: f32,
pub y: f32,
pub zoom: f32,
pub width: u32, // screen width (these are for aspect ratio)
pub height: u32, // screen height
}
#[derive(Component, Debug, Clone, Copy)]
pub struct Player;
#[derive(Component, Debug, Clone, Copy)]
pub struct Planet;
#[derive(Component, Debug, Clone, Copy)]
pub struct Part;
#[derive(Component, Debug, Clone, Copy)]
pub struct ServerId(pub u32);
#[derive(Event, Clone, PartialEq)]
pub struct SendPacket(pub Packet);
#[derive(Event, Clone, PartialEq)]
pub struct RecvPacket(pub Packet);