use std::collections::HashMap; use std::net::SocketAddr; use std::sync::Arc; use rapier2d::prelude::{IntegrationParameters, PhysicsPipeline, IslandManager, BroadPhase, NarrowPhase, ImpulseJointSet, MultibodyJointSet, CCDSolver, EventHandler, PhysicsHooks, RigidBodySet, ColliderSet}; use tokio::sync::mpsc::Sender; use tokio::sync::RwLock; #[derive(Clone)] pub struct ClientManager { pub handlers: Arc>>, pub usernames: Arc>>, pub players: Arc>> } #[derive(Default)] pub struct Player { pub id: u16, pub x: f64, pub y: f64, pub vel_x: f64, pub vel_y: f64, } #[derive(Clone)] pub struct ClientHandler { pub tx: Sender } pub struct PhysicsEngine { pub gravity: Vec, pub integration_parameters: IntegrationParameters, pub pipeline: PhysicsPipeline, pub island_manager: IslandManager, pub broad_phase: BroadPhase, pub narrow_phase: NarrowPhase, pub rigid_body_set: RigidBodySet, pub collider_set: ColliderSet, pub impulse_joint_set: ImpulseJointSet, pub multibody_joint_set: MultibodyJointSet, pub ccd_solver: CCDSolver, } pub enum ClientHandlerMessage { Tick, ChatMessage { from: String, message: String } }