export type Vec2 = [number, number] // x, y export type PlayerID = number export type ItemID = number export type ItemIndex = number export type TileIndex = number export interface Gamedata { item_names: string[], // Look-up table for ItemIndex tile_names: string[], // Look-up table for TileIndex } export type PacketS = { type: "join", name: string } // You join, sent as first packet. | { type: "position", pos: Vec2, rot: number } // Update your position and rotation in radians (0 is -y) | { type: "interact", pos: Vec2, edge: boolean } // Interact with some tile. edge is true when pressing and false when releasing interact button | { type: "collide", player: PlayerID, force: Vec2 } // Apply force to another player as a result of a collision export type PacketC = { type: "joined", id: PlayerID, data: Gamedata } // You joined | { type: "add_player", id: PlayerID, name: string, hand?: [ItemID, ItemIndex] } // Somebody else joined (or was already in the game) | { type: "remove_player", id: PlayerID } // Somebody left | { type: "position", player: PlayerID, pos: Vec2, rot: number } // Update the position of a players (your own position is included here) | { type: "take_item", item: ItemID, player: PlayerID } // An item was taken from a tile | { type: "put_item", item: ItemID, pos: Vec2 } // An item was put on a tile | { type: "produce_item", id: ItemID, pos: Vec2, kind: ItemIndex } // A tile generated a new item | { type: "consume_item", id: ItemID, pos: Vec2 } // A tile removed an item | { type: "set_active", tile: Vec2, progress?: number } // A tile is doing something. progress goes from 0 to 1, then null when finished | { type: "update_map", pos: Vec2, tile: TileIndex } // A map tile was changed