1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Make edit mode usable; complete #11

This commit is contained in:
NGnius (Graham)
2025-03-15 11:03:35 -04:00
parent 47eb32056c
commit 6fd4d673ca
40 changed files with 5313 additions and 2162 deletions

View File

@@ -1,6 +1,6 @@
#![allow(dead_code)]
use std::collections::HashMap;
use polariton::operation::Typed;
use polariton::operation::{Dict, Typed};
pub struct CubeInfo<C: Clone> {
pub cpu: u32,
@@ -40,7 +40,12 @@ impl <C: Clone> CubeInfo<C> {
(Typed::Str("LeagueUnlockIndex".into()), Typed::Int(self.league_unlock_index)),
(Typed::Str("DisplayStats".into()), {
let items: Vec<(Typed<C>, Typed<C>)> = self.stats.iter().map(|(key, val)| (Typed::<C>::Str(key.into()), val.to_owned())).collect();
Typed::HashMap(items.into())
//Typed::HashMap(items.into())
Typed::Dict(Dict {
key_ty: polariton::serdes::TypePrefix::Str,
val_ty: polariton::serdes::TypePrefix::Any,
items,
})
}),
(Typed::Str("Description".into()), Typed::Str(self.description.clone().into())),
(Typed::Str("ItemSize".into()), Typed::Int(self.size as i32)),

View File

@@ -24,7 +24,7 @@ pub struct GarageSlotInfo {
}
impl GarageSlotInfo {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
(Typed::Str("numberCubes".into()), Typed::Int(self.cubes as i32)),
@@ -71,7 +71,7 @@ pub struct ControlOptions {
}
impl ControlOptions {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::Arr(Arr {
ty: TypePrefix::Bool, // bool
items: vec![

View File

@@ -11,7 +11,7 @@ pub struct TechTreeNode {
}
impl TechTreeNode {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("mainCubeId".into()), Typed::Str(hex::encode(self.main_cube_id.to_be_bytes()).into())),
(Typed::Str("positionX".into()), Typed::Int(self.position_x)),
@@ -26,7 +26,7 @@ impl TechTreeNode {
].into())
}
pub fn as_transmissible_key_val(&self) -> (Typed, Typed) {
pub fn as_transmissible_key_val<C>(&self) -> (Typed<C>, Typed<C>) {
(Typed::Str(hex::encode(self.main_cube_id.to_be_bytes()).into()), self.as_transmissible())
}
}

View File

@@ -115,7 +115,10 @@ impl WeaponData {
if !self.group_fire_scales.is_empty() {
let typed_arr: Vec<Typed<C>> = self.group_fire_scales.iter().map(|x| Typed::Float(*x)).collect();
out.push((Typed::Str("groupFireScales".into()), Typed::ObjArr(typed_arr.into())));
out.push((Typed::Str("groupFireScales".into()), Typed::Arr(polariton::operation::Arr {
ty: polariton::serdes::TypePrefix::Float,
items: typed_arr,
})));
}
self.mana_cost.map(|x| out.push((Typed::Str("manaCost".into()), Typed::Float(x))));

View File

@@ -12,7 +12,7 @@ pub struct WeaponUpgradeInfo {
}
impl WeaponUpgradeInfo {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::Dict(Dict {
key_ty: TypePrefix::Str, // str
val_ty: TypePrefix::Any, // obj