From 92810693747f72e2b81ca8bd5a555262dc352336 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Sat, 31 May 2025 11:38:41 -0400 Subject: [PATCH] Add immediate variant for singleplayer vehicle, misc tweaks --- rc_core/src/persist/combat.rs | 12 +++---- rc_core/src/persist/garage.rs | 6 +++- rc_core/src/persist/user/account_json.rs | 31 +++++++++++++++++-- rc_factory/src/arc/adapter.rs | 8 +++-- .../src/operations/load_ai_robots.rs | 25 --------------- 5 files changed, 46 insertions(+), 36 deletions(-) diff --git a/rc_core/src/persist/combat.rs b/rc_core/src/persist/combat.rs index 21ccab9..a589a36 100644 --- a/rc_core/src/persist/combat.rs +++ b/rc_core/src/persist/combat.rs @@ -227,13 +227,13 @@ fn default_game_modes() -> GameModes { GameModes { battle_arena: GameMode { respawn_heal_duration: 10.0, - respawn_full_heal_duration: 10.0, + respawn_full_heal_duration: 0.5, kill_limit: 0, game_time_m: 20, }, elimination: GameMode { respawn_heal_duration: 10.0, - respawn_full_heal_duration: 10.0, + respawn_full_heal_duration: 0.5, kill_limit: 10, game_time_m: 10, }, @@ -245,7 +245,7 @@ fn default_game_modes() -> GameModes { }, team_deathmatch: GameMode { respawn_heal_duration: 10.0, - respawn_full_heal_duration: 10.0, + respawn_full_heal_duration: 0.5, kill_limit: 10, game_time_m: 10, }, @@ -321,17 +321,17 @@ pub(super) fn default_campaigns() -> super::SingleplayerConfig { vehicles: vec![ super::PrefabVehicle { name: Some("Config your singleplayer!".to_owned()), - username: "NGnius".to_owned(), + username: "NGnius!".to_owned(), id: super::PrefabId::Database { garage: 1 } }, super::PrefabVehicle { name: Some("Config your singleplayer!".to_owned()), - username: "NGram".to_owned(), + username: "NGram!".to_owned(), id: super::PrefabId::Database { garage: 1 } }, super::PrefabVehicle { name: Some("Config your singleplayer!".to_owned()), - username: "NGniusness".to_owned(), + username: "NGniusness!".to_owned(), id: super::PrefabId::Database { garage: 1 } }, ], diff --git a/rc_core/src/persist/garage.rs b/rc_core/src/persist/garage.rs index 64b7dbf..6a71b98 100644 --- a/rc_core/src/persist/garage.rs +++ b/rc_core/src/persist/garage.rs @@ -195,5 +195,9 @@ pub enum PrefabId { Database { garage: u32, }, - // TODO File, Raw + Raw { + cube_data: Vec, + colour_data: Vec, + } + // TODO File } diff --git a/rc_core/src/persist/user/account_json.rs b/rc_core/src/persist/user/account_json.rs index 6a4cd57..6fd669b 100644 --- a/rc_core/src/persist/user/account_json.rs +++ b/rc_core/src/persist/user/account_json.rs @@ -29,7 +29,7 @@ impl AccountProvider { }) } - pub fn fake_user(&self) -> Box + Send + Sync> { + /*pub fn fake_user(&self) -> Box + Send + Sync> { Box::new(UserData { token: super::UserToken { uuid: "fake user!".to_owned(), token: "".to_owned(), refresh_token: "".to_owned() }, account: rc_database::schema::user::Model { @@ -56,7 +56,7 @@ impl AccountProvider { extensions: Default::default(), db: self.db.clone(), }) - } + }*/ } #[async_trait::async_trait] @@ -351,6 +351,33 @@ impl UserData { } } }, + crate::persist::PrefabId::Raw { + cube_data, + colour_data, + } => { + let weapons_guess = weapon_order.guess_weapons(&mut std::io::Cursor::new(&cube_data)); + let weapons_guess = vec![weapons_guess[0], 0, 0]; + let weapon_ranks = weapons_guess.iter().map(|&x| (x, if x == 0 { 0 } else { 1 })).collect(); + crate::data::player_data::PlayerData { + name: username.clone(), + display_name: username.clone(), + mastery: 1, + tier: 1, // FIXME + robot_name: vehicle.name.clone().unwrap_or_else(|| "Raw Robot".to_owned()), + robot_map: cube_data.to_owned(), + team: 1, + has_premium: false, + robot_uuid: uuid_str, + cpu: 420, // FIXME + weapon_order: weapons_guess, + colour_map: colour_data.to_owned(), + is_ai: true, + spawn_effect: "Spawn".to_owned(), + death_effect: "Explosion".to_owned(), + player_rank: 1, + weapon_rank: weapon_ranks, + } + } }; next_id += 1; enemies.push(enemy); diff --git a/rc_factory/src/arc/adapter.rs b/rc_factory/src/arc/adapter.rs index 12cfae3..e482da3 100644 --- a/rc_factory/src/arc/adapter.rs +++ b/rc_factory/src/arc/adapter.rs @@ -11,11 +11,15 @@ impl ArcAdapter { log::debug!("Connecting to Archive of RoboCraft (ARC) vehicle factory database URI: {}", uri); let db = sea_orm::Database::connect(uri).await?; let good_cdn = override_cdn.map(|s| if s.ends_with("/") { s } else { format!("{}/", s) }); - Ok(Self { + let adapter = Self { orm: db, ignore_expiry: show_expired, cdn: good_cdn, - }) + }; + // do query to ensure database is ok + adapter.default_query().one(&adapter.orm).await?; + + Ok(adapter) } fn default_query(&self) -> sea_orm::Select { diff --git a/rc_singleplayer_room/src/operations/load_ai_robots.rs b/rc_singleplayer_room/src/operations/load_ai_robots.rs index a4346cb..5354c64 100644 --- a/rc_singleplayer_room/src/operations/load_ai_robots.rs +++ b/rc_singleplayer_room/src/operations/load_ai_robots.rs @@ -15,31 +15,6 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: let ulock = user.user()?; let mut params = params.to_dict(); params.insert(PARAM_KEY, ulock.singleplayer_robots(factory, weapon_order).await?); - /*let event_tx = user.event_sender(); - let user_bot_data = ulock.slot_by_id(ulock.selected_garage().await.1 as _).await?; - tokio::spawn(async move { - tokio::time::sleep(std::time::Duration::from_secs(20)).await; - log::debug!("Sending singleplayer event"); - let mut spawn_params = std::collections::HashMap::with_capacity(4); - spawn_params.insert(2 /* robot GUID */, user_bot_data.uuid); - spawn_params.insert(3 /* machine model */, user_bot_data.data); - spawn_params.insert(4 /* robot name */, Typed::Str("Robot123".into())); // FIXME - spawn_params.insert(7 /* color model */, user_bot_data.colour_data); - event_tx.send(polariton_server::ToSend::Data { - data: polariton::packet::Data::Event(polariton::operation::Event { code: 3, params: spawn_params.into() }), - encrypt: true, - channel: 0, - reliable: true, - }).unwrap(); - /*let mut update_params = std::collections::HashMap::with_capacity(1); - update_params.insert(6 /* ??? */, Typed::Int(5)); - event_tx.send(polariton_server::ToSend::Data { - data: polariton::packet::Data::Event(polariton::operation::Event { code: 5, params: update_params.into() }), - encrypt: true, - channel: 0, - reliable: true, - }).unwrap();*/ - });*/ Ok(params.into()) }