mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
wip
This commit is contained in:
parent
e96ae90b1d
commit
f88e2733f3
|
@ -5,3 +5,4 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-udp = { path = "../kubi-udp" }
|
||||
|
|
|
@ -12,24 +12,18 @@ pub enum ClientToServerMessage {
|
|||
password: Option<String>,
|
||||
},
|
||||
PositionChanged {
|
||||
client_id: u8,
|
||||
secret: u32,
|
||||
position: Vec3Arr,
|
||||
velocity: Vec3Arr,
|
||||
direction: QuatArr,
|
||||
},
|
||||
ChunkRequest {
|
||||
client_id: u8,
|
||||
secret: u32,
|
||||
chunk: IVec3Arr,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode)]
|
||||
pub enum ServerToClientMessage {
|
||||
ServerHello {
|
||||
client_id: u8,
|
||||
secret: u32,
|
||||
},
|
||||
ServerHello,
|
||||
ServerFuckOff {
|
||||
reason: String,
|
||||
},
|
||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-udp = { path = "../kubi-udp", optional = true }
|
||||
glium = "0.32"
|
||||
glam = { version = "0.22", features = ["debug-glam-assert", "fast-math"] }
|
||||
image = { version = "0.24", default_features = false, features = ["png"] }
|
||||
|
|
22
kubi/src/init.rs
Normal file
22
kubi/src/init.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use std::net::SocketAddr;
|
||||
use shipyard::AllStoragesView;
|
||||
use std::env;
|
||||
use crate::{
|
||||
networking::{GameType, ServerAddress},
|
||||
state::GameState
|
||||
};
|
||||
|
||||
pub fn initialize_from_args(
|
||||
all_storages: AllStoragesView,
|
||||
) {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() > 1 {
|
||||
let address = args[1].parse::<SocketAddr>().expect("invalid address");
|
||||
all_storages.add_unique(GameType::Muliplayer);
|
||||
all_storages.add_unique(GameState::Connecting);
|
||||
all_storages.add_unique(ServerAddress(address));
|
||||
} else {
|
||||
all_storages.add_unique(GameType::Singleplayer);
|
||||
all_storages.add_unique(GameState::LoadingWorld);
|
||||
}
|
||||
}
|
|
@ -13,10 +13,10 @@ use glium::{
|
|||
}
|
||||
};
|
||||
use glam::vec3;
|
||||
use state::GameState;
|
||||
use std::time::Instant;
|
||||
|
||||
mod logging;
|
||||
|
||||
pub(crate) mod rendering;
|
||||
pub(crate) mod world;
|
||||
pub(crate) mod player;
|
||||
|
@ -33,6 +33,8 @@ pub(crate) mod cursor_lock;
|
|||
pub(crate) mod control_flow;
|
||||
pub(crate) mod state;
|
||||
pub(crate) mod gui;
|
||||
pub(crate) mod networking;
|
||||
pub(crate) mod init;
|
||||
|
||||
use world::{
|
||||
init_game_world,
|
||||
|
@ -63,6 +65,7 @@ use block_placement::block_placement_system;
|
|||
use delta_time::{DeltaTime, init_delta_time};
|
||||
use cursor_lock::{insert_lock_state, update_cursor_lock_state, lock_cursor_now};
|
||||
use control_flow::{exit_on_esc, insert_control_flow_unique, SetControlFlow};
|
||||
use init::initialize_from_args;
|
||||
|
||||
fn startup() -> Workload {
|
||||
(
|
||||
|
@ -70,6 +73,7 @@ fn startup() -> Workload {
|
|||
load_prefabs,
|
||||
init_simple_box_buffers,
|
||||
insert_lock_state,
|
||||
initialize_from_args,
|
||||
lock_cursor_now,
|
||||
init_input,
|
||||
init_game_world,
|
||||
|
@ -151,9 +155,9 @@ fn main() {
|
|||
last_update = now;
|
||||
}
|
||||
|
||||
//Run update workflow
|
||||
//Run update workflows
|
||||
world.run_workload(update).unwrap();
|
||||
|
||||
|
||||
//Start rendering (maybe use custom views for this?)
|
||||
let target = {
|
||||
let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
|
|
12
kubi/src/networking.rs
Normal file
12
kubi/src/networking.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use std::net::SocketAddr;
|
||||
|
||||
use shipyard::Unique;
|
||||
|
||||
#[derive(Unique, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GameType {
|
||||
Singleplayer,
|
||||
Muliplayer
|
||||
}
|
||||
|
||||
#[derive(Unique, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ServerAddress(pub SocketAddr);
|
|
@ -1,14 +1,10 @@
|
|||
use strum::EnumIter;
|
||||
use shipyard::Unique;
|
||||
|
||||
#[derive(Unique)]
|
||||
#[derive(Unique, EnumIter)]
|
||||
#[track(All)]
|
||||
pub enum GameState {
|
||||
Connecting,
|
||||
LoadingWorld,
|
||||
InGame,
|
||||
}
|
||||
|
||||
fn insert_default_state(
|
||||
|
||||
) {
|
||||
|
||||
InGame
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue