Network networking
This commit is contained in:
parent
c9a7e071cd
commit
eafc7cfced
14 changed files with 334 additions and 36 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,74 +0,0 @@
|
|||
______________________________
|
||||
Quantum Created by Brian Kent
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
Thanks for Downloading Quantum.
|
||||
|
||||
-Quantum Round
|
||||
-Quantum Round Hollow
|
||||
-Quantum Flat
|
||||
-Quantum Flat Hollow
|
||||
-Quantum Taper
|
||||
|
||||
If you have any questions or comments, you can e-mail me at
|
||||
aefonts[AT]frontiernet[DOT]net
|
||||
|
||||
You can visit my Homepage <ÆNIGMA GAMES & FONTS> at
|
||||
http://www.aenigmafonts.com/
|
||||
|
||||
____________
|
||||
!!! NOTE !!!
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
This font has been updated! I've edited the (BRK) in the font name
|
||||
to just BRK. It seems that Adobe Illustrator and web pages with CSS
|
||||
don't like fonts with ( and ) in their name.
|
||||
|
||||
________________
|
||||
INSTALLING FONTS
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
There's a couple of ways to install Fonts. The 'easy' way to
|
||||
install fonts is to just Unzip/place the font file [.ttf] into your
|
||||
Windows\Fonts directory (I always use this method). If you're unable
|
||||
to do it the 'easy' way, then try to do it this way (for Windows
|
||||
95/98/NT):
|
||||
|
||||
1] Unzip the Font(s) to a folder (or somewhere, just remember where
|
||||
you unzipped it) on your Computer.
|
||||
|
||||
2] Next, click on the START button, then select SETTINGS then
|
||||
CONTROL PANEL.
|
||||
|
||||
3] When the Control Panel Window pops up, Double Click on FONTS.
|
||||
|
||||
4] When the FONTS window pops up, select File then Install New Font...
|
||||
|
||||
5] A Add Fonts window will pop up, just go to the folder that you
|
||||
unzipped the Font(s) to, select the Font(s) and then click on OK.
|
||||
Now the Font(s) are installed.
|
||||
|
||||
Now you can use the Font(s) in programs the utilize Fonts. Make
|
||||
sure that you install the font(s) first, then open up your apps
|
||||
(so the app will recognize the font). Sometimes you'll have to
|
||||
wait until you computer 'auto-refreshes' for programs to recognize
|
||||
fonts (Windows is sometimes slow to do that). You can refresh your
|
||||
computer quicker by going into Windows Explorer -or- My Computer and
|
||||
press F5 (or in the menubar select VIEW then REFRESH).
|
||||
|
||||
|
||||
__________
|
||||
DISCLAIMER
|
||||
¯¯¯¯¯¯¯¯¯¯
|
||||
-The font(s) in this zip file were created by me (Brian Kent). All
|
||||
of my Fonts are Freeware, you can use them any way you want to
|
||||
(Personal use, Commercial use, or whatever).
|
||||
|
||||
-If you have a Font related site and would like to offer my fonts on
|
||||
your site, go right ahead. All I ask is that you keep this text file
|
||||
intact with the Font.
|
||||
|
||||
-You may not Sell or Distribute my Fonts for profit or alter the font
|
||||
file(s) [.ttf .fon] in any way without asking me first. I can be
|
||||
reached at:
|
||||
aefonts[AT]frontiernet[DOT]net
|
||||
|
||||
(make sure you replace the [AT] and [DOT] with the proper characters) .
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#import bevy_pbr::forward_io::VertexOutput
|
||||
|
||||
struct WireframeMaterial {
|
||||
color: vec4<f32>,
|
||||
};
|
||||
|
||||
@group(2) @binding(0)
|
||||
var<uniform> material: WireframeMaterial;
|
||||
@fragment
|
||||
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return material.color;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ use bevy::{
|
|||
};
|
||||
use bevy_matchbox::{matchbox_signaling::SignalingServer, prelude::*};
|
||||
use orthros_network::{
|
||||
generic::EntityID,
|
||||
generic::{EntityID, NetworkObject},
|
||||
starchart::star::{STARS, StarClass, StarInfo, star_diameter_range},
|
||||
};
|
||||
use rand::{
|
||||
|
|
@ -14,15 +14,16 @@ use rand::{
|
|||
distr::{Distribution, Uniform},
|
||||
rng,
|
||||
};
|
||||
use rmp_serde::{Deserializer, Serializer};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
net::{Ipv4Addr, SocketAddrV4},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
const CHANNEL_ID: usize = 0;
|
||||
#[derive(Component)]
|
||||
struct NetworkObject;
|
||||
#[derive(Component)]
|
||||
struct Changed;
|
||||
fn main() {
|
||||
App::new()
|
||||
|
|
@ -44,10 +45,7 @@ fn main() {
|
|||
)
|
||||
.add_systems(
|
||||
Update,
|
||||
(
|
||||
receive_messages,
|
||||
send_message.run_if(on_timer(Duration::from_secs(5))),
|
||||
),
|
||||
(send_message.run_if(on_timer(Duration::from_secs(5))),),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
@ -74,10 +72,10 @@ fn start_signaling_server(mut commands: Commands) {
|
|||
|
||||
fn setup_scene(mut commands: Commands, mut socket: ResMut<MatchboxSocket>) {
|
||||
let mut spawned_ids: HashSet<u32> = HashSet::new();
|
||||
for _ in 0..4 {
|
||||
let x = Uniform::try_from(-2000..2000).unwrap().sample(&mut rng());
|
||||
let z = Uniform::try_from(-8000..8000).unwrap().sample(&mut rng());
|
||||
let star_class: StarClass = match rng().random_range(0..2) {
|
||||
for _ in 0..10 {
|
||||
let x = Uniform::try_from(-200..200).unwrap().sample(&mut rng());
|
||||
let z = Uniform::try_from(-800..800).unwrap().sample(&mut rng());
|
||||
let star_class: StarClass = match rng().random_range(0..3) {
|
||||
0 => StarClass::MType,
|
||||
1 => StarClass::BType,
|
||||
2 => StarClass::GType,
|
||||
|
|
@ -97,7 +95,7 @@ fn setup_scene(mut commands: Commands, mut socket: ResMut<MatchboxSocket>) {
|
|||
transform: Transform::from_xyz(x as f32 / 100.0, z as f32 / 20000.0, z as f32 / 100.0),
|
||||
};
|
||||
|
||||
commands.spawn((StarInfoComp(star_info), NetworkObject, Changed));
|
||||
commands.spawn((NetworkObject::Star(star_info), Changed));
|
||||
let peers: Vec<_> = socket.connected_peers().collect();
|
||||
|
||||
for peer in peers {
|
||||
|
|
@ -109,34 +107,27 @@ fn setup_scene(mut commands: Commands, mut socket: ResMut<MatchboxSocket>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
fn on_client_connect(mut socket: ResMut<MatchboxSocket>, Query<&StarInfo>)
|
||||
fn start_socket(mut commands: Commands) {
|
||||
let socket = MatchboxSocket::new_reliable("ws://localhost:3536/hello");
|
||||
info!("Created socket");
|
||||
commands.insert_resource(socket);
|
||||
}
|
||||
|
||||
fn send_message(mut socket: ResMut<MatchboxSocket>) {
|
||||
let peers: Vec<_> = socket.connected_peers().collect();
|
||||
|
||||
for peer in peers {
|
||||
let message = "Hello";
|
||||
info!("Sending message: {message:?} to {peer}");
|
||||
socket
|
||||
.channel_mut(CHANNEL_ID)
|
||||
.send(message.as_bytes().into(), peer);
|
||||
}
|
||||
}
|
||||
|
||||
fn receive_messages(mut socket: ResMut<MatchboxSocket>) {
|
||||
fn send_message(mut socket: ResMut<MatchboxSocket>, network_objects: Query<&NetworkObject>) {
|
||||
for (peer, state) in socket.update_peers() {
|
||||
info!("{peer}: {state:?}");
|
||||
}
|
||||
|
||||
for (_id, message) in socket.channel_mut(CHANNEL_ID).receive() {
|
||||
match std::str::from_utf8(&message) {
|
||||
Ok(message) => info!("Received message: {message:?}"),
|
||||
Err(e) => error!("Failed to convert message to string: {e}"),
|
||||
let peers: Vec<_> = socket.connected_peers().collect();
|
||||
|
||||
for peer in peers {
|
||||
for network_object in network_objects.iter() {
|
||||
let mut ser_buf: Vec<u8> = Vec::new();
|
||||
network_object.serialize(&mut Serializer::new(&mut ser_buf));
|
||||
info!("Sending message: {ser_buf:?} to {peer}");
|
||||
socket
|
||||
.channel_mut(CHANNEL_ID)
|
||||
.send(ser_buf.as_slice().into(), peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue