1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00
Files
ojrc/rc_services_room/src/operations/cube_inventory.rs

18 lines
796 B
Rust
Raw Normal View History

use polariton_server::operations::SimpleFunc;
2025-03-08 17:16:02 -05:00
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
2025-03-30 16:22:25 -04:00
use rc_core::ConfigProvider;
const PARAM_KEY: u8 = 16;
2025-03-30 16:22:25 -04:00
pub(super) fn cube_inv_provider(cubes: &rc_core::ConfigImpl) -> SimpleFunc<16, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
let cube_ids = <rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
2025-03-15 11:03:35 -04:00
SimpleFunc::new(move |params, _| {
let mut params = params.to_dict();
params.insert(PARAM_KEY, Typed::Dict(Dict {
2025-03-08 17:16:02 -05:00
key_ty: TypePrefix::Int, // int
val_ty: TypePrefix::Int, // int
2025-03-15 11:03:35 -04:00
items: cube_ids.iter().map(|id| (Typed::Int(*id as _), Typed::Int(1))).collect()}));
Ok(params.into())
})
}