mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add immediate variant for singleplayer vehicle, misc tweaks
This commit is contained in:
@@ -227,13 +227,13 @@ fn default_game_modes() -> GameModes {
|
|||||||
GameModes {
|
GameModes {
|
||||||
battle_arena: GameMode {
|
battle_arena: GameMode {
|
||||||
respawn_heal_duration: 10.0,
|
respawn_heal_duration: 10.0,
|
||||||
respawn_full_heal_duration: 10.0,
|
respawn_full_heal_duration: 0.5,
|
||||||
kill_limit: 0,
|
kill_limit: 0,
|
||||||
game_time_m: 20,
|
game_time_m: 20,
|
||||||
},
|
},
|
||||||
elimination: GameMode {
|
elimination: GameMode {
|
||||||
respawn_heal_duration: 10.0,
|
respawn_heal_duration: 10.0,
|
||||||
respawn_full_heal_duration: 10.0,
|
respawn_full_heal_duration: 0.5,
|
||||||
kill_limit: 10,
|
kill_limit: 10,
|
||||||
game_time_m: 10,
|
game_time_m: 10,
|
||||||
},
|
},
|
||||||
@@ -245,7 +245,7 @@ fn default_game_modes() -> GameModes {
|
|||||||
},
|
},
|
||||||
team_deathmatch: GameMode {
|
team_deathmatch: GameMode {
|
||||||
respawn_heal_duration: 10.0,
|
respawn_heal_duration: 10.0,
|
||||||
respawn_full_heal_duration: 10.0,
|
respawn_full_heal_duration: 0.5,
|
||||||
kill_limit: 10,
|
kill_limit: 10,
|
||||||
game_time_m: 10,
|
game_time_m: 10,
|
||||||
},
|
},
|
||||||
@@ -321,17 +321,17 @@ pub(super) fn default_campaigns() -> super::SingleplayerConfig {
|
|||||||
vehicles: vec![
|
vehicles: vec![
|
||||||
super::PrefabVehicle {
|
super::PrefabVehicle {
|
||||||
name: Some("Config your singleplayer!".to_owned()),
|
name: Some("Config your singleplayer!".to_owned()),
|
||||||
username: "NGnius".to_owned(),
|
username: "NGnius!".to_owned(),
|
||||||
id: super::PrefabId::Database { garage: 1 }
|
id: super::PrefabId::Database { garage: 1 }
|
||||||
},
|
},
|
||||||
super::PrefabVehicle {
|
super::PrefabVehicle {
|
||||||
name: Some("Config your singleplayer!".to_owned()),
|
name: Some("Config your singleplayer!".to_owned()),
|
||||||
username: "NGram".to_owned(),
|
username: "NGram!".to_owned(),
|
||||||
id: super::PrefabId::Database { garage: 1 }
|
id: super::PrefabId::Database { garage: 1 }
|
||||||
},
|
},
|
||||||
super::PrefabVehicle {
|
super::PrefabVehicle {
|
||||||
name: Some("Config your singleplayer!".to_owned()),
|
name: Some("Config your singleplayer!".to_owned()),
|
||||||
username: "NGniusness".to_owned(),
|
username: "NGniusness!".to_owned(),
|
||||||
id: super::PrefabId::Database { garage: 1 }
|
id: super::PrefabId::Database { garage: 1 }
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -195,5 +195,9 @@ pub enum PrefabId {
|
|||||||
Database {
|
Database {
|
||||||
garage: u32,
|
garage: u32,
|
||||||
},
|
},
|
||||||
// TODO File, Raw
|
Raw {
|
||||||
|
cube_data: Vec<u8>,
|
||||||
|
colour_data: Vec<u8>,
|
||||||
|
}
|
||||||
|
// TODO File
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl AccountProvider {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fake_user<C: Clone>(&self) -> Box<dyn super::User<C> + Send + Sync> {
|
/*pub fn fake_user<C: Clone>(&self) -> Box<dyn super::User<C> + Send + Sync> {
|
||||||
Box::new(UserData {
|
Box::new(UserData {
|
||||||
token: super::UserToken { uuid: "fake user!".to_owned(), token: "".to_owned(), refresh_token: "".to_owned() },
|
token: super::UserToken { uuid: "fake user!".to_owned(), token: "".to_owned(), refresh_token: "".to_owned() },
|
||||||
account: rc_database::schema::user::Model {
|
account: rc_database::schema::user::Model {
|
||||||
@@ -56,7 +56,7 @@ impl AccountProvider {
|
|||||||
extensions: Default::default(),
|
extensions: Default::default(),
|
||||||
db: self.db.clone(),
|
db: self.db.clone(),
|
||||||
})
|
})
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[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;
|
next_id += 1;
|
||||||
enemies.push(enemy);
|
enemies.push(enemy);
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ impl ArcAdapter {
|
|||||||
log::debug!("Connecting to Archive of RoboCraft (ARC) vehicle factory database URI: {}", uri);
|
log::debug!("Connecting to Archive of RoboCraft (ARC) vehicle factory database URI: {}", uri);
|
||||||
let db = sea_orm::Database::connect(uri).await?;
|
let db = sea_orm::Database::connect(uri).await?;
|
||||||
let good_cdn = override_cdn.map(|s| if s.ends_with("/") { s } else { format!("{}/", s) });
|
let good_cdn = override_cdn.map(|s| if s.ends_with("/") { s } else { format!("{}/", s) });
|
||||||
Ok(Self {
|
let adapter = Self {
|
||||||
orm: db,
|
orm: db,
|
||||||
ignore_expiry: show_expired,
|
ignore_expiry: show_expired,
|
||||||
cdn: good_cdn,
|
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<super::entities::robot_metadata::Entity> {
|
fn default_query(&self) -> sea_orm::Select<super::entities::robot_metadata::Entity> {
|
||||||
|
|||||||
@@ -15,31 +15,6 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
|||||||
let ulock = user.user()?;
|
let ulock = user.user()?;
|
||||||
let mut params = params.to_dict();
|
let mut params = params.to_dict();
|
||||||
params.insert(PARAM_KEY, ulock.singleplayer_robots(factory, weapon_order).await?);
|
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())
|
Ok(params.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user