aboutsummaryrefslogtreecommitdiff
path: root/src/net/cargo.rs
blob: 6e6ee41aea16492543e5ac6174ec60ab95f71f36 (plain) (blame)
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
38
//! The cargo is information actually concerning the inner workings of graf karto,
//! as opposed to the inner workings of the network library.

use crate::world::{Icon, Room, Wall, World};
use nalgebra::Matrix3;
use serde::{Deserialize, Serialize};

/// Packets sent oven the network will carry this cargo to inform on what the client needs or the
/// server wants.
#[derive(Debug, Deserialize, Serialize)]
pub enum Cargo {
    /// Client -> Server: Request to add an icon to the map
    AddIcon(Icon),
    /// Client -> Server: Request to add a room to the map
    AddRoom(Room),
    /// Client -> Server: Request to add a wall to the map
    AddWall(Wall),
    /// Client <-> Server: Update the info of the icon with the given id.
    /// Server -> Client can also create an item with this id.
    SetIcon((usize, Icon)),
    /// Client <-> Server: Update the info of the room with the given id.
    /// Server -> Client can also create an item with this id.
    SetRoom((usize, Room)),
    /// Client <-> Server: Update the info of the wall with the given id.
    /// Server -> Client can also create an item with this id.
    SetWall((usize, Wall)),
    /// Client -> Server: Request to apply the given matrix to the item with the provided id.
    /// If the matrix cannot be applied to an item with the given id, it will do nothing.
    ApplyMatrix((usize, Matrix3<f64>)),
    /// Client <-> Server: Clear all data from the world.
    ClearAll,
    /// Client <-> Server: Remove the item with the given id.
    Remove(usize),
    /// Server -> Client: Add all of the data additively to the map
    AddMapData(World),
    /// Server -> Client: Clear the current map data of the client and replace it with this.
    UpdateMapData(World),
}