How ernwong/crystalorb works
Main Components
• Core Library (Sequencer):
• Located in the /src directory, this is where the bulk of the networking logic exists. Key modules include protocol handling (client.rs and server.rs), time synchronization (clocksync.rs, timestamp.rs, fixed_timestepper.rs), and world simulation (modules under src/world).
• Integration Crates:
• Under /crates, two notable crates are present: “crystalorb-bevy-networking-turbulence” and “crystalorb-mock-network”.
• These provide concrete implementations or examples of integrating the core library with different networking layers (e.g., Bevy-based networking) and mock networking for testing.
• Examples:
• The /examples/demo and the standalone example (examples/standalone.rs) serve as templates and real-world usage scenarios that illustrate how the core library interacts with external components like a physics engine (Rapier, as mentioned in the README).
• These examples are useful to showcase the flow from client input to simulation and network synchronization.
• Testing Framework:
• The /tests directory shows various tests validating critical components like clock synchronization, state initialization, and determinism.
• Although not a runtime component, this directs you to consider how validation and isolation between components might be represented in the design.
Interactions and Data Flow
• Client-Server Interaction:
• From the /src files, particularly src/client.rs and src/server.rs, model the bidirectional flow.
• Clients apply local input immediately and then communicate with the server module, which runs the simulation authoritatively.
• Time and State Management:
• The clocksync and timestamp modules indicate a mechanism for aligning game simulation frames across clients and the server.
• Integration Points for Networking and Physics:
• Clearly the external dependencies where your own networking layer or a physics engine (e.g., Rapier via the demo) is plugged in.
• Use labels like “Networking Layer” and “Physics Engine” to emphasize that CrystalOrb acts as a mediator for these functionalities.
Architectural Choices and Patterns
• Modularity via Rust Workspaces:
• The multiple crates under /crates and /examples show a separation-of-concerns design where the core library is independent of implementation details.
• Sequencer Pattern:
• CrystalOrb works as a sequencer that synchronizes and sequences game states between predicted local states and authoritative server states.
• Use of Unstable Rust Features:
• Although not a runtime interaction, note that the project leverages advanced Rust features (e.g., generic associated types) which informs the design’s extensibility and performance characteristics.
Final Checklist
• Clearly delineate the main components:
• Client Module (input handling, prediction, interpolation)
• Server Module (authoritative simulation, reconciliation)
• Core Synchronization Logic (time, clocksync, fixed timestepper)
• World/Simulation Modules (state representation and update logic)
• Integration Points (crates for different networking layers, demos)
• Notes on external dependencies (networking layer, physics engine) as separate components.