From c53af0485f38a1f5bd843154eb27357a5c0aed11 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Thu, 4 Feb 2021 15:13:39 +0100 Subject: Add matrix transform capabilities back --- src/client/editor.rs | 6 ++++-- src/server/mod.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/client/editor.rs b/src/client/editor.rs index e030558..14f25ef 100644 --- a/src/client/editor.rs +++ b/src/client/editor.rs @@ -192,8 +192,10 @@ impl Editor { } Cargo::AddMapData(_) => unimplemented!(), Cargo::UpdateMapData(_) => unimplemented!(), - Cargo::ApplyMatrix(_) => unimplemented!(), - Cargo::AddIcon(_) | Cargo::AddRoom(_) | Cargo::AddWall(_) => { + Cargo::AddIcon(_) + | Cargo::AddRoom(_) + | Cargo::AddWall(_) + | Cargo::ApplyMatrix(_) => { error!("Packet is only valid in Client -> Server direction") } } diff --git a/src/server/mod.rs b/src/server/mod.rs index 4f95378..d25b799 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -2,7 +2,7 @@ use crate::net::server::ConnectionManager; use crate::net::Cargo; -use crate::world::World; +use crate::world::{Component, World}; use std::io; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr}; use std::sync::atomic::{AtomicBool, Ordering}; @@ -105,7 +105,15 @@ fn start(conn_man: ConnectionManager) -> (JoinHandle<()>, Arc error!("Unable to remove item. No item with id `{}` found.", id); } } - Cargo::ApplyMatrix((_id, _matrix)) => unimplemented!(), + Cargo::ApplyMatrix((id, matrix)) => { + if let Some(room) = world.get_room_mut(id) { + room.as_non_rigid_mut().unwrap().apply_matrix(&matrix); + conn_man.broadcast(Cargo::SetRoom((id, room.clone()))); + } else if let Some(wall) = world.get_wall_mut(id) { + wall.as_non_rigid_mut().unwrap().apply_matrix(&matrix); + conn_man.broadcast(Cargo::SetWall((id, wall.clone()))); + } + } Cargo::AddMapData(_) | Cargo::UpdateMapData(_) => { error!("This packet is not allowed in the client -> server direction"); } -- cgit v1.2.3-70-g09d2