mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Get enemies spawning in singleplayer #23
This commit is contained in:
1 parent
1a7400d3d9
commit
50cc0cc3a9
19 files changed
+327
-54
No files matched your search
@@ -1,26 +1,29 @@
|
||||
use polariton::operation::{ParameterTable, Typed, OperationResponse};
|
||||
use polariton::operation::{ParameterTable, OperationResponse};
|
||||
|
||||
const CODE: u8 = 1;
|
||||
|
||||
const PARAM_KEY: u8 = 8;
|
||||
|
||||
pub(super) fn tdm_machines_provider() -> AiRobots {
|
||||
AiRobots
|
||||
pub(super) fn tdm_machines_provider(factory: &std::sync::Arc<rc_core::factory::Factory>, weapon_order: std::sync::Arc<rc_core::cubes::WeaponListParser>) -> AiRobots {
|
||||
AiRobots {
|
||||
factory: factory.to_owned(),
|
||||
weapon_parser: weapon_order,
|
||||
}
|
||||
}
|
||||
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy) -> Result<ParameterTable<()>, i16> {
|
||||
async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory: &rc_core::factory::Factory, weapon_order: &rc_core::cubes::WeaponListParser) -> Result<ParameterTable<()>, i16> {
|
||||
let ulock = user.user()?;
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, ulock.singleplayer_robots().await?);
|
||||
let event_tx = user.event_sender();
|
||||
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 */, Typed::Str("1337_1337".into()));
|
||||
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("RE_robot_spawn_name0".into())); // FIXME
|
||||
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() }),
|
||||
@@ -36,18 +39,21 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy) -> Result
|
||||
channel: 0,
|
||||
reliable: true,
|
||||
}).unwrap();*/
|
||||
});
|
||||
});*/
|
||||
Ok(params.into())
|
||||
}
|
||||
|
||||
pub struct AiRobots;
|
||||
pub struct AiRobots {
|
||||
factory: std::sync::Arc<rc_core::factory::Factory>,
|
||||
weapon_parser: std::sync::Arc<rc_core::cubes::WeaponListParser>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl polariton_server::operations::Operation<()> for AiRobots {
|
||||
type User = crate::UserTy;
|
||||
|
||||
async fn handle_async(&self, params: ParameterTable<()>, user: &Self::User) -> OperationResponse<()> {
|
||||
polariton_server::operations::result_to_op_resp::<CODE, ()>(do_handling(params, user).await)
|
||||
polariton_server::operations::result_to_op_resp::<CODE, ()>(do_handling(params, user, self.factory.as_ref(), self.weapon_parser.as_ref()).await)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ mod load_ai_robots;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler() -> OperationsHandler<crate::UserTy> {
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::<crate::UserTy>::new()
|
||||
.modify(rc_core::polariton::OpIdCopy)
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
.add(eac::EacChallengeIgnorer)
|
||||
.add(load_ai_robots::tdm_machines_provider())
|
||||
.add(load_ai_robots::tdm_machines_provider(&init_ctx.factory, init_ctx.parsers.weapon_order()))
|
||||
//.add(polariton_server::operations::Ack::<33, _>::default()) // get user clan info (this is equivalent to not being in a clan)
|
||||
}
|
||||
Reference in new issue
Block a user