crystalorb-mock-network

Provides an implementation of crystalorb::network_recource::NetworkResource that works offline, backed using VecDeque, allowing CrystalOrb to work offline for demo and testing purposes.

Usage

```rust use crystalorbmocknetwork::MockNetwork; use crystalorb_demo::DemoWorld; use crystalorb::{client::Client, server::Server, Config};

let (mut servernet, (mut client1net, mut client2net)) = MockNetwork::newmock_network::();

let client1 = Client::::new(Config::default()); let client2 = Client::::new(Config::default()); let server = Server::::new(Config::default(), 0.0);

// You need to manually call connect. client1net.connect(); client2net.connect();

// (You can also simulate a disconnection later on) // client1net.disconnect(); // client2net.disconnect();

// (You can also set the latency of each connection) // client1net.setdelay(numberofsecondsas_f64);

// Later, in your update loop: fn updateloop( deltaseconds: f64, secondssincestartup: f64, client1: &mut Client, client2: &mut Client, server: &mut Server, client1net: &mut MockNetwork, client2net: &mut MockNetwork, servernet: &mut MockNetwork, ) { // You can then use these network resource instances to update // the crystalorb clients and server. client1.update(deltaseconds, secondssincestartup, client1net); client2.update(deltaseconds, secondssincestartup, client2net); server.update(deltaseconds, secondssincestartup, server_net);

// Call the `tick` method to simulate the flow of messages.
// If you don't call `tick`, then no messages will be able to pass through the network.
client_1_net.tick(delta_seconds);
client_2_net.tick(delta_seconds);
server_net.tick(delta_seconds);

} ```