players : Default::default(),
log : Default::default(),
gen : Generation(0),
- max_z: ZCoord(0.),
+ max_z: default(),
};
let name = InstanceName {
if p.nfaces() <= face.into() {
throw!(SpecError::FaceNotFound);
}
- let z = ZCoord(gs.max_z.0 + (i + 1) as f64);
+ let z = gs.max_z.add(i + 1);
let pc = PieceState {
held: None,
zlevel: ZLevel { z, zg: gs.gen },
visible_slotmap_key!{ VisiblePieceId('.') }
#[derive(Debug,Copy,Clone,PartialEq,PartialOrd)]
-#[derive(Serialize,Deserialize)]
+#[derive(Serialize,Deserialize,Default)]
#[serde(into="f64")]
#[serde(try_from="f64")]
-pub struct ZCoord(pub f64);
+pub struct ZCoord(f64);
#[derive(Clone,Serialize,Deserialize,Eq,Ord,PartialEq,PartialOrd)]
#[serde(transparent)]
}
}
+impl ZCoord {
+ pub fn add(&self, v: u32) -> ZCoord {
+ ZCoord(self.0 + (v as f64))
+ }
+}
+
pub trait ClampTable : Sized {
fn clamped(self, range: Self) -> (Self, bool);
}