use bevy::asset::Asset; use bevy::color::Color; use crate::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Asset, TypePath, Component, Serialize, Clone, Debug)] #[require( RigidBody::Dynamic, Replicated, )] pub struct Planet { pub name: String, pub sprite: String, pub indicator_sprite: Option, pub radius: f32, pub mass: f32, pub default_transform: [f32; 3], pub planet_resource: Option, pub special_sprite_properties: Option, pub orbit: Option } #[derive(Component, Serialize, Deserialize)] #[require( RigidBody::Static, Replicated, )] pub struct PlanetSpring { pub name: String } #[derive(Component, Serialize, Deserialize)] #[require( Replicated, )] pub struct PlanetSpringJoint { pub name: String } #[derive(Deserialize, TypePath, Serialize, Clone, Debug)] pub struct PlanetResource { pub name: String, pub color: Color, pub mining_speed: f32, // resource / second } #[derive(Deserialize, TypePath, Serialize, Clone, Debug)] pub struct OrbitData { pub orbiting: String, pub eccentricity: f32, pub period: f32 } #[derive(Deserialize, TypePath, Serialize, Clone, Debug)] pub enum SpecialSpriteProperties { ForceColor(Color), } #[derive(Bundle)] pub struct PlanetBundle { pub planet: Planet, pub transform: Transform, pub collider: Collider, pub mass: Mass } #[derive(Deserialize, Asset, TypePath)] pub struct PlanetConfigCollection { pub planets: Vec, pub orbit: OrbitConfig } #[derive(Deserialize, Asset, TypePath, Clone, Debug)] pub struct OrbitConfig { pub planet_spring_compliance: f32 }