feat(simulation): add input processing, snapshot gen, and game loop

Implements the full server-side tick pipeline:
- process_player_input drains InputQueue, converts PlayerActions to
  MoveIntent components or pause/unpause toggles
- generate_snapshot builds ObserverSnapshot from ECS state with
  render coordinate conversion
- receive_bridge_inputs/send_bridge_snapshot handle bridge I/O with
  graceful disconnect detection via ServerRunning resource
- main.rs now accepts TCP connections and runs a proper game loop
- PlayerCharacter marker, Player EntityKind, SnapshotBuffer resource

Closes server side of #81, #82, #83.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 21:01:28 +01:00
co-authored by Claude Opus 4.6
parent 1b0e514560
commit 7864bfdf7d
7 changed files with 397 additions and 10 deletions
+27 -4
View File
@@ -4,7 +4,9 @@
use bevy_app::prelude::*;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use settled_reach_server::bridge::BridgePlugin;
use settled_reach_server::bridge::tcp::TcpBridge;
use settled_reach_server::bridge::{BridgePlugin, BridgeResource, ServerRunning};
use settled_reach_server::simulation::movement::{PlayerCharacter, TilePosition, WalkabilityMap};
use settled_reach_server::simulation::SimulationPlugin;
fn main() {
@@ -17,15 +19,36 @@ fn main() {
.with(tracing_subscriber::fmt::layer())
.init();
let addr = std::env::args()
.nth(1)
.or_else(|| std::env::var("SR_ADDR").ok())
.unwrap_or_else(|| "127.0.0.1:9876".to_string());
tracing::info!("The Settled Reach - Simulation Server starting");
tracing::info!("Waiting for client connection on {}", addr);
let bridge = TcpBridge::accept(&addr).expect("Failed to accept client connection");
tracing::info!("Client connected, initializing simulation");
// Create the bevy App and add plugins
let mut app = App::new();
app.add_plugins(SimulationPlugin);
app.add_plugins(BridgePlugin);
app.insert_resource(BridgeResource::new(bridge));
app.insert_resource(WalkabilityMap::new(32, 32, 1));
app.world_mut()
.spawn((PlayerCharacter, TilePosition::new(16, 16, 0)));
// Single tick for smoke verification; real game loop in phase 2
app.update();
tracing::info!("Simulation initialized, entering game loop");
tracing::info!("Simulation server update complete");
// Game loop: run until client disconnects
loop {
app.update();
// Check ServerRunning resource
if !app.world().resource::<ServerRunning>().0 {
break;
}
}
tracing::info!("Simulation server shutting down");
}