mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 06:48:43 -06:00
wip
This commit is contained in:
parent
e96ae90b1d
commit
f88e2733f3
|
@ -5,3 +5,4 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kubi-shared = { path = "../kubi-shared" }
|
kubi-shared = { path = "../kubi-shared" }
|
||||||
|
kubi-udp = { path = "../kubi-udp" }
|
||||||
|
|
|
@ -12,24 +12,18 @@ pub enum ClientToServerMessage {
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
},
|
},
|
||||||
PositionChanged {
|
PositionChanged {
|
||||||
client_id: u8,
|
|
||||||
secret: u32,
|
|
||||||
position: Vec3Arr,
|
position: Vec3Arr,
|
||||||
|
velocity: Vec3Arr,
|
||||||
direction: QuatArr,
|
direction: QuatArr,
|
||||||
},
|
},
|
||||||
ChunkRequest {
|
ChunkRequest {
|
||||||
client_id: u8,
|
|
||||||
secret: u32,
|
|
||||||
chunk: IVec3Arr,
|
chunk: IVec3Arr,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Encode, Decode)]
|
#[derive(Encode, Decode)]
|
||||||
pub enum ServerToClientMessage {
|
pub enum ServerToClientMessage {
|
||||||
ServerHello {
|
ServerHello,
|
||||||
client_id: u8,
|
|
||||||
secret: u32,
|
|
||||||
},
|
|
||||||
ServerFuckOff {
|
ServerFuckOff {
|
||||||
reason: String,
|
reason: String,
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kubi-shared = { path = "../kubi-shared" }
|
kubi-shared = { path = "../kubi-shared" }
|
||||||
|
kubi-udp = { path = "../kubi-udp", optional = true }
|
||||||
glium = "0.32"
|
glium = "0.32"
|
||||||
glam = { version = "0.22", features = ["debug-glam-assert", "fast-math"] }
|
glam = { version = "0.22", features = ["debug-glam-assert", "fast-math"] }
|
||||||
image = { version = "0.24", default_features = false, features = ["png"] }
|
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 glam::vec3;
|
||||||
|
use state::GameState;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
mod logging;
|
mod logging;
|
||||||
|
|
||||||
pub(crate) mod rendering;
|
pub(crate) mod rendering;
|
||||||
pub(crate) mod world;
|
pub(crate) mod world;
|
||||||
pub(crate) mod player;
|
pub(crate) mod player;
|
||||||
|
@ -33,6 +33,8 @@ pub(crate) mod cursor_lock;
|
||||||
pub(crate) mod control_flow;
|
pub(crate) mod control_flow;
|
||||||
pub(crate) mod state;
|
pub(crate) mod state;
|
||||||
pub(crate) mod gui;
|
pub(crate) mod gui;
|
||||||
|
pub(crate) mod networking;
|
||||||
|
pub(crate) mod init;
|
||||||
|
|
||||||
use world::{
|
use world::{
|
||||||
init_game_world,
|
init_game_world,
|
||||||
|
@ -63,6 +65,7 @@ use block_placement::block_placement_system;
|
||||||
use delta_time::{DeltaTime, init_delta_time};
|
use delta_time::{DeltaTime, init_delta_time};
|
||||||
use cursor_lock::{insert_lock_state, update_cursor_lock_state, lock_cursor_now};
|
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 control_flow::{exit_on_esc, insert_control_flow_unique, SetControlFlow};
|
||||||
|
use init::initialize_from_args;
|
||||||
|
|
||||||
fn startup() -> Workload {
|
fn startup() -> Workload {
|
||||||
(
|
(
|
||||||
|
@ -70,6 +73,7 @@ fn startup() -> Workload {
|
||||||
load_prefabs,
|
load_prefabs,
|
||||||
init_simple_box_buffers,
|
init_simple_box_buffers,
|
||||||
insert_lock_state,
|
insert_lock_state,
|
||||||
|
initialize_from_args,
|
||||||
lock_cursor_now,
|
lock_cursor_now,
|
||||||
init_input,
|
init_input,
|
||||||
init_game_world,
|
init_game_world,
|
||||||
|
@ -151,7 +155,7 @@ fn main() {
|
||||||
last_update = now;
|
last_update = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Run update workflow
|
//Run update workflows
|
||||||
world.run_workload(update).unwrap();
|
world.run_workload(update).unwrap();
|
||||||
|
|
||||||
//Start rendering (maybe use custom views for this?)
|
//Start rendering (maybe use custom views for this?)
|
||||||
|
|
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;
|
use shipyard::Unique;
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique, EnumIter)]
|
||||||
|
#[track(All)]
|
||||||
pub enum GameState {
|
pub enum GameState {
|
||||||
Connecting,
|
Connecting,
|
||||||
LoadingWorld,
|
LoadingWorld,
|
||||||
InGame,
|
InGame
|
||||||
}
|
|
||||||
|
|
||||||
fn insert_default_state(
|
|
||||||
|
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue